ncs_add_partition_manager_config not working

ncs_add_partition_manager_config does not appear to be working.  I am using ncs 2.1.0 and doing a build with MCUboot.  Am I doing something wrong below?

I am using the following in a CMakeLists.txt to add a region to use for storage:

message("adding wynd_storage via pm.yml.storage")
ncs_add_partition_manager_config(pm.yml.storage)

The pm.yml.storage file containss:

wynd_storage:
  size: 0x10000
  placement:
    before: end

When I build I see the message "adding wynd_storage via pm.yml.storage", so it appears ncs_add_partition_manager_config(pm.yml.storage) is executed.  However, I don't see wynd_storage in the ninja partition_manager_report:

flash_primary (0x100000 - 1024kB):
+-------------------------------------------------+
| 0x0: mcuboot (0xc000 - 48kB) |
+---0xc000: mcuboot_primary (0x7a000 - 488kB)-----+
| 0xc000: mcuboot_pad (0x200 - 512B) |
+---0xc200: mcuboot_primary_app (0x79e00 - 487kB)-+
| 0xc200: app (0x79e00 - 487kB) |
+-------------------------------------------------+
| 0x86000: mcuboot_secondary (0x7a000 - 488kB) |
+-------------------------------------------------+

sram_primary (0x40000 - 256kB):
+--------------------------------------------+
| 0x20000000: sram_primary (0x40000 - 256kB) |
+--------------------------------------------+

  • Hi,

    Thank you for clarifying. Then I agree that ncs_add_partition_manager_config() is the correct solution, but you cannot use it in the application CMakeLists.txt.

    Instead, you must create your pm.yml.storage file under nrf/subsys/partition_manager, and then add your partition manager configuration file in partition manager's CMakeLists.txt as is done for other subsystems. See https://github.com/nrfconnect/sdk-nrf/blob/v2.1.0/subsys/partition_manager/CMakeLists.txt#L49.

    Best regards,

    Marte

  • I want to be able to build as a freestanding application, not a workspace application.  Having to maintain a modified nRF Connect SDK is not desirable (for most people I would think).

    I think ncs_add_partition_manager_config or something equivalent should be supported for out of tree use.

  • We have the same problem on our project (out-of-tree project, need to add a dynamic partition). The current design of partition manager is unnecessarily shortsighted in this regard. One cannot add to a dynamic partition via a pm_static.yml file, and one cannot add to a dynamic partition using ncs_add_partition_manager_config() in an out-of-tree project.

    A reasonable fix for this would be for the partition manager machinery to look for something like a `pm_config.cmake` or `pm_config_<board>.cmake'. The subsys/partition_manager/CMakeLists.txt would then include any such files before processing the list of partition manager configurations. An out-of-tree project could then add a call to ncs_add_partition_manager_config() in their local `pm_config.cmake`.

  • Actually the problem is in availability of ncs_add_partition_manager_config() in particular place in CMakeFiles.txt. It should be available before processing of yml files. So the workaround is to copy definition of this function into CMakeFiles.txt and place it and call it before find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}). This way we get PM_SUBSYS_PATHS defined before Zephyr scripts are run.

  • Great suggestion, thank you! I ran into the same problem, and this was the only way I could find to add dynamic partitions in a standalone project without modifying the SDK:

    ...


    # This is a hack to work around ncs_add_partition_manager_config() behavior
    # Without this, we have to modify the partition manager subsystem in
    # github.com/.../CMakeLists.txt
    # to add a custom partition.
    # See discussion here:
    # devzone.nordicsemi.com/.../ncs_add_partition_manager_config-not-working
    function(my_ncs_add_partition_manager_config config_file)
    get_filename_component(pm_path ${config_file} REALPATH)
    get_filename_component(pm_filename ${config_file} NAME)

    if (NOT EXISTS ${pm_path})
    message(FATAL_ERROR
    "Could not find specified partition manager configuration file "
    "${config_file} at ${pm_path}"
    )
    endif()

    set_property(GLOBAL APPEND PROPERTY
    PM_SUBSYS_PATHS
    ${pm_path}
    )
    set_property(GLOBAL APPEND PROPERTY
    PM_SUBSYS_OUTPUT_PATHS
    ${CMAKE_CURRENT_BINARY_DIR}/${pm_filename}
    )
    endfunction()

    my_ncs_add_partition_manager_config(pm.yml.flash_audio_buffer)

    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})

    ...
Related