Partion Manager script failing when MCUboot configured

Hi everyone, 

I have a fairly mature project that I am now required to add MCUboot to so that remote firmware updates can be possible. I am building for a custom board based upon the NRF9160.

I have verified the following things so far:

  • My project builds with CONFIG_MCUBOOT=n without issue
  • I can build a simple sample (hello world) with CONFIG_MCUBOOT=y on my custom board

I get the following output message from the build process:

Building SG-Firmware
west build --build-dir /home/cmabon/Documents/Projects/SG-Firmware/build_primary /home/cmabon/Documents/Projects/SG-Firmware --pristine --board crm_nrf9160_primary_ns --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION=NONE -DBOARD_ROOT=/home/cmabon/ncs/v2.4.1/zephyr;/home/cmabon/Documents/Projects/SG-Firmware -Db0_OVERLAY_CONFIG=/home/cmabon/ncs/v2.5.0/nrf/subsys/partition_manager/partition_manager_enabled.conf -Dmcuboot_OVERLAY_CONFIG=/home/cmabon/Documents/Projects/SG-Firmware/child_image/mcuboot.conf;/home/cmabon/ncs/v2.5.0/nrf/subsys/partition_manager/partition_manager_enabled.conf -DCACHED_CONF_FILE=/home/cmabon/Documents/Projects/SG-Firmware/prj.conf -DDTC_OVERLAY_FILE=/home/cmabon/Documents/Projects/SG-Firmware/boards/crm_nrf9160_primary_ns.overlay

-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /home/cmabon/Documents/Projects/SG-Firmware
-- CMake version: 3.20.5
-- Found Python3: /home/cmabon/ncs/toolchains/7795df4459/usr/local/bin/python3.8 (found suitable version "3.8.2", minimum required is "3.8") found components: Interpreter 
-- Cache files will be written to: /home/cmabon/.cache/zephyr
-- Zephyr version: 3.4.99 (/home/cmabon/ncs/v2.5.0/zephyr)
-- Found west (found suitable version "1.1.0", minimum required is "0.14.0")
CMake Warning at /home/cmabon/ncs/v2.5.0/zephyr/cmake/modules/boards.cmake:92 (message):
  BOARD_ROOT element without a 'boards' subdirectory:

  /home/cmabon/ncs/v2.4.1/zephyr

  Hints:

    - if your board directory is '/foo/bar/boards/<ARCH>/my_board' then add '/foo/bar' to BOARD_ROOT, not the entire board directory
    - if in doubt, use absolute paths
Call Stack (most recent call first):
  /home/cmabon/ncs/v2.5.0/zephyr/cmake/modules/zephyr_default.cmake:129 (include)
  /home/cmabon/ncs/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  /home/cmabon/ncs/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
  CMakeLists.txt:5 (find_package)


