The mmc.o driver for OpenWrt only supports 2 GB SD cards because the byte address sent to the mmc/sd card is 32 bits, and the math used to calculate this from the block address uses a SIGNED number. Therefore, mmc.o only supports cards whose size is between -2 GB and +2 GB. I have made extensive changes to MY copy of mmc.c, and I fixed the math to support 4 GB cards. I do not have a 4 GB SD card to test this though.
My mmc driver has been optimized to leave interrupts ON where appropriate, so other sessions are not bogged down during lengthy SD card IO (such as using dd to copy a partition on the SD card). I also rewrote the SPI bitbang routines to use separate input-only and output-only subroutines, and to use word-based rather than bit-based IO, so I can output the clock and data at the same time (only 2 GPIO outputs per data bit). Input from the SD card requires 2 outputs plus an input, so it is a little slower.
I also output to both GPIO2 and GPIO5, so my driver works fine with either router wiring version. It does not take any extra time to output a clock bit plus 2 outputs to the sd card, when output an entire word to the GPIO port. My GPIO outputs are 32 bits, because testing showed this to be faster than 8-bit outputs to these ports.
There seems to be a hardware wait-state generated during GPIO output, because writing to the port is far slower than writing to RAM. Also, timing analysis shows that the SD card itself takes extra time during sequential reads or writes when it crosses an erase-block boundary. Diffierent SD cards have different timing boundaries.
Although I have not done it yet, I plan to also support using DI and DO sharing a single GPIO bit, as is commonly done using PIC microcontrollers, by tying the SD card output pin to its input pin via a resistor. My code changes will need to change the data direction on the shared GPIO pin between reads and writes to the SD card.
I turn off the WRT54G front panel amber LED before exiting from the mmc driver, so the LED doubles as a "disk access" light.
I have made numerous other small corrections to the code as well.
I am booting (pivotroot) from my SD card ext3 partition, and I also have a second partition formatted as JFFS2. In theory, the effective throughput should be faster sending COMPRESSED data over the slow bit-bang SPI bus. Because JFFS2 always does an integrity check during mount, it takes several minutes to mount, so my /etc/init.d startup script launches the mount in the background so booting can continue. The JFFS2 partition mount point is empty for several minutes after booting, until the background mount completes.
I have not yet submitted my extensive mmc.c changes, or my updated mmc.o. I plan to make more changes, but I have been using my current MUCH FASTER version since March 2006, with no glitches or other problems, so I should probably submit my current mmc driver as-is.
Where do I submit an updated mmc driver?
BTW, I discovered that an SD card plugs nicely into a floppy edge-connector (many of which are unused in most computers). All the MMC pins line up good, but the unused SD-only pins do not align. I use a small piece of plastic inserted into the connector to fill the unused pins and help align the card during insertion. I have a nice set of photos that show assembling and using this connector for mmc.
SD floppy details here:
My OpenWRT mmc driver status: