Skip to content

Storage & Configuration Module

The Storage_&_Configuration module (main/modules/) provides unified, memory-safe access to all persistent storage and configuration data on the ESP32 pendant. It abstracts internal flash and SD card filesystems behind a single POSIX-like API, handles all SD-card-sourced firmware and resource update operations during boot, parses INI-style configuration files, and manages optional sensor hardware polling. Every other module that reads or writes files — HTTP handlers, GCode host, update screen, translation service — goes through this layer.


Storage & Configuration

SD Backend (ESP3D_SD_CARD_FEATURE)

Flash Backend

/fs/...

/sd/...

Consumers

HTTP Handlers

ESP Commands

720 / 740 / 780

GCode Host

CNC File Screens

Translation Service

Macro Manager

globalFs

ESP3DGlobalFileSystem

(path router)

main/modules/filesystem/esp3d_globalfs.h

flashFs · ESP3DFlash

mount: /fs

main/modules/filesystem/esp3d_flash.h

esp_flash_fatFs.cpp

ESP3D_FATFS_FEATURE

esp_flash_littleFs.cpp

ESP3D_LITTLEFS_FEATURE

sd · ESP3DSd

mount: /sd

main/modules/filesystem/esp3d_sd.h

esp_sd_spi.cpp

SD_INTERFACE_TYPE=0

esp_sd_sdio.cpp

SD_INTERFACE_TYPE=1

ESP3DUpdateService

main/modules/update/

ESP3DConfigFile

main/modules/config_file/

ESP3DSensor

main/modules/sensors/

(dormant - no active SKU)


/fs/...

/sd/...

/

other

path argument

Prefix?

flashFs

(internal flash)

sd

(SD card)

virtual root

lists fs/ and sd/

NULL / false

Tier 1 — Router (esp3d_globalfs.h): Inspects path prefix and dispatches to the correct backend. Exposes a unified POSIX-like API (open, close, exists, remove, rename, opendir, readdir, stat, getSpaceInfo).

Tier 2 — Backends:

  • ESP3DFlash (esp3d_flash.h): Internal flash, mount point /fs, partition label flashfs. Uses a uint16_t nesting counter for access control.
  • ESP3DSd (esp3d_sd.h): SD card, mount point /sd. Uses a pthread_mutex_t + watchdog counter for safe concurrent and long-lived access.

Tier 3 — Implementations (compile-time selected, one per medium):

  • Flash: esp_flash_fatFs.cpp (ESP3D_FATFS_FEATURE) or esp_flash_littleFs.cpp (ESP3D_LITTLEFS_FEATURE)
  • SD: esp_sd_spi.cpp (SD_INTERFACE_TYPE=0) or esp_sd_sdio.cpp (SD_INTERFACE_TYPE=1)

Runs once at boot before LVGL starts. Detects and executes one SD-card-sourced update per boot cycle in priority order:

① firmware

esp3dfw.bin

→ OTA partition

② config

esp3dcnf.ini

→ NVS

③ resources

ui_resources.bin

→ ui_resources partition

④ theme_colors

esp3dtheme.ini

→ ui_resources partition

⑤ language_packs

/ui_*.lng

→ ui_resources partition

⑥ resource_patches

/esp3dres/*.bin|*.fnt

→ ui_resources partition

After each update the source file is renamed to .ok (success, with secrets scrambled for config) or .bad (failure), and the device reboots. Progress is pushed to the LVGL Update Screen via ESP3DValues.


ESP3DConfigFile (esp3d_config_file.h) is a lightweight INI parser operating entirely on fixed-size stack buffers (no heap allocation). Used by:

CallerFileAction
Update Service/sd/esp3dcnf.iniParse all settings → NVS; revoke with secrets masked
Translation Service/fs/*.lngParse language key/value pairs
UIManager/sd/esp3dtheme.iniParse theme token overrides
Macro Manager/fs/macros.iniParse stored GCode macro list

Two modes: full-scan with callback (processingFunction_t) or single-key lookup (processFile(section, key, buf, size)). revokeFile() atomically replaces the original with a sanitized copy masking protected keys (passwords, tokens, PINs).


ESP3DSensor (esp3d_sensor.h) manages periodic polling of one compile-time-selected hardware sensor — DHT11/22, BMP280/BME280, or ADC analog. Results are normalized into ESP3DSensorData and exposed via [ESP210] command and mDNS. No board currently enables SENSOR_SERVICE; this is reserved groundwork for future SKUs.


globalFs

ESP3DGlobalFileSystem

flashFs

ESP3DFlash

sd

ESP3DSd

ESP3DUpdateService

ESP3DConfigFile

ESP3DSettings

(NVS)

esp3d_resources

(ui_resources partition)

ESP3DValues

(observables)

ESP3DTranslationService

Update Screen

(LVGL)


ComponentFileDescription
ESP3DGlobalFileSystemmain/modules/filesystem/esp3d_globalfs.hPath-routing façade — preferred entry point for all callers
ESP3DFlashmain/modules/filesystem/esp3d_flash.hInternal flash filesystem driver
ESP3DSdmain/modules/filesystem/esp3d_sd.hSD card filesystem driver with watchdog and mutex
esp3d_sd_config_tmain/modules/filesystem/esp3d_sd_config.hBoard-level SD pin/interface configuration struct
ESP3DUpdateServicemain/modules/update/esp3d_update_service.hBoot-time SD update orchestrator
ESP3DConfigFilemain/modules/config_file/esp3d_config_file.hINI-style file parser and revoker
ESP3DSensor / ESP3DSensorDatamain/modules/sensors/esp3d_sensor.hSensor polling facade (dormant)
  • docs/architecture/shared_sd_mechanism_V2.0.md — Shared SD bus protocol (ESP32 ↔ MCU ownership handoff)
  • docs/guides/esp32_memory_constraints.md — Heap budget; SD/flash allocation rules
  • docs/guides/ui_resources_guide.md — UI resource partition format validated by the update service
  • docs/ui_resources/development.md — Binary format, partition structure, and patch mechanism
  • main/core/includes/esp3d_settings.h — NVS settings read by update service and sensor module
  • main/modules/values/esp3d_values.h — Observable system used for update-progress feedback to LVGL