Skip to content

Commit 492d658

Browse files
committed
sysbuild: Fix bootconf not building without Partition Manager
Add building bootconf with non-Partition Manager configurations that use NSIB (B0). Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
1 parent 1bfa7d5 commit 492d658

2 files changed

Lines changed: 54 additions & 27 deletions

File tree

cmake/sysbuild/bootconf.cmake

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,58 @@
33
#
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
#
6+
include(${ZEPHYR_NRF_MODULE_DIR}/cmake/sysbuild/bootloader_dts_utils.cmake)
67

7-
function(setup_bootconf_data)
8-
if(SB_CONFIG_PARTITION_MANAGER)
9-
add_custom_target(bootconf_target
10-
DEPENDS ${CMAKE_BINARY_DIR}/bootconf.hex
11-
)
8+
set(bootconf_hex ${CMAKE_BINARY_DIR}/bootconf.hex)
9+
set(bootconf_dependency)
1210

13-
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bootconf.hex
14-
COMMAND ${Python3_EXECUTABLE}
15-
${ZEPHYR_NRF_MODULE_DIR}/scripts/reglock.py
16-
--output ${CMAKE_BINARY_DIR}/bootconf.hex
17-
--size $<TARGET_PROPERTY:partition_manager,PM_B0_SIZE>
18-
--soc ${SB_CONFIG_SOC}
19-
DEPENDS ${APPLICATION_BINARY_DIR}/pm.config
20-
VERBATIM
21-
)
11+
if(SB_CONFIG_PARTITION_MANAGER)
12+
set(bootconf_size $<TARGET_PROPERTY:partition_manager,PM_B0_SIZE>)
13+
set(bootconf_dependency ${APPLICATION_BINARY_DIR}/pm.config)
14+
else()
15+
dt_partition_size(bootconf_size LABEL b0_partition TARGET b0 REQUIRED)
16+
endif()
2217

23-
set_property(
24-
GLOBAL PROPERTY
25-
bootconf_PM_HEX_FILE
26-
${CMAKE_BINARY_DIR}/bootconf.hex
27-
)
18+
# bootconf.hex is only created when there is b0_partition, which
19+
# indicates that b0 is used.
20+
if(NOT bootconf_size EQUAL 0)
21+
add_custom_command(OUTPUT ${bootconf_hex}
22+
COMMAND ${Python3_EXECUTABLE}
23+
${ZEPHYR_NRF_MODULE_DIR}/scripts/reglock.py
24+
--output ${bootconf_hex}
25+
--size ${bootconf_size}
26+
--soc ${SB_CONFIG_SOC}
27+
DEPENDS ${bootconf_dependency}
28+
VERBATIM
29+
)
30+
else()
31+
# Whether we have this CMake invoked or not is controlled by paths in
32+
# scripts that invoke; it is expected to be called when Secure Bootloader is
33+
# build, which means that the B0 partition for it also exists. If these
34+
# expectations are not met and somehow we have this part invoked, this means
35+
# that bootconf build has been invoked for something it can not handle.
36+
message(FATAL_ERROR "bootconf.hex has nothing to protect."
37+
"CMake path that should not have been taken?"
38+
)
39+
endif()
2840

29-
set_property(
30-
GLOBAL PROPERTY
31-
bootconf_PM_TARGET
32-
bootconf_target
33-
)
34-
endif()
35-
endfunction()
41+
add_custom_target(bootconf_target
42+
DEPENDS ${bootconf_hex}
43+
)
3644

37-
setup_bootconf_data()
45+
if(SB_CONFIG_PARTITION_MANAGER)
46+
set_property(
47+
GLOBAL PROPERTY
48+
bootconf_PM_HEX_FILE
49+
${bootconf_hex}
50+
)
51+
52+
set_property(
53+
GLOBAL PROPERTY
54+
bootconf_PM_TARGET
55+
bootconf_target
56+
)
57+
else()
58+
# Add the bootconf with b0 as bootconf is supposed to protect it.
59+
add_dependencies(b0 bootconf_target)
60+
endif()

sysbuild/secureboot.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ if(SB_CONFIG_SECURE_BOOT)
9494

9595
include(image_flasher.cmake)
9696
add_image_flasher(NAME app_provision HEX_FILE "${CMAKE_BINARY_DIR}/app_provision.hex")
97+
if(SB_CONFIG_SOC_SERIES_NRF54L)
98+
add_image_flasher(NAME bootconf HEX_FILE "${CMAKE_BINARY_DIR}/bootconf.hex")
99+
sysbuild_add_dependencies(FLASH bootconf b0)
100+
endif()
97101
endif()
98102

99103
set_target_properties(b0 PROPERTIES

0 commit comments

Comments
 (0)