#173127 - gorka - Tue Mar 23, 2010 5:32 pm
how stable is libfat against turning off the GBA during read/write processes?
Is it known for causing trouble into the memory cards? (damaging/corrupting files or making the whole card unreadable)
I am planning a project that will require a lot of reading a writing to the Mini SD card in my M3 perfect and would like to know if there is anything I should consider to avoid possible damage to files or the card.
Thanks in advance
#173130 - wintermute - Tue Mar 23, 2010 7:07 pm
Turning off during read will cause no issues.
Turning off during write is likely to cause data loss of some description, that's why gba games have a banner advising the user not to switch off while saving to eeprom.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog
#173139 - Dwedit - Wed Mar 24, 2010 12:35 am
Pre-alllocate big files at a time when people wouldn't be turning off the system. That way it's not interrupted during critical stuff (like writing to the FAT tables or directories). The only thing you could lose would be the last 512 bytes of the file's data.
You need to call fflush() when you want to empty stdio's buffer to the disk.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#173140 - Ludo6431 - Wed Mar 24, 2010 1:22 am
Just show when you write data (so the user is warned) and setup a checksum system to verify that the file isn't corrupted.
_________________
Sorry for my poor english, I'm french.
#173150 - gorka - Wed Mar 24, 2010 9:10 am
Thanks a lot for your replies.
Dwedit, you mentioned:
Quote: |
Pre-alllocate big files at a time when people wouldn't be turning off the system. That way it's not interrupted during critical stuff (like writing to the FAT tables or directories). The only thing you could lose would be the last 512 bytes of the file's data. |
Sorry for my ignorance, but what exactly do you mean by Pre-allocating the files?
Quote: |
Just show when you write data (so the user is warned) and setup a checksum system to verify that the file isn't corrupted. |
My problem is that I plan to write little amount of data, but very frequently, so the warning is likely to be on and off all the time. But I would definitely add some kind of way to warn the user (a red dot or something like that)[/quote]
#173160 - Dwedit - Wed Mar 24, 2010 3:46 pm
That means if you want to make a file that might get bigger as more stuff is added to it, just make a big file immediately, and let more and more data gradually fill the file.
Of course, you need to track the actual size of the data inside separately from the file's size.
Or you can just allocate double the file size, then alternately write to the first half, then the second half. Use a checksum so you know whether it is good or not, then use an increasing sequence number so you know which half is newer.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."