Skip to content

Bring in mapped partition binding#3880

Open
nordicjm wants to merge 63 commits intonrfconnect:mainfrom
nordicjm:bringinnewmappedbinding
Open

Bring in mapped partition binding#3880
nordicjm wants to merge 63 commits intonrfconnect:mainfrom
nordicjm:bringinnewmappedbinding

Conversation

@nordicjm
Copy link
Contributor

Including reverts and pre-requisites, some commits have been converted to no-ups with permission of Shantha to avoid bringing in many commits for other vendors that have no use in NCS

manifest-pr-skip

@github-actions
Copy link

github-actions bot commented Mar 18, 2026

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
mcuboot zephyrproject-rtos/mcuboot@9ac7296 zephyrproject-rtos/mcuboot@9eac8cb zephyrproject-rtos/mcuboot@9ac72969..9eac8cb5

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@nordicjm nordicjm force-pushed the bringinnewmappedbinding branch from 9df7b84 to 7bfbb78 Compare March 18, 2026 14:12
Copy link
Contributor

@tomchy tomchy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few lines that I find suspicious. Please take a look at them as there might be some hidden bugs in this PR.


#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION)
#define PARTITION_IS_RUNNING_APP_PARTITION(label) \
DT_SAME_NODE(DT_CHOSEN(zephyr_code_partition), DT_NODELABEL(label))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of having range checks was to support merged slots (i.e. inside FW loader on multi-core devices). Since we have a copy of this file in sdk-nrf, I do not see it as a necessity to add this support in the upstream Zephyr though.

@@ -14,19 +14,18 @@

&cpuapp_rram {
partitions {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that in most place, when the fixed-partitions compatible was removed, the ranges property was added. Please double-check that indeed in this instance the ranges propagates from the board-level definitions.

reg = <0x0 DT_SIZE_K(64)>;
};

#ifdef WITH_FLPR_PARTITIONS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a little bit strange that WITH_FLPR_PARTITIONS does not define the FLPR partition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it means with allowance left for flpr partitions to be defined, they are defined in the snippet. Not that the way it's been done is all that great, but that's what has been inherited by the people that first created it


#undef DEFINE_PARTITION
#undef DEFINE_PARTITION_1
#undef DEFINE_PARTITION_0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of having definitions in lines 73, 74 and 77?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are called by the dt macros, so are needed for that, they are not needed after the macro's have been called

DT_FOREACH_STATUS_OKAY(zephyr_mapped_partition, DECLARE_MAPPED_PARTITION)

#undef DECLARE_MAPPED_PARTITION
#undef DECLARE_MAPPED_PARTITION_0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why define things to #undef them right in the next line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above, they are called by the macros

elif compat == "zephyr,mapped-partition":
parent = node.parent

while parent and "soc-nv-flash" not in parent.compats:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
while parent and "soc-nv-flash" not in parent.compats:
while parent and "soc-nv-flash" not in parent.compats and "nordic,mram" not in parent.compats:

If I correctly remember, @57300 knows the reason behind it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the mram device is being reworked so this is no longer an issue

#define DT_MEM_FROM_MAPPED_PARTITION(node_id) \
COND_CODE_1(DT_NODE_HAS_COMPAT(DT_CAT(node_id, _NVM_DEVICE), soc_nv_flash), \
(DT_CAT(node_id, _NVM_DEVICE)), \
(DT_INVALID_NODE))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(DT_INVALID_NODE))
(COND_CODE_1(DT_NODE_HAS_COMPAT(DT_CAT(node_id, _NVM_DEVICE), nordic_mram), (DT_CAT(node_id, _NVM_DEVICE)), (DT_INVALID_NODE))))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above, mram is being reworked, changes will be brought in

* @return the node identifier of the memory technology device that contains the
* zephyr,mapped-partition node.
*/
#define DT_MTD_FROM_MAPPED_PARTITION(node_id) DT_PARENT(DT_MEM_FROM_MAPPED_PARTITION(node_id))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If DT_MEM_FROM_MAPPED_PARTITION returns a reference to the *_NVM_DEVICE, why there is still a need to call DT_PARENT(..) to get the MTD?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mem is the memory node, the parent is memory controller node

