Support for separate mcuboot configurations for nrf52840 and nrf5340

nrf52840 and nrf5340

NCS 2.4.1

I have a project based on the Thread coap_client with mcubbot added, and we are migrating it from the 52840 to the 5340.  We need to maintain firmware for both board types.  I have created board files for both and can compile both.

I want to have separate mcuboot signature keys for each board, so that firmware for the nrf5340 cannot be accidentally loaded onto a nrf52840 and vice versa.

I though the way to do that was to provide a <boardname>.conf file in the child_image/mcuboot/boards directory.  There I could define 

CONFIG_BOOT_SIGNATURE_KEY_FILE differently for each build.
This works for the nrf52840 build, but not for the nrf5340.  I do have a prj.conf file in the child_image/mcuboot directory.
Build log for nrf52840 (fl_digital_io)
=== child image mcuboot -  begin ===
loading initial cache file D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/build/mcuboot/child_image_preload.cmake
Loading Zephyr default modules (Zephyr base).
-- Application: D:/NordicSemi/v2.4.1/bootloader/mcuboot/boot/zephyr
-- CMake version: 3.20.5
-- Found Python3: D:/NordicSemi/toolchains/31f4403e35/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter 
-- Cache files will be written to: D:/NordicSemi/v2.4.1/zephyr/.cache
-- Zephyr version: 3.3.99 (D:/NordicSemi/v2.4.1/zephyr)
-- Found west (found suitable version "1.0.0", minimum required is "0.7.1")
-- Board: fl_digital_io
-- Found host-tools: zephyr 0.16.0 (D:/NordicSemi/toolchains/31f4403e35/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.16.0 (D:/NordicSemi/toolchains/31f4403e35/opt/zephyr-sdk)
-- Found Dtc: D:/NordicSemi/toolchains/31f4403e35/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6") 
-- Found BOARD.dts: D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/boards/arm/fl_digital_io/fl_digital_io.dts
-- Found devicetree overlay: D:/NordicSemi/v2.4.1/bootloader/mcuboot/boot/zephyr/app.overlay
'label' is marked as deprecated in 'properties:' in D:/NordicSemi/v2.4.1/zephyr/dts/bindings\mtd\nordic,qspi-nor.yaml for node /soc/qspi@40029000/mx25r6435f@0.
-- Generated zephyr.dts: D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/build/mcuboot/zephyr/zephyr.dts
-- Generated devicetree_generated.h: D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/build/mcuboot/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/build/mcuboot/zephyr/dts.cmakeParsing D:/NordicSemi/v2.4.1/bootloader/mcuboot/boot/zephyr/Kconfig
Loaded configuration 'D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/boards/arm/fl_digital_io/fl_digital_io_defconfig'
Merged configuration 'D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/child_image/mcuboot/prj.conf'
Merged configuration 'D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/child_image/mcuboot/boards/fl_digital_io.conf'
Merged configuration 'D:/NordicSemi/v2.4.1/nrf/subsys/partition_manager/ext_flash_mcuboot_secondary.conf'
Merged configuration 'D:/NordicSemi/v2.4.1/nrf/subsys/partition_manager/partition_manager_enabled.conf'
Merged configuration 'D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/build/mcuboot/zephyr/misc/generated/extra_kconfig_options.conf'
Configuration saved to 'D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/build/mcuboot/zephyr/.config'
Kconfig header saved to 'D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/build/mcuboot/zephyr/include/generated/autoconf.h'
-- Found GnuLd: d:/nordicsemi/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe (found version "2.38") 

The above includes this line:
Merged configuration 'D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/child_image/mcuboot/boards/fl_digital_io.conf', and defines the signature key file as desired.
 
Build log for nrf5340 (fl_dio_cpuapp)
Loading Zephyr default modules (Zephyr base).
-- Application: D:/NordicSemi/v2.4.1/bootloader/mcuboot/boot/zephyr
-- CMake version: 3.20.5
-- Found Python3: D:/NordicSemi/toolchains/31f4403e35/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter 
-- Cache files will be written to: D:/NordicSemi/v2.4.1/zephyr/.cache
-- Zephyr version: 3.3.99 (D:/NordicSemi/v2.4.1/zephyr)
-- Found west (found suitable version "1.0.0", minimum required is "0.7.1")
-- Board: fl_dio_nrf5340_cpuapp
-- Found host-tools: zephyr 0.16.0 (D:/NordicSemi/toolchains/31f4403e35/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.16.0 (D:/NordicSemi/toolchains/31f4403e35/opt/zephyr-sdk)
-- Found Dtc: D:/NordicSemi/toolchains/31f4403e35/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6") 
-- Found BOARD.dts: D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/boards/arm/fl_dio_nrf5340/fl_dio_nrf5340_cpuapp.dts
-- Found devicetree overlay: D:/NordicSemi/v2.4.1/nrf/modules/mcuboot/usb.overlay
-- Found devicetree overlay: D:/NordicSemi/v2.4.1/nrf/modules/mcuboot/flash_sim.overlay
-- Generated zephyr.dts: D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/fl_dio_cpuapp/mcuboot/zephyr/zephyr.dts
-- Generated devicetree_generated.h: D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/fl_dio_cpuapp/mcuboot/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/fl_dio_cpuapp/mcuboot/zephyr/dts.cmakeParsing D:/NordicSemi/v2.4.1/bootloader/mcuboot/boot/zephyr/Kconfig
Loaded configuration 'D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/boards/arm/fl_dio_nrf5340/fl_dio_nrf5340_cpuapp_defconfig'
Merged configuration 'D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/child_image/mcuboot/prj.conf'
Merged configuration 'D:/NordicSemi/v2.4.1/nrf/subsys/pcd/pcd.conf'
Merged configuration 'D:/NordicSemi/v2.4.1/nrf/subsys/partition_manager/partition_manager_enabled.conf'
Merged configuration 'D:/NordicSemi/v2.4.1/nrf/subsys/partition_manager/ext_flash_mcuboot_secondary.conf'
Merged configuration 'D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/fl_dio_cpuapp/mcuboot/zephyr/misc/generated/extra_kconfig_options.conf'
Configuration saved to 'D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/fl_dio_cpuapp/mcuboot/zephyr/.config'
Kconfig header saved to 'D:/FloLogic/VS_Code_Projects/FloLogic_NCS_2/fl_digitalio/fl_dio_cpuapp/mcuboot/zephyr/include/generated/autoconf.h'
But this time it did not load anything from child_image/mcuboot/boards, so uses the default key file and gives a waring not to use it.
child_image/mcuboot/boarrds
nrf5340 board files
Have I named the .conf file incorrectly?
Mary
Parents Reply Children
  • Thank you. 

    I know how to generate a custom key.  I have generated two custom keys, one for each build type.

    I want each build to use it's corresponding key.

    The build for the nrf52840 does that by merging child_image/mcuboot/boards/fl_digital_io.conf into the configuration.

    There is a file for the nrf5340 board in the same location:  child_image/mcuboot/boards/fl_dio_nrf5340_cpuapp.conf, but it is not being loaded by the compiler. Why not?

    Mary

  • The 'Extra CMake arguments' were not correct:

    -Dmcuboot_CONF_FILE="my_project/child_image/mcuboot/prj.conf";

    I removed the nrf5340 build and added a new one which compiled properly, and it automatically generated the proper Extra CMake arguments.

    -Dmcuboot_CONF_FILE=my_project/child_image/mcuboot/prj.conf;"my_project/child_image/mcuboot/boards/fl_dio_nrf5340_cpuapp.conf"

    This seems to be an ongoing problem.  It's not the first time I had to remove a build and create a new one again to get those CMake arguments to come out right.  I feel like that should happen whenever you do a pristine build.

    Mary

Related