Windows XP Formatting SD Card through Windows XP

Joined
Mar 25, 2009
Messages
2
Reaction score
0
Hi,

I am in the process of writing FAT16 compliant file system. I want to port it to SDCard, for this I am using 2GB SDCard(Sandisk). The basic formatting and writing data to the SDCard I am doing through windows(XP) only.

I am facing following issues-
1: Master Boot Record is missing and Partition Boot Record starts from zero sector.
2: Data file should start at the first sector of data area but doesn't starts there. Let me explain this-

I have read following values form Partiton Boot Record-
Bytes_per_sector = 512
Sectors_per_cluster = 64
Reserved_sectors = 2
Number_of_FAT_copies = 2
Maximum_Root_DIR_entries = 512
Sectors_per_FAT = 243

With the above information we can say that-
partition_start_sector = 0;
fat1_start_sector = 2; //partition_start_sector + Reserved_sectors
fat2_start_sector = 245; //fat1_start_sector + Sectors_per_FAT
rdir_start_sector = 488; //fat2_start_sector + Sectors_per_FAT
userdata_start_sec = 520; //rdir_start_sector + 32

As user data starts at 520th sector thus first file's data should at this sector, but instead of this first file's data is starting from 525th sector.

I am unable to figure out why this is starting after 5 sectors.

Thanks
Parag
 

crazylegs

Member Extraordinaire
Joined
Dec 31, 2004
Messages
5,743
Reaction score
64
You should always format SD cards in the device they are going to be used in or you will lose data through corruption..

Why do you need to format the card through windows..
 
Joined
May 27, 2007
Messages
2,534
Reaction score
0
Hi,

I also second what CL, has said the best way to format an SD Card is through the device its self. Often when you format through windows you will need to reformat the card again when you put it into the device.
 

floppybootstomp

sugar 'n spikes
Moderator
Joined
Mar 5, 2002
Messages
20,281
Reaction score
1,794
Aye, I formatted my SD card in NTFS once and my camera wouldn't recognise it.

Turned out it only liked FAT32.
 

muckshifter

I'm not weird, I'm a limited edition.
Moderator
Joined
Mar 5, 2002
Messages
25,739
Reaction score
1,204
... it's the best "numbers game" ever constituted. ;)

Nice link JaLing, I think you also read the "question" properly. :thumb:


Can I point out folks, ParagGupta is in the process of writing FAT16 compliant file system, he is merely using the SDcard to port it. The "device" don't really exist, that's the way I read it. :D


You should try FAT, or, as they call it now, FAT12 ... now that was fun!!


:wave:
 

floppybootstomp

sugar 'n spikes
Moderator
Joined
Mar 5, 2002
Messages
20,281
Reaction score
1,794
muckshifter said:
... it's the best "numbers game" ever constituted. ;)

Nice link JaLing, I think you also read the "question" properly. :thumb:


Can I point out folks, ParagGupta is in the process of writing FAT16 compliant file system, he is merely using the SDcard to port it. The "device" don't really exist, that's the way I read it. :D


You should try FAT, or, as they call it now, FAT12 ... now that was fun!!


:wave:

oops :blush:

That'll teach me to speed read... ;)
 
Joined
Mar 25, 2009
Messages
2
Reaction score
0
What my intention is formatting & loading files onto SDCard through windows then plugging same SDCard on some microcontroller and reading back files through my File System (off course in this case my file system code will be running from microcontroller).

I have verified the contents till rdir_start_sector through hex editor and all the things (FAT1/FAT2, RDIR) are starting at correct offset only user data is starting after 5 sectors (i.e. 525) from the actual one (i.e. 500).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top