Skip to content

Commit e608555

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

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+
ifneq ($(WOLFBOOT_VERSION_SECTION),)
3365+
CFLAGS+=-DVERSION_SECTION=$(WOLFBOOT_VERSION_SECTION)
3366+
endif
3367+
33643368
CFLAGS+=-DWOLFBOOT_ARCH_$(ARCH)
33653369
CFLAGS+=-DTARGET_$(TARGET)

‎include/wolfboot/wolfboot.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ 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
120+
121+
#if defined(VERSION_SECTION)
122+
#define WOLFBOOT_VERSION_SECTION __attribute__((section(WB_STRINGIFY(VERSION_SECTION))))
123+
#else
124+
#define WOLFBOOT_VERSION_SECTION
125+
#endif
116126

117127
/* Helpers for memory alignment */
118128
#ifndef XALIGNED

‎src/loader.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ 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+
static volatile const uint32_t __attribute__((used)) WOLFBOOT_VERSION_SECTION wolfboot_version = WOLFBOOT_VERSION;
5555
/**
5656
* @brief RAM Interrupt Vector table.
5757
*/

‎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)