Partition Manager Configuration

Hi all,

We started from the asset tracker v2 application and we want to add a partition to the non secure storage just to save some additional data to nvs.

I'm a bit confused what the proper way is to configure this today. Is it correct that there are two approaches?

  1. The device tree overlay
  2. Partition manager

I've tried to configure a pm_static.yml by placing it in the configuration folder of my board, and set the env variable PM_STATIC_YML_FILE to this file (as specified here) in my CMakeLists, but this doesn't seem to do anything.

# Partition Manager file
set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/pm_static.yml)

What are we missing here?
Are there some additional configuration options missing?

Or should we use the device tree overlay?

Thanks!

Parents
  • Hi,

    In the nRF Connect SDK, when you have a multi-image build, the Partition Manager is used automatically, and it will override the device tree partition layout.

    When building an application for the non-secure domain (e.g. nrf9160dk_nrf9160_ns), TF-M is automatically included, so you will always have a multi-image build.

    Can you share the CMake part of your build output?

    Did you try to delete your build folder before you built the project?

    Best regards,

    Didrik

Reply
  • Hi,

    In the nRF Connect SDK, when you have a multi-image build, the Partition Manager is used automatically, and it will override the device tree partition layout.

    When building an application for the non-secure domain (e.g. nrf9160dk_nrf9160_ns), TF-M is automatically included, so you will always have a multi-image build.

    Can you share the CMake part of your build output?

    Did you try to delete your build folder before you built the project?

    Best regards,

    Didrik

