SD/MMC mod

From DD-WRT Wiki

Revision as of 06:48, 9 July 2007 by Iron (Talk | contribs)
Jump to: navigation, search

Contents

SD/MMC Mod for the Buffalo WHR-G54S

This is a work in progress...


1. Introduction

This tutorial guides you through adding a [http://en.wikipedia.org/wiki/Secure_Digital_card SD]/MMC interface to the Buffalo WHR-G54S router and gives some general information and tips that help you to do the same with other routers. Applying this modification to the Buffalo WHR-HP-G54S will be very similar.

The modification will allow you to add non-volatile memory to your router. I recommend using a SD/MMC card up to 1GB. Some users reported that they got 2GB working, but both my 2GB cards failed to work. This might be solved in future with an updated MMC driver, but probably my SD cards are to blaim.

This modification should also work with MMC cards, but the here used communication protocol is optional for MMC cards. It is only required for SD and mini-SD cards. So start with a SD card of 1GB or less.

1GB does perhaps not sound like a lot, but for this application it is huge!

So what can you do with this added storage:

1) Store your own custom programs, scripts and package (standard or optware)

2) Store communication and packet logs


There is another way to add storage capacity to your router, and that is by mounting a shared directory on you computer. DD-WRT supports Samba shares, which is the default Windows sharing mechanism. Samba shares can also be made with Linux. The will make your available hard disk space accessible to your router.

Compared to the SD/MMC modification this has 2 disadvantages:

1) Samba only works over a wired connection (so a wire between the PC and router is required)

2) Your PC needs to be switched on for the storage capacity to be available

You can read more about how to mount a directory with Samba here: The Samba Filesystem


Note: The Samba tutorial is outdated. I will add a section to it to show you how to mount a Samba share with the V2.4 firmwares.

2. How to open your router

Check this Wiki How to open the Buffalo WHR-HP-G54 to see how to open your router without breaking it. Inside you will find a printed circuit board(PCB).


3. Finding suitable IO points

Once you have opened the router you will have access to the PCB. We need to find several points on the board that we are going to use to build our SD/MMC interface. We use the SPI mode of the SD/MMC card because this mode only requires a few IO lines. Thus we need to find the following:

1) Ground

2) 3.3 volt

3) Three general IO output points

4) One general IO input point


To find these points we will need our general purpose friend, the multi-meter.


3.1 Ground

It is very easy to find a grounded point, because ground is present all over the PCB. In most cases the input power ground will also be the ground for the whole PCB. So start looking at the input power connector. This connector has quite big soldering pads, which makes it easy to add an extra wire. Once this point is found, verify it by checking big metal object on the PCB. Usually the metal housing around the tuner (see pictures below to find the tuner) will be grounded too. To verify that the points are connected use the conductivity check of the multi-meter. Make sure the router is powered down. The connection between the points should give you a very low resistance, about the same resistance as what you would get when just shorting the multi-meter probes. With the Buffalo WHR-G54S I found that the metal mounting pins for the AOSS switch are also grounded(indicated with SD3/6 in the picture below). This gave me an easy access point, and is also a nice point for the routing of the wires.


3. 2 A 3.3 volt power point

Once a grounded point is found we can start looking for the 3.3 volt power supply that we need. Check your power supply specification. Check if it provides AC or DC at the output. AC is indicated with a waived line (~), while DC is indicated with 2 straight lines. The bottom line is interrupted. If the output indicates that the power supply is 3.3 volt already, then check the power socket connection at the PCB for 3.3 volt. To verify this you need to power up the router. Be very careful with this, as it is very easy to short circuit the board with some parts lying around. Switch the multi-meter to DC volt measurement, range 0-20 volt. The actual value that you find might be slightly higher or lower than 3.3 volt(3.1-3.5 volt). If you power supply states an output voltage higher than 3.3 volt (usually 5 or 12 volts) then the PCB contains a power regulator to lower the input voltage to 3.3 volt. You will need to find this power converter, and it's 3.3 volt output. The power converter is a big component, usually close to the input power socket. Power up the router and connect one multimeter probe to a grounded point. Then carefully use the other probe to check the voltage at big pads of the big components close to the power socket until you find the 3.3 volt power supply.

