File System Component  Version 6.0
MDK-Professional Middleware for Devices with Flash File System
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Create an Application Using the File System

The steps to create a microcontroller application that uses the File System are:

  1. Select RTE Components along with other components that are required for your application.
  2. Enable necessary Drivers.
  3. Configure the various File System Components.
  4. Implement the User Code.

RTE Component Selection

Only a few steps are necessary to complete the RTE Component selection:

  1. From the File System Component:
    • Select File System:CORE that provides the basic functionality required for data storage and access. In the Variant drop-down box you can choose to use the SFN or LFN version.
    • Select your desired File System:Drive. For example, set File System:Drive:Memory Card to '1' for getting file access to an attached SD card.
  2. From the Drivers Component:
    • Select appropriate drivers suitable for your application. For example, if you are using the Memory Card drive you need to select the MCI (and the SPI driver, if you intend to use the device in SPI mode). For Flash drives, you need to select the appropriate Flash driver. USB memory stick will be served selecting the USB driver.
  3. From the Device Component:
    • Additional device specific drivers may be required according to the validation output.
  4. From the CMSIS Component:
    • Select the CMSIS:CORE to provide the core interface to the processor.
    • Select a suitable CMSIS:RTOS that is a required for the File System Component.
fs_rte_comp_selection.png
RTE Component for File System

Necessary Drivers

As the file system is not bound to a special type of hardware, you need to configure the necessary drivers according to the requirements of your target device. This configuration is done in the RTE_Device.h configuration file. Some devices require to have the DMA controller configured, while others need to have the SDIO driver selected. Please consult the device's user manual or hardware reference. Alternatively you may copy the setup of a File System example that is provided for various evaluation boards.

File System Configuration

File System Core

The File System Core configuration file FS_Config.c is listed in the Project Window under the Component File System and contains settings for the amount of files that can be open at the same time, the cache size for FAT names and for the cache buffer. Usually, the default settings will serve most of the applications. Changing the settings will affect the amount of memory that is used for the project.

Drives

The Drive configuration file FS_Config_Drive_0.h is also listed under the File System Component. It contains mostly drive specific settings, such as page and block sizes for Flash memories, general disk sizes for a RAM drive, and the hardware driver number for connecting the drive to the appropriate driver. Also, a file system cache can be enabled for non-Flash drives, FAT journaling can be selected and the default drive may be set.

System Resource Configuration

For proper operation, the File System Component requires some system configuration settings. The requirements are:

  • Minimum 608 bytes heap size for each opened file. If you want to be able to have three files open at the same time, you need to set a heap size of at least 3 * 608 = 1824 bytes. This can be configured in the device's startup code (Heap_Size).
  • As the File System Component is not creating any additional threads, you need to add at least 1 kB to the calling thread. This calling thread can be the main thread, a thread with a default stack size or a thread with a user provided stack size. Changing the size for these threads can be done in the RTX_Conf_CM.c file.

User Code Implementation

User code template files provide access to all functions that are required to use the File System Component. The available functions are explained in the Reference section of the File System Component. These routines can be adapted to the needs of the microcontroller application, in case more functionality is needed.