Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LittleFS port #121

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

LittleFS port #121

wants to merge 7 commits into from

Conversation

jmaksymowicz
Copy link
Contributor

Adds support for LittleFS filesystem to Phoenix RTOS.

Description

LittleFS is a high-integrity filesystem designed for use on relatively small Flash memory devices. This driver allows the use of LittleFS with Phoenix RTOS.

Because of the requirements of Phoenix RTOS API, every file is given a unique numeric identifier that is stored on disk. To achieve good performance, after a path lookup the ID of the file, along with its location on the disk, is cached in memory. In case of a cache miss, the entire file system needs to be scanned to find the file corresponding to an ID. In practice, most file operations in Phoenix RTOS are preceded by a lookup operation, so the requested file's data is very likely cached in memory (unless the cache is too small).

This driver can handle situations where a file has no ID stored on disk - in this case, an ID will be written to disk upon lookup or (if mounted in read-only mode) stored permanently in memory.

Due to the construction of LittleFS, hard links were not implemented. As a result, this driver is not fully compatible with Phoenix RTOS API, which expects the link syscall to create hard links and unlink to remove them. Instead, in this driver link renames a file and unlink removes a file. As a result, the "rename" operation in Phoenix RTOS - which is implemented as a link then unlink - always fails due to the unlink operation failing to find the file (which has already been moved by link).

Sparse files are not implemented, which causes one of libc tests to fail.

Both little-endian and big-endian systems are supported. Mounting of other filesystems within LittleFS is supported (also in read-only mode).

For now this file system has only been tested with pc-ata driver on ia32-generic-qemu.

Motivation and Context

Due to its characteristics, LittleFS is a good filesystem for use on STM32L4 targets.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: ia32-generic-qemu

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

  • This PR needs additional PRs to work (list the PRs, preferably in merge-order).
  • I will merge this PR by myself when appropriate.

Imported littlefs v2.8.1 from
https://github.com/littlefs-project/littlefs commit
c733d9ec5776dfc949ec6dc71fa9ce3ff71de6e5

JIRA: RTOS-686
littlefs/lfs_bd.c Show resolved Hide resolved
littlefs/lfs_bd.c Show resolved Hide resolved
littlefs/lfs_bd.c Show resolved Hide resolved
littlefs/lfs_bd.c Show resolved Hide resolved
littlefs/lfs_bd.c Show resolved Hide resolved
littlefs/lfs_bd.h Show resolved Hide resolved
littlefs/lfs_bd.h Show resolved Hide resolved
littlefs/lfs_bd.h Show resolved Hide resolved
littlefs/lfs_bd.h Show resolved Hide resolved
littlefs/lfs_bd.h Show resolved Hide resolved
littlefs/lfs.c Outdated Show resolved Hide resolved
littlefs/lfs.c Outdated Show resolved Hide resolved
remove trailing whitespace
fix comments to satisfy codespell

JIRA: RTOS-686
change error handling in lfs_fs_rawgrow()

JIRA: RTOS-686
move block device operations to separate file
export selected functions from lfs.c

JIRA: RTOS-686
link function implemented as "move"

JIRA: RTOS-686
Copy link

github-actions bot commented Feb 14, 2024

Unit Test Results

7 254 tests  +99   6 543 ✅ +95   37m 59s ⏱️ + 2m 9s
  408 suites +11     711 💤 + 4 
    1 files   ± 0       0 ❌ ± 0 

Results for commit 7019e91. ± Comparison against base commit fd34198.

♻️ This comment has been updated with latest results.

littlefs/liblfs.c Outdated Show resolved Hide resolved
fix compilation warnings with 32-bit IDs
add API for mounting with explicit configuration

JIRA: RTOS-686
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