Image swap with MCUmgr does not work, after reset device end up in endless loop

Hello i have an issue that i created boot and booted the thingy53 nrf5340 with smp svr example with west. So far everything went smoothly. Then i tried to create similar build and upload signed.bin via mcumgr image upload
mcumgr --conntype serial --connstring "COM7,baud=115200" image upload C:\ncs\v2.5.2\zephyr\samples\subsys\mgmt\mcumgr\smp_svr\build_console\zephyr\zephyr.signed.bin
124.17 KiB / 124.17 KiB

then i tested the image and reset the device.

Images:
image=0 slot=0
version: 0.0.0
bootable: true
flags: active confirmed
hash: c242c2c20cb8b6fa7b82f659c9d7ca9d8700725b1b0a9102d5eccd0e415943ab
image=0 slot=1
version: 0.0.0
bootable: true
flags: pending
hash: 2ed62aac00265647c8343286dcc410a59ed8b83a5fffab103f54abedca21a5b6
Split status: N/A (0)

after that device does not communicate and after debug i discovered it got stuck in endless halt with reason 35.

If anyone have some ideas what can cause this problem i would really appreciate help

Parents
  • Hi,

    did you confirm the image? You said that you tested the image and then reset, so i suppose you did something like this:

    mcumgr -c acm0 image test <HASH>

    mcumgr -c acm0 reset

    NOTE: acm0 is the connection profile you're using, created coherently with the procedure indicated HERE in the docs.

    After this commands you should confirm the image:

    mcumgr -c acm0 image confirm <HASH>

  • Yes i did exactly that but the problem is i lost communication after reset and could not confirm the image. My serial communication runs on com 7 but after reset it does not show any device on com 7
    In debuger i end up in: 

    FUNC_NORETURN __weak void arch_system_halt(unsigned int reason)
    {
        ARG_UNUSED(reason);

        /* TODO: What's the best way to totally halt the system if SMP
         * is enabled?
         */

        (void)arch_irq_lock();
        for (;;) {
            /* Spin endlessly */
        }
    }
Reply
  • Yes i did exactly that but the problem is i lost communication after reset and could not confirm the image. My serial communication runs on com 7 but after reset it does not show any device on com 7
    In debuger i end up in: 

    FUNC_NORETURN __weak void arch_system_halt(unsigned int reason)
    {
        ARG_UNUSED(reason);

        /* TODO: What's the best way to totally halt the system if SMP
         * is enabled?
         */

        (void)arch_irq_lock();
        for (;;) {
            /* Spin endlessly */
        }
    }
Children
  • Can you share your proj.conf and mcuboot.conf configuration settings?

  • prj.conf

    # Enable MCUmgr and dependencies.
    CONFIG_NET_BUF=y
    CONFIG_ZCBOR=y
    CONFIG_CRC=y
    CONFIG_MCUMGR=y
    CONFIG_STREAM_FLASH=y
    CONFIG_FLASH_MAP=y
    
    # Some command handlers require a large stack.
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2304
    CONFIG_MAIN_STACK_SIZE=2048
    
    # Ensure an MCUboot-compatible binary is generated.
    CONFIG_BOOTLOADER_MCUBOOT=y
    
    # Enable flash operations.
    CONFIG_FLASH=y
    
    # Required by the `taskstat` command.
    CONFIG_THREAD_MONITOR=y
    
    # Support for taskstat command
    CONFIG_MCUMGR_GRP_OS_TASKSTAT=y
    
    # Enable statistics and statistic names.
    CONFIG_STATS=y
    CONFIG_STATS_NAMES=y
    
    # Enable most core commands.
    CONFIG_FLASH=y
    CONFIG_IMG_MANAGER=y
    CONFIG_MCUMGR_GRP_IMG=y
    CONFIG_MCUMGR_GRP_OS=y
    CONFIG_MCUMGR_GRP_STAT=y
    
    # Enable logging
    CONFIG_LOG=y
    CONFIG_MCUBOOT_UTIL_LOG_LEVEL_WRN=y
    
    # Disable debug logging
    CONFIG_LOG_MAX_LEVEL=3
    

    overlay-shell.conf

    # Enable the shell MCUmgr transport.
    CONFIG_BASE64=y
    CONFIG_SHELL=y
    CONFIG_SHELL_BACKEND_SERIAL=y
    CONFIG_MCUMGR_TRANSPORT_SHELL=y
    
    # mcumgr-cli application doesn't accepts log in the channel it uses
    CONFIG_SHELL_LOG_BACKEND=n
    

    custom-edit.conf

    CONFIG_USE_SEGGER_RTT=y
    #CONFIG_LOG_BACKEND_RTT=y
    CONFIG_BOOTLOADER_MCUBOOT=y
    
    
    CONFIG_LOG_MODE_DEFERRED=y
    CONFIG_LOG_RUNTIME_FILTERING=y
    CONFIG_LOG_BUFFER_SIZE=2048
    CONFIG_LOG_PRINTK=y
    CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD=0
    CONFIG_LOG_TAG_MAX_LEN=8
    CONFIG_MCUBOOT_UTIL_LOG_LEVEL_DBG=y
    # Disable debug logging
    #CONFIG_LOG_MAX_LEVEL=3
    #UART LOGGING
    CONFIG_LOG_BACKEND_UART=y
    
    CONFIG_LOG_MAX_LEVEL=4
    CONFIG_LOG_DEFAULT_LEVEL=3

  • I don't see anything evidently wrong in these settings. Moreover, imho, this part has not super clear docs to work with, but i would start from these to debug your issue

  • I resolved the issue i dug down into the problem. It was in signing the image as i used:

    # I used "--header-size 32 --pad-header" becase --> "error header size was not specified"
    # The error suggested using specified 32 size header
    
    west sign -t imgtool -- --key C:\ncs\v2.5.2\bootloader\mcuboot\root-rsa-2048.pem  --header-size 32 --pad-header

    The problem was that image generated before sign had 512 header so after adjusting command as shown

    west sign -t imgtool -- --key C:\ncs\v2.5.2\bootloader\mcuboot\root-rsa-2048.pem  --header-size 512 --pad-header

    i was able to update firmware via MCUmgr and serial communication
    also minor changes i used these config files: 

    -DEXTRA_CONF_FILE='overlay-serial.conf;overlay-fs.conf;overlay-shell-mgmt.conf'

Related