🛰️Zafer Satılmış - Aviora

File System Port Implementations

FlashLink, FlashFS and littlefs integration — and the flexibility provided by cells, geometry, and flashHwFunc.

FlashLink — Linked-Cell Storage

Lightweight linked-cell model running in MCU internal flash. Ideal for customers with small storage needs; no external flash required.

  • File data stored across multiple linked cells
  • Header: name (64B), nextIndex, dataLen
  • Delete: flash-safe tombstone-style header update
FlashLink cell layout

FlashFS — Append-Only Log

Tiny append-only log backend. Good for simple write patterns with controlled format cycles.

  • Superblock plus append-only records
  • FILE, DELETE, RENAME records
  • Index rebuilt at mount time
FlashFS log layout

Flexibility Points: cells, geometry, flashHwFunc

These three blocks enable customer adaptation without editing app-level code.

cells

Controls logical storage granularity and file split behavior for flashlink-style backends.

geometry

Controls physical memory region, size, and erase/program units.

flashHwFunc

Injects platform-specific read/prog/erase/sync callbacks and driver include path. Main hardware portability mechanism.

Mermaid flexibility model
flowchart LR
  CFG[fs_config.json] --> CELLS[cells]
  CFG --> GEO[geometry]
  CFG --> HW[flashHwFunc]
  CELLS --> MAC1["FLASHLINK_CELL macros"]
  GEO --> MAC2["BASE/REGION/ERASE macros"]
  HW --> MAC3["STORAGE_DRV_FUNC + driver"]
  MAC1 --> INIT[FS_HARDWARE_INIT]
  MAC2 --> INIT
  MAC3 --> INIT
[Fallback flexibility model]
fs_config.json
  -> cells      -> cell related macros
  -> geometry   -> base and size macros
  -> flashHwFunc -> callback macros and driver include
all -> FS_HARDWARE_INIT()

fs_littlefs_helper_func — Why It Exists

littlefs expects mutex lock/unlock callbacks for thread-safe access. These depend on the RTOS or bare-metal environment and are centralized in the fs_littlefs_helper_func module.

  • fsHelperMutexCreate() — Suitable for static mutex before kernel start
  • fsHelperMutexLock/Unlock — Called from lfs_config; critical section enter/exit
  • osHelper JSON block injects path and function names
littlefs → mutex → RTOS
flowchart LR
  A[fs_port_littlefs] --> B[lfs_config]
  B --> C[mutex_lock]
  B --> D[mutex_unlock]
  C --> E[fsHelperMutexLock]
  D --> F[fsHelperMutexUnlock]
  E --> G["OsMutex/RTOS"]
  F --> G

Integration Note

StorageFlashPort_littlefs.c may be a stub in the current repo. Product branches should replace it with real hardware I/O callbacks.