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, 

Parents
  • Hi,

    I will continue to help in this ticket

    The error comes from https://github.com/nrfconnect/sdk-nrf/blob/1fae141fc6713dd331b797fc96c90dc84552242d/cmake/partition_manager.cmake#L630-L634.

    It looks like the addresses are not found.

    My main suspect is how you set up partitioning.
    Did you change anything other than Kconfig?
    Can you give a screenshot of your project folder? (So I can see the file structure)
    Do you have any pm_static.yml files?

    Regards,
    Sigurd Hellesvik

  • In between the build with and without MCUboot nothing else was changed. Just the option to enable the partition manager and MCUBoot.

    Is it relevant to mention that I have an external SPI Flash memory chip connected and configured but not used?

    Can you give a screenshot of your project folder? (So I can see the file structure)

    Full KConfig below:

    #MCUBoot
    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_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
    
    #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="*****"
    CONFIG_AZURE_IOT_HUB_HOSTNAME="*****"
    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
    

    Checked again and the project builds without the MCUboot and partition manager options. 

    Do you have any pm_static.yml files?

    As far as I am aware no. There is some address assignment stuff in my board definition files, though I didn't change them when I edited an exsisting NRF9160 based board to make my custom one. 

    crm_nrf9160_primary_partition_conf.dtsi:

    /*
     * Copyright (c) 2019-2022 Actinius
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    /*
     * Default Flash planning for actinius_icarus.
     *
     * Zephyr build for nRF9160 with ARM TrustZone-M support,
     * implies building Secure and Non-Secure Zephyr images.
     *
     * Secure image will be placed, by default, in flash0
     * (or in slot0, if MCUboot is present).
     * Secure image will use sram0 for system memory.
     *
     * Non-Secure image will be placed in slot0_ns, and use
     * sram0_ns for system memory.
     *
     * Note that the Secure image only requires knowledge of
     * the beginning of the Non-Secure image (not its size).
     */
    
    &slot0_partition {
    	reg = <0x00010000 0x40000>;
    };
    
    &slot0_ns_partition {
    	reg = <0x00050000 0x30000>;
    };
    
    &slot1_partition {
    	reg = <0x00080000 0x40000>;
    };
    
    &slot1_ns_partition {
    	reg = <0x000c0000 0x30000>;
    };
    
    /* Default SRAM planning when building for nRF9160 with
     * ARM TrustZone-M support
     * - Lowest 88 kB SRAM allocated to Secure image (sram0_s).
     * - 40 kB SRAM reserved for and used by the modem library
     *   (sram0_modem). This memory is Non-Secure.
     * - Upper 128 kB allocated to Non-Secure image (sram0_ns).
     */
    
    &sram0_s {
    	reg = <0x20000000 DT_SIZE_K(88)>;
    };
    
    &sram0_modem {
    	reg = <0x20016000 DT_SIZE_K(40)>;
    };
    
    &sram0_ns {
    	reg = <0x20020000 DT_SIZE_K(128)>;
    };
    

    crm_nrf9160_primary_common.dtsi:

    /*
     * Copyright (c) 2019-2022 Actinius
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    /* Modifications made by Camry Mabon for the SG-01 project
     *
     * Changes made to the intial Actinius version are included in the list below:
     *  -> Removed the UART 2 Node since it's not needed and the slot will be taken up by the i2c bus anyways
     *
    */
    
    #include "crm_nrf9160_primary_common-pinctrl.dtsi"
    /*#include "crm_nrf9160_primary_common.dtsi"*/
    
    / {
    	model = "CRM SG01 Primary Board";
    	compatible = "crm,nrf_9160_primary";
    
    	chosen {/* Include file with mappings and aliases for feather compatibility */
    		zephyr,console = &uart0;
    		zephyr,shell-uart = &uart0;
    		zephyr,uart-mcumgr = &uart0;
    	};
    
    	buttons {
    		compatible = "gpio-keys";
    
    		button0: button_0 {
    			gpios = <&gpio0 4 (GPIO_ACTIVE_HIGH)>;
    			label = "Push Button 1";
    		};
    
    	};
    
    	aliases {
    		sw0 = &button0;
    		mcuboot-button0 = &button0;
    		watchdog0 = &wdt0;
    	};
    };
    
    &adc {
    	status ="okay";
    };
    
    &gpiote {
    	status = "okay";
    };
    
    &gpio0 {
    	status = "okay";
    };
    
    &uart0 {
    	status = "okay";
    
    	current-speed = <115200>;
    	pinctrl-0 = <&uart0_default>;
    	pinctrl-1 = <&uart0_sleep>;
    	pinctrl-names = "default", "sleep";
    };
    
    &uart1 {
    	status = "disabled";
    
    	current-speed = <115200>;
    	pinctrl-0 = <&uart1_default>;
    	pinctrl-1 = <&uart1_sleep>;
    	pinctrl-names = "default", "sleep";
    };
    
    &i2c2 {
    	compatible = "nordic,nrf-twim";
    	status = "okay";
    
    	clock-frequency = <I2C_BITRATE_FAST>;
    
    	pinctrl-0 = <&i2c2_default>;
    	pinctrl-1 = <&i2c2_sleep>;
    	pinctrl-names = "default", "sleep";
    	pcf8523: pcf8523@68 {
    		compatible = "nxp,pcf8523";
    		battery-switch-over = "standard";
    		alarms-count = <1>;
    		reg = <0x68 >;
    		status = "okay";
        };
    };
    
    &spi3 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	cs-gpios = <&gpio0 7 GPIO_ACTIVE_LOW>;
    	pinctrl-0 = <&spi3_default>;
    	pinctrl-1 = <&spi3_sleep>;
    	pinctrl-names = "default", "sleep";
    
    	w25q64: w25q64fv@0{
    		compatible = "jedec,spi-nor";
    		reg = < 0 >;
    		spi-max-frequency = < 80000000 >;
    		jedec-id = [ ef 40 17 ];
    		size = < 0x4000000 >;
    		has-dpd;
    		t-enter-dpd = <3500>;
    		t-exit-dpd = <3500>;
    		/*
    		paritions {
    			compatible = "fixed-partitions";
    			#address-cells = < 1 >;
    			#size-cells = < 1 >;
    
    			partition@0 {
    				label = "storage";
    				reg = < 0x000000 0x7A0000 >;
    				};
    		};
    		*/
    	};
    };
    
    / {
    	aliases {
    		spi-flash0 = &w25q64;
    	};
    };
    
    /*
     * Memory Stuff no-touchy-touchy without real good reason
    */
    
    &flash0 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		boot_partition: partition@0 {
    			label = "mcuboot";
    			reg = <0x00000000 0x10000>;
    		};
    		slot0_partition: partition@10000 {
    			label = "image-0";
    		};
    		slot0_ns_partition: partition@50000 {
    			label = "image-0-nonsecure";
    		};
    		slot1_partition: partition@80000 {
    			label = "image-1";
    		};
    		slot1_ns_partition: partition@c0000 {
    			label = "image-1-nonsecure";
    		};
    		storage_partition: partition@fa000 {
    			label = "internal-storage";
    			reg = <0x000fa000 0x00006000>;
    		};
    	};
    };
    
    / {
    	reserved-memory {
    		#address-cells = <1>;
    		#size-cells = <1>;
    		ranges;
    
    		sram0_s: image_s@20000000 {
    			/* Secure image memory */
    		};
    
    		sram0_modem: image_modem@20016000 {
    			/* Modem (shared) memory */
    		};
    
    		sram0_ns: image_ns@20020000 {
    			/* Non-Secure image memory */
    		};
    	};
    };
    /* Include partition configuration file */
    #include "crm_nrf9160_primary_partition_conf.dtsi"
    
    

    Also created a new application based upon the hello world sample and was able to build and application for the custom board with MCUboot enabled (and partition manager) without issue

