SD Card Issues after updating to SDK 2.1

We have updated our firmware runnung on an nRF9160 from SDK 1.9 to SDK 2.1 using the now deprecated SPM (We will upgrade to TFM soon). 

When booting our firmware, we initialize and mount our SD Card using FAT filesystem. 

The function disk_access_get_di couldnt find any disk  (returned null) so after some research in this forum and on github we updated our devicetree as following:

NOTE: we had to define sck-pin, mosi-pin and miso-pin in order to make it work. 

And activated to following additional kConfig:

Now, disk_access_get_di found our sd card, but it crashed (immediate reset) at the following line:

SD Card initilization happens during initialization level 'POST_KERNEL'. We had to change this to 'APPLICATION' to make it work...

SYS_INIT(initSdCard, APPLICATION, CONFIG_SDHC_INIT_PRIORITY);

We try to understand if this is to be expected or a bug? What is the problem of running this on initialization level 'POST_KERNEL'? Also, could you update the samples? We think its outdated.. https://github.com/nrfconnect/sdk-zephyr/tree/v3.1.99-ncs1-branch/samples/subsys/fs/fat_fs 

Parents Reply Children
  • Hi Stian

    Once you handled this particular problem, could you also look into the following issue:

    When doing SD Card Initialization whilst in initialization level 'APPLICATION'  we can mount the SD card successfully. 
    I can Open, read and close files successfully on my SD Card. 

    However, when i open, WRITE and close file is get a 'fs: file close error (-5)' error. 

    Debugging this I see that the failure comes from a timeout in sdmmc_wait_ready, there i see that the card_busy ptr from sdhc_driver_api is NULL, hence the failure. 

    The screenshot should show everthing that is relevant:


    Writing the data actually WORKS, (i see Hello World in the file), but the system is blocked 10 seconds, as we k_busy_wait 10 seconds in  sdmmc_wait_ready.

    I do base my code on https://github.com/nrfconnect/sdk-zephyr/tree/v3.1.99-ncs1/samples/subsys/fs/fat_fs ... 

Related