fix: uebersprungenes Recovery-Image ist kein Fehler mehr

Lehnte die Recovery ein Image ab, weil es bereits die laufende Version
traegt, meldete die Firmware das als last_ota_error=trailer. Wer eine
Lampe im Feld ausliest, haette dort einen Trailer-Fehler gesehen, wo in
Wahrheit nichts passiert ist - und die Meldung in der Konsole lautete
"update failed". Das bewusste Ueberspringen hat jetzt einen eigenen
Zustand (nl_ota_skipped()), setzt keinen Fehlerwert und wird als
"image already up to date" protokolliert.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Michael Sauer
2026-09-12 11:22:17 +02:00
co-authored by Claude Opus 5
parent c5d76efb25
commit 37a5fe2ca9
3 changed files with 20 additions and 5 deletions
+8 -2
View File
@@ -23,6 +23,7 @@ static char s_url[NL_OTA_URL_MAX];
static volatile bool s_busy;
static volatile bool s_reject_running_version; /* recovery path only, see nl_ota_start_recovery() */
static const char * volatile s_error;
static volatile bool s_skipped;
static u32 s_stack[NL_OTA_STACK];
static char s_tail_version[NL_TRAILER_VERSION_LEN]; /* used by the hook, kept off its 2 KB stack */
@@ -33,6 +34,7 @@ void nl_ota_init(void)
}
bool nl_ota_busy(void) { return s_busy; }
bool nl_ota_skipped(void) { return s_skipped; }
const char *nl_ota_last_error(void) { return s_error; }
void nl_ota_set_error(const char *e) { s_error = e; }
@@ -61,7 +63,10 @@ bool nl_fwup_verify_tail(const uint8_t sha256[32], const uint8_t *tail, uint32_t
if (strcmp(s_tail_version, NINLIGHT_FW_VERSION) == 0) {
printf("ota: recovery image already carries the running version %s, not flashing\r\n",
s_tail_version);
s_error = "trailer";
/* Deliberately skipped, not failed: leave last_ota_error alone. Reporting "trailer"
* here used to make a perfectly healthy lamp look like it had rejected a malformed
* image, which is exactly the wrong thing to read off a lamp in the field. */
s_skipped = true;
return false;
}
printf("ota: recovery image version %s (running %s)\r\n", s_tail_version, NINLIGHT_FW_VERSION);
@@ -90,7 +95,7 @@ static void ota_task(void *arg)
log_url(s_url);
rc = t_http_fwup(s_url);
/* Only reached on failure - the SDK resets the chip itself after a good image. */
if (s_error == NULL)
if (s_error == NULL && !s_skipped)
s_error = "download";
printf("ota: failed (rc=%d, %s)\r\n", rc, s_error);
{
@@ -125,6 +130,7 @@ static int ota_start(const char *url, bool reject_running_version)
}
s_busy = true;
s_error = NULL;
s_skipped = false;
s_reject_running_version = reject_running_version;
memcpy(s_url, url, n + 1);