From 099119868ecc62af7c8c9907b7a4e8ec09741647 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 2f358f2ed8..42c4fe20cb 100644 --- a/arch.mk +++ b/arch.mk @@ -3595,5 +3595,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 a5740078e2..4019ff8ae3 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 005c72f2c7..3f799915fc 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 970485371a09fb8adcc17fd07b5f39764f4920b0 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 --- include/wolfboot/wolfboot.h | 6 +++++- tools/config.mk | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/wolfboot/wolfboot.h b/include/wolfboot/wolfboot.h index 4019ff8ae3..0c78ce54cb 100644 --- a/include/wolfboot/wolfboot.h +++ b/include/wolfboot/wolfboot.h @@ -119,7 +119,11 @@ extern "C" { #endif #if defined(VERSION_SECTION) -#define WOLFBOOT_VERSION_SECTION __attribute__((section(WB_STRINGIFY(VERSION_SECTION)))) +#if defined(__IAR_SYSTEMS_ICC__) +#define WOLFBOOT_VERSION_SECTION(name) __section(WB_STRINGIFY(VERSION_SECTION)) +#else +#define WOLFBOOT_VERSION_SECTION(name) __attribute__((section(WB_STRINGIFY(VERSION_SECTION)))) +#endif #else #define WOLFBOOT_VERSION_SECTION #endif diff --git a/tools/config.mk b/tools/config.mk index 07227e8fc9..b865322719 100644 --- a/tools/config.mk +++ b/tools/config.mk @@ -143,6 +143,7 @@ CONFIG_VARS:= ARCH TARGET SIGN HASH MCUXSDK MCUXPRESSO MCUXPRESSO_CPU MCUXPRESSO WOLFBOOT_PARTITION_SWAP_ADDRESS WOLFBOOT_LOAD_ADDRESS \ WOLFBOOT_LOAD_DTS_ADDRESS WOLFBOOT_LOAD_RAMDISK_ADDRESS \ WOLFBOOT_LOAD_KERNEL_ADDRESS \ + WOLFBOOT_VERSION_SECTION \ DDR_HIGH_BASE DDR_HIGH_SIZE NO_DDR_LOW \ BOOT_EL1 BOOT_EL2 \ WOLFBOOT_DTS_BOOT_ADDRESS WOLFBOOT_DTS_UPDATE_ADDRESS \