OpenWrt Forum Archive

Topic: Problem wtih SDHC card

The content of this topic has been archived on 23 Apr 2018. Unfortunately there are posts – most likely complete pages – missing.

ok I tried  insmod mmc

root@OpenWrt:~# cd /
root@OpenWrt:/# insmod mmc
insmod: Loading module failed: No such file or directory

and the lines from dmesg that refer to the mmc are

mmc_spi: Unknown symbol spi_register_driver
mmc_spi: Unknown symbol spi_write_then_read
mmc_spi: Unknown symbol spi_sync
mmc_spi: Unknown symbol spi_bus_type
spi_bitbang: Unknown symbol spi_unregister_master
spi_bitbang: Unknown symbol spi_register_master
spi_gpio: Unknown symbol spi_bitbang_stop
spi_gpio: Unknown symbol spi_alloc_master
spi_gpio: Unknown symbol spi_new_device
spi_gpio: Unknown symbol spi_bitbang_start
spi_gpio: Unknown symbol spi_bitbang_stop
spi_gpio: Unknown symbol spi_alloc_master
spi_gpio: Unknown symbol spi_new_device
spi_gpio: Unknown symbol spi_bitbang_start
gpiommc: Unknown symbol config_group_init
gpiommc: Unknown symbol configfs_unregister_subsystem
gpiommc: Unknown symbol configfs_register_subsystem
gpiommc: Unknown symbol config_item_init_type_name
gpiommc: Unknown symbol spi_gpio_next_id

also both the surface mount LEDs under the front button are on - is this normal ?

I couldn't tell you what's wrong there. When I used the 2.6 kernel, that package worked without issues for me.

Actually, I think that package does have a startup script. Try typing "/etc/init.d/mmc start".

in the /etc/init.d  directory there is only mmc_over_gpio file

looking into the file is

root@OpenWrt:/etc/init.d# vi mmc_over_gpio
#!/bin/sh /etc/rc.common
# Copyright (C) 2008 OpenWrt.org
START=90

CONFIGFS_DIR="/config/gpiommc"

# add_device(name, DI_pin, DO_pin, CLK_pin, CS_pin, mode)
add_device() {
        local dir="$CONFIGFS_DIR/$1"

        mkdir $dir
        [ $? -eq 0 ] || return 1
        echo $2 > $dir/gpio_data_in
        [ $? -eq 0 ] || return 1
        echo $3 > $dir/gpio_data_out
        [ $? -eq 0 ] || return 1
        echo $4 > $dir/gpio_clock
        [ $? -eq 0 ] || return 1
        echo $5 > $dir/gpio_chipselect
        [ $? -eq 0 ] || return 1
        echo $6 > $dir/spi_mode
        [ $? -eq 0 ] || return 1
        # XXX We have more config options available. Use defaults for now.

        echo 1 > $dir/register
        [ $? -eq 0 ] || return 1

        return 0
}

# remove_device(name)
remove_device() {
        local dir="$CONFIGFS_DIR/$1"

        rmdir $dir
}

