MCUBOOT Sign the firmware

Hello Everyone,

First of all, what a terrible experience this has been. I'm trying to use custom RSA private key in order to sign the firmware before we go into production. However whatever I do, I can't get rid of this warning:

---------------------------------------------------------
--- WARNING: Using default MCUBoot key, it should not ---
--- be used for production.                           ---
---------------------------------------------------------

Let me say that I've gone through all of devzone forum, all of the documentation I could find, and nothing seems to work. So I think the only thing that can work for me is to give me a step by step guide on how to use a custom key to sign one of your samples, and I'll adjust it for our product. I've been stuck on this for hours, and it seems like config is completely broken.

We are using ncs v1.9.1.


What I'd like to do is to get it all done in the config (probably mcuboot.conf which I've linked in the CMakeLists.txt). Something like this seems to be working on your end:

CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=n
CONFIG_BOOT_SIGNATURE_TYPE_RSA=y
CONFIG_BOOT_SIGNATURE_KEY_FILE="custom_key_rsa-2048.pem"

But the build system just keeps telling me how this is wrong, how the key file variable is ignored and how it will keep on using the default keys. 


Does this really work at all for NCS? It should be trivial to sign the firmware with a custom key, but somehow I've wasted quite a bit of time on it by now.

Cheers,
Aleksa

Parents Reply Children
  • Why is it necessary to double escape (\\") the quotation marks in the sample code you provided?

    I believe this is the same issue as https://github.com/nrfconnect/sdk-nrf/pull/7997

    i.e. the NCS cmake scripts cache the value of this variable but they're storing that value without properly escaping the quotes.

    Hoping it gets fixed in v2.1.0.

    (Also I suspect that backslashes might suffer from a similar issue, but I'll leave it to the Windows users to test that.)

    Per that link above it seems necessary to set both CONFIG_MCUBOOT_SIGNATURE_KEY_FILE and CONFIG_BOOT_SIGNATURE_KEY_FILE. Is that correct, or is it sufficient to set only CONFIG_BOOT_SIGNATURE_KEY_FILE?

    I'm just a random user so maybe I'm doing things all wrong, but after applying the change from the above PR on github, this is what has worked for me:

    OTA_ARGS = \
     -DOVERLAY_CONFIG=overlay-fota.conf \
     -DPM_STATIC_YML_FILE=pm_ota.yml \
     -D"mcuboot_CONFIG_BOOT_SIGNATURE_KEY_FILE=\"$(ZIGBEE_SIGNING_KEY)\"" \
     -D"CONFIG_MCUBOOT_IMAGE_VERSION=\"$(shell ./scripts/unix-time-to-version.sh)\"" \
     -D"CONFIG_DATE_CODE=\"$(shell date +%Y%m%d-%H%M)\""

    .PHONY: ota
    ota:
     $(if $(ZIGBEE_SIGNING_KEY),,$(error Please set $$ZIGBEE_SIGNING_KEY))
     $(WEST_BUILD) --board raw_dongle -- $(OTA_ARGS)

    There are no CONFIG_MCUBOOT options in prj.conf or overlay-fota.conf

Related