Skip to content

Commit ef85447

Browse files
committed
mcuboot: Support for DIRECT XIP on nRF54H - app core only
This commit adds support for the DIRECT_XIP modes on nRF54H20 Signed-off-by: Artur Hadasz <artur.hadasz@nordicsemi.no>
1 parent 900df03 commit ef85447

File tree

5 files changed

+66
-28
lines changed

5 files changed

+66
-28
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@
792792
/subsys/fw_info/ @nrfconnect/ncs-pluto
793793
/subsys/gazell/ @leewkb4567
794794
/subsys/logging/ @nrfconnect/ncs-protocols-serialization
795+
/subsys/mcuboot/ @nrfconnect/ncs-charon
795796
/subsys/mgmt/ @nrfconnect/ncs-pluto
796797
/subsys/mgmt/suitfu/ @nrfconnect/ncs-charon
797798
/subsys/mpsl/ @nrfconnect/ncs-dragoon

cmake/sysbuild/image_signing.cmake

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,36 +58,46 @@ function(zephyr_mcuboot_tasks)
5858
# Fetch devicetree details for flash and slot information
5959
dt_chosen(flash_node PROPERTY "zephyr,flash")
6060
dt_nodelabel(slot0_flash NODELABEL "slot0_partition" REQUIRED)
61-
dt_prop(slot_size PATH "${slot0_flash}" PROPERTY "reg" INDEX 1 REQUIRED)
61+
dt_reg_size(slot_size PATH "${slot0_flash}" REQUIRED)
6262
dt_prop(write_block_size PATH "${flash_node}" PROPERTY "write-block-size")
6363

6464
if(NOT write_block_size)
6565
set(write_block_size 4)
6666
message(WARNING "slot0_partition write block size devicetree parameter is missing, assuming write block size is 4")
6767
endif()
6868

69-
set(imgtool_directxip_hex_command)
70-
71-
if(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP_WITH_REVERT OR CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP)
72-
# XIP image, need to use the fixed address for this slot
73-
if(CONFIG_NCS_IS_VARIANT_IMAGE)
74-
set(imgtool_rom_command --rom-fixed @PM_MCUBOOT_SECONDARY_ADDRESS@)
75-
else()
76-
set(imgtool_rom_command --rom-fixed @PM_MCUBOOT_PRIMARY_ADDRESS@)
69+
if(CONFIG_PARTITION_MANAGER_ENABLED)
70+
if(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP_WITH_REVERT OR CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP)
71+
# XIP image, need to use the fixed address for this slot
72+
if(CONFIG_NCS_IS_VARIANT_IMAGE)
73+
set(imgtool_rom_command --rom-fixed @PM_MCUBOOT_SECONDARY_ADDRESS@)
74+
else()
75+
set(imgtool_rom_command --rom-fixed @PM_MCUBOOT_PRIMARY_ADDRESS@)
76+
endif()
7777
endif()
7878

79-
if(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP_WITH_REVERT)
80-
set(imgtool_directxip_hex_command --confirm)
79+
# Split fields, imgtool_sign_sysbuild is stored in cache which will have fields updated by
80+
# sysbuild, imgtool_sign must not be stored in cache because it would then prevent those fields
81+
# from being updated without a pristine build
82+
# TODO: NCSDK-28461 sysbuild PM fields cannot be updated without a pristine build, will become
83+
# invalid if a static PM file is updated without pristine build
84+
set(imgtool_sign_sysbuild --slot-size @PM_MCUBOOT_PRIMARY_SIZE@ --pad-header --header-size @PM_MCUBOOT_PAD_SIZE@ ${imgtool_rom_command} CACHE STRING "imgtool sign sysbuild replacement")
85+
set(imgtool_sign ${PYTHON_EXECUTABLE} ${IMGTOOL} sign --version ${CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION} --align ${write_block_size} ${imgtool_sign_sysbuild})
86+
else()
87+
set(imgtool_rom_command)
88+
if(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP_WITH_REVERT OR CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP)
89+
dt_chosen(code_partition PROPERTY "zephyr,code-partition")
90+
dt_reg_addr(code_partition_offset PATH "${code_partition}" REQUIRED)
91+
set(imgtool_rom_command --rom-fixed ${code_partition_offset})
8192
endif()
93+
set(imgtool_sign ${PYTHON_EXECUTABLE} ${IMGTOOL} sign --version ${CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION} --align ${write_block_size} --slot-size ${slot_size} --header-size ${CONFIG_ROM_START_OFFSET} ${imgtool_rom_command})
8294
endif()
8395

