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

  • Actually I have already tested with the serial recovery config options disabled, last week.  It was still overwriting and not swapping.  

    Also I should add that I did already review the differences between 2.4.0 and 2.3.0.

    Here is my child_image/mcuboot/prj.conf, you can see I have commented out the CONFIG_MCUBOOT_SERIAL and CONFIG_MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD

    # In order to provide board specific configurations to the MCUboot child image
    # we also need to provide a base configuration for MCUboot. This file contains
    # the basic configurations needed to successfully build and run MCUboot.
    CONFIG_PM=n

    # MCUboot requires a large stack size, otherwise an MPU fault will occur
    CONFIG_MAIN_STACK_SIZE=10240
    CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h"

    #since flash pages are heterogenous swap with scratch?
    CONFIG_BOOT_SWAP_USING_SCRATCH=y
    CONFIG_BOOT_PREFER_SWAP_MOVE=n

    #AA TODO switch y ?
    #CONFIG_BOOT_SWAP_SAVE_ENCTLV=n
    CONFIG_BOOT_ENCRYPT_RSA=n
    CONFIG_BOOT_ENCRYPT_EC256=n
    CONFIG_BOOT_ENCRYPT_X25519=n

    CONFIG_BOOT_UPGRADE_ONLY=n
    CONFIG_BOOT_BOOTSTRAP=n

    # Enable flash operations
    CONFIG_FLASH=y

    CONFIG_LOG=y
    CONFIG_LOG_MODE_MINIMAL=y # former CONFIG_MODE_MINIMAL
    ### Ensure Zephyr logging changes don't use more resources
    CONFIG_LOG_DEFAULT_LEVEL=0
    ### Decrease footprint by ~4 KB in comparison to CBPRINTF_COMPLETE=y
    CONFIG_CBPRINTF_NANO=y
    CONFIG_NRF_RTC_TIMER_USER_CHAN_COUNT=0
    # This can be increased to accommodate the bigger images.
    CONFIG_BOOT_MAX_IMG_SECTORS=256

    # Enable serial recovery
    # AA TODO maybe?
    #CONFIG_UART_CONSOLE=n
    #CONFIG_MCUBOOT_SERIAL=y
    #CONFIG_MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD=

    Here is my child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf

    # The following configurations are required to support simultaneous multi image update
    CONFIG_PCD_APP=y
    CONFIG_UPDATEABLE_IMAGE_NUMBER=2
    CONFIG_FLASH_SIMULATOR=y
    CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
    CONFIG_FLASH_SIMULATOR_STATS=n
    CONFIG_BOOT_UPGRADE_ONLY=y

    CONFIG_SIZE_OPTIMIZATIONS=y

    Here is my child_image/mcuboot.conf

    CONFIG_NCS_MCUBOOT_IN_BUILD=y
    CONFIG_FW_INFO_FIRMWARE_VERSION=

    # Configure QSPI for external flash
    CONFIG_FLASH=y

Reply
  • Actually I have already tested with the serial recovery config options disabled, last week.  It was still overwriting and not swapping.  

    Also I should add that I did already review the differences between 2.4.0 and 2.3.0.

    Here is my child_image/mcuboot/prj.conf, you can see I have commented out the CONFIG_MCUBOOT_SERIAL and CONFIG_MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD

    # In order to provide board specific configurations to the MCUboot child image
    # we also need to provide a base configuration for MCUboot. This file contains
    # the basic configurations needed to successfully build and run MCUboot.
    CONFIG_PM=n

    # MCUboot requires a large stack size, otherwise an MPU fault will occur
    CONFIG_MAIN_STACK_SIZE=10240
    CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h"

    #since flash pages are heterogenous swap with scratch?
    CONFIG_BOOT_SWAP_USING_SCRATCH=y
    CONFIG_BOOT_PREFER_SWAP_MOVE=n

    #AA TODO switch y ?
    #CONFIG_BOOT_SWAP_SAVE_ENCTLV=n
    CONFIG_BOOT_ENCRYPT_RSA=n
    CONFIG_BOOT_ENCRYPT_EC256=n
    CONFIG_BOOT_ENCRYPT_X25519=n

    CONFIG_BOOT_UPGRADE_ONLY=n
    CONFIG_BOOT_BOOTSTRAP=n

    # Enable flash operations
    CONFIG_FLASH=y

    CONFIG_LOG=y
    CONFIG_LOG_MODE_MINIMAL=y # former CONFIG_MODE_MINIMAL
    ### Ensure Zephyr logging changes don't use more resources
    CONFIG_LOG_DEFAULT_LEVEL=0
    ### Decrease footprint by ~4 KB in comparison to CBPRINTF_COMPLETE=y
    CONFIG_CBPRINTF_NANO=y
    CONFIG_NRF_RTC_TIMER_USER_CHAN_COUNT=0
    # This can be increased to accommodate the bigger images.
    CONFIG_BOOT_MAX_IMG_SECTORS=256

    # Enable serial recovery
    # AA TODO maybe?
    #CONFIG_UART_CONSOLE=n
    #CONFIG_MCUBOOT_SERIAL=y
    #CONFIG_MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD=

    Here is my child_image/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf

    # The following configurations are required to support simultaneous multi image update
    CONFIG_PCD_APP=y
    CONFIG_UPDATEABLE_IMAGE_NUMBER=2
    CONFIG_FLASH_SIMULATOR=y
    CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
    CONFIG_FLASH_SIMULATOR_STATS=n
    CONFIG_BOOT_UPGRADE_ONLY=y

    CONFIG_SIZE_OPTIMIZATIONS=y

    Here is my child_image/mcuboot.conf

    CONFIG_NCS_MCUBOOT_IN_BUILD=y
    CONFIG_FW_INFO_FIRMWARE_VERSION=

    # Configure QSPI for external flash
    CONFIG_FLASH=y

Children
No Data
Related