This project ports LittleFS — a small, fail-safe filesystem designed for microcontrollers — to MCU platforms. It supports both internal Flash and external SPI Flash as storage backends.
| MCU | Status | Notes |
|---|---|---|
| APM32F103 | ✅ | Internal Flash + SPI Flash |
| APM32F107 | ✅ | Internal Flash + SPI Flash |
Code/
├── Littlefs/ # LittleFS source code + port layer
│ ├── lfs.c / lfs.h # Core filesystem
│ ├── lfs_util.c / lfs_util.h # Utility functions
│ ├── bd/ # Block device drivers (rambd, emubd)
│ └── port/ # MCU port layer (lfs_app.c, flash drivers)
├── Boards/ # Board support
├── Libraries/ # CMSIS, DSP, RTOS libraries
├── Example/ # Example projects
└── test/ # Host-side test suite
├── Unity/ # Unity test framework
├── stubs/ # Hardware stubs for host testing
├── common/ # Shared test helpers
├── test_lfs_core/ # Core library tests
├── test_lfs_app/ # Application layer tests
├── test_block_device/ # Block device tests
├── test_port/ # Port layer tests
── test_fault_injection/ # Fault injection tests
| Tool | Version | Download |
|---|---|---|
| ARM GCC Toolchain | ≥ 10.0 | ARM Developer |
| CMake | ≥ 3.10 | cmake.org |
| Make / Ninja | any | GNU Make / Ninja |
| Eclipse (optional) | latest | Eclipse IDE for Embedded |
| Tool | Version | Download |
|---|---|---|
| GCC (MinGW-w64 on Windows) | ≥ 10.0 | MinGW-w64 |
| CMake | ≥ 3.10 | cmake.org |
| gcovr | ≥ 5.0 | gcovr.com |
Windows:
# Install MinGW-w64 (via MSYS2 or standalone)
# Install CMake from https://cmake.org/download/
# Install Python + gcovr
pip install gcovrLinux (Ubuntu/Debian):
sudo apt update
sudo apt install gcc cmake gcovrmacOS:
brew install gcc cmake gcovrcd test
# Windows
build.bat
# Linux
chmod +x build.sh && ./build.sh
# Or using CMake directly
mkdir build && cd build
cmake ..
make -j8
ctest --output-on-failure
# Generate coverage report
make coverageBuild with your preferred toolchain (Keil, IAR, or GCC) targeting a supported MCU. See the Example/ directory for ready-to-use project files.
| Parameter | Value |
|---|---|
| Internal Flash base | 0x08010000 |
| Flash size | 64 KB |
| Block size | 1 KB |
| Block count | 64 |
- LittleFS: BSD-3-Clause
- Unity Test Framework: MIT
本项目将 LittleFS(一个为微控制器设计的小型、掉电安全文件系统)移植到 MCU 平台。支持内部 Flash 和外部 SPI Flash 作为存储后端。
| MCU | 状态 | 说明 |
|---|---|---|
| APM32F103 | ✅ | 内部 Flash + SPI Flash |
| APM32F107 | ✅ | 内部 Flash + SPI Flash |
Code/
├── Littlefs/ # LittleFS 源码 + 移植层
│ ├── lfs.c / lfs.h # 核心文件系统
│ ├── lfs_util.c / lfs_util.h # 工具函数
│ ├── bd/ # 块设备驱动(rambd、emubd)
│ └── port/ # MCU 移植层(lfs_app.c、Flash 驱动)
├── Boards/ # 板级支持
├── Libraries/ # CMSIS、DSP、RTOS 库
├── Example/ # 示例工程
└── test/ # PC 端测试套件
├── Unity/ # Unity 测试框架
├── stubs/ # 硬件桩(替代真实硬件)
├── common/ # 公共测试辅助代码
├── test_lfs_core/ # 核心库测试
├── test_lfs_app/ # 应用层测试
├── test_block_device/ # 块设备测试
├── test_port/ # 端口层测试
└── test_fault_injection/ # 故障注入测试
| 工具 | 版本要求 | 下载地址 |
|---|---|---|
| ARM GCC 工具链 | ≥ 10.0 | ARM Developer |
| CMake | ≥ 3.10 | cmake.org |
| Make / Ninja | 任意 | GNU Make / Ninja |
| Eclipse (可选) | 最新版 | Eclipse IDE for Embedded |
| 工具 | 版本要求 | 下载地址 |
|---|---|---|
| GCC(Windows 用 MinGW-w64) | ≥ 10.0 | MinGW-w64 |
| CMake | ≥ 3.10 | cmake.org |
| gcovr(生成覆盖率报告) | ≥ 5.0 | gcovr.com |
Windows:
# 安装 MinGW-w64(可通过 MSYS2 或独立安装)
# 从 https://cmake.org/download/ 安装 CMake
# 安装 Python + gcovr
pip install gcovrLinux(Ubuntu/Debian):
sudo apt update
sudo apt install gcc cmake gcovrmacOS:
brew install gcc cmake gcovrcd test
# Windows
build.bat
# Linux
chmod +x build.sh && ./build.sh
# 或直接用 CMake
mkdir build && cd build
cmake ..
make -j8
ctest --output-on-failure
# 生成覆盖率报告
make coverage使用 Keil、IAR 或 GCC 工具链编译,目标芯片为已支持的 MCU。参见 Example/ 目录下的现成工程文件。
| 参数 | 值 |
|---|---|
| 内部 Flash 起始地址 | 0x08010000 |
| Flash 大小 | 64 KB |
| 块大小 | 1 KB |
| 块数量 | 64 |
- LittleFS:BSD-3-Clause
- Unity 测试框架:MIT