Using STM32Cube_FW_F4_V1.18.0 + SDIO + FATFS R0.12c + FreeRtos compiled in Atollic(was previously using IAR and saw the same issue there)
I am logging info to a uSD card. I have 3 types of messages of which one is 524bytes long. I have been getting errors when decoding the logfiles and I believe that I have traced it to a fatfs (possibly a sector) issue.
When the write begins at a 512byte boundary, or 1 or two bytes before I see a corruption.
If the write begins on the 512 byte boundary then I see the first byte is 0x00 and in the 512 byte sector everything else is written in order but the last byte is missing. Then the tail of the write in the next sector is correct.
If the write begins 1 back from the 512 byte boundary then that first byte is correct, the second byte(first in new sector) is 0x00, then the data being written is started again from the first byte! Then all data in that sector is in order but we are missing two bytes from the end of the sector. Then again the tail of the write in the next sector is correct.
If the write begins 2 back from the 512 byte boundary then it repeats the above pattern with 3 bytes missing from the end of the sector.
Note that I see this in the very first write in a file so I hope others can reproduce it.
Looking through the CubeMX config values it pops out that the sector size (min and max) is 512bytes so I wondered if the problem is writing with a length greater that the sector size?
Please let me know if any of this is unclear or there is other info that could be useful.
Does anyone have any idea on what could be causing this? And how to fix it?