3.3 General IO output points

To control the SD/MMC card we need some outputs, which are connected to the inputs of the SD/MMC card. Router usually contain LED's to signal their status. This gives us a easy opportunity to find some output points. The only disadvantage of this is that we will lose the signaling functionality of the LED's because they are now used for the SD/MMC card communication. What we first should establish is which LED's we can control by software. To do this login to the router and use the "gpio" command. So under Windows type in your dos box: "telnet <router IP address". The default address is 192.168.1.1. The login name is: "root", even if you changes the router name, the default password is "admin". The syntax of the gpio command is like this:

gpio enable <IO pin number> # to enable a IO pin, which switches the LED off

gpio disable <IO pin number> # to disable a IO pin, which switches the LED on

The reason why the logic is reversed(enabled switches LED off) can be found in the inverting amplifier that is used to power the LED's. For the <IO pin number> use numbers between 0 and 14. So watch the LED's closely while giving the gpio commands. You can also use this little command line to make your life easier:

while true; do gpio disable 3; sleep 1; gpio enable 2; sleep 1; done

You will need to press <CTRL> + "c" to exit from this command.

Image:WHR_G54S_SD_MOD-Telnet_DOS_BOX.png

Replace the "3" in two places to change it for other IO numbers.

There is one important thing to consider! The IO pins can be use for input and for output purposes, and as you know there is usually a reset switch on the router. So what would happen is you write the status of the pin that is used to see if the reset button was pressed!? Right, you create a reset. This is not a problem. When this happens you will lose the telnet connection and see the LED's flashing like when you reset the router. Now go through all the IO numbers and record accurately which LED's are software controllable by which IO pin. For my buffalo this yielded this:

GPIO 1 - Bridge LED(Green, 3rd LED on front panel

GPIO 2 - WLAN LED(Green)

GPIO 3 - Extra LED between bridge and WLAN (Green, not visible from the outside)

GPIO 6 - AOSS LED(Orange, on top)

And I found that the reset button is behind GPIO 4:

GPIO 4 - Reset Button


The DIAG LED and Power LED are not software controllable in my router. We need 3 outputs, I found 4, so let's make a choice. Let's not use the WLAN LED, because it is giving quite useful information. (Todo: how to electrically verify this with the multi meter, which side of LED) (Can the chip select line be fixed? Always selected?) (Use negative side of LED (+ side is marked).)

3.4 General IO input point

We need to find 1 input pin. The switches on router are the candidates for this. My router has 3 switches: 1) A reset switch, which is not suitable to use as it has some side effects ;) 2) The AOSS switch 3) The auto/bridged switch

I choose to use the auto/bridges switch because this switch is not very useful. With the DD-WRT firmware it not used anyway. The router mode is defined by the software settings, not by the switch. To see if you can read a switch use the "gpio" command again:

gpio poll <IO pin number> # to read the status of a switch


When you execute this command it will wait until a change in the switch position is detected and signal this by printing "00" or "01". You will need to press <CTRL> + "c" to exit from this command. Try this with all IO pins that you did not find connected to a LED. In my case this yielded:

GPIO 0 - AOSS button on top - State 00 is down, state 01 is up.

GPIO 5 - Bridge/Auto Switch - State 01 is "auto", state 00 is "bri".

4. Wiring layout.

In total this yielded the following wiring layout:

SD function SD Direction SD Pin Router IO Router function
Chip Select IN 1 GPIO 1 Bridge LED
Data In IN 2 GPIO 5 Bridge/Auto switch
Ground - 3 Ground Ground
Vcc(3.3v) - 4 Vcc(3.3v) Vcc(3.3 volt)
Clock IN 5 GPIO 3 Extra LED
SD sleep mode IN 6 Ground Ground
Data Out OUT 7 GPIO 6 AOSS LED

Required tools: Soldering iron with a very fine tip. Some pieces of thin wire (diameters approx. 0.25 mm) A SD card adapter. A SD or MMC card.

Image:WHR_G54S_SD_MOD-Component_Side.png

Image:WHR_G54S_SD_MOD-PCB_Backside.png

Image:WHR_G54S_SD_MOD-SD_Card.png

Image:WHR G54S SD MOD-Management Screen.png