littlefs2-tool
A command line interface tool for packing, unpacking, inspecting, and flashing LittleFS images to embedded devices.
There is also a library crate for integrating with the Rust build process called littlefs2-pack. See the littlefs-tooling-rs GitHub project README for information on integrating the two in a build system.
CLI Tool
The easiest way to interact with LittleFS images is through the CLI tool. You can install it with Cargo:
This installs a binary called littlefs which has options for packing, unpacking, and inspecting LittleFS images. This is the only part of the project that can be used for non-Rust projects!
)
)
All of the commands can take a path to a config file as an input or have a config file defined with the constituent flags (--block-count, --block-size, etc). The flash command is intended for a different use case, discussed in the Flash Runner section.
LittleFS Config Files
LittleFS images have quite a few configuration options that must match between packing the image and then accessing it on the device. A single source of truth is necessary to maintain this alignment. Factoring in the myriad other configuration options it was logical to store them in a configuration file. This is a TOML file, generally stored at the root of your project repository and named littlefs.toml.
The configuration file has three main sections for the image to be created, the directory that will be packed into it, and the process for flashing it. There's a full example at littlefs2-pack/littlefs.toml with every option and comments explaining them but a minimal example might look like:
[]
# This is the name of the generated files. It defaults to "filesystem" but can be used to differentiate multiple images
= "filesystem"
= 4096
= 256
= 16
= 512
= 3096
# Note that the total size of the image can also be defined with image_size
# But this is mutually exclusive to block_count and most be a multiple of block_size
# image_size = 15_998_976
= 256
= 8
[]
= "./image_directory"
= -1 # Unlimited recursion
= true # Ignore hidden dotfiles
= true # Respect the gitignore files found in the directory
= true # Respect the repo level gitignore
= ["*.bkup", "build"] # Global ignore patterns
= [] # Global includes that supercede all ignore patterns
[]
= "espflash flash --chip esp32s3 {path}"
[]
= "espflash write-bin {address} {path}"
= "0x200000"
Some of these are optional and have default values. Most should be self-explanatory from the comments.