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

  • Hi, 

    Are you doing pristine builds in VS code? Could you try to use west build? Also, test west build with the example provided by Simon in this thread

    Regards,
    Amanda

  • Hi Amanda,

    As described in the original ticket (the same thread you pointed to), I use west to build:

      $ rm -rf build
      $ west build --build-dir build/ncs src/ncs
      $ nrfjprog -f NRF52 --sectorerase --verify --program build/ncs/mcuboot/zephyr/zephyr.hex
      $ nrfjprog -f NRF52 --sectorerase --verify --program build/ncs/zephyr/app_signed.hex
      $ nrfjprog -f NRF52 --reset

    And yes, I tried the suggestion with the child_image, but it didn't help.

    Best regards,
    Thomas

  • Hi, 

    With the hello_world_with_mcuboot_v2.zip provided by Simon, I run the command with nRF52DK as:

    west build -b nrf52dk_nrf52832 -p && west flash --recover

    And get:

    *** Booting Zephyr OS build v2.6.99-ncs1  ***
    
    I: Starting bootloader
    
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    
    I: Boot source: none
    
    I: Swap type: none
    
    I: Bootloader chainload address offset: 0xc000
    
    I: Jumping to the first image slot
    ▒*** Booting Zephyr OS build v2.6.99-ncs1  ***
    
    Hello World! nrf52dk_nrf52832
    
     

    -Amanda

  • 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.

  • Hi,

    The suggestion to use child_image was found in the following issue:
    https://devzone.nordicsemi.com/f/nordic-q-a/84564/unable-to-find-bootable-image---mcuboot

    I tried the solution given there, but without any success.
    For time being, I have just updated the build-script to build two times - crude but works ...

    Cheers,

    Thomas

Related