MCUBoot fails to load if using CMake Overlay Config

I am developing an app with the MCUBoot and a main applicaton. I followed the SMP SVR tutorial and modified it to my needs.

I have noticed that if I use a config overlay for MCUBoot (in CMake), it fails to set the config CONFIG_PARTITION_MANAGER_ENABLED and CONFIG_FLASH_MAP_CUSTOM=y, which then makes the bootloader fail. (Note: I am using a custom static partition yaml filee)

If I declare all my overlay configurations in child_image/mcuboot.conf or as CMake defines as mcuboot_CONFIG_HELLO, it works.

I need an overlay config since only when I am in a certain build configuration I want to activate them

This is how the CMake snippet looks like

if(MYCONDITION_FOR_USING_OVERLAY)
    set(mcuboot_OVERLAY_CONFIG ${CMAKE_CURRENT_LIST_DIR}/child_image/mcuboot_my_overlay.conf)
endif()

And the file child_image/mcuboot_my_overlay.conf looks as follows

CONFIG_LOG=y
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y

Log error message

*** Booting Zephyr OS build v3.0.99-ncs1  ***
I: Starting bootloader
W: Failed reading sectors; BOOT_MAX_IMG_SECTORS=128 - too small?
W: Cannot upgrade: not a compatible amount of sectors
E: Image in the primary slot is not valid!
E: Unable to find bootable image

However, if I use CMake options or declare everything in the child_image_name/child_image.conf dir (i.e., child_image/mcuboot.conf) it works:

if(MYCONDITION_FOR_USING_OVERLAY)
    set(mcuboot_CONFIG_SERIAL y)
    set(mcuboot_CONFIG_LOG y)
    set(mcuboot_CONFIG_CONSOLE y)
    set(mcuboot_CONFIG_UART_CONSOLE y)
endif()

Am I missing something that makes the build not include my static partition and thus making the bootloader fail?

I used as reference this:

developer.nordicsemi.com/.../ug_multi_image.html

Parents
  • Well escaping the characters did not help, Zephyr interpreted it as

    file not found:
    C:/ncs/v2.0.0/bootloader/mcuboot/boot/zephyr/"C:/MY_PROJECT_PATH/child_image/mcuboot_Debug.conf"

    The variable is set correctly here is the outpt

    message(SEND_ERROR "overlay config is ${mcuboot_OVERLAY_CONFIG}" )

    overlay config is
      C:/MY_PROJECT_PATH/child_image/mcuboot_Debug.conf

    What I dont understand is why zephyr ignores my partition_static.yml when using the overlay config... The problem is not related to the MCuboot config not being passed or merged in the build process but rather that when using the mcuboot overlay as discussed above those two specifc defines for partition configuration are not set anymore. Note that these configurations are not set by me but I guess they are selected with the partition manager script.

    I also checked the partition manager script output and seems correct

    -- Found partition manager static configuration: C:/MY_PROJECT_PATH/pm_static.yml
    Partition 'mcuboot' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_pad' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_primary' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_primary_app' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_secondary' is not included in the dynamic resolving since it is statically defined.
    Partition 'nvs_storage' is not included in the dynamic resolving since it is statically defined.

  • I need to ask my colleague to help me with this. Please wait until I get some more insights from him.

Reply Children
No Data
Related