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) |
+--------------------------------------------+

Parents Reply
  • 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.

Children
  • 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