From 6b64ed62824c09a48d8aa8741964d19db3fcee4c Mon Sep 17 00:00:00 2001 From: Dirk Van Haerenborgh Date: Mon, 2 Nov 2026 15:54:26 +0100 Subject: [PATCH 1/2] feat: store wolfboot version in named section --- arch.mk | 4 ++++ include/wolfboot/wolfboot.h | 10 ++++++++++ src/loader.c | 2 +- src/update_flash.c | 3 ++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/arch.mk b/arch.mk index 2bfaaea8e9..469cdd32b2 100644 --- a/arch.mk +++ b/arch.mk @@ -3506,5 +3506,9 @@ ifeq ($(BIG_ENDIAN),1) CFLAGS+=-D"BIG_ENDIAN_ORDER" endif +ifneq ($(WOLFBOOT_VERSION_SECTION),) + CFLAGS+=-DVERSION_SECTION=$(WOLFBOOT_VERSION_SECTION) +endif + CFLAGS+=-DWOLFBOOT_ARCH_$(ARCH) CFLAGS+=-DTARGET_$(TARGET) diff --git a/include/wolfboot/wolfboot.h b/include/wolfboot/wolfboot.h index 65824e6dcf..91582f8d45 100644 --- a/include/wolfboot/wolfboot.h +++ b/include/wolfboot/wolfboot.h @@ -113,6 +113,16 @@ extern "C" { # endif #endif +#ifndef WB_STRINGIFY +#define _WB_STRINGIFY_L2(str) #str +#define WB_STRINGIFY(str) _WB_STRINGIFY_L2(str) +#endif + +#if defined(VERSION_SECTION) +#define WOLFBOOT_VERSION_SECTION __attribute__((section(WB_STRINGIFY(VERSION_SECTION)))) +#else +#define WOLFBOOT_VERSION_SECTION +#endif /* Helpers for memory alignment */ #ifndef XALIGNED diff --git a/src/loader.c b/src/loader.c index bf8e5551c3..cbe5711a94 100644 --- a/src/loader.c +++ b/src/loader.c @@ -51,7 +51,7 @@ extern unsigned int _start_text; /** * @brief wolfBoot version number (used in RAM code). */ -static volatile const uint32_t __attribute__((used)) wolfboot_version = WOLFBOOT_VERSION; +static volatile const uint32_t __attribute__((used)) WOLFBOOT_VERSION_SECTION wolfboot_version = WOLFBOOT_VERSION; /** * @brief RAM Interrupt Vector table. */ diff --git a/src/update_flash.c b/src/update_flash.c index 05eb937a16..074c141137 100644 --- a/src/update_flash.c +++ b/src/update_flash.c @@ -133,7 +133,8 @@ extern unsigned int _start_text; extern unsigned int __logical_binary_start; unsigned int _start_text = (unsigned int)&__logical_binary_start; #endif -static volatile const uint32_t __attribute__((used)) wolfboot_version = WOLFBOOT_VERSION; + +static volatile const uint32_t __attribute__((used)) WOLFBOOT_VERSION_SECTION wolfboot_version = WOLFBOOT_VERSION; #ifdef EXT_FLASH # ifndef BUFFER_DECLARED From 2a297c1fd35e25cca46a5e9393cd0ba8e720ea19 Mon Sep 17 00:00:00 2001 From: Dirk Van Haerenborgh Date: Thu, 5 Nov 2026 10:49:20 +0100 Subject: [PATCH 2/2] add WOLFBOOT_VERSION_SECTION to tools/config.mk --- tools/config.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/config.mk b/tools/config.mk index 02dc6757b7..651c6cfa2d 100644 --- a/tools/config.mk +++ b/tools/config.mk @@ -170,4 +170,5 @@ CONFIG_VARS:= ARCH TARGET SIGN HASH MCUXSDK MCUXPRESSO MCUXPRESSO_CPU MCUXPRESSO CERT_CHAIN_GEN_CA_ALGO \ CERT_CHAIN_GEN_CA_HASH \ CERT_CHAIN_NAME_CONSTRAINTS \ - ENCRYPT_CACHE + ENCRYPT_CACHE \ + WOLFBOOT_VERSION_SECTION