Compile the MMC driver (module) for the SD card mod
This should describe howto compile and include the MMC driver in OpenWrt WhiteRussian
1. Build OpenWrt WhiteRussian
2. Compile the mmc driver
Ok, let's start.
1. How to build OpenWrt with the free VMware player on Windows is described in another howto.
Run 'make menuconfig' and select Kernel Configuration / Device Support ->
<*> VFAT filesystem support -- (fat.o, vfat.o), creates the kmod-vfat package
<*> MSDOS filesystem support -- (msdos.o), creates the kmod-msdos package
Now continue building OpenWrt WhiteRussian. Simply run 'make world'. After the build process finished flash the image to your router.
2. It is time to compile the MMC driver kernel module. It is nothing magic here.
2.1. Create a directory for the driver
cd ~/whiterussian
mkdir mmc
2.2. Download the driver source code (mmc.c) and the its Makefile
cd ~/whiterussian/mmc
wget http://kiel.kool.dk/mmc.c
wget http://kiel.kool.dk/Makefile
2.3. Next edit the Makefile. If you used my howto to build WhiteRussian you can patch the Makefile. Save the following patch as Makefile.patch (fix the spaces and convert them into tabs).
--- Makefile.orig 2006-12-11 18:00:00.000000000 +0100
+++ Makefile 2006-12-11 18:17:23.000000000 +0100
@@ -1,7 +1,12 @@
TARGET := mmc
WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes -fno-strict-aliasing -mips32
-INCLUDE := -isystem /home/rohde/buildroot/build_mipsel/linux/include
+INCLUDE := -isystem /home/ubuntu/whiterussian/build_mipsel/linux-2.4-brcm/linux-2.4.30/include
CFLAGS := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE} -fno-pic -mno-abicalls -mlong-calls
-CC := /home/rohde/develop/buildroot/build_mipsel/staging_dir/bin/mipsel-linux-uclibc-gcc
+CC := /home/ubuntu/whiterussian/staging_dir_mipsel/bin/mipsel-linux-uclibc-gcc
-${TARGET}.o: ${TARGET}.c
+
+all:
+ $(CC) ${CFLAGS} -c -o ${TARGET}.o ${TARGET}.c
+
+clean:
+ rm -f mmc.o
2.4. Apply the patch:
cd ~/whiterussian/mmc
patch -p0 < Makefile.patch
2.5. Next step is to edit mmc.c and adjust the 4 required GPIO lines. You have to change the hex value at the end of the following four lines in mmc.c
#define SD_DI 0x20
#define SD_DO 0x10
#define SD_CLK 0x08
#define SD_CS 0x80
Here is a list with the GPIOs and its hex values:
GPIO PIN 0: 0x01
GPIO PIN 1: 0x02
GPIO PIN 2: 0x04
GPIO PIN 3: 0x08
GPIO PIN 4: 0x10
GPIO PIN 5: 0x20
GPIO PIN 6: 0x40
GPIO PIN 7: 0x80
GPIO PIN 8: 0x100
GPIO PIN 9: 0x200
GPIO PIN 10: 0x400
GPIO PIN 11: 0x800
GPIO PIN 12: 0x1000
GPIO PIN 13: 0x2000
GPIO PIN 14: 0x4000
GPIO PIN 15: 0x8000
2.6. Compile the driver with make (you can ignore the warnings) and copy mmc.o to the ~/public_html directory
cd ~/whiterussian/mmc
make clean all
cp -fpR mmc.o ~/public_html
Now, the driver is ready. A new file exists in the directory, mmc.o. You can check it with 'file mmc.o' if the file is correctly cross-compiled.
2.7. On the router create /etc/modules.d/20-mmc to automatically load the driver
echo "mmc" > /etc/modules.d/20-mmc
2.8. Transfer the driver to your router (use wget or whatever)
cd /lib/modules/2.4.30
wget http://ubuntu/~ubuntu/mmc.o
2.9. Reboot the router and 'lsmod' should show the MMC driver loaded
I worte a guide for changing mini_fo's storage directory (/jffs) to external media like MMC/SD card or USB stick. No more need to mess around with environment variables for libraries.
Also look at:
- Changing mini_fo's storage directory (/jffs on external media)
- kiel.kool.dk
- OpenWrtDocs/Customizing/Hardware/MMC
(Last edited by forum2006 on 21 May 2007, 10:19)