Skip to content

Commit 188627f

Browse files
asmellbykartben
authored andcommitted
soc: silabs: Support image properties for Series 2
Add image properties data structure to Series 2 binaries. This data structure is used by the SE or bootloader to enforce secure boot, and by other tools to extract image information. Use the app version if set, or fall back to the kernel version for the image version field. Set image type based on Kconfig options. Signed-off-by: Aksel Skauge Mellbye <[email protected]>
1 parent 3568f25 commit 188627f

File tree

4 files changed

+90
-0
lines changed

4 files changed

+90
-0
lines changed

soc/silabs/silabs_s2/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
zephyr_sources(soc.c)
5+
zephyr_sources_ifdef(CONFIG_SOC_SILABS_IMAGE_PROPERTIES soc_image_properties.c)
6+
zephyr_linker_sources_ifdef(CONFIG_SOC_SILABS_IMAGE_PROPERTIES RODATA soc_image_properties.ld)

soc/silabs/silabs_s2/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ config SOC_FAMILY_SILABS_S2
1010
select SOC_EARLY_INIT_HOOK
1111
select HAS_SILABS_SISDK
1212

13+
config SOC_SILABS_IMAGE_PROPERTIES
14+
bool "Include application properties data structure in image"
15+
default y if MCUBOOT
16+
help
17+
Include the Silicon Labs application properties data structure in the
18+
the firmware image. This allows the SE and Gecko bootloader to access
19+
information about the image, such as its version and capabilities. If
20+
MCUboot is used, only the MCUboot image itself needs the image
21+
properties data structure to enable the SE to perform secure boot
22+
verification of the bootloader. MCUboot uses its own TLV format to
23+
verify the application. If Gecko bootloader is used, the Zephyr
24+
application image also needs the data structure.
25+
1326
rsource "*/Kconfig"
1427

1528
config ARM_SECURE_FIRMWARE
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (c) 2025 Silicon Laboratories Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
9+
#if defined __has_include
10+
#if __has_include("app_version.h")
11+
#include "app_version.h"
12+
#define SOC_IMAGE_VERSION APPVERSION
13+
#endif
14+
#endif
15+
16+
#if !defined(SOC_IMAGE_VERSION)
17+
#include <zephyr/version.h>
18+
#define SOC_IMAGE_VERSION KERNELVERSION
19+
#endif
20+
21+
#if !defined(SOC_IMAGE_TYPE)
22+
#define SOC_IMAGE_TYPE \
23+
((IS_ENABLED(CONFIG_MCUBOOT) ? BIT(6) : 0) | (IS_ENABLED(CONFIG_BT) ? BIT(3) : 0))
24+
#endif
25+
26+
#if !defined(SOC_IMAGE_CAPABILITIES)
27+
#define SOC_IMAGE_CAPABILITIES 0
28+
#endif
29+
30+
#if !defined(SOC_IMAGE_PRODUCT_ID)
31+
#define SOC_IMAGE_PRODUCT_ID {0}
32+
#endif
33+
34+
struct image_info {
35+
uint32_t type;
36+
uint32_t version;
37+
uint32_t capabilities;
38+
uint8_t id[16];
39+
};
40+
41+
struct image_properties {
42+
uint8_t magic[16];
43+
uint32_t header_version;
44+
uint32_t signature_type;
45+
uint32_t signature_location;
46+
struct image_info info;
47+
void *cert;
48+
void *token_location;
49+
};
50+
51+
const struct image_properties image_props __attribute__((used, section(".image_properties"))) = {
52+
.magic = {0x13, 0xb7, 0x79, 0xfa, 0xc9, 0x25, 0xdd, 0xb7, 0xad, 0xf3, 0xcf, 0xe0, 0xf1,
53+
0xb6, 0x14, 0xb8},
54+
.header_version = 0x0101,
55+
.signature_type = 0,
56+
.signature_location = 0,
57+
.info = {.type = SOC_IMAGE_TYPE,
58+
.version = SOC_IMAGE_VERSION,
59+
.capabilities = SOC_IMAGE_CAPABILITIES,
60+
.id = SOC_IMAGE_PRODUCT_ID},
61+
.cert = NULL,
62+
.token_location = NULL,
63+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (c) 2025 Silicon Laboratories Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Ensure that image properties section is preserved in the final binary.
7+
*/
8+
9+
_image_properties_start = .;
10+
KEEP(*(.image_properties));
11+
_image_properties_end = .;
12+
_image_properties_size = ABSOLUTE(_image_properties_end - _image_properties_start);

0 commit comments

Comments
 (0)