Hello, I am working on a datalogger based on a STM32F207IG microcontroller + 2GB SD CARD. The microcontroller read the ADC and continuosly saves data,event logs and alarms in different files. I'm having some trouble with my sd card formatted with the FAT/FAT32 file system. The problem is a file system corruption, data loss or an error returned by the fwrite after a long period of running. Due to these issues i decided to build a simple test firmware (a modified version of the project "File System Demo" provided by Keil in the Pack Installer) to verify the long therm stability of the FlashFs keil file system. The test firmware is programmed on a STM3220G board. Six tasks that continuosly copy twelve files (about 12/13Mb each file) from one source folder to a destination folder in append mode. Each task has its own source and destination folder. Three tasks have a priority of osPriorityNormal, and three tasks have a priority of osPriorityAboveNormal. This operation it is repeated thirtytwo times (the complete test takes about ten/twelve days). If I format the SD CARD using the FAT32/4096Bytes, after about 3/4 days I get an error from the fwrite function (it returns a value different from the number of elements I want to write). If I format the SD CARD using the FAT file system, the test ends but if I take the sd card from the demo board and I insert it in my PC it appears that not all files are correctly copied (one file is truncated and others files contains 0 bytes). What could be the cause of this data loss/corruption? I want underline that - The SD CARD is ok, I tested it all bytes of the SD CARD with a stress tool. - No power loss happened during the test - THE NUMBER OF BLOCK EREASE/WRITE CYCLE IS VERY FAR FROM THE SD CARD SPECIFICATIONS (ABOUT SEVEN EREASE/WRITE CYCLES PER BLOCK for each test cycle)
The MDK-ARM version is 5.12.
I attach the entire project build for the STM3220G board and the SD CARD directory structure (small files for a preliminary test. Use bigger files for a intensive test).
wikisend.com/.../Test demo board x32.zip
Thankyou.
Best Regards.
We had the same problem. If you are doing the SD control through the SPI then make sure you have the new library's version * @version V1.1.1 * @date 20-November-2015 They fixed some bugs on the SPI functions.
Hope that gives you a light.
Cheers