Unable to find bootable image - MCUBoot - again

Hi again,

The previous issue is closed - but I never got any suggestions or answers to my problem.

I still have this problem - if I do a prestine build the mcuboot doesn't work - if I just touch the makefile and build again - then it works.

Below is my last entry in the original issue (https://devzone.nordicsemi.com/f/nordic-q-a/84564/unable-to-find-bootable-image---mcuboot).

Best regards,
Thomas

-------------------


I'm trying to see what differs between the two builds, and one thing I noticed is in the build/ncs/CMakeCache.txt file.

When it fails, it more or less only differs in the following line:

mcuboot_OVERLAY_CONFIG:INTERNAL=
  /xx/vsln-ncs/vt2-overlays/vt2-mcuboot-overlay.conf
  /xx/ncs/nrf/subsys/partition_manager/partition_manager_enabled.conf


When it works it looks like this:

mcuboot_OVERLAY_CONFIG:INTERNAL=
  /xx/vsln-ncs/vt2-overlays/vt2-mcuboot-overlay.conf
  /xx/ncs/nrf/subsys/partition_manager/partition_manager_enabled.conf
  ; /xx/vsln-ncs/vt2-overlays/vt2-mcuboot-overlay.conf
  /xx/ncs/nrf/subsys/partition_manager/ext_flash_mcuboot_secondary.conf

And the .config only differs for mcuboot as I showed in a previous entry:

$ diff build/ncs/mcuboot/zephyr/.config fail_build/ncs/mcuboot/zephyr/.config
  265,266c265,266
  < CONFIG_PARTITION_MANAGER_ENABLED=y
  < CONFIG_FLASH_MAP_CUSTOM=y
  ---
  > # CONFIG_PARTITION_MANAGER_ENABLED is not set
  > # CONFIG_FLASH_MAP_CUSTOM is not set

So, it seems as if the config somehow is not correctly setup during a prestine build. The vt2-mcuboot-overlay.conf is included twice, and the ext_flash_mcuboot_secondary is only included in the working build.

The ext_flash_mcuboot_secondary.conf is included in the CMakeFile.txt for the mcuboot, in the file ncs/nrf/modules/mcuboot/CMakeLists.txt:

  if (CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY)
    # By passing this value we don't require the user to pass any overlay files
    # to the MCUboot child image for storing the secondary partition in
    # external flash.
    add_overlay_config(
      mcuboot
      ${ZEPHYR_NRF_MODULE_DIR}/subsys/partition_manager/ext_flash_mcuboot_secondary.conf
)
  endif()

And CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY seems to be configured in the subsys/partition_manager/ext_flash_mcuboot_secondary.conf file, which seems odd since then we have a circular reference ... (the config is set in the file included if the config is set ...) ?

And that is the only content of the file ncs/nrf/subsys/partition_manager/ext_flash_mcuboot_secondary.conf:

  CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY
=y

I can't see that this config is set anywhere else ...

Could that be that the MCUBOOT_SECONDARY somehow is not included in the first build, but in the second build the buildsystem gets that the MCUBOOT_SECONDARY should be included ... at least that how I interpret the CMakeCache.txt contents ... that could explain why the bootloader doesn't find the image in the first build.

Best regards,
Thomas

Parents
  • Hi Thomas,

    I also experience this issue with nRF SDK 1.9.1. I don't really know the reason, but it seems to me there is something wrong with CMake + west + zephyr magic build system. I noticed when I remove MCUboot overlay, the problem goes away.

    I have found a workaround. Instead of using MCUboot overlay, I am using child image. The disadvantage of this is that I have to completely duplicate MCUboot configuration since it is not merged with default.

    Steps to perform a workaround:

    1. Crete a folder in the root of your project child_images/mcuboot/

    2. Copy zephyr/bootloader/mcuboot/boot/zephyr/prj.conf to that folder

    3. Make required modifications to prj.conf according to your mcuboot-overlay.conf

    4. Delete your mcuboot-overlay.conf and reference to it from CMakeLists.txt

    Edit: I just noticed you mention child_image in on of your comments, unfortunately the link to your previous ticket does not work for me, so I can't verify if suggested workaround was the same.

Reply
  • Hi Thomas,

    I also experience this issue with nRF SDK 1.9.1. I don't really know the reason, but it seems to me there is something wrong with CMake + west + zephyr magic build system. I noticed when I remove MCUboot overlay, the problem goes away.

    I have found a workaround. Instead of using MCUboot overlay, I am using child image. The disadvantage of this is that I have to completely duplicate MCUboot configuration since it is not merged with default.

    Steps to perform a workaround:

    1. Crete a folder in the root of your project child_images/mcuboot/

    2. Copy zephyr/bootloader/mcuboot/boot/zephyr/prj.conf to that folder

    3. Make required modifications to prj.conf according to your mcuboot-overlay.conf

    4. Delete your mcuboot-overlay.conf and reference to it from CMakeLists.txt

    Edit: I just noticed you mention child_image in on of your comments, unfortunately the link to your previous ticket does not work for me, so I can't verify if suggested workaround was the same.

Children
Related