DeterministicESPAsyncWebServer v6.28.0
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
wearlevel.h File Reference

Flash wear-leveling slot selector (DETWS_ENABLE_WEARLEVEL). More...

#include "ServerConfig.h"
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Detailed Description

Flash wear-leveling slot selector (DETWS_ENABLE_WEARLEVEL).

Flash/NVS cells wear out after a bounded number of erase cycles, so a device that repeatedly writes a record (a log line, a config snapshot, a counter) to the same location burns that block out early. This is the pure core of wear leveling: given a per-slot erase/write count, detws_wearlevel_pick returns the least-worn slot to write next, so writes spread evenly and the whole region ages together.

The app owns the actual slots (NVS keys, flash sectors, VFS files) and the persisted counts; this core just decides where the next write goes and reports the wear imbalance. Pure, zero heap, no stdlib, so it is fully host-testable. It composes with services/vfs (the storage medium) and services/logbuf (whose sink can offload to a wear-leveled store).

Definition in file wearlevel.h.