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

    The only reasons for error -134 (ENOTSUP) should be that the SD card is not recognized (likely due to incorrect setup) or that the SD card you're using is not supported which I don't think is the case with the SD cards you've mentioned using. Unfortunately I will need some time to set up something like this to test on my end, so I can't guarantee getting back to you with a tested solution any time soon. Some things you can check on your end:

    • Is the SD card reader powered sufficiently, maybe it is set to too low a voltage and thus browns out after reporting the SD size for example?
    • Is the SD size reported by the actual SD card, or is the size perhaps reported by the device tree?

    Without knowing what bytes we should expect return data on it's very hard to gather something from these scope traces, as it only seems to be empty data (FF) from the SD card reader except that 05 value.

    Best regards,

    Simon

  • I can imagine it's not an easy and fast task, don't worry.

    - I cannot report the SD size anymore

    - The SD size never shows in the devicetree.

    The card is powered at 3.336V (measured with a multimeter)

    One thing I want to mention is that when I was able to retrieve the SD size, I was using a custom dts for my board, that was building only for the APPCORE. Due to the need of building also for the NETCORE, I started using it to build for nrf5340dk and used an overlay file to define my hardware.

  • Hi can you share some details on what changes you made when changing the sample to also build for the NET core? Can you upload this overlay file so we can take a look?

    Best regards,

    Simon

  • Hi simonr,

    for sure. Right now I'm building for nrf5340dk_nrf5340_cpuapp, with the same structure of the multicore sample, using the following overlay for appcore and netcore

    0116.nrf5340dk_nrf5340_cpunet.overlay6283.nrf5340dk_nrf5340_cpuapp.overlay

    When I opened the ticket, I was building only for the appcore using the following board devicetree

    board.dts

  • I made some tests:
    - I run the fat_fs example in my custom board, using the above _cpuapp.overlay. It works fine

    - I use the fat_fs example in my custom board in the multicore example running in the APPCORE. I wrote an empty NETCORE fw. Attached you will find the project. Card is not recognized

    This seems absurd to me and it seems that I don't have any margin of making it work in a multicore application

    testmulticore.zip

Reply Children
No Data
Related