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

NCS recommended MCUboot enabled apps build and flash methods

I am testing smp_srv (bluetooth) with NCS 1.3.2.
I don't know how to build and flash related apps for MCU boot in NCS.
MCUboot is unable to boot smp_srv even after running as documented.
All sample code related to MCUboot will fail to start the application.

1. Is this smp_srv build correct in NCS? Or what is the recommended build method?
2. How do you do the flash method related to MCU boot recommended by NCS?
I don't use west sign -t imgtool because it doesn't seem to be recommended by NCS.
I'm flashing merged.hex with west flash.


[challenged command]
cd ~/ncs/v1.3.2/zephyr/samples/subsys/mgmt/mcumgr/smp_svr
west build -b nrf52dk_nrf52832 -d build_nrf52dk_nrf52832 . -- -DOVERLAY_CONFIG=overlay-bt.conf
west flash -d build_nrf52dk_nrf52832


nRF Connect SDK 1.3.2
Ubuntu 20.04.1 LTS

SEGGER J-Link V6.86e - Real time terminal output
J-Link OB-SAM3U128-V2-NordicSemi compiled Mar 17 2020 14:43:00 V1.0, SN=682102400
Process: JLinkExe
[00:00:00.003,753] <inf> mcuboot: Starting bootloader
[00:00:00.010,467] <inf> mcuboot: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
[00:00:00.021,667] <inf> mcuboot: Boot source: none
[00:00:00.027,770] <inf> mcuboot: Swap type: none
[00:00:00.244,415] <err> mcuboot: Image in the primary slot is not valid!
[00:00:00.252,838] <err> mcuboot: Unable to find bootable image

  • Thanks for the pointers.

    I am on v1.5.1 and ended up with another method of setting a custom key that I though is worth sharing. Not sure if v1.6 changes anything. At least I found not relevant info in the release notes.

    This processes of setting up a custom mcuboot signing key is definitely not polished enough. Took a while to solve. I hope Nordic can improve on that.

    A good implementation for this in the build system will allow to set a relative path to a file. Then it should take effect in the app and in the mcuboot build processes. It should support the file being located in the app folder or in some other out-of-tree folder.

    All of the other solutions I have seen are based on putting the file in mcuboot project folder. That code is shared by several projects, so doesn't seem to be a proper solution.

    Also, most of the solutions will not accept a relative file path...

    The way I found that addresses these issues is adding the following line in CMakeLists.txt:

    set(mcuboot_CONFIG_BOOT_SIGNATURE_KEY_FILE "\"${CMAKE_CURRENT_LIST_DIR}/mcuboot_key_dev.pem\"")

    This works. Makes a different autogen-pubkey.c file and signs the bin file correctly. Make sure you verify with "imgtool.py verify".

    Specifying this line in cmake allows for variables to be used. This way I can convert a relative path to an absolute one that mcuboot script expects.

    The quotes make sure the values goes correctly to "build_*\mcuboot\zephyr\misc\generated\extra_kconfig_options.conf" file. Otherwise it doesn't build.

Related