From 738c069c642e0bbb0a61fe1b00a0e515795c82fc Mon Sep 17 00:00:00 2001 From: Tomasz Chyrowicz Date: Fri, 3 Oct 2025 13:02:59 +0200 Subject: [PATCH 1/2] cmake: Automatically convert slotted dependencies If the main image specifies a slotted dependency, assume that the variant image should include a similar dependency, but for the secondary slot. Ref: NCSDK-35733 Signed-off-by: Tomasz Chyrowicz --- cmake/modules/kconfig.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmake/modules/kconfig.cmake b/cmake/modules/kconfig.cmake index 8aed0a828ee..fd5fd5e2880 100644 --- a/cmake/modules/kconfig.cmake +++ b/cmake/modules/kconfig.cmake @@ -39,6 +39,7 @@ if(CONFIG_NCS_IS_VARIANT_IMAGE) # Modify the CONFIG_FLASH_LOAD_OFFSET and CONFIG_FLASH_LOAD_SIZE for both the .config and autoconf.h files. # If partition manager is not used, these values should be taken from the device tree. + # Additionally, convert primary slot dependencies to secondary slot dependencies. set(dotconfig_variant_content) foreach(line IN LISTS dotconfig_content) if("${line}" MATCHES "^CONFIG_FLASH_LOAD_OFFSET=.*$") @@ -49,6 +50,10 @@ if(CONFIG_NCS_IS_VARIANT_IMAGE) string(REGEX REPLACE "CONFIG_FLASH_LOAD_SIZE=(.*)" "CONFIG_FLASH_LOAD_SIZE=${code_partition_size}" line ${line}) endif() + if("${line}" MATCHES "(--dependencies|-d).*\([0-9, ]+primary[0-9., ]+\)") + string(REGEX REPLACE "primary" "secondary" line ${line}) + endif() + list(APPEND dotconfig_variant_content "${line}\n") endforeach() @@ -62,6 +67,10 @@ if(CONFIG_NCS_IS_VARIANT_IMAGE) string(REGEX REPLACE "#define CONFIG_FLASH_LOAD_SIZE (.*)" "#define CONFIG_FLASH_LOAD_SIZE ${code_partition_size}" line ${line}) endif() + if("${line}" MATCHES "(--dependencies|-d).*\([0-9, ]+primary[0-9., ]+\)") + string(REGEX REPLACE "primary" "secondary" line ${line}) + endif() + list(APPEND autoconf_variant_content "${line}\n") endforeach() From 509b69290675a47cf578a59688bb9b20e310017d Mon Sep 17 00:00:00 2001 From: Tomasz Chyrowicz Date: Fri, 3 Oct 2025 15:30:08 +0200 Subject: [PATCH 2/2] cmake: Support for split slot Direct XIP in ZIP Add code necessary to include both slots, generated by the Direct XIP inside the DFU ZIP distribution file. Ref: NCSDK-35733 Signed-off-by: Tomasz Chyrowicz --- cmake/sysbuild/zip.cmake | 97 +++++++++++++++++++++++++++------------- 1 file changed, 66 insertions(+), 31 deletions(-) diff --git a/cmake/sysbuild/zip.cmake b/cmake/sysbuild/zip.cmake index 8dee146422d..a20a109325d 100644 --- a/cmake/sysbuild/zip.cmake +++ b/cmake/sysbuild/zip.cmake @@ -193,6 +193,7 @@ function(dfu_app_zip_package) # Network core get_property(image_name GLOBAL PROPERTY DOMAIN_APP_CPUNET) set(net_update_name "${image_name}.bin") + set(secondary_net_update_name "${image_name}_secondary_app.bin") sysbuild_get(net_core_board IMAGE ${image_name} VAR BOARD CACHE) if(SB_CONFIG_SECURE_BOOT_NETCORE) @@ -204,42 +205,76 @@ function(dfu_app_zip_package) mcuboot_image_number_to_slot(net_update_slot_primary ${SB_CONFIG_MCUBOOT_NETWORK_CORE_IMAGE_NUMBER} n) mcuboot_image_number_to_slot(net_update_slot_secondary ${SB_CONFIG_MCUBOOT_NETWORK_CORE_IMAGE_NUMBER} y) - if(SB_CONFIG_PARTITION_MANAGER) - set(net_load_address "$") - else() - get_address_from_dt_partition_nodelabel("slot${net_update_slot_primary}_partition" - net_load_address - ) - endif() + if(NOT SB_CONFIG_MCUBOOT_BUILD_DIRECT_XIP_VARIANT) + if(SB_CONFIG_PARTITION_MANAGER) + set(net_load_address "$") + else() + get_address_from_dt_partition_nodelabel("slot${net_update_slot_primary}_partition" + net_load_address + ) + endif() - math(EXPR net_update_slot_primary "${net_update_slot_primary} + 1") - math(EXPR net_update_slot_secondary "${net_update_slot_secondary} + 1") + math(EXPR net_update_slot_primary "${net_update_slot_primary} + 1") + math(EXPR net_update_slot_secondary "${net_update_slot_secondary} + 1") + + set(generate_script_app_params + ${generate_script_app_params} + "${net_update_name}image_index=${SB_CONFIG_MCUBOOT_NETWORK_CORE_IMAGE_NUMBER}" + "${net_update_name}slot_index_primary=${net_update_slot_primary}" + "${net_update_name}slot_index_secondary=${net_update_slot_secondary}" + "${net_update_name}load_address=${net_load_address}" + "${net_update_name}version=${net_update_version}" + "${net_update_name}board=${net_core_board}" + "${net_update_name}soc=${SB_CONFIG_SOC}" + ) + + if(SB_CONFIG_SECURE_BOOT_NETCORE) + list(APPEND bin_files "${CMAKE_BINARY_DIR}/signed_by_mcuboot_and_b0_${image_name}.bin") + list(APPEND signed_targets ${image_name}_signed_packaged_target) + else() + sysbuild_get(net_CONFIG_KERNEL_BIN_NAME IMAGE ${image_name} VAR CONFIG_KERNEL_BIN_NAME KCONFIG) + if(SB_CONFIG_BOOT_ENCRYPTION) + list(APPEND bin_files "${CMAKE_BINARY_DIR}/${image_name}/zephyr/${net_CONFIG_KERNEL_BIN_NAME}.signed.encrypted.bin") + else() + list(APPEND bin_files "${CMAKE_BINARY_DIR}/${image_name}/zephyr/${net_CONFIG_KERNEL_BIN_NAME}.signed.bin") + endif() + endif() + + list(APPEND zip_names "${net_update_name}") + list(APPEND signed_targets ${image_name}_extra_byproducts) + elseif(NOT SB_CONFIG_PARTITION_MANAGER) + get_address_from_dt_partition_nodelabel("slot${net_update_slot_primary}_partition" primary_net_load_address) + get_address_from_dt_partition_nodelabel("slot${net_update_slot_secondary}_partition" secondary_net_load_address) - set(generate_script_app_params + # Radio in DirectXIP mode + set(generate_script_app_params ${generate_script_app_params} - "${net_update_name}image_index=${SB_CONFIG_MCUBOOT_NETWORK_CORE_IMAGE_NUMBER}" - "${net_update_name}slot_index_primary=${net_update_slot_primary}" - "${net_update_name}slot_index_secondary=${net_update_slot_secondary}" - "${net_update_name}load_address=${net_load_address}" - "${net_update_name}version=${net_update_version}" - "${net_update_name}board=${net_core_board}" - "${net_update_name}soc=${SB_CONFIG_SOC}" - ) + "${net_update_name}load_address=${primary_net_load_address}" + "${net_update_name}version_MCUBOOT+XIP=${CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION}" + "${net_update_name}image_index=${SB_CONFIG_MCUBOOT_NETWORK_CORE_IMAGE_NUMBER}" + "${net_update_name}slot=${net_update_slot_primary}" + "${secondary_net_update_name}load_address=${secondary_net_load_address}" + "${secondary_net_update_name}image_index=${SB_CONFIG_MCUBOOT_NETWORK_CORE_IMAGE_NUMBER}" + "${secondary_net_update_name}slot=${net_update_slot_secondary}" + "${secondary_net_update_name}version_MCUBOOT+XIP=${CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION}" + ) + list(APPEND bin_files + "${CMAKE_BINARY_DIR}/${image_name}/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin" + "${CMAKE_BINARY_DIR}/${image_name}_secondary_app/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin" + ) + set(exclude_files EXCLUDE + ${CMAKE_BINARY_DIR}/${image_name}/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin + ${CMAKE_BINARY_DIR}/${image_name}_secondary_app/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin + ) + set(include_files INCLUDE + ${CMAKE_BINARY_DIR}/${image_name}/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin + ${CMAKE_BINARY_DIR}/${image_name}_secondary_app/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin + ) - if(SB_CONFIG_SECURE_BOOT_NETCORE) - list(APPEND bin_files "${CMAKE_BINARY_DIR}/signed_by_mcuboot_and_b0_${image_name}.bin") - list(APPEND signed_targets ${image_name}_signed_packaged_target) - else() - sysbuild_get(net_CONFIG_KERNEL_BIN_NAME IMAGE ${image_name} VAR CONFIG_KERNEL_BIN_NAME KCONFIG) - if(SB_CONFIG_BOOT_ENCRYPTION) - list(APPEND bin_files "${CMAKE_BINARY_DIR}/${image_name}/zephyr/${net_CONFIG_KERNEL_BIN_NAME}.signed.encrypted.bin") - else() - list(APPEND bin_files "${CMAKE_BINARY_DIR}/${image_name}/zephyr/${net_CONFIG_KERNEL_BIN_NAME}.signed.bin") - endif() + list(APPEND zip_names "${net_update_name};${secondary_net_update_name}") + list(APPEND signed_targets ${image_name}_extra_byproducts) + list(APPEND signed_targets ${image_name}_secondary_app_extra_byproducts) endif() - - list(APPEND zip_names "${net_update_name}") - list(APPEND signed_targets ${image_name}_extra_byproducts) endif() if(SB_CONFIG_DFU_ZIP_WIFI_FW_PATCH)