Embedded File System

Portable, Embedded Flash File Systems

The use of a portable file system decreases application complexity and simplifies the movement of existing code from one platform to another. With a standardized and modular file system, a wide variety of physical flash storage may be utilized for dedicated (fixed) and removable media.

POSIX File System and C Standard I/O Library Interfaces – a Portable File System Model

A portable file system is achieved through the use of a standardized interface. Two popular and very common file system interfaces are the POSIX File System Application Programming Interface (API) and the C language's Standard I/O Library Interface (STDIO). In using either of these standards, application code performing file operations is abstracted from the underlying implementation which provides a hardware independence across product platforms and technology types.

In embedded file systems, a wide variety of flash memory parts are available. A portable, embedded file system, such as the Unison Real Time Operating System (RTOS), uses a layered model to achieve functional modularity, application abstraction, and hardware independence.

Portable Flash File System Model

 

From the diagram, the application code may perform file operations using the POSIX file or C's STDIO APIs. The underlying storage medium (Flash Memory, RAM, for example) is controlled by technology specific drivers. This leaves the service layer to implement data integrity techniques, storage efficiency, and performance enhancements which will be common across all Unison RTOS installations.

Embedded File System Types

The Unison RTOS provides two generic, embedded file system implementations. The first, FSYS, is best suited for a local, embedded file system. The second, FATFS, is normally used for removable media types (Secure Digital (SD) cards, USB Mass Storage Flash Drive), where flash file system compatibility with other computer operating systems (Linux, Windows) and devices is required.

FSYS is provided as a basic component with the Unison RTOS Kernel Package. It is an Extent Based File System utilizing one (1) bit per block for extremely efficient encoding. FSYS implements a user configurable cache which may be disabled. The file system is rebuilt from the block table at mount time and contains a mechanism for the immediate flush of any pending block table updates under program control. For file system integrity, any entry additions are made before the old entry is removed. Additionally, FSYS can run optional multiple service threads to increase I/O throughput and application response. FSYS has a tiny memory footprint of 7.7K flash and requires under 200 bytes of RAM on a typical Cortex M3.

FATFS is provided as an add-on package for the Unison RTOS. It offers a standard 12/16/32 FAT format and is typically used with removable media. FATFS has a small memory footprint of 13.7K flash and requires under 550 bytes of RAM on a typical Cortex M3.

Both implementations are interchangeable to the application, by way of the POSIX File and C language STDIO APIs, providing CRC based error detection and correction. And, both flash file system implementations are available on all microcontroller (MCU), microprocessor (MPU), and FPGA platforms supported by the Unison RTOS. Also, each implementation can be entirely RAM based.

Network File System

Either of Unison embedded file system implementations can be combined with Unison's optional Network File System (NFS) support. This package implements NFS v2, with a 2 GB file size limitation. It requires UDP capability via Unison's TCP/IP stack and supports stateless operation. Any POSIX limitations from the remote site are passed through to the calling application.

The use of NFS allows file exchange with a wide collection of existing installations.

Enhanced Driver Capabilities

To better deal with the nuances in NAND and NOR flash memory technology, Unison's flash file system implementations utilize replacement drivers specifically written for these technologies. These drivers provide static and dynamic write levelling, minimize block erase operations, and allow separate pages within blocks; all while maintaining a small RAM and flash memory footprint.

Additionally, Unison's NAND flash file system drivers implement wear levelling with dynamic block verification and replacement to eliminate the bad block issues inherent in the use of NAND flash technology.

Power Safe Operation

A further enhancement for a flash file system is through the selection of a driver set specifically written to allow power safe operation. In combination with any power management hardware available on the platform, Unison's embedded file system implementations can minimize data loss on a hard, sudden power failure to a single block write.

This power safe operation is achieved by dynamically separating file manipulation requests into single atomic operations.  The selection between power safe and normal mode is under programmatic control for flexibility.

Summary

Significant cost savings occur when previously developed and debugged code can be reused on a variety of platforms. A POSIX/STDIO interface provides application portability.

A modular, layered embedded file system model permits the greatest flexibility to support local and removable flash file system media.

Replaceable drivers minimize the impact of introducing or changing flash technology types, on product development, while exploiting any cost or technology advantages present in the physical medium.

The use of a RTOS allows hardware specific features, such as Power Management, to be seamlessly propagated throughout product platforms to support peripherals such a as a flash file system.