Add unstable-littlefs-patched feature

In #27, we updated littlefs to a patched version that backports a change
from littlefs v2.11 (filesystem shrinking) and adds a feature that has
not been merged upstream yet (config flag to disable block count check
on mount). To be able to cut a new release without rolling out these
changes to all users, this patch adds the new unstable-littlefs-patched
feature that enables these changes.
This commit is contained in:
Robin Krahl
2026-02-25 16:20:18 +01:00
parent 357781807f
commit 65e2a03484
7 changed files with 27 additions and 7 deletions
+3 -1
View File
@@ -41,7 +41,9 @@ jobs:
cargo check --all-features
- name: Build
run: cargo build --release --verbose
run: |
cargo build --release
cargo build --release --features unstable-littlefs-patched
- name: Run clippy
if: matrix.target == 'x86_64-unknown-linux-gnu'
+3
View File
@@ -1,3 +1,6 @@
[submodule "littlefs"]
path = littlefs
url = https://github.com/ARMmbed/littlefs
[submodule "littlefs-patched"]
path = littlefs-patched
url = https://github.com/trussed-dev/littlefs
+3
View File
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Derive `Default` if possible
- Add `unstable-littlefs-patched` feature. Enabling this feature may break semantic versioning guarantees. If this feature is enabled, a patched version of littlefs ([v2.9-trussed.1](https://github.com/trussed-dev/littlefs/releases/tag/v2.9-trussed.1)) is used with the following changes from v2.9.3:
- [Add config flag to disable block count check on mount](https://github.com/trussed-dev/littlefs/commit/5328ae4b2ad95088a8079c0dfbc623df45598a88)
- [Add support for shrinking a filesystem](https://github.com/trussed-dev/littlefs/commit/9a6ef46eb43e7edfdfdba04e50c602a8173b456c)
## [0.3.1] - 2025-02-27
+5
View File
@@ -19,3 +19,8 @@ trace = []
malloc = []
software-intrinsics = []
multiversion = []
# unstable features -- enabling one of the following features may break semantic versioning guarantees
# use a patched version of littlefs: https://github.com/trussed-dev/littlefs/releases/tag/v2.9-trussed.1
unstable-littlefs-patched = []
+11 -5
View File
@@ -2,6 +2,11 @@ use std::env;
use std::path::PathBuf;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let littlefs_path = if cfg!(feature = "unstable-littlefs-patched") {
"littlefs-patched"
} else {
"littlefs"
};
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
// Patch lfs.h to remove the lfs_util import because clang fails to locate the
@@ -10,8 +15,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// which comes as a distribution with these utils.
// Turns out lfs_utils is not used in lfs.h, and clang properly finds stdint.h and stdbool,
// but not string.h
let lfs_h = std::fs::read_to_string("littlefs/lfs.h").expect("Reading lfs.h succeeds");
println!("cargo::rerun-if-changed=littlefs/lfs.h");
let lfs_h =
std::fs::read_to_string(format!("{littlefs_path}/lfs.h")).expect("Reading lfs.h succeeds");
println!("cargo::rerun-if-changed={littlefs_path}/lfs.h");
let out_lfs_h = out_path.join("lfs.h");
std::fs::write(
&out_lfs_h,
@@ -29,9 +35,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.flag("-DLFS_NO_WARN")
.flag("-DLFS_NO_ERROR")
.include(&out_path)
.include("littlefs")
.file("littlefs/lfs.c")
.file("littlefs/lfs_util.c")
.include(littlefs_path)
.file(format!("{littlefs_path}/lfs.c"))
.file(format!("{littlefs_path}/lfs_util.c"))
.file("string.c");
#[cfg(feature = "software-intrinsics")]
+1
Submodule littlefs-patched added at 5328ae4b2a