mount_configfs() {
        # FIXME: This should probably be done somewhere else.
        mount | grep configfs
        if [ $? -eq 0 ]; then
                # already mounted
                return 0
        fi

and the /etc/config dir does not contain "/config/gpiommc"

not sure if this sheds any light on what I have or have not done yet

root@OpenWrt:/# find -name 'mmc*'
./etc/init.d/mmc_over_gpio
./lib/modules/2.6.25.17/mmc_spi.ko
./lib/modules/2.6.25.17/mmc_core.ko
./lib/modules/2.6.25.17/mmc_block.ko
./jffs/etc/init.d/mmc_over_gpio
./jffs/lib/modules/2.6.25.17/mmc_spi.ko
./jffs/lib/modules/2.6.25.17/mmc_core.ko
./jffs/lib/modules/2.6.25.17/mmc_block.ko
./sys/bus/mmc
./sys/bus/mmc/drivers/mmcblk
./sys/class/mmc_host
./sys/module/mmc_core
./sys/module/mmc_core/holders/mmc_block
./sys/module/mmc_block
root@OpenWrt:/#

still googling on big_smile

I installed via x-wrt GUI the package
gpioctl    1.0-1

with the thought I can toggle to the pins and check with a multimeter what happens ( no CRO sad ) - will have to google for instructions on how to use gpioctl

root@OpenWrt:/# gpioctl --help
gpioctl dirin|dirout|get|set|clear gpio
root@OpenWrt:/# find -name 'gpioctl*'
./usr/bin/gpioctl
./usr/lib/opkg/info/gpioctl.list
./usr/lib/opkg/info/gpioctl.control
./jffs/usr/bin/gpioctl
./jffs/usr/lib/opkg/info/gpioctl.list
./jffs/usr/lib/opkg/info/gpioctl.control

does this mean I am missing something critical ?  do I need something started  ?

root@OpenWrt:/# gpioctl get 1
Error whilst opening /dev/gpio
root@OpenWrt:/#

Are you sure you have the kmod-mmc package installed? It sounds like you may only have kmod-mmc-over-gpio installed. I thought it was dependant on kmod-mmc, but check. Type "opkg list" and look for "kmod-mmc". There should be three packages.

I installed using the x-wrt GUI and it shows all 3 installed on the packages page

with opkg search '*mmc*'

root@OpenWrt:/# opkg search '*mmc*'
kmod-mmc - 2.6.25.17-brcm47xx-1 - /etc/modules.d/90-mmc
kmod-mmc - 2.6.25.17-brcm47xx-1 - /lib/modules/2.6.25.17/mmc_core.ko
kmod-mmc - 2.6.25.17-brcm47xx-1 - /lib/modules/2.6.25.17/mmc_block.ko
kmod-mmc-over-gpio - 2.6.25.17-brcm47xx-2 - /etc/init.d/mmc_over_gpio
kmod-mmc-over-gpio - 2.6.25.17-brcm47xx-2 - /lib/modules/2.6.25.17/gpiommc.ko
kmod-mmc-over-gpio - 2.6.25.17-brcm47xx-2 - /etc/modules.d/93-mmc-over-gpio
kmod-mmc-spi - 2.6.25.17-brcm47xx-1 - /lib/modules/2.6.25.17/mmc_spi.ko
kmod-mmc-spi - 2.6.25.17-brcm47xx-1 - /lib/modules/2.6.25.17/mmc_spi.ko
kmod-mmc-spi - 2.6.25.17-brcm47xx-1 - /etc/modules.d/90-mmc-spi
root@OpenWrt:/#

this page here gives a nice tutorial - though my following it stopped at wget   mmc.o section as that gave me an error

it is a nice tutorial - http://blog.tcsoft.net/linux/openwrt/sd … gs-v4.html - but for 7.09

As I have OpenWRT running on my router I’ll provide the necessary instructions for it here.
OpenWRT Kamikaze 7.09
First, download the compiled kernel-module (adapted for our gpio2-mod) from here.

Connect to your router by ssh e.g. with putty.

# cd /lib/modules/2.4.34 (where 2.4.34 stands for the kernel version and my be different) # wget http://download.tcsoft.net/mmc.o Now mask the gpio-pins – otherwise the router would lock up when we load the module.

# echo "0x9c" > /proc/diag/gpiomask
# cat /proc/diag/gpiomask
0×009c # insmod mmc

Control if everything went like expected:

# dmesgShould show something like this

[INFO] mmc_hardware_init: initializing GPIOs
[INFO] mmc_card_init: the period of a 380KHz frequency lasts 524 CPU cycles
[INFO] mmc_card_init: powering card on. sending 80 CLK
[INFO] mmc_card_init: 80 CLK sent in 43661 CPU cycles
[INFO] mmc_card_init: resetting card (CMD0)
[INFO] mmc_card_init: doing initialization loop
[INFO] mmc_card_init: card inited successfully in 2 tries (61573 CPU cycles).
[INFO] mmc_init: MMC/SD Card ID:
41 34 32 53 44 31 47 42 10 23 90 02 92 00 71 11 [INFO] Manufacturer ID   : 41
[INFO] OEM/Application ID: 42
[INFO] Product name      : SD1GB
[INFO] Product revision  : 1.0
[INFO] Product SN        : 23900292
[INFO] Product Date      : 2007-1
[INFO] mmc_card_config: size = 997632, hardsectsize = 512, sectors = 1995264
[WARN] mmc_init: hd_sizes=997632, hd[0].nr_sects=1995264
[INFO] mmc_card_init: set_blocklen (CMD16) succeeded !otherwhise we should check our soldering again.

That tutorial won't apply to you though. That's for a 2.4 kernel. For 2.6 you only need the packages. You won't need to download anything else.

I didn't work much with the package though. I'd suggest searching the net for help on the kmod-mmc package specifically.

Hi all,

Hope this helps

LinkSys WRT54GL v1.1
Kamikaze 8.09 branch 2.4
root@crys:~# cat /etc/banner
  _______                     ________        __
|       |.-----.-----.-----.|  |  |  |.----.|  |_
|   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
|_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
KAMIKAZE (8.09, r14511) ----------------------------
  * 10 oz Vodka       Shake well with ice and strain
  * 10 oz Triple sec  mixture into 10 shot glasses.
  * 10 oz lime juice  Salute!
---------------------------------------------------
root@crys:~#


I have had a 2Go NoName SDCard wired successfully :
http://wiki.openwrt.org/OpenWrtDocs/Har … ys/WRT54GL very instructive and well designed

http://wiki.openwrt.org/OpenWrtDocs/Kam … MediaHowTo this one to boot from yur card !

[INFO] mmc_hardware_init: initializing GPIOs
[INFO] mmc_card_init: the period of a 380KHz frequency lasts 524 CPU cycles
[INFO] mmc_card_init: powering card on. sending 80 CLK
[INFO] mmc_card_init: 80 CLK sent in 43646 CPU cycles
[INFO] mmc_card_init: resetting card (CMD0)
[INFO] mmc_card_init: doing initialization loop
[INFO] mmc_card_init: card inited successfully in 2 tries (61570 CPU cycles).
[INFO] mmc_init: MMC/SD Card ID:
1b 53 4d 30 30 30 30 30 10 b1 62 42 eb 00 8b 6b [INFO] Manufacturer ID   : 1b
[INFO] OEM/Application ID: SM
[INFO] Product name      : 00000
[INFO] Product revision  : 1.0
[INFO] Product SN        : b16242eb
[INFO] Product Date      : 2008-11
[INFO] mmc_card_config: size = 1993728, hardsectsize = 1024, sectors = 1993728
[WARN] mmc_init: hd_sizes=1993728, hd[0].nr_sects=3987456
[INFO] mmc_card_init: set_blocklen (CMD16) succeeded !
Partition check:
mmca: p1 p2 p3
Journalled Block Device driver loaded
kjournald starting.  Commit interval 5 seconds
EXT3 FS 2.4-0.9.19, 19 August 2002 on mmc(121,3), internal journal
EXT3-fs: recovery complete.
EXT3-fs: mounted filesystem with ordered data mode.

Keep on mind to follow the instructions given before first use of card
echo 0x9c >/proc/diag/gpiomask
install the kamikaze 7.07 mmc optimized version
the first time you make a fdisk part don't build no more than a 32Mb partition cause yu get a seg. fault error due to the poor amount of memory of the wrt54G router.

Good luck ;0)

