FAT file system introduction





The file FatCore.fth contains the core FAT filing system. before you compile this file you must provide some configuration information, a prortability harness for your Forth kernel, and a sector read/write interface for your disk system. Some example interfaces are provided in the issue code.

To build the code, there are example build files, including amongst others:

FatVfxW.bld

Builds a demonstration system on VFX Forth for Windows. This can be used with any drive formatted with a FAT file system.

SSP2148.bld

Builds code for an Olimex LPC-P2148 board using the SSP (SPI1) driver from the ARM cross compiler.

mci23xx.bld

Builds code for an NXP device using the MCI controller (4 bit SD card) on LPC23xx/24xx and some LPC17xx devices.

qspi52259.bld

Builds code for the QSPI device on Coldfire MCF522xx devices.

STM32F4eval.bld

Builds code for an STM32F4xx on the ST STM3240G-EVAL board.

STM32F4disco.bld

Builds code for an STM32F4xx on the STM32F4 Discovery board.

The Docs folder includes useful documentation about FAT file systems, including fatgen103.pdf from Microsoft.

Some useful links:

http://www.seas.ucla.edu/classes/mkampe/cs111.sq05/docs/dos.html



Design objectives

This is a filing system for embedded systems, in particular for use with SD/SDHC/MMC and other Flash cards. You must provide the sector read and write routines.

Because the filing system is designed for use with removable media, it is assumed that they will be formatted on a PC.

RAM usage is more important than performance, although the use of the LRU sector cache considerably improves performance with both hard and floppy drives, as well as with slow Flash drives.




Capabilities




Restrictions




Build files

Each supported configuration has a build file with a .bld extension. The build file contains equates describing the maximum number of open files, number of sector buffers and some CPU characteristics. The build file than loads a the required files, e.g. for an STM32F4 board:


include %FFDir%\XC6harn               \ harness
include %FFDir%\Drivers\sdioSTM32F4xx \ STM32F4 SDIO (1-bit DMA)
include %FFDir%\FatCore               \ core file system code
include %FFDir%\PlainDir              \ simple directory listing
include %FFDir%\DelDirs               \ directory and disk deletion

Note the use of text macros to define the directory containing the file system code.

The file sdioSTM32F4xx.fth is the CPU specific driver. Where there are hardware differences, e.g. for the card detect pin, write protectpin, power control or pin assignments, there may also be a file describing the hardware. This is often called *\i{hwxxxxxx.fth) and may be compiled before the build file.




Configuration options

The following equates control compilation of some features. The defaults here are used if the equates have not previously been defined, e.g.in your control file.

1 equ FATopen?  \ -- flag
Set non-zero to compile the FAT code with all heads present.

1 equ FATtext?  \ -- flag
Set non-zero to compile the FAT code for READ-LINE and WRITE-LINE.

1 equ FATio?    \ -- flag
Set non-zero to compile the FAT code with a file generic I/O device.

1 equ FATspace? \ -- flag
Set non-zero to compile the FAT code for used space.

0 equ FATtest?  \ -- flag
Set non-zero to compile the FAT code with test code.