Re: Compact flash with 8051 - sector numbers all wrong

Hello, I'm working on a project to read files from a PC-formatted

>compactflash card using an 8051. CF card is in 8 bit memory mode. I can >read & write its control registers OK, and I've used "WinHex" to display >the FAT16 structure of the card so I know what's going on in there. > >Here is my problem: reading sectors 0x01-0x20 all return the boot sector >which WinHex shows at 0x00. Sector 0x00 returns some data I don't >recognise. From sectors 0x21 onwards, the 8051 reads the sectors which >WinHex shows at 0x01 onwards, i.e, all sector numbers seem to be 0x20 >higher than they should be. Apart from that, I can read the sector data >correctly so it seems like the hardware interface is fine. I'm using LBA >addressing, I can't get my head round Sector/Cylinder/Head mode. Can >anyone tell me what's going on here?

Tim,

The way it sounds you stumbled over a common misinterpretation.

Removeable media can be formatted in two flavours. With one you have a partition table, and then at the offset specified by the partition table you have the FAT MBR and remaining parts of what forms the FAT filesystem(s) etc. The other flavour does not have a partition table and the medium directly starts with the FAT MBR. This latter case is what happens if Windows formats a removeable media. Windows recognizes both cases. WinHex by default showes you the start of the MBR. If memory serves you can put it into some sort of "physical" mode where you should be able to look at sector 0 on the PC end also and where you will see the IMHO present partition table of your specific CF also from within WinHex.

HTH

Markus

Reply to
Markus Zingg
Loading thread data ...

My authoritive source is "Disk Operating System Version 3.30 Technical Reference" by IBM, pages 9-6,7. Probably long out of print.

Reply to
Jim Stewart

It was a PITA to understand. There are other better descriptions of the FAT file systems out there I think. Though this was during a stressful time last year and my memory may be wrong. ;)

Reply to
Brett

What I do like about the document is that it clearly showes WHAT EXACTLY Microsoft does when it comes to recognizing FAT Media and also clears up a couple of other often misinterprated things. I agree that there are good other sources and I also agree that one most likely will also need other sources if starting from scratch. However, the others (otherwise good ones) I found all lacked this very information which I found important. I was asuming that the original poster will do a google search and actually just wanted to make sure he is going to read the one from Microsoft too.

Markus

Reply to
Markus Zingg

In article , Markus Zingg writes

I've got the MS Fat32 document but it does not describe the partition table, or at least I can't find it. It seems to start with the boot sector.

--
Tim Mitchell
Reply to
Tim Mitchell

Yes, you need other sources also. I found this one pretty usefull - along with the document from Ms

formatting link

HTH

Markus

Reply to
Markus Zingg

Markus, could you please provide a link to the document you are referring to?

--

Regards
David Milne
Reply to
David Milne

I downloaded two pdf's from microsoft, but did not have the URL redy cause it's a while ago. One is caled "fatgen103.pdf", the other "fatformat.pdf". I hope Google will show up a place to download them, if not let me know.

Markus

Reply to
Markus Zingg

Thank you for those filenames Markus.

Here are the locations of the files.

formatting link
formatting link

--

Regards
David Milne
Reply to
David Milne

Tim Mitchell moved upon the face of the 'Net and spake thusly:

Once place is

formatting link
(specifically Hale Landis' "how it works" documents)

--cjb

Reply to
Christopher Biggs

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.