Reply
  • In between the build with and without MCUboot nothing else was changed. Just the option to enable the partition manager and MCUBoot.

    Is it relevant to mention that I have an external SPI Flash memory chip connected and configured but not used?

    Can you give a screenshot of your project folder? (So I can see the file structure)

    Full KConfig below:

    #MCUBoot
    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_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
    
    #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="*****"
    CONFIG_AZURE_IOT_HUB_HOSTNAME="*****"
    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
    

    Checked again and the project builds without the MCUboot and partition manager options. 

    Do you have any pm_static.yml files?

    As far as I am aware no. There is some address assignment stuff in my board definition files, though I didn't change them when I edited an exsisting NRF9160 based board to make my custom one. 

    crm_nrf9160_primary_partition_conf.dtsi:

    /*
     * Copyright (c) 2019-2022 Actinius
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    /*
     * Default Flash planning for actinius_icarus.
     *
     * Zephyr build for nRF9160 with ARM TrustZone-M support,
     * implies building Secure and Non-Secure Zephyr images.
     *
     * Secure image will be placed, by default, in flash0
     * (or in slot0, if MCUboot is present).
     * Secure image will use sram0 for system memory.
     *
     * Non-Secure image will be placed in slot0_ns, and use
     * sram0_ns for system memory.
     *
     * Note that the Secure image only requires knowledge of
     * the beginning of the Non-Secure image (not its size).
     */
    
    &slot0_partition {
    	reg = <0x00010000 0x40000>;
    };
    
    &slot0_ns_partition {
    	reg = <0x00050000 0x30000>;
    };
    
    &slot1_partition {
    	reg = <0x00080000 0x40000>;
    };
    
    &slot1_ns_partition {
    	reg = <0x000c0000 0x30000>;
    };
    
    /* Default SRAM planning when building for nRF9160 with
     * ARM TrustZone-M support
     * - Lowest 88 kB SRAM allocated to Secure image (sram0_s).
     * - 40 kB SRAM reserved for and used by the modem library
     *   (sram0_modem). This memory is Non-Secure.
     * - Upper 128 kB allocated to Non-Secure image (sram0_ns).
     */
    
    &sram0_s {
    	reg = <0x20000000 DT_SIZE_K(88)>;
    };
    
    &sram0_modem {
    	reg = <0x20016000 DT_SIZE_K(40)>;
    };
    
    &sram0_ns {
    	reg = <0x20020000 DT_SIZE_K(128)>;
    };
    

    crm_nrf9160_primary_common.dtsi:

    /*
     * Copyright (c) 2019-2022 Actinius
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    /* Modifications made by Camry Mabon for the SG-01 project
     *
     * Changes made to the intial Actinius version are included in the list below:
     *  -> Removed the UART 2 Node since it's not needed and the slot will be taken up by the i2c bus anyways
     *
    */
    
    #include "crm_nrf9160_primary_common-pinctrl.dtsi"
    /*#include "crm_nrf9160_primary_common.dtsi"*/
    
    / {
    	model = "CRM SG01 Primary Board";
    	compatible = "crm,nrf_9160_primary";
    
    	chosen {/* Include file with mappings and aliases for feather compatibility */
    		zephyr,console = &uart0;
    		zephyr,shell-uart = &uart0;
    		zephyr,uart-mcumgr = &uart0;
    	};
    
    	buttons {
    		compatible = "gpio-keys";
    
    		button0: button_0 {
    			gpios = <&gpio0 4 (GPIO_ACTIVE_HIGH)>;
    			label = "Push Button 1";
    		};
    
    	};
    
    	aliases {
    		sw0 = &button0;
    		mcuboot-button0 = &button0;
    		watchdog0 = &wdt0;
    	};
    };
    
    &adc {
    	status ="okay";
    };
    
    &gpiote {
    	status = "okay";
    };
    
    &gpio0 {
    	status = "okay";
    };
    
    &uart0 {
    	status = "okay";
    
    	current-speed = <115200>;
    	pinctrl-0 = <&uart0_default>;
    	pinctrl-1 = <&uart0_sleep>;
    	pinctrl-names = "default", "sleep";
    };
    
    &uart1 {
    	status = "disabled";
    
    	current-speed = <115200>;
    	pinctrl-0 = <&uart1_default>;
    	pinctrl-1 = <&uart1_sleep>;
    	pinctrl-names = "default", "sleep";
    };
    
    &i2c2 {
    	compatible = "nordic,nrf-twim";
    	status = "okay";
    
    	clock-frequency = <I2C_BITRATE_FAST>;
    
    	pinctrl-0 = <&i2c2_default>;
    	pinctrl-1 = <&i2c2_sleep>;
    	pinctrl-names = "default", "sleep";
    	pcf8523: pcf8523@68 {
    		compatible = "nxp,pcf8523";
    		battery-switch-over = "standard";
    		alarms-count = <1>;
    		reg = <0x68 >;
    		status = "okay";
        };
    };
    
    &spi3 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	cs-gpios = <&gpio0 7 GPIO_ACTIVE_LOW>;
    	pinctrl-0 = <&spi3_default>;
    	pinctrl-1 = <&spi3_sleep>;
    	pinctrl-names = "default", "sleep";
    
    	w25q64: w25q64fv@0{
    		compatible = "jedec,spi-nor";
    		reg = < 0 >;
    		spi-max-frequency = < 80000000 >;
    		jedec-id = [ ef 40 17 ];
    		size = < 0x4000000 >;
    		has-dpd;
    		t-enter-dpd = <3500>;
    		t-exit-dpd = <3500>;
    		/*
    		paritions {
    			compatible = "fixed-partitions";
    			#address-cells = < 1 >;
    			#size-cells = < 1 >;
    
    			partition@0 {
    				label = "storage";
    				reg = < 0x000000 0x7A0000 >;
    				};
    		};
    		*/
    	};
    };
    
    / {
    	aliases {
    		spi-flash0 = &w25q64;
    	};
    };
    
    /*
     * Memory Stuff no-touchy-touchy without real good reason
    */
    
    &flash0 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		boot_partition: partition@0 {
    			label = "mcuboot";
    			reg = <0x00000000 0x10000>;
    		};
    		slot0_partition: partition@10000 {
    			label = "image-0";
    		};
    		slot0_ns_partition: partition@50000 {
    			label = "image-0-nonsecure";
    		};
    		slot1_partition: partition@80000 {
    			label = "image-1";
    		};
    		slot1_ns_partition: partition@c0000 {
    			label = "image-1-nonsecure";
    		};
    		storage_partition: partition@fa000 {
    			label = "internal-storage";
    			reg = <0x000fa000 0x00006000>;
    		};
    	};
    };
    
    / {
    	reserved-memory {
    		#address-cells = <1>;
    		#size-cells = <1>;
    		ranges;
    
    		sram0_s: image_s@20000000 {
    			/* Secure image memory */
    		};
    
    		sram0_modem: image_modem@20016000 {
    			/* Modem (shared) memory */
    		};
    
    		sram0_ns: image_ns@20020000 {
    			/* Non-Secure image memory */
    		};
    	};
    };
    /* Include partition configuration file */
    #include "crm_nrf9160_primary_partition_conf.dtsi"
    
    

    Also created a new application based upon the hello world sample and was able to build and application for the custom board with MCUboot enabled (and partition manager) without issue

