Functional Description
www.ti.com
There is a slight difference between FAT12/16 and FAT32 when handling the Root Directory. On
FAT12/16, this directory has a fixed location (see above) and length fixed by BPB_RootEntCnt which is
the total number of 32 bytes entries. Handling this directory is therefore straight forward. On FAT32, the
Root Directory is like a standard file, the File Allocation Table (FAT) has to be used in order to retrieve
each sector of the Directory. The way the FAT is handled is described in the next paragraph.
Table 26-26. FAT Directory Entry
Offset Length[bytes] Name Description
0000h 11 DIR_Name Short Name (8+3)
000Bh 1 DIR_Attr File Attributes:
ATTR_READ_ONLY 01h
ATTR_HIDDEN 02h
ATTR_SYSTEM 04h
ATTR_VOLUME_ID 08h
ATTR_DIRECTORY 10h
ATTR_ARCHIVE 20h
ATTR_READ_ONLY |
ATTR_HIDDEN |
ATTR_LONG_NAME
ATTR_SYSTEM |
ATTR_VOLUME_ID
000Ch 1 DIR_NTRes Reserved, set to 00h
000Dh 1 DIR_CrtTimeTenth Millisecond stamp at file creation
000Eh 2 DIR_CrtTime Time file was created
0010h 2 DIR_CrtDate Date file was created
0012h 2 DIR_LstAccDate Last Access date
0014h 2 DIR_FstClusHi High word of this entry’s first cluster number
0016h 2 DIR_WrtTime Time of last write
0018h 2 DIR_WrtDate Date of last write
001Ah 2 DIR_FstClusLo Low word of this entry’s first cluster number
001Ch 4 DIR_FileSize File size in bytes
26.1.7.5.7.4 FAT12/16/32 File Allocation Table
The ROM Code needs to read the FAT in order to retrieve sectors either for the booting file or for the Root
Directory (in case the file system is FAT32).
There can be multiple copies of the FAT inside the file system (ROM Code supports only 2) located after
the Boot Sector:
FATn
sector
= BPB_HiddSec+BPB_RsvdSecCnt+BPB_FatSz x n
Its size is given by BPB_FATSz16 or BPB_FATSz32. The ROM Code checks each copy of the FAT if
identical. In case the values are different, the ROM Code uses the value from the last FAT copy.
With FAT32 file system, the copy system can be disabled according to a flag located in BPB_ExtFlags[7].
If this flag is set then FAT BPB_ExtFlags[3:0] is used. In this case no verification is made by the ROM
Code with other copies of FAT.
The FAT is a simple array of values each refering to a cluster located in the Data Area. One entry of the
array is 12, 16 or 32 bits depending on the file system in use.
The value inside an entry defines whether the cluster is being used or not and if another cluster has to be
taken into account. This creates a singly-linked chain of clusters defining the file. The meaning of an entry
is described in Table 26-27.
Note: For compatibility reasons, clusters 0 and 1 are not used for files and those entries must contain
FF8h and FFFh (for FAT12); FFF8h and FFFFh (for FAT16); ?FFFFFF8h and ?FFFFFFFh (for FAT32).
4140
Initialization SPRUH73H–October 2011–Revised April 2013
Submit Documentation Feedback
Copyright © 2011–2013, Texas Instruments Incorporated