0xAA55
at offset 0x01FE
Is there a FAT?
Was there
an MBR?
BPB_BytsPerSec
=
512
Yes
No
Success:
FAT12,
FAT16 or
FAT32
Failed
Yes
No
Yes
BPB_TotSec16 or
BPB_TotSec32
=
MBR_Partition_Size
Yes
No
Yes
Yes
Compute data area size to
determine FAT type
BPB_SecPerClus
=
1, 2, 4, 8, 16,
32, 64 or 128
BPB_RsvdSecCnt
>
0
BPB_NumFATs
=
2
BPB_RootEntCnt
multiple of
BPB_BytsPerSec/
32
or 0
Yes
Yes
No
No
No
No
No
Functional Description
Figure 26-22. FAT Detection Procedure
26.1.7.5.7.3 FAT12/16/32 Root Directory
The next task for the ROM Code is to find the booting file named “MLO” inside the Root Directory of the
FAT12/16/32 file system. The file is not searched in any other location.
For a FAT12/16 file system, the Root Directory has a fixed location which is cluster 0. For a FAT32 file
system, its cluster location is given by BPB_RootClus. The general formulae to find the sector number
(relative to device sector 0, not partition sector 0) of a cluster is given by:
Cluster
sector
= BPB_Rsvd BPB_NumFATs x BPB Cluster x BPB_SecPerClus
Note: BPB_FatSz is BPB_FatSz16 for FAT12/16 or BPB_FatSz32 for FAT32
Note: the BPB_HiddSec field can contain 0 even though the FAT file system is located somewhere other
than on sector 0 (floppy-like). The ROM Code actually uses the partition offset taken from the MBR
instead of this field which can be wrong. If no MBR was found (floppy-like) the value 0 is used.
Each entry in the Root Directory is 32 bytes long and hold information about the file, i.e. filename, date of
creation, rights, cluster location etc. This is described in
The ROM Code checks each entry in the Root Directory until either the booting file is found or the entry is
empty (first byte is 00h) or when the end of the Root Directory has been reached. Entries with
ATTR_LONG_NAME attribute (LFN) and with first byte at E5h (erased file) are ignored. When found, the
first cluster offset of the file is read from the DIR_FstClusHi/DIR_FstClusLo fields.
4139
SPRUH73H – October 2011 – Revised April 2013
Initialization
Copyright © 2011–2013, Texas Instruments Incorporated