Children
  • 4DoorToyota said:
    In between the build with and without MCUboot nothing else was changed. Just the option to enable the partition manager and MCUBoot.

    Good to know. That narrows stuff down quite a bit.
    CONFIG_PARTITION_MANAGER_ENABLED is read-only, and will be automatically set by MCUboot. Try not setting it manually, it might mess up some stuff.
    (But maybe keep a comment that it is enabled automatically to make the Kconfig more readable?)

    4DoorToyota said:
    Is it relevant to mention that I have an external SPI Flash memory chip connected and configured but not used?

    It is relevant, but if you do not set External flash memory partitions from DTS that should not be used here.

    4DoorToyota said:

    That looks good to me.
    But what do you got in child_image/mcuboot.conf?
    That may impact some stuff.

    4DoorToyota said:
    As far as I am aware no. There is some address assignment stuff in my board definition files, though I didn't change them when I edited an exsisting NRF9160 based board to make my custom one. 

    Good good. That narrows it down some more.

    4DoorToyota said:

    As far as I am aware no. There is some address assignment stuff in my board definition files, though I didn't change them when I edited an exsisting NRF9160 based board to make my custom one. 

    Then those should be good. They need to be there, but when you enable the partition manager, they are mostly ignored. So if you later decide to edit partitioning, remember to use the partition manager for that. (And its Kconfig options).

    4DoorToyota said:
    Also created a new application based upon the hello world sample and was able to build and application for the custom board with MCUboot enabled (and partition manager) without issue

    Very nice testing.
    So we know that it is not the custom board now.

    Try to copy your child_image/mcuboot.conf to hello world and see if that does anything?

  • Commented out the CONFIG_PARTITION_MANAGER_ENABLED and sadly no change. I did take your advice and add a comment noting why. 

    That looks good to me.
    But what do you got in child_image/mcuboot.conf?
    That may impact some stuff.

    Currently only one lines:

    CONFIG_MULTITHREADING=y
    CONFIG_SERIAL=n

    Is there perhaps additional settings that should be added here? Serial is disabled since the serial port that MCUBoot normally uses is used by my main program.

    CONFIG_MULTITHREADING is enabled due to the testing explained in the next paragraph. Chaning this particular option does not appear to change the error reported while building 

    I am able to compile the hello world sample on the board with the MCUboot options being the same as my main project. Of note is that if I disable the CONFIG_MULTITHREADING then I get the following build error in the hello world application:

    171/176] Linking C executable zephyr/zephyr_pre0.elf
    FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map 
    : && ccache /home/cmabon/ncs/toolchains/7795df4459/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc  -gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr/zephyr_pre0.elf  -fuse-ld=bfd  -T  zephyr/linker_zephyr_pre0.cmd  -Wl,-Map=/home/cmabon/hello_world/build/mcuboot/zephyr/zephyr_pre0.map  -Wl,--whole-archive  app/libapp.a  zephyr/libzephyr.a  zephyr/arch/common/libarch__common.a  zephyr/arch/arch/arm/core/aarch32/libarch__arm__core__aarch32.a  zephyr/arch/arch/arm/core/aarch32/cortex_m/libarch__arm__core__aarch32__cortex_m.a  zephyr/arch/arch/arm/core/aarch32/cortex_m/cmse/libarch__arm__core__aarch32__cortex_m__cmse.a  zephyr/lib/libc/minimal/liblib__libc__minimal.a  zephyr/lib/libc/common/liblib__libc__common.a  zephyr/drivers/clock_control/libdrivers__clock_control.a  zephyr/drivers/flash/libdrivers__flash.a  zephyr/drivers/gpio/libdrivers__gpio.a  zephyr/drivers/pinctrl/libdrivers__pinctrl.a  zephyr/drivers/timer/libdrivers__timer.a  modules/nrf/lib/fprotect/lib..__nrf__lib__fprotect.a  modules/nrf/lib/fatal_error/lib..__nrf__lib__fatal_error.a  modules/nrf/drivers/hw_cc310/lib..__nrf__drivers__hw_cc310.a  modules/mcuboot/boot/bootutil/zephyr/libmcuboot_util.a  modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj  -L"/home/cmabon/ncs/toolchains/7795df4459/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v8-m.main+fp/hard"  -L/home/cmabon/hello_world/build/mcuboot/zephyr  -lgcc  zephyr/arch/common/libisr_tables.a  -mcpu=cortex-m33  -mthumb  -mabi=aapcs  -mfpu=fpv5-sp-d16  -mfloat-abi=hard  -mfp16-format=ieee  -Wl,--gc-sections  -Wl,--build-id=none  -Wl,--sort-common=descending  -Wl,--sort-section=alignment  -Wl,-u,_OffsetAbsSyms  -Wl,-u,_ConfigAbsSyms  -nostdlib  -static  -Wl,-X  -Wl,-N  -Wl,--orphan-handling=warn  -Wl,-no-pie  /home/cmabon/ncs/v2.5.0/nrfxlib/crypto/nrf_cc310_platform/lib/cortex-m33/hard-float/no-interrupts/libnrf_cc310_platform_0.9.18.a  /home/cmabon/ncs/v2.5.0/nrfxlib/crypto/nrf_cc310_bl/lib/cortex-m33/hard-float/no-interrupts/libnrf_cc310_bl_0.9.12.a && cd /home/cmabon/hello_world/build/mcuboot/zephyr && /home/cmabon/ncs/toolchains/7795df4459/usr/local/bin/cmake -E true
    /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: zephyr/drivers/flash/libdrivers__flash.a(spi_nor.c.obj): in function `k_sleep':
    /home/cmabon/hello_world/build/mcuboot/zephyr/include/generated/syscalls/kernel.h:135: undefined reference to `z_impl_k_sleep'
    /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: /home/cmabon/hello_world/build/mcuboot/zephyr/include/generated/syscalls/kernel.h:135: undefined reference to `z_impl_k_sleep'
    /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: zephyr/drivers/flash/libdrivers__flash.a(spi_nor.c.obj):(.rodata.spi_nor_config_0+0x0): undefined reference to `__device_dts_ord_93'
    collect2: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.

    (Fix grabbed from  https://devzone.nordicsemi.com/f/nordic-q-a/101398/nrf9160-mcuboot-link-failure-searching-for-z_impl_k_sleep-is-config_multithreading-required )

    In case anything has changed here is the output I get when trying to build my main program:

     *  Executing task: nRF Connect: Build [pristine]: SG-Firmware/build (active) 
    
    Building SG-Firmware
    west build --build-dir /home/cmabon/Documents/Projects/SG-Firmware/build /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 -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/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: /home/cmabon/Documents/Projects/SG-Firmware/build/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: /home/cmabon/Documents/Projects/SG-Firmware/build/zephyr/dts.cmake
    
    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/zephyr/.config'
    Kconfig header saved to '/home/cmabon/Documents/Projects/SG-Firmware/build/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 
    loading initial cache file /home/cmabon/Documents/Projects/SG-Firmware/build/mcuboot/child_image_preload.cmake
    Changed board to secure crm_nrf9160_primary (NOT NS)
    
    === child image mcuboot -  begin ===
    -- Application: /home/cmabon/ncs/v2.5.0/bootloader/mcuboot/boot/zephyr
    -- CMake version: 3.20.5
    Loading Zephyr default modules (Zephyr base).
    -- 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/mcuboot/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: /home/cmabon/Documents/Projects/SG-Firmware/build/mcuboot/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: /home/cmabon/Documents/Projects/SG-Firmware/build/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/mcuboot/zephyr/misc/generated/extra_kconfig_options.conf'
    Configuration saved to '/home/cmabon/Documents/Projects/SG-Firmware/build/mcuboot/zephyr/.config'
    Kconfig header saved to '/home/cmabon/Documents/Projects/SG-Firmware/build/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.
    
    
    CMake Warning at /home/cmabon/ncs/v2.5.0/zephyr/CMakeLists.txt:893 (message):
      No SOURCES given to Zephyr library: drivers__spi
    
      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/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/partitions.yml;--input-regions;/home/cmabon/Documents/Projects/SG-Firmware/build/regions.yml;--header-files;/home/cmabon/Documents/Projects/SG-Firmware/build/mcuboot/zephyr/include/generated/pm_config.h;/home/cmabon/Documents/Projects/SG-Firmware/build/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/CMakeFiles/CMakeOutput.log".
    See also "/home/cmabon/Documents/Projects/SG-Firmware/build/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 -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' '-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
    
     *  The terminal process terminated with exit code: 1. 
     *  Terminal will be reused by tasks, press any key to close it. 
    

    Further information:

    Here is my build configuration in case it is helpful:

  • Some

    4DoorToyota said:
    Is there perhaps additional settings that should be added here? Serial is disabled since the serial port that MCUBoot normally uses is used by my main program.

    Some times, if you want something extra.
    Usually external flash or serial recovery. Oh and also custom key.
    See DevAcademy on bootloaders and my unofficial bootloader samples for some samples of what goes there.

    No worries about the serial. MCUboot cleans up everything so you can use the same stuff in both MCUboot and the app.

    At this point I am running low on ideas.
    Is it possible for you to send me your project as a zip so I can try to reproduce this?
    If you dont want it public, create a new private ticket and upload it there. Then let me know that  you created the ticket and I will run it on my side to reproduce and hopefully find the issue.

  • Here is the firmware:

    4426.Project.zip

    and here is the board file:

    crm_nrf9160_primary.zip

    On my computer I am currently running the following:

    Fedora Linux

    Tool chain version 2.5.0

  • Found it.

    You add the mcuboot.conf at the wrong place in CMakeLists.txt.
    You can just move it down a bit.

    Alternatively, you do not need to put it in CMakeLists.txt at all.The project will automatically search for the folder child_image and add files with the name of <child_image>.conf ( and other files, following these rules).

    Bonus tip:

    If you want, you can create an directory in your boards/ dir named "arm" and put your board files inside there:

    Then you can build with -- -DBOARD_ROOT=.

    This is not necessarily the best method, but it can be useful sometimes and very useful when sharing projects.

Related