Chapter 32. Configuring the FAT Filesystem

This chapter shows how to include the FAT filesystem into an eCos configuration and how to configure it once installed.

32.1. Including FAT Filesystem in a Configuration

The FAT filesystem is contained in a single eCos package, CYGPKG_FS_FAT. However, it depends on the services of a collection of other packages for complete functionality:

The File IO package. This provides the POSIX compatible API by which the FAT filesystem is accessed.
Device IO package. This provides all the infrastructure for the disk devices.
Disk device IO support. This provides the top level generic disk driver functions. It also interprets partition tables and provides a separate access channel for each partition. This package is described in detail elsewhere.
Linux compatibility library. The FAT filesystem only used the list and RBtree features of this library.
Strings library. This provides the string and memory move and compare routines used by the filesystem.
The FAT filesystem currently uses malloc() to allocate its memory resources, such as the node and block caches, so this package is required.

To add the FAT filesystem to a configuration, it is necessary to add all of these packages. This is best done by using an import file. The following file will add the FAT filesystem and all the necessary packages to any configuration:

cdl_savefile_version 1;
cdl_savefile_command cdl_savefile_version {};
cdl_savefile_command cdl_savefile_command {};
cdl_savefile_command cdl_configuration { description hardware template package };
cdl_savefile_command cdl_package { value_source user_value wizard_value inferred_value };
cdl_savefile_command cdl_component { value_source user_value wizard_value inferred_value };
cdl_savefile_command cdl_option { value_source user_value wizard_value inferred_value };
cdl_savefile_command cdl_interface { value_source user_value wizard_value inferred_value };

cdl_configuration eCos {
    package CYGPKG_FS_FAT current ;
    package CYGPKG_IO_DISK current ;
    package CYGPKG_LINUX_COMPAT current ;
    package CYGPKG_IO_FILEIO current ;
    package CYGPKG_IO current ;
    package CYGPKG_LIBC_STRING current ;
    package CYGPKG_MEMALLOC current ;

In addition to these packages, hardware-specific device driver packages will be needed for the disk devices to be used. These device drivers are usually part of the target description in the eCos database and will be enabled if the CYGPKG_IO_DISK package is included.

32.2. Configuring the FAT Filesystem

Once added to the configuration, the FAT filesystem has a number of configuration options:


This option controls the number of slots in the hash table used to store file nodes using filenames as keys.

Default value: 32


This option controls the size of the node pool used for storing file nodes. This value should be set to the maximum required number of simultaneously open files plus the desired size of unused node cache.

Default value: CYGNUM_FILEIO_NFILE + 2


This option controls the size of blocks in the block cache. This value should be a power-of-2 multiple of 512. It must be at least as great as the underlying disk sector size (usually 512) but can be greater, allowing multiple underlying blocks to be cached within a single cache block.

With some underlying disk devices, performance can be greatly improved by increasing the size of this option, as it may allow multiple disk blocks to be transferred in one transaction. This is known to be particularly true with MMC or SD card media and it is recommended to increase the size of this option with such media.

Default value: 512


This option controls the amount of memory used for the block cache.



This option controls the inclusion of extra sanity checks in node cache code.

Default value: 1


This option controls whether the FAT filesystem supports or honors the FAT filesystem file attributes.

Default value: 0


This option controls the FAT filesystem support for long file names.

Default value: 0


This option defines the maximum size of long file names supported by the filesystem. The default value of 64 corresponds to NAME_MAX, which defines the size of d_name[] in a struct dirent.

Default value: 64


Normally every operation on a mounted FAT filesystem must complete before another operation can start. However sometimes a thread must block while waiting for a read or write to the underlying disk medium to complete. As a performance improvement, this option allows other threads to perform operations on the FAT filesystem while other threads are blocked. This can be especially beneficial when the operations can be performed entirely using the in-built file system block and node cache.

However, a known limitation is that there is not currently sufficient protection in place to handle situations where two threads update a directory at the same time, for example, both creating, renaming or removing files or directories (Issue #1001183). Other operations should be safe, but for the time being care is advised if enabling this option, and eCosCentric cannot provide support for resulting problems if it is enabled.

Default value: 0


This option enables support for formatting a FAT filesystem on the device before mounting it. Only FAT16 and FAT32 formats are supported, FAT12 is not. The variety of options supported is also limited to choosing the format, block size, and volume label, where appropriate.

Default value: 1

Normally these options should be left as they are unless you have a specific need to change them. Once the configuration had been created, it should be possible to compile eCos and link it with the application without any errors.