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

    I see that you've set the SPI max frequency to 16MHz, but the SPI1 instance in the nRF5340 does not support higher data rates than 8Mbps, so can you try lowering the spi-max-frequency down to 8000000?

    What SDK version are you using for development? When debugging, do you see any kinds of error codes as when the application moves into fs_mount(), or where does the debugging session end up?

    Best regards,
    Simon

Reply
  • Hi

    I see that you've set the SPI max frequency to 16MHz, but the SPI1 instance in the nRF5340 does not support higher data rates than 8Mbps, so can you try lowering the spi-max-frequency down to 8000000?

    What SDK version are you using for development? When debugging, do you see any kinds of error codes as when the application moves into fs_mount(), or where does the debugging session end up?

    Best regards,
    Simon

Children
  • Hi Simonr.

    I tried to lower the SPI freq to 8M, and this time I cannot even see the size of the SD. If you take into consideration the fat_fs example, with 8M I enter this control

    if (disk_access_init(disk_pdrv) != 0) {
                printk("Storage init ERROR!\n");
                break;
            }
    While with 16M I successfully skip that and while debugging it ends up to the first sdhc_spi_send_cmd that it encounters deep down to the function fs_mount inside functions, showing no errors but rebooting the MCU.
    My SDK is NCS 2.2.0.
Related