Skip to content

Commit 060ec96

Browse files
committed
feat: store wolfboot version in named section
1 parent 80a186f commit 060ec96

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎arch.mk‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3361,5 +3361,9 @@ ifeq ($(BIG_ENDIAN),1)
33613361
CFLAGS+=-D"BIG_ENDIAN_ORDER"
33623362
endif
33633363

3364+
ifeq ($(WOLFBOOT_VERSION_SECTION),)
3365+
CFLAGS+=-DWOLFBOOT_VERSION_SECTION=$(WOLFBOOT_VERSION_SECTION)
3366+
endif
3367+
33643368
CFLAGS+=-DWOLFBOOT_ARCH_$(ARCH)
33653369
CFLAGS+=-DTARGET_$(TARGET)

‎include/wolfboot/wolfboot.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ extern "C" {
113113
# endif
114114
#endif
115115

116+
#ifndef WB_STRINGIFY
117+
#define _WB_STRINGIFY_L2(str) #str
118+
#define WB_STRINGIFY(str) _WB_STRINGIFY_L2(str)
119+
#endif
116120

117121
/* Helpers for memory alignment */
118122
#ifndef XALIGNED

‎src/loader.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ extern unsigned int _start_text;
5151
/**
5252
* @brief wolfBoot version number (used in RAM code).
5353
*/
54-
static volatile const uint32_t __attribute__((used)) wolfboot_version = WOLFBOOT_VERSION;
54+
#if defined(VERSION_SECTION)
55+
#define WOLFBOOT_VERSION_SECTION __attribute__((section(WB_STRINGIFY(VERSION_SECTION))))
56+
#else
57+
#define WOLFBOOT_VERSION_SECTION
58+
#endif
59+
60+
static volatile const uint32_t __attribute__((used)) WOLFBOOT_VERSION_SECTION wolfboot_version = WOLFBOOT_VERSION;
5561
/**
5662
* @brief RAM Interrupt Vector table.
5763
*/

‎src/update_flash.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ extern unsigned int _start_text;
126126
extern unsigned int __logical_binary_start;
127127
unsigned int _start_text = (unsigned int)&__logical_binary_start;
128128
#endif
129-
static volatile const uint32_t __attribute__((used)) wolfboot_version = WOLFBOOT_VERSION;
129+
130+
static volatile const uint32_t __attribute__((used)) WOLFBOOT_VERSION_SECTION wolfboot_version = WOLFBOOT_VERSION;
130131

131132
#ifdef EXT_FLASH
132133
# ifndef BUFFER_DECLARED

0 commit comments

Comments
 (0)