SD/MMC mod

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 17:07, 8 July 2007 (edit)
Iron (Talk | contribs)

← Previous diff
Revision as of 03:19, 9 July 2007 (edit) (undo)
Iron (Talk | contribs)
(4. Wiring layout.)
Next diff →
Line 87: Line 87:
== 4. Wiring layout. == == 4. Wiring layout. ==
-In total this yielded the following wiring layout: 
-SD Function SD Dir. SD Pin Router IO Router function 
----- 
---------------------------------------------------------------- 
-Chip Select (IN) 1 GPIO 1 Bridge LED 
-Data In (IN) 2 GPIO 5 Bridge/Auto switch+In total this yielded the following wiring layout:
- +
-Ground - 3 Ground Ground+
- +
-Vcc(3.3v) - 4 Vcc Vcc(3.3 volt)+
- +
-Clock (IN) 5 GPIO 3 Extra LED+
-SD Sleep Mode (IN) 6 Ground Ground+{| border="1" style="text-align:center"
 +|-
 +! 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
 +|}
-Data Out (OUT) 7 GPIO 6 AOSS LED 
---- ----
---------------------------------------------------------------- 
Required tools: Required tools:

Revision as of 03:19, 9 July 2007

SD/MMC Mod for the Buffalo WHR-G54S

This is a work in progress...

1. Introduction

This tutorial guides you through adding a 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.


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 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) A ground access point 2) A power supply of 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 access point

It is usually very easy to find a grounded point, because ground is present all over the PCB. Usually the input power ground will also be the ground level for the whole PCB. So start looking at the input power socket. This socket usually 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) 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 number, about the same number you would get when just shorting your 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). This gave me an easy access point, and is also a nice point for the routing of the wires. I don't like to access different point all over the PCB.

3. 2) A power supply of 3.3 volt

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. One of the lines is interrupted. If the output indicates that the power supply is 3.3 volt already, then check the power plug 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 (3.1-3.5 volt). If you power supply is 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 carefully probe the big pads of the big components close to the power socket until you find the 3.3 volt power supply.

3.3) Three general IO output points To control the SD/MMC card we need some outputs, which are connected to the inputs of the 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. What we first should establish is which LED's we can control by software. To do so login to the router and use the "gpio" command. So under Windows type in your dos box: "telnet 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 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. 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 output, and 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) One general IO input point

We need to find 1 input pin. The switches on router a good 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