SPI Interface for MicroSD Card

Hello,

I am attempting to mount and write to a microSD card via SPI. I am using the Fat_fs example found under "zephyr/samples/subsys/fs/fat_fs" and I am getting an error code of -5 during disk initialization. 

When I run the same code without the card inserted, I get the exact same behavior. So it almost seems like the driver isn't detecting the card at all. I have check that the sd card is FAT formatted and is working on my computer.

Also when using a logic analyzer, I can see that the MISO, MOSI, CS, and SCK signals appear to be working. However, pretty much all responses from the card (such as the CSD) return empty with all zeros. 

Below is the dts, config, and some notes about the board.

* MISO is tied high by an external resistor. 

Thanks in advance for the help

  • After updating to v2.1.0 I am now getting and error with disk initialization

    After calling, disk_access_init the error happens here in disk_access_get_di(). The disk access list and node appear to be empty so nothing is ever initialized. 

    I actually ran into this same problem when I was using v.2.0.2. I fixed it then by adding these settings to my config file

    Are there more settings I need to define for the newer SDK? 

  • Drew7997 said:
    Where are the logs saved to? I'm new to developing/debugging in this environment. 

    The logs are output on the selected logger backend, typically UART or RTT. See Logging in nRF Connect SDK for more details.

    Drew7997 said:
    I have made no modifications to the sample.
    Drew7997 said:
    After calling, disk_access_init the error happens here in disk_access_get_di(). The disk access list and node appear to be empty so nothing is ever initialized. 

    Are you building for a custom board? Did you try the sample on a nRF52833 DK first? Did it work with the card?

    If you are using a custom board, can you upload the board files and any overlays you are using? There might be some missing config in for your board.

  • Hi Jørgen, here is the board and fat_fs files. 

    This is a custom board I am developing. The module we are using is Fantsel's  BM833, which is built on the nrf52833 SOC.

    This module features an external clock which we had to configure in the proj.config file, just as an additional note.

    It seems to me like the SPI is working since the fat_fs that was built on the 2.0.2 SDK was able to read basic info from the card (memory size, format, etc), but just failed on the mounting step.

    For some reason when I upgraded to 2.1.0 however, it wasn't able to even read the chip at all.

    Because I was able to read the chip, I'm hoping its not a hardware issue. 

     

    microflow.zip

  • I too am getting this error after upgrade to 2.1.0 disk_agget_get_di() for drive "SD" is returning NULL.
    The disk access list is empty; this must have been populated by defalt in the old SDK and in the new not?

    Any progress on this one?

  • Hi Owain,

    No unfortunately no progress yet on my end. I've run out of things to try at the moment. Are you also using the nrf52833?

Related