Overview ¶
Purpose ¶
The EEPROM Emulation module provides an abstraction layer to emulate EEPROM functionality on STM32 Flash memory. It lets applications store and retrieve data persistently without requiring dedicated EEPROM hardware.
Key Features ¶
The main features of EEPROM Emulation are:
Configurable emulation capacity: Number of variables and write cycles.
Algorithm selection: FLITF or NVM aligned with device constraints and performance.
Power-failure recovery: Restores a consistent state after reset, even if power is lost during a write.
Data integrity options: CRC for corruption detection and BCH-based ECC for bit error correction.
Pluggable interfaces: Ready-to-use and template drivers for Flash, CRC, and ECC.
Typed variable access: Persistent variables with fixed sizes (for example 8-bit, 16-bit, 32-bit).
Maintenance modes: Cleanup and wear-leveling can run in polling or interrupt-driven workflows.
Architecture ¶
The following diagram illustrates the software components of the EEPROM Emulation utility and their interactions across the application, core, algorithms (FLITF/NVM), interfaces (Flash/CRC/ECC), STM32 HAL libraries, and hardware.
Component Structure ¶
Core
(
eeprom_emul_core.c
/
eeprom_emul_core.h): Provides the main APIs for initialization, variable read/write, and maintenance. It manages the overall state and coordinates interactions between algorithms and interfaces.
Algorithms
(
eeprom_algo_flitf.c
/
eeprom_algo_nvm.c): Implement the EEPROM Emulation algorithms, handling initialization, data read/write, and memory cleanup according to the selected method (FLITF or NVM).
The EEPROM Emulation utility supports two Flash memory technologies, selected according to the target STM32 device: FLITF and NVM. While the application always uses the same core API, the underlying algorithm differs because these technologies do not support updates in the same way.
With FLITF, a sector containing existing data must be erased before new data can be written to the same Flash location. The corresponding EEPROM emulation algorithm therefore manages updates through page states, page transfers, and cleanup operations.
With NVM, new data can be written to the same address without a prior erase operation. The corresponding EEPROM emulation algorithm stores variable values in dedicated records and can use the configured CRC and ECC services to preserve data integrity and support recovery after reset.
User configuration
(
eeprom_emul_conf.h): Defines the main parameters for EEPROM Emulation, including Flash layout, number and size of variables, endurance options (number of write cycles), and enabled features (algorithms, CRC, ECC, maintenance mode).
Interfaces : Provide both ready-to-use implementations and customizable templates for Flash access, CRC calculation, and ECC encoding/decoding. The appropriate implementation can be selected or adapted to the target hardware and application needs.
Modules and Files ¶
The following diagram illustrates the EEPROM Emulation module and its associated files.