Getting errors with nRF Connect sample project 'SMP Server Sample'

My environment:

nRF Connect version 2.1.0
Board: nrf52840 DK
Host: MacOS 12.6

Trying to use the Zephyr sample project called SMP Server Sample. The instructions are here:

http://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.1.0/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/README.html

The project path is here:

/opt/nordic/ncs/v2.1.0/zephyr/samples/subsys/mgmt/mcumgr/smp_svr

These steps worked without error: 

  1. Build bootloader
  2. flash bootloader
  3. Build sample application

When I try to sign the sample application I get an error.

(base) √ smp_svr % west sign -t imgtool -- --key ../../../../../../bootloader/mcuboot/root-rsa-2048.pem                                  
=== image configuration:
partition offset: 49152 (0xc000)
partition size: 421888 (0x67000)
rom start offset: 0 (0x0)
=== signing binaries
unsigned bin: /opt/nordic/ncs/v2.1.0/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/build/zephyr/zephyr.bin
signed bin:   /opt/nordic/ncs/v2.1.0/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/build/zephyr/zephyr.signed.bin
Usage: imgtool sign [OPTIONS] INFILE OUTFILE

Error: Invalid value for '-H' / '--header-size': Minimum value for -H/--header-size is 32
FATAL ERROR: command exited with status 2: /opt/nordic/ncs/toolchains/v2.1.0/bin/imgtool sign --version 0.0.0+0 --align 4 --header-size 0 --slot-size 421888 --key ../../../../../../bootloader/mcuboot/root-rsa-2048.pem /opt/nordic/ncs/v2.1.0/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/build/zephyr/zephyr.bin /opt/nordic/ncs/v2.1.0/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/build/zephyr/zephyr.signed.bin
(base) ?2 smp_svr % pwd
/opt/nordic/ncs/v2.1.0/zephyr/samples/subsys/mgmt/mcumgr/smp_svr

When I read the help for imgtool I found this:

The image header size, alignment, and slot sizes are determined from
the build directory using .config and the device tree. A default
version number of 0.0.0+0 is used (which can be overridden by passing
"--version x.y.z+w" after "--key"). As shown above, extra arguments
after a '--' are passed to imgtool directly.

Not sure how to fix the problem. 

  • Getting same error with SDK v2.0.2

    (base) √ v2.0.2 % west sign -t imgtool -d build_smp_svr -- --key bootloader/mcuboot/root-rsa-2048.pem 
    === image configuration:
    partition offset: 49152 (0xc000)
    partition size: 421888 (0x67000)
    rom start offset: 0 (0x0)
    === signing binaries
    unsigned bin: /opt/nordic/ncs/v2.0.2/build_smp_svr/zephyr/zephyr.bin
    signed bin:   /opt/nordic/ncs/v2.0.2/build_smp_svr/zephyr/zephyr.signed.bin
    Usage: imgtool sign [OPTIONS] INFILE OUTFILE
    
    Error: Invalid value for '-H' / '--header-size': Minimum value for -H/--header-size is 32
    FATAL ERROR: command exited with status 2: /opt/nordic/ncs/toolchains/v2.0.2/bin/imgtool sign --version 0.0.0+0 --align 4 --header-size 0 --slot-size 421888 --key bootloader/mcuboot/root-rsa-2048.pem /opt/nordic/ncs/v2.0.2/build_smp_svr/zephyr/zephyr.bin /opt/nordic/ncs/v2.0.2/build_smp_svr/zephyr/zephyr.signed.bin
    

  • Getting same errors on M1 and Intel. Here is output from Intel.

    smp_svr % west sign -t imgtool -- --key /opt/nordic/ncs/v2.1.0/bootloader/mcuboot/root-rsa-2048.pem
    === image configuration:
    partition offset: 49152 (0xc000)
    partition size: 204800 (0x32000)
    rom start offset: 0 (0x0)
    === signing binaries
    unsigned bin: /opt/nordic/ncs/v2.1.0/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/build/zephyr/zephyr.bin
    signed bin:   /opt/nordic/ncs/v2.1.0/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/build/zephyr/zephyr.signed.bin
    Usage: imgtool sign [OPTIONS] INFILE OUTFILE
    
    Error: Invalid value for '-H' / '--header-size': Minimum value for -H/--header-size is 32
    FATAL ERROR: command exited with status 2: /opt/nordic/ncs/toolchains/v2.1.0/bin/imgtool sign --version 0.0.0+0 --align 4 --header-size 0 --slot-size 204800 --key /opt/nordic/ncs/v2.1.0/bootloader/mcuboot/root-rsa-2048.pem /opt/nordic/ncs/v2.1.0/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/build/zephyr/zephyr.bin /opt/nordic/ncs/v2.1.0/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/build/zephyr/zephyr.signed.bin
    

  • Tool versions:

    ncs % pip3 show imgtool west       
    Name: imgtool
    Version: 1.9.0
    Summary: MCUboot's image signing and key management
    Home-page: http://github.com/mcu-tools/mcuboot
    Author: The MCUboot committers
    Author-email: [email protected]
    License: Apache Software License
    Location: /Users/mjc/opt/anaconda3/lib/python3.9/site-packages
    Requires: cryptography, intelhex, click, cbor2
    Required-by: 
    ---
    Name: west
    Version: 0.14.0
    Summary: Zephyr RTOS Project meta-tool
    Home-page: https://github.com/zephyrproject-rtos/west
    Author: Zephyr Project
    Author-email: [email protected]
    License: UNKNOWN
    Location: /Users/mjc/opt/anaconda3/lib/python3.9/site-packages
    Requires: setuptools, colorama, PyYAML, pykwalify, packaging
    Required-by: 
    

  • My issue looks very similar to this issue logged over two years ago by someone using NCS 1.3.2. It seems the errors in the sample documentation still remain. It is unclear exactly how to fix the problem with NCS 2.1.0 because so many things have changed. Please advise.

  • Hi Michael,

    Thanks for the details. I'll take a look at this and get back to you when I find out more.

    Best regards,

    Raoul

Related