Problem with updatable MCUBoot + multi updatable images

Hello, 

I work on a zephyr project with updatable MCUBoot and two updatable images. This configuration ends up with an unbootable image. The reason is that the CONFIG_MCUBOOT_MCUBOOT_IMAGE_NUMBER ends up with value 1 while the SECURE_BOOT_APPCORE is enabled and MCUBOOT_UPDATEABLE_IMAGES > 1. The following patch seems to solve the issue:

diff --git a/sysbuild/CMakeLists.txt b/sysbuild/CMakeLists.txt
index 7abed9c84c..155f83be32 100644
--- a/sysbuild/CMakeLists.txt
+++ b/sysbuild/CMakeLists.txt
@@ -232,6 +232,17 @@ function(${SYSBUILD_CURRENT_MODULE_NAME}_pre_cmake)
       set(${current_cache_name} ${value} CACHE INTERNAL "" FORCE)
     endforeach()
 
+    if(SB_CONFIG_SECURE_BOOT_APPCORE)
+      math(EXPR correct_mcuboot_image_number "${mcuboot_total_images} - 1")
+      if(NOT ${NCS_MCUBOOT_MCUBOOT_IMAGE_NUMBER} EQUAL ${correct_mcuboot_image_number})
+        set(image_list b0;mcuboot;${updateable_images})
+        foreach(image ${image_list})
+          set_config_int(${image} CONFIG_MCUBOOT_MCUBOOT_IMAGE_NUMBER ${correct_mcuboot_image_number})
+        endforeach()
+        set(NCS_MCUBOOT_MCUBOOT_IMAGE_NUMBER ${correct_mcuboot_image_number} CACHE INTERNAL "" FORCE)
+      endif()
+    endif()
+
     # Assign image IDs for MCUboot extra images
     set(dfu_slots_application_kconfigs CONFIG_MCUBOOT_EXTRA_1_IMAGE_NUMBER;CONFIG_MCUBOOT_EXTRA_2_IMAGE_NUMBER)
     set(dfu_slots_cache_names NCS_MCUBOOT_EXTRA_1_IMAGE_NUMBER;NCS_MCUBOOT_EXTRA_2_IMAGE_NUMBER)

NCS v3.5.0-preview1
nRF54L15 DK

Could you confirm if you can reproduce the issue?

Regards,
Filip

Related