84-
# Split fields, imgtool_sign_sysbuild is stored in cache which will have fields updated by
85-
# sysbuild, imgtool_sign must not be stored in cache because it would then prevent those fields
86-
# from being updated without a pristine build
87-
# TODO: NCSDK-28461 sysbuild PM fields cannot be updated without a pristine build, will become
88-
# invalid if a static PM file is updated without pristine build
89-
set(imgtool_sign_sysbuild --slot-size @PM_MCUBOOT_PRIMARY_SIZE@ --pad-header --header-size @PM_MCUBOOT_PAD_SIZE@ ${imgtool_rom_command} CACHE STRING "imgtool sign sysbuild replacement")
90-
set(imgtool_sign ${PYTHON_EXECUTABLE} ${IMGTOOL} sign --version ${CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION} --align ${write_block_size} ${imgtool_sign_sysbuild})
96+
set(imgtool_directxip_hex_command)
97+
98+
if(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP_WITH_REVERT)
99+
set(imgtool_directxip_hex_command --confirm)
100+
endif()
91101

92102
# Arguments to imgtool.
93103
if(NOT CONFIG_MCUBOOT_EXTRA_IMGTOOL_ARGS STREQUAL "")
@@ -197,9 +207,11 @@ function(zephyr_mcuboot_tasks)
197207
set(unconfirmed_args ${input}.hex ${output}.hex)
198208
list(APPEND byproducts ${output}.hex)
199209

200-
# Do not run zephyr_runner_file here as PM will provide the merged hex file from
201-
# sysbuild's scope unless this is a variant image
202-
if(CONFIG_NCS_IS_VARIANT_IMAGE)
210+
# If using partition manager do not run zephyr_runner_file here as PM will
211+
# provide the merged hex file from sysbuild's scope unless this is a variant image
212+
# Otherwise run zephyr_runner_file for both images to ensure the signed hex file
213+
# is used for flashing
214+
if((NOT CONFIG_PARTITION_MANAGER_ENABLED) OR CONFIG_NCS_IS_VARIANT_IMAGE)
203215
zephyr_runner_file(hex ${output}.hex)
204216
endif()
205217

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/ {
8+
chosen {
9+
zephyr,code-partition = &slot1_partition;
10+
};
11+
};

sysbuild/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_pre_cmake)
287287
set_config_bool(mcuboot CONFIG_BOOT_FIH_PROFILE_DEFAULT_LOW y)
288288
endif()
289289

290-
if(SB_CONFIG_PARTITION_MANAGER)
291-
# Use NCS signing script with support for PM
290+
if(SB_CONFIG_PARTITION_MANAGER OR SB_CONFIG_MCUBOOT_MODE_DIRECT_XIP OR SB_CONFIG_MCUBOOT_MODE_DIRECT_XIP_WITH_REVERT)
291+
# Use NCS signing script with support for PM or direct XIP (NCS specific features)
292292
if(SB_CONFIG_QSPI_XIP_SPLIT_IMAGE)
293293
set(${DEFAULT_IMAGE}_SIGNING_SCRIPT "${ZEPHYR_NRF_MODULE_DIR}/cmake/sysbuild/image_signing_split.cmake" CACHE INTERNAL "MCUboot signing script" FORCE)
294294

sysbuild/mcuboot.cmake

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,24 @@
55

66
if(SB_CONFIG_MCUBOOT_BUILD_DIRECT_XIP_VARIANT)
77
set(image mcuboot_secondary_app)
8-
ExternalNcsVariantProject_Add(APPLICATION ${DEFAULT_IMAGE} VARIANT ${image})
8+
if(SB_CONFIG_PARTITION_MANAGER)
9+
ExternalNcsVariantProject_Add(APPLICATION ${DEFAULT_IMAGE} VARIANT ${image})
910

10-
set_property(GLOBAL APPEND PROPERTY
11-
PM_APP_IMAGES
12-
"${image}"
13-
)
11+
set_property(GLOBAL APPEND PROPERTY
12+
PM_APP_IMAGES
13+
"${image}"
14+
)
15+
else()
16+
# TODO: NCSDK-33774 add a general way to pass configuration options to the variant
17+
# image
18+
zephyr_get(extra_conf_file SYSBUILD LOCAL VAR EXTRA_CONF_FILE)
19+
20+
ExternalNcsVariantProject_Add(APPLICATION ${DEFAULT_IMAGE} VARIANT ${image} SPLIT_KCONFIG true)
21+
set(${image}_EXTRA_CONF_FILE "${extra_conf_file}" CACHE INTERNAL "")
22+
set_target_properties(${image} PROPERTIES
23+
IMAGE_CONF_SCRIPT ${ZEPHYR_BASE}/share/sysbuild/image_configurations/MAIN_image_default.cmake
24+
)
25+
set(secondary_overlay "${ZEPHYR_NRF_MODULE_DIR}/subsys/mcuboot/mcuboot_secondary_app.overlay")
26+
add_overlay_dts(${image} "${secondary_overlay}")
27+
endif()
1428
endif()

0 commit comments

Comments
 (0)