Download FreeRTOS

Quality RTOS & Embedded Software

Simplifying Authenticated Cloud Connectivity for Any Device.
Designing an energy efficient and cloud-connected IoT solution with CoAP.
Introducing FreeRTOS Kernel version 11.0.0:
FreeRTOS Roadmap and Code Contribution process.
OPC-UA over TSN with FreeRTOS.
FreeRTOS-Plus-FAT is a FreeRTOS Labs project. It is fully functional, and quite mature, but as an originally acquired (rather than authored) product it does not necessarily meet our production code or testing standards. It is available from the Lab-Project-FreeRTOS-FAT repository on GitHub.

Creating a FreeRTOS-Plus-FAT Media Driver

The Structure of a Media Driver

The Structure of a Media Driver
The media is the physical device on which files are stored. Examples of media suitable for use in an embedded file system include SD cards, solid state disks, NOR flash memory chips, NAND flash chips, and RAM chips. The media driver is the software responsible for writing to the media, and reading from the media.

FreeRTOS-Plus-FAT stores information that is common to all media types in a structure of type FF_Disk_t. The FF_Disk_t structure can be extended by the developer of the media driver so it includes additional information that is specific to the media in use.

The FF_Disk_t structure references an object called an input/output manager (IO Manager, or simply IOMAN). The IO manager is responsible for, amongst other things, buffering and caching both file and directory information.

The mechanism for actually reading data from and writing data to the media is dependent on the media type. Therefore the developer of the media driver must provide suitable read and write functions.

Many media drivers will themselves make use of a peripheral driver in order to perform the actual read and write operations. For example, if the media is an SD card then it might be necessary to access the card through an SPI peripheral. A peripheral driver is not necessary when implementing a RAM disk, as RAM can be read from and written to using the standard C library memcpy() function.

Some media types also require higher level management logic to perform actions such as bad block management, or wear levelling.

Creating a New Media Driver

A media driver requires [at least] three functions.

  1. A function that reads sectors from the media
  2. A function that writes sectors to the media
  3. An initialisation function

Click each item above for more information, and to see a worked example.

Preparing Media For First Use

Just like a disk in a desktop computer, before the media can be used in an embedded system it must first be partitioned, then a partition must be formatted and mounted.

FreeRTOS-Plus-FAT implements a virtual file system in which the mounted partition must be registered, after which it will appear as a directory in the embedded file system's root directory.

Driver API and Structures

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.