Skip to content

Commit f26022f

Browse files
committed
CMake: program SoftDevice with application when not using bootloader
Add a new Kconfig option CONFIG_PROGRAM_SOFTDEVICE_WITH_APP. When enabled, the SoftDevice hex will be programmed together with the application image. This only applies to the none MCUboot board variants. For the MCUboot board variants, the SoftDevice is already programmed together with the MCUboot bootloader. Signed-off-by: Andreas Moltumyr <[email protected]>
1 parent 28dbc33 commit f26022f

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
if(CONFIG_NCS_BM)
88
zephyr_include_directories(include)
99

10+
include(cmake/merge_app_softdevice.cmake)
1011
include(cmake/version.cmake)
1112

1213
add_subdirectory(drivers)

Kconfig.nrf_bm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,13 @@ rsource "samples/Kconfig"
1717
rsource "subsys/Kconfig"
1818
# zephyr-keep-sorted-stop
1919

20+
config PROGRAM_SOFTDEVICE_WITH_APP
21+
bool "Program SoftDevice together with application (none MCUboot board variant)"
22+
depends on !BOOTLOADER_MCUBOOT
23+
depends on SOFTDEVICE
24+
default y
25+
26+
config SOFTDEVICE_FILE
27+
string "SoftDevice file (DO NOT ALTER)"
28+
2029
endif # NCS_BM

cmake/merge_app_softdevice.cmake

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
if(CONFIG_PROGRAM_SOFTDEVICE_WITH_APP)
8+
add_custom_target(app_softdevice_merged
9+
ALL
10+
DEPENDS ${ZEPHYR_BINARY_DIR}/${KERNEL_NAME}_softdevice_merged.hex
11+
)
12+
13+
add_custom_command(OUTPUT ${ZEPHYR_BINARY_DIR}/${KERNEL_NAME}_softdevice_merged.hex
14+
COMMAND
15+
${PYTHON_EXECUTABLE}
16+
${ZEPHYR_BASE}/scripts/build/mergehex.py
17+
-o ${ZEPHYR_BINARY_DIR}/${KERNEL_NAME}_softdevice_merged.hex
18+
${ZEPHYR_BINARY_DIR}/${KERNEL_NAME}.hex
19+
${CONFIG_SOFTDEVICE_FILE}
20+
DEPENDS
21+
${ZEPHYR_BINARY_DIR}/${KERNEL_NAME}.hex
22+
${CONFIG_SOFTDEVICE_FILE}
23+
)
24+
25+
set_target_properties(runners_yaml_props_target PROPERTIES "hex_file"
26+
"${ZEPHYR_BINARY_DIR}/${KERNEL_NAME}_softdevice_merged.hex"
27+
)
28+
set(BYPRODUCT_KERNEL_APP_SD_HEX_NAME
29+
"${ZEPHYR_BINARY_DIR}/${KERNEL_NAME}_softdevice_merged.hex"
30+
CACHE FILEPATH "Application with SoftDevice hex file" FORCE
31+
)
32+
33+
endif()

sysbuild/image_configurations/MAIN_image_default.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ if(SB_CONFIG_BM_BOOTLOADER_MCUBOOT)
2424
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP y)
2525
endif()
2626
endif()
27+
28+
set_config_string(${ZCMAKE_APPLICATION} CONFIG_SOFTDEVICE_FILE "${SB_CONFIG_SOFTDEVICE_FILE}")

0 commit comments

Comments
 (0)