Skip to content

Vanderhell/microflash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

microflash

CI License: MIT C99

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.

Why microflash

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.

Features

  • Named partition table with lookup by index or name
  • Unified read/write/erase API
  • Storage types: NOR, EEPROM, FRAM, RAM
  • erase_write helper 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

Repository Layout

  • include/mflash.h: public API
  • src/mflash.c: implementation
  • tests/test_all.c: test suite
  • docs/: API reference and design notes

Build and Test

Linux/macOS:

cd tests
make

Direct compile:

gcc -std=c99 -Wall -Wextra -Wpedantic -Werror -Iinclude src/mflash.c tests/test_all.c -o test_all
./test_all

Quick Start

#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;
}

Documentation

CI

GitHub Actions runs build and tests on every push and pull request to master.

License

MIT, see LICENSE.

About

Unified flash abstraction layer for embedded systems in C99. One partition-based API for NOR, EEPROM, FRAM, and RAM with stats, CRC32, and strict bounds checks.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors