Description
Summary
FsImplPtr make_littlefs_filesystem(bool) (proposed in #4006) names a technology in FastLED's public API. It should name the concept instead, with LittleFS demoted to a platform detail under src/platforms/.
This is a narrower and more actionable point than the general audit in #4003: the public filesystem API may grow for convenience, but it must not leak platform vocabulary.
Why the current shape is wrong
Every platform inherits the vocabulary. Once make_littlefs_filesystem() is public, the host stub, WASM, Teensy, and AVR all live in a world where "LittleFS" is a concept they must have an opinion about. platforms/stub/fs_stub.hpp maps filesystem calls to a real directory on the developer's disk — asking it to answer "do you support LittleFS?" is meaningless. The honest answer for the stub is "I have somewhere to put files," which is the concept, not the technology.
LittleFS is not even the only answer on the platforms that have it. ESP32 can back on-chip flash with LittleFS, SPIFFS (legacy), or FatFS. RP2040 uses LittleFS. Teensy 4.x uses LittleFS_Program with genuinely different semantics (program flash, wiped on re-upload). Pinning the public name to one of those choices means the API is wrong for its siblings and blocks changing the default later.
It breaks the symmetry the API already has. make_sdcard_filesystem(int cs_pin) names a medium (an SD card) and takes a property of the medium (the chip-select pin) — not make_sdfat_filesystem() or make_arduino_sd_filesystem(). The SD entry point is already technology-neutral; the flash one should match.
Proposed shape
Public API — one generic factory, no platform words:
// On-chip flash storage. The platform picks the implementation:
// LittleFS on ESP32/ESP8266/RP2040, LittleFS_Program on Teensy 4.x,
// a scratch directory on host/stub. Returns null where the platform has
// no such storage, so callers get a clean begin() failure.
FsImplPtr make_flash_filesystem(bool format_on_fail = false) FL_NO_EXCEPT;Name is up for discussion — make_flash_filesystem, make_internal_filesystem, make_onboard_filesystem. The requirement is only that it describes where the bytes live, not which filesystem driver puts them there. "Flash" describes the medium, parallel to "sdcard".
Platform detail — LittleFS moves under src/platforms/:
src/platforms/esp/32/fs/fs_littlefs_esp32.{h,cpp.hpp} LittleFS on ESP32
src/platforms/.../fs_littlefs_rp2040.{h,cpp.hpp} later
src/platforms/stub/fs_stub.hpp already maps to a real dir
with a dispatcher TU selecting among them, exactly as fl/system/sd/file_system_sd.cpp.hpp already does for SD (FASTLED_TESTING → stub, FL_IS_WASM → browser VFS, FL_IS_TEENSY → SdFat, else Arduino SD). That file is the working exemplar for this pattern.
Constraint to preserve: the separate translation unit. fl.system.sd+.cpp exists so the linker drops the SD chain (~16 KB on ESP32-S3) when beginSd() is never called — #2773 item 1.2. The flash filesystem needs the same treatment; do not fold it into fl.system+.cpp.
Questions this issue should settle
- The name.
flash/internal/onboard, and whether it reads right besidemake_sdcard_filesystem. - Is
format_on_failthe right generic parameter? It is meaningful on ESP32, absent on ESP8266/RP2040 (no such hook), and arguably dangerous on Teensy where re-upload wipes storage anyway. It may belong in a small options struct rather than the signature, or not be exposed at all. - Should the stub implement it? Mapping it to a scratch directory would let host tests exercise real read paths instead of only the null-fallback contract. That is a genuine testability win and the strongest argument for the generic name.
- Free factory or
FileSystem::beginFlash()? audit: fl/system/file_system.h has drifted from the API Object Pattern #4003 argues against growing the class per backend; a generic concept is a better candidate for a member than a technology was. Worth deciding once rather than per-backend. - Does Teensy's
LittleFS_Programbelong behind this name at all, given it is wiped on every upload? Possibly yes with a documented caveat, possibly a separate concept.
Related
- refactor(fs): expose embedded storage generically as fl::getEmbeddedFs() #4006 — the LittleFS PR that prompted this; should be reworked to this shape before merge
- audit: fl/system/file_system.h has drifted from the API Object Pattern #4003 — broader
file_system.haudit - feat: add a LittleFS FsImpl backend — on-chip flash storage is unreachable today #3984 — LittleFS backend
- meta: remote assets — hosting, build-time resolution, and on-device filesystem deployment #3986 — meta
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
refactor(fs): expose embedded storage generically as fl::getEmbeddedFs()
refactor(fs): consolidate the filesystem subsystem under fl/fs/ (#4010)
refactor(fs): expose embedded storage generically as fl::getEmbeddedF…
docs(review): refresh the API-expansion rule after the fl/fs move (#4014
zackees commentedon Sep 8, 2026
This looks satisfied on current
masterby the merged #4006. Checking each requirement in the proposal against the tree rather than assuming:1. Public API names the medium, not the driver.
src/fl/fs/embedded/embedded_fs.h:49:Structurally identical to the proposed
make_flash_filesystem(bool format_on_fail = false)— same parameter, same default, medium-named. The issue said "Name is up for discussion ... The requirement is only that it describes where the bytes live", andgetEmbeddedFsdoes.2. No driver name reaches the public API.
littlefsappears in five headers undersrc/fl/, but every occurrence is a comment explaining the platform detail, not an identifier.src/fl/fs/backend.h:17is explicit about it:and
embedded_fs.h:8-9:3. LittleFS demoted to
src/platforms/. The backends live atplatforms/esp/fs/embedded_fs_esp.hppandplatforms/wasm/fs/embedded_fs_wasm.hpp, dispatched fromplatforms/embedded_fs.h. Nothing named*littlefs*exists anywhere undersrc/platforms/.4. Symmetry with the SD entry point.
src/fl/fs/fs.h:44addsgetSdFs(int cs_pin)alongside the originalmake_sdcard_filesystem, with a comment citing this issue: "Preferred spelling: it names the medium, matchinggetEmbeddedFs()for on-chip flash, so every backend reads the same way and no driver name reaches the public API (FastLED #4007)." That is thesdcard/flashparallel the issue asked for.5. Null where the platform has no such storage. The proposal said "Returns null where the platform has no such storage, so callers get a clean
begin()failure."platforms/embedded_fs.h:35sends everything outside ESP32/ESP8266/WASM toplatforms/shared/embedded_fs_noop.hpp, whosemakeEmbeddedFs()returns a default-constructedFsImplPtr().RP-specific note, since this issue is tagged for RP2040/RP2350. The proposal lists "RP2040 uses LittleFS" among the platforms, but there is no RP backend — RP takes the
#elsebranch and gets the noop. So RP2350W/RP2040 currently return null fromgetEmbeddedFs()and callers get the cleanbegin()failure the design intends, rather than on-chip flash storage. That is correct behaviour under this design, but it means an RP LittleFS backend is still unimplemented work if on-chip storage is wanted there. Worth tracking separately rather than leaving implied by this issue's platform list.Suggest this can close as completed by #4006, with the RP backend split out if it is still wanted.
zackees commentedon Sep 10, 2026
Question 3 answered with code, not by omission (#4270)
Your triage above checks the design point by point and I agree with all of it. The one thing it does not cover is the issue's own third question, which #4006 settled by default rather than by decision:
It is, so #4270 does it. Before it, the only host coverage of embedded storage was the no-op fragment — a real contract, and one
tests/fl/fs/embedded/embedded_fs.cppdoes test, but one that exercises none of the read path a sketch runs.Two constraints kept it from disturbing anything:
getEmbeddedFs()returns null on the host exactly as the no-op fragment does until a test callssetTestEmbeddedFileSystemRoot(). The four existing cases keep testing the null fallback and keep meaning what they meant. There is now a case pinning that as well, because if pointing the host at a directory ever became the default those cases would silently stop testing it.setTestFileSystemRoot's directory would make such a test green here and red on hardware, so the roots are independent and a case asserts a file under one is not visible through the other.The fragment takes the shape
platforms/embedded_fs.hdocuments — a plain header composed intofl.fs.embedded+.cpp, dropped with the entry point when a sketch never asks — gated onFL_IS_STUB && FASTLED_TESTING, which cannot reach a device build.On closing
I have not touched the RP gap you flagged: RP2040/RP2350 still take the no-op branch and return null. Correct under this design, and unimplemented work rather than a defect — worth the separate issue you suggested.
Questions 1, 2, 4 and 5 in the body are settled by the shipped shape (
getEmbeddedFs,format_on_failretained, free factory, Teensy not backed). With question 3 now answered in code, this issue looks complete apart from the RP split-out.feat(fs): let the host back getEmbeddedFs() with a real directory (#4007
zackees commentedon Sep 10, 2026
Verified against current master, and closing
Re-checked each of the issue's four requirements against the tree rather than carrying the earlier triage forward, plus the third open question that #4270 answered.
src/fl/fs/embedded/embedded_fs.h:49—FsImplPtr getEmbeddedFs(bool format_on_fail = false)littlefs/LittleFSacrosssrc/fl/**/*.h,*.hppoutside comments returns nothingsrc/platforms/find src/platforms -iname "*littlefs*"returns nothing; the backends areplatforms/esp/fs/embedded_fs_esp.hppandplatforms/wasm/fs/embedded_fs_wasm.hppsrc/fl/fs/fs.h:36—make_sdcard_filesystem(int cs_pin), with the neighbouring comment citing this issuefl::setTestEmbeddedFileSystemRootinsrc/fl/fs/testing.h:35, backed byplatforms/stub/fs/embedded_fs_stub.hpp, opt-in and null until askedNothing here is outstanding. Closing.