Question:
Out of purely a curiosity thing I formatted an SD Card using Windows XP and a card reader. I then looked at sector 0 and found the FAT32 information as per MS.
I then ran a Keil example program on my ST eval board and formatted the SD Card using the /fat32 switch.
Whn I looked at sector 0 I could not find the FAT32 MBR.
BUT, At offset 0x1BE of sector 0 I found some non-zero bytes.
00 01 01 00 0B FE FF FF 08 01 00 00 FF 22 B7 03
After further research I found this info:
The next 64 bytes contain the partition table. Information on each partition begins at the following offsets: Partition 1: 0x1BE (446) Partition 2: 0x1CE (462) Partition 3: 0x1DE (478) Partition 4: 0x1EE (494) Each partition table entry contains the following information (offsets are for partition 1): Offset Length Contents 0x1BE 1 byte Boot Indicator: 0x00=no boot, 0x80=boot 0x1BF 1 byte Starting Head 0x1C0 6 bits Starting sector. Bits 0-5 are used 0x1C1 10 bits Starting Cylinder: Bits 6-7 of 0x1C0 are used with this byte. Max value is 1023. 0x1C2 1 byte System ID ID Partition type 0x1 FAT12 primary partition or logical drive (fewer than 32,680 sectors in the volume) 0x4 FAT16 partition or logical drive (32,680–65,535 sectors or 16 MB–33 MB) 0x5 Extended partition 0x6 BIGDOS FAT16 partition or logical drive (33 MB– 4 GB) 0x7 Installable File System (NTFS partition or logical drive) 0xB FAT32 partition or logical drive 0xC FAT32 partition or logical drive using BIOS INT 13h extensions 0xE BIGDOS FAT16 partition or logical drive using BIOS INT 13h extensions 0xF Extended partition using BIOS INT 13h extensions 0x12 EISA partition or OEM partition 0x42 Dynamic volume 0x84 Power management hibernation partition 0x86 Multidisk FAT16 volume created by using Windows NT 4.0 0x87 Multidisk NTFS volume created by using Windows NT 4.0 0xA0 Laptop hibernation partition 0xDE Dell OEM partition 0xFE IBM OEM partition 0xEE GPT partition 0xEF EFI System partition on an MBR disk 0x1C3 1 byte Ending head 0x1C4 6 bits Ending sector. Bits 0-5 are used 0x1C5 10 bits Ending cylinder. Bits 6-7 of 0x1C4 are used with this byte. Max value is 1023. 0x1C6 4 bytes Relative sectors. The offset from the beginning of the disk to the beginning of the volume, counting by sectors. 0x1CA 4 bytes Total sectors. The total number of sectors in the volume.
So, I determined that at offset 0x108 (or 135,168 bytes) into memory that the FAT32 table should reside there. After reading a memory block starting at 135,168 I did find the FAT32.
Question then: Why does Keil library skip 135,168 bytes before writing the FAT table?
Also, as a side note, if the Card is formatted by Keil library and then tried to be reformatted by Windows it fails. If I blow away sector 0, then Windows can reformat the disk? If Windows formats the disk, Keil code can operate with it fine.
Although most of this is irrelevant to the casual user if you just use the library out-of-the- box, I usually do not 'accept on faith' that binaries will properly function.
Thus, the curiosity.....