Skip to content

feat: add buildfs/uploadfs — build and flash LittleFS/SPIFFS images from data/ #1358

Description

@zackees

Summary

fbuild has no way to build or flash a filesystem image. PlatformIO's buildfs / uploadfs targets have no fbuild equivalent, so there is no path from a sketch's data/ directory to an on-device filesystem.

Split out of #1354, whose original premise turned out to be partly stale: build-time .lnk resolution already exists. This is the actual remaining gap.

Verified current state

  • No buildfs, uploadfs, --filesystem or equivalent anywhere in the fbuild CLI surface.
  • .lnk resolution and materialization already exist: crates/fbuild-toolchain/src/lnk/mod.rs:1-22 documents scanner -> resolver -> materializer -> downstream build steps, and materialize.rs projects <src>/<rel>/foo.ext.lnk into <build_resources_dir>/<rel>/foo.ext.
  • One consumer already exists: crates/fbuild-build-esp/src/esp32/orchestrator/embed_stage.rs:38-46 resolves .lnk entries named in board_build.embed_files and objcopy-embeds them into firmware.
  • So the pipeline terminates at "materialized into the build tree" with no filesystem-image consumer.

Proposed

fbuild buildfs — assemble a filesystem image from the build-tree projection of data/:

  • inputs = committed files in data/ union materialized .lnk blobs
  • exclude *.lnk sidecars from the image (they must never ship to the device)
  • invoke mklittlefs / mkspiffs per the environment's board_build.filesystem
  • pre-check total size plus filesystem overhead against the partition size from the partition CSV, and fail at build time rather than at runtime mount

fbuild uploadfs — flash that image to the filesystem partition via esptool (already a dependency for firmware flashing).

Partition configurationci/boards.py in FastLED already has board_build_filesystem_size (unused) and board_partitions (used by two boards, both huge_app.csv). A default partition CSV reserving a filesystem region is needed for boards that want one.

Platform capability

buildfs is only meaningful where a flash filesystem exists:

Platform Flash FS PIO buildfs/uploadfs
ESP32 (Arduino-ESP32) LittleFS, SPIFFS (legacy), FFat Yes
ESP8266 LittleFS (SPIFFS deprecated in core docs) Yes (plus uploadfsota)
RP2040/RP2350 (arduino-pico) LittleFS only Yes
Teensy 4.x LittleFS_Program — runtime only, re-upload wipes files No
AVR none (1 KB EEPROM) No
SD card, all platforms runtime library, removable media n/a — not deployable by a build tool

Selecting a filesystem target on AVR or Teensy should be a clear error, not a silent no-op.

Blocker

FastLED has no LittleFS backend. FsImpl is implemented only for Arduino SD over SPI, the WASM browser VFS, and a host stub. A littlefs image would be unreachable from FastLED's FileSystem API. buildfs should not ship pointing at an API gap — see the paired FastLED issue linked below.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions