Skip to content

Commit 7b4d2ba

Browse files
committed
sysbuild: image_signing: set ih_load_addr from slot0 partition
The MCUboot CHECK_HEADER_LOAD_ADDRESS feature (CONFIG_MCUBOOT_CHECK_HEADER_LOAD_ADDRESS) verifies that an image in the secondary slot is intended for the primary slot by comparing the ih_load_addr field in the image header against the primary slot boundaries. The NCS sysbuild signing script did not pass --load-addr or --rom-fixed to imgtool for the OVERWRITE_ONLY and default swap branches, leaving ih_load_addr at zero in the signed application image. This caused MCUboot to reject every legitimate application update because zero falls outside the primary slot's address range. Updated nrf/cmake/sysbuild/image_signing.cmake to read the absolute slot0_partition address with dt_partition_addr ABSOLUTE and pass it as --rom-fixed to imgtool for both the OVERWRITE_ONLY and default swap branches. The ROM_FIXED flag follows the pattern already used by the cpunet image signing in nrf/cmake/sysbuild/b0_mcuboot_signing.cmake. Added SB_CONFIG_SOC_SERIES_NRF53 to the list of platforms in nrf/sysbuild/CMakeLists.txt that route through the NCS sysbuild signing script instead of the upstream zephyr/cmake/mcuboot.cmake. This makes non-PM nRF53 builds (such as the Fast Pair Locator Tag sample migrated to DTS) pick up the ih_load_addr fix. The change mirrors the existing treatment of SB_CONFIG_SOC_SERIES_NRF54L and SB_CONFIG_SOC_SERIES_NRF54H. Verified on the nRF5340 DK Fast Pair Locator Tag sample (nrf5340dk/nrf5340/cpuapp): the signed application image now reports ih_load_addr = 0xc000 and flags = ROM_FIXED, matching the slot0_partition definition in DTS. The cpunet image signing remains unchanged (ih_load_addr = 0x01002800, flags = ROM_FIXED). The equivalent fix is needed in upstream Zephyr (zephyr/cmake/mcuboot.cmake) for users that do not route through the NCS sysbuild signing script. Ref: NCSDK-38010 Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
1 parent e795138 commit 7b4d2ba

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

cmake/sysbuild/image_signing.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ function(zephyr_mcuboot_tasks)
6262
dt_chosen(flash_node PROPERTY "zephyr,flash")
6363
dt_nodelabel(slot0_flash NODELABEL "slot0_partition" REQUIRED)
6464
dt_reg_size(slot_size PATH "${slot0_flash}" REQUIRED)
65+
# Absolute slot0 address is used to set ih_load_addr in the image header so
66+
# that the MCUBOOT_CHECK_HEADER_LOAD_ADDRESS feature can verify the
67+
# secondary-slot image is intended for the primary slot.
68+
dt_partition_addr(slot0_partition_address PATH "${slot0_flash}" REQUIRED ABSOLUTE)
6569
dt_prop(write_block_size PATH "${flash_node}" PROPERTY "write-block-size")
6670

6771
if(NOT write_block_size)
@@ -90,7 +94,7 @@ function(zephyr_mcuboot_tasks)
9094
set(imgtool_rom_command)
9195
if(CONFIG_MCUBOOT_IMGTOOL_OVERWRITE_ONLY)
9296
# Use overwrite-only instead of swap upgrades.
93-
set(imgtool_rom_command --overwrite-only --align 1)
97+
set(imgtool_rom_command --overwrite-only --align 1 --rom-fixed ${slot0_partition_address})
9498
elseif(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD OR
9599
CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD_WITH_REVERT)
96100
# RAM load requires setting the location of where to load the image to
@@ -124,7 +128,7 @@ function(zephyr_mcuboot_tasks)
124128
dt_reg_size(slot_size PATH "${code_partition}" REQUIRED)
125129
set(imgtool_rom_command --rom-fixed ${code_partition_offset} --align ${write_block_size})
126130
else()
127-
set(imgtool_rom_command --align ${write_block_size})
131+
set(imgtool_rom_command --align ${write_block_size} --rom-fixed ${slot0_partition_address})
128132
endif()
129133

130134
# TF-M combined images need --pad-header because the MCUboot header gap is

sysbuild/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_pre_cmake)
472472
OR SB_CONFIG_MCUBOOT_COMPRESSED_IMAGE_SUPPORT
473473
OR SB_CONFIG_MCUBOOT_HARDWARE_DOWNGRADE_PREVENTION
474474
# Do not use the upstream mcuboot.cmake on new platforms.
475+
OR SB_CONFIG_SOC_SERIES_NRF53
475476
OR SB_CONFIG_SOC_SERIES_NRF54L
476477
OR SB_CONFIG_SOC_SERIES_NRF54H OR SB_CONFIG_QSPI_XIP_SPLIT_IMAGE
477478
# TF-M NS builds require signing tfm_merged.hex, not zephyr.hex.

0 commit comments

Comments
 (0)