Children
  • Hi Didrik,

    Thanks for the reply.
    I've deleted the build folder, but no dice, same result. I bet I'm doing something wrong somewhere.

    Output:

    [0/1] Re-running CMake...
    Loading Zephyr default modules (Zephyr base (cached)).
    -- Application: C:/PathToProjectFolder
    -- CMake version: 3.20.5
    -- Found Python3: C:/ncs/toolchains/c57af46cb7/opt/bin/python.exe (found suitable version "3.8.2", minimum required is "3.8") found components: Interpreter 
    -- Cache files will be written to: C:/ncs/v2.5.0/zephyr/.cache
    -- Zephyr version: 3.4.99 (C:/ncs/v2.5.0/zephyr)
    -- Found west (found suitable version "1.1.0", minimum required is "0.14.0")
    -- Board: nrf9160dk_nrf9160_ns, Revision: 0.14.0
    -- Found host-tools: zephyr 0.16.1 (C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.1 (C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk)
    -- Found BOARD.dts: C:/ncs/v2.5.0/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_ns.dts
    -- Found devicetree overlay: C:/ncs/v2.5.0/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_ns_0_14_0.overlay
    -- Found devicetree overlay: C:/PathToProjectFolder/boards/nrf9160dk_nrf9160_ns.overlay
    -- Found devicetree overlay: boards/nrf9160dk_nrf9160_ns.overlay
    -- Generated zephyr.dts: C:/PathToProjectFolder/build_5/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: C:/PathToProjectFolder/build_5/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: C:/PathToProjectFolder/build_5/zephyr/dts.cmake
    
    warning: Experimental symbol HTTP_CLIENT is enabled.
    
    Parsing C:/PathToProjectFolder/Kconfig
    Loaded configuration 'C:/PathToProjectFolder/build_5/zephyr/.config'
    No change to configuration in 'C:/PathToProjectFolder/build_5/zephyr/.config'
    No change to Kconfig header in 'C:/PathToProjectFolder/build_5/zephyr/include/generated/autoconf.h'
    -- Found Python3: C:/ncs/toolchains/c57af46cb7/opt/bin/python.exe (found version "3.8.2") found components: Interpreter 
    Changed board to secure nrf9160dk_nrf9160 (NOT NS)
    
    === child image mcuboot -  begin ===
    loading initial cache file C:/PathToProjectFolder/build_5/mcuboot/child_image_preload.cmake
    Loading Zephyr default modules (Zephyr base (cached)).
    -- Application: C:/ncs/v2.5.0/bootloader/mcuboot/boot/zephyr
    -- CMake version: 3.20.5
    -- Cache files will be written to: C:/ncs/v2.5.0/zephyr/.cache
    -- Zephyr version: 3.4.99 (C:/ncs/v2.5.0/zephyr)
    -- Found west (found suitable version "1.1.0", minimum required is "0.14.0")
    -- Board: nrf9160dk_nrf9160, Revision: 0.14.0
    -- Found host-tools: zephyr 0.16.1 (C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.1 (C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk)
    -- Found BOARD.dts: C:/ncs/v2.5.0/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160.dts
    -- Found devicetree overlay: C:/ncs/v2.5.0/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_0_14_0.overlay
    -- Found devicetree overlay: C:/ncs/v2.5.0/bootloader/mcuboot/boot/zephyr/app.overlay
    -- Generated zephyr.dts: C:/PathToProjectFolder/build_5/mcuboot/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: C:/PathToProjectFolder/build_5/mcuboot/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: C:/PathToProjectFolder/build_5/mcuboot/zephyr/dts.cmake
    Parsing C:/ncs/v2.5.0/bootloader/mcuboot/boot/zephyr/Kconfig
    Loaded configuration 'C:/PathToProjectFolder/build_5/mcuboot/zephyr/.config'
    No change to configuration in 'C:/PathToProjectFolder/build_5/mcuboot/zephyr/.config'
    No change to Kconfig header in 'C:/PathToProjectFolder/build_5/mcuboot/zephyr/include/generated/autoconf.h'
    MCUBoot bootloader key file: C:/ncs/v2.5.0/bootloader/mcuboot/root-ec-p256.pem
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/PathToProjectFolder/build_5/mcuboot
    === child image mcuboot -  end ===
    
    CMake Warning at C:/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 C:/ncs/v2.5.0/zephyr/CMakeLists.txt:1958 (message):
      __ASSERT() statements are globally ENABLED
    
    
    CMake Warning at C:/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):
      C:/ncs/v2.5.0/zephyr/cmake/modules/kernel.cmake:247 (include)
      C:/ncs/v2.5.0/zephyr/cmake/modules/zephyr_default.cmake:138 (include)
      C:/ncs/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      C:/ncs/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
      CMakeLists.txt:9 (find_package)
    
    
    Dropping partition 'nrf_modem_lib_trace' since its size is 0.
    -- PM_STATIC_YML_FILE: C:/PathToProjectFolder/configuration/nrf9160dk_nrf9160_ns/pm_static.yml
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/PathToProjectFolder/build_5
    [23/27] Linking C executable bin\tfm_s.axf
    Memory region         Used Size  Region Size  %age Used
               FLASH:       31544 B      32256 B     97.79%
                 RAM:       14736 B        32 KB     44.97%
    [27/27] Linking C executable zephyr\zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:       31190 B        48 KB     63.46%
                 RAM:       16368 B        32 KB     49.95%
            IDT_LIST:          0 GB         2 KB      0.00%
    [93/109] Linking C executable zephyr\zephyr_pre0.elf
    lto-wrapper.exe: warning: using serial compilation of 3 LTRANS jobs
    lto-wrapper.exe: note: see the '-flto' option documentation for more information
    [98/107] Linking C executable zephyr\zephyr.elf
    lto-wrapper.exe: warning: using serial compilation of 3 LTRANS jobs
    lto-wrapper.exe: note: see the '-flto' option documentation for more information
    Memory region         Used Size  Region Size  %age Used
               FLASH:      360660 B       416 KB     84.67%
                 RAM:      169060 B     211608 B     79.89%
            IDT_LIST:          0 GB         2 KB      0.00%
    [102/107] Generating ../../zephyr/app_update.bin
    image.py: sign the payload
    [104/107] Generating ../../zephyr/app_signed.hex
    image.py: sign the payload
    [105/107] Generating ../../zephyr/app_test_update.hex
    image.py: sign the payload
    [107/107] Generating zephyr/merged.hex


    Top level CMakeLists:
    #
    # Copyright (c) 2021 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    cmake_minimum_required(VERSION 3.20.0)
    
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    project(myproject)
    zephyr_compile_definitions(PROJECT_NAME=${PROJECT_NAME})
    
    # Partition Manager file
    set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/configuration/${BOARD}/pm_static.yml)
    message(STATUS "PM_STATIC_YML_FILE: ${PM_STATIC_YML_FILE}")
    
    
    # NORDIC SDK APP START
    target_sources(app PRIVATE src/main.c)
    # NORDIC SDK APP END
    
    # Include source directory
    target_include_directories(app PRIVATE src)
    target_include_directories(app PRIVATE include/${BOARD}/)
    zephyr_include_directories_ifdef(CONFIG_MEMFAULT configuration/memfault)
    
    # Application directories
    add_subdirectory(src/modules)
    add_subdirectory(src/events)
    add_subdirectory(src/bma400)
    add_subdirectory(src/agps)
    add_subdirectory(src/ext_sensors)
    add_subdirectory(src/helper)
    #add_subdirectory(src/json)
    add_subdirectory(src/watchdog)
    add_subdirectory(src/cloud)
    
    if(CONFIG_ASSET_TRACKER_V2_LTO)
            target_compile_options(app PRIVATE "-flto")
    endif()

    Thanks for the help.

  • Try to set the PM_STATIC_YML_FILE earlier, above the find_package line.

    That way, the variable is set when the Partition Manager is run.

Related