From 14f62eaa88683fa85a681d6c790e2fe0fbd27c54 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Mon, 14 Feb 2022 13:37:20 +0100 Subject: [PATCH] armsrc check: skip if no src available; postpone warning --- armsrc/appmain.c | 1 + client/src/cmdhw.c | 13 +++++++++---- tools/mkversion.sh | 8 +++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index afe10694c..9a61669e2 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -287,6 +287,7 @@ static void SendVersion(void) { strncat(VersionString, "\n", sizeof(VersionString) - strlen(VersionString) - 1); } + FormatVersionInformation(temp, sizeof(temp), " os: ", &g_version_information); strncat(VersionString, temp, sizeof(VersionString) - strlen(VersionString) - 1); strncat(VersionString, "\n", sizeof(VersionString) - strlen(VersionString) - 1); diff --git a/client/src/cmdhw.c b/client/src/cmdhw.c index 52084cadc..c6d4be8da 100644 --- a/client/src/cmdhw.c +++ b/client/src/cmdhw.c @@ -1072,22 +1072,27 @@ void pm3_version(bool verbose, bool oneliner) { struct p *payload = (struct p *)&resp.data.asBytes; - PrintAndLogEx(NORMAL, payload->versionstr); + bool armsrc_mismatch = false; char *ptr = strstr(payload->versionstr, " os: "); if (ptr != NULL) { ptr = strstr(ptr, "\n"); - if (ptr != NULL) { + if ((ptr != NULL) && (strlen(g_version_information.armsrc) == 9)) { if (strncmp(ptr-9, g_version_information.armsrc, 9) != 0) { - PrintAndLogEx(NORMAL, "\n:warning: " _RED_("ARM os does not match the source at the time the client was compiled") " :warning:"); - PrintAndLogEx(NORMAL, "Make sure to flash a correct and up-to-date version"); + armsrc_mismatch = true; } } } + PrintAndLogEx(NORMAL, payload->versionstr); if (strstr(payload->versionstr, "2s30vq100") == NULL) { PrintAndLogEx(NORMAL, " FPGA firmware... %s", _RED_("chip mismatch")); } lookupChipID(payload->id, payload->section_size); + if (armsrc_mismatch) { + PrintAndLogEx(NORMAL, ""); + PrintAndLogEx(WARNING, _RED_("ARM firmware does not match the source at the time the client was compiled")); + PrintAndLogEx(WARNING, "Make sure to flash a correct and up-to-date version"); + } } } PrintAndLogEx(NORMAL, ""); diff --git a/tools/mkversion.sh b/tools/mkversion.sh index 60c13d379..c20f9ba4f 100755 --- a/tools/mkversion.sh +++ b/tools/mkversion.sh @@ -59,9 +59,11 @@ if [ "$fullgitinfoextra" != "$fullgitinfo" ]; then fullgitinfo="${fullgitinfo46}..." fi sha=$( - pm3path=$(dirname -- "$0")/.. - cd "$pm3path" || return - ls armsrc/*.[ch] common_arm/*.[ch]|grep -v disabled|grep -v version_pm3|xargs sha256sum|sha256sum|grep -o '^.........' + pm3path=$(dirname -- "$0")/.. + cd "$pm3path" || return + # did we find the src? + [ -f armsrc/appmain.c ] || return + ls armsrc/*.[ch] common_arm/*.[ch]|grep -v disabled|grep -v version_pm3|xargs sha256sum|sha256sum|grep -o '^.........' ) cat <