This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SDCard busy after several writes

Hi,

I've modified the SDCard example to write every 2 seconds 80 bytes to a SD Card. The SDCard is correctly mounted and the File is opened and kept open.

After several writes the program hangs being busy

And then the timer expires and the program crashes. I've tested with several SD Cards big and small and it did not change something. Furthermore, I've tested with several SDCARD Frequencies but same here. Is there any reason why the program hangs?

Parents Reply
  • Okay solved now. The issue was related to the same undocumented issue before. If the cluster size is reached which is normally 32 kb the f_sync needs to shift the cluster. If during this sync a new write is called the fatfs freezes forever. This can only be handled if all write and sync operations are shifted to the main context and handled inside the while loop with flags.

    This is very uncomfortable and bad documented aswell. So please update the docu and make the example more explicitly for this case.

    Furthermore, the current implementation of the nrf_block_dev is not C++ compliant. Which was already stated in https://devzone.nordicsemi.com/f/nordic-q-a/21693/nrf_block_dev_sdc-h-c-compability and yet there was not solution nor work around for this issue. The only solution at the moment is to shift the NRF_BLOCK_DEV_SDC_DEFINE to an extra C file and write a init inside this c file which can be referenced in (extern "C") in a c++ class.

    Last but not least the app_sdcard does not use the SPIM module. Furthermore, I guess it would be a good  idead to use the spi_mngr for the SD card then I guess the syncing issue might be gone aswell.

    The issue can be closed although there is not yet a real solution.

Children
Related