SDHC SPI Send Command

Hello.

I have a custom board featuring nRF5340. I placed a microSD card reader in my board connected to SPI. I followed the fatfs zephyr example, but I'm struggling in mounting the disk.

I can correctly see the block count, sector size and capacity of the microSD, but as soon as I try to run fs_mount(&mp), the board resets.

When debugging, I saw that the board resets as it tries to run the function sdhc_spi_send_cmd

I don't know where the problem can be, since as I said I can correctly see the capacity of the card (I'm using a Premium microSDHC 32gb card by Verbatim )

I already tried to format the card both with Windows10 and the program SDCardFormatter, but nothing changed.

My devicetree for the spi/sd device is 

&spi1 {
	compatible = "nordic,nrf-spim";
	status = "okay";
	cs-gpios = < &gpio0 7 GPIO_ACTIVE_LOW >;
	sck-pin = < 8 >;
	mosi-pin = < 9 >;
	miso-pin = < 10 >;
	sdhc0: sdhc@0 {
		compatible = "zephyr,sdhc-spi-slot";
		reg = <0>;
		status = "okay";
		label = "SDHC0";
		mmc {
			compatible = "zephyr,sdmmc-disk";
			status = "okay";
		};
		spi-max-frequency = <16000000>;
	};	
};

And my connector is the following

Parents
  • Hi

    Error message -22 means that there is an invalid argument in that function. The disk_access_init() only input parameter should be the Disk name as a const char, so are you sure that is the function returning this error?

    Best regards,

    Simon

  • As you can see from the snippet above, i directly print the return value of disk_access_init.

    If I keep in the DTS the following part

    		mmc {
    			compatible = "zephyr,sdmmc-disk";
    			status = "okay";
    		};

    Then it returns ENOTSUP (-134)

    I tried different combinations of possible configurations based on what I can find online, but it seems to be something very unclear.

    At the moment it seems that it's not a problem of the SD itself, neither of the SPI bus, but an hardware configuration that somehow is not working.

    By receiving -22 (EINOTVAL), I think that I miss the link between the const char disk name, and the device registered in the dts/prj.conf

Reply
  • As you can see from the snippet above, i directly print the return value of disk_access_init.

    If I keep in the DTS the following part

    		mmc {
    			compatible = "zephyr,sdmmc-disk";
    			status = "okay";
    		};

    Then it returns ENOTSUP (-134)

    I tried different combinations of possible configurations based on what I can find online, but it seems to be something very unclear.

    At the moment it seems that it's not a problem of the SD itself, neither of the SPI bus, but an hardware configuration that somehow is not working.

    By receiving -22 (EINOTVAL), I think that I miss the link between the const char disk name, and the device registered in the dts/prj.conf

Children
  • I was debugging where the ENOTSUP -134 error is originating, and I can see that it comes from

    ret = sdhc_request(card->sdhc, &cmd, NULL);  (sd.c)
    Apparently, the cmd structure will contain information about the response of the SD card. In my case, the field response of the structure sdhc_command cmd is 0, hence it returns -134.
    At this point I need to check if I see something from the logic analyzer when the sdhc_request is sent. I'll post updates soon
Related