fix: Zustands-Log bei fehlgeschlagenem Löschen neu einlesen

This commit is contained in:
Michael Sauer
2026-09-11 13:35:56 +02:00
parent b1b4ec214b
commit 35b59a64ed
2 changed files with 26 additions and 5 deletions
+10 -5
View File
@@ -144,9 +144,14 @@ int nl_state_log_erase(void)
{
int r0 = nl_flash_erase_sector(s_sector[0]);
int r1 = nl_flash_erase_sector(s_sector[1]);
s_have = false;
s_seq = 0;
s_active = 0;
s_next = 0;
return (r0 == 0 && r1 == 0) ? 0 : -1;
if (r0 == 0 && r1 == 0) {
s_have = false;
s_seq = 0;
s_active = 0;
s_next = 0;
return 0;
}
/* If erase failed, re-scan the flash to restore consistency */
nl_state_log_init(s_sector[0], s_sector[1]);
return -1;
}