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. 

Parents Reply Children
  • Thanks for the update. Please note I am using the sample project as-is with no modifications to prj.conf or any other. I did find the image files you mentioned, however the documentation page you referenced says the DFU will only support *.bin files. In my testing I discovered the correct file to use when burning the application image to flash was app_signed.hex

    west flash --bin-file build/zephyr/app_signed.hex

    This conflicts with the zephyr documentation which says:

    west flash --bin-file build/zephyr/zephyr.signed.bin

    In any case the app is now running on the board and I can get the echo command to work:

    (base) ?1 v2.1.0 % ~/go/bin/mcumgr --conntype ble --connstring peer_name='Zephyr' echo hello 
    
    hello

    The next step in the tutorial is to upload the signed image using mcumgr. The command fails on my system (see error below) but this problem seems unrelated to the instructions in the tutorial so I will log a separate ticket for that issue.

    Note that I did play around with imgtool but could not get it to work on my system. Hopefully this will not be a problem as long as the build system creates the signed image files automatically. Here is the error:

    (base) √ v2.1.0 % west sign -t imgtool -- --key bootloader/mcuboot/root-rsa-2048.pem --header-size 32 --pad-header
    === 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/build/zephyr/zephyr.bin
    signed bin:   /opt/nordic/ncs/v2.1.0/build/zephyr/zephyr.signed.bin
    Usage: imgtool sign [OPTIONS] INFILE OUTFILE
    Error: Image size (0x33ac0) + trailer (0x630) exceeds requested size 0x32000
    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 bootloader/mcuboot/root-rsa-2048.pem --header-size 32 --pad-header /opt/nordic/ncs/v2.1.0/build/zephyr/zephyr.bin /opt/nordic/ncs/v2.1.0/build/zephyr/zephyr.signed.bin

  • Hi,

    Yes, in the case of signing images, the Zephyr documentation will conflict with the nRF Connect SDK documentation, as NCS is set up to sign images automatically.

    If you want some examples of bootloader use in NCS, you might be interested in my colleague's Github repo, with "minimal" samples and detailed readmes: samples_for_nrf_connect_sdk/bootloader_samples/

    Thanks for filing a separate ticket for your new issue. Is the fatal error you shared related to that new issue, or something you wanted me to troubleshoot?

    Best regards,

    Raoul Pathak

  • The fatal error comes from imgtool. Most likely I will not need to use this tool because the build system already creates the signed image as you pointed out. You can close this out. 

Related