fix: OTA-Log im Recovery-Skip-Pfad nicht mehr als Fehlschlag ausgeben
Auf dem Überspring-Pfad (Recovery lehnt ein Image ab, weil es bereits die
laufende Version trägt) bleibt s_error absichtlich NULL, landete aber
trotzdem in printf("ota: failed (rc=%d, %s)\r\n", rc, s_error) - ein
Nullzeiger an %s ist undefiniertes Verhalten und wurde bislang nur zufällig
von newlib als "(null)" abgefangen. Zusätzlich widersprach die Meldung
"failed" der direkt folgenden Zeile "recovery: image already up to date,
continuing normal boot".
ota_task() unterscheidet jetzt explizit zwischen dem Skip-Fall (eigene,
ehrliche "ota: skipped"-Zeile) und dem echten Fehlschlag (bestehende
"ota: failed"-Zeile, weiterhin mit dem "download"-Fallback für ein leeres
s_error). rc bleibt reiner Diagnosewert im Log, da das SDK den Transfer in
beiden Fällen abbricht, sobald der Trailer-Hook das Image ablehnt.
Restliche Leser von s_error/nl_ota_last_error() (nl_recovery.c, nl_api.c)
waren bereits NULL-sicher und mussten nicht angepasst werden.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
62903a7f05
commit
908fda8240
+11
-2
@@ -94,10 +94,19 @@ static void ota_task(void *arg)
|
|||||||
(void)arg;
|
(void)arg;
|
||||||
log_url(s_url);
|
log_url(s_url);
|
||||||
rc = t_http_fwup(s_url);
|
rc = t_http_fwup(s_url);
|
||||||
/* Only reached on failure - the SDK resets the chip itself after a good image. */
|
/* Only reached on failure or a deliberate skip - the SDK resets the chip itself after a good
|
||||||
if (s_error == NULL && !s_skipped)
|
* image. rc is not a reliable success/failure signal here: the SDK aborts the transfer as
|
||||||
|
* soon as the trailer hook returns false, which happens both for a real rejection and for the
|
||||||
|
* deliberate "recovery image already up to date" skip. s_error/s_skipped are what actually
|
||||||
|
* distinguish the two, so branch on those instead of folding everything into one printf that
|
||||||
|
* would risk passing a NULL s_error to %s. */
|
||||||
|
if (s_skipped) {
|
||||||
|
printf("ota: skipped (rc=%d, image already up to date)\r\n", rc);
|
||||||
|
} else {
|
||||||
|
if (s_error == NULL)
|
||||||
s_error = "download";
|
s_error = "download";
|
||||||
printf("ota: failed (rc=%d, %s)\r\n", rc, s_error);
|
printf("ota: failed (rc=%d, %s)\r\n", rc, s_error);
|
||||||
|
}
|
||||||
{
|
{
|
||||||
nl_settings_t *s;
|
nl_settings_t *s;
|
||||||
nl_app_lock();
|
nl_app_lock();
|
||||||
|
|||||||
Reference in New Issue
Block a user