@nordicjm nordicjm force-pushed the bringinnewmappedbinding branch 4 times, most recently from 31f25d4 to 68bef84 Compare March 23, 2026 09:26
@nordicjm nordicjm requested a review from tomchy March 24, 2026 08:01
@nordicjm nordicjm force-pushed the bringinnewmappedbinding branch 2 times, most recently from ad2b9b6 to 11bc279 Compare March 24, 2026 15:59
nordicjm and others added 14 commits March 25, 2026 15:17
…s file

Removes wrongly including an nRF52840 partition file from an
nRF52832 board

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 20fda0c)
Adds a binding which is used to specify memory mapped NVM
partitions, this offers much simpler understanding than the
existing fixed-partitions compatible and vastly simplifies build
system/linker logic, and also allows for multiple nested layers of
partitions without needing macros updated to parse through each
layer to find the nodes to work out the offsets to add

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 031ffad)
…ed-partitions

Adds support for outputting partition information on this new
compatible, to match fixed-partitions

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit ba68dd0)
This change introduces generating definitions corresponding to
`*-map` property, which was currently discarded.

For `*-map` properties are made able to be treated as a variation
of phandle-array, assign sequential cell names for each group of
specifiers (child_specifier_0, child_specifier_1, ...,
parent_specifier_0, ...).

The `*-map` data is like a two-dimensional array, so it is difficult to
handle with the existing APIs, so we will also provide new APIs.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
(cherry picked from commit 5979e40)
… API

Introduce a new Wakeup Controller (WUC) driver API to manage wakeup
sources in low-power scenarios. The WUC API provides a standardized
interface for enabling, disabling, checking, recording and clearing
wakeup sources that can bring a device out of low-power states.

Signed-off-by: Albort Xue <yao.xue@nxp.com>
(cherry picked from commit 0cab5de)
Adds support for this new binding with new macros, also introduces
a new PARTITION_* macro scheme which allows for using either
storage method without needing to pick one or the other, and
deprecates the previous FIXED_PARTITION_* macros

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit f8f8328)
…nitions"

This reverts commit a8cb6e2.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
…pped-partition

Adds support for using this new binding

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit a28e286)
Add tests for map property related macros.

Add `native_sim/native/64` to allowed platforms.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
(cherry picked from commit 6a53d5c)
…e handling"

This reverts commit 0bfdaab.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
…andling"

This reverts commit a1bf1cd.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
…artition handling"

This reverts commit 4cf767d.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
…n handling"

This reverts commit 276acc0.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
…on handling"

This reverts commit 8426260.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
JordanYates and others added 29 commits March 25, 2026 15:17
Add support for the PM API to the flash simulator. This enables testing
the PM behaviour of higher level libraries that use PM in CI to ensure
there are no missing/excessive calls to `pm_device_runtime_put` by the
library. For example:

```
ZTEST(library_pm, test_pm_calls)
{
    const struct device *flash = DEVICE_DT_GET_ONE();

    zassert_equal(0, pm_device_runtime_usage(flash));
    some_complex_flash_user();
    zassert_equal(0, pm_device_runtime_usage(flash));
}
```

Signed-off-by: Jordan Yates <jordan@embeint.com>
(cherry picked from commit 08f9b85)
…e capability

The simulated flash driver incorrectly applied the no_explicit_erase
capability. It was overriding Kconfig settings with a missing Devicetree
property, which caused RAM-like configurations to wrongly report needing
explicit erases before writes.

This commit fixes the initialization macro to correctly check the DT
instance property no-explicit-erase, while properly falling back to the
global CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE Kconfig.

A new runtime test is also added to properly verify this capability.

Fixes #100352
Fixes #100400

Signed-off-by: Seyoung Jeong <seyoungjeong@gmail.com>
(cherry picked from commit fa0ed03)
…-partitions

Updates these to support using this new binding whilst retaining
support for fixed-partitions

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit c086f4d)
…-partitions

Updates this to support using this new binding whilst retaining
support for fixed-partitions

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 44b2f4c)
…ions

Updates this to support using this new binding whilst retaining
support for fixed-partitions

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 1b4d81c)
Replaces usage of these deprecated macros with ones that support
fixed and mapped partition compatibles. Also includes an update to
hal_espressif which also (rightly or wrongly) has zephyr specific
code in it
This is a no-up instead which MUST BE DROPPED during the next
upmerge, this is applied as a no-up as it would bring in a mass
of commits, which are entirely irrelevant to NCS

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit f22592c)
…partitions

