Unified flash abstraction layer for embedded systems.
microflash provides one partition-based interface for multiple storage types (NOR, EEPROM, FRAM, RAM) so higher-level libraries can share a single hardware driver contract.
In embedded projects, config, logs, boot records, and queues are often implemented as separate modules with slightly different read/write/erase semantics. microflash standardizes these operations behind one API and one partition table.
- Named partition table with lookup by index or name
- Unified read/write/erase API
- Storage types: NOR, EEPROM, FRAM, RAM
erase_writehelper for safe NOR updates- Read-only partitions for protected regions
- Bounds checking and alignment validation
- Per-partition I/O statistics
- CRC32 utility and CRC32-over-region
- C99, zero dependencies, zero dynamic allocation
include/mflash.h: public APIsrc/mflash.c: implementationtests/test_all.c: test suitedocs/: API reference and design notes
Linux/macOS:
cd tests
makeDirect compile:
gcc -std=c99 -Wall -Wextra -Wpedantic -Werror -Iinclude src/mflash.c tests/test_all.c -o test_all
./test_all#include "mflash.h"
static int drv_read(uint32_t addr, void *buf, uint32_t len, void *ctx);
static int drv_write(uint32_t addr, const void *buf, uint32_t len, void *ctx);
static int drv_erase(uint32_t addr, uint32_t len, void *ctx);
int main(void) {
mflash_t fl;
mflash_driver_t drv = {
.read = drv_read,
.write = drv_write,
.erase = drv_erase,
.ctx = NULL
};
mflash_init(&fl, &drv);
mflash_add_partition(&fl, "config", 0x00000, 4096, 4096, MFLASH_TYPE_NOR, false);
return 0;
}GitHub Actions runs build and tests on every push and pull request to master.
MIT, see LICENSE.