mcuboot test image became active confirm without external confirm from mcumgr

I am testing with NCS 2.3.0,  nrf5340dk, on an application based on smp_svr sample.

I was testing with mcumgr  and found an unexpected behavior.  Maybe its a feature I have unwittingly enabled. 

I added the configuration from nrf/tests/modules/mcuboot/external_flash to my smp_server sample based application. 

I used mcumgr image upload to send the file

I did mcumgr image test <hash>  to prepare the test. 

I triggered a reset (reset button) and on my next call to image list, only 1 image was found and it was active confirmed state.  I thought this would only be allowed if I used mcumgr to confirm the image.

Did I unknowingly disable the image swap feature from mcuboot when I copied the externa_flash test?

Is this somehow part of the serial recovery settings in the externa_flash test?

Parents
  • Hi,

    First a note: The test you use have been updated in v2.4.0, I suggest looking at the changes to child image configuration, which makes it configure the MCUboot child image properly.

    Then to your question:

    Serial Recovery will overwrite the primary slot, and by default not interact with the secondary slot.
    So what you explain is expected.

    I have written a little intro to MCUboot + samples at https://github.com/hellesvik-nordic/samples_for_nrf_connect_sdk/tree/main/bootloader_samples. (not official)

    Give it a read, and let me know if you got any questions.

    Regards,
    Sigurd Hellesvik

  • I suspect the issue is caused by the CONFIG_BOOT_UPGRADE_ONLY=y option in child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf 

    Perhaps 

    I just tried disabling that option, however I started getting a errors with the partition manager addresses:

    [156/198] Building C object modules/nrf/modules/mcuboot/hooks/CMakeFiles/..__nrf__modules__mcuboot__hooks.dir/nrf53_hooks.c.obj
    FAILED: modules/nrf/modules/mcuboot/hooks/CMakeFiles/..__nrf__modules__mcuboot__hooks.dir/nrf53_hooks.c.obj
    D:\Bmmpr\toolchains\v2.3.0\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DEXT_API_MAGIC=0x281ee6de,0xb845acea,13570 -DFIRMWARE_INFO_MAGIC=0x281ee6de,0x8fcebb4c,13570 -DKERNEL -DNRF5340_XXAA_APPLICATION -DNRF_SKIP_FICR_NS_COPY_TO_RAM -DUSE_PARTITION_MANAGER=1 -D__PROGRAM_START -D__ZEPHYR__=1 -ID:/Bmmpr/v2.3.0/zephyr/include -Izephyr/include/generated -ID:/Bmmpr/v2.3.0/zephyr/soc/arm/nordic_nrf/nrf53 -ID:/Bmmpr/v2.3.0/zephyr/soc/arm/nordic_nrf/common/. -ID:/Bmmpr/v2.3.0/nrf/include -ID:/Bmmpr/v2.3.0/nrf/tests/include -ID:/Bmmpr/v2.3.0/modules/hal/cmsis/CMSIS/Core/Include -ID:/Bmmpr/v2.3.0/modules/hal/nordic/nrfx -ID:/Bmmpr/v2.3.0/modules/hal/nordic/nrfx/drivers/include -ID:/Bmmpr/v2.3.0/modules/hal/nordic/nrfx/mdk -ID:/Bmmpr/v2.3.0/zephyr/modules/hal_nordic/nrfx/. -ID:/Bmmpr/v2.3.0/bootloader/mcuboot/ext/tinycrypt/lib/include -ID:/Bmmpr/v2.3.0/bootloader/mcuboot/boot/bootutil/zephyr/.. -ID:/Bmmpr/v2.3.0/bootloader/mcuboot/boot/bootutil/zephyr/../include -ID:/Bmmpr/v2.3.0/bootloader/mcuboot/boot/bootutil/zephyr/../../zephyr/include -ID:/Bmmpr/v2.3.0/bootloader/mcuboot/boot/bootutil/zephyr/../../../ext/tinycrypt/lib/include -isystem D:/Bmmpr/v2.3.0/zephyr/lib/libc/minimal/include -isystem d:/bmmpr/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/include -isystem d:/bmmpr/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/include-fixed -isystem D:/Bmmpr/v2.3.0/nrfxlib/crypto/nrf_cc312_platform/include -fno-strict-aliasing -Os -imacros D:/Bmmpr/provisioning/provisioning_image/smp_svr/build/mcuboot/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=D:/Bmmpr/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros D:/Bmmpr/v2.3.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=D:/Bmmpr/v2.3.0/bootloader/mcuboot/boot/zephyr=CMAKE_SOURCE_DIR -fmacro-prefix-map=D:/Bmmpr/v2.3.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=D:/Bmmpr/v2.3.0=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT modules/nrf/modules/mcuboot/hooks/CMakeFiles/..__nrf__modules__mcuboot__hooks.dir/nrf53_hooks.c.obj -MF modules\nrf\modules\mcuboot\hooks\CMakeFiles\..__nrf__modules__mcuboot__hooks.dir\nrf53_hooks.c.obj.d -o modules/nrf/modules/mcuboot/hooks/CMakeFiles/..__nrf__modules__mcuboot__hooks.dir/nrf53_hooks.c.obj -c D:/Bmmpr/v2.3.0/nrf/modules/mcuboot/hooks/nrf53_hooks.c
    D:/Bmmpr/v2.3.0/nrf/modules/mcuboot/hooks/nrf53_hooks.c: In function 'boot_read_image_header_hook':
    D:\Bmmpr\v2.3.0\nrf\modules\mcuboot\hooks\nrf53_hooks.c:28:42: error: 'PM_MCUBOOT_PRIMARY_1_ADDRESS' undeclared (first use in this function); did you mean 'PM_MCUBOOT_PRIMARY_ADDRESS'?
    28 | img_head->ih_load_addr = PM_MCUBOOT_PRIMARY_1_ADDRESS;
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | PM_MCUBOOT_PRIMARY_ADDRESS
    D:\Bmmpr\v2.3.0\nrf\modules\mcuboot\hooks\nrf53_hooks.c:28:42: note: each undeclared identifier is reported only once for each function it appears in
    In file included from D:\Bmmpr\v2.3.0\zephyr\include\zephyr\toolchain\gcc.h:89,
    from D:\Bmmpr\v2.3.0\zephyr\include\zephyr\toolchain.h:50,
    from D:\Bmmpr\v2.3.0\zephyr\include\zephyr\sys\__assert.h:11,
    from D:\Bmmpr\v2.3.0\zephyr\lib\libc\minimal\include\assert.h:11,
    from D:\Bmmpr\v2.3.0\nrf\modules\mcuboot\hooks\nrf53_hooks.c:7:
    D:/Bmmpr/v2.3.0/nrf/modules/mcuboot/hooks/nrf53_hooks.c: In function 'network_core_update':
    D:\Bmmpr\v2.3.0\zephyr\include\zephyr\device.h:83:41: error: '__device_dts_ord_DT_N_NODELABEL_PM_MCUBOOT_PRIMARY_1_DEV_ORD' undeclared (first use in this function)
    83 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
    | ^~~~~~~~~
    D:\Bmmpr\v2.3.0\zephyr\include\zephyr\device.h:209:37: note: in expansion of macro 'DEVICE_NAME_GET'
    209 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_ID(node_id))
    | ^~~~~~~~~~~~~~~
    D:\Bmmpr\v2.3.0\zephyr\include\zephyr\device.h:226:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
    226 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
    | ^~~~~~~~~~~~~~~~~~
    D:\Bmmpr\v2.3.0\nrf\modules\mcuboot\hooks\nrf53_hooks.c:85:26: note: in expansion of macro 'DEVICE_DT_GET'
    85 | mock_flash_dev = DEVICE_DT_GET(DT_NODELABEL(PM_MCUBOOT_PRIMARY_1_DEV));
    | ^~~~~~~~~~~~~
    [157/198] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/D_/Bmmpr/v2.3.0/modules/hal/nordic/nrfx/helpers/nrfx_flag32_allocator.c.obj
    [158/198] Building C object modules/mcuboot/boot/bootutil/zephyr/CMakeFiles/mcuboot_util.dir/D_/Bmmpr/v2.3.0/bootloader/mcuboot/boot/bootutil/src/bootutil_public.c.obj
    [159/198] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/D_/Bmmpr/v2.3.0/modules/hal/nordic/nrfx/drivers/src/nrfx_dppi.c.obj
    [160/198] Linking C static library zephyr\drivers\pinctrl\libdrivers__pinctrl.a
    [161/198] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/D_/Bmmpr/v2.3.0/modules/hal/nordic/nrfx/mdk/system_nrf5340_application.c.obj
    [162/198] Linking C static library modules\nrf\lib\fatal_error\lib..__nrf__lib__fatal_error.a
    [163/198] Linking C static library modules\nrf\subsys\fw_info\lib..__nrf__subsys__fw_info.a
    [164/198] Linking C static library modules\nrf\subsys\pcd\lib..__nrf__subsys__pcd.a
    [165/198] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/D_/Bmmpr/v2.3.0/modules/hal/nordic/nrfx/drivers/src/nrfx_clock.c.obj
    ninja: build stopped: subcommand failed.
    [429/447] Generating zephyr/b0_container.hex
    FAILED: modules/mcuboot/mcuboot_subimage-prefix/src/mcuboot_subimage-stamp/mcuboot_subimage-build mcuboot/zephyr/zephyr.hex mcuboot/zephyr/zephyr.elf
    cmd.exe /C "cd /D D:\Bmmpr\provisioning\provisioning_image\smp_svr\build\mcuboot && D:\Bmmpr\toolchains\v2.3.0\opt\bin\cmake.exe --build . --"
    [431/447] Linking C executable zephyr\zephyr.elf

