FatFs

{{Short description|Software library for microcontrollers}}

{{Infobox software

| title = FatFs

| name = FatFs

| logo = MicroSD card connected to Arduino nano with OLED display.jpg

| logo caption = Listing files on Micro SD card connected to Arduino Nano using FatFs

| logo alt =

| logo size = 300px

| screenshot size =

| screenshot alt =

| caption =

| other_names =

| author =

| developer = ChaN

| released = {{Start date and age|2006|2|26}}

| ver layout =

| latest release version = R0.15

| latest release date = 2022

| latest preview version =

| latest preview date =

| repo = [http://elm-chan.org/fsw/ff/archives.html Releases archive]

| qid =

| programming language = ANSI C

| middleware =

| engine =

| operating system =

| platform = Intel 8051, PIC, AVR, ARM, Z80

| included with =

| replaces =

| replaced_by =

| service_name =

| size =

| standard =

| language =

| language count =

| language footnote =

| genre = Embedded systems software

| license = Own license, similar to BSD

| website = [http://elm-chan.org/fsw/ff/00index_e.html elm-chan.org]

| AsOf =

}}

FatFs is a lightweight software library for microcontrollers and embedded systems that implements FAT/exFAT file system support.{{Cite book

|last=Ivan Cibrario Bertolotti

|url=https://www.worldcat.org/oclc/932464067

|title=Embedded Software Development; The Open-Source Approach

|date=2016

|page=361

|others=Tingting Hu

|isbn=9781466593930

|oclc=932464067

}} 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,{{Cite web |title=erlends-os / kmod / fatfs |url=https://git.erlendjs.no/erlends-os/kmod/fatfs |access-date=2023-11-16 |website=GitLab |language=en}} and Zephyr real-time operating systems.{{Cite book

|last=Yi Qiu

|url=https://www.worldcat.org/oclc/1197810565

|title=The design and implementation of the RT-thread operating system

|date=2020

|page=361

|others=Xiong Puxiang, Tianlong Zhu

|isbn=9780367554866

|oclc=1197810565

}}

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.{{Cite web|title=FatFs Memory Usage comparison table|url=http://elm-chan.org/fsw/ff/doc/appnote.html#memory|access-date=2022-06-17|website=elm-chan.org}}

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.{{cite web |url=https://www.st.com/resource/en/user_manual/um1721-developing-applications-on-stm32cube-with-fatfs-stmicroelectronics.pdf |title=Developing applications on STM32Cube with FatFs |publisher=STMicroelectronics |access-date=22 June 2022}} 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

File:FatFs Architecture.jpg

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.{{rp|11}} 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:{{rp|14}}

  • disk_status — return block device status (not initialized, missing, protected, ready)
  • disk_initialize — initialize the physical disk
  • disk_read — read block from physical disk

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.{{Cite book

|first=Jacob

|last=Beningo

|url=https://books.google.com/books?id=wzVCDwAAQBAJ&pg=PA255

|title=Reusable Firmware Development; A Practical Approach to APIs, HALs and Drivers

|date=2017

|page=255

|isbn=9781484232972

|oclc=1484232976

}}

License

FatFs has its own minimalistic license {{Cite web|title=FatFs License|url=http://elm-chan.org/fsw/ff/doc/appnote.html#license|access-date=2022-06-17|website=elm-chan.org}} similar to the BSD license. It allows usage in commercial products without disclosing the source code.{{rp|12}} The only condition is to keep the copyright notice in case of redistribution of the source code. The conditions of FatFs license do not cover any redistributions in binary form, such as embedded code and hex files.

Projects using FatFs

  • Arduino (STM32Duino) — port of Arduino platform for STM32 MCU's{{Cite web|title=FatFs Library description on Arduino platform documentation|url=https://www.arduino.cc/reference/en/libraries/fatfs/|access-date=2022-06-17|website=Arduino Official Website}}
  • ChibiOS/RTopen-source real-time operating system (RTOS) for microcontrollers
  • Flipper Zero — open source portable multi-tool device
  • Marlin (firmware) — open source firmware for 3D printers and CNC machines
  • ESP-IDF — official IoT Development Framework for the ESP32 series SoC's{{Cite web |title=FAT Filesystem Support - ESP32 - — ESP-IDF Programming Guide latest documentation |url=https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/storage/fatfs.html |access-date=2022-06-27 |website=docs.espressif.com}}
  • Prusa Mini — open-source firmware for low cost 3D printer
  • RT-Thread — open-source real-time operating system for embedded systems{{Cite web|title=FatFs File System Configuration in rt-thread operating system|url=https://www.rt-thread.io/document/site/programming-manual/filesystem/filesystem/#elm-fatfs-file-system-configuration-option|access-date=2022-06-26|website=www.rt-thread.io}}
  • Zephyr — real-time operating system for embedded systems supporting multiple architectures
  • ErlendOS — an open source minimal UNIX-like operating system for embedded systems
  • EZ-Flash Omega - Family of flashcarts for the Nintendo Game Boy Advance.

References