Global Sources
EE Times-India
Stay in touch with EE Times India
EE Times-India > Embedded

Using FAT16/FAT32 systems in CF devices

Posted: 02 Feb 2004     Print Version  Bookmark and Share

Keywords:FAT16/FAT32 system 

cation tables (FAT) to common


paper will focus on the issues of

FAT, and how it relates to com-


erate large file sizes.

/PDF document

By William Heybruck

Sr. Applications Engineer

Hitachi Global Storage



This article introduces file allo-

cation tables (FAT) to common


paper will focus on the issues of

FAT, and how it relates to com-


erate large file sizes.

The reason that FAT is now

important to CF users is that

devices that require, or are op-

timized by using, storage ca-

pacity greater than 2.14GB

need a different type of FAT

than those that use fewer than


Not since the application of

a hard disk into PC has this

topic been so important. The

next section is written for those

who are interested in the his-

torical background relative to

FAT. If that is not of interest to

you, feel free to continue with

the clusters section.

When the first PCs were de-

veloped, they used floppy disks

with a capacity of 180KB, soon

followed by double-sided dis-

kettes of 360KB. These were

the 5 1

/4 diskettes that you

probably noticed in your

father's PC. To organize data

on these storage devices, the

initial developers of the disk

operating system (DOS) cre-

ated tables to indicate which

sectors belonged to which files

and which sectors were vacant.

This allowed the operating sys-

tem (OS) to make maximum

use of the limited space on

these diskettes. Files could be


ous series of sectors available.

The data for the files could be


the diskette in an organized

manner that is now called frag-

mentation. However, at that

time, it would have been better

if you can store your data on the

same diskette as the OS so you

don't have to keep switching

diskettes in and out during the

operation of the program.

There are 768 sectors on a


had to be big enough to identify

each of the 768 sectors and al-


the developers knew that larger

diskettes were coming. Using

1byte per table entry only per-


would not do. Two bytes would

permit 16,384 entries and

would be wasteful of disk space.

So the decision was made to use

12bits (1.5B) as the length of

the table entries to keep track

of sector usage on these first


This permitted 4,096 pos-

sible values. If each entry refer-

enced a single 512byte sector,

then this FAT could handle

storage devices of up to 2GB.

However, this resulted in long

tables that took time to retrieve

and could not be kept in

memory--since memory sizes

were usually less than 64KB!

So the concept of clusters

was incorporated. This in-

creased the minimum element

of storage on a device from a

single sector to a fixed number

of sectors, called a cluster. For

the first 180KB diskettes, the

cluster size was 1,024bytes.

Thus, if one was saving a

500byte file, it would occupy

1,024bytes on the diskette.

This seems wasteful, but in re-

ality, the cluster concept works

great on larger files. Table 1 il-


of clusters that can be repre-

sented by a FAT.

Allocating sectors to files

The smallest element of an ad-

dressable storage on a disk is


512bytes (or characters). Since

most files are larger than a sec-

tor, an even larger amount of

storage should be the smallest

amount allocated to any par-

ticular file. This allocated

amount is called a cluster; and

depending on the capacity of

the storage device (diskette,

flash card or hard drive), the


optimum use of the device. On

the early 360KB diskettes, the

cluster size was 2 sectors

(1,024bytes). Using the first


was increased to 8 sectors

(4,096bytes). Typical cluster

sizes for CF devices today are

8K (8,192bytes) or 16K


2GB have a cluster size of 32K.

Table 2 illustrates the maxi-

mum size of a partition given a

cluster size and a FAT type.

Why clusters? The alloca-


is somewhat random. On a new

device, files are saved in a se-

quential manner. Knowing the

Using FAT16/FAT32 systems in CF devices

starting sector, ending sector

and length would be enough to


some time--when some files are

erased and some files grow in

size--it is easy to comprehend

that the file will no longer be

contained in a contiguous se-

ries of sectors. A method is

needed to identify which sec-

tors are allocated to certain

files, and which sectors are

available. Having a method to


a table with an entry per sector.

Since most files consist of mul-

tiple sectors, this table would

be overkill. Hence, a table

where each entry represented a

fixed number of sectors makes

more sense. That fixed number

of sectors is called a cluster.

Given that the smallest

amount of storage one can allo-

cate to a file (a cluster) depends

on the media the file is stored

upon, we must have a method

that will indicate that a cluster

is either available or allocated

to a file. If a cluster is allocated

to a file, then we must know

which part of the file this clus-

ter is allocated to. This can be

accomplished by FAT. The FAT

is merely a list of N numbers,

where N is the maximum num-

ber of clusters on the device.

The number of bits in each en-

try is called the FAT size, and is

one of three values--12, 16 or

32. Early storage devices used

a 12bit (byte and a half) FAT to

reduce waste, as 12bits would

accommodate up to 4,096 clus-

ters. Given a cluster size of 2

sectors (1,024bytes), a storage



be handled with a larger cluster

size. However, more space

would be wasted on smaller

files and clusters that were

not full.

The OS determines what

size FAT to use based on the

