From 5f8788c4b4826ca0ce772743515c18d3481580cf Mon Sep 17 00:00:00 2001 From: TeTeHacko Date: Fri, 13 Nov 2026 00:37:12 +0100 Subject: [PATCH] FwUpdate: fw base prints the full sha256 of the running image (cache vs fresh) --- src/helpers/FwUpdate.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/helpers/FwUpdate.cpp b/src/helpers/FwUpdate.cpp index 3f57c799..a6d77344 100644 --- a/src/helpers/FwUpdate.cpp +++ b/src/helpers/FwUpdate.cpp @@ -913,8 +913,20 @@ bool FwUpdate::handleCommand(uint32_t sender_timestamp, const char *command, cha strcpy(reply, "OK"); } else if (strcmp(arg, "bl") == 0) cmdBootloader(reply); + else if (strcmp(arg, "base") == 0) { + // full sha256 of the running image: the cached value and a fresh one + uint8_t fresh[32]; + SHA256 sha; + sha.update((const uint8_t *)APP_START, imageEnd() - APP_START); + sha.finalize(fresh, 32); + const uint8_t *c = baseSha(); + int pos = sprintf(reply, "> "); + for (int i = 0; i < 32; i++) + pos += sprintf(reply + pos, "%02x", c[i]); + sprintf(reply + pos, " %s", memcmp(c, fresh, 32) == 0 ? "ok" : "CACHE DIFFERS"); + } else - strcpy(reply, "ERR: fw status|begin|w|missing|verify|apply|abort|bl"); + strcpy(reply, "ERR: fw status|begin|w|missing|verify|apply|abort|bl|base"); return true; }