Hi there!
I'm encountering a very nasty FAT corruption problem. The problem appears systematically after a first write in a file stored in an uSD card.
There is a workaround: to place the file at the very beginning of the uSD card or in the first 2Gb of uSD space. In this case the problem is avoided whaterver the number of writes (hundreds) !
The problem does not appear during file reads. For instance I can place the BOOT.BIN at the very end of the uSD card (after 23Gb of data) and the system boots OK every time! I manage to read without probles configuration files placed also at the high end of the uSD capacity.
The FAT corruption is quite strange since I use standard ff.c functions (version R0.10b, 19 May 2014, included in Vivado 2015.2 ) in order to open the pre-existing file and to write data into.
The file is contiguous and its size remains constant so there should be no cluster allocation/change. Despite this after the first write in the file I see the first sector number truncated. Runing chkdsk detects an file entry crossing which is quite abnormal since once again I use standard access functions.
My application:
-Bare Metal on PicoZed (Zynq 7020)
-Vivado 2015.2 (project legacy reasons)
-xilffs 3.0
-uSD SanDisk MaxEndurance, 32Gb HC I U3 C10
-Standard factory FAT32 formatting (512bytes sector size, 32768bytes cluster size).
I force a uSD check-up and the card is free from errors prior to an atomic writing. After a first write, if the file is in a "high" position the portion of FAT concerning the respective file appears to be corrupted.
One hypothesis is that the initial formatting of the uSD is not compatible with the xilff library. What formatting works for you and with what capacity ?
Any help will be greatly appreciated.!!!
Regards,