Skip to content

Commit 0d7cbfd

Browse files
committed
sysbuild: bootconf lock
Add bootloader immutability through RRAMC's region no.3 Applies before first boot. Signed-off-by: Mateusz Michalek <[email protected]>
1 parent 8f0ab45 commit 0d7cbfd

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

cmake/sysbuild/bootconf.cmake

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
function(setup_bootconf_data)
8+
add_custom_target(bootconf_target
9+
ALL
10+
DEPENDS ${CMAKE_BINARY_DIR}/bootconf.hex
11+
)
12+
13+
dt_nodelabel(boot_partition_node_full_path NODELABEL "boot_partition")
14+
dt_reg_size(boot_partition_node_size PATH "${boot_partition_node_full_path}")
15+
if(${boot_partition_node_size} GREATER 0x7c00)
16+
message(WARNING "boot_partition doesn't fit into protection region.
17+
Protection will be applied over maximum allowed span.")
18+
endif()
19+
20+
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bootconf.hex
21+
COMMAND ${Python3_EXECUTABLE}
22+
${ZEPHYR_NRF_MODULE_DIR}/scripts/reglock.py
23+
--output ${CMAKE_BINARY_DIR}/bootconf.hex
24+
--size ${boot_partition_node_size}
25+
VERBATIM
26+
)
27+
28+
endfunction()
29+
30+
setup_bootconf_data()

modules/mcuboot/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ include(${ZEPHYR_NRF_MODULE_DIR}/modules/mcuboot/CMakeLists.txt)
99
if(CONFIG_MCUBOOT AND CONFIG_NCS_BM)
1010
include(${ZEPHYR_NRF_BM_MODULE_DIR}/cmake/image_signing_softdevice.cmake)
1111
include(${ZEPHYR_NRF_BM_MODULE_DIR}/cmake/flash_metadata.cmake)
12+
include(${ZEPHYR_NRF_BM_MODULE_DIR}/cmake/sysbuild/bootconf.cmake)
1213
endif()

sysbuild/Kconfig.bm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ config BM_BOOT_IMG_HASH_ALG_PURE
8484

8585
endchoice
8686

87+
config BM_BOOT_BOOTCONF_LOCK_WRITES
88+
bool "Protect bootloader's NVM from writes"
89+
depends on SOC_NRF54L15_CPUAPP || SOC_NRF54L05_CPUAPP || SOC_NRF54L10_CPUAPP
90+
default y
91+
help
92+
Sets RRAMC's BOOTCONF region protection to disable writes.
93+
8794
endmenu
8895

8996
endif # BM_BOOTLOADER_MCUBOOT

0 commit comments

Comments
 (0)