-- Board: crm_nrf9160_primary_ns
-- Found host-tools: zephyr 0.16.1 (/home/cmabon/ncs/toolchains/7795df4459/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.16.1 (/home/cmabon/ncs/toolchains/7795df4459/opt/zephyr-sdk)
-- Found Dtc: /home/cmabon/ncs/toolchains/7795df4459/usr/bin/dtc (found suitable version "1.4.7", minimum required is "1.4.6") 
-- Found BOARD.dts: /home/cmabon/ncs/v2.5.0/zephyr/boards/arm/crm_nrf9160_primary/crm_nrf9160_primary_ns.dts
-- Found devicetree overlay: /home/cmabon/Documents/Projects/SG-Firmware/boards/crm_nrf9160_primary_ns.overlay
-- Generated zephyr.dts: /home/cmabon/Documents/Projects/SG-Firmware/build_primary/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/cmabon/Documents/Projects/SG-Firmware/build_primary/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: /home/cmabon/Documents/Projects/SG-Firmware/build_primary/zephyr/dts.cmake

warning: FILE_SYSTEM_SHELL (defined at subsys/fs/Kconfig:46) was assigned the value 'y' but got the
value 'n'. Check these unsatisfied dependencies: FILE_SYSTEM (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_FILE_SYSTEM_SHELL and/or look up
FILE_SYSTEM_SHELL in the menuconfig/guiconfig interface. The Application Development Primer, Setting
Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
too.


warning: Experimental symbol AZURE_IOT_HUB is enabled.


warning: Experimental symbol HTTP_CLIENT is enabled.


warning: Experimental symbol NET_CONNECTION_MANAGER is enabled.

Parsing /home/cmabon/ncs/v2.5.0/zephyr/Kconfig
Loaded configuration '/home/cmabon/ncs/v2.5.0/zephyr/boards/arm/crm_nrf9160_primary/crm_nrf9160_primary_ns_defconfig'
Merged configuration '/home/cmabon/Documents/Projects/SG-Firmware/prj.conf'
Configuration saved to '/home/cmabon/Documents/Projects/SG-Firmware/build_primary/zephyr/.config'
Kconfig header saved to '/home/cmabon/Documents/Projects/SG-Firmware/build_primary/zephyr/include/generated/autoconf.h'
-- Found GnuLd: /home/cmabon/ncs/toolchains/7795df4459/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd (found version "2.38") 
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/cmabon/ncs/toolchains/7795df4459/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
-- Found Python3: /home/cmabon/ncs/toolchains/7795df4459/usr/local/bin/python3.8 (found version "3.8.2") found components: Interpreter 
Changed board to secure crm_nrf9160_primary (NOT NS)

=== child image mcuboot -  begin ===
loading initial cache file /home/cmabon/Documents/Projects/SG-Firmware/build_primary/mcuboot/child_image_preload.cmake
Loading Zephyr default modules (Zephyr base).
-- Application: /home/cmabon/ncs/v2.5.0/bootloader/mcuboot/boot/zephyr
-- CMake version: 3.20.5
-- Found Python3: /home/cmabon/ncs/toolchains/7795df4459/usr/local/bin/python3.8 (found suitable version "3.8.2", minimum required is "3.8") found components: Interpreter 
-- Cache files will be written to: /home/cmabon/.cache/zephyr
-- Zephyr version: 3.4.99 (/home/cmabon/ncs/v2.5.0/zephyr)
-- Found west (found suitable version "1.1.0", minimum required is "0.14.0")
-- Board: crm_nrf9160_primary
-- Found host-tools: zephyr 0.16.1 (/home/cmabon/ncs/toolchains/7795df4459/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.16.1 (/home/cmabon/ncs/toolchains/7795df4459/opt/zephyr-sdk)
-- Found Dtc: /home/cmabon/ncs/toolchains/7795df4459/usr/bin/dtc (found suitable version "1.4.7", minimum required is "1.4.6") 
-- Found BOARD.dts: /home/cmabon/ncs/v2.5.0/zephyr/boards/arm/crm_nrf9160_primary/crm_nrf9160_primary.dts
-- Found devicetree overlay: /home/cmabon/ncs/v2.5.0/bootloader/mcuboot/boot/zephyr/app.overlay
-- Generated zephyr.dts: /home/cmabon/Documents/Projects/SG-Firmware/build_primary/mcuboot/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/cmabon/Documents/Projects/SG-Firmware/build_primary/mcuboot/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: /home/cmabon/Documents/Projects/SG-Firmware/build_primary/mcuboot/zephyr/dts.cmake
Parsing /home/cmabon/ncs/v2.5.0/bootloader/mcuboot/boot/zephyr/Kconfig
Loaded configuration '/home/cmabon/ncs/v2.5.0/zephyr/boards/arm/crm_nrf9160_primary/crm_nrf9160_primary_defconfig'
Merged configuration '/home/cmabon/ncs/v2.5.0/bootloader/mcuboot/boot/zephyr/prj.conf'
Merged configuration '/home/cmabon/Documents/Projects/SG-Firmware/child_image/mcuboot.conf'
Merged configuration '/home/cmabon/Documents/Projects/SG-Firmware/build_primary/mcuboot/zephyr/misc/generated/extra_kconfig_options.conf'
Configuration saved to '/home/cmabon/Documents/Projects/SG-Firmware/build_primary/mcuboot/zephyr/.config'
Kconfig header saved to '/home/cmabon/Documents/Projects/SG-Firmware/build_primary/mcuboot/zephyr/include/generated/autoconf.h'

warning: UART_CONSOLE (defined at drivers/console/Kconfig:43) was assigned the value 'y' but got the
value 'n'. Check these unsatisfied dependencies: SERIAL (=n), SERIAL_HAS_DRIVER (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_UART_CONSOLE and/or look up UART_CONSOLE in
the menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration
Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful too.

-- Found GnuLd: /home/cmabon/ncs/toolchains/7795df4459/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd (found version "2.38") 
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/cmabon/ncs/toolchains/7795df4459/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
CMake Warning at /home/cmabon/ncs/v2.5.0/zephyr/CMakeLists.txt:893 (message):
  No SOURCES given to Zephyr library: drivers__console

  Excluding target from build.


MCUBoot bootloader key file: /home/cmabon/ncs/v2.5.0/bootloader/mcuboot/root-ec-p256.pem
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cmabon/Documents/Projects/SG-Firmware/build_primary/mcuboot
=== child image mcuboot -  end ===

CMake Warning at /home/cmabon/ncs/v2.5.0/nrf/modules/mcuboot/CMakeLists.txt:320 (message):
  

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



CMake Warning at /home/cmabon/ncs/v2.5.0/nrf/cmake/partition_manager.cmake:79 (message):
  

          ---------------------------------------------------------------------
          --- WARNING: Using a bootloader without pm_static.yml.            ---
          --- There are cases where a deployed product can consist of       ---
          --- multiple images, and only a subset of these images can be     ---
          --- upgraded through a firmware update mechanism. In such cases,  ---
          --- the upgradable images must have partitions that are static    ---
          --- and are matching the partition map used by the bootloader     ---
          --- programmed onto the device.                                   ---
          ---------------------------------------------------------------------
          

Call Stack (most recent call first):
  /home/cmabon/ncs/v2.5.0/zephyr/cmake/modules/kernel.cmake:247 (include)
  /home/cmabon/ncs/v2.5.0/zephyr/cmake/modules/zephyr_default.cmake:138 (include)
  /home/cmabon/ncs/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  /home/cmabon/ncs/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
  CMakeLists.txt:5 (find_package)


Dropping partition 'nrf_modem_lib_trace' since its size is 0.
Dropping partition 'nonsecure_storage' since it is empty.
CMake Error at /home/cmabon/ncs/v2.5.0/nrf/cmake/partition_manager.cmake:630 (math):
  math cannot parse the expression: " + - ": syntax error, unexpected end of
  file (18).
Call Stack (most recent call first):
  /home/cmabon/ncs/v2.5.0/zephyr/cmake/modules/kernel.cmake:247 (include)
  /home/cmabon/ncs/v2.5.0/zephyr/cmake/modules/zephyr_default.cmake:138 (include)
  /home/cmabon/ncs/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  /home/cmabon/ncs/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
  CMakeLists.txt:5 (find_package)


Traceback (most recent call last):
  File "/home/cmabon/ncs/v2.5.0/nrf/scripts/partition_manager_output.py", line 251, in <module>
    main()
  File "/home/cmabon/ncs/v2.5.0/nrf/scripts/partition_manager_output.py", line 247, in main
    write_gpm_config(gpm_config, greg_config, name, header_file)
  File "/home/cmabon/ncs/v2.5.0/nrf/scripts/partition_manager_output.py", line 142, in write_gpm_config
    if any('span' in x for x in gpm_config[domain][image]):
KeyError: 'mcuboot'
CMake Error at /home/cmabon/ncs/v2.5.0/nrf/cmake/partition_manager.cmake:665 (message):
  Partition Manager GLOBAL output generation failed,

      aborting. Command: /home/cmabon/ncs/toolchains/7795df4459/usr/local/bin/python3.8;/home/cmabon/ncs/v2.5.0/nrf/scripts/partition_manager_output.py;--input-partitions;/home/cmabon/Documents/Projects/SG-Firmware/build_primary/partitions.yml;--input-regions;/home/cmabon/Documents/Projects/SG-Firmware/build_primary/regions.yml;--header-files;/home/cmabon/Documents/Projects/SG-Firmware/build_primary/mcuboot/zephyr/include/generated/pm_config.h;/home/cmabon/Documents/Projects/SG-Firmware/build_primary/zephyr/include/generated/pm_config.h;--images;:mcuboot;:app
Call Stack (most recent call first):
  /home/cmabon/ncs/v2.5.0/zephyr/cmake/modules/kernel.cmake:247 (include)
  /home/cmabon/ncs/v2.5.0/zephyr/cmake/modules/zephyr_default.cmake:138 (include)
  /home/cmabon/ncs/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  /home/cmabon/ncs/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
  CMakeLists.txt:5 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/cmabon/Documents/Projects/SG-Firmware/build_primary/CMakeFiles/CMakeOutput.log".
See also "/home/cmabon/Documents/Projects/SG-Firmware/build_primary/CMakeFiles/CMakeError.log".
FATAL ERROR: command exited with status 1: /home/cmabon/ncs/toolchains/7795df4459/usr/local/bin/cmake -DWEST_PYTHON=/home/cmabon/ncs/toolchains/7795df4459/usr/local/bin/python3.8 -B/home/cmabon/Documents/Projects/SG-Firmware/build_primary -GNinja -DBOARD=crm_nrf9160_primary_ns -DNCS_TOOLCHAIN_VERSION=NONE '-DBOARD_ROOT=/home/cmabon/ncs/v2.4.1/zephyr;/home/cmabon/Documents/Projects/SG-Firmware' -Db0_OVERLAY_CONFIG=/home/cmabon/ncs/v2.5.0/nrf/subsys/partition_manager/partition_manager_enabled.conf '-Dmcuboot_OVERLAY_CONFIG=/home/cmabon/Documents/Projects/SG-Firmware/child_image/mcuboot.conf;/home/cmabon/ncs/v2.5.0/nrf/subsys/partition_manager/partition_manager_enabled.conf' -DCACHED_CONF_FILE=/home/cmabon/Documents/Projects/SG-Firmware/prj.conf -DDTC_OVERLAY_FILE=/home/cmabon/Documents/Projects/SG-Firmware/boards/crm_nrf9160_primary_ns.overlay -S/home/cmabon/Documents/Projects/SG-Firmware

My project configuration looks like this:

#MCUBootloader Stuff
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_PARTITION_MANAGER_ENABLED=y

#C library stuff
CONFIG_NEWLIB_LIBC_NANO=n
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_CBPRINTF_FP_SUPPORT=y
CONFIG_CJSON_LIB=y

#General Stuff
CONFIG_COMMON_LIBC_MALLOC=y
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_HEAP_MEM_POOL_SIZE=32768
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=1024

#Other Stuff so far
CONFIG_PM_DEVICE=y
CONFIG_POSIX_API=y

#Shell Stuff
CONFIG_SHELL=y
CONFIG_FILE_SYSTEM_SHELL=y
CONFIG_SHELL_BACKEND_SERIAL=y

#I2C Stuff
CONFIG_I2C=y
CONFIG_RTC=y
CONFIG_RTC_ALARM=y
CONFIG_RTC_PCF8523=y

#SPI Stuff
CONFIG_SPI=y
CONFIG_SPI_NOR=y
CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y

#Flash Stuff
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_STREAM_FLASH=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

#LittleFS
#CONFIG_FILE_SYSTEM=y
#CONFIG_FILE_SYSTEM_LITTLEFS=y

#Settings
#ONFIG_SETTINGS=y
#CONFIG_SETTINGS_SHELL=y
#CONFIG_SETTINGS_FILE=y
#CONFIG_SETTINGS_FILE_PATH="/lfs/settings"
#CONFIG_SETTINGS_LOG_LEVEL_INF=y

#Logging
CONFIG_LOG=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_NRF_MODEM_LOG=y

#Networking
CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS=y
CONFIG_DNS_RESOLVER=y
CONFIG_NET_SHELL=n
CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=y
CONFIG_NRF_MODEM_LIB=y
CONFIG_NET_CONNECTION_MANAGER=y
CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE=1024
CONFIG_LTE_LINK_CONTROL=y
CONFIG_MODEM_INFO=y
CONFIG_SNTP=y
CONFIG_NET_IPV6_NBR_CACHE=n
CONFIG_NET_IPV6_MLD=n
CONFIG_REST_CLIENT=y

#Azure IOT HUB
CONFIG_AZURE_IOT_HUB=y
CONFIG_AZURE_IOT_HUB_DEVICE_ID="sg01"
CONFIG_AZURE_IOT_HUB_HOSTNAME="NRC-DataIngest-Hub.azure-devices.net"
CONFIG_AZURE_IOT_HUB_LOG_LEVEL_DBG=y
CONFIG_AZURE_IOT_HUB_AUTO_DEVICE_TWIN_REQUEST=n
CONFIG_MQTT_KEEPALIVE=1767
CONFIG_MQTT_HELPER_SEC_TAG=10
CONFIG_MQTT_HELPER_STACK_SIZE=8192

#These should be adjusted they are taken from somewhere else!
# PSM & eDRX enable
CONFIG_LTE_EDRX_REQ=y
CONFIG_LTE_PSM_REQ=y
CONFIG_LTE_PSM_REQ_RPTAU="00000001" # 10 Minutes checkin interval
#CONFIG_LTE_PSM_REQ_RPTAU="00000110" # 60 Minutes checkin interval
CONFIG_LTE_PSM_REQ_RAT="00000011" # 6 sec active time
#CONFIG_LTE_PSM_REQ_RAT="00000101" # 10 sec active time
CONFIG_LTE_LC_TAU_PRE_WARNING_NOTIFICATIONS=y
CONFIG_LTE_LC_TAU_PRE_WARNING_THRESHOLD_MS=60000
CONFIG_LTE_LC_MODEM_SLEEP_NOTIFICATIONS=y
CONFIG_LTE_LC_MODEM_SLEEP_NOTIFICATIONS_THRESHOLD_MS=60000

# Increased sysworkq size, due to LTE connectivity
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

#Debug
CONFIG_DEBUG=y
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_COREDUMP=y
CONFIG_AT_SHELL=y

and my MCUBoot configuration is this:

CONFIG_MULTITHREADING=y
CONFIG_SERIAL=n

I am unsure as to how to proceed with debugging my project further and any help would be very very appreciated!

Thank you, 

Related