OpenWrt Forum Archive

Topic: TF card doesn't work

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

In my development board (ar9341, openwrt 12.09), there is a TF card shared the same spi bus with m25p80 (the main MTD). I integrated some mmc modules in kernel --
+CONFIG_EXT4_FS=y
+CONFIG_MMC=y
+CONFIG_MMC_SPI=y
+CONFIG_MMC_BLOCK=y

After booted, their are errors as below (whether TF card inserted or not):

[    3.020000] mmc_spi spi0.1: SD/MMC host mmc0, no DMA, no WP, no poweroff
[    3.020000] TCP cubic registered
[    3.030000] NET: Registered protocol family 17
[    3.030000] 8021q: 802.1Q VLAN Support v1.8
[    3.050000] VFS: Mounted root (squashfs filesystem) readonly on device 31:3.
[    3.060000] Freeing unused kernel memory: 216k freed
- preinit -
Press the [f] key and hit [enter] to enter failsafe mode
[    6.070000] mmc0: host doesn't support card's voltages
[    6.070000] mmc0: error -22 whilst initialising SDIO card
[    6.080000] mmc0: host doesn't support card's voltages
[    6.090000] mmc0: error -22 whilst initialising SD card
[    6.090000] mmc0: host doesn't support card's voltages
[    6.100000] mmc0: error -22 whilst initialising MMC card


Then I checked my schematic circuit, and put 2 10K ohm pull-up resistors for  'cs' pin and 'DO' pin each in TF card socket.
After booted, there are no errors occured, but TF card is not mounted yet! (whether TF card inserted or not) :

[    3.020000] mmc_spi spi0.1: SD/MMC host mmc0, no DMA, no WP, no poweroff
[    3.020000] TCP cubic registered
.....
root@Linkpower:~# cat /sys/kernel/debug/mmc0/ios
clock:          0 Hz
vdd:            0 (invalid)
bus mode:       2 (push-pull)
chip select:    1 (active high)
power mode:     0 (off)
bus width:      0 (1 bits)
timing spec:    0 (legacy)
root@Linkpower:~#


What to do to make my TF card work?

I used oscilloscope to monitor, and found the "CS" pin of TF card is abnormal. The pin was used as "DB120_GPIO_LED_USB" in Demo board (DB120 board). Now the pin is changed to be TF card's "CS" pin. Anywhere else should be changed to adopt it either?

I feel somewhere in AR9341 GPIO setting is wrong. The CS of TF card uses GPIO11.

Done!

Besides a reference as below:

https://wiki.openwrt.org/toh/tp-link/tl … p.mmc.hack

I added some source code to init relative GPIOs in the board init c file:

        /* Disable JTAG, enabling GPIOs 0-3 */
        /* Configure OBS4 line, for GPIO 4*/
        ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
                                 AR934X_GPIO_FUNC_CLK_OBS4_EN);

        /* config gpio11 as normal gpio function, "11" should be accord with dev-m25p80.c*/
        ath79_gpio_output_select(11,
                                 AR934X_GPIO_OUT_GPIO);

Be careful those changes should match your hardware.

That is all.

The discussion might have continued from here.