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..0c78ce54cb 100644 --- a/include/wolfboot/wolfboot.h +++ b/include/wolfboot/wolfboot.h @@ -113,6 +113,20 @@ 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) +#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 /* 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 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 \