Changes the recently added
``CONFIG_FLASH_CODE_PARTITION_ADDRESS_INVALID`` Kconfig to
``CONFIG_FLASH_CODE_PARTITION_USING_FIXED_PARTITIONS`` which
indicates when a ``zephyr,code-partition`` chosen node has not
been updated to use the ``zephyr,mapped-partition`` binding.
This new binding substantially improves ease of build system and
partition library code as it has been designed specifically for
memory-mapped devices rather than using the Linux kernel's
``fixed-partitions`` binding, which was designed around devices
that are not memory mapped

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 1d32ca8)
The commits adds support for generating flash disks from Partition
Manager defined partitions.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
(cherry picked from commit 80eff8d)
Partition Manager (PM) is a component of the nRF Connect SDK (NCS)
which uses yaml files to resolve flash partition placement with a
holistic view of the entire device, including each firmware image
present on the flash device, and various subsystems, such as settings
and NFFS.

When this NCS extension is used, various source files which would use
partition information from devicetree in "vanilla" zephyr instead use
defines generated by PM instead.

This commit removes support for HEX_FILES_TO_MERGE, as it conflicts
with PM.

The settings subsystem pm.yml defines a partition 'settings_storage'.
The nffs subsystem pm.yml defines 'nffs_storage'.

Leverage label translation to avoid patching partition names.

Refer to the NCS documentation page for this feature for more details.

This is a long-running out of tree patch which has been worked on by
several people. The following sign-offs are in alphabetical order by
first name.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Signed-off-by: Ole Sæther <ole.saether@nordicsemi.no>
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Signed-off-by: Sigvart Hovland <sigvart.hovland@nordicsemi.no>
Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 19efc58)
Fixes wrongly using the mapped partition parts if XIP is not
enabled, when it should use RAM instead

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 294755a)
…mapped-partition

Adds support for using this new binding

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 09e73db)
…d-partition

Adds support for using this new binding

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit f75c444)
…d-partition

Adds support for using this new binding

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 8dcea32)
…ed-partition

Adds support for using this new binding

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 96137ac)
…ions

Updates the dts nodes switch partitions to use the new
zephyr,mapped-partition compatible.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit b5611a6)
…ions

Updates the dts nodes switch partitions to use the new
zephyr,mapped-partition compatible.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit ab202cd)
…ions

Updates the dts nodes switch partitions to use the new
zephyr,mapped-partition compatible.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 1a9f1b6)
…rtitions

Updates the dts nodes switch partitions to use the new
zephyr,mapped-partition compatible.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 6b34b4d)
…pped-partitions

Updates the dts nodes switch partitions to use the new
zephyr,mapped-partition compatible.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 3ac8512)
Uses the newly introduced zephyr,mapped-partition binding, as the
board has switched to using it

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit b0f647d)
…pped-partitions

Updates the dts nodes switch partitions to use the new
zephyr,mapped-partition compatible.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit cdc480a)
MRAM sizes were wrongly defined in .dtsi files and
so required updating.

Signed-off-by: Robert Robinson <robert.robinson@nordicsemi.no>
(cherry picked from commit edc6378)
…itions

Updates the dts nodes switch partitions to use the new
zephyr,mapped-partition compatible.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit e79a144)
Adds this include, which was missed in a previous commit

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit c9607b6)
Fixes a typo, from flash to rram

Upstream PR #: 106057

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
… include

Adds a missing include of base.yaml which meant some properties
were not available when using the CMake dt functions

Upstream PR #: 106061

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
…heck

Adds a missing check for CONFIG_XIP to be set to use the mapped
partition information, this was wrongly missed from here when it
was added to the other linker files

Upstream PR #: 106058

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fixes this macro when it used with a child node of a top level
fixed-subpartitions node

Upstream PR #: 106059

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fixes the logic in detecting which partition is being executed
from, also fixes a test for this feature

Upstream PR #: 106189

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
@nordicjm nordicjm force-pushed the bringinnewmappedbinding branch from 11bc279 to e94c43e Compare March 25, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.