If you're running kernel v2.4, I highly recommend using the SDHC version earlier in this post.  It's much easier to configure and can handle the 4gb+, as well as, the HC versions.

Per Cybersaga's comments this may not work on the v2.6.

Cyber - do you have any experience testing this on v2.6, or is it just a concern that it was designed for v2.4 and may not work.

Yeah, I tried the SDHC module on 2.6 and it doesn't work. I read up a little bit on linux drivers between the two versions and they're totally different.

cybersaga wrote:

Yeah, I tried the SDHC module on 2.6 and it doesn't work. I read up a little bit on linux drivers between the two versions and they're totally different.

I am not making any progress with my mmc and 2.6

all the tutorials and help I can find refer to 2.4

I think I will flash my 54GL with 2.4 and do the learning with 2.4 until I believe 2.6 will work

This might be a dumb question, but is there some way to use the SDHC package and an sd card for the installation of extra packages?

---

I got it.... somewhat, there's probally a better way to do it, but I'll post what I did here anyway in case anyone else is having trouble.

Followed this guide http://wiki.openwrt.org/OpenWrtDocs/Kam … MediaHowTo  except

* Did not create a /etc/config/bootfromexternalmedia file
(I was having issues getting the config file to read in properly...)


* use the following script as /sbin/init
(Replace the options for gpiomask and for the sdhc module as necessary )

#!/bin/sh
. /etc/functions.sh
echo 0x9c >> /proc/diag/gpiomask
insmod sdhcd clk=3 din=2 dout=4 cs=7 major=0 maxsec=32 rahead=2 dbg=1
insmod jbd 
insmod ext3 
sleep 5
mount -o rw /dev/sdcard/part1 /mnt 
[ -x /mnt/sbin/init ] && {
        . /bin/firstboot
        pivot  /mnt /mnt
}

