Error mounting some SD cards on Linux Kernel 3.3+

June 2012 ยท 2 minute read

I ran into an issue today using the gpiommc and mmc_spi kernel modules to use SD cards from GPIO pins, in OpenWRT.

Using a 2GB Transcend card I was getting:

[ 1473.570000] gpio-mmc: GPIO based MMC-Card "default" removed
[ 1473.960000] gpio-mmc: Failed to request mmc_spi module.
[ 1474.030000] mmc_spi spi32757.0: ASSUMING 3.2-3.4 V slot power
[ 1474.100000] mmc_spi spi32757.0: SD/MMC host mmc0, no DMA, no WP, no poweroff
[ 1474.190000] gpio-mmc: MMC-Card "default" attached to GPIO pins di=1, do=3, clk=4, cs=2
[ 1477.420000] mmc_spi spi32757.0: setup: unsupported mode bits 4
[ 1477.490000] mmc_spi spi32757.0: can't change chip-select polarity
[ 1477.960000] mmc0: error -145 whilst initialising SD card
[ 1478.030000] mmc0: card claims to support voltages below the defined range. These will be ignored.
[ 1478.210000] mmc0: unrecognised CSD structure version 0
[ 1478.270000] mmc0: error -22 whilst initialising MMC card

With more debugging, it turns out the “mmc_read_switch” function in the “drivers/mmc/core/sd.c” file was returning an error -145 with that SD card. Not sure why, either the CARD doesn’t support it? I can’t even find that error code anywhere so not really sure what the root reason is. BUT when just doing a “return 0;” there, the SD card ends up mounting perfectly and working quite well.

This same SD worked in kernel 2.6.30 but its “mmc_read_switch” function was simpler and probably didn’t try to read all the extra info that the 3.3+ one is and erroring out on. Not getting this info didn’t seem to impact anything much.

I hope this helps someone if they’re looking for a fix for a similar issue.