This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Zephyr with MCUboot and Simple Management Protocol (SMP)

Dear community,

i'm working on an application for the nRF52832. I would like to use MCUboot as Bootloader and Zephyr for the main application. The current situation is that i'm using the west tool for buildung and flashing the software. Not sure if it's my fault but the west tool has issues with debugging (that's what im doing with Segger Studio for NRF now). Mainly im working with the examples from ncs (Zephyr + NRF) and with the contributions of the devzone community to figure how things are working - many thanks!

But i'm stuck now: 

  • When i'm uploading the application (currently it is the smp_svr app) and the bootloader the microcontroller can be reset by mcumgr and the 'echo' command works also fine. The upload does not work. Does the application needs to be signed?
  • When i'm uploading only the bootloader it's not possible to communicate with mcumgr. Do i need to setup the smp features for the MCUboot, too?

In both cases i'm using the serial line.

Many thanks in advance!

Kind regards,

Michael

Parents
  • Hello Carl,

    thanks for your reply. Do i need MCUBoot with mcumgr? What's the common way to use MCUBoot with Zephyr?

    I have built the smp_svr (zephyr\samples\subsys\mgmt\mcumgr\smp_svr) example within the ncs folder and after building there weren't no signed files in the <project_folder>/<build_folder>/zephyr/.

    # Enable mcumgr.
    CONFIG_MCUMGR=y
    
    # Some command handlers require a large stack.
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    # Ensure an MCUboot-compatible binary is generated.
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_ROM_START_OFFSET=0xc000 <-- That's the only flag i add, because imgtool was complaining about the offset
    
    # Enable flash operations.
    CONFIG_FLASH=y
    
    # Required by the `taskstat` command.
    CONFIG_THREAD_MONITOR=y
    
    # Enable statistics and statistic names.
    CONFIG_STATS=y
    CONFIG_STATS_NAMES=y
    
    # Enable most core commands.
    CONFIG_MCUMGR_CMD_IMG_MGMT=y
    CONFIG_MCUMGR_CMD_OS_MGMT=y
    CONFIG_MCUMGR_CMD_STAT_MGMT=y
    
    # Enable logging
    CONFIG_LOG=y
    CONFIG_MCUBOOT_UTIL_LOG_LEVEL_WRN=y

    The smp_svr software was built with the command  west build -b nrf52dk_nrf52832. The MCUboot was built with the same command without any changes in the prj.conf.

    Kind regards,

    Michael

  • Hi Carl,

    many thanks for your help. After following some How-To's i have messed up my NRF Connect SDK folder - cleaning everything up was the solution. Your proposed solution works with NRF Connect SDK v1.4.0 and NRF Connect SDK v1.5.0. The smg_svr example works fine.

    The prj.conf is set up as necessary for mcumgr:

    # Enable mcumgr.
    CONFIG_MCUMGR=y
    
    # Some command handlers require a large stack.
    CONFIG_SYSTEM_WORKQUEUE_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
    
    # Enable statistics and statistic names.
    CONFIG_STATS=y
    CONFIG_STATS_NAMES=y
    
    # Enable most core commands.
    CONFIG_MCUMGR_CMD_IMG_MGMT=y
    CONFIG_MCUMGR_CMD_OS_MGMT=y
    CONFIG_MCUMGR_CMD_STAT_MGMT=y
    
    # Enable logging
    CONFIG_LOG=y
    

    My build command is:

    west build -b nrf52dk_nrf52832 -s . --pristine -d build\app -- -DOVERLAY_CONFIG='overlay-serial.conf;overlay-fs.conf'

    My build output <project_folder>/<build_folder>/zephyr/ looks like follows:

    -a----        11.03.2021     08:06         633702 app_moved_test_update.hex
    -a----        11.03.2021     08:06         186842 app_signed.hex
    -a----        11.03.2021     08:06         191314 app_test_update.hex
    -a----        11.03.2021     08:06          65568 app_to_sign.bin
    -a----        11.03.2021     08:06          66416 app_update.bin
    -a----        11.03.2021     08:05           5258 cmake_install.cmake
    -a----        11.03.2021     08:06          67040 dfu_application.zip

    I'm getting an echo response with the following command:

    mcumgr.exe --conntype=serial --connstring='COM6,baud=115200' echo hello

    With the following list command i'm getting the flashed images:

    mcumgr.exe --conntype=serial --connstring='COM6,baud=115200' image list
    
    # Output
    
    Images:
     image=0 slot=0
        version: 0.0.0
        bootable: true
        flags: active confirmed
        hash: 22870947a1db8e9d0ead516a71868b01d04ad6d25823373d327ad6dc5099579c
     image=0 slot=1
        version: 0.0.0
        bootable: true
        flags:
        hash: ec5c943d376968638609abfa20737644e1e6f10ea8a2fc50fa83efa14ffc3c45
    Split status: N/A (0)

    The updating works with the following command:

     mcumgr.exe --conntype=serial --connstring='COM6,baud=115200' image upload .\build\app\zephyr\app_update.bin
     
     # Output
     
      mcumgr.exe --conntype=serial --connstring='COM6,baud=115200' image upload .\build\app\zephyr\app_update.bin
     22.20 KiB / 61.84 KiB [========================>-------------------------------------------]  35.90% 2.10 KiB/s 00m18s

    Kind regards,

    Michael