exec /bin/busybox init

One extra thing I had to do to get some packages to install, was to comment out the following line in /etc/opkg.conf

option overlay_root /jffs

seems the availble space is calculated based on /jffs, although it installs to /

(Last edited by Daedelus on 2 Mar 2009, 10:13)

Thanks Daedelus. I'll try that when I get home. I've been having a hard time getting that to work.

bwanna wrote:

I FULLY understand your email.  I felt the same way.

I recommend using the link http://4mul8.ca/openwrt/packages/8.09/ as it is a package that will support both standard and HC type SD cards.  The mmc will max out at 2 or 4gb.

So here's what I did that has worked for me with an 8gb SDHC type card (Office Depot sale for $10)

1. Download package to PC
2. Connect to Router using WinSCP (much easier than using wget, etc.)
3. Copy package to the router /tmp directory
4. open a terminal or Putty link and go to the /tmp directory  ("CD /tmp")
5. run "opkg install kmod-broadcom-sdhc_2.4.35.4-brcm-2.4-2.0.1-1_mipsel.ipk"
v8.09 uses "opkg" instead of "ipkg" that's shown on almost all of the websites

6. In WinSCP migrate to the /etc directory and look for the "sdcard.conf" file
7. Open this file for editing.
8. Change the GPIO settings to match your specific modification that you did on the router.
Specifically, near the top of the file you'll see: (these are my settings)
______________________________________
# SD/MM card contact to GPIO pin mapping - set to match your connections
cs=7
clk=3
din=2
dout=4
______________________________________

9. Save the changes to the file.  (I reopened the file to make sure they were saved.)
10.  run the following command: "/etc/init.d/sdcard help"
This will provide you a listing of the commands you'll need.  Also notice you're NOT using "mmc"
11. Now do "/etc/init.d/sdcard start"
12. now "dmesg"
You should see something that portrays that the card has been initialized and mounted.
13.  Now install "opkg install e2fsprogs"
14.  Run "mke2fs -j /dev/sdcard/part1". Leave out the "-j" if you want ext2
(These last two are the key steps that cybersaga gave me.  They will format the card.)
At this point, I believe I rebooted.  You could also run "/etc/init.d/sdcard reload" or "stop" and then "start" to get it to catch.

Run "df" to show the sdcard size.

Let me know how it goes.  I was in your same shoes just a few days ago, so I'm no expert.  This is just what worked for me.

Good Luck!

Cheers

Hi All,

I followed the instructions exactly as above, but only had to make this change in sdcard.conf "dbg=0" to "dbg=2" to get my Sandisk 8gb SDHC card detected and formatted, every thing works good execpt when I reboot the unit all is lost, it does not detect the SDHC card at boot up, what do I have to do so this will survive a bootup.

Regarding the SDHC module at http://4mul8.ca/openwrt/packages/8.09/

1) By default, the /etc/init.d/sdcard script is not set to run at boot time. To enable sdcard initialization at boot time run:

/etc/init.d/sdcard enable

2) There is a bug in the init script that prevents your configuration settings from being passed to the kernel module if "dbg=0" is set in /etc/sdcard.conf.  To work around this problem and have the module work without debugging enabled (slightly faster) do the following:

a) Replace the following line from file /etc/init.d/sdcard

    [ ${dbg:-0} -gt 0 ] || continue

with the line:

       [ ${arg} == "dbg" ] && [ ${dbg:-0} -eq 0 ] && continue

I will try to find the time to fix this bug and re-package the sdhc module soon.

chris.krusch wrote:

Regarding the SDHC module at http://4mul8.ca/openwrt/packages/8.09/

1) By default, the /etc/init.d/sdcard script is not set to run at boot time. To enable sdcard initialization at boot time run:

/etc/init.d/sdcard enable

2) There is a bug in the init script that prevents your configuration settings from being passed to the kernel module if "dbg=0" is set in /etc/sdcard.conf.  To work around this problem and have the module work without debugging enabled (slightly faster) do the following:

a) Replace the following line from file /etc/init.d/sdcard

    [ ${dbg:-0} -gt 0 ] || continue

with the line:

       [ ${arg} == "dbg" ] && [ ${dbg:-0} -eq 0 ] && continue

I will try to find the time to fix this bug and re-package the sdhc module soon.

Thanks will give it a try.

Cool

The discussion might have continued from here.