cancel
Showing results for 
Search instead for 
Did you mean: 

SD Card + FATFS USB MSC data Corruption Issue

pankaj4
Associate II

Originally posted in TouchGFX Forum - moved & merged with duplicate.


Hi,

I am working on the STM32F439 development board. I am creating a test.csv file and logging data using FATFS on an SDIO SD card. I can view the data through USB MSC on a Windows PC. However, when I open the file in .csv format or edit some data from the PC, and then reconnect the board to the PC, the data gets corrupted or changes.

Does anyone know about this problem? If so, please help me.

Thank you!

Best regards,

Pankaj

3 REPLIES 3
pankaj4
Associate II

 

Hi,

I am working on the STM32F439 development board. I am creating a test.csv file and logging data using FATFS on an SDIO SD card. I can view the data through USB MSC on a Windows PC. However, when I open the file in .csv format or edit some data from the PC, and then reconnect the board to the PC, the data gets corrupted or changes.

Does anyone know about this problem? If so, please help me.

Thank you!

Best regards,

Pankaj

You've posted in the TouchGFX forum, and tagged this as TouchGFX - but it doesn't seem to have anything to do with TouchGFX?

Thread now moved.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
Ozone
Principal

I'm pretty sure the problem is within your STM32 application code.
I would suggest the call the fflush() - equivalent after every write operation.
If I remember correctly, this is f_sync() in the FatFS context.

And of course you need to be careful when to remove the SD card or turn off power to the board.
Write acces can take some time, if you interrupt it, you get file corruption as well.