Reply
  • Hi Carl,

    many thanks for your help. After following some How-To's i have messed up my NRF Connect SDK folder - cleaning everything up was the solution. Your proposed solution works with NRF Connect SDK v1.4.0 and NRF Connect SDK v1.5.0. The smg_svr example works fine.

    The prj.conf is set up as necessary for mcumgr:

    # Enable mcumgr.
    CONFIG_MCUMGR=y
    
    # Some command handlers require a large stack.
    CONFIG_SYSTEM_WORKQUEUE_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
    
    # Enable statistics and statistic names.
    CONFIG_STATS=y
    CONFIG_STATS_NAMES=y
    
    # Enable most core commands.
    CONFIG_MCUMGR_CMD_IMG_MGMT=y
    CONFIG_MCUMGR_CMD_OS_MGMT=y
    CONFIG_MCUMGR_CMD_STAT_MGMT=y
    
    # Enable logging
    CONFIG_LOG=y
    

    My build command is:

    west build -b nrf52dk_nrf52832 -s . --pristine -d build\app -- -DOVERLAY_CONFIG='overlay-serial.conf;overlay-fs.conf'

    My build output <project_folder>/<build_folder>/zephyr/ looks like follows:

    -a----        11.03.2021     08:06         633702 app_moved_test_update.hex
    -a----        11.03.2021     08:06         186842 app_signed.hex
    -a----        11.03.2021     08:06         191314 app_test_update.hex
    -a----        11.03.2021     08:06          65568 app_to_sign.bin
    -a----        11.03.2021     08:06          66416 app_update.bin
    -a----        11.03.2021     08:05           5258 cmake_install.cmake
    -a----        11.03.2021     08:06          67040 dfu_application.zip

    I'm getting an echo response with the following command:

    mcumgr.exe --conntype=serial --connstring='COM6,baud=115200' echo hello

    With the following list command i'm getting the flashed images:

    mcumgr.exe --conntype=serial --connstring='COM6,baud=115200' image list
    
    # Output
    
    Images:
     image=0 slot=0
        version: 0.0.0
        bootable: true
        flags: active confirmed
        hash: 22870947a1db8e9d0ead516a71868b01d04ad6d25823373d327ad6dc5099579c
     image=0 slot=1
        version: 0.0.0
        bootable: true
        flags:
        hash: ec5c943d376968638609abfa20737644e1e6f10ea8a2fc50fa83efa14ffc3c45
    Split status: N/A (0)

    The updating works with the following command:

     mcumgr.exe --conntype=serial --connstring='COM6,baud=115200' image upload .\build\app\zephyr\app_update.bin
     
     # Output
     
      mcumgr.exe --conntype=serial --connstring='COM6,baud=115200' image upload .\build\app\zephyr\app_update.bin
     22.20 KiB / 61.84 KiB [========================>-------------------------------------------]  35.90% 2.10 KiB/s 00m18s

    Kind regards,

    Michael

Children
Related