1.2.7.1 How the Library Works

The MPLAB Harmony File System Service (SYS_FS) provides embedded application developers with a file system framework for retrieving and storing data from various media.

The File System Service abstracts the native file system calls and provides a common interface to the user/application layer. For example, while the application layer requests for a file read or write from a disk, due to the presence of the this abstraction, the application need not be bothered about the native file system implemented on that disk. Instead, the application can call the read/write API of the File System service, which in turn translates to the read/write command of the native file system used on the required disk.

This simplifies the implementation of the higher application layer and also provides a mechanism to add more native file system to the File System framework in the future.

Abstraction Model

The File System framework features a modular and layered architecture, as shown in the following figure.

sys_fs_abstraction_model
  • The Media Block Driver for the physical media has to be included as a part of the FS Framework.

    • This layer provides a mechanism to access the media as "sectors". Sectors are the smallest storage element accessed by a file system and are contiguous memory locations. Typically, each sector has 512 bytes.

    • It can directly provide low-level interface to access the physical media or an interface to access the intermediate media device drivers.

    • This layer also enables multiple instances of media. It depends on below drivers for accessing the media

      • Memory Driver if media is NVM, SPI/QSPI Flash, SPI/I2C EEPROM, RAM

      • SDMMC or SDSPI Driver if media is a SD Card or eMMC

      • USB Host MSD driver if media is a USB thumb drive

  • The Media manager implements a disk and sector based media access mechanism. It also performs disk allocate/deallocate on media attach/detach events. Due to the implementation of this layer, the FS Framework can support multiple disks.

    • The media manager detects and analyzes a media based on its Master Boot Record (MBR). Therefore, it is mandatory for the media to have a MBR for it to work with the FS.

  • The Native file system implements support for the media file system format. Below are the examples of native file systems currently supported. However, more native file systems can be included.

    • FAT12, FAT16, FAT32 and exFAT

    • MPFS

    • littleFS

    • FileX

  • The Virtual file system (or SYS_FS ) layer provides a file system independent file system operation interface. This layer translates virtual file systems calls to native file system calls. Due to this layer, applications can now support multiple file systems. Commonly used interfaces provided by this layer, but not limited to, include:

    • SYS_FS_mount

    • SYS_FS_unmount

    • SYS_FS_open

    • SYS_FS_read

    • SYS_FS_write

    • SYS_FS_close