Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I've got a bizarre problem reading SD cards on Windows XP. The cards are formatted FAT16 and I am writing data to them from a microcontroller. When I put the cards into a Windows XP machine, the directories and files appear with the correct size and date and time stamps. However, if I try to look at the properties of a file the dialog that pops up says that it is zero bytes and does not know what the date and time stamps are. If I try to open the file with Visual Studio or Matlab I get an error that the file does not exist. But I can open the drive in a hexeditor and see that the data is written to the drive (with appropriate FAT and directory entries). I can also take the SD card over to a Linux machine (I've used both Fedora Core3 and Knoppix) and read and edit the files without any error messages.
For the record, I have verified that my code matches the Microsoft FAT standard and I'm only using short file names. I've reformatted the cards with both Linux and XP to be FAT16 with the appropriate cluster size and everything. None of the formatting seemed to make a difference. To speed up writing to the SD card on the microcontroller, I preallocate the files to fill up all the available clusters in one sector of the FAT. I've tried various other options for writing the files with the microcontroller but none of them are fast enough to support the data rate I need.
So... does anyone know what I'm doing wrong? Why does Linux not have a problem with the file and WinXP does? Is there a difference in how the two OS's read the master boot record, BIOS Parameter Block, or FAT? Why does XP show the appropriate file info when I use My Computer but then tell me that the files are zero size when I try to look at their properties. Any help would be appreciated.
Thanks,
Craig

I may be off track but....SD memory cards are usually formatted FAT32 (never FAT16).
I also read from my digital camera FAQ that these cards should never be formatted by anything except the camera itself.
i_XpUser

i don't have to say which is the better OS if it can't even get those simple things like reading a SD card :-)
but a similiar annoyance occurs to me any time i boot my pc in xp with a sd card connected, it always kicks in scandisk ... i'm dying to read a solution or at least a reason for it ... although xp is reading my memory cards correct.
maybe it's my external reader, i really don't know. i kinda gave up and pull the reader prior to booting xp :-)
Today's subliminal thought is: 'Calm down ... it's only ones and zeros.'
icq 10183575

XpUser... there is a quick little calculation that determines whether a card should be formatted FAT16 or FAT32. It turns out the only thing that matters is the number of clusters on the card. As a general rule, anything less than 2GB will support FAT16. Most SD cards come preformatted FAT16 which is why I picked it. I don't want the end user to have to reformat the card before using it.
mattie... there are a couple of bits that can be set in the FAT table that indicate to XP that the SD card was not shut down properly and that scandisk should be run on the next bootup. XP is supposed to clear those bits during it's shutdown routine. Are you shutting the machine down in a "nice" way so XP can finish writing everthing? Maybe those bits are always set and never cleared.
I did notice in the Administrator tools that you can set whether you can yank out a card without clicking on the "Safely Removing Hardware". You might want to see if that is enabled. It's under Administrative Tools->Disk Management-> Drive (whatever). Click on the Disk # to the left of the drive you want to change the setting on and then click right click on properties. Under the Policies tab you have two options. See if that helps.

yeah, might be this bad habit, pulling the card when i need it without asking my pc permission :-)
Today's subliminal thought is: 'Calm down ... it's only ones and zeros.'
icq 10183575

I guess You're correct it's fat16 (?) under 2GB. SD knowledgebase is vague on whats what - maybe it's a trade secret, who knows.
I also read that you should right-click the memory card drive and select EJECT before pulling it out.
i_XpUser

they're not Pull 'n Play? :-)
Today's subliminal thought is: 'Calm down ... it's only ones and zeros.'
icq 10183575

Did you put syslinux on it?
As normal things go MS and linux seem to be at odds. Might have to wipe out the mbr area and put a new one on if you did fool with it for a while. There was some old ranish notes about that. Might be on his site still.

I installed damn linux on my sd card. The format is exactly fat16.
No problem read/write files from xp or linux.
If you devide sd card into many partitions, Linux can recognize all partitions, but xp can only recognize one partition (only the first partition), you made.
I only see this weakness of xp.

I have tried formatting the card (actually several cards) under both Windows and Linux but I have not made it bootable under either OS (no syslinux or MSDOS boot stuff). I get the same result regardless of which OS formatted the card. I'm pretty sure it's an error in my microcontroller code that writes the file system to the card. I'm hoping that, if I can find out why Linux handles the disk differently from XP, I can figure out what I'm doing wrong on the microcontroller.

![]() |
Internet Explorer Homepag...
|
startup fails
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |