Skip to content

Commit d516bf4

Browse files
committed
sysbuild: Add firmware loader application type support
Adds support for setting up a firmware loader image in a build, which can also optionally automatically configure MCUboot and the application image to be able to boot the firmware loader image using the retention subsystem Signed-off-by: Jamie McCrae <[email protected]>
1 parent f8c63ab commit d516bf4

File tree

9 files changed

+95
-1
lines changed

9 files changed

+95
-1
lines changed

share/sysbuild/cmake/modules/sysbuild_extensions.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ endfunction()
216216
# and debugging.
217217
#
218218
function(ExternalZephyrProject_Add)
219-
set(app_types MAIN BOOTLOADER)
219+
set(app_types MAIN BOOTLOADER FIRMWARE_LOADER)
220220
cmake_parse_arguments(ZBUILD "" "APPLICATION;BOARD;BOARD_REVISION;SOURCE_DIR;APP_TYPE;BUILD_ONLY" "" ${ARGN})
221221

222222
if(ZBUILD_UNPARSED_ARGUMENTS)

share/sysbuild/image_configurations/BOOTLOADER_image_default.cmake

+7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ elseif(SB_CONFIG_MCUBOOT_MODE_RAM_LOAD)
3030
set(bootmode CONFIG_BOOT_RAM_LOAD)
3131
elseif(SB_CONFIG_MCUBOOT_MODE_FIRMWARE_UPDATER)
3232
set(bootmode CONFIG_BOOT_FIRMWARE_LOADER)
33+
34+
if(SB_CONFIG_MCUBOOT_MODE_FIRMWARE_UPDATER_BOOT_MODE_ENTRANCE)
35+
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_RETAINED_MEM y)
36+
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_RETENTION y)
37+
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_RETENTION_BOOT_MODE y)
38+
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_BOOT_FIRMWARE_LOADER_BOOT_MODE y)
39+
endif()
3340
endif()
3441

3542
foreach(loopbootmode ${bootmodes})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (c) 2025 Nordic Semiconductor
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
# This sysbuild CMake file sets the sysbuild controlled settings as properties
6+
# on a firmware updater image.
7+
8+
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_BOOTLOADER_MCUBOOT "${SB_CONFIG_BOOTLOADER_MCUBOOT}")
9+
set_config_string(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_SIGNATURE_KEY_FILE
10+
"${SB_CONFIG_BOOT_SIGNATURE_KEY_FILE}"
11+
)
12+
set_config_string(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_ENCRYPTION_KEY_FILE
13+
"${SB_CONFIG_BOOT_ENCRYPTION_KEY_FILE}"
14+
)
15+
16+
if("${SB_CONFIG_SIGNATURE_TYPE}" STREQUAL "NONE")
17+
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE y)
18+
else()
19+
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE n)
20+
endif()
21+
22+
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER y)

share/sysbuild/image_configurations/MAIN_image_default.cmake

+7
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,12 @@ if(SB_CONFIG_BOOTLOADER_MCUBOOT)
4141
set_config_int(${ZCMAKE_APPLICATION} CONFIG_FLASH_SIZE 0)
4242
elseif(SB_CONFIG_MCUBOOT_MODE_FIRMWARE_UPDATER)
4343
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER y)
44+
45+
if(SB_CONFIG_MCUBOOT_MODE_FIRMWARE_UPDATER_BOOT_MODE_ENTRANCE)
46+
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_REBOOT y)
47+
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_RETAINED_MEM y)
48+
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_RETENTION y)
49+
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_RETENTION_BOOT_MODE y)
50+
endif()
4451
endif()
4552
endif()

share/sysbuild/images/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ExternalZephyrProject_Add(
1212

1313
# This allows for MCUboot to be included.
1414
sysbuild_add_subdirectory(bootloader)
15+
sysbuild_add_subdirectory(firmware_loader)
1516

1617
# Include zephyr modules generated sysbuild CMake file.
1718
foreach(SYSBUILD_CURRENT_MODULE_NAME ${SYSBUILD_MODULE_NAMES})

share/sysbuild/images/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
rsource "bootloader/Kconfig"
6+
rsource "firmware_loader/Kconfig"

share/sysbuild/images/bootloader/Kconfig

+8
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ config MCUBOOT_MODE_FIRMWARE_UPDATER
128128

129129
endchoice
130130

131+
config MCUBOOT_MODE_FIRMWARE_UPDATER_BOOT_MODE_ENTRANCE
132+
bool "Firmware updater retention boot mode entrance"
133+
depends on MCUBOOT_MODE_FIRMWARE_UPDATER
134+
help
135+
Will enable retained memory, retention and the boot mode module in MCUboot and the main
136+
application so that it can be used to force booting the firmware loader application
137+
image. This needs the ``zephyr,boot-mode`` chosen node to be correctly configured.
138+
131139
config SIGNATURE_TYPE
132140
string
133141
default "NONE" if BOOT_SIGNATURE_TYPE_NONE
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (c) 2025 Nordic Semiconductor
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
if(SB_CONFIG_FIRMARE_LOADER_IMAGE_PATH)
6+
ExternalZephyrProject_Add(
7+
APPLICATION ${SB_CONFIG_FIRMARE_LOADER_IMAGE_NAME}
8+
SOURCE_DIR ${SB_CONFIG_FIRMARE_LOADER_IMAGE_PATH}
9+
APP_TYPE FIRMWARE_LOADER
10+
)
11+
endif()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright (c) 2025 Nordic Semiconductor
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
config SUPPORT_FIRMWARE_LOADER_SMP_SVR
6+
bool
7+
default y
8+
9+
choice FIRMWARE_LOADER
10+
prompt "Firmware loader image"
11+
default FIRMWARE_LOADER_IMAGE_NONE
12+
depends on MCUBOOT_MODE_FIRMWARE_UPDATER
13+
14+
config FIRMWARE_LOADER_IMAGE_NONE
15+
bool "None"
16+
help
17+
Do not Include a firmware loader image in the build.
18+
19+
config FIRMWARE_LOADER_IMAGE_SMP_SVR
20+
bool "smp_svr"
21+
depends on SUPPORT_FIRMWARE_LOADER_SMP_SVR
22+
help
23+
Include the MCUmgr ``smp_svr`` sample as the firmware loader image to use.
24+
25+
endchoice
26+
27+
config FIRMARE_LOADER_IMAGE_NAME
28+
string
29+
default "smp_svr" if FIRMWARE_LOADER_IMAGE_SMP_SVR
30+
help
31+
Name of firmware loader image.
32+
33+
config FIRMARE_LOADER_IMAGE_PATH
34+
string
35+
default "${ZEPHYR_BASE}/samples/subsys/mgmt/mcumgr/smp_svr" if FIRMWARE_LOADER_IMAGE_SMP_SVR
36+
help
37+
Source directory of firmware loader image.

0 commit comments

Comments
 (0)