Introduction to FILEX

Revision as of 16:41, 15 February 2021 by Registered User



1. Introduction

FileX is a fully compliant FAT library for media storage and file system management. It supports the standard filesystem operations like media formatting and files/directories management. FileX is designed in a modular way that facilitate the integration of any media storage.

FileX Overview

FileX support FAT16, FAT32 and extFAT formats. It offers a set of APIs to deal with files and directories such as create, delete and read/write. FileX supports both utf8 and Unicode coding as well as the "Long File Name” features to ensure filesystem compatibility between MCU and modern PCs. It also ensures the integrity of the file system via the failsafe feature (fault tolerance) especially for the flash memories where the “power loss” may damage the data content and break the whole file system.

Further details are available in the FileX official documentation

2. STM32 Integration

FileX supports the common media storage devices like µSD. Combined with LevelX it can also support file systems on NAND and NOR flash memories. Below are the supported media devices in the context of the STM32.

  • SRAM memories: a FAT file system can be created on the MCU internal memories. This is useful for applications with a small footprint and for fast testing and prototyping.
  • SDMMC: this is the typical media storage device used in MCU based applications. It requires both an SDMMC HW IP in the MCU and a uSD connector on the board. Therefore, dedicated BSP APIs are required. The availability of this media depends on MCU and the board. (Nucleo-144 board does not have µSD connectors, unless an external shield is used).
  • NOR/NAND memories:(via SPI/QSPI/OSPI/FMC) In order to support this type of memories, FileX shall be combined with LevelX. FileX manages the filesystem logic, while LevelX ensures the efficient access to these memories in read and write modes (wear-leveling, bad block management…). FileX is hw agnostic, in this case, as LevelX is offering a common porting layer for NOR and NAND memories.

In all cases, FileX requires a low-level driver to interact with the underlining media storage device.

FileX Folders
  • fx_stm32_xxx_driver_template.c/fx_stm32_xxx_driver_template.h: these files represent the driver interfaces (i.e. a driver skeleton without any functional API). It is used to implement the actual driver. These files are copied in the user application source tree then customized depending on application targets.
  • fx_stm32_*_driver.c: these are driver patterns, that implement FileX drivers for specific media devices. (ppp can be, sdmmc, sram…). These drivers are referenced directly by the applications.
  • fx_stm32_*_driver_template.h: to make the patterns usable across different platforms, a configuration step is required. For this reason, the user needs to provide a configuration file at application level to tune the driver. The fx_stm32_*_driver_template.h are header file templates that contain the driver configuration options. config flags should be defined the in "xxx_driver_template.h". Then, this file should be renamed to “fx_stm32_*_driver.h” and copied under the user application source tree.

Note: the driver list is not exhaustive and depends on the MCU and boards.

2.1. FileX and LevelX Integration

The figure below illustrates how to FileX is used in conjunction with LevelX to read and write NAND and NOR flash memories :

FileX LevelX Integration

2.2. Known Limitations

3. How To Use

A FileX based application, has two methods to instantiate a media storage driver:

  1. 1. Formatting the media storage device using one of the following APIs:

Or:

  1. 2. Open the media storage if it already contains a valid FAT file System:

The two main items used in APIs above are:

  • struct FX_MEDIA: This structure holds all needed information about media storage device.
  • VOID (* media_driver) (FX_MEDIA *): This is the pointer to the unique entry point to the low-level driver.

Note: the fx_system_initialize() has to be called before calling any other fx_xxx() API

3.1. Example1: SRAM Interface

  • SRAM driver implementation:
  • SRAM driver loading:

3.2. Example2: NOR Interface

The FileX NOR flash low-level interface APIs has a modular generic multi-instance architecture that allows simultaneously using several IP instances. To use the multi-instances feature, the instances shall be defined in “fx_stm32_levelx_nor_driver.h” file.

Supported instances are:

  • Nor Flash simulator: #define LX_NOR_SIMULATOR_DRIVER
  • Nor Flash OctoSPI interface: #define LX_NOR_OSPI_DRIVER
  • Nor Flash QuadSPI interface: #define LX_NOR_QSPI_DRIVER
  • Nor Flash custom interface: #define LX_NOR_USE_CUSTOM_DRIVER

The main steps to use FileX NOR driver are:

  • NOR driver implementation:
  • NOR driver Instanciation:
  • NOR driver loading:

4. STM32 FileX Applications

STM32 Packages provide the following set of applications (supported applications list may differ between products and boards):

Application Short Description
Fx_uSD_File_Edit It demonstrates how to develop a basic SD card file operations application. The application is designed to handle SD card insertion/removal events, and depending on that state, it starts and stops file operations from and into the SD card. [readme]
Fx_MultiAccess It demonstrates the FileX's concurrent file access capabilities. The application is designed to execute file operations on the SD card device, the code provides all required software code for handling SD card I/O operations. [readme]
Fx_NoR_Write_Read_File It demonstrates how to create a Fat File system on the NOR flash using FileX alongside LevelX. The application is designed to execute file operations on the MX25LM51245G NOR flash device, the code provides all required software code for properly managing it. [readme]