Skip to content

Commit 4edd541

Browse files
michalek-norlubos
authored andcommitted
fw_info: Change allowed offsets for firmware info struct
Since the vector table of nRF54LX series is larger than before using it is nice to have an offset between `0x400` and `0x800` to store `fw_info` in to ensure you can tightly pack your application together with firmware info. One downside of this is that this new offset is not supported in any older version of NSIB. Signed-off-by: Mateusz Michalek <mateusz.michalek@nordicsemi.no>
1 parent da9d5ac commit 4edd541

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

doc/nrf/libraries/security/bootloader/fw_info.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ Purpose
1717
The purpose of the firmware information is to allow other images such as bootloaders, or infrastructure such as firmware servers, to gain information about the firmware image.
1818

1919
The firmware information structure has a 12-byte magic header and a verified binary layout to ensure that the format is portable and identifiable.
20-
It must be located at one of the following offsets from the start of the image: 0x0, 0x200, 0x400, 0x800, 0x1000.
20+
It must be located at one of the following offsets from the start of the image: 0x0, 0x200, 0x400, 0x600, 0x800, 0xe00, 0x1000.
2121
The reason that the structure is not located at 0x00 is that this can be problematic in some use cases, such as when the vector table must be located at 0x00.
2222

23-
These rules make it simple to retrieve the information by checking for each possible offset (0x0, 0x200, 0x400, 0x800, 0x1000) if the first 12 bytes match the magic value.
23+
These rules make it simple to retrieve the information by checking for each possible offset (0x0, 0x200, 0x400, 0x600, 0x800, 0xe00, 0x1000) if the first 12 bytes match the magic value.
2424
If they do, the information can be retrieved according to the definition in :c:struct:`fw_info`.
2525

2626
Information structure

include/fw_info.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,14 @@ BUILD_ASSERT(ARRAY_SIZE(fw_info_allowed_offsets) == FW_INFO_OFFSET_COUNT,
156156
*/
157157

158158
/* Build time check of CONFIG_FW_INFO_OFFSET. */
159-
#if (FW_INFO_OFFSET_COUNT != 5) \
159+
#if (FW_INFO_OFFSET_COUNT != 7) \
160160
|| ((FW_INFO_CURRENT_OFFSET) != (FW_INFO_OFFSET0) && \
161161
(FW_INFO_CURRENT_OFFSET) != (FW_INFO_OFFSET1) && \
162162
(FW_INFO_CURRENT_OFFSET) != (FW_INFO_OFFSET2) && \
163163
(FW_INFO_CURRENT_OFFSET) != (FW_INFO_OFFSET3) && \
164-
(FW_INFO_CURRENT_OFFSET) != (FW_INFO_OFFSET4))
164+
(FW_INFO_CURRENT_OFFSET) != (FW_INFO_OFFSET4) && \
165+
(FW_INFO_CURRENT_OFFSET) != (FW_INFO_OFFSET5) && \
166+
(FW_INFO_CURRENT_OFFSET) != (FW_INFO_OFFSET6))
165167
#error FW_INFO_OFFSET not set to one of the allowed values.
166168
#endif
167169

include/fw_info_bare.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ extern "C" {
2424
#define FW_INFO_OFFSET0 0x0
2525
#define FW_INFO_OFFSET1 0x200
2626
#define FW_INFO_OFFSET2 0x400
27-
#define FW_INFO_OFFSET3 0x800
28-
#define FW_INFO_OFFSET4 0x1000
29-
#define FW_INFO_OFFSET_COUNT 5
27+
#define FW_INFO_OFFSET3 0x600
28+
#define FW_INFO_OFFSET4 0x800
29+
#define FW_INFO_OFFSET5 0xe00
30+
#define FW_INFO_OFFSET6 0x1000
31+
#define FW_INFO_OFFSET_COUNT 7
3032

3133
/**
3234
* This struct serves as a header before an EXT_API.
@@ -192,7 +194,8 @@ static inline const struct fw_info *fw_info_check(uint32_t fw_info_addr)
192194
static const uint32_t fw_info_allowed_offsets[] = {
193195
FW_INFO_OFFSET0, FW_INFO_OFFSET1,
194196
FW_INFO_OFFSET2, FW_INFO_OFFSET3,
195-
FW_INFO_OFFSET4};
197+
FW_INFO_OFFSET4, FW_INFO_OFFSET5,
198+
FW_INFO_OFFSET6};
196199

197200

198201
/** Search for the firmware_info structure inside the firmware.

subsys/fw_info/Kconfig

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ config FW_INFO_API
1818

1919
config FW_INFO_OFFSET
2020
hex "The location of firmware info inside this firmware"
21+
default 0x600 if SOC_SERIES_NRF54LX
2122
default 0x200
2223
help
2324
The location of firmware information inside the current firmware
24-
image. Valid values are 0x0, 0x200, 0x400, 0x800, and 0x1000.
25+
image. Valid values are 0x0, 0x200, 0x400, 0x600, 0x800, 0xe00, and 0x1000.
2526
Compatible readers of firmware information should search all possible
2627
offsets. Note that all space between the vector table and this address
2728
is unused.

0 commit comments

Comments
 (0)