Reply
  • I suspect the issue is caused by the CONFIG_BOOT_UPGRADE_ONLY=y option in child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf 

    Perhaps 

    I just tried disabling that option, however I started getting a errors with the partition manager addresses:

    [156/198] Building C object modules/nrf/modules/mcuboot/hooks/CMakeFiles/..__nrf__modules__mcuboot__hooks.dir/nrf53_hooks.c.obj
    FAILED: modules/nrf/modules/mcuboot/hooks/CMakeFiles/..__nrf__modules__mcuboot__hooks.dir/nrf53_hooks.c.obj
    D:\Bmmpr\toolchains\v2.3.0\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DEXT_API_MAGIC=0x281ee6de,0xb845acea,13570 -DFIRMWARE_INFO_MAGIC=0x281ee6de,0x8fcebb4c,13570 -DKERNEL -DNRF5340_XXAA_APPLICATION -DNRF_SKIP_FICR_NS_COPY_TO_RAM -DUSE_PARTITION_MANAGER=1 -D__PROGRAM_START -D__ZEPHYR__=1 -ID:/Bmmpr/v2.3.0/zephyr/include -Izephyr/include/generated -ID:/Bmmpr/v2.3.0/zephyr/soc/arm/nordic_nrf/nrf53 -ID:/Bmmpr/v2.3.0/zephyr/soc/arm/nordic_nrf/common/. -ID:/Bmmpr/v2.3.0/nrf/include -ID:/Bmmpr/v2.3.0/nrf/tests/include -ID:/Bmmpr/v2.3.0/modules/hal/cmsis/CMSIS/Core/Include -ID:/Bmmpr/v2.3.0/modules/hal/nordic/nrfx -ID:/Bmmpr/v2.3.0/modules/hal/nordic/nrfx/drivers/include -ID:/Bmmpr/v2.3.0/modules/hal/nordic/nrfx/mdk -ID:/Bmmpr/v2.3.0/zephyr/modules/hal_nordic/nrfx/. -ID:/Bmmpr/v2.3.0/bootloader/mcuboot/ext/tinycrypt/lib/include -ID:/Bmmpr/v2.3.0/bootloader/mcuboot/boot/bootutil/zephyr/.. -ID:/Bmmpr/v2.3.0/bootloader/mcuboot/boot/bootutil/zephyr/../include -ID:/Bmmpr/v2.3.0/bootloader/mcuboot/boot/bootutil/zephyr/../../zephyr/include -ID:/Bmmpr/v2.3.0/bootloader/mcuboot/boot/bootutil/zephyr/../../../ext/tinycrypt/lib/include -isystem D:/Bmmpr/v2.3.0/zephyr/lib/libc/minimal/include -isystem d:/bmmpr/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/include -isystem d:/bmmpr/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/include-fixed -isystem D:/Bmmpr/v2.3.0/nrfxlib/crypto/nrf_cc312_platform/include -fno-strict-aliasing -Os -imacros D:/Bmmpr/provisioning/provisioning_image/smp_svr/build/mcuboot/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=D:/Bmmpr/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros D:/Bmmpr/v2.3.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=D:/Bmmpr/v2.3.0/bootloader/mcuboot/boot/zephyr=CMAKE_SOURCE_DIR -fmacro-prefix-map=D:/Bmmpr/v2.3.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=D:/Bmmpr/v2.3.0=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT modules/nrf/modules/mcuboot/hooks/CMakeFiles/..__nrf__modules__mcuboot__hooks.dir/nrf53_hooks.c.obj -MF modules\nrf\modules\mcuboot\hooks\CMakeFiles\..__nrf__modules__mcuboot__hooks.dir\nrf53_hooks.c.obj.d -o modules/nrf/modules/mcuboot/hooks/CMakeFiles/..__nrf__modules__mcuboot__hooks.dir/nrf53_hooks.c.obj -c D:/Bmmpr/v2.3.0/nrf/modules/mcuboot/hooks/nrf53_hooks.c
    D:/Bmmpr/v2.3.0/nrf/modules/mcuboot/hooks/nrf53_hooks.c: In function 'boot_read_image_header_hook':
    D:\Bmmpr\v2.3.0\nrf\modules\mcuboot\hooks\nrf53_hooks.c:28:42: error: 'PM_MCUBOOT_PRIMARY_1_ADDRESS' undeclared (first use in this function); did you mean 'PM_MCUBOOT_PRIMARY_ADDRESS'?
    28 | img_head->ih_load_addr = PM_MCUBOOT_PRIMARY_1_ADDRESS;
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | PM_MCUBOOT_PRIMARY_ADDRESS
    D:\Bmmpr\v2.3.0\nrf\modules\mcuboot\hooks\nrf53_hooks.c:28:42: note: each undeclared identifier is reported only once for each function it appears in
    In file included from D:\Bmmpr\v2.3.0\zephyr\include\zephyr\toolchain\gcc.h:89,
    from D:\Bmmpr\v2.3.0\zephyr\include\zephyr\toolchain.h:50,
    from D:\Bmmpr\v2.3.0\zephyr\include\zephyr\sys\__assert.h:11,
    from D:\Bmmpr\v2.3.0\zephyr\lib\libc\minimal\include\assert.h:11,
    from D:\Bmmpr\v2.3.0\nrf\modules\mcuboot\hooks\nrf53_hooks.c:7:
    D:/Bmmpr/v2.3.0/nrf/modules/mcuboot/hooks/nrf53_hooks.c: In function 'network_core_update':
    D:\Bmmpr\v2.3.0\zephyr\include\zephyr\device.h:83:41: error: '__device_dts_ord_DT_N_NODELABEL_PM_MCUBOOT_PRIMARY_1_DEV_ORD' undeclared (first use in this function)
    83 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
    | ^~~~~~~~~
    D:\Bmmpr\v2.3.0\zephyr\include\zephyr\device.h:209:37: note: in expansion of macro 'DEVICE_NAME_GET'
    209 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_ID(node_id))
    | ^~~~~~~~~~~~~~~
    D:\Bmmpr\v2.3.0\zephyr\include\zephyr\device.h:226:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
    226 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
    | ^~~~~~~~~~~~~~~~~~
    D:\Bmmpr\v2.3.0\nrf\modules\mcuboot\hooks\nrf53_hooks.c:85:26: note: in expansion of macro 'DEVICE_DT_GET'
    85 | mock_flash_dev = DEVICE_DT_GET(DT_NODELABEL(PM_MCUBOOT_PRIMARY_1_DEV));
    | ^~~~~~~~~~~~~
    [157/198] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/D_/Bmmpr/v2.3.0/modules/hal/nordic/nrfx/helpers/nrfx_flag32_allocator.c.obj
    [158/198] Building C object modules/mcuboot/boot/bootutil/zephyr/CMakeFiles/mcuboot_util.dir/D_/Bmmpr/v2.3.0/bootloader/mcuboot/boot/bootutil/src/bootutil_public.c.obj
    [159/198] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/D_/Bmmpr/v2.3.0/modules/hal/nordic/nrfx/drivers/src/nrfx_dppi.c.obj
    [160/198] Linking C static library zephyr\drivers\pinctrl\libdrivers__pinctrl.a
    [161/198] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/D_/Bmmpr/v2.3.0/modules/hal/nordic/nrfx/mdk/system_nrf5340_application.c.obj
    [162/198] Linking C static library modules\nrf\lib\fatal_error\lib..__nrf__lib__fatal_error.a
    [163/198] Linking C static library modules\nrf\subsys\fw_info\lib..__nrf__subsys__fw_info.a
    [164/198] Linking C static library modules\nrf\subsys\pcd\lib..__nrf__subsys__pcd.a
    [165/198] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/D_/Bmmpr/v2.3.0/modules/hal/nordic/nrfx/drivers/src/nrfx_clock.c.obj
    ninja: build stopped: subcommand failed.
    [429/447] Generating zephyr/b0_container.hex
    FAILED: modules/mcuboot/mcuboot_subimage-prefix/src/mcuboot_subimage-stamp/mcuboot_subimage-build mcuboot/zephyr/zephyr.hex mcuboot/zephyr/zephyr.elf
    cmd.exe /C "cd /D D:\Bmmpr\provisioning\provisioning_image\smp_svr\build\mcuboot && D:\Bmmpr\toolchains\v2.3.0\opt\bin\cmake.exe --build . --"
    [431/447] Linking C executable zephyr\zephyr.elf

Children
Related