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 

And my connector is the following

Parents
  • Here you have a scope trace of the SPI pins (SD card not placed) when I call sdhc_request

    I know that MISO is stale because there is no SD (I'll try get a scope trace also with the SD in), but how does the rest look?

Reply
  • Here you have a scope trace of the SPI pins (SD card not placed) when I call sdhc_request

    I know that MISO is stale because there is no SD (I'll try get a scope trace also with the SD in), but how does the rest look?

Children
  • This is instead sdhc_request when the SD card is in the slot. I honestly have no idea of what's happening.

  • Some investigation led me to understand where it arises the -134 error.

    It happens when the system checks the sd card type (either SDIO or SDMMC). The function sd_test_sdio returns -134.

    Inside of that, we try to send a sdhc command with opcode 5 and response type 85. 

    This is the scope trace of that transaction is the following

  • Same return error also trying with a SanDisk Ultra microSDXC 128Gb.

    I don't think it's a problem of the SD I'm using, since as the original post says, I was able at least to retrieve the SD size

  • That is a correct response "illegal command + idle state" from an SD card to a CMD5. SD cards don't typically support CMD5.

    I've seen cards that need a power cycle when they receive unsupported commands.