diff --git a/src/helpers/FwUpdate.cpp b/src/helpers/FwUpdate.cpp index 794b5b44..0bbfaddc 100644 --- a/src/helpers/FwUpdate.cpp +++ b/src/helpers/FwUpdate.cpp @@ -500,6 +500,7 @@ const char *FwUpdate::writeAt(uint32_t off, const uint8_t *buf, int len) { for (uint32_t u = u0; u < u1; u++) if (!haveUnit(u)) all = false; if (off < FW_OTA_MANIFEST_SIZE) { + _mani_off = off; uint32_t n = (uint32_t)len; if (off + n > FW_OTA_MANIFEST_SIZE) n = FW_OTA_MANIFEST_SIZE - off; memcpy(&_mani[off], buf, n); @@ -528,8 +529,13 @@ int FwUpdate::handleBinary(const uint8_t *req, int len, uint8_t *reply, int repl memcpy(&sid, &req[2], 2); memcpy(&off, &req[4], 4); int n = req[8]; - if (_state != RECEIVING || sid != _sid) return 0; // another (stale) transfer - if (9 + n <= len) writeAt(off, &req[9], n); // errors show in the next 'm' + if (_state != RECEIVING || sid != _sid) { // another (stale) transfer + _w_drop++; + return 0; + } + _w_bin++; + _mani_src = 'b'; + if (9 + n <= len) writeAt(off, &req[9], n); // errors show in the next 'm' return 0; } if (len >= 2 && req[1] == 'm' && reply_max >= 5) { @@ -643,7 +649,8 @@ void FwUpdate::cmdStatus(char *reply) { (unsigned long)_raw_size, _crc, mv); break; case FAILED: - sprintf(reply, "> failed: %s%s", _err, _flash_diff ? " (flash readback differed)" : ""); + sprintf(reply, "> failed: %s%s [b%u d%u t%u last %c@%lu sid %u]", _err, _flash_diff ? " flash!" : "", _w_bin, + _w_drop, _w_txt, _mani_src, (unsigned long)_mani_off, _sid); break; } } @@ -674,6 +681,8 @@ void FwUpdate::cmdBegin(const char *arg, char *reply) { _flash_diff = false; memset(_mani, 0xFF, sizeof(_mani)); _sid = (uint16_t)sid; + _w_bin = _w_drop = _w_txt = 0; + _mani_src = '-'; _apply_at = 0; sprintf(reply, "OK %lu chunks of %u at %05lX", (unsigned long)((total + FW_OTA_CHUNK - 1) / FW_OTA_CHUNK), FW_OTA_CHUNK, (unsigned long)stage); @@ -694,6 +703,8 @@ void FwUpdate::cmdWrite(const char *arg, char *reply) { end++; uint8_t buf[FW_OTA_CHUNK]; int len = b64decode(end, buf, sizeof(buf)); + _w_txt++; + _mani_src = 't'; const char *err = writeAt(off, buf, len); if (err) sprintf(reply, "ERR: %s", err); diff --git a/src/helpers/FwUpdate.h b/src/helpers/FwUpdate.h index 3fa5ce19..4a98b12c 100644 --- a/src/helpers/FwUpdate.h +++ b/src/helpers/FwUpdate.h @@ -115,6 +115,10 @@ private: // mismatch after the flush, for diagnosis (`fw status`). uint8_t _mani[FW_OTA_MANIFEST_SIZE]; uint16_t _sid = 0; // transfer session, 0 = none given (text-only senders) + // diagnosis of the "wrong base image" hunt (13. 11. 2026): who wrote the manifest + uint16_t _w_bin = 0, _w_drop = 0, _w_txt = 0; + char _mani_src = '-'; + uint32_t _mani_off = 0; bool _flash_diff = false; char _version[48] = { 0 }; char _err[64] = { 0 };