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
  • Can you please verify that his configurations are actually set by checking the build/mcuboot/zephyr/include/generated/autoconf.h or by running "menuconfig" inside build/mcuboot.

    My colleague says he had some issues with paths inside CMakeLists.txt. Can you do "message(mcuboot_OVERLAY_CONFIG)" after setting it, to double check inside CMakeList.txt also.

    See this for how to escape the paths:
    set(mcuboot_CONFIG_BOOT_SIGNATURE_KEY_FILE \\"${CMAKE_CURRENT_SOURCE_DIR}/custom_key_dir/custom_priv.pem\\")
  • I will try to check by printing the mcuboot_OVERLAY_CONFIG variable in cmake after setting it.  The way I know that specifcally the config CONFIG_PARTITION_MANAGER_ENABLED  and CONFIG_FLASH_MAP_CUSTOM are different is because I compared the .config and autonf.h files of the childimage (mcuboot) with winmerge. 

    About escaping characters I will have a look about this, because I am also using a private key and know about this issue. Actually I had to escape characters three times  when I was using a private key Sweat smile, anyhow that is not my problem but will see if escaping characters as well for the MCUBoot overlay config solves this.

    set(mcuboot_CONFIG_BOOT_SIGNATURE_KEY_FILE \\\"${CMAKE_CURRENT_LIST_DIR}/keys/mcuboot_sign.pem\\\")

Reply
  • I will try to check by printing the mcuboot_OVERLAY_CONFIG variable in cmake after setting it.  The way I know that specifcally the config CONFIG_PARTITION_MANAGER_ENABLED  and CONFIG_FLASH_MAP_CUSTOM are different is because I compared the .config and autonf.h files of the childimage (mcuboot) with winmerge. 

    About escaping characters I will have a look about this, because I am also using a private key and know about this issue. Actually I had to escape characters three times  when I was using a private key Sweat smile, anyhow that is not my problem but will see if escaping characters as well for the MCUBoot overlay config solves this.

    set(mcuboot_CONFIG_BOOT_SIGNATURE_KEY_FILE \\\"${CMAKE_CURRENT_LIST_DIR}/keys/mcuboot_sign.pem\\\")

Children
No Data
Related