This repository demonstrates how to create test fixtures for embedded systems, specifically for interacting with a GD25Q16C NOR flash memory chip. It provides a comprehensive example of implementing and testing a file system interface using the LittleFS filesystem on NOR flash memory.
The project implements a simple file system interface that operates on top of NOR flash memory. For testing purposes, it includes a fake implementation that simulates the behavior of the physical memory, allowing for thorough testing without actual hardware.
To verify the implementation, run the included tests:
cd test
makeThe project is organized as follows:
-
src/: Contains the production codefile_system.c/h: File system interface implementationmemory_io.h: Hardware abstraction layer for memory operationslfs/: LittleFS library integration (v2.11.0)
-
test/: Contains test code and fixturesfake_memory_io.c/h: Fake implementation of the memory I/O interfacefile_system.test.cpp: CppUTest test cases for the file systemmakefile: Build instructions for the test suite
This project includes a Visual Studio Code Devcontainer configuration that provides a ready-to-use development environment with all necessary tools preinstalled:
- Ubuntu 24.04 LTS base image
- GCC, G++, Make, and CMake
- CppUTest framework preinstalled at
/opt/cpputest - Code formatting and static analysis tools (clang-format)
To use it:
- Open the project in Visual Studio Code
- Install the "Remote - Containers" extension
- Use the command palette (F1) and select "Remote-Containers: Reopen in Container"
| Library | Tag/Version | Remote Repository |
|---|---|---|
| LittleFS | v2.11.0 | LittleFS v2.11.0 |
| CppUTest | latest-passing-build | CppUTest latest-passing-build |
The project uses the littlefs-python package to generate test images stored in the test/generated_images folder. Each binary image (.bin file) corresponds to a folder with the same name that contains the files and directories to be included in the image.
To create a new LittleFS image:
littlefs-python create img01 img01.bin --fs-size=2mb --block-size=4096This command creates a 2MB image file img01.bin with 4KB blocks from the contents of the img01 directory.
The project already includes sample images in test/generated_images/ that are used by the test fixtures. The folder structure (e.g., img01/tmp/test_folder/test_file.bin) is mirrored in the corresponding binary image.
This project is licensed under the MIT License - see the LICENSE file for details.