User`s manual

140 digi.com File Systems
10.2 FAT File System
Dynamic C 8.51 introduced a FAT (File Allocation Table) file system. The small footprint of this well-
defined industry-standard file system makes it ideal for embedded systems. The Dynamic C implementa-
tion of FAT has a directory structure that can be accessed with either Unix or DOS style paths. The stan-
dard directory structure allows monitoring, logging, Web browsing, and FTP updates of files.
The FAT filesystem is included with Dynamic C starting with version 9.60. In earlier versions of
Dynamic C, FAT was sold separately.
FAT version 1.02 supports SPI-based serial flash devices. FAT versions 2.01 and 2.05 also support SPI-
based serial flash devices and require Dynamic C 9.01 or later. FAT version 2.05 introduces support for
NAND flash devices. FAT version 2.10 extends µC/OS-II compatibility to make the FAT API reentrant
from multiple tasks. FAT version 2.13 adds support for SD cards and requires Dynamic C 9.60 or later. In
all versions of the FAT, a battery-backed write-back cache reduces wear on the flash device and a round-
robin cluster assignment helps spread the wear over its surface.
Please be sure check the Digi website for software patches and updates to Dynamic C, the FAT filessytem,
and for your specific hardware:
www.digi.com/support/
The FAT library can be used in either blocking or non-blocking mode and supports both FAT12 and FAT16.
(See Section 10.2.5.3.1 for more information on these FAT types.)
Let’s define some terms before continuing.
A device is a single physical hardware item such as a hard drive, a serial flash or a NAND flash. E.g.,
one serial flash is a single device. The device, in turn, can host one to four partitions.
A partition is a range of logical sectors on a device. A real-world example of a partition is what is com-
monly known as the C drive on a PC.
A driver is the software interface that handles the hardware-specific aspects of any communication to
or from the device.
Blocking is a term that describes a function’s behavior in regards to completion of the requested task. A
blocking function will not return until it has completely finished its task. In contrast, a non-blocking
function will return to its calling function before the task is finished if it is waiting for something. A
non-blocking function can return a code that indicates it is not finished and should be called again.
Used in conjunction with cooperative multitasking, non-blocking functions allow other processes to
proceed while waiting for hardware resources to finish or become available.
Operations performed by the Dynamic C FAT implementation are:
Formatting and partitioning of devices
Formatting partitions
File operations: create, open, close, delete, seek, read and write
Directory
i
operations: create, read and delete
Labels: create and delete
i. We use the terms directory and subdirectory somewhat interchangeably. The exception is the
root directory—it is never called a subdirectory. Any directory below the root directory may be
referred to as a directory or a subdirectory.