FatFS compatibility with windows question - Page 1
Forum section: electronics / general

author: SimonR
author_rank: Regular Contributor
timestamp: May 15, 2019, 10:39:24 am
content: I bolted FatFS into an existing system, its really painful to use but its working. I can format write a file and read the data back.However it doesn't seem to be reliably compatible with windows, windows XP in this case.If I let FatFS do the format when windows sees the card in a card reader it wants to format it again.If I let windows format the card the FatFS will happily use the format (it doesn't want to re format) and will add files to it.But if I create a file write data and then close it windows will once again ask to reformat.Anyone have experience of this problem?I am using an ATMEL ARM9 and the FatFS library is the one from an ATMEL example project. Maybe I should try the latest version in case there were issues with the version I have, or maybe I've done something wrong.Its annoying I can create my files and I can see them on the card but windows cannot.

author: ehughes
author_rank: Frequent Contributor
timestamp: May 15, 2019, 02:50:04 pm
content: I have been using Chan FatFs for awhile (since 2008ish) with various media (SD cards, USB Thumb Drives, custom flash, etc, USB MSC). with little issue. I ran into a wierd formatting issue with 64GB drives in 2013 but windows could always see the formatted drive.The best thing is always to pull the latest source from his website and integrate into your project. There are lots of config options so study those caefully.

author: magic
author_rank: Super Contributor
timestamp: May 15, 2019, 08:45:26 pm
content: Maybe try scandisk or fsck on Linux to see what problems supposedly exist with the filesystem.The FS is still readable in your device after reinserting the card, just not in Windows?

author: thm_w
author_rank: Super Contributor
timestamp: May 15, 2019, 09:22:19 pm
content: I haven't had this problem. Post the format function and the parameters you are passing to it.Are you also closing the file properly? The correct step is something like f_sync(), then f_close(), but you might want to double check.

author: SimonR
author_rank: Regular Contributor
timestamp: May 16, 2019, 10:56:31 am
content: The FatFS library code is included in my projet exactly as is with no modifications so ai can just replace it with latest code.Thats because its never a good idea to modify anything before you know it works.I'll try latest code later when I have a bit more time, Windows support isn't crtical yet but will be, at the moment it does what I needed it to.The media card is 1.9 gig actually 0x39CFE0 blocksIn my case the media is not read in a card reader it is made available to windows through USB as a mass storage device which works perfectly.scandisk or fsck on Linux is a good idea I'll try it to see if it lets me know what windows is unhappy about.f_sync() is not needed before close as f_close() calls it internally anyway.This is my format functionCode:FRESULT FileSys_Format(uint8_t drv){FRESULT res;uint32_t count;disk_ioctl(drv, GET_SECTOR_COUNT, &count);printf("\r\n""-FS- Format disk %d to %u blocks", drv, count);printf("\r\n""-FS- Please wait a moment during formating...");res = f_mkfs(drv, // Drv0, // FDISK partition512); // AllocSizeprintf("\n\r-FS- Format disk finished !");if( res != FR_OK ) {FileSys_DisplayResult("f_mkfs", res);}return res;}

author: ehughes
author_rank: Frequent Contributor
timestamp: May 16, 2019, 06:52:38 pm
content: What version of the library are you using. It must be a bit older as the current docs have a different set of arguments for f_mkfshttp://elm-chan.org/fsw/ff/doc/mkfs.html

author: SimonR
author_rank: Regular Contributor
timestamp: May 16, 2019, 07:10:06 pm
content: Quote from: ehughes on May 16, 2019, 06:52:38 pmI'm not sure where to look for the version number so I'm going to stick my neck out here and say its really really old.The most recent comment in ff.c is Apr 01,'08 R0.06.This could be my problem. As I said I used the ATMEL example code (on an ATMEL device) and once I got it working I thought it would be good enough until I tried to get windows working with it.Its working well enough for the time being so I'll live with it as I won't be able to try the latest library for a couple of weeks.EditLooking at the date again I guess its version R0.06

author: thm_w
author_rank: Super Contributor
timestamp: May 16, 2019, 10:48:58 pm
content: Quote from: SimonR on May 16, 2019, 10:56:31 amYeah thats right, was using f_sync in case SD is pulled during use.It looks like the old version is a bit different:http://irtos.sourceforge.net/FAT32_ChaN/doc/en/mkfs.htmlNew version you can specify FAT/FAT32 etc:Quote

author: stj
author_rank: Super Contributor
timestamp: May 17, 2019, 07:48:27 pm
content: windows xp and newer dont actually handle FAT32 very well.i speculate that it's intentional to force people to use NTFS.i have seen windows reject and threaten to format stuff that works just fine in Linux and embeded devices for years now.