arduino-posix-fs

Arduino Posix API for data in PROGMEM - used by espeak-ng

Stars
3

Arduino Posix Filesystem

Overview

All regular C or C++ projects that use files are based on the Posix File Operations. In Microcontrollers things are quite different and you use a SD library which has it's own API to store files on a SD drive.

If you want to store larger amount of data on a Microcontroller you can also use the Program Memory (PROGMEM).

The goals of this project is to provide Posix File API support to Microcontrollers in order to access of data in PROGMEM as files (w/o separate file deployment step), so that existing projects can be easily migrated to run on microcontrollers.

Documentation

Here is the link to the class documentation.

Implementation & Configuration

On ESP32 processors this is implmented with the help of the Virtual filesystem (VFS)

On mbed based implementations we implmenent a FileSystemLike subclass.

All processors are configured in ConfigFS.h

Using PROGMEM Files

You can convert any file into c source code with the help of xxd. Don't forget to change the generated defintion by adding a const to the test string. This makes sure that it is stored in PROGMEM.

Then you can register the files with their corresponding name and size: Here is an example sketch that registers some files. You can read the files with the regualr C or C++ APIs: see the other examples.

Logging

You can set up the logger by providing the log level and the logging output:

  file_systems::FSLogger.begin(file_systems::FSDebug, Serial); 

Supported Platforms

  • ESP32 (using the Virtual File System)
  • Rasperry Pico (RP2040)
  • Arduino implementation based on MBED

Installation in Arduino

You can download the library as zip and call include Library -> zip library. Or you can git clone this project into the Arduino libraries folder e.g. with

cd  ~/Documents/Arduino/libraries
git clone pschatzmann/arduino-posix-fs.git

I recommend to use git because you can easily update to the latest version just by executing the git pull command in the project folder.