OpenWrt Forum Archive

Topic: SD hotplug not being called

The content of this topic has been archived on 18 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I have recently added an SD card to my Linksys AP (WRT54GL v1.1).  Followed the how-to and everything went great (http://wiki.openwrt.org/OpenWrtDocs/Har … ys/WRT54GL).  Thanks to those that put that together.  I am able to mount and read/write the SD and also have the init scripts set up to load the mmc module and mount the card on reboot (assuming the card is plugged in of course).

Now I am trying to get hotplugging to work.  I tried by creating /etc/hotplug.d/mmc/01-mmc-storage but when I insert/remove the card nothing happens.  My 01-mmc-storage file is executable and currently just looks like:

echo "mmc hotplug" >> /root/LOG


I know that won't mount the thing, I am just trying to verify that I get an event, which I don't.  I tried following  http://wiki.openwrt.org/OpenWrtDocs/Cus … WifiToggle  to set up a button hotplug event script so I created  /etc/hotplug.d/button/01-radio-toggle  and added a simple echo command to that script.  Pressing the button does not trigger that one either.

When I boot I notice that the button/01-radio-toggle DOES get called a bunch of times...but won't get called after bootup.  In both cases the mmc/01-mmc-storage does not get called.  So what has to happen for hotplug to get called?  Maybe it has something to do with my gpiomask (0x9c).  Does that disable hotplug events or something?  I'm sure I'm just missing a step here.  I'd appreciate your help.

I'm running OpenWrt 2.4.34.  I got the image from    http://downloads.openwrt.org/kamikaze/7 … uashfs.bin

Thanks!

Ok, I have an update to my issue.  I edited /etc/hotplug.d/button/01-radio-toggle to just have:

echo "toggle hotplug"

I don't switch on "$BUTTON" = "ses" but rather just print the test message if the 01-radio-toggle gets called at all.  What I've found is that I don't get an event on the Secure Easy Setup button ("ses") but I DO get an event on the reset button.  Still not sure how to get an event for SD card insert/remove.

I still haven't  sorted this out.  I am trying to understand how to get a hotplug event to trigger when I plug in an SD card and I haven't found any documentation on how the OpenWRT hotplug stuff works.  From what I can tell the kernel calls /proc/sys/kernel/hotplug  which calls /sbin/hotplug-call which then calls the appropriate handler script in /etc/hotplug.d/$1/* where $1 can be 'button' or 'usb', etc.

SO, it looks like I need the kernel to make the hotplug call and pass 'mmc' or something like that so that /etc/hotplug.d/mmc/* gets called.  Plugging and unplugging the SD card does not result in /proc/sys/kernel/hotplug getting called so of course it never gets anywhere else.   

Do I need to set up an interrupt handler or something on GPIO 2,3,4 or 7 that does something like   cat /proc/sys/kernel/hotplug mmc   or something like that to get things going?  I'd appreciate any input on this.

Thanks.

I'm thinking that the SD driver module may be the one responsible for generating the hotplug event.  So I looked at the mmc.c source and I see that the mmc_timer part is commented out.  I believe that is the timer that occasionally fires and checks for a device.  If that's the case then this driver currently is not checking.  I wonder why it was left out.  When the timer fires it is supposed to call mmc_check_media which does the detection and a hotplug call could be added here.

Any thoughts on why the timer was disabled or if my plan of action doesn't make sense?  Clearly I'm new to the whole hotplug thing.  I am going to try to get it working again.

The discussion might have continued from here.