diff --git a/arch.mk b/arch.mk index 0da7cdd03f..48313f73ac 100644 --- a/arch.mk +++ b/arch.mk @@ -3361,5 +3361,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 d8313809e8..1c7c1ff0b8 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 6968439868..1cf1370b64 100644 --- a/src/update_flash.c +++ b/src/update_flash.c @@ -126,7 +126,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