gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > libfat problems

#117979 - SukkoPera - Thu Feb 08, 2007 11:47 pm

Here's a report of a couple problems I seem to have with libfat-based programs. They they seem more related to the fat implementation than to the DLDI interfaces, as exactly the same problems happen with both my SCL and my R4.

I have a 64 MB MicroSD that I use for testing, it's formatted FAT16 with 2 kb clusters: that gets corrupted every time I write a file with libfat on it.

On my 1 GB MicroSD (FAT16, tried with both 32 kb and 64 kb clusters), if I launch MCTool after I write something to the card using libfat, it will detect different FATs, and fix them correctly.

(No, it's not MCTool's fault: the same problem is detected if I check the card on my PC.)
[/list]
_________________
Nintendo DS Lite (White) + Supercard Lite + R4 + Sandisk 1 GB MicroSD
Sony PSP + Firmware 3.03 OE-A2

#118016 - chishm - Fri Feb 09, 2007 2:47 am

Only the first FAT is updated. This is within normal FAT specs, and is done by design so that the filesystem can be recovered in the event of a gba_nds_fat (and subsequently libfat) failure.

What type of corruption occurs on the 64 MB TF? It could be FAT corruption, directory corruption, long filename corruption, file corruption, or a combination of the above.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com

#118255 - SukkoPera - Sun Feb 11, 2007 4:51 pm

This is the error with 2kb clusters on the 64 MB card:

"File size is 4867 bytes, cluster chain length is 4096 bytes, truncating file to 4096 bytes."

So it would seem that partially used clusters get messed up?
_________________
Nintendo DS Lite (White) + Supercard Lite + R4 + Sandisk 1 GB MicroSD
Sony PSP + Firmware 3.03 OE-A2

#118313 - chishm - Mon Feb 12, 2007 2:25 am

Was the disc nearly full when this happened? I'm wondering if it tried to get a new cluster but couldn't, but it thought it had anyway.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com

#118319 - SukkoPera - Mon Feb 12, 2007 3:02 am

Actually yes, but I've tried deleting many files and get the same problem.
_________________
Nintendo DS Lite (White) + Supercard Lite + R4 + Sandisk 1 GB MicroSD
Sony PSP + Firmware 3.03 OE-A2

#118322 - chishm - Mon Feb 12, 2007 3:36 am

Really stupid question here, but bear with me. Did you close the file after you finished writing?
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com

#118348 - SukkoPera - Mon Feb 12, 2007 1:35 pm

Yes, I even call fatUnmount() thereafter. Would you like me to provide a raw image (made with dd) of the card?
_________________
Nintendo DS Lite (White) + Supercard Lite + R4 + Sandisk 1 GB MicroSD
Sony PSP + Firmware 3.03 OE-A2

#118387 - chishm - Tue Feb 13, 2007 12:20 am

Yes, that might help. Can you also provide a copy of the file you tried to write (the full file) so that I can try to find the missing data on the disc.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com