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

  • Hello!

    Good to hear that you have progress. As for your questions:

    - Which file are you trying to upload? When building using NCS an image called app_signed.bin app_update.bin is created and signed automatically. You should use this. The file is located in <project_folder>/<build_folder>/zephyr/. 

    - MCUBoot is not setup with mcumgr out of the box, you will have to enable it. Though be aware that the img_mgmt features most likely won't work for the MCUBoot image, as they rely on MCUBoot themselves.

    Best regards,
    Carl Richard

  • 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 again!

    You do not need MCUBoot with mcumgr. As explained in the Zephyr DFU documentation MCUBoot should be flashed initially, and then the application image can be upgraded using mcumgr. It's the DFU subsystem in the that interacts with MCUBoot, not mcumgr directly. 

    Are you using Zephyr standalone or the nRF Connect SDK? Below is some of the images that should be present in the zephyr folder after building with NCS:

    app_signed.hex
    app_test_update.hex
    app_to_sign.bin
    app_update.bin

    I'm not sure if Zephyr standalone does this signing process. If not you must sign the image as described in the SMP Server documentation. Make sure that you build with serial support as well: 
    west build -b nrf52dk_nrf52832 -p -- -DOVERLAY_CONFIG='overlay-serial.conf;'

    Best regards,
    Carl Richard

  • I'm working with the nRF Connect SDK. The path in my previous reply was relative. My fault... i'm building the software over command line like follows:

    smp_svr:

    west build -b nrf52dk_nrf52832 -s app --pristine -d build\app -- -DOVERLAY_CONFIG='overlay-serial.conf;overlay-fs.conf'
    mcuboot:
    west build -b nrf52dk_nrf52832 -s ..\ncs\bootloader\mcuboot\boot\zephyr\ --pristine -d build\bootloader
    The smp_svr project was copied to <project-name>/<app>
    Kind regards,
    Michael
  • Hi, Michael!

    I understand. With NCS the bootloader is built automatically and added in the build folder, so there should not be any need to build it separately. Could you have a look at the contents in your build/app folder? It should contain something like this:

    d-----        09.03.2021     14:19                app
    d-----        09.03.2021     14:19                CMakeFiles
    d-----        09.03.2021     14:19                Kconfig
    d-----        09.03.2021     14:19                mcuboot
    d-----        09.03.2021     14:19                modules
    d-----        09.03.2021     14:19                zephyr
    -a----        09.03.2021     14:19         103504 .ninja_deps
    -a----        09.03.2021     14:19          24897 .ninja_log
    -a----        09.03.2021     14:19         925615 build.ninja
    -a----        09.03.2021     14:19          21613 CMakeCache.txt
    -a----        09.03.2021     14:19           1839 cmake_install.cmake
    -a----        09.03.2021     10:37          17920 libapp.a
    -a----        09.03.2021     14:19           1221 partitions.yml
    -a----        09.03.2021     14:19           2136 pm.config
    -a----        09.03.2021     14:19            327 regions.yml
    -a----        09.03.2021     14:19           1877 zephyr_modules.txt
    -a----        09.03.2021     14:19             84 zephyr_settings.txt


    Best regards,
    Carl Richard

Related