Skip to content

Support littlefs as the CIRCUITPY filesystem - #11352

Draft
tannewt wants to merge 1 commit into
adafruit:mainfrom
tannewt:littlefs
Draft

Support littlefs as the CIRCUITPY filesystem#11352
tannewt wants to merge 1 commit into
adafruit:mainfrom
tannewt:littlefs

Conversation

@tannewt

@tannewt tannewt commented Sep 12, 2026

Copy link
Copy Markdown
Member

Add a supervisor-level filesystem API (supervisor_vfs_*) that works on both FAT and littlefs mounts so workflows, BLE file transfer, the web workflow and settings don't care which filesystem is active. The root filesystem storage becomes a supervisor_vfs_t union of fs_user_mount_t (FAT) and mp_obj_vfs_lfs2_t (littlefs); the root is mounted as littlefs when CIRCUITPY_FILESYSTEM_LITTLEFS is set.

  • extmod: export mp_obj_vfs_lfs2_t and add mp_vfs_lfs2_mount_supervisor() so the supervisor can mount littlefs before the VM and GC run, and make the littlefs VFS honor the supervisor write-protection flags so storage.remount() applies to it like FAT.
  • supervisor: map FatFS and littlefs errors to shared supervisor_fs_err_t codes, carry mtimes as ns past 1970 and stamp littlefs mtime attributes and FAT timestamps from the same value.
  • workflow/USB/BLE/web code switch from FRESULT to supervisor_fs_err_t and use the new API, removing direct FatFS access.
  • zephyr-cp: pick FAT or littlefs per board from the partition layout (a littlefs_partition devicetree node selects littlefs), add a native_sim_lfs test harness, fix the flash write cache stale-read when the target block is in the currently cached page, and provide mp_hal_time_ns().

Add a supervisor-level filesystem API (supervisor_vfs_*) that works on
both FAT and littlefs mounts so workflows, BLE file transfer, the web
workflow and settings don't care which filesystem is active. The root
filesystem storage becomes a supervisor_vfs_t union of fs_user_mount_t
(FAT) and mp_obj_vfs_lfs2_t (littlefs); the root is mounted as littlefs
when CIRCUITPY_FILESYSTEM_LITTLEFS is set.

- extmod: export mp_obj_vfs_lfs2_t and add mp_vfs_lfs2_mount_supervisor()
  so the supervisor can mount littlefs before the VM and GC run, and make
  the littlefs VFS honor the supervisor write-protection flags so
  storage.remount() applies to it like FAT.
- supervisor: map FatFS and littlefs errors to shared supervisor_fs_err_t
  codes, carry mtimes as ns past 1970 and stamp littlefs mtime attributes
  and FAT timestamps from the same value.
- workflow/USB/BLE/web code switch from FRESULT to supervisor_fs_err_t and
  use the new API, removing direct FatFS access.
- zephyr-cp: pick FAT or littlefs per board from the partition layout (a
  littlefs_partition devicetree node selects littlefs), add a
  native_sim_lfs test harness, fix the flash write cache stale-read when
  the target block is in the currently cached page, and provide
  mp_hal_time_ns().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant