Connecting an SD/MMC card to your BR-6104K router ------------------------------------------------- .. image:: sd_card.jpg SD Card Slot ============ You will need to get hold of an SD card slot. You can either just buy one, or make one from an old floppy drive cable with edge connector as I did. Here's the connector: .. image:: floppy_connector_before.jpg There's a polarising tab in the way on the right, so we're going to put the SD card to the left side of the connector instead. We are going to use the SD card only in MMC mode, so we only need 7 wires. Turn the connector over, so the cable is coming out of the top, and carefully cut away all but 13 of the wires, as shown here: .. image:: floppy_connector.jpg Notice I've left a short length of ribbon to make cable annotation a little easer, so from the left:: CS (chip select) dot-dash-dot MMC DI (data in) dash-dot-dash-dot GND solid black 3.3v solid red CLK dots GND solid black MMC DO (data out) dot-dash-dot-dash NB: When we talk about data in and data out it's with respect to the card. This guide always gives these directions relative to the card, not the SPI interface on the board - be warned. Board Connections ================= You'll need to get out your solder sucker and iron and remove four LEDs: D9, D10, D11 and D12, bottom-right on the board. You can link the bottom of the current-limiting resistor R85 to D12 anode, which you should be able to make out below. I use this trick to get 3.3v to a through-hole solder point, but of course you could get 3.3v instead from any number of other places on the board. C99 and C100 provide a close-by earthing point, again plenty of other places to find that. .. image:: board_wiring.jpg Here is the connected SD card reader. I was a bit sloppy about cable lengths - it's probably better to make the wires as short as possible. .. image:: total.jpg When inserting the card, ensure it is hard up against the left end of the connector, and that the SD card contacts meet the edge connector contacts. The picture below shows the SD card pushed half-way in to indicate position of the contacts. .. image:: floppy_connector2.jpg OpenWrt Configuration ===================== You will need to ensure you've selected the mmc_over_gpio package: .. image:: config_mmc_gpio.jpg You will also want to access files on the MMC card, so you could include msdos/vfat. Make sure you have cp437 (United stated codepage) module, or you probably won't be able to mount the filesystem. .. image:: config_fs.jpg Pin Configuration ================= I almost forgot... we need to tell OpenWrt which pins we'll be using for the MMC interface. Edit the init file for the mmc_over_gpio package:: vim package/mmc_over_gpio/files/mmc_over_gpio.init The script is fairly easy to follow, and just seems to echo some numbers into one of the /sys files. In this example I've already changed the file to be compatible with the pins I've used above:: #!/bin/sh /etc/rc.common # Copyright (C) 2008 OpenWrt.org START=90 SYSFS="/sys" SYSFS_DRIVERDIR="$SYSFS/bus/platform/drivers/spi-gpio-mmc" # add_device(name, DI_pin, DO_pin, CLK_pin, CS_pin, mode) add_device() { echo -n "$1" "$2","$3","$4","$5" "$6" > $SYSFS_DRIVERDIR/add } # remove_device(name) remove_device() { echo -n "$1" > $SYSFS_DRIVERDIR/remove } start() { #FIXME we should use a config file, but I dunno how that parser #works. add_device "default" 21 17 20 18 0 } stop() { remove_device "default" } You probably guessed the crucial line is:: add_device "default" 21 17 20 18 0 Save the file with either these values, or alternatives if you wired your card to the board differently to mine. My init file is available for download `here `_. First Boot ========== The card should be recognised on boot, and if all works you should get something like:: mmc_spi spi32766.0: ASSUMING 3.2-3.4 V slot power mmc_spi spi32766.0: SD/MMC host mmc0, no DMA, no WP, no poweroff spi-gpio-mmc: MMC-Card "default" attached to GPIO pins 21,17,20,18 mmc_spi spi32766.0: can't change chip-select polarity mmc0: problem reading switch capabilities, performance might suffer. mmc0: new SD card on SPI mmcblk0: mmc0:0000 979456KiB mmcblk0: If you get:: mmc0: error -22 whilst initialising SDIO card then go back and check your wiring and/or the position of the SD card in the edge connector. To use the card you can format and mount /dev/mmcblk0, or alternatively one of the partitions (e.g. /dev/mmcblk0p1), depending on how you've set it up.