FatFs explained

FatFs
FatFs
Logo Caption:Listing files on Micro SD card connected to Arduino Nano using FatFs
Logo Size:300px
Developer:ChaN
Latest Release Version:R0.15
Latest Release Date:2022
Repo:Releases archive
Programming Language:ANSI C
Engines:-->
Platform:Intel 8051, PIC, AVR, ARM, Z80
Genre:Embedded systems software
License:Own license, similar to BSD
Website:elm-chan.org

FatFs is a lightweight software library for microcontrollers and embedded systems that implements FAT/exFAT file system support.[1] Written on pure ANSI C, FatFs is platform-independent and easy to port on many hardware platforms such as 8051, PIC, AVR, ARM, Z80. FatFs is designed as thread-safe and is built into ChibiOS, RT-Thread, ErlendOS,[2] and Zephyr real-time operating systems.[3]

Most often, FatFs is used in low-power Embedded systems where memory is limited, since the library takes up little space in RAM and program code. In the minimum version, the working code takes from 2 to 10 kB of RAM.[4]

Overview

FatFs is designed to be a Filesystem Layer that is agnostic to the platform and storage media it is used with. This is achieved by providing a media access interface that is used to communicate with the storage device control module which is provided by the implementer.[5] This means that FatFs can work with any physical device such as an SD card or a hard disk on any platform that can run plain C code if the implementer provides a control module interface.

Architecture

FatFs library architecture logically separates the abstractions of the user app and the platform-dependent code. The user application and the low level disk I/O layer (driver) must be added by the implementer. Also, the architecture of the library implies that the system can have several storage devices with different drivers and the library can work in a multi-threaded operating system. At the application level it is hidden which physical media is used.

In the minimum implementation, the driver layer must support at least these 3 interfaces:

This level of abstraction allows implementers to write an application once, and then port it on different platforms, changing only the implementation of the driver.[6]

License

FatFs has its own minimalistic license [7] similar to the BSD license. It allows usage in commercial products without disclosing the source code. The only condition is to keep the copyright notice in case of redistribution of the source code. The conditions of FatFs license are not cover any redistributions in binary form, such as embedded code and hex files.

Projects using FatFs

Notes and References

  1. Book: Ivan Cibrario Bertolotti . Embedded Software Development; The Open-Source Approach. 2016. 361. Tingting Hu. 9781466593930. 932464067.
  2. Web site: erlends-os / kmod / fatfs . 2023-11-16 . GitLab . en.
  3. Book: Yi Qiu . The design and implementation of the RT-thread operating system. 2020. 361. Xiong Puxiang, Tianlong Zhu. 9780367554866. 1197810565.
  4. Web site: FatFs Memory Usage comparison table. 2022-06-17. elm-chan.org.
  5. Web site: Developing applications on STM32Cube with FatFs . . 22 June 2022.
  6. Book: Beningo , Jacob . Reusable Firmware Development; A Practical Approach to APIs, HALs and Drivers. 2017. 255. 9781484232972. 1484232976.
  7. Web site: FatFs License. 2022-06-17. elm-chan.org.
  8. Web site: FatFs Library description on Arduino platform documentation. 2022-06-17. Arduino Official Website.
  9. Web site: FAT Filesystem Support - ESP32 - — ESP-IDF Programming Guide latest documentation . 2022-06-27 . docs.espressif.com.
  10. Web site: FatFs File System Configuration in rt-thread operating system. 2022-06-26. www.rt-thread.io.