Hey all,
more a general question than looking for a specific answer, but would like to know your experiences in this matter.
I'm using an NRF52840 (u-blox) connected to an SD Card using the SPI interface. Filesystem is FatFS as far as I can tell. Basically the file system and the SD interface are all set up automagically by Zephyr. Good or bad, no point arguing that, but comfortable.
This device writes at low speeds, 10 KBytes per second at most (so far) from a buffer, always trying to write out multiple of 512 bytes at a time. It's not too busy. After each write, I call the flush() or sync() function (don't have the code in front of me) to make sure the data persists on the SD card.
Data files can be displayed and then be retrieved over bluetooth, and that also works a treat, reading at about 500 kbps.
So far, so good.
In time, after much use (days? weeks?) the SD cards I've used seem to deteriorate. I can read them on Windows, it doesn't complain, but the micro either fails to init them, or sometimes it does init them but it can't read the file listing. Yet, if it inits them it seems to write data. Sometimes it can't do anything.
Swap the SD card and everything seems to work well again for a few days / weeks.
I still need to improve on a few things. When the micro is reset, the power to the SD card is off (no 3.3v), when a BLE connection is detected, the power to the 3.3V is turned on, card init'd and ideally all works. If I don't reset the unit explicitly, the 3.3V to the SD card would stay on indefinitely. That is something I need to fix. If not doing it's data logging, the unit just stays on basically. I'm sure I've covered most cases, it's unlikely that files are not closed after the micro's work is finished. Then again, I confess I have not tested all possible issues.
I wonder if you guys have experienced similar issues with SD cards using SPI? If so, if you were able to fix them or improve the reliability, what did you do?
Cheers,
Alberto