flash cleaning improvements

This commit is contained in:
liquidraver
2026-08-28 09:41:43 +02:00
parent 8adbe2a648
commit 27ea7e41a5
13 changed files with 432 additions and 109 deletions
+19
View File
@@ -32,6 +32,7 @@
LOG_MODULE_REGISTER(zephcore_observer_main, CONFIG_ZEPHCORE_MAIN_LOG_LEVEL);
#include <app/RepeaterDataStore.h>
#include "../adapters/datastore/ZephyrFsFormat.h"
#include <app/ObserverMesh.h>
#include <adapters/clock/ZephyrRTCClock.h>
#include <mesh/RadioIncludes.h>
@@ -306,6 +307,24 @@ int main(void)
}
#endif
/* First boot on a volume that is not this role's - a fresh chip, a
* companion, or a node that was running Arduino MeshCore, whose nRF52
* filesystems overlap our lfs_partition
* (devdocs/HANDOVER_lfs_arduino_overlap.md). Erase everything so we
* start from a known state: Zephyr's automount only
* auto-formats the LittleFS volume when it fails to mount, and never
* touches storage_partition (BLE bonds NVS) or QSPI.
*
* Self-limiting, so it needs no "done" marker: the identity is generated
* and saved a few lines below, and loadPrefs() persists defaults on the
* same boot, so the next boot sees this role's data and skips this. */
if (!data_store.hasRoleData()) {
LOG_WRN("Volume holds no data for this role - formatting before first boot");
if (!zephcore_fs_format_all(nullptr)) {
LOG_ERR("First-boot format failed - /lfs is not mounted");
}
}
/* Initialize LittleFS data store */
if (!data_store.begin()) {
LOG_ERR("RepeaterDataStore init failed");