FatFS Demo

Last Updated July 7, 2011

Contents


  1. 1. The Idea

  2. 2. Main Components

  3. 3. The Demo

  4. i. Introduction

  5. ii. The Hardware

  6. iii. System Layers View

  7. iv. How disk I/O works?

  8. v. The FatTest task

  9. 4. Download

  10. 5. Latest news

 

The Idea


To integrate the open source project FatFS in the ODeV framework. FatFs is a generic FAT file system module for small embedded systems. The FatFs is written in compliance with ANSI C and completely separated from the disk I/O layer. Therefore it is independent of hardware architecture.

NOTE: fore more details about the FatFS API see the project web page:

http://elm-chan.org/fsw/ff/00index_e.html


 
Projects.html
fatfs-news/fatfs-news.html

Projects  >  FatFS Demo

Main Components


  1. ELM - FatFS - version R0.08a.

  2. STM3210E-EVAL evaluation board.

  3. FreeRTOS.org real time scheduler.

  4. OpenOCD  On-Chip debug solution for embedded target systems.

  5. Eclipse open development platform.

  6. Sourcery G++ C/C++ tool chain.

  7. Versaloon hardware IF.

 

The Demo


Introduction

The evaluation board is equipped with 128 Mbit NOR Flash. The demo makes a FAT filesystem (FS) in order to make the FLASH available to the application tasks. The concurrent access to the FAT is managed by the FatFS component itself as described in this application note.

The hardware

The demo uses the hardware resource of the evaluation board as displayed in Fig.1.


Fig. 1 - Hardware resources

The SRAM is used as swap area to implement the disk I/O function required by FatFS as explained below in this page. The LCD is used by the application test task to report some information during the access to the file system.

System Layers View

The system functionalities are logically divided into four layers as showed in Fig. 2.


Fig. 2 - System Layers

Above the hardware the Kernel layer is composed by FreeRTOS and STM32 Library modules. They provide the multi tasking environment and the basic MCU access library.

One step upper there is the Low Level API. This layer contains all modules needed to provide programmatic access to all the hardware but the MCU peripherals. In this case the External Memory Lib module (Ext Mem Lib) provides the API to operate the NOR FLASH and the SRAM connected to the STM32 via FSMC peripheral. Another module in this layer is the HMI Lib, that is part of the Board Support Package (BSP), and it exports the API to operate the LCD and it is not displayed in Fig.2.

The Service Layer contains all modules that export more complex algorithms and (when needed) service tasks. In this case the FAT Interface (FAT IF) implements the disk I/O driver required by the FatFS module.

The Application Layer implements all application task. In this case there is only one task that uses the FS.

NOTE: in this demo both FreeRTOS, STM32 Library and FatFS are Firmware Components that provide the source files to implement some modules of the demo.


The following table shows the files grouped by modules.










How disk I/O works?

The FatFS module needs some low level functions to operate the physical media, that is the NOR FLASH in this demo, as a block device. These functions are defined in the diskio2flash_a.c file. The FLASH chip is composed by 128 block of 128KB size. This is the physical organization of the FLASH. The FatFS module uses a logical organization of 16384 sectors of 1KB size. In this way each physical block of the FLASH is composed by 128 sectors.

When an application task operates on a file or directory, FatFS translates that operation in a set of read and write operations on one ore more sectors. But to write a sector in the FLASH it is needed to erase and write one block (128KB). There is not enough internal RAM in the STM32F103 device to perform this operation. This is why the external SRAM is used. The three steps algorithm that implement this operation is showed in Fig.3.


Fig. 3

The FAT IF module optimizes this algorithm by minimizing the data amount to move from the FLASH to SRAM and vice versa.

The FatTest task

The demo runs only one task that make some operation on the FS like formatting the FS, write and read a file. During each test some information message are displayed in the LCD.

 

Download


The latest version of the the demo is located in the Download page of the site.

The demo is available for the following host:

  1. Windows:    wFatFSDemo.psf


To use the demo you need also the FreeRTOS, FatFS and STM32F10x_StdPeriph_Lib components. They are automatically downloaded by the demo .psf file.

 

Latest news