From 2adc5378f619a2cd174b5c5536c12e2fd3f148b6 Mon Sep 17 00:00:00 2001 From: Nathan Hui Date: Thu, 19 Oct 2023 14:34:57 -0700 Subject: [PATCH] feat: Adds firmware hashes --- src/vers.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/vers.cpp b/src/vers.cpp index 4ab82f1d..7516f684 100644 --- a/src/vers.cpp +++ b/src/vers.cpp @@ -2,6 +2,9 @@ #include "product.hpp" #include "cli/conio.hpp" #include "consts.hpp" +#include "util.hpp" + +#include "Particle.h" const char* BUILD_DATE = __DATE__; const char* BUILD_TIME = __TIME__; @@ -38,8 +41,27 @@ const char* BUILD_TIME = __TIME__; void VERS_printBanner(void) { - SF_OSAL_printf(__NL__ "Smartfin FW v%d.%d.%d%s\r" __NL__, FW_MAJOR_VERSION, FW_MINOR_VERSION, FW_BUILD_NUM, FW_BRANCH); + SF_OSAL_printf(__NL__ "Smartfin FW v%d.%d.%d%s" __NL__, FW_MAJOR_VERSION, FW_MINOR_VERSION, FW_BUILD_NUM, FW_BRANCH); SF_OSAL_printf("FW Build: %s %s" __NL__ , BUILD_DATE, BUILD_TIME); + #ifdef SYSTEM_VERSION_v310 + const uint32_t APP_ADDR = 0x000b4000; // Device OS 3.1 and later (256K binaries) + #else + const uint32_t APP_ADDR = 0x000d4000; // Earlier versions including 2.x LTS + #endif + + const module_info_t *prefix = (module_info_t *)APP_ADDR; + + const uint32_t *crcAddr = (const uint32_t *)prefix->module_end_address; + SF_OSAL_printf("CRC32=%lx" __NL__, N_TO_B_ENDIAN_4(*crcAddr)); + + const uint8_t *sha = (const uint8_t *)(((uint32_t)prefix->module_end_address) - 34); + SF_OSAL_printf("SHA256="); + for (size_t byte_idx = 0; byte_idx < 32; byte_idx++) + { + SF_OSAL_printf("%02x", sha[byte_idx]); + } + SF_OSAL_printf(__NL__); + } const char* VERS_getBuildDate(void)