FwUpdate: diagnosis counters in 'failed' status (binary/dropped/text chunks, last manifest writer)

This commit is contained in:
tth committed 2026-11-13 01:57:56 +01:00
1 parent b4d2601c8f
commit 0c06994d1f
2 files changed
+18 -3

No files matched your search

+14 -3
View File
@@ -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);