cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f2 SD card corruption

l239955_stm1_stmicro
Associate II
Posted on October 12, 2015 at 17:02

Hi to all,

Did anybody experience random corruption of bits (not byte) on a SDcard..?

We are using an stm32f217 with RTX, FlashFS and tcp from Keil, v4.70.

uSD card is connected through SDIO port.We are using 2Gb uSD card from Transcend (FAT32). After several days/months we get problems with the uSD card and we have spotted 3 different levels of corruption:

uSD card is not readable anymore by the embedded system but a computer can

uSD card is not readable both by embedded system and computer

uSD card is still readable but files are corrupted

After a while we discovered some random bits corruptions on the SD card (both in the FAT32 sectors and in the memory blocks). Some systems have been running for years without any problems..

Thanks in advance for your interest and replies!

Loïc
4 REPLIES 4
Posted on October 12, 2015 at 18:10

The computer/system not being able to ''read'' the card is a bit of a high level diagnosis. You'd need to dig a lot deeper into the file system structures and sector access level to make a real determination on the nature of the failure.

FAT is not a particularly FLASH friendly file system, it uses a lot of repetitive writing to specific areas of the media, and while mitigated by the micro-controller in the card. Can be further mitigated on the host side with caching and lazy-writers.

Do you have an error handling or retry code in disk access layer? Go flushing/removal handling?

Are there any mechanical, thermal or moisture issue with how the card is installed?

How fast are you clocking the interface? Placement of pull-up resistors? Using 4-bit mode? Observed bit error in the same bit positions in high/low 4-bit nibbles?

Waiting for DMA complete and FIFO to flush?

Pretty sure most code doesn't use CRC, you might need to add you own integrity checking.

Are the cards using SLC or MLC NAND?

Do you have an experiences with higher grade cards from SanDisk?

Stuff wears out, you'd probably need a method to identify failing cards, do fsck/chkdsk on the board, or be able to perform recovery/reformatting.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jpeacock
Associate III
Posted on October 12, 2015 at 19:41

How do you handle power fails or resets during a write to the card?  FAT is not a logged file system so an incomplete write is likely to corrupt something, especially if it's in a directory or the FAT allocation tables.  The errors aren't immediately obvious but do accumulate.  It would explain why the STMF2 can read the card but not a PC.

  Jack Peacock
l239955_stm1_stmicro
Associate II
Posted on October 15, 2015 at 16:49

--- this message is an error ---

l239955_stm1_stmicro
Associate II
Posted on October 15, 2015 at 16:49

Dear all

thanks for your time. here's more precision.

between the time, I have readed about FAT32 system. Have dumped my Sd card on an image. and check for the corruption.

it result that the corruption flip some random bit il large region. (it appear to be random... didn't see any pattern).

this phenomena occur one 2 system different with both different SD card.

those flipping bit are on :

- the volume ID [read only ?]

(see atachement pic)

- the root cluster [read/write]

(see atachement pic)

- rarely on other read access cluster.

wath is strange is that on both SD card the full root cluster is corrupted by those random flipped bit. And the corruption stop just at the second cluster.

I suppose FlashFs only write first sector of the cluster. not the whole cluster.

I now know that FAT32 is wrong with embded system. but it's not like the system was shutting down or somethings. We just lost SD card at some point during run time (1-2 week).

Waht can I tell more?

- we try to write as few as possible on the SD card. only log and sometime ini file when parameters changes.

- the device is in a clean dry environment and not specially hot ( ? 21°C ? )!

- it manage power of some kW. but is isolated from them. (oscilloscope measurement were done to have an idea.)

I run out of idea.

again, thanks for the help.

________________

Attachments :

rootclusterEnd.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0qi&d=%2Fa%2F0X0000000beR%2FKtVUby6Tg4Ktkwag6_L4sryZdmpAjRENHh30oPRqx_o&asPdf=false

rootEndofFolder.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0qY&d=%2Fa%2F0X0000000beQ%2FC9lgn1pM4V4teIDv3uHWcHHLfDok5cUBWcTqADFPkYw&asPdf=false

volumeID.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hzgu&d=%2Fa%2F0X0000000beP%2FbRhykyQbNplFiDpIwUp0sl38gR6I7s6vIDPPQfLKKQE&asPdf=false