Zephyr SD card returns "Card never left busy state"

Using the zephyr RTOS I currently want to acces filesystem on a SD card. I wired it correctly and used this example to getting started: https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/subsys/fs/fs_sample

The log returns follwowing error:

[00:00:03.463,989] <inf> sd: Detected SD card
[00:00:05.601,104] <err> sd: Card never left busy state
[00:00:05.601,135] <err> sd: Card init failed
[00:00:05.601,165] <err> main: Storage init ERROR!

Hence, I wired my Logic to get some more details

.

There is definitely some communication, but not as described here: http://elm-chan.org/docs/mmc/mmc_e.html.

Here are the first commands:

name type start_time duration mosi miso

SPI result 1.0015495 3.05e-05 0x40 0xFF

SPI result 1.00158175 3.05e-05 0x00 0xFF

SPI result 1.001614 3.05e-05 0x00 0xFF

SPI result 1.00164625 3.075e-05 0x00 0xFF

SPI result 1.00167875 3.05e-05 0x00 0xFF

SPI result 1.001711 3.05e-05 0x95 0xFF

SPI result 1.0017435 3.05e-05 0xFF 0xFF

SPI result 1.00177575 3.05e-05 0xFF 0x01

SPI result 1.001808 3.05e-05 0xFF 0xFF

SPI result 1.00184025 3.075e-05 0xFF 0xFF

SPI result 1.00187275 3.05e-05 0xFF 0xFF

SPI result 1.001905 3.05e-05 0xFF 0xFF

SPI result 1.00193725 3.05e-05 0xFF 0xFF

SPI result 1.0019695 3.05e-05 0xFF 0xFF

SPI result 1.00200175 3.075e-05 0xFF 0xFF

SPI result 1.00203425 3.05e-05 0xFF 0xFF

SPI result 1.0020665 3.05e-05 0xFF 0xFF

SPI result 1.00209875 3.05e-05 0xFF 0xFF

SPI result 1.00213125 3.05e-05 0xFF 0xFF

SPI result 1.0021635 3.05e-05 0xFF 0xFF

I doubt that the correct frequency is not set properly. But cannot figure out, where it should be.

I formatted the SD card to FAT many time. Always getting the same result.

Parents
  • Hi

    Are you using SPI or QSPI for communication here? The frequency should be set in SPI or QSPI section of your .dts (device tree) file in something like the following:

    &qspi {
    	status = "okay";
    	pinctrl-0 = <&qspi_default>;
    	pinctrl-1 = <&qspi_sleep>;
    	pinctrl-names = "default", "sleep";
    	mx25r64: mx25r6435f@0 {
    		compatible = "nordic,qspi-nor";
    		reg = <0>;
    		/* MX25R64 supports only pp and pp4io */
    		writeoc = "pp4io";
    		/* MX25R64 supports all readoc options */
    		readoc = "read4io";
    		sck-frequency = <8000000>;
    		};
    	};

    What SDK version are you using for development of your application, and what GPIOs on the nRF52840 are you using for connecting to the SD card?

    Best regards,

    Simon

  • I use SPI, is the frquency wrong in this case?

    &spi1 {
        status = "okay";
        cs-gpios = <&gpio0 3  GPIO_ACTIVE_LOW>;
    
        sdhc0: sdhc@0 {
                compatible = "zephyr,sdhc-spi-slot";
                reg = <0>;
                status = "okay";
                mmc {
                    compatible = "zephyr,sdmmc-disk";
                    status = "okay";
                };
                spi-max-frequency = <24000000>;
        };
    };

    SDK v2.3.0

    MISO: P1.08

    SCK: P0.31

    MOSI: P0.30

  • Can you please try to see if you see the same issue with lower qspi frequency? It seems that at that high speed there is some deadlock inside the driver trying to take a mutex.

Reply Children
Related