cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
milosoftware
Scholar
Scholar
8,869 Views
Registered: ‎10-26-2012

SD/MMC card removal/insertion detection

Jump to solution

If an SD card is present while booting linux 3.5, the card is detected and the partitions are parsed. Hotplug sees them and mounts them fine.This works regardless of whether or not the boot image is on the SD card.

 

Once Linux is running, inserting or removing the SD card is not detected. There appears to be no way whatsoever to get the board to "see" the card if it wasn't present at boot time. On other hardware, this fires hotplug events. This bug makes it impossible to use the SD card for anything else than booting...

 

This happens on both the zc702 evaluation board and the Zedboard. They behave identical.

 

Is this a hardware limitation, a problem with the driver, or a configuration issue?

 

From the documentation I understand that there are GPIO pins connected to the card detect and read-only signals of the card reader. But maybe the reader doesn't use these signals.

0 Kudos
1 Solution

Accepted Solutions
milosoftware
Scholar
Scholar
11,414 Views
Registered: ‎10-26-2012

Okay found it, thanks for the tip.

 

The devicetree was missing a "xlnx,has-cd = <0x1>;" value. With that addition, the MMC partitions are automatically being (un)mounted when inserting (removing) the SD card.

View solution in original post

0 Kudos
5 Replies
norman_wong
Scholar
Scholar
8,859 Views
Registered: ‎05-28-2012

It's been a while. If I remember correctly, the Zynq MMC controller has inputs for the CD and WP. So the pins should be configured as CD and WP and not GPIOs (like other MMC controllers). The device tree entry doesn't specify GPIOs but does specify IRQs. Implies CD and WP usage. The registers to check for pin config:

 

SD0_WR_CD_SEL [0x58000830]
SD1_WR_CD_SEL [0x58000834]
MIO_PIN_00 [0x58000700]
MIO_PIN_15 [0x5800073C]

 

I think it up to designer to make sure the SD0_WR_CD_SEL is consistent with the MIO registers. Also that SD1 doesn't conflict with SD0.

 

Not sure about the hotplug functionality. I thought auto-mount required hotplug scripts on the file system. The basic pre-built filesystem doesn't have any scripts. I found that when I plugged in a USB flash drive, the driver is recognized with a console message but I had to mount the device manually.

 

0 Kudos
milosoftware
Scholar
Scholar
8,851 Views
Registered: ‎10-26-2012

So if I understand correctly, you're saying it must be a configuration issue?

 

(Don't worry about the hotplug part, I got that covered. Inserting a USB stick in my system automatically mounts it. Inserting an SD card doesn't even generate any kernel message.)

0 Kudos
milosoftware
Scholar
Scholar
11,415 Views
Registered: ‎10-26-2012

Okay found it, thanks for the tip.

 

The devicetree was missing a "xlnx,has-cd = <0x1>;" value. With that addition, the MMC partitions are automatically being (un)mounted when inserting (removing) the SD card.

View solution in original post

0 Kudos
justinlh
Explorer
Explorer
7,948 Views
Registered: ‎02-18-2014

I felt like my problem would be best suited under this thread even though its not the same problem.

 

Im trying to write myself an application to detect the removal/insertion of the sd card. I've read alot of things about how there is a indicator pin that i would read somewhere to get this data, but ive seen no example. Ive also heard SPI being mentioned, can someone point me to an example of SPI being used in an application c++ file?

 

My current setup is zc702 board, petalinux, and some custom hardware.

 

Also, would there be any petalinux-drivers to help make this easier?

 

Thanks!

0 Kudos
milosoftware
Scholar
Scholar
7,941 Views
Registered: ‎10-26-2012
To detect such event, use the linux hotplug mechanism. The easiest way is to configure mdev or udev to call a program or a shell script upon insert or remove. You can also listen on a hotplug event socket, which sends the information directly to your application.
0 Kudos