When you search google for FAT file format you get tons of pages on formatting disks. It's harder to pull out the detailed format of the SD card. Wikipedia to the rescue (Design of the FAT file system). A less technical FAT32 Wikipedia page is File Allocation Table. Here's a helpful page in the references at the end of the Wikipedia page (The FAT filesystem).
I used my PC running Windoze to format an 8GB SDHC card. I can view the raw data on the card using HxD (How to use HxD as Disk Editor to save Sectors as Binary Files). Here is what the boot sector (first sector on the SD card) looks like:
.From the page (The FAT filesystem):
Here the FAT32 version of the boot sectors. Values from HxD <>. Bytes Content 0-2 BS_jmpBoot Jump to bootstrap (E.g. eb 3c 90; on i86: JMP 003E NOP. One finds either eb xx 90, or e9 xx xx. The position of the bootstrap varies. <0xEB5890> 3-10 BS_OEMName OEM name/version (E.g. "IBM 3.3", "IBM 20.0", "MSDOS5.0", "MSWIN4.0". Various format utilities leave their own name, like "CH-FOR18". Sometimes just garbage. Microsoft recommends "MSWIN4.1".) <"MSDOS5.0 "> /* BIOS Parameter Block starts here */ 11-12 BPB_BytsPerSec Number of bytes per sector (512) Must be one of 512, 1024, 2048, 4096. <0x0200> = 512 13 BPB_SecPerClus Number of sectors per cluster (1) Must be one of 1, 2, 4, 8, 16, 32, 64, 128. A cluster should have at most 32768 bytes. In rare cases 65536 is OK. <0x08> = 8 sectors per clusters 14-15 BPB_RsvdSecCnt Number of reserved sectors (1) FAT12 and FAT16 use 1. FAT32 uses 32. <0x083a> = 2106 decimal 16 BPB_NumFATs Number of FAT copies <0x02> 17-18 BPB_RootEntCnt Number of root directory entries (224) 0 for FAT32. <0x0000> = 0 root directory entries 19-20 BPB_TotSec16 Total number of sectors in the filesystem (2880) (in case the partition is not FAT32 and smaller than 32 MB) <0x0000> 21 BPB_Media Media descriptor type <0xF8> = Non-removable media 22-23 BPB_FATSz16 Number of sectors per FAT (9) 0 for FAT32. <0x0000> = FAT32 24-25 BPB_SecPerTrk Number of sectors per track (12) <0x003F> = 63 decimal 26-27 BPB_NumHeads Number of heads (2, for a double-sided diskette) <0x00FF> = 255 decimal 28-31 BPB_HiddSec Number of hidden sectors (0) <0X00002000> 32-35 BPB_TotSec32 Total number of sectors in the filesystem <0X00ECC000> = 15,514,648 sectors (8GB) 36-39 BPB_FATSz32 This field is the FAT32 32-bit count of sectors occupied by ONE FAT. Sectors per FAT <0x00003BE3> = 15331 dec 40-41 BPB_ExtFlags Mirror flags Bits 0-3: number of active FAT (if bit 7 is 1) Bits 4-6: reserved Bit 7: one: single active FAT; zero: all FATs are updated at runtime Bits 8-15: reserved <0x0000> 42-43 BPB_FSVer Filesystem version <0x0000> 44-47 BPB_RootClus First cluster of root directory (usually 2) <0x00000002> 48-49 BPB_FSInfo Filesystem information sector number in FAT32 reserved area (usually 1) <0x0001> 50-51 BPB_BkBootSec Backup boot sector location or 0 or 0xffff if none (usually 6) <0x0006> 52-63 BPB_Reserved Reserved 64 BS_DrvNum Logical Drive Number (for use with INT 13, e.g. 0 or 0x80) <0x80> 65 BS_Reserved1 Reserved - used to be Current Head (used by Windows NT) <0x00> 66 BS_BootSig Extended signature (0x29) Indicates that the three following fields are present. <0x29> 67-70 BS_VolID Serial number of partition <0xD086111A> 71-81 BS_VolLab Volume label "NO NAME " 82-89 BS_FilSysType Filesystem type ("FAT32 ") "FAT32 " The old 2-byte fields "total number of sectors" and "number of sectors per FAT" are now zero; this information is now found in the new 4-byte fields. An important improvement is the "First cluster of root directory" field. Earlier, the root directory was not part of the Data Area, and was in a known place with a known size, and hence was unable to grow. Now the root directory is just somewhere in the Data Area. The signature is found at offset 510-511. This will be the end of the sector only in case the sector size is 512.
FirstDataSector = BPB_RsvdSecCnt + (BPB_NumFATs * BPB_FATSz32) + RootDirSectors;
= 2106 + (2 * 15331)
= 32,768
The sector there is:
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.