number of clusters it takes to

represent the entire disk

space. If the disk requires less

than 4,096 clusters, then a

12bit FAT is used. If it is less

than 65,536 clusters but more

than 4,096 clusters, then a

16bit FAT is used. Otherwise,

a 32bit FAT is used for the de-

vice. The cluster size is speci-

fied in the first sector of the

FAT size in bits Number of clusters













Drive partitions

Number of partitions


Figure 1: A storage device may be split up into multiple partitions/drives.

Table 1: Clusters per file allocation table.

0 1 2 3 4 5 6 7 8

0 1 2 3 4 5 6 7 8

FAT examples

An empty 16bit FAT

A 16bit FAT with a single file entry

This FAT illustrates that the first cluster is number 0, the second is number 1,

the third is number 2, the fourth is number 6 and the last is number 7.

This FAT has 2 files. One has 3 clusters (0,1,8) and the other has 2 clusters (2,6).

0000 0000 0000


0001 0008 0006

0002 0006







0000 0000 0000 0000








device in a list of numbers

called the BIOS parameter

block. The OS can read this

sector during boot, so it can

configure how to read files

from the storage device.

The FAT is a linked list

table. A linked list table is one

where related entries point to

one another. For the FAT, the

device directory contains the

name, size of the file and the

number of the first cluster al-

located to that file. The entry

in the table for that first clus-

ter contains the number of the

second cluster in that file. This

continues until the last cluster

entry for that file, which will

contain all F's indicating it, is

used. The first file on a new

device will use all sequential

clusters. Hence, the first clus-

ter will point to the second,

which will point to the third,

and so on.

In reality, the first cluster


OS information, the root direc-

tory and two copies of the FAT.

The system creates two copies

of the FAT so that should the

system be interrupted (crash)

while modifying one of the cop-

ies, the other copy is still intact

and a recovery program may

check the FAT and recover it

using the copy.

Big deal?

So what is the big deal about

FAT? Up to now, CF storage de-


16bit FAT. Digital cameras and



structure. With the coming of

the 4GB microdrive, the 16bit

FAT is not large enough to

handle all the sectors. With


be represented; and with the

maximum cluster size of 32KB,

only 2.14GB can be accommo-

dated in a single FAT. There are


size to 32bits, or split up the

storage device into multiple





entities where each partition

appears as a separate storage


Each partition would then

have its own directory and FAT.



disk when you only have one

hard drive but have a "C:"and

"D:"drive not counting your

CDROM drive.

Most portable devices such

as cameras and MP3 players are

not programmed to accept par-

titions. On the other hand,

PDAs' file system routines are

designed for partitions.

For the digital camera mar-

ket, storage devices need to

have a single partition to be

compatible. Figure 1 illus-

trates a drive split into one, two

or three different partitions. To

the user, each partition will

have its own logical drive letter

and will usually be assigned

drives--C:, D:, E:, etc.

FAT inter-compatibility

Using a FAT16 storage device

in a host compatible with

FAT32 will operate seamlessly

because operating systems that

support FAT32 will also sup-

port FAT16. The only caution

is when you want to reformat

the FAT16 device. Some

FAT32-compatible hosts will

default to a FAT32 format, un-


doing this for the first time,

watch the prompts carefully to

ensure you will keep your

FAT16 format unless your cam-

era, MP3 player or PDA sup-

ports FAT32.

Using a FAT32 device in a

FAT16-compatible host will re-

sult in several possible out-

comes. The most common is

that the ubiquitous CF error

appears on the display. Should

a 4GB device be formatted in a

FAT16-only-compatible host,

the drive will format without

error, but should indicate a

2GB capacity. Note the word

"should". Different program-

mers can use different methods

to handle this issue. For this

unusual case, the result is not

always predictable. If a 4GB de-

vice is formatted with FAT16,

one can reformat the device in

a FAT32 compliant host--as

long as the FAT32 is specified

during the format session. This

will enable the user to regain

the full 4GB capacity in a

FAT32 compliant host.



partitions, FAT32 is the only

answer to provide them with

storage in excess of 2.14GB.

To provide for compatibility

with more devices, the 2GB

microdrive will continue to use

FAT16. Other compact flash

devices must jump on the

FAT32 bandwagon as their ca-

pacities exceed the 2GB bar-

rier. The good news is that sev-

eral companies are already sup-


and MP3 players. Most PDAs

that have a CF slot support

FAT32 today.

If you are planning to pur-

chase a new digital camera or

MP3 player, it would be a good

idea to verify that it does sup-

port FAT32 for future compat-



Figure 2: File allocation table examples.





















Cluster size (bytes) FAT 12 (MB) FAT 16 (MB) FAT 32 (TB)

Table 2: The size of the cluster will depend on the capacity of the storage device.

Comment on "Using FAT16/FAT32 systems in CF devi..."
*  You can enter [0] more charecters.
*Verify code:


Visit Asia Webinars to learn about the latest in technology and get practical design tips.


Go to top             Connect on Facebook      Follow us on Twitter      Follow us on Orkut

Back to Top