From c4a7482ab81e102450b90a06c67f2529f2cbca06 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Tue, 24 Feb 2026 12:40:32 +0000 Subject: [PATCH 01/63] [nrf fromtree] boards: holyiot: yj16019: Remove wrong include from dts file Removes wrongly including an nRF52840 partition file from an nRF52832 board Signed-off-by: Jamie McCrae (cherry picked from commit 20fda0cba9a47675d8cf86659b86ac57ce2b13fc) --- boards/holyiot/yj16019/holyiot_yj16019.dts | 1 - 1 file changed, 1 deletion(-) diff --git a/boards/holyiot/yj16019/holyiot_yj16019.dts b/boards/holyiot/yj16019/holyiot_yj16019.dts index e97ae44c7536..561f394f1a10 100644 --- a/boards/holyiot/yj16019/holyiot_yj16019.dts +++ b/boards/holyiot/yj16019/holyiot_yj16019.dts @@ -6,7 +6,6 @@ /dts-v1/; #include -#include #include "holyiot_yj16019-pinctrl.dtsi" #include From f4f29fdecfb0d54f3657e03de00449c1132680ea Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Mon, 23 Feb 2026 11:38:31 +0000 Subject: [PATCH 02/63] [nrf fromtree] dts: bindings: Add zephyr,mapped-partition binding 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 (cherry picked from commit 031ffadedda090e154bcecc0145a894aebc4da59) --- dts/bindings/mtd/zephyr,mapped-partition.yaml | 149 ++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 dts/bindings/mtd/zephyr,mapped-partition.yaml diff --git a/dts/bindings/mtd/zephyr,mapped-partition.yaml b/dts/bindings/mtd/zephyr,mapped-partition.yaml new file mode 100644 index 000000000000..eb7f351a7c04 --- /dev/null +++ b/dts/bindings/mtd/zephyr,mapped-partition.yaml @@ -0,0 +1,149 @@ +description: | + Memory-mapped partition of a flash (or other non-volatile storage) memory. + + The `zephyr,mapped-partition` node should be (descendant) children of the NVM memory node, either + directly or through intermediatory grouping child nodes or through parent + `zephyr,mapped-partition` nodes. Note that the NVM memory node and NVM controller nodes must have + `ranges` properties to indicate that they are all part of the SoC's address space which specify + the full range of the NVM area (usually the same as the `reg` property with a 0x0 prepended + before the offset value). Nested `zephyr,mapped-partition` nodes are supported, and should have + `ranges` properties set to indicate their range to their child nodes. + +compatible: "zephyr,mapped-partition" + +include: base.yaml + +properties: + "#address-cells": + type: int + description: | + Number of cells required to represent a child node's reg property address. This must be + large enough to represent the start offset of each partition. + + "#size-cells": + type: int + description: | + Number of cells required to represent a child node's reg property address. This must be + large enough to represent the size of each partition in bytes. + + label: + type: string + description: Human readable string describing the NVM partition. + + read-only: + type: boolean + description: Set this property if the partition is read-only + + reg: + type: array + required: true + description: | + This should be in the format , where OFFSET is the offset of the flash + partition relative to the base address of the parent memory, and SIZE is the size of the + partition in bytes. + +examples: + - | + /* + * The NVM controller node defines the ranges which map the NVM memory nodes to the CPU address + * space. + */ + flash_controller: flash-controller@4001e000 { + compatible = "vnd,flash-controller" + reg = <0x4001e000 0x1000> + ranges; + #address-cells = <1>; + #size-cells = <1>; + + /* + * An NVM memory node describes a consecutive block of non volatile physical memory. + * Partitions are added to the this node, adhering to physical limitations like + * write-block-size. An empty `ranges;` property is required to ensure any partition + * added to the NVM memory is mapped correctly to the CPU address space, and a + * nodelabel should be defined make it easier for applications to add add partitions + * to the NVM memory node. + */ + flash0: flash@0 { + compatible = "soc-nv-flash" + reg = <0x0 DT_SIZE_K(1024)>; + ranges = <0x0 0x0 DT_SIZE_K(1024)> + #address-cells = <1>; + #size-cells = <1>; + + /* + * The 'partitions' grouping is optional, it allows for clearing all partitions + * in a device (e.g. using a dtc overlay file) but is not required. If used, + * then it needs a `ranges;` property and to specify the #address-cells and + * #size-cells properties + */ + partitions { + ranges; + #address-cells = <1>; + #size-cells = <1>; + + /* + * Offsets are relative to the flash0 node, if flash0 had an address of + * 0x10000000 then the below offset of 0x0 means address 0x10000000 + */ + boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; + label = "mcuboot"; + reg = <0x0 0xc000>; + }; + + slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; + label = "image-0"; + reg = <0xc000 0x76000>; + }; + + slot1_partition: partition@82000 { + compatible = "zephyr,mapped-partition"; + label = "image-1"; + reg = <0x82000 0x76000>; + }; + + /* + * Below example disables an NVM partition, if using the flash map + * subsystem with the default mappings then the below partition will + * not be present in the flash map + */ + storage_partition: partition@f8000 { + compatible = "zephyr,mapped-partition"; + label = "storage"; + reg = <0xf8000 0x8000>; + status = "disabled"; + }; + }; + }; + + flash1: flash@10000000 { + compatible = "soc-nv-flash" + reg = <0x10000000 DT_SIZE_K(256)>; + ranges = <0x0 0x10000000 DT_SIZE_K(256)>; + #address-cells = <1>; + #size-cells = <1>; + + /* + * Below demonstrates usage without partitions {}; grouping, and demos + * partitions inside of a parent partition + */ + external_partition: partition@0 { + compatible = "zephyr,mapped-partition"; + reg = <0x0 0x10000>; + ranges = <0x0 0x0 0x10000>; + #address-cells = <1>; + #size-cells = <1>; + + external_inner_a_partition: partition@0 { + compatible = "zephyr,mapped-partition"; + reg = <0x0 0x6000>; + }; + + external_inner_b_partition: partition@6000 { + compatible = "zephyr,mapped-partition"; + reg = <0x6000 0xa000>; + }; + }; + }; + }; From e2e64bf0196a6c81c2d11b5f65f6f6c1daf1def7 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Mon, 23 Feb 2026 11:41:34 +0000 Subject: [PATCH 03/63] [nrf fromtree] scripts: dts: gen_defines: Add support for zephyr,mapped-partitions Adds support for outputting partition information on this new compatible, to match fixed-partitions Signed-off-by: Jamie McCrae (cherry picked from commit ba68dd026f00950e5c32ab6a71cb74c0b859499e) --- scripts/dts/gen_defines.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/scripts/dts/gen_defines.py b/scripts/dts/gen_defines.py index 94c6d0e085ac..5e1345859c62 100755 --- a/scripts/dts/gen_defines.py +++ b/scripts/dts/gen_defines.py @@ -286,7 +286,7 @@ def write_special_props(node: edtlib.Node) -> None: # Macros that are special to bindings inherited from Linux, which # we can't capture with the current bindings language. write_pinctrls(node) - write_fixed_partitions(node) + write_partition_data(node) write_gpio_hogs(node) @@ -564,10 +564,12 @@ def write_pinctrls(node: edtlib.Node) -> None: f"DT_{ph.z_path_id}") -def write_fixed_partitions(node: edtlib.Node) -> None: - # Macros for child nodes of each fixed-partitions node. +def write_partition_data(node: edtlib.Node) -> None: + # Macros for partition nodes (fixed-partitions, fixed-subpartitions, zephyr,mapped-partition) - if not (node.parent and ("fixed-partitions" in node.parent.compats or "fixed-subpartitions" in node.parent.compats)): + if not (node.parent and ("fixed-partitions" in node.parent.compats or + "zephyr,mapped-partition" in node.compats or + "fixed-subpartitions" in node.parent.compats)): return global flash_area_num @@ -998,6 +1000,25 @@ def write_global_macros(edt: edtlib.EDT): out_dt_define(macro, val) out_dt_define(macro + "_EXISTS", 1) + elif compat == "zephyr,mapped-partition": + parent = node.parent + + while parent and "soc-nv-flash" not in parent.compats: + parent = parent.parent + + if not parent: + err(f"zephyr,mapped-partition node lacks soc-nv-flash parent: {node.path}") + + out_comment("parent NVM identifier:") + out_dt_define(f"{node.z_path_id}_NVM_DEVICE", f"DT_{parent.z_path_id}") + + if "label" in node.props: + label = node.props["label"].val + macro = f"COMPAT_{str2ident(compat)}_LABEL_{str2ident(label)}" + val = f"DT_{node.z_path_id}" + + out_dt_define(macro, val) + out_dt_define(macro + "_EXISTS", 1) out_comment('Macros for compatibles with status "okay" nodes\n') for compat, okay_nodes in edt.compat2okay.items(): From 1ce7879870dd41bc9a6d60bb6898f32b752fd804 Mon Sep 17 00:00:00 2001 From: TOKITA Hiroshi Date: Sun, 23 Mar 2025 20:07:55 +0900 Subject: [PATCH 04/63] [nrf fromtree] scripts: dts: Add handling for `*-map` property 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 (cherry picked from commit 5979e40d32662c64dc847e50c02937688ff459e8) --- doc/build/dts/macros.bnf | 67 +++ include/zephyr/devicetree.h | 1 + include/zephyr/devicetree/map.h | 457 ++++++++++++++++++ scripts/dts/gen_defines.py | 68 +++ .../src/devicetree/edtlib.py | 151 ++++++ 5 files changed, 744 insertions(+) create mode 100644 include/zephyr/devicetree/map.h mode change 100755 => 100644 scripts/dts/gen_defines.py diff --git a/doc/build/dts/macros.bnf b/doc/build/dts/macros.bnf index 75bb431ecbb1..f02461c32822 100644 --- a/doc/build/dts/macros.bnf +++ b/doc/build/dts/macros.bnf @@ -22,6 +22,8 @@ node-macro = property-macro node-macro =/ pinctrl-macro ; A macro about the GPIO hog properties in a node. node-macro =/ gpiohogs-macro +; A macro about the map properties in a node. +node-macro =/ map-macro ; EXISTS macro: node exists in the devicetree node-macro =/ %s"DT_N" path-id %s"_EXISTS" ; Bus macros: the plain BUS is a way to access a node's bus controller. @@ -233,6 +235,71 @@ gpiohogs-macro =/ %s"DT_N" path-id %s"_GPIO_HOGS_IDX_" DIGIT %s"_VAL_flags_EXIST ; #define DT_N__GPIO_HOGS_IDX_0_VAL_flags 0x30 gpiohogs-macro =/ %s"DT_N" path-id %s"_GPIO_HOGS_IDX_" DIGIT %s"_VAL_flags" + +; -------------------------------------------------------------------- +; map-macro: a macro related to map properties +; +; Macros are generated when there is a property ending with '-map' as shown below. +; +; connector { +; ... +; interrupt-map = <0 1 &intc0 2 3>; +; }; +; +; The existence of map entry; +; +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_EXISTS 1 +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_EXISTS" +; +; The child address length, value, and existence. +; +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_CHILD_ADDRESS_LEN 1 +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_CHILD_ADDRESS_IDX_0 0 +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_CHILD_ADDRESS_IDX_0_EXISTS 1 +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_CHILD_ADDRESS_LEN" +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_CHILD_ADDRESS_IDX_" DIGIT +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_CHILD_ADDRESS_IDX_" DIGIT %s"_EXISTS" +; +; The length of child specifiers length, value, and existence. +; +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_CHILD_SPECIFIER_LEN 1 +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_CHILD_SPECIFIER_IDX_0_EXISTS 1 +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_CHILD_SPECIFIER_IDX_0 0 +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_CHILD_SPECIFIER_LEN" +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_CHILD_SPECIFIER_IDX_" DIGIT +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_CHILD_SPECIFIER_IDX_" DIGIT %s"_EXISTS" +; +; The parent node of this map. +; +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT DT_N_S_gpio_emul +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT" +; +; The length of parent address, value, and existence. +; +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT_ADDRESS_LEN 1 +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT_ADDRESS_IDX_0 2 +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT_ADDRESS_IDX_0_EXISTS 1 +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT_ADDRESS_LEN" +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT_ADDRESS_IDX_" DIGIT +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT_ADDRESS_IDX_" DIGIT %s"_EXISTS" +; +; The length of parent specifiers length, value, and existence. +; +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT_SPECIFIER_LEN 1 +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT_SPECIFIER_IDX_0_EXISTS 1 +; #define DT_N_S_connector_P_interrupt_map_MAP_ENTRY_0_PARENT_SPECIFIER_IDX_0 3 +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT_SPECIFIER_LEN" +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT_SPECIFIER_IDX_" DIGIT +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_MAP_ENTRY_" DIGIT %s"_PARENT_SPECIFIER_IDX_" DIGIT %s"_EXISTS" +; +; Iteration helpers for map. +; +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_FOREACH_MAP_ENTRY" +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_FOREACH_MAP_ENTRY_SEP" +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_FOREACH_MAP_ENTRY_VARGS" +map-macro =/ %s"DT_N" path-id %s"_P_" prop-id %s"_FOREACH_MAP_ENTRY_SEP_VARGS" + + ; -------------------------------------------------------------------- ; property-macro: a macro related to a node property ; diff --git a/include/zephyr/devicetree.h b/include/zephyr/devicetree.h index 497822f6cfc6..11ba4a61d6b8 100644 --- a/include/zephyr/devicetree.h +++ b/include/zephyr/devicetree.h @@ -5694,5 +5694,6 @@ #include #include #include +#include #endif /* ZEPHYR_INCLUDE_DEVICETREE_H_ */ diff --git a/include/zephyr/devicetree/map.h b/include/zephyr/devicetree/map.h new file mode 100644 index 000000000000..6560b3a223db --- /dev/null +++ b/include/zephyr/devicetree/map.h @@ -0,0 +1,457 @@ +/* + * Copyright (c) 2025 TOKITA Hiroshi + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_DEVICETREE_MAP_H_ +#define ZEPHYR_INCLUDE_DEVICETREE_MAP_H_ + +/** + * @file + * @brief Map devicetree macro public API header file. + * + * This module provides helper macros that facilitate interrupt mapping and + * specifier mapping based on DeviceTree specifications. It enables the extraction + * and interpretation of mapping data represented as phandle-arrays. + * + * In a typical DeviceTree fragment, properties ending with "-map" specify: + * - The child specifier to be mapped. + * - The parent node (phandle) to which the mapping applies. + * - The parent specifier associated with the mapping. + * + * For example, when the following DeviceTree snippet is defined: + * + * @code{.dts} + * n: node { + * gpio-map = <0 1 &gpio0 2 3>, <4 5 &gpio0 6 7>; + * }; + * @endcode + * + * In the first mapping entry: + * - `0 1` are the child specifiers. + * - &gpio0 is the parent node. + * - `2 3` are the parent specifiers. + * + * The map API provides the following macros for access to specific parts of a mapping entry: + * - DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX() + * - DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX() + * - DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX() + * - DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX() + * - DT_MAP_ENTRY_PARENT_BY_IDX() + * + * These macros extract, respectively, the child specifier arguments, the parent specifier + * arguments, and the parent node argument from a mapping element identified by its node ID, + * property name, and index. + * + * For instance: + * + * @code{.c} + * #define SRC_AND_DST(node_id, map, entry_idx) \ + * { DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(node_id, map, entry_idx, 0), \ + * DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(node_id, map, entry_idx, 0) } + * + * int src_and_dst[][2] = { + * DT_FOREACH_MAP_ENTRY_SEP(DT_NODELABEL(n), gpio_map, SRC_AND_DST, (,)) + * }; + * @endcode + * + * The above expansion yields: + * + * @code{.c} + * int src_and_dst[][2] = {{0, 2}, {4, 6}}; + * @endcode + * + */ + +/** + * @defgroup devicetree-map Map helpers + * @ingroup devicetree + * @{ + */ + +/** + * @brief Returns the existence of map property. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @retval True if the map exists, otherwise 0. + * + * @see DT_NODE_HAS_PROP + */ +#define DT_NODE_HAS_MAP(node_id, prop) DT_NODE_HAS_PROP(node_id, prop) + +/** + * @brief Returns the number of maps for the given property. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @return The total count of mapping entries. + * + * @see DT_PROP_LEN + */ +#define DT_MAP_LEN(node_id, prop) DT_PROP_LEN(node_id, prop) + +/** + * @brief Is index @p idx valid for an array type property? + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx index to check + * @return An expression which evaluates to 1 if @p idx is a valid index + * into the given property, and 0 otherwise. + */ +#define DT_MAP_HAS_ENTRY_BY_IDX(node_id, prop, entry_idx) \ + IS_ENABLED(DT_CAT6(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _EXISTS)) + +/** + * @brief Checks if the map property has any entries. + * + * Equivalent to calling @ref DT_MAP_HAS_ENTRY_BY_IDX with @p entry_idx set to + * zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @return An expression which evaluates to 1 if @p idx is a valid index + * into the given property, and 0 otherwise. + */ +#define DT_MAP_HAS_ENTRY(node_id, prop) DT_MAP_HAS_ENTRY_BY_IDX(node_id, prop, 0) + +/** + * @brief Get the number of child addresses. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @return The number of child addresses. + */ +#define DT_MAP_ENTRY_CHILD_ADDRESS_LEN(node_id, prop, entry_idx) \ + DT_CAT6(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _CHILD_ADDRESS_LEN) + +/** + * @brief Checks if the child address has the specified index. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @param param_idx The index in the child addresses. + * @retval True if the child address has the index, otherwise 0. + */ +#define DT_MAP_ENTRY_HAS_CHILD_ADDRESS_BY_IDX(node_id, prop, entry_idx, param_idx) \ + IS_ENABLED(DT_CAT8(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _CHILD_ADDRESS_IDX_, \ + param_idx, _EXISTS)) + +/** + * @brief Checks if the mapping entry has any child addresses. + * + * Equivalent to calling @ref DT_MAP_ENTRY_HAS_CHILD_ADDRESS_BY_IDX with + * @p param_idx set to zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @retval True if the child address has the index, otherwise 0. + */ +#define DT_MAP_ENTRY_HAS_CHILD_ADDRESS(node_id, prop, entry_idx) \ + DT_MAP_ENTRY_HAS_CHILD_ADDRESS_BY_IDX(node_id, prop, entry_idx, 0) + +/** + * @brief Get the child address element from a mapping entry, by index. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @param param_idx The index in the child addresses. + * @return The element of the specified position of the child addresses. + */ +#define DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(node_id, prop, entry_idx, param_idx) \ + DT_CAT7(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _CHILD_ADDRESS_IDX_, param_idx) + +/** + * @brief Get the first child address element from a mapping entry. + * + * Equivalent to calling @ref DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX with + * @p param_idx set to zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @return The element of the specified position of the child addresses. + */ +#define DT_MAP_ENTRY_CHILD_ADDRESS(node_id, prop, entry_idx) \ + DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(node_id, prop, entry_idx, 0) + +/** + * @brief Get the number of child specifiers. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @return The number of child specifiers. + */ +#define DT_MAP_ENTRY_CHILD_SPECIFIER_LEN(node_id, prop, entry_idx) \ + DT_CAT6(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _CHILD_SPECIFIER_LEN) + +/** + * @brief Checks if the child specifier has the specified index. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @param param_idx The index in the child specifiers. + * @retval True if the child specifier has the index, otherwise 0. + */ +#define DT_MAP_ENTRY_HAS_CHILD_SPECIFIER_BY_IDX(node_id, prop, entry_idx, param_idx) \ + IS_ENABLED(DT_CAT8(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _CHILD_SPECIFIER_IDX_, \ + param_idx, _EXISTS)) + +/** + * @brief Checks if the mapping entry has any child specifiers. + * + * Equivalent to calling @ref DT_MAP_ENTRY_HAS_CHILD_SPECIFIER_BY_IDX with + * @p param_idx set to zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @retval True if the child specifier has the index, otherwise 0. + */ +#define DT_MAP_ENTRY_HAS_CHILD_SPECIFIER(node_id, prop, entry_idx) \ + DT_MAP_ENTRY_HAS_CHILD_SPECIFIER_BY_IDX(node_id, prop, entry_idx, 0) + +/** + * @brief Get the child specifier element from a mapping entry, by index. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @param param_idx The index in the child specifiers. + * @return The element of the specified position of the child specifiers. + */ +#define DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(node_id, prop, entry_idx, param_idx) \ + DT_CAT7(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _CHILD_SPECIFIER_IDX_, param_idx) + +/** + * @brief Get the first child specifier element from a mapping entry. + * + * Equivalent to calling @ref DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX with + * @p param_idx set to zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @return The element of the specified position of the child specifiers. + */ +#define DT_MAP_ENTRY_CHILD_SPECIFIER(node_id, prop, entry_idx) \ + DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(node_id, prop, entry_idx, 0) + +/** + * @brief Extracts the parent node from a mapping entry. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @return The parent node id. + */ +#define DT_MAP_ENTRY_PARENT_BY_IDX(node_id, prop, entry_idx) \ + DT_CAT6(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _PARENT) + +/** + * @brief Extracts the parent node from the first mapping entry. + * + * Equivalent to calling @ref DT_MAP_ENTRY_PARENT_BY_IDX with @p entry_idx set + * to zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @return The parent node id. + */ +#define DT_MAP_ENTRY_PARENT(node_id, prop) \ + DT_MAP_ENTRY_PARENT_BY_IDX(node_id, prop, 0) + +/** + * @brief Get the number of parent addresses. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @return The number of parent addresses. + */ +#define DT_MAP_ENTRY_PARENT_ADDRESS_LEN(node_id, prop, entry_idx) \ + DT_CAT6(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _PARENT_ADDRESS_LEN) + +/** + * @brief Checks if the parent address has the specified index. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @param param_idx The index in the parent addresses. + * @retval True if the parent address has the index, otherwise 0. + */ +#define DT_MAP_ENTRY_HAS_PARENT_ADDRESS_BY_IDX(node_id, prop, entry_idx, param_idx) \ + IS_ENABLED(DT_CAT8(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _PARENT_ADDRESS_IDX_, \ + param_idx, _EXISTS)) + +/** + * @brief Checks if the mapping entry has any parent addresses. + * + * Equivalent to calling @ref DT_MAP_ENTRY_HAS_PARENT_ADDRESS_BY_IDX with + * @p param_idx set to zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @retval True if the parent address has the index, otherwise 0. + */ +#define DT_MAP_ENTRY_HAS_PARENT_ADDRESS(node_id, prop, entry_idx) \ + DT_MAP_ENTRY_HAS_PARENT_ADDRESS_BY_IDX(node_id, prop, entry_idx, 0) + +/** + * @brief Get the parent address element from a mapping entry, by index. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @param param_idx The index in the parent addresses. + * @retval The element of the specified position of the parent addresses. + */ +#define DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX(node_id, prop, entry_idx, param_idx) \ + DT_CAT7(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _PARENT_ADDRESS_IDX_, param_idx) + +/** + * @brief Get the first parent address element from a mapping entry. + * + * Equivalent to calling @ref DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX with + * @p param_idx set to zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @retval The element of the specified position of the parent addresses. + */ +#define DT_MAP_ENTRY_PARENT_ADDRESS(node_id, prop, entry_idx) \ + DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX(node_id, prop, entry_idx, 0) + +/** + * @brief Get the number of parent specifiers. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @retval The number of parent specifiers. + */ +#define DT_MAP_ENTRY_PARENT_SPECIFIER_LEN(node_id, prop, entry_idx) \ + DT_CAT6(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _PARENT_SPECIFIER_LEN) + +/** + * @brief Checks if the parent specifier has the specified index. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @param param_idx The index in the parent specifiers. + * @retval True if the parent specifier has the index, otherwise 0. + */ +#define DT_MAP_ENTRY_HAS_PARENT_SPECIFIER_BY_IDX(node_id, prop, entry_idx, param_idx) \ + IS_ENABLED(DT_CAT8(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _PARENT_SPECIFIER_IDX_, \ + param_idx, _EXISTS)) + +/** + * @brief Checks if the mapping entry has any parent specifiers. + * + * Equivalent to calling @ref DT_MAP_ENTRY_HAS_PARENT_SPECIFIER_BY_IDX with + * @p param_idx set to zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @retval True if the parent specifier has the index, otherwise 0. + */ +#define DT_MAP_ENTRY_HAS_PARENT_SPECIFIER(node_id, prop, entry_idx) \ + DT_MAP_ENTRY_HAS_PARENT_SPECIFIER_BY_IDX(node_id, prop, entry_idx, 0) + +/** + * @brief Get the parent specifier element from a mapping entry, by index. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @param param_idx The index in the parent specifiers. + * @retval The element of the specified position of the parent specifiers. + */ +#define DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(node_id, prop, entry_idx, param_idx) \ + DT_CAT7(node_id, _P_, prop, _MAP_ENTRY_, entry_idx, _PARENT_SPECIFIER_IDX_, param_idx) + +/** + * @brief Get the first parent specifier element from a mapping entry. + * + * Equivalent to calling @ref DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX with + * @p param_idx set to zero. + * + * @param node_id The node identifier. + * @param prop The map property name. i.e. "gpio_map" + * @param entry_idx The mapping entry index. + * @retval The element of the specified position of the parent specifiers. + */ +#define DT_MAP_ENTRY_PARENT_SPECIFIER(node_id, prop, entry_idx) \ + DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(node_id, prop, entry_idx, 0) + +/** + * @brief Invokes @p fn for each map entry in the @p map. + * + * @param node_id node identifier + * @param prop The map property name. i.e. "gpio_map" + * @param fn macro to invoke + * + * @see DT_FOREACH_PROP_ELEM + */ +#define DT_FOREACH_MAP_ENTRY(node_id, prop, fn) DT_CAT4(node_id, _P_, prop, _FOREACH_MAP_ENTRY)(fn) + +/** + * @brief Invokes @p fn for each map entry in the @p map with separator. + * + * @param node_id node identifier + * @param prop The map property name. i.e. "gpio_map" + * @param fn macro to invoke + * @param sep Separator (e.g. comma or semicolon). Must be in parentheses; + * this is required to enable providing a comma as separator. + * + * @see DT_FOREACH_PROP_ELEM_SEP + */ +#define DT_FOREACH_MAP_ENTRY_SEP(node_id, prop, fn, sep) \ + DT_CAT4(node_id, _P_, prop, _FOREACH_MAP_ENTRY_SEP)(fn, sep) + +/** + * @brief Invokes @p fn for each map entry in the @p map with separator. + * + * @param node_id node identifier + * @param prop The map property name. i.e. "gpio_map" + * @param fn macro to invoke + * @param ... variable number of arguments to pass to fn + * + * @see DT_FOREACH_PROP_ELEM_VARGS + */ +#define DT_FOREACH_MAP_ENTRY_VARGS(node_id, prop, fn, ...) \ + DT_CAT4(node_id, _P_, prop, _FOREACH_MAP_ENTRY_VARGS)(fn, __VA_ARGS__) + +/** + * @brief Invokes @p fn for each map entry in the @p map with separator. + * + * @param node_id node identifier + * @param prop The map property name. i.e. "gpio_map" + * @param fn macro to invoke + * @param sep Separator (e.g. comma or semicolon). Must be in parentheses; + * this is required to enable providing a comma as separator. + * @param ... variable number of arguments to pass to fn + * + * @see DT_FOREACH_PROP_ELEM_SEP_VARGS + */ +#define DT_FOREACH_MAP_ENTRY_SEP_VARGS(node_id, prop, fn, sep, ...) \ + DT_CAT4(node_id, _P_, prop, _FOREACH_MAP_ENTRY_SEP_VARGS)(fn, sep, __VA_ARGS__) + +/** + * @} + */ + +#endif /* ZEPHYR_INCLUDE_DEVICETREE_MAP_H_ */ diff --git a/scripts/dts/gen_defines.py b/scripts/dts/gen_defines.py old mode 100755 new mode 100644 index 5e1345859c62..446a5d79e3e4 --- a/scripts/dts/gen_defines.py +++ b/scripts/dts/gen_defines.py @@ -288,6 +288,7 @@ def write_special_props(node: edtlib.Node) -> None: write_pinctrls(node) write_partition_data(node) write_gpio_hogs(node) + write_maps(node) def write_ranges(node: edtlib.Node) -> None: @@ -594,6 +595,73 @@ def write_gpio_hogs(node: edtlib.Node) -> None: out_dt_define(macro, val) +def write_maps(node: edtlib.Node) -> None: + if len(node.maps.keys()) == 0: + return + + out_comment("Map properties:") + + macro2val = {} + + for bn, entries in node.maps.items(): + basename = str2ident(bn) + plen = len(entries) + prop_id = f"{basename}_map" + macro = f"{node.z_path_id}_P_{basename}_map" + + # _LEN and _EXISTS share the grammar with `prop` element. + + macro2val[f"{macro}_LEN"] = plen + macro2val[f"{macro}_EXISTS"] = 1 + + # Map node specific definitions + for i, mp in enumerate(entries): + macro2val[f"{macro}_MAP_ENTRY_{i}_EXISTS"] = 1 + + macro2val[f"{macro}_MAP_ENTRY_{i}_CHILD_ADDRESS_LEN"] = len(mp.child_addresses) + for n, addr in enumerate(mp.child_addresses): + macro2val[f"{macro}_MAP_ENTRY_{i}_CHILD_ADDRESS_IDX_{n}_EXISTS"] = 1 + macro2val[f"{macro}_MAP_ENTRY_{i}_CHILD_ADDRESS_IDX_{n}"] = addr + + macro2val[f"{macro}_MAP_ENTRY_{i}_CHILD_SPECIFIER_LEN"] = len(mp.child_specifiers) + for n, sp in enumerate(mp.child_specifiers): + macro2val[f"{macro}_MAP_ENTRY_{i}_CHILD_SPECIFIER_IDX_{n}_EXISTS"] = 1 + macro2val[f"{macro}_MAP_ENTRY_{i}_CHILD_SPECIFIER_IDX_{n}"] = sp + + macro2val[f"{macro}_MAP_ENTRY_{i}_PARENT"] = "DT_" + node_z_path_id(mp.parent) + macro2val[f"{macro}_MAP_ENTRY_{i}_PARENT_ADDRESS_LEN"] = len(mp.parent_addresses) + for n, addr in enumerate(mp.parent_addresses): + macro2val[f"{macro}_MAP_ENTRY_{i}_PARENT_ADDRESS_IDX_{n}_EXISTS"] = 1 + macro2val[f"{macro}_MAP_ENTRY_{i}_PARENT_ADDRESS_IDX_{n}"] = addr + macro2val[f"{macro}_MAP_ENTRY_{i}_PARENT_SPECIFIER_LEN"] = len(mp.parent_specifiers) + for n, sp in enumerate(mp.parent_specifiers): + macro2val[f"{macro}_MAP_ENTRY_{i}_PARENT_SPECIFIER_IDX_{n}_EXISTS"] = 1 + macro2val[f"{macro}_MAP_ENTRY_{i}_PARENT_SPECIFIER_IDX_{n}"] = sp + + macro2val[f"{macro}_FOREACH_MAP_ENTRY(fn)"] = ' \\\n\t'.join( + f'fn(DT_{node.z_path_id}, {prop_id}, {i})' for i in range(plen) + ) + + macro2val[f"{macro}_FOREACH_MAP_ENTRY_SEP(fn, sep)"] = ( + ' DT_DEBRACKET_INTERNAL sep \\\n\t'.join( + f'fn(DT_{node.z_path_id}, {prop_id}, {i})' for i in range(plen) + ) + ) + + macro2val[f"{macro}_FOREACH_MAP_ENTRY_VARGS(fn, ...)"] = ' \\\n\t'.join( + f'fn(DT_{node.z_path_id}, {prop_id}, {i}, __VA_ARGS__)' for i in range(plen) + ) + + macro2val[f"{macro}_FOREACH_MAP_ENTRY_SEP_VARGS(fn, sep, ...)"] = ( + ' DT_DEBRACKET_INTERNAL sep \\\n\t'.join( + f'fn(DT_{node.z_path_id}, {prop_id}, {i}, __VA_ARGS__)' for i in range(plen) + ) + ) + + for mc, val in macro2val.items(): + out_dt_define(mc, val) + + def write_vanilla_props(node: edtlib.Node) -> None: # Writes macros for any and all properties defined in the # "properties" section of the binding for the node. diff --git a/scripts/dts/python-devicetree/src/devicetree/edtlib.py b/scripts/dts/python-devicetree/src/devicetree/edtlib.py index 8151388a6df2..c9584e1d3aa5 100644 --- a/scripts/dts/python-devicetree/src/devicetree/edtlib.py +++ b/scripts/dts/python-devicetree/src/devicetree/edtlib.py @@ -915,6 +915,55 @@ def name_as_token(self): "See the class docstring" return str_as_token(self.name) if self.name is not None else None +@dataclass +class MapEntry: + """ + Represents a single entry parsed from a ``*-map`` property. For example, + the value '<0 0 &gpio0 14 0>' from 'gpio-map = <0 0 &gpio0 14 0>, <1 0 &gpio0 0 0>;' + becomes one ``MapEntry`` instance. + + These attributes are available on ``MapEntry`` objects: + + node: + The Node instance whose property contains the map entry. + + child_addresses: + A list of integers describing the unit address portion that precedes the + child specifier. ``interrupt-map`` entries, for example, begin with the + child unit address whose length is determined by ``#address-cells`` on the + nexus node or its parent. When no address cells are defined this list is + empty. + + child_specifiers: + A list of integers read from the child side of the map entry after any + address words. These are the specifier cells that precede the parent + phandle. + + parent: + The parent Node instance. + + parent_addresses: + The unit address portion that follows the parent phandle. Its length is + derived from the parent's ``#address-cells`` (with the same parent lookup + fallback as in the devicetree specification). Empty when no address cells + are provided. + + parent_specifiers: + A list of integers describing the parent side of the mapping after any + parent address cells. These values correspond to the ``*-cells`` + definition in the parent's binding. + + basename: + The base name of the ``*-map`` property, which also describes the + specifier space for the mapping. + """ + node: 'Node' + child_addresses: list[int] + child_specifiers: list[int] + parent: 'Node' + parent_addresses: list[int] + parent_specifiers: list[int] + basename: str class Node: """ @@ -1062,6 +1111,11 @@ class Node: list is empty if the node does not hog any GPIOs. Only relevant for GPIO hog nodes. + maps: + A dictionary that contains a list of MapEntry instances associated with each string key. + The key is the basename-part of the node property name, the value is + the entries of the property value. + is_pci_device: True if the node is a PCI device. """ @@ -1334,6 +1388,103 @@ def gpio_hogs(self) -> list[ControllerAndData]: return res + @property + def maps(self) -> dict[str, list[MapEntry]]: + "See the class docstring" + + res: dict[str, list[MapEntry]] = {} + + def count_specifier_cells(node: dtlib_Node, specifier: str) -> int: + """Return the number of specifier cells for *specifier* in *node*.""" + + cells_prop = f"#{specifier}-cells" + + if cells_prop not in node.props: + _err(f"{node!r} lacks required '{cells_prop}' property") + + return node.props[cells_prop].to_num() + + def count_address_cells(node: dtlib_Node) -> int: + """Return the number of interrupt address cells for *node*.""" + + if "#address-cells" in node.props: + return node.props["#address-cells"].to_num() + + if node.parent and "#address-cells" in node.parent.props: + return node.parent.props["#address-cells"].to_num() + + return 0 + + for prop in [v for k, v in self._node.props.items() if k.endswith("-map")]: + specifier_space = prop.name[:-4] # Strip '-map' + entries: list[MapEntry] = [] + raw = prop.value + while raw: + if len(raw) < 4: + # Not enough room for phandle + _err("bad value for " + repr(prop)) + + child_address_cells = 0 + if specifier_space == "interrupt": + child_address_cells = count_address_cells(prop.node) + + child_specifier_cells = count_specifier_cells(prop.node, specifier_space) + child_total_cells = child_address_cells + child_specifier_cells + + if len(raw) < 4 * child_total_cells: + _err("bad value for " + repr(prop)) + + child_cells = to_nums(raw[: 4 * child_total_cells]) + child_addresses = child_cells[:child_address_cells] + child_specifiers = child_cells[child_address_cells:] + + raw = raw[4 * child_total_cells :] + phandle = to_num(raw[:4]) + raw = raw[4:] + + parent_node = prop.node.dt.phandle2node.get(phandle) + if parent_node is None: + _err(f"parent node cannot be found from phandle:{phandle}") + + parent: Node = self.edt._node2enode[parent_node] + if parent is None: + _err("parent cannot be found from: " + repr(parent_node)) + + parent_address_cells = 0 + if specifier_space == "interrupt": + parent_address_cells = count_address_cells(parent_node) + + parent_specifier_cells = count_specifier_cells(parent_node, specifier_space) + parent_total_cells = parent_address_cells + parent_specifier_cells + + if len(raw) < 4 * parent_total_cells: + _err("bad value for " + repr(prop)) + + parent_cells = to_nums(raw[: 4 * parent_total_cells]) + parent_addresses = parent_cells[:parent_address_cells] + parent_specifiers = parent_cells[parent_address_cells:] + + raw = raw[4 * parent_total_cells :] + + entries.append( + MapEntry( + node=self, + child_addresses=child_addresses, + child_specifiers=child_specifiers, + parent=parent, + parent_addresses=parent_addresses, + parent_specifiers=parent_specifiers, + basename=specifier_space, + ) + ) + + if len(raw) != 0: + _err(f"unexpected prop.value remaining: {raw}") + + res[specifier_space] = entries + + return res + @property def has_child_binding(self) -> bool: """ From 57b1b0a604c1a39d1b214e3ca3c6167f0960b244 Mon Sep 17 00:00:00 2001 From: Albort Xue Date: Tue, 16 Dec 2025 23:12:28 +0800 Subject: [PATCH 05/63] [nrf fromtree] drivers: wuc: introduce Wakeup Controller (WUC) driver 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 (cherry picked from commit 0cab5de544b3d9c3ff1e1a174750d06a1b56367d) --- drivers/CMakeLists.txt | 1 + drivers/Kconfig | 1 + drivers/wuc/Kconfig | 26 +++ dts/bindings/wuc/wuc-controller.yaml | 13 ++ dts/bindings/wuc/wuc-device.yaml | 11 + include/zephyr/devicetree.h | 1 + include/zephyr/devicetree/wuc.h | 209 ++++++++++++++++++ include/zephyr/drivers/wuc.h | 310 +++++++++++++++++++++++++++ 8 files changed, 572 insertions(+) create mode 100644 drivers/wuc/Kconfig create mode 100644 dts/bindings/wuc/wuc-controller.yaml create mode 100644 dts/bindings/wuc/wuc-device.yaml create mode 100644 include/zephyr/devicetree/wuc.h create mode 100644 include/zephyr/drivers/wuc.h diff --git a/drivers/CMakeLists.txt b/drivers/CMakeLists.txt index 8706f7535882..80441ece7e75 100644 --- a/drivers/CMakeLists.txt +++ b/drivers/CMakeLists.txt @@ -100,5 +100,6 @@ add_subdirectory_ifdef(CONFIG_VIRTUALIZATION virtualization) add_subdirectory_ifdef(CONFIG_W1 w1) add_subdirectory_ifdef(CONFIG_WATCHDOG watchdog) add_subdirectory_ifdef(CONFIG_WIFI wifi) +add_subdirectory_ifdef(CONFIG_WUC wuc) add_subdirectory_ifdef(CONFIG_XEN xen) # zephyr-keep-sorted-stop diff --git a/drivers/Kconfig b/drivers/Kconfig index 7b98396266b5..59aa779f7b85 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -99,6 +99,7 @@ source "drivers/virtualization/Kconfig" source "drivers/w1/Kconfig" source "drivers/watchdog/Kconfig" source "drivers/wifi/Kconfig" +source "drivers/wuc/Kconfig" source "drivers/xen/Kconfig" # zephyr-keep-sorted-stop diff --git a/drivers/wuc/Kconfig b/drivers/wuc/Kconfig new file mode 100644 index 000000000000..7e06af4094f9 --- /dev/null +++ b/drivers/wuc/Kconfig @@ -0,0 +1,26 @@ +# Copyright 2026 NXP +# SPDX-License-Identifier: Apache-2.0 + +menuconfig WUC + bool "Wakeup Controller drivers" + help + Enable wakeup controller driver configuration + +if WUC + +module = WUC +module-str = WUC +source "subsys/logging/Kconfig.template.log_config" + +config WUC_INIT_PRIORITY + int "Wakeup controller init priority" + default KERNEL_INIT_PRIORITY_DEVICE + help + Wakeup controller device driver initialization priority. + + +# zephyr-keep-sorted-start + +# zephyr-keep-sorted-stop + +endif # WAKEUP_CONTROL diff --git a/dts/bindings/wuc/wuc-controller.yaml b/dts/bindings/wuc/wuc-controller.yaml new file mode 100644 index 000000000000..314e9fb2d60c --- /dev/null +++ b/dts/bindings/wuc/wuc-controller.yaml @@ -0,0 +1,13 @@ +# Copyright 2026 NXP +# SPDX-License-Identifier: Apache-2.0 + +description: | + Common file for Wakeup Controllers + +properties: + "#wakeup-ctrl-cells": + type: int + required: true + description: | + Number of cells in wakeup-ctrls property. There must be a cell + name "id" to use. diff --git a/dts/bindings/wuc/wuc-device.yaml b/dts/bindings/wuc/wuc-device.yaml new file mode 100644 index 000000000000..c8c2cedd01a5 --- /dev/null +++ b/dts/bindings/wuc/wuc-device.yaml @@ -0,0 +1,11 @@ +# Copyright 2026 NXP +# SPDX-License-Identifier: Apache-2.0 + +description: | + Common file for wake-up source devices referencing wake up controller(s). + +properties: + wakeup-ctrls: + type: phandle-array + description: | + Phandle and wakeup source identifier of the corresponding wakeup controller. diff --git a/include/zephyr/devicetree.h b/include/zephyr/devicetree.h index 11ba4a61d6b8..6547246bb0a8 100644 --- a/include/zephyr/devicetree.h +++ b/include/zephyr/devicetree.h @@ -5695,5 +5695,6 @@ #include #include #include +#include #endif /* ZEPHYR_INCLUDE_DEVICETREE_H_ */ diff --git a/include/zephyr/devicetree/wuc.h b/include/zephyr/devicetree/wuc.h new file mode 100644 index 000000000000..1e59c475a39c --- /dev/null +++ b/include/zephyr/devicetree/wuc.h @@ -0,0 +1,209 @@ +/** + * @file + * @brief Wakeup Controller Devicetree macro public API header file. + */ + +/* + * Copyright 2026 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_DEVICETREE_WUC_H_ +#define ZEPHYR_INCLUDE_DEVICETREE_WUC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup devicetree-wakeup-controller Devicetree WUC Controller API + * @ingroup devicetree + * @ingroup wuc_interface + * @{ + */ + +/** + * @brief Get the node identifier for the controller phandle from a + * "wakeup-ctrls" phandle-array property at an index + * + * Example devicetree fragment: + * + * wuc1: wakeup-controller@... { ... }; + * + * wuc2: wakeup-controller@... { ... }; + * + * n: node { + * wakeup-ctrls = <&wuc1 10>, <&wuc2 20>; + * }; + * + * Example usage: + * + * DT_WUC_BY_IDX(DT_NODELABEL(n), 0) // DT_NODELABEL(wuc1) + * DT_WUC_BY_IDX(DT_NODELABEL(n), 1) // DT_NODELABEL(wuc2) + * + * @param node_id node identifier + * @param idx logical index into "wakeup-ctrls" + * @return the node identifier for the wakeup controller referenced at + * index "idx" + * @see DT_PHANDLE_BY_IDX() + */ +#define DT_WUC_BY_IDX(node_id, idx) DT_PHANDLE_BY_IDX(node_id, wakeup_ctrls, idx) + +/** + * @brief Equivalent to DT_WUC_BY_IDX(node_id, 0) + * @param node_id node identifier + * @return a node identifier for the wakeup controller at index 0 + * in "wakeup-ctrls" + * @see DT_WUC_BY_IDX() + */ +#define DT_WUC(node_id) DT_WUC_BY_IDX(node_id, 0) + +/** + * @brief Get a wakeup controller specifier's cell value at an index + * + * Example devicetree fragment: + * + * wuc: wakeup-controller@... { + * compatible = "vnd,wuc"; + * #wakeup-ctrl-cells = <1>; + * }; + * + * n: node { + * wakeup-ctrls = <&wuc 10>; + * }; + * + * Bindings fragment for the vnd,wuc compatible: + * + * wakeup-ctrl-cells: + * - id + * + * Example usage: + * + * DT_WUC_CELL_BY_IDX(DT_NODELABEL(n), 0, id) // 10 + * + * @param node_id node identifier for a node with a wakeup-ctrls property + * @param idx logical index into wakeup-ctrls property + * @param cell lowercase-and-underscores cell name + * @return the cell value at index "idx" + * @see DT_PHA_BY_IDX() + */ +#define DT_WUC_CELL_BY_IDX(node_id, idx, cell) DT_PHA_BY_IDX(node_id, wakeup_ctrls, idx, cell) + +/** + * @brief Equivalent to DT_WUC_CELL_BY_IDX(node_id, 0, cell) + * @param node_id node identifier for a node with a wakeup-ctrls property + * @param cell lowercase-and-underscores cell name + * @return the cell value at index 0 + * @see DT_WUC_CELL_BY_IDX() + */ +#define DT_WUC_CELL(node_id, cell) DT_WUC_CELL_BY_IDX(node_id, 0, cell) + +/** + * @brief Get the node identifier for the controller phandle from a + * "wakeup-ctrls" phandle-array property at an index + * + * @param inst instance number + * @param idx logical index into "wakeup-ctrls" + * @return the node identifier for the wakeup controller referenced at + * index "idx" + * @see DT_WUC_BY_IDX() + */ +#define DT_INST_WUC_BY_IDX(inst, idx) DT_WUC_BY_IDX(DT_DRV_INST(inst), idx) + +/** + * @brief Equivalent to DT_INST_WUC_BY_IDX(inst, 0) + * @param inst instance number + * @return a node identifier for the wakeup controller at index 0 + * in "wakeup-ctrls" + * @see DT_WUC_BY_IDX() + */ +#define DT_INST_WUC(inst) DT_INST_WUC_BY_IDX(inst, 0) + +/** + * @brief Get a DT_DRV_COMPAT instance's wakeup controller specifier's cell value + * at an index + * @param inst DT_DRV_COMPAT instance number + * @param idx logical index into wakeup-ctrls property + * @param cell lowercase-and-underscores cell name + * @return the cell value at index "idx" + * @see DT_WUC_CELL_BY_IDX() + */ +#define DT_INST_WUC_CELL_BY_IDX(inst, idx, cell) DT_WUC_CELL_BY_IDX(DT_DRV_INST(inst), idx, cell) + +/** + * @brief Equivalent to DT_INST_WUC_CELL_BY_IDX(inst, 0, cell) + * @param inst DT_DRV_COMPAT instance number + * @param cell lowercase-and-underscores cell name + * @return the value of the cell inside the specifier at index 0 + */ +#define DT_INST_WUC_CELL(inst, cell) DT_INST_WUC_CELL_BY_IDX(inst, 0, cell) + +/** + * @brief Get a Wakeup Controller specifier's id cell at an index + * + * This macro only works for Wakeup Controller specifiers with cells named "id". + * Refer to the node's binding to check if necessary. + * + * Example devicetree fragment: + * + * wuc: wakeup-controller@... { + * compatible = "vnd,wuc"; + * #wakeup-ctrl-cells = <1>; + * }; + * + * n: node { + * wakeup-ctrls = <&wuc 10>; + * }; + * + * Bindings fragment for the vnd,wuc compatible: + * + * wakeup-ctrl-cells: + * - id + * + * Example usage: + * + * DT_WUC_ID_BY_IDX(DT_NODELABEL(n), 0) // 10 + * + * @param node_id node identifier + * @param idx logical index into "wakeup-ctrls" + * @return the id cell value at index "idx" + * @see DT_PHA_BY_IDX() + */ +#define DT_WUC_ID_BY_IDX(node_id, idx) DT_PHA_BY_IDX(node_id, wakeup_ctrls, idx, id) + +/** + * @brief Equivalent to DT_WUC_ID_BY_IDX(node_id, 0) + * @param node_id node identifier + * @return the id cell value at index 0 + * @see DT_WUC_ID_BY_IDX() + */ +#define DT_WUC_ID(node_id) DT_WUC_ID_BY_IDX(node_id, 0) + +/** + * @brief Get a DT_DRV_COMPAT instance's Wakeup Controller specifier's id cell value + * at an index + * @param inst DT_DRV_COMPAT instance number + * @param idx logical index into "wakeup-ctrls" + * @return the id cell value at index "idx" + * @see DT_WUC_ID_BY_IDX() + */ +#define DT_INST_WUC_ID_BY_IDX(inst, idx) DT_WUC_ID_BY_IDX(DT_DRV_INST(inst), idx) + +/** + * @brief Equivalent to DT_INST_WUC_ID_BY_IDX(inst, 0) + * @param inst DT_DRV_COMPAT instance number + * @return the id cell value at index 0 + * @see DT_INST_WUC_ID_BY_IDX() + */ +#define DT_INST_WUC_ID(inst) DT_INST_WUC_ID_BY_IDX(inst, 0) + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_INCLUDE_DEVICETREE_WUC_H_ */ diff --git a/include/zephyr/drivers/wuc.h b/include/zephyr/drivers/wuc.h new file mode 100644 index 000000000000..d43103260865 --- /dev/null +++ b/include/zephyr/drivers/wuc.h @@ -0,0 +1,310 @@ +/* + * Copyright 2026 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file + * @ingroup wuc_interface + * @brief Main header file for WUC (Wakeup Controller) driver API. + */ + +#ifndef ZEPHYR_INCLUDE_DRIVERS_WUC_H_ +#define ZEPHYR_INCLUDE_DRIVERS_WUC_H_ + +/** + * @brief Wakeup Controller (WUC) Driver APIs + * @defgroup wuc_interface WUC + * @since 4.4 + * @version 0.1.0 + * @ingroup io_interfaces + * @{ + */ + +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** Wakeup controller device configuration. */ +struct wuc_dt_spec { + /** Wakeup controller device. */ + const struct device *dev; + /** Wakeup source identifier. */ + uint32_t id; +}; + +/** + * @brief Static initializer for a @p wuc_dt_spec + * + * This returns a static initializer for a @p wuc_dt_spec structure given a + * devicetree node identifier, a property specifying a Wakeup Controller and an index. + * + * Example devicetree fragment: + * + * n: node { + * wakeup-ctrls = <&wuc 10>; + * } + * + * Example usage: + * + * const struct wuc_dt_spec spec = WUC_DT_SPEC_GET_BY_IDX(DT_NODELABEL(n), 0); + * Initializes 'spec' to: + * { + * .dev = DEVICE_DT_GET(DT_NODELABEL(wuc)), + * .id = 10 + * } + * + * The 'wuc' field must still be checked for readiness, e.g. using + * device_is_ready(). It is an error to use this macro unless the node + * exists, has the given property, and that property specifies a wakeup + * controller wakeup source id as shown above. + * + * @param node_id devicetree node identifier + * @param idx logical index into "wakeup-ctrls" + * @return static initializer for a struct wuc_dt_spec for the property + */ +#define WUC_DT_SPEC_GET_BY_IDX(node_id, idx) \ + {.dev = DEVICE_DT_GET(DT_WUC_BY_IDX(node_id, idx)), .id = DT_WUC_ID_BY_IDX(node_id, idx)} + +/** + * @brief Like WUC_DT_SPEC_GET_BY_IDX(), with a fallback to a default value + * + * If the devicetree node identifier 'node_id' refers to a node with a + * 'wakeup-ctrls' property, this expands to + * WUC_DT_SPEC_GET_BY_IDX(node_id, idx). The @p + * default_value parameter is not expanded in this case. + * + * Otherwise, this expands to @p default_value. + * + * @param node_id devicetree node identifier + * @param idx logical index into the 'wakeup-ctrls' property + * @param default_value fallback value to expand to + * @return static initializer for a struct wuc_dt_spec for the property, + * or default_value if the node or property do not exist + */ +#define WUC_DT_SPEC_GET_BY_IDX_OR(node_id, idx, default_value) \ + COND_CODE_1(DT_NODE_HAS_PROP(node_id, wakeup_ctrls), \ + (WUC_DT_SPEC_GET_BY_IDX(node_id, idx)), \ + (default_value)) + +/** + * @brief Equivalent to WUC_DT_SPEC_GET_BY_IDX(node_id, 0). + * + * @param node_id devicetree node identifier + * @return static initializer for a struct wuc_dt_spec for the property + * @see WUC_DT_SPEC_GET_BY_IDX() + */ +#define WUC_DT_SPEC_GET(node_id) WUC_DT_SPEC_GET_BY_IDX(node_id, 0) + +/** + * @brief Equivalent to + * WUC_DT_SPEC_GET_BY_IDX_OR(node_id, 0, default_value). + * + * @param node_id devicetree node identifier + * @param default_value fallback value to expand to + * @return static initializer for a struct wuc_dt_spec for the property, + * or default_value if the node or property do not exist + */ +#define WUC_DT_SPEC_GET_OR(node_id, default_value) \ + WUC_DT_SPEC_GET_BY_IDX_OR(node_id, 0, default_value) + +/** + * @brief Static initializer for a @p wuc_dt_spec from a DT_DRV_COMPAT + * instance's Wakeup Controller property at an index. + * + * @param inst DT_DRV_COMPAT instance number + * @param idx logical index into "wakeup-ctrls" + * @return static initializer for a struct wuc_dt_spec for the property + * @see WUC_DT_SPEC_GET_BY_IDX() + */ +#define WUC_DT_SPEC_INST_GET_BY_IDX(inst, idx) WUC_DT_SPEC_GET_BY_IDX(DT_DRV_INST(inst), idx) + +/** + * @brief Static initializer for a @p wuc_dt_spec from a DT_DRV_COMPAT + * instance's 'wakeup-ctrls' property at an index, with fallback + * + * @param inst DT_DRV_COMPAT instance number + * @param idx logical index into the 'wakeup-ctrls' property + * @param default_value fallback value to expand to + * @return static initializer for a struct wuc_dt_spec for the property, + * or default_value if the node or property do not exist + */ +#define WUC_DT_SPEC_INST_GET_BY_IDX_OR(inst, idx, default_value) \ + COND_CODE_1(DT_PROP_HAS_IDX(DT_DRV_INST(inst), wakeup_ctrls, idx), \ + (WUC_DT_SPEC_GET_BY_IDX(DT_DRV_INST(inst), idx)), \ + (default_value)) + +/** + * @brief Equivalent to WUC_DT_SPEC_INST_GET_BY_IDX(inst, 0). + * + * @param inst DT_DRV_COMPAT instance number + * @return static initializer for a struct wuc_dt_spec for the property + * @see WUC_DT_SPEC_INST_GET_BY_IDX() + */ +#define WUC_DT_SPEC_INST_GET(inst) WUC_DT_SPEC_INST_GET_BY_IDX(inst, 0) + +/** + * @brief Equivalent to + * WUC_DT_SPEC_INST_GET_BY_IDX_OR(node_id, 0, default_value). + * + * @param inst DT_DRV_COMPAT instance number + * @param default_value fallback value to expand to + * @return static initializer for a struct wuc_dt_spec for the property, + * or default_value if the node or property do not exist + */ +#define WUC_DT_SPEC_INST_GET_OR(inst, default_value) \ + WUC_DT_SPEC_INST_GET_BY_IDX_OR(inst, 0, default_value) +/** + * @cond INTERNAL_HIDDEN + * + * For internal use only, skip these in public documentation. + */ +typedef int (*wuc_api_enable_wakeup_source)(const struct device *dev, uint32_t id); + +typedef int (*wuc_api_disable_wakeup_source)(const struct device *dev, uint32_t id); + +typedef int (*wuc_api_check_wakeup_source_triggered)(const struct device *dev, uint32_t id); + +typedef int (*wuc_api_clear_wakeup_source_triggered)(const struct device *dev, uint32_t id); + +__subsystem struct wuc_driver_api { + wuc_api_enable_wakeup_source enable; + wuc_api_disable_wakeup_source disable; + wuc_api_check_wakeup_source_triggered triggered; + wuc_api_clear_wakeup_source_triggered clear; +}; +/** @endcond */ + +/** + * @brief Enable a wakeup source + * + * @param dev Pointer to the WUC device structure + * @param id Wakeup source identifier + * + * @retval 0 If successful + * @retval -errno Negative errno code on failure + */ +static inline int wuc_enable_wakeup_source(const struct device *dev, uint32_t id) +{ + return DEVICE_API_GET(wuc, dev)->enable(dev, id); +} + +/** + * @brief Enable a wakeup source using a @ref wuc_dt_spec. + * + * @param spec Pointer to the WUC devicetree spec structure. + * + * @retval 0 If successful. + * @retval -errno Negative errno code on failure. + */ +static inline int wuc_enable_wakeup_source_dt(const struct wuc_dt_spec *spec) +{ + return wuc_enable_wakeup_source(spec->dev, spec->id); +} + +/** + * @brief Disable a wakeup source. + * + * @param dev Pointer to the WUC device structure. + * @param id Wakeup source identifier. + * + * @retval 0 If successful. + * @retval -errno Negative errno code on failure. + */ +static inline int wuc_disable_wakeup_source(const struct device *dev, uint32_t id) +{ + return DEVICE_API_GET(wuc, dev)->disable(dev, id); +} + +/** + * @brief Disable a wakeup source using a @ref wuc_dt_spec. + * + * @param spec Pointer to the WUC devicetree spec structure. + * + * @retval 0 If successful. + * @retval -errno Negative errno code on failure. + */ +static inline int wuc_disable_wakeup_source_dt(const struct wuc_dt_spec *spec) +{ + return wuc_disable_wakeup_source(spec->dev, spec->id); +} + +/** + * @brief Check if a wakeup source triggered. + * + * @param dev Pointer to the WUC device structure. + * @param id Wakeup source identifier. + * + * @retval 1 If wakeup was triggered by this source. + * @retval 0 If wakeup was not triggered by this source. + * @retval -errno Negative errno code on failure. + * @retval -ENOSYS if the interface is not implemented. + */ +static inline int wuc_check_wakeup_source_triggered(const struct device *dev, uint32_t id) +{ + if (DEVICE_API_GET(wuc, dev)->triggered == NULL) { + return -ENOSYS; + } + return DEVICE_API_GET(wuc, dev)->triggered(dev, id); +} + +/** + * @brief Check if a wakeup source triggered using a @ref wuc_dt_spec. + * + * @param spec Pointer to the WUC devicetree spec structure. + * + * @retval 1 If wakeup was triggered by this source. + * @retval 0 If wakeup was not triggered by this source. + * @retval -errno Negative errno code on failure. + * @retval -ENOSYS if the interface is not implemented. + */ +static inline int wuc_check_wakeup_source_triggered_dt(const struct wuc_dt_spec *spec) +{ + return wuc_check_wakeup_source_triggered(spec->dev, spec->id); +} + +/** + * @brief Clear a wakeup source triggered status. + * + * @param dev Pointer to the WUC device structure. + * @param id Wakeup source identifier. + * + * @retval 0 If successful. + * @retval -errno Negative errno code on failure. + * @retval -ENOSYS if the interface is not implemented. + */ +static inline int wuc_clear_wakeup_source_triggered(const struct device *dev, uint32_t id) +{ + if (DEVICE_API_GET(wuc, dev)->clear == NULL) { + return -ENOSYS; + } + return DEVICE_API_GET(wuc, dev)->clear(dev, id); +} + +/** + * @brief Clear a wakeup source triggered status using a @ref wuc_dt_spec. + * + * @param spec Pointer to the WUC devicetree spec structure. + * + * @retval 0 If successful. + * @retval -errno Negative errno code on failure. + * @retval -ENOSYS if the interface is not implemented. + */ +static inline int wuc_clear_wakeup_source_triggered_dt(const struct wuc_dt_spec *spec) +{ + return wuc_clear_wakeup_source_triggered(spec->dev, spec->id); +} + +#ifdef __cplusplus +} +#endif + +/** @} */ + +#endif /* ZEPHYR_INCLUDE_DRIVERS_WUC_H_ */ From ac57c50822e219150e8626a09b35fd3f39318924 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Mon, 23 Feb 2026 11:42:48 +0000 Subject: [PATCH 06/63] [nrf fromtree] storage: Add support for zephyr,mapped-partition 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 (cherry picked from commit f8f83289c00565df24f475de9617fa01eb3be26c) --- include/zephyr/devicetree.h | 1 + include/zephyr/devicetree/mapped-partition.h | 188 ++++++++++++++++++ include/zephyr/devicetree/partitions.h | 115 +++++++++++ include/zephyr/storage/flash_map.h | 195 +++++++++++++------ subsys/storage/flash_map/flash_map_default.c | 41 +++- 5 files changed, 477 insertions(+), 63 deletions(-) create mode 100644 include/zephyr/devicetree/mapped-partition.h create mode 100644 include/zephyr/devicetree/partitions.h diff --git a/include/zephyr/devicetree.h b/include/zephyr/devicetree.h index 6547246bb0a8..cafcdeaba3f6 100644 --- a/include/zephyr/devicetree.h +++ b/include/zephyr/devicetree.h @@ -5696,5 +5696,6 @@ #include #include #include +#include #endif /* ZEPHYR_INCLUDE_DEVICETREE_H_ */ diff --git a/include/zephyr/devicetree/mapped-partition.h b/include/zephyr/devicetree/mapped-partition.h new file mode 100644 index 000000000000..bb58e65c6f51 --- /dev/null +++ b/include/zephyr/devicetree/mapped-partition.h @@ -0,0 +1,188 @@ +/** + * @file + * @brief Flash Devicetree macro public API header file, for memory-mapped partitions. + */ + +/* + * Copyright (c) 2020, Linaro Ltd. + * Copyright (c) 2026 Nordic Semiconductor ASA. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_DEVICETREE_MAPPED_PARTITION_H_ +#define ZEPHYR_INCLUDE_DEVICETREE_MAPPED_PARTITION_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup devicetree-mapped-partition Devicetree Mapped Partition API + * @ingroup devicetree + * @{ + */ + +/** + * @brief Get a node identifier for a mapped partition with a given label property + * + * Example devicetree fragment: + * + * flash@... { + * reg = <0x0 0x40000>; + * ranges = <0x0 0x0 0x40000>; + * + * partitions { + * ranges; + * + * boot_partition: partition@0 { + * compatible = "zephyr,mapped-partition"; + * reg = <0x0 0xc000>; + * label = "mcuboot"; + * }; + * + * slot0_partition: partition@c000 { + * compatible = "zephyr,mapped-partition"; + * reg = <0xc000 0x18000>; + * label = "image-0"; + * }; + * + * ... + * }; + * }; + * + * Example usage: + * + * DT_NODE_BY_MAPPED_PARTITION_LABEL(mcuboot) // Node identifier for boot_partition + * DT_NODE_BY_MAPPED_PARTITION_LABEL(image_0) // Node identifier for slot0_partition + * + * @param label lowercase-and-underscores label property value. + * @return a node identifier for the partition with that label property. + */ +#define DT_NODE_BY_MAPPED_PARTITION_LABEL(label) \ + DT_CAT(DT_COMPAT_zephyr_mapped_partition_LABEL_, label) + +/** + * @brief Test if a mapped partition with a given label property exists. + * @param label lowercase-and-underscores label property value. + * @return 1 if the device has a "zephyr,mapped-partition" compatible, 0 otherwise. + */ +#define DT_HAS_MAPPED_PARTITION_LABEL(label) \ + IS_ENABLED(DT_CAT3(DT_COMPAT_zephyr_mapped_partition_LABEL_, label, _EXISTS)) + +/** + * @brief Test if zephyr,mapped-partition compatible node exists. + * + * @param node_id DTS node to test. + * @return 1 if node exists and has a zephyr,mapped-partition compatible, 0 otherwise. + */ +#define DT_MAPPED_PARTITION_EXISTS(node_id) DT_NODE_HAS_COMPAT(node_id, zephyr_mapped_partition) + +/** + * @brief Get a numeric identifier for a mapped partition. + * @param node_id node identifier for a zephyr,mapped-partition node. + * @return the partition's ID, a unique zero-based index number. + */ +#define DT_MAPPED_PARTITION_ID(node_id) DT_CAT(node_id, _PARTITION_ID) + +/** + * @brief Get the node identifier of the NVM memory for a partition. + * @param node_id node identifier for a zephyr,mapped-partition node. + * @return the node identifier of the internal memory that contains the zephyr,mapped-partition + * node, or @ref DT_INVALID_NODE if it doesn't exist. + */ +#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)) + +/** + * @brief Get the node identifier of the NVM controller for a partition. + * @param node_id node identifier for a zephyr,mapped-partition node. + * @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)) + +/** + * @brief Get the absolute address of a mapped partition + * + * Example devicetree fragment: + * + * flash@1000000 { + * compatible = "soc-nv-flash"; + * reg = <0x1000000 0x30000>; + * ranges = <0x0 0x1000000 0x30000>; + * + * partitions { + * ranges; + * + * storage_partition: partition@3a000 { + * compatible = "zephyr,mapped-partition"; + * label = "storage"; + * reg = <0x3a000 0x8000>; + * }; + * }; + * }; + * + * Here, the "storage" partition is seen to belong to flash memory starting at address 0x1000000. + * The partition's address of 0x3a000 represents an offset inside that flash memory. + * + * Example usage: + * + * DT_MAPPED_PARTITION_ADDR(DT_NODELABEL(storage_partition)) // 0x103a000 + * + * This macro can only be used with partitions of internal memory addressable by the CPU. + * Otherwise, it may produce a compile-time error, such as: `'__REG_IDX_0_VAL_ADDRESS' undeclared`. + * + * @param node_id node identifier for a zephyr,mapped-partition node + * @return the partition's unit address. + */ +#define DT_MAPPED_PARTITION_ADDR(node_id) DT_REG_ADDR(node_id) + +/** + * @brief Get the offset address of a mapped partition from the NVM node + * + * Example devicetree fragment: + * + * flash@1000000 { + * compatible = "soc-nv-flash"; + * reg = <0x1000000 0x30000>; + * ranges = <0x0 0x1000000 0x30000>; + * + * partitions { + * ranges; + * + * storage_partition: partition@3a000 { + * compatible = "zephyr,mapped-partition"; + * label = "storage"; + * reg = <0x3a000 0x8000>; + * }; + * }; + * }; + * + * Here, the "storage" partition is seen to belong to flash memory starting at address 0x1000000. + * The partition's address of 0x3a000 represents an offset inside that flash memory. + * + * Example usage: + * + * DT_MAPPED_PARTITION_OFFSET(DT_NODELABEL(storage_partition)) // 0x3a000 + * + * This macro can only be used with partitions of internal memory addressable by the CPU. + * Otherwise, it may produce a compile-time error, such as: `'__REG_IDX_0_VAL_ADDRESS' undeclared`. + * + * @param node_id node identifier for a zephyr,mapped-partition node + * @return the partition's offset from the memory device. + */ +#define DT_MAPPED_PARTITION_OFFSET(node_id) \ + (DT_REG_ADDR(node_id) - DT_REG_ADDR(DT_MEM_FROM_MAPPED_PARTITION(node_id))) + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_INCLUDE_DEVICETREE_MAPPED_PARTITION_H_ */ diff --git a/include/zephyr/devicetree/partitions.h b/include/zephyr/devicetree/partitions.h new file mode 100644 index 000000000000..34738334d604 --- /dev/null +++ b/include/zephyr/devicetree/partitions.h @@ -0,0 +1,115 @@ +/** + * @file + * @brief Flash Devicetree macro public API header file, for partitions. + */ + +/* + * Copyright (c) 2026 Nordic Semiconductor ASA. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_DEVICETREE_PARTITIONS_H_ +#define ZEPHYR_INCLUDE_DEVICETREE_PARTITIONS_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup devicetree-partition Devicetree Partition API + * @ingroup devicetree + * @{ + */ + +/** + * @brief Get a node identifier for a partition with a given label property + * + * @param label lowercase-and-underscores label property value + * @return a node identifier for the partition with that label property + */ +#define DT_NODE_BY_PARTITION_LABEL(label) \ + COND_CODE_1(DT_HAS_MAPPED_PARTITION_LABEL(label), \ + (DT_NODE_BY_MAPPED_PARTITION_LABEL(label)), \ + (DT_NODE_BY_FIXED_PARTITION_LABEL(label))) + +/** + * @brief Test if a partition with a given label property exists + * @param label lowercase-and-underscores label property value + * @return 1 if the device has a "zephyr,mapped-partition" or "fixed-subpartitions" compatible, + * or parent has a "fixed-partitions" compatible, 0 otherwise. + */ +#define DT_HAS_PARTITION_LABEL(label) \ + UTIL_OR(DT_HAS_MAPPED_PARTITION_LABEL(label), DT_HAS_FIXED_PARTITION_LABEL(label)) + +/** + * @brief Test if zephyr,mapped-partition, fixed-partitions or fixed-subpartitions compatible + * node exists + * + * @param node_id DTS node to test + * @return 1 if node exists and has a "zephyr,mapped-partition" or "fixed-subpartitions" + * compatible, or if parent has a "fixed-partitions" compatible, 0 otherwise. + */ +#define DT_PARTITION_EXISTS(node_id) \ + UTIL_OR(DT_MAPPED_PARTITION_EXISTS(node_id), \ + UTIL_OR(DT_FIXED_PARTITION_EXISTS(node_id), \ + DT_FIXED_SUBPARTITION_EXISTS(node_id))) + +/** + * @brief Get a numeric identifier for a partition + * @param node_id node identifier for a partition node + * @return the partition's ID, a unique zero-based index number + */ +#define DT_PARTITION_ID(node_id) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(node_id, zephyr_mapped_partition), \ + (DT_MAPPED_PARTITION_ID(node_id)), \ + (DT_FIXED_PARTITION_ID(node_id))) + +/** + * @brief Get the node identifier of the NVM memory for a partition + * @param node_id node identifier for a partition node + * @return the node identifier of the internal memory that contains the partition node, or + * @ref DT_INVALID_NODE if it doesn't exist. + */ +#define DT_MEM_FROM_PARTITION(node_id) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(node_id, zephyr_mapped_partition), \ + (DT_MEM_FROM_MAPPED_PARTITION(node_id)), \ + (DT_MEM_FROM_FIXED_PARTITION(node_id))) + +/** + * @brief Get the node identifier of the NVM controller for a partition + * @param node_id node identifier for a partition node + * @return the node identifier of the memory technology device that contains the partition node. + */ +#define DT_MTD_FROM_PARTITION(node_id) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(node_id, zephyr_mapped_partition), \ + (DT_MTD_FROM_MAPPED_PARTITION(node_id)), \ + (DT_MTD_FROM_FIXED_PARTITION(node_id))) + +/** + * @brief Get the absolute address of a partition + * This macro can only be used with partitions of internal memory + * addressable by the CPU. Otherwise, it may produce a compile-time + * error, such as: `'__REG_IDX_0_VAL_ADDRESS' undeclared`. + * + * @param node_id node identifier for a partition node + * @return the partition's unit address. + */ +#define DT_PARTITION_ADDR(node_id) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(node_id, zephyr_mapped_partition), \ + (DT_MAPPED_PARTITION_ADDR(node_id)), \ + (DT_FIXED_PARTITION_ADDR(node_id))) + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_INCLUDE_DEVICETREE_PARTITIONS_H_ */ diff --git a/include/zephyr/storage/flash_map.h b/include/zephyr/storage/flash_map.h index bfd86e7771f2..fe69550cd858 100644 --- a/include/zephyr/storage/flash_map.h +++ b/include/zephyr/storage/flash_map.h @@ -19,7 +19,7 @@ * * @defgroup flash_area_api flash area Interface * @since 1.11 - * @version 1.1.0 + * @version 1.1.1 * @ingroup storage_apis * @{ */ @@ -40,6 +40,9 @@ #include #include #include +#include +#include +#include #ifdef __cplusplus extern "C" { @@ -139,7 +142,7 @@ void flash_area_close(const struct flash_area *fa); * Indicates whether the provided flash area has a device known to be * in a state where it can be used with Flash Map API. * - * This can be used with struct flash_area pointers captured from FIXED_PARTITION(). + * This can be used with struct flash_area pointers captured from PARTITION(). * At minimum this means that the device has been successfully initialized. * * @param fa pointer to flash_area object to check. @@ -353,97 +356,132 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); #else /** - * Returns non-0 value if fixed-partition or fixed-subpartition of given - * DTS node label exists. + * Returns non-0 value if partition of given DTS node label exists. * * @param label DTS node label * - * @return non-0 if fixed-partition node exists and is enabled; - * 0 if node does not exist, is not enabled or is not fixed-partition. + * @return non-0 if partition node exists and is enabled; + * 0 if node does not exist, is not enabled or is not partition. */ -#define FIXED_PARTITION_EXISTS(label) \ - UTIL_OR(DT_FIXED_PARTITION_EXISTS(DT_NODELABEL(label)), \ - DT_FIXED_SUBPARTITION_EXISTS(DT_NODELABEL(label))) +#define PARTITION_EXISTS(label) DT_PARTITION_EXISTS(DT_NODELABEL(label)) /** - * Get flash area ID from fixed-partition DTS node label + * Deprecated macro, replace with PARTITION_EXISTS(), this cannot use __DEPRECATED_MACRO as it + * causes usage of the macro to fail with compiler errors + */ +#define FIXED_PARTITION_EXISTS(label) PARTITION_EXISTS(label) + +/** + * Get flash area ID from partition DTS node label * * @param label DTS node label of a partition * * @return flash area ID */ -#define FIXED_PARTITION_ID(label) DT_FIXED_PARTITION_ID(DT_NODELABEL(label)) +#define PARTITION_ID(label) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(DT_NODELABEL(label), zephyr_mapped_partition), \ + (DT_MAPPED_PARTITION_ID(DT_NODELABEL(label))), \ + (DT_FIXED_PARTITION_ID(DT_NODELABEL(label)))) + +/** Deprecated macro, replace with PARTITION_ID() */ +#define FIXED_PARTITION_ID(label) PARTITION_ID(label) __DEPRECATED_MACRO /** - * Get fixed-partition or fixed-subpartition offset from DTS node label + * Get partition offset from DTS node label * * Note: This only works from a top level ``fixed-partitions`` node, top level * ``fixed-subpartitions`` node or ``fixed-partitions`` node inside of 1 layer of a * ``fixed-subpartitions`` node, it will not work for multiple layers of ``fixed-subpartitions`` - * nodes. + * nodes, though this works on all instances of ``zephyr,mapped-partition`` nodes. * * @param label DTS node label of a partition * - * @return fixed-partition offset, as defined for the partition in DTS. + * @return offset, as defined for the partition in DTS. */ -#define FIXED_PARTITION_OFFSET(label) \ - COND_CODE_1(DT_FIXED_SUBPARTITION_EXISTS(DT_NODELABEL(label)), \ - (DT_PROP_BY_IDX(DT_PARENT(DT_NODELABEL(label)), reg, 0) + \ - DT_PROP_BY_IDX(DT_NODELABEL(label), reg, 0)), \ - (DT_PROP_BY_IDX(DT_NODELABEL(label), reg, 0))) +#define PARTITION_OFFSET(label) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(DT_NODELABEL(label), zephyr_mapped_partition), \ + (DT_MAPPED_PARTITION_OFFSET(DT_NODELABEL(label))), \ + (COND_CODE_1(DT_FIXED_SUBPARTITION_EXISTS(DT_NODELABEL(label)), \ + (DT_PROP_BY_IDX(DT_PARENT(DT_NODELABEL(label)), reg, 0) + \ + DT_PROP_BY_IDX(DT_NODELABEL(label), reg, 0)), \ + (DT_PROP_BY_IDX(DT_NODELABEL(label), reg, 0))))) + +/** Deprecated macro, replace with PARTITION_OFFSET() */ +#define FIXED_PARTITION_OFFSET(label) PARTITION_OFFSET(label) __DEPRECATED_MACRO /** - * Get fixed-partition or fixed-subpartition address from DTS node label + * Get partition address from DTS node label * - * @param label DTS node label of a partition or subpartition + * @param label DTS node label of a partition * - * @return fixed-partition address, as defined for the partition in DTS. + * @return address, as defined for the partition in DTS. */ -#define FIXED_PARTITION_ADDRESS(label) DT_REG_ADDR(DT_NODELABEL(label)) +#define PARTITION_ADDRESS(label) PARTITION_NODE_ADDRESS(DT_NODELABEL(label)) + +/** Deprecated macro, replace with PARTITION_ADDRESS() */ +#define FIXED_PARTITION_ADDRESS(label) PARTITION_ADDRESS(label) __DEPRECATED_MACRO /** - * Get fixed-partition or fixed-subpartition address from DTS node + * Get partition address from DTS node * * @param node DTS node of a partition * - * @return fixed-partition address, as defined for the partition in DTS. + * @return address, as defined for the partition in DTS. */ -#define FIXED_PARTITION_NODE_ADDRESS(node) DT_REG_ADDR(node) +#define PARTITION_NODE_ADDRESS(node) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(node, zephyr_mapped_partition), \ + (DT_MAPPED_PARTITION_ADDR(node)), \ + (DT_REG_ADDR(node))) + +/** Deprecated macro, replace with PARTITION_NODE_ADDRESS() */ +#define FIXED_PARTITION_NODE_ADDRESS(node) PARTITION_NODE_ADDRESS(node) __DEPRECATED_MACRO /** - * Get fixed-partition offset from DTS node + * Get partition offset from DTS node * * Note: This only works from a top level ``fixed-partitions`` node, top level * ``fixed-subpartitions`` node or ``fixed-partitions`` node inside of 1 layer of a * ``fixed-subpartitions`` node, it will not work for multiple layers of ``fixed-subpartitions`` - * nodes. + * nodes, though this works on all instances of ``zephyr,mapped-partition`` nodes. * * @param node DTS node of a partition * - * @return fixed-partition offset, as defined for the partition in DTS. + * @return offset, as defined for the partition in DTS. */ -#define FIXED_PARTITION_NODE_OFFSET(node) \ - COND_CODE_1(DT_FIXED_SUBPARTITION_EXISTS(node), \ - (DT_PROP_BY_IDX(DT_PARENT(node), reg, 0) + DT_PROP_BY_IDX(node, reg, 0)), \ - (DT_PROP_BY_IDX(node, reg, 0))) +#define PARTITION_NODE_OFFSET(node) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(node, zephyr_mapped_partition), \ + (DT_MAPPED_PARTITION_OFFSET(node)), \ + (COND_CODE_1(DT_FIXED_SUBPARTITION_EXISTS(node), \ + (DT_PROP_BY_IDX(DT_PARENT(node), reg, 0) + \ + DT_PROP_BY_IDX(node, reg, 0)), \ + (DT_PROP_BY_IDX(node, reg, 0))))) + +/** Deprecated macro, replace with PARTITION_NODE_OFFSET() */ +#define FIXED_PARTITION_NODE_OFFSET(label) PARTITION_NODE_OFFSET(label) __DEPRECATED_MACRO /** - * Get fixed-partition size for DTS node label + * Get partition size for DTS node label * * @param label DTS node label * - * @return fixed-partition offset, as defined for the partition in DTS. + * @return size, as defined for the partition in DTS. */ -#define FIXED_PARTITION_SIZE(label) DT_REG_SIZE(DT_NODELABEL(label)) +#define PARTITION_SIZE(label) DT_REG_SIZE(DT_NODELABEL(label)) + +/** Deprecated macro, replace with PARTITION_SIZE() */ +#define FIXED_PARTITION_SIZE(label) PARTITION_SIZE(label) __DEPRECATED_MACRO /** * Get fixed-partition size for DTS node * * @param node DTS node of a partition * - * @return fixed-partition size, as defined for the partition in DTS. + * @return size, as defined for the partition in DTS. */ -#define FIXED_PARTITION_NODE_SIZE(node) DT_REG_SIZE(node) +#define PARTITION_NODE_SIZE(node) DT_REG_SIZE(node) + +/** Deprecated macro, replace with PARTITION_NODE_SIZE() */ +#define FIXED_PARTITION_NODE_SIZE(node) PARTITION_NODE_SIZE(node) __DEPRECATED_MACRO /** * Get device pointer for device the area/partition resides on @@ -452,8 +490,12 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); * * @return const struct device type pointer */ -#define FLASH_AREA_DEVICE(label) \ - DEVICE_DT_GET(DT_MTD_FROM_FIXED_PARTITION(DT_NODE_BY_FIXED_PARTITION_LABEL(label))) +#define FLASH_AREA_DEVICE(label) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(DT_NODELABEL(label), zephyr_mapped_partition), \ + (DEVICE_DT_GET(DT_MTD_FROM_MAPPED_PARTITION( \ + DT_NODE_BY_MAPPED_PARTITION_LABEL(label)))), \ + (DEVICE_DT_GET(DT_MTD_FROM_FIXED_PARTITION( \ + DT_NODE_BY_FIXED_PARTITION_LABEL(label))))) /** * Get device pointer for device the area/partition resides on @@ -462,11 +504,11 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); * * @return Pointer to a device. */ -#define FIXED_PARTITION_DEVICE(label) \ - DEVICE_DT_GET(COND_CODE_1( \ - DT_FIXED_SUBPARTITION_EXISTS(DT_NODELABEL(label)), \ - (DT_MTD_FROM_FIXED_SUBPARTITION(DT_NODELABEL(label))), \ - (DT_MTD_FROM_FIXED_PARTITION(DT_NODELABEL(label))))) +#define PARTITION_DEVICE(label) PARTITION_NODE_DEVICE(DT_NODELABEL(label)) + +/** Deprecated macro, replace with PARTITION_DEVICE() */ +#define FIXED_PARTITION_DEVICE(label) PARTITION_DEVICE(label) __DEPRECATED_MACRO + /** * Get device pointer for device the area/partition resides on * @@ -474,11 +516,15 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); * * @return Pointer to a device. */ -#define FIXED_PARTITION_NODE_DEVICE(node) \ - DEVICE_DT_GET(COND_CODE_1( \ - DT_FIXED_SUBPARTITION_EXISTS(node), \ - (DT_MTD_FROM_FIXED_SUBPARTITION(node)), \ - (DT_MTD_FROM_FIXED_PARTITION(node)))) +#define PARTITION_NODE_DEVICE(node) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(node, zephyr_mapped_partition), \ + (DEVICE_DT_GET(DT_MTD_FROM_MAPPED_PARTITION(node))), \ + (DEVICE_DT_GET(COND_CODE_1(DT_FIXED_SUBPARTITION_EXISTS(node), \ + (DT_MTD_FROM_FIXED_SUBPARTITION(node)), \ + (DT_MTD_FROM_FIXED_PARTITION(node)))))) + +/** Deprecated macro, replace with PARTITION_NODE_DEVICE() */ +#define FIXED_PARTITION_NODE_DEVICE(node) PARTITION_NODE_DEVICE(node) __DEPRECATED_MACRO /** * Get the node identifier of the flash controller the area/partition resides on @@ -487,11 +533,10 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); * * @return Pointer to a device. */ -#define FIXED_PARTITION_MTD(label) \ - COND_CODE_1( \ - DT_FIXED_SUBPARTITION_EXISTS(DT_NODELABEL(label)), \ - (DT_MTD_FROM_FIXED_SUBPARTITION(DT_NODELABEL(label))), \ - (DT_MTD_FROM_FIXED_PARTITION(DT_NODELABEL(label)))) +#define PARTITION_MTD(label) PARTITION_NODE_MTD(DT_NODELABEL(label)) + +/** Deprecated macro, replace with PARTITION_OFFSET() */ +#define FIXED_PARTITION_MTD(label) PARTITION_MTD(label) __DEPRECATED_MACRO /** * Get the node identifier of the flash controller the area/partition resides on @@ -500,11 +545,15 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); * * @return Pointer to a device. */ -#define FIXED_PARTITION_NODE_MTD(node) \ - COND_CODE_1( \ - DT_FIXED_SUBPARTITION_EXISTS(node), \ - (DT_MTD_FROM_FIXED_SUBPARTITION(node)), \ - (DT_MTD_FROM_FIXED_PARTITION(node))) +#define PARTITION_NODE_MTD(node) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(node, zephyr_mapped_partition), \ + (DT_MTD_FROM_MAPPED_PARTITION(node)), \ + (COND_CODE_1(DT_FIXED_SUBPARTITION_EXISTS(node), \ + (DT_MTD_FROM_FIXED_SUBPARTITION(node)), \ + (DT_MTD_FROM_FIXED_PARTITION(node))))) + +/** Deprecated macro, replace with PARTITION_NODE_MTD() */ +#define FIXED_PARTITION_NODE_MTD(node) PARTITION_NODE_MTD(node) __DEPRECATED_MACRO /** * Get pointer to flash_area object by partition label @@ -513,7 +562,10 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); * * @return Pointer to flash_area type object representing partition */ -#define FIXED_PARTITION(label) FIXED_PARTITION_1(DT_NODELABEL(label)) +#define PARTITION(label) PARTITION_BY_NODE(DT_NODELABEL(label)) + +/** Deprecated macro, replace with PARTITION() */ +#define FIXED_PARTITION(label) PARTITION(label) __DEPRECATED_MACRO /** * Get pointer to flash_area object by partition node in DTS @@ -522,7 +574,13 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); * * @return Pointer to flash_area type object representing partition */ -#define FIXED_PARTITION_BY_NODE(node) FIXED_PARTITION_1(node) +#define PARTITION_BY_NODE(node) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(node, zephyr_mapped_partition), \ + (MAPPED_PARTITION_1(node)), \ + (FIXED_PARTITION_1(node))) + +/** Deprecated macro, replace with PARTITION_OFFSET() */ +#define FIXED_PARTITION_BY_NODE(node) PARTITION_BY_NODE(node) __DEPRECATED_MACRO /** @cond INTERNAL_HIDDEN */ #define FIXED_PARTITION_1(node) FIXED_PARTITION_0(DT_DEP_ORD(node)) @@ -541,6 +599,19 @@ DT_FOREACH_STATUS_OKAY(fixed_partitions, FOR_EACH_PARTITION_TABLE) #undef DECLARE_PARTITION_0 #undef FOR_EACH_PARTITION_TABLE +#define MAPPED_PARTITION_1(node) MAPPED_PARTITION_0(DT_DEP_ORD(node)) +#define MAPPED_PARTITION_0(ord) \ + ((const struct flash_area *)&DT_CAT(global_zephyr_mapped_partition_ORD_, ord)) + +#define DECLARE_MAPPED_PARTITION(node) DECLARE_MAPPED_PARTITION_0(DT_DEP_ORD(node)) +#define DECLARE_MAPPED_PARTITION_0(ord) \ + extern const struct flash_area DT_CAT(global_zephyr_mapped_partition_ORD_, ord); + +DT_FOREACH_STATUS_OKAY(zephyr_mapped_partition, DECLARE_MAPPED_PARTITION) + +#undef DECLARE_MAPPED_PARTITION +#undef DECLARE_MAPPED_PARTITION_0 + #define FIXED_SUBPARTITION_1(node) FIXED_SUBPARTITION_0(DT_DEP_ORD(node)) #define FIXED_SUBPARTITION_0(ord) \ ((const struct flash_area *)&DT_CAT(global_fixed_subpartition_ORD_, ord)) diff --git a/subsys/storage/flash_map/flash_map_default.c b/subsys/storage/flash_map/flash_map_default.c index c5ba79af2340..94069fb00653 100644 --- a/subsys/storage/flash_map/flash_map_default.c +++ b/subsys/storage/flash_map/flash_map_default.c @@ -9,6 +9,8 @@ #include #include #include +#include +#include #if CONFIG_FLASH_MAP_LABELS #define FLASH_AREA_FOO(part, mtd_from_partition) \ @@ -17,21 +19,39 @@ .fa_dev = DEVICE_DT_GET(mtd_from_partition(part)), \ .fa_size = DT_REG_SIZE(part), \ .fa_label = DT_PROP_OR(part, label, NULL), }, + +#define MAPPED_AREA(part) \ + {.fa_id = DT_MAPPED_PARTITION_ID(part), \ + .fa_off = PARTITION_NODE_OFFSET(part), \ + .fa_dev = DEVICE_DT_GET(DT_MTD_FROM_MAPPED_PARTITION(part)), \ + .fa_size = DT_REG_SIZE(part), \ + .fa_label = DT_PROP_OR(part, label, NULL), }, #else #define FLASH_AREA_FOO(part, mtd_from_partition) \ {.fa_id = DT_FIXED_PARTITION_ID(part), \ .fa_off = FIXED_PARTITION_NODE_OFFSET(part), \ .fa_dev = DEVICE_DT_GET(mtd_from_partition(part)), \ .fa_size = DT_REG_SIZE(part), }, + +#define MAPPED_AREA(part) \ + {.fa_id = DT_MAPPED_PARTITION_ID(part), \ + .fa_off = PARTITION_NODE_OFFSET(part), \ + .fa_dev = DEVICE_DT_GET(DT_MTD_FROM_MAPPED_PARTITION(part)), \ + .fa_size = DT_REG_SIZE(part), }, #endif #define FLASH_AREA_FOOO(part) \ - COND_CODE_1(DT_NODE_HAS_COMPAT(DT_PARENT(part), fixed_partitions), (\ + COND_CODE_1(DT_NODE_HAS_COMPAT(DT_PARENT(part), fixed_partitions), ( \ COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_FIXED_PARTITION(part)), \ (FLASH_AREA_FOO(part, DT_MTD_FROM_FIXED_PARTITION)), ())), ( \ COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_FIXED_SUBPARTITION(part)), \ (FLASH_AREA_FOO(part, DT_MTD_FROM_FIXED_SUBPARTITION)), ()))) +#define MAPPED_AREA_FOREACH(part) \ + COND_CODE_1(UTIL_AND(DT_NODE_HAS_STATUS_OKAY(part), \ + DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_MAPPED_PARTITION(part))), \ + (MAPPED_AREA(part)), ()) + #define FOREACH_PARTITION(n) DT_FOREACH_CHILD(n, FLASH_AREA_FOOO) /* We iterate over all compatible 'fixed-partitions' nodes and @@ -39,6 +59,7 @@ * 'fixed-partitions' node. This way we build a global partition map */ const struct flash_area default_flash_map[] = { + DT_FOREACH_STATUS_OKAY(zephyr_mapped_partition, MAPPED_AREA_FOREACH) DT_FOREACH_STATUS_OKAY(fixed_partitions, FOREACH_PARTITION) DT_FOREACH_STATUS_OKAY(fixed_subpartitions, FOREACH_PARTITION) }; @@ -49,6 +70,24 @@ const struct flash_area *flash_map = default_flash_map; /* Generate objects representing each partition in system. In the end only * objects referenced by code will be included into build. */ +#define DEFINE_PARTITION(part) DEFINE_PARTITION_1(part, DT_DEP_ORD(part)) +#define DEFINE_PARTITION_1(part, ord) \ + COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_MAPPED_PARTITION(part)), \ + (DEFINE_PARTITION_0(part, ord)), ()) +#define DEFINE_PARTITION_0(part, ord) \ + const struct flash_area DT_CAT(global_zephyr_mapped_partition_ORD_, ord) = { \ + .fa_id = DT_MAPPED_PARTITION_ID(part), \ + .fa_off = MAPPED_PARTITION_NODE_OFFSET(part), \ + .fa_dev = DEVICE_DT_GET(DT_MTD_FROM_MAPPED_PARTITION(part)), \ + .fa_size = DT_REG_SIZE(part), \ + }; + +DT_FOREACH_STATUS_OKAY(zephyr_mapped_partition, DEFINE_PARTITION) + +#undef DEFINE_PARTITION +#undef DEFINE_PARTITION_1 +#undef DEFINE_PARTITION_0 + #define DEFINE_PARTITION(part) DEFINE_PARTITION_1(part, DT_DEP_ORD(part)) #define DEFINE_PARTITION_1(part, ord) \ COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_FIXED_PARTITION(part)), \ From 93304e0da8ed28986143770d3a2757286e701ab0 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Wed, 18 Mar 2026 07:45:09 +0000 Subject: [PATCH 07/63] Revert "[nrf noup] tree-wide: support NCS Partition Manager (PM) definitions" This reverts commit a8cb6e26828c238cb4f46f81c1f45215f6a83deb. Signed-off-by: Jamie McCrae --- arch/arm/core/mpu/arm_mpu_regions.c | 13 ----- cmake/linker/ld/target.cmake | 1 - cmake/linker/lld/target.cmake | 1 - cmake/modules/kernel.cmake | 4 -- drivers/flash/soc_flash_nrf.c | 11 ---- drivers/flash/soc_flash_nrf_rram.c | 11 ---- .../arch/arm/cortex_m/scripts/linker.ld | 50 ------------------- include/zephyr/storage/flash_map.h | 6 --- lib/heap/Kconfig | 2 +- lib/libc/common/source/stdlib/malloc.c | 18 +------ subsys/dfu/boot/mcuboot_shell.c | 40 --------------- subsys/fs/littlefs_fs.c | 7 +-- subsys/ipc/rpmsg_service/rpmsg_backend.h | 27 ---------- 13 files changed, 4 insertions(+), 187 deletions(-) diff --git a/arch/arm/core/mpu/arm_mpu_regions.c b/arch/arm/core/mpu/arm_mpu_regions.c index 71c0a9a2b739..4771c5914ce6 100644 --- a/arch/arm/core/mpu/arm_mpu_regions.c +++ b/arch/arm/core/mpu/arm_mpu_regions.c @@ -8,9 +8,6 @@ #include #include -#if USE_PARTITION_MANAGER -#include -#endif #ifdef CONFIG_ARM_MPU_SRAM_WRITE_THROUGH #define ARM_MPU_SRAM_REGION_ATTR REGION_RAM_WT_ATTR @@ -33,14 +30,6 @@ static const struct arm_mpu_region mpu_regions[] = { /* Region 1 */ MPU_REGION_ENTRY("SRAM_0", -#if USE_PARTITION_MANAGER - PM_SRAM_ADDRESS, -#if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE) - REGION_RAM_ATTR(PM_SRAM_ADDRESS, PM_SRAM_SIZE)), -#else - REGION_RAM_ATTR(REGION_SRAM_SIZE)), -#endif -#else CONFIG_SRAM_BASE_ADDRESS, #if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE) ARM_MPU_SRAM_REGION_ATTR(CONFIG_SRAM_BASE_ADDRESS, @@ -48,8 +37,6 @@ static const struct arm_mpu_region mpu_regions[] = { #else ARM_MPU_SRAM_REGION_ATTR(REGION_SRAM_SIZE)), #endif - -#endif /* USE_PARTITION_MANAGER */ }; const struct arm_mpu_config mpu_config = { diff --git a/cmake/linker/ld/target.cmake b/cmake/linker/ld/target.cmake index ccf6a1903162..592596576d11 100644 --- a/cmake/linker/ld/target.cmake +++ b/cmake/linker/ld/target.cmake @@ -80,7 +80,6 @@ macro(configure_linker_script linker_script_gen linker_pass_define) ${current_includes} ${soc_linker_script_includes} ${template_script_defines} - -DUSE_PARTITION_MANAGER=$ -E ${LINKER_SCRIPT} -P # Prevent generation of debug `#line' directives. -o ${linker_script_gen} diff --git a/cmake/linker/lld/target.cmake b/cmake/linker/lld/target.cmake index fe8aad62c73d..96df1c123796 100644 --- a/cmake/linker/lld/target.cmake +++ b/cmake/linker/lld/target.cmake @@ -52,7 +52,6 @@ macro(configure_linker_script linker_script_gen linker_pass_define) -imacros ${AUTOCONF_H} ${current_includes} ${template_script_defines} - -DUSE_PARTITION_MANAGER=$ -E ${LINKER_SCRIPT} -P # Prevent generation of debug `#line' directives. -o ${linker_script_gen} diff --git a/cmake/modules/kernel.cmake b/cmake/modules/kernel.cmake index 83c3e4bcb846..af9c85d80e35 100644 --- a/cmake/modules/kernel.cmake +++ b/cmake/modules/kernel.cmake @@ -256,7 +256,3 @@ if("${CMAKE_EXTRA_GENERATOR}" STREQUAL "Eclipse CDT4") include(${ZEPHYR_BASE}/cmake/ide/eclipse_cdt4_generator_amendment.cmake) eclipse_cdt4_generator_amendment(1) endif() - -if(ZEPHYR_NRF_MODULE_DIR) - include(${ZEPHYR_NRF_MODULE_DIR}/cmake/partition_manager.cmake) -endif() diff --git a/drivers/flash/soc_flash_nrf.c b/drivers/flash/soc_flash_nrf.c index 27fda598be20..f6b8a6f5eef3 100644 --- a/drivers/flash/soc_flash_nrf.c +++ b/drivers/flash/soc_flash_nrf.c @@ -36,11 +36,6 @@ LOG_MODULE_REGISTER(flash_nrf); #define SOC_NV_FLASH_NODE DT_INST(0, soc_nv_flash) -#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER -#include -#include -#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER */ - #ifndef CONFIG_SOC_FLASH_NRF_RADIO_SYNC_NONE #define FLASH_SLOT_WRITE 7500 #if defined(CONFIG_SOC_FLASH_NRF_PARTIAL_ERASE) @@ -170,12 +165,6 @@ static int flash_nrf_read(const struct device *dev, off_t addr, } #endif -#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER && PM_APP_ADDRESS - if (addr < PM_APP_ADDRESS) { - return soc_secure_mem_read(data, (void *)addr, len); - } -#endif - nrf_nvmc_buffer_read(data, (uint32_t)addr, len); return 0; diff --git a/drivers/flash/soc_flash_nrf_rram.c b/drivers/flash/soc_flash_nrf_rram.c index 84c7e958f3cd..9f0e24dc33d5 100644 --- a/drivers/flash/soc_flash_nrf_rram.c +++ b/drivers/flash/soc_flash_nrf_rram.c @@ -54,11 +54,6 @@ LOG_MODULE_REGISTER(flash_nrf_rram, CONFIG_FLASH_LOG_LEVEL); #define WRITE_BLOCK_SIZE_FROM_DT DT_PROP(RRAM, write_block_size) #define ERASE_VALUE 0xFF -#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER -#include -#include -#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER */ - #ifdef CONFIG_MULTITHREADING static struct k_sem sem_lock; #define SYNC_INIT() k_sem_init(&sem_lock, 1, 1) @@ -297,12 +292,6 @@ static int nrf_rram_read(const struct device *dev, off_t addr, void *data, size_ } addr += RRAM_START; -#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER && PM_APP_ADDRESS - if (addr < PM_APP_ADDRESS) { - return soc_secure_mem_read(data, (void *)addr, len); - } -#endif - memcpy(data, (void *)addr, len); return 0; diff --git a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld index 82e417900ff0..288e0d0dc647 100644 --- a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld +++ b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld @@ -34,39 +34,6 @@ #define ROMSTART_REGION ROMABLE_REGION #endif -#if USE_PARTITION_MANAGER - -#include - -#if CONFIG_NCS_IS_VARIANT_IMAGE && defined(PM_S0_ID) -/* We are linking against S1, create symbol containing the flash ID of S0. - * This is used when writing code operating on the "other" slot. - */ -_image_1_primary_slot_id = PM_S0_ID; - -#else /* ! CONFIG_NCS_IS_VARIANT_IMAGE */ - -#ifdef PM_S1_ID -/* We are linking against S0, create symbol containing the flash ID of S1. - * This is used when writing code operating on the "other" slot. - */ -_image_1_primary_slot_id = PM_S1_ID; -#endif /* PM_S1_ID */ - -#endif /* CONFIG_NCS_IS_VARIANT_IMAGE */ - -#define ROM_ADDR PM_ADDRESS -#define ROM_SIZE PM_SIZE - -#if defined(CONFIG_PM_USE_CONFIG_SRAM_SIZE) -#define RAM_SIZE CONFIG_PM_SRAM_SIZE -#else -#define RAM_SIZE PM_SRAM_SIZE -#endif -#define RAM_ADDR PM_SRAM_ADDRESS - -#else /* ! USE_PARTITION_MANAGER */ - #if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) #define ROM_ADDR RAM_ADDR #else @@ -88,23 +55,6 @@ _image_1_primary_slot_id = PM_S1_ID; #define RAM_SIZE (CONFIG_SRAM_SIZE * 1K) #define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS -#endif /* USE_PARTITION_MANAGER */ - -#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_ccm), okay) -#define CCM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ccm)) -#define CCM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ccm)) -#endif - -#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_itcm), okay) -#define ITCM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_itcm)) -#define ITCM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_itcm)) -#endif - -#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_dtcm), okay) -#define DTCM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_dtcm)) -#define DTCM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_dtcm)) -#endif - #if defined(CONFIG_CUSTOM_SECTION_ALIGN) _region_min_align = CONFIG_CUSTOM_SECTION_MIN_ALIGN_SIZE; #else diff --git a/include/zephyr/storage/flash_map.h b/include/zephyr/storage/flash_map.h index fe69550cd858..f0cb4985eaee 100644 --- a/include/zephyr/storage/flash_map.h +++ b/include/zephyr/storage/flash_map.h @@ -351,10 +351,6 @@ const char *flash_area_label(const struct flash_area *fa); */ uint8_t flash_area_erased_val(const struct flash_area *fa); -#if USE_PARTITION_MANAGER -#include -#else - /** * Returns non-0 value if partition of given DTS node label exists. * @@ -629,8 +625,6 @@ DT_FOREACH_STATUS_OKAY(fixed_subpartitions, FOR_EACH_SUBPARTITION_TABLE) #undef FOR_EACH_SUBPARTITION_TABLE /** @endcond */ -#endif /* USE_PARTITION_MANAGER */ - #ifdef __cplusplus } #endif diff --git a/lib/heap/Kconfig b/lib/heap/Kconfig index 9a39ab8ad73b..0d97da3e340b 100644 --- a/lib/heap/Kconfig +++ b/lib/heap/Kconfig @@ -81,7 +81,7 @@ config HEAP_LISTENER choice prompt "Supported heap sizes" depends on !64BIT - default SYS_HEAP_SMALL_ONLY if (SRAM_SIZE <= 256) && !PARTITION_MANAGER_ENABLED + default SYS_HEAP_SMALL_ONLY if (SRAM_SIZE <= 256) default SYS_HEAP_AUTO help Heaps using reduced-size chunk headers can accommodate so called diff --git a/lib/libc/common/source/stdlib/malloc.c b/lib/libc/common/source/stdlib/malloc.c index 2821ae8173ac..2b01e152f009 100644 --- a/lib/libc/common/source/stdlib/malloc.c +++ b/lib/libc/common/source/stdlib/malloc.c @@ -25,20 +25,6 @@ #include LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL); -#if USE_PARTITION_MANAGER - -#include - -#define RAM_SIZE PM_SRAM_SIZE -#define RAM_ADDR PM_SRAM_ADDRESS - -#else /* ! USE_PARTITION_MANAGER */ - -#define RAM_SIZE (KB((size_t) CONFIG_SRAM_SIZE)) -#define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS - -#endif /* USE_PARTITION_MANAGER */ - #ifdef CONFIG_COMMON_LIBC_MALLOC #if (CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE != 0) @@ -120,8 +106,8 @@ static POOL_SECTION unsigned char __aligned(HEAP_ALIGN) malloc_arena[HEAP_SIZE]; extern char _heap_sentry[]; # define HEAP_SIZE ROUND_DOWN((POINTER_TO_UINT(_heap_sentry) - HEAP_BASE), HEAP_ALIGN) # else -# define HEAP_SIZE ROUND_DOWN((RAM_SIZE - \ - ((size_t) HEAP_BASE - (size_t) RAM_ADDR)), HEAP_ALIGN) +# define HEAP_SIZE ROUND_DOWN((KB((size_t) CONFIG_SRAM_SIZE) - \ + ((size_t) HEAP_BASE - (size_t) CONFIG_SRAM_BASE_ADDRESS)), HEAP_ALIGN) # endif /* else CONFIG_XTENSA */ # endif /* else CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE > 0 */ diff --git a/subsys/dfu/boot/mcuboot_shell.c b/subsys/dfu/boot/mcuboot_shell.c index e167bc1e39b8..be4e558713f1 100644 --- a/subsys/dfu/boot/mcuboot_shell.c +++ b/subsys/dfu/boot/mcuboot_shell.c @@ -20,16 +20,6 @@ #endif #endif -#if USE_PARTITION_MANAGER -#include - -#ifdef CONFIG_NCS_IS_VARIANT_IMAGE -#define ACTIVE_IMAGE_ID PM_MCUBOOT_SECONDARY_ID -#else -#define ACTIVE_IMAGE_ID PM_MCUBOOT_PRIMARY_ID -#endif -#endif - struct area_desc { const char *name; unsigned int id; @@ -103,35 +93,6 @@ static int cmd_mcuboot_erase(const struct shell *sh, size_t argc, id = strtoul(argv[1], NULL, 0); /* Check if this is the parent (MCUboot) or own slot and if so, deny the request */ -#if USE_PARTITION_MANAGER -#ifdef PM_MCUBOOT_ID - if (id == PM_MCUBOOT_ID || id == PM_MCUBOOT_PAD_ID) { - shell_error(sh, "Cannot erase boot partition"); - return -EACCES; - } -#endif - -#ifdef PM_APP_ID - if (id == PM_APP_ID) { - shell_error(sh, "Cannot erase this area"); - return -EACCES; - } -#endif - -#ifdef PM_MCUBOOT_PRIMARY_APP_ID - if (id == PM_MCUBOOT_PRIMARY_APP_ID) { - shell_error(sh, "Cannot erase this area"); - return -EACCES; - } -#endif - -#ifdef ACTIVE_IMAGE_ID - if (id == ACTIVE_IMAGE_ID) { - shell_error(sh, "Cannot erase active partitions"); - return -EACCES; - } -#endif -#else #if FIXED_PARTITION_EXISTS(boot_partition) if (id == FIXED_PARTITION_ID(boot_partition)) { shell_error(sh, "Cannot erase boot partition"); @@ -144,7 +105,6 @@ static int cmd_mcuboot_erase(const struct shell *sh, size_t argc, shell_error(sh, "Cannot erase active partitions"); return -EACCES; } -#endif #endif err = boot_erase_img_bank(id); diff --git a/subsys/fs/littlefs_fs.c b/subsys/fs/littlefs_fs.c index a31e01836a9c..bf60649e9b95 100644 --- a/subsys/fs/littlefs_fs.c +++ b/subsys/fs/littlefs_fs.c @@ -1133,12 +1133,7 @@ struct fs_mount_t FS_FSTAB_ENTRY(DT_DRV_INST(inst)) = { \ .type = FS_LITTLEFS, \ .mnt_point = FSTAB_ENTRY_DT_INST_MOUNT_POINT(inst), \ .fs_data = &fs_data_##inst, \ - .storage_dev = (void *) \ - COND_CODE_1(USE_PARTITION_MANAGER, \ - (COND_CODE_1(FIXED_PARTITION_EXISTS(littlefs_storage), \ - (FIXED_PARTITION_ID(littlefs_storage)), \ - (FIXED_PARTITION_ID(storage)))), \ - (DT_FIXED_PARTITION_ID(FS_PARTITION(inst)))), \ + .storage_dev = (void *)DT_FIXED_PARTITION_ID(FS_PARTITION(inst)), \ .flags = FSTAB_ENTRY_DT_MOUNT_FLAGS(DT_DRV_INST(inst)), \ }; diff --git a/subsys/ipc/rpmsg_service/rpmsg_backend.h b/subsys/ipc/rpmsg_service/rpmsg_backend.h index 9996e1d74d9b..a74e46b85207 100644 --- a/subsys/ipc/rpmsg_service/rpmsg_backend.h +++ b/subsys/ipc/rpmsg_service/rpmsg_backend.h @@ -13,35 +13,8 @@ extern "C" { #endif -#if CONFIG_PARTITION_MANAGER_ENABLED - -#include "pm_config.h" - -#if defined(PM_RPMSG_NRF53_SRAM_ADDRESS) || defined(PM__RPMSG_NRF53_SRAM_ADDRESS) - -#if defined(PM_RPMSG_NRF53_SRAM_ADDRESS) -#define VDEV_START_ADDR PM_RPMSG_NRF53_SRAM_ADDRESS -#define VDEV_SIZE PM_RPMSG_NRF53_SRAM_SIZE -#else -/* The current image is a child image in a different domain than the image - * which defined the required values. To reach the values of the parent domain - * we use the 'PM__' variant of the define. - */ -#define VDEV_START_ADDR PM__RPMSG_NRF53_SRAM_ADDRESS -#define VDEV_SIZE PM__RPMSG_NRF53_SRAM_SIZE -#endif /* defined(PM_RPMSG_NRF53_SRAM_ADDRESS) */ - -#else #define VDEV_START_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ipc_shm)) #define VDEV_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ipc_shm)) -#endif /* defined(PM_RPMSG_NRF53_SRAM_ADDRESS) || defined(PM__RPMSG_NRF53_SRAM_ADDRESS) */ - -#else - -#define VDEV_START_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ipc_shm)) -#define VDEV_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ipc_shm)) - -#endif /* CONFIG_PARTITION_MANAGER_ENABLED */ #define VDEV_STATUS_ADDR VDEV_START_ADDR #define VDEV_STATUS_SIZE 0x400 From b5a45376037ce117000d443a2c6c66ffe135b54b Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Mon, 23 Feb 2026 11:45:35 +0000 Subject: [PATCH 08/63] [nrf fromtree] arch: arm: cortex_m: linker: Add support for zephyr,mapped-partition Adds support for using this new binding Signed-off-by: Jamie McCrae (cherry picked from commit a28e2864f47dab8a06c08eeef47dd87385dcba50) --- Kconfig.zephyr | 11 +++++++++++ .../zephyr/arch/arm/cortex_m/scripts/linker.ld | 17 +++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Kconfig.zephyr b/Kconfig.zephyr index 89c45793bdfb..9c8584184a02 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -99,6 +99,17 @@ config USE_DT_CODE_PARTITION # Workaround for not being able to have commas in macro arguments DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition DT_CHOSEN_Z_FLASH := zephyr,flash +DT_COMPAT_Z_MAPPED_PARTITION := zephyr,mapped-partition + +config FLASH_USES_MAPPED_PARTITION + bool + default $(dt_node_has_compat,$(dt_chosen_path,$(DT_CHOSEN_Z_CODE_PARTITION)),$(DT_COMPAT_Z_MAPPED_PARTITION)) + depends on USE_DT_CODE_PARTITION + help + Temporary Kconfig to indicate if underlying chosen chosen flash partition uses the + zephyr,mapped-partition compatible, this is to allow ease of migration from + fixed-partitions and should not be relied upon outside of the zephyr build system and + will be removed in future. config FLASH_CODE_PARTITION_ADDRESS_INVALID bool diff --git a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld index 288e0d0dc647..0663ac97653e 100644 --- a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld +++ b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld @@ -34,23 +34,28 @@ #define ROMSTART_REGION ROMABLE_REGION #endif -#if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) -#define ROM_ADDR RAM_ADDR -#else -#define ROM_ADDR (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) -#endif - #if defined(CONFIG_ROM_END_OFFSET) #define ROM_END_OFFSET CONFIG_ROM_END_OFFSET #else #define ROM_END_OFFSET 0 #endif +#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) +#define ROM_ADDR (DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition))) +#define ROM_SIZE (DT_REG_SIZE(DT_CHOSEN(zephyr_code_partition)) - ROM_END_OFFSET) +#else +#if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) +#define ROM_ADDR RAM_ADDR +#else +#define ROM_ADDR (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) +#endif /* !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) */ + #if CONFIG_FLASH_LOAD_SIZE > 0 #define ROM_SIZE (CONFIG_FLASH_LOAD_SIZE - ROM_END_OFFSET) #else #define ROM_SIZE (CONFIG_FLASH_SIZE * 1024 - CONFIG_FLASH_LOAD_OFFSET - ROM_END_OFFSET) #endif +#endif /* defined(CONFIG_FLASH_USES_MAPPED_PARTITION) */ #define RAM_SIZE (CONFIG_SRAM_SIZE * 1K) #define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS From 4622f7eb4664b64e131dbd2c860e9c617d9bd569 Mon Sep 17 00:00:00 2001 From: TOKITA Hiroshi Date: Mon, 14 Apr 2025 01:58:25 +0900 Subject: [PATCH 09/63] [nrf fromtree] tests: lib: devicetree: api: Add map property tests Add tests for map property related macros. Add `native_sim/native/64` to allowed platforms. Signed-off-by: TOKITA Hiroshi (cherry picked from commit 6a53d5c63d3c016b2c6955da357f2c15dad91725) --- dts/bindings/test/vnd,gpio-nexus.yaml | 8 ++ dts/bindings/test/vnd,intr-nexus.yaml | 8 ++ tests/lib/devicetree/api/app.overlay | 55 ++++++++++ tests/lib/devicetree/api/src/main.c | 140 +++++++++++++++++++++++++ tests/lib/devicetree/api/testcase.yaml | 1 + 5 files changed, 212 insertions(+) create mode 100644 dts/bindings/test/vnd,gpio-nexus.yaml create mode 100644 dts/bindings/test/vnd,intr-nexus.yaml diff --git a/dts/bindings/test/vnd,gpio-nexus.yaml b/dts/bindings/test/vnd,gpio-nexus.yaml new file mode 100644 index 000000000000..2274be7451da --- /dev/null +++ b/dts/bindings/test/vnd,gpio-nexus.yaml @@ -0,0 +1,8 @@ +# Copyright (c) 2025, TOKITA Hiroshi +# SPDX-License-Identifier: Apache-2.0 + +description: VND GPIO nexus + +include: [gpio-nexus.yaml] + +compatible: "vnd,gpio-nexus" diff --git a/dts/bindings/test/vnd,intr-nexus.yaml b/dts/bindings/test/vnd,intr-nexus.yaml new file mode 100644 index 000000000000..f3b194c55838 --- /dev/null +++ b/dts/bindings/test/vnd,intr-nexus.yaml @@ -0,0 +1,8 @@ +# Copyright (c) 2025, TOKITA Hiroshi +# SPDX-License-Identifier: Apache-2.0 + +description: VND interrupt nexus + +include: [interrupt-nexus.yaml] + +compatible: "vnd,intr-nexus" diff --git a/tests/lib/devicetree/api/app.overlay b/tests/lib/devicetree/api/app.overlay index ecbe17df3e78..c90a2a36d7d9 100644 --- a/tests/lib/devicetree/api/app.overlay +++ b/tests/lib/devicetree/api/app.overlay @@ -1065,4 +1065,59 @@ compatible = "vnd,non-deprecated-label"; label = "FOO"; }; + + gpio-map-test { + connector { + compatible = "vnd,gpio-nexus"; + #gpio-cells = <2>; + gpio-map = <1 2 &{/gpio-map-test/parent} 3 + 4 5 &{/gpio-map-test/parent} 6>; + gpio-map-mask = <0xffffffff 0xffffffc0>; + gpio-map-pass-thru = <0x0 0x3f>; + }; + + parent { + compatible = "gpio-dst"; + gpio-controller; + #gpio-cells = <1>; + }; + }; + + interrupt-map-test { + #address-cells = <2>; + #size-cells = <0>; + + controller-0@0 { + compatible = "vnd,cpu-intc"; + reg = <0x0 0x0>; + #address-cells = <1>; + #interrupt-cells = <1>; + interrupt-controller; + }; + + controller-1@1 { + compatible = "vnd,intc"; + reg = <0x0 0x1>; + #address-cells = <2>; + #interrupt-cells = <2>; + interrupt-controller; + }; + + nexus { + compatible = "vnd,intr-nexus"; + #address-cells = <2>; + #interrupt-cells = <2>; + interrupt-map = <0 0 1 2 &{/interrupt-map-test/controller-0@0} 3 4 + 0 0 5 6 &{/interrupt-map-test/controller-1@1} 7 8 9 0 + 0 1 9 8 &{/interrupt-map-test/controller-0@0} 7 6 + 0 1 5 4 &{/interrupt-map-test/controller-1@1} 3 2 1 0>; + }; + + empty { + compatible = "vnd,intr-nexus"; + #address-cells = <2>; + #interrupt-cells = <2>; + interrupt-map = <>; + }; + }; }; diff --git a/tests/lib/devicetree/api/src/main.c b/tests/lib/devicetree/api/src/main.c index eb06c570e116..673dad16276d 100644 --- a/tests/lib/devicetree/api/src/main.c +++ b/tests/lib/devicetree/api/src/main.c @@ -130,6 +130,10 @@ #define TEST_SUBPARTITION_1 DT_PATH(test, test_mtd_ffeeddcc, flash_20001000, partitions, \ partition_100, partition_40) +#define TEST_GPIO_CONNECTOR DT_PATH(gpio_map_test, connector) +#define TEST_INTERRUPT_NEXUS DT_PATH(interrupt_map_test, nexus) +#define TEST_INTERRUPT_NEXUS_EMPTY DT_PATH(interrupt_map_test, empty) + #define ZEPHYR_USER DT_PATH(zephyr_user) #define TA_HAS_COMPAT(compat) DT_NODE_HAS_COMPAT(TEST_ARRAYS, compat) @@ -4117,4 +4121,140 @@ ZTEST(devicetree_api, test_nvmem_devictree_inst) "/test/test-nvmem-provider"); } +#define INTERRUPT_NEXUS_CHECK_0(n, p, i, ...) \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(n, p, i, 0), 0); \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(n, p, i, 1), 0); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(n, p, i, 0), 1); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(n, p, i, 1), 2); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_LEN(n, p, i), 1); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX(n, p, i, 0), 3); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_LEN(n, p, i), 1); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(n, p, i, 0), 4); \ + zassert_str_equal(STRINGIFY(DT_MAP_ENTRY_PARENT(n, p)), \ + "DT_N_S_interrupt_map_test_S_controller_0_0"); + +#define INTERRUPT_NEXUS_CHECK_1(n, p, i, ...) \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS(n, p, i), 0); \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(n, p, i, 1), 0); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER(n, p, i), 5); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(n, p, i, 1), 6); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS(n, p, i), 7); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX(n, p, i, 1), 8); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER(n, p, i), 9); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(n, p, i, 1), 0); \ + zassert_str_equal(STRINGIFY(DT_MAP_ENTRY_PARENT_BY_IDX(n, p, i)), \ + "DT_N_S_interrupt_map_test_S_controller_1_1"); + +#define INTERRUPT_NEXUS_CHECK_2(n, p, i, ...) \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(n, p, i, 0), 0); \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(n, p, i, 1), 1); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(n, p, i, 0), 9); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(n, p, i, 1), 8); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_LEN(n, p, i), 1); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX(n, p, i, 0), 7); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_LEN(n, p, i), 1); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(n, p, i, 0), 6); \ + zassert_str_equal(STRINGIFY(DT_MAP_ENTRY_PARENT_BY_IDX(n, p, i)), \ + "DT_N_S_interrupt_map_test_S_controller_0_0"); + +#define INTERRUPT_NEXUS_CHECK_3(n, p, i, ...) \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(n, p, i, 0), 0); \ + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_BY_IDX(n, p, i, 1), 1); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(n, p, i, 0), 5); \ + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(n, p, i, 1), 4); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX(n, p, i, 0), 3); \ + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_BY_IDX(n, p, i, 1), 2); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_LEN(n, p, i), 2); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(n, p, i, 0), 1); \ + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(n, p, i, 1), 0); \ + zassert_str_equal(STRINGIFY(DT_MAP_ENTRY_PARENT_BY_IDX(n, p, i)), \ + "DT_N_S_interrupt_map_test_S_controller_1_1"); + +#define INTERRUPT_NEXUS_CHECK(n, p, i) UTIL_CAT(INTERRUPT_NEXUS_CHECK_, i)(n, p, i) +#define INTERRUPT_NEXUS_CHECK_VARGS(n, p, i, ...) UTIL_CAT(INTERRUPT_NEXUS_CHECK_, i)(n, p, i) + +#define EMPTY_MAP_SHOULD_NOT_RUN(...) zassert_unreachable("map should be empty") + +ZTEST(devicetree_api, test_map) +{ + zassert_equal(DT_PROP_LEN(TEST_GPIO_CONNECTOR, gpio_map_mask), 2); + zassert_equal(DT_PROP_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map_mask, 0), 0xffffffff); + zassert_equal(DT_PROP_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map_mask, 1), 0xffffffc0); + zassert_equal(DT_PROP_LEN(TEST_GPIO_CONNECTOR, gpio_map_pass_thru), 2); + zassert_equal(DT_PROP_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map_pass_thru, 0), 0x0); + zassert_equal(DT_PROP_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map_pass_thru, 1), 0x3f); + + zassert_equal(DT_PROP_LEN(TEST_GPIO_CONNECTOR, gpio_map), 2); + + zassert_equal(DT_MAP_ENTRY_CHILD_ADDRESS_LEN(TEST_GPIO_CONNECTOR, gpio_map, 0), 0); + zassert_equal(DT_MAP_ENTRY_PARENT_ADDRESS_LEN(TEST_GPIO_CONNECTOR, gpio_map, 0), 0); + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_LEN(TEST_GPIO_CONNECTOR, gpio_map, 0), 2); + zassert_equal(DT_MAP_ENTRY_HAS_CHILD_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 0, 1), + 1); + zassert_equal(DT_MAP_ENTRY_HAS_CHILD_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 0, 2), + 0); + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 0, 0), 1); + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 0, 1), 2); + + zassert_str_equal(STRINGIFY(DT_MAP_ENTRY_PARENT_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 0)), + "DT_N_S_gpio_map_test_S_parent"); + + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_LEN(TEST_GPIO_CONNECTOR, gpio_map, 1), 1); + zassert_equal(DT_MAP_ENTRY_HAS_PARENT_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 1, 0), + 1); + zassert_equal(DT_MAP_ENTRY_HAS_PARENT_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 1, 1), + 0); + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 0, 0), 3); + + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_LEN(TEST_GPIO_CONNECTOR, gpio_map, 1), 2); + zassert_equal(DT_MAP_ENTRY_HAS_CHILD_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 1, 1), + 1); + zassert_equal(DT_MAP_ENTRY_HAS_CHILD_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 1, 2), + 0); + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 1, 0), 4); + zassert_equal(DT_MAP_ENTRY_CHILD_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 1, 1), 5); + + zassert_str_equal(STRINGIFY(DT_MAP_ENTRY_PARENT_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 1)), + "DT_N_S_gpio_map_test_S_parent"); + + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_LEN(TEST_GPIO_CONNECTOR, gpio_map, 0), 1); + zassert_equal(DT_MAP_ENTRY_HAS_PARENT_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 0, 0), + 1); + zassert_equal(DT_MAP_ENTRY_HAS_PARENT_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 0, 1), + 0); + zassert_equal(DT_MAP_ENTRY_PARENT_SPECIFIER_BY_IDX(TEST_GPIO_CONNECTOR, gpio_map, 1, 0), 6); + + zassert_true(DT_NODE_HAS_MAP(TEST_INTERRUPT_NEXUS_EMPTY, interrupt_map), ""); + zassert_equal(DT_MAP_LEN(TEST_INTERRUPT_NEXUS_EMPTY, interrupt_map), 0); + zassert_equal(DT_MAP_HAS_ENTRY(TEST_INTERRUPT_NEXUS_EMPTY, interrupt_map), 0); + + DT_FOREACH_MAP_ENTRY(TEST_INTERRUPT_NEXUS_EMPTY, interrupt_map, EMPTY_MAP_SHOULD_NOT_RUN); + DT_FOREACH_MAP_ENTRY_SEP(TEST_INTERRUPT_NEXUS_EMPTY, interrupt_map, + EMPTY_MAP_SHOULD_NOT_RUN, ()); + DT_FOREACH_MAP_ENTRY_VARGS(TEST_INTERRUPT_NEXUS_EMPTY, interrupt_map, + EMPTY_MAP_SHOULD_NOT_RUN, 1234); + DT_FOREACH_MAP_ENTRY_SEP_VARGS(TEST_INTERRUPT_NEXUS_EMPTY, interrupt_map, + EMPTY_MAP_SHOULD_NOT_RUN, (), 1234); + + zassert_equal(DT_MAP_HAS_ENTRY_BY_IDX(TEST_INTERRUPT_NEXUS, interrupt_map, 3), 1); + zassert_equal(DT_MAP_HAS_ENTRY_BY_IDX(TEST_INTERRUPT_NEXUS, interrupt_map, 4), 0); + DT_FOREACH_MAP_ENTRY(TEST_INTERRUPT_NEXUS, interrupt_map, INTERRUPT_NEXUS_CHECK) + DT_FOREACH_MAP_ENTRY_SEP(TEST_INTERRUPT_NEXUS, interrupt_map, INTERRUPT_NEXUS_CHECK, ()) + DT_FOREACH_MAP_ENTRY_VARGS(TEST_INTERRUPT_NEXUS, interrupt_map, INTERRUPT_NEXUS_CHECK_VARGS, + 9999); + DT_FOREACH_MAP_ENTRY_SEP_VARGS(TEST_INTERRUPT_NEXUS, interrupt_map, + INTERRUPT_NEXUS_CHECK_VARGS, (), 9999); +} + ZTEST_SUITE(devicetree_api, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/lib/devicetree/api/testcase.yaml b/tests/lib/devicetree/api/testcase.yaml index ded886833ac8..2759a047ab7d 100644 --- a/tests/lib/devicetree/api/testcase.yaml +++ b/tests/lib/devicetree/api/testcase.yaml @@ -5,6 +5,7 @@ tests: # will mostly likely be the fastest. platform_allow: - native_sim + - native_sim/native/64 - qemu_x86 - qemu_x86_64 - qemu_cortex_m3 From 625466248f34a2be0f2aa2ab6a64277f53765bd2 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Wed, 18 Mar 2026 07:46:59 +0000 Subject: [PATCH 10/63] Revert "[nrf fromlist] include: devicetree: fixed-partitions: Fix node handling" This reverts commit 0bfdaabb1afe0079e68fedb2800c6cb45005842f. Signed-off-by: Jamie McCrae --- include/zephyr/devicetree/fixed-partitions.h | 38 +---- tests/lib/devicetree/api/app.overlay | 83 +---------- tests/lib/devicetree/api/src/main.c | 146 ++----------------- 3 files changed, 20 insertions(+), 247 deletions(-) diff --git a/include/zephyr/devicetree/fixed-partitions.h b/include/zephyr/devicetree/fixed-partitions.h index 3a60f960013c..ff44e07ef644 100644 --- a/include/zephyr/devicetree/fixed-partitions.h +++ b/include/zephyr/devicetree/fixed-partitions.h @@ -5,7 +5,6 @@ /* * Copyright (c) 2020, Linaro Ltd. - * Copyright (c) 2026, Nordic Semiconductor ASA * * SPDX-License-Identifier: Apache-2.0 */ @@ -106,15 +105,9 @@ extern "C" { * &flash_controller { * flash@1000000 { * compatible = "soc-nv-flash"; - * reg = <0x1000000 0x50000> - * ranges = <0x0 0x1000000 0x50000> - * * partitions { * compatible = "fixed-partitions"; - * ranges; - * * storage_partition: partition@3a000 { - * reg = <0x3a000 0x8000> * label = "storage"; * }; * }; @@ -137,20 +130,8 @@ extern "C" { * @return the partition's offset plus the base address of the flash * node containing it. */ - -/* - * The COND_CODE_0 ranges part handles invalid devices where they wrongly do not inherit the - * parent's address and wrongly start at address 0x0 which was a bug that was fixed post Zephyr - * 4.3, this extra handling can be removed in Zephyr 4.6 or newer - */ -#define DT_FIXED_PARTITION_ADDR(node_id) \ - COND_CODE_0(DT_NODE_HAS_COMPAT(DT_PARENT(node_id), fixed_subpartitions), \ - (COND_CODE_0(DT_NUM_RANGES(DT_GPARENT(node_id)), \ - (DT_REG_ADDR(node_id) + DT_REG_ADDR(DT_GPARENT(node_id))), \ - (DT_REG_ADDR(node_id)))), \ - (COND_CODE_0(DT_NUM_RANGES(DT_GPARENT(DT_PARENT(node_id))), \ - (DT_REG_ADDR(node_id) + DT_REG_ADDR(DT_GPARENT(node_id))), \ - (DT_REG_ADDR(node_id))))) +#define DT_FIXED_PARTITION_ADDR(node_id) \ + (DT_REG_ADDR(node_id) + DT_REG_ADDR(DT_GPARENT(node_id))) /** * @brief Test if fixed-subpartitions compatible node exists @@ -189,12 +170,9 @@ extern "C" { * &flash_controller { * flash@1000000 { * compatible = "soc-nv-flash"; - * reg = <0x1000000 0x50000> - * ranges = <0x0 0x1000000 0x50000> * * partitions { * compatible = "fixed-partitions"; - * ranges; * * slot0_partition: partition@10000 { * compatible = "fixed-subpartitions"; @@ -228,16 +206,8 @@ extern "C" { * @return the subpartition's offset plus the base address of the flash * node containing it. */ - -/* - * The COND_CODE_0 part handles invalid devices where they wrongly do not inherit the parent's - * address and wrongly start at address 0x0 which was a bug that was fixed post Zephyr 4.3, this - * extra handling can be removed in Zephyr 4.6 or newer - */ -#define DT_FIXED_SUBPARTITION_ADDR(node_id) \ - COND_CODE_0(DT_NUM_RANGES(DT_GPARENT(DT_PARENT(node_id))), \ - (DT_REG_ADDR(node_id) + DT_REG_ADDR(DT_GPARENT(DT_PARENT(node_id)))), \ - (DT_REG_ADDR(node_id))) +#define DT_FIXED_SUBPARTITION_ADDR(node_id) \ + (DT_REG_ADDR(node_id) + DT_REG_ADDR(DT_GPARENT(DT_PARENT(node_id)))) /** * @} diff --git a/tests/lib/devicetree/api/app.overlay b/tests/lib/devicetree/api/app.overlay index c90a2a36d7d9..f9b5bd8757c4 100644 --- a/tests/lib/devicetree/api/app.overlay +++ b/tests/lib/devicetree/api/app.overlay @@ -886,14 +886,6 @@ #address-cells = <1>; #size-cells = <1>; - /* - * The below specifies an invalid setup whereby partitions wrongly do not - * inherit the parent node's address space and specify that the partitions - * start at absolute address 0x0 onwards, this has been fixed post Zephyr - * 4.3 and is only here to ensure macros do not break for out of tree - * users so that they have time to fix their DTS files, it will be removed - * in Zephyr 4.6 or newer. - */ flash@20000000 { compatible = "soc-nv-flash"; reg = <0x20000000 0x100>; @@ -903,51 +895,6 @@ #address-cells = <1>; #size-cells = <1>; - partition@0 { - reg = <0x0 0xc0>; - label = "test-partition-0-deprecated"; - }; - - partition@c0 { - reg = <0xc0 0x40>; - label = "test-partition-1-deprecated"; - }; - - partition@100 { - compatible = "fixed-subpartitions"; - label = "test-subpartitions-deprecated"; - reg = <0x00000100 0x100>; - ranges = <0x0 0x100 0x100>; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - label = "test-subpartition-0-deprecated"; - reg = <0x00000000 0x40>; - }; - - partition@40 { - label = "test-subpartition-1-deprecated"; - reg = <0x00000040 0xc0>; - }; - }; - }; - }; - - /* The below device correctly inherits the parent's address space */ - flash@20001000 { - compatible = "soc-nv-flash"; - reg = <0x20001000 0x200>; - ranges = <0x0 0x20001000 0x200>; - #address-cells = <1>; - #size-cells = <1>; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - ranges; - partition@0 { reg = <0x0 0xc0>; label = "test-partition-0"; @@ -980,42 +927,14 @@ }; }; - /* - * The below specifies an invalid setup whereby partitions wrongly do not - * inherit the parent node's address space and specify that the partitions - * start at absolute address 0x0 onwards, this has been fixed post Zephyr - * 4.3 and is only here to ensure macros do not break for out of tree - * users so that they have time to fix their DTS files, it will be removed - * in Zephyr 4.6 or newer. - */ test-mtd@33221100 { - reg = <0x33221100 0x70000>; + reg = <0x33221100 0x1000>; partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; - partition@6ff80 { - reg = <0x6ff80 0x80>; - label = "test-partition-2-deprecated"; - }; - }; - }; - - /* The below device correctly inherits the parent's address space */ - test-mtd@33291100 { - reg = <0x33291100 0x70000>; - ranges = <0x0 0x33291100 0x70000>; - #address-cells = <1>; - #size-cells = <1>; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - ranges; - partition@6ff80 { reg = <0x6ff80 0x80>; label = "test-partition-2"; diff --git a/tests/lib/devicetree/api/src/main.c b/tests/lib/devicetree/api/src/main.c index 673dad16276d..5d7ac3fee534 100644 --- a/tests/lib/devicetree/api/src/main.c +++ b/tests/lib/devicetree/api/src/main.c @@ -97,37 +97,19 @@ #define TEST_RANGES_EMPTY DT_NODELABEL(test_ranges_empty) #define TEST_MTD_0 DT_PATH(test, test_mtd_ffeeddcc) +#define TEST_MTD_1 DT_PATH(test, test_mtd_33221100) -#define TEST_MTD_1_DEPRECATED DT_PATH(test, test_mtd_33221100) +#define TEST_MEM_0 DT_CHILD(TEST_MTD_0, flash_20000000) -#define TEST_MEM_0_DEPRECATED DT_CHILD(TEST_MTD_0, flash_20000000) +#define TEST_PARTITION_0 DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, partitions, partition_0) +#define TEST_PARTITION_1 DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, partitions, partition_c0) +#define TEST_PARTITION_2 DT_PATH(test, test_mtd_33221100, partitions, partition_6ff80) -#define TEST_PARTITION_0_DEPRECATED DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, partitions, \ - partition_0) -#define TEST_PARTITION_1_DEPRECATED DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, partitions, \ - partition_c0) -#define TEST_PARTITION_2_DEPRECATED DT_PATH(test, test_mtd_33221100, partitions, partition_6ff80) - -#define TEST_SUBPARTITION_COMBINED_DEPRECATED DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, \ - partitions, partition_100) -#define TEST_SUBPARTITION_0_DEPRECATED DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, \ - partitions, partition_100, partition_0) -#define TEST_SUBPARTITION_1_DEPRECATED DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, \ - partitions, partition_100, partition_40) - -#define TEST_MTD_1 DT_PATH(test, test_mtd_33291100) - -#define TEST_MEM_0 DT_CHILD(TEST_MTD_0, flash_20001000) - -#define TEST_PARTITION_0 DT_PATH(test, test_mtd_ffeeddcc, flash_20001000, partitions, partition_0) -#define TEST_PARTITION_1 DT_PATH(test, test_mtd_ffeeddcc, flash_20001000, partitions, partition_c0) -#define TEST_PARTITION_2 DT_PATH(test, test_mtd_33291100, partitions, partition_6ff80) - -#define TEST_SUBPARTITION_COMBINED DT_PATH(test, test_mtd_ffeeddcc, flash_20001000, partitions, \ +#define TEST_SUBPARTITION_COMBINED DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, partitions, \ partition_100) -#define TEST_SUBPARTITION_0 DT_PATH(test, test_mtd_ffeeddcc, flash_20001000, partitions, \ +#define TEST_SUBPARTITION_0 DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, partitions, \ partition_100, partition_0) -#define TEST_SUBPARTITION_1 DT_PATH(test, test_mtd_ffeeddcc, flash_20001000, partitions, \ +#define TEST_SUBPARTITION_1 DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, partitions, \ partition_100, partition_40) #define TEST_GPIO_CONNECTOR DT_PATH(gpio_map_test, connector) @@ -3300,107 +3282,13 @@ ZTEST(devicetree_api, test_mbox) DT_NODELABEL(test_mbox_zero_cell)), ""); } -/* - * Tests that invalid but accidentally working behaviour does not break out of tree users, to be - * removed in Zephyr 4.6 or newer - */ -ZTEST(devicetree_api, test_fixed_partitions_deprecated) -{ - /* Test finding fixed partitions by the 'label' property. */ - zassert_true(DT_HAS_FIXED_PARTITION_LABEL(test_partition_0_deprecated)); - zassert_true(DT_HAS_FIXED_PARTITION_LABEL(test_partition_1_deprecated)); - zassert_true(DT_HAS_FIXED_PARTITION_LABEL(test_partition_2_deprecated)); - zassert_true(DT_SAME_NODE(TEST_PARTITION_0_DEPRECATED, - DT_NODE_BY_FIXED_PARTITION_LABEL(test_partition_0_deprecated))); - zassert_true(DT_SAME_NODE(TEST_PARTITION_1_DEPRECATED, - DT_NODE_BY_FIXED_PARTITION_LABEL(test_partition_1_deprecated))); - zassert_true(DT_SAME_NODE(TEST_PARTITION_2_DEPRECATED, - DT_NODE_BY_FIXED_PARTITION_LABEL(test_partition_2_deprecated))); - - zassert_true(DT_FIXED_PARTITION_EXISTS(TEST_PARTITION_0_DEPRECATED)); - zassert_true(DT_FIXED_PARTITION_EXISTS(TEST_PARTITION_1_DEPRECATED)); - zassert_true(DT_FIXED_PARTITION_EXISTS(TEST_PARTITION_2_DEPRECATED)); - - /* There should not be a node with `label = "test_partition_3_deprecated"`. */ - zassert_false(DT_HAS_FIXED_PARTITION_LABEL(test_partition_3_deprecated)); - zassert_false(DT_NODE_EXISTS( - DT_NODE_BY_FIXED_PARTITION_LABEL(test_partition_3_deprecated))); - - /* Test DT_MTD_FROM_FIXED_PARTITION. */ - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_PARTITION(TEST_PARTITION_0_DEPRECATED))); - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_PARTITION(TEST_PARTITION_1_DEPRECATED))); - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_PARTITION(TEST_PARTITION_2_DEPRECATED))); - - zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_FIXED_PARTITION( - TEST_PARTITION_0_DEPRECATED))); - zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_FIXED_PARTITION( - TEST_PARTITION_1_DEPRECATED))); - zassert_true(DT_SAME_NODE(TEST_MTD_1_DEPRECATED, DT_MTD_FROM_FIXED_PARTITION( - TEST_PARTITION_2_DEPRECATED))); - - /* Test DT_MEM_FROM_FIXED_PARTITION. */ - zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_PARTITION(TEST_PARTITION_0_DEPRECATED))); - zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_PARTITION(TEST_PARTITION_1_DEPRECATED))); - zassert_false(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_PARTITION(TEST_PARTITION_2_DEPRECATED))); - - zassert_true(DT_SAME_NODE(TEST_MEM_0_DEPRECATED, DT_MEM_FROM_FIXED_PARTITION( - TEST_PARTITION_0_DEPRECATED))); - zassert_true(DT_SAME_NODE(TEST_MEM_0_DEPRECATED, DT_MEM_FROM_FIXED_PARTITION( - TEST_PARTITION_1_DEPRECATED))); - - /* Test DT_FIXED_PARTITION_ADDR. */ - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_0_DEPRECATED), 0x20000000); - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_1_DEPRECATED), 0x200000c0); - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_2_DEPRECATED), 0x33291080); -} - -ZTEST(devicetree_api, test_fixed_subpartitions_deprecated) -{ - zassert_true(DT_FIXED_PARTITION_EXISTS(TEST_SUBPARTITION_COMBINED_DEPRECATED)); - zassert_true(DT_FIXED_SUBPARTITION_EXISTS(TEST_SUBPARTITION_0_DEPRECATED)); - zassert_true(DT_FIXED_SUBPARTITION_EXISTS(TEST_SUBPARTITION_1_DEPRECATED)); - - /* Test DT_MEM_FROM_FIXED_SUBPARTITION. */ - zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_PARTITION( - TEST_SUBPARTITION_COMBINED_DEPRECATED))); - zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_SUBPARTITION( - TEST_SUBPARTITION_0_DEPRECATED))); - zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_SUBPARTITION( - TEST_SUBPARTITION_1_DEPRECATED))); - - /* Test DT_MTD_FROM_FIXED_SUBPARTITION. */ - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_PARTITION( - TEST_SUBPARTITION_COMBINED_DEPRECATED))); - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_SUBPARTITION( - TEST_SUBPARTITION_0_DEPRECATED))); - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_SUBPARTITION( - TEST_SUBPARTITION_1_DEPRECATED))); - zassert_true(DT_SAME_NODE( - DT_MTD_FROM_FIXED_PARTITION(TEST_SUBPARTITION_COMBINED_DEPRECATED), - DT_MTD_FROM_FIXED_SUBPARTITION(TEST_SUBPARTITION_1_DEPRECATED))); - - /* Test DT_FIXED_SUBPARTITION_ADDR. */ - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_SUBPARTITION_COMBINED_DEPRECATED), 0x20000100); - zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_0_DEPRECATED), - DT_FIXED_PARTITION_ADDR(TEST_SUBPARTITION_COMBINED_DEPRECATED)); - zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_0_DEPRECATED), 0x20000100); - zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_1_DEPRECATED), 0x20000140); - - /* Check sizes match */ - zassert_equal(DT_REG_SIZE(TEST_SUBPARTITION_COMBINED_DEPRECATED), - (DT_REG_SIZE(TEST_SUBPARTITION_0_DEPRECATED) + - DT_REG_SIZE(TEST_SUBPARTITION_1_DEPRECATED))); - zassert_equal(DT_REG_SIZE(TEST_SUBPARTITION_COMBINED_DEPRECATED), - (DT_REG_SIZE(TEST_SUBPARTITION_0_DEPRECATED) + - DT_REG_SIZE(TEST_SUBPARTITION_1_DEPRECATED))); -} - ZTEST(devicetree_api, test_fixed_partitions) { /* Test finding fixed partitions by the 'label' property. */ zassert_true(DT_HAS_FIXED_PARTITION_LABEL(test_partition_0)); zassert_true(DT_HAS_FIXED_PARTITION_LABEL(test_partition_1)); zassert_true(DT_HAS_FIXED_PARTITION_LABEL(test_partition_2)); + zassert_true(DT_SAME_NODE(TEST_PARTITION_0, DT_NODE_BY_FIXED_PARTITION_LABEL(test_partition_0))); zassert_true(DT_SAME_NODE(TEST_PARTITION_1, @@ -3438,9 +3326,9 @@ ZTEST(devicetree_api, test_fixed_partitions) zassert_true(DT_SAME_NODE(TEST_MEM_0, DT_MEM_FROM_FIXED_PARTITION(TEST_PARTITION_1))); /* Test DT_FIXED_PARTITION_ADDR. */ - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_0), 0x20001000); - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_1), 0x200010c0); - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_2), 0x33301080); + zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_0), 0x20000000); + zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_1), 0x200000c0); + zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_2), 0x33291080); /* Test that all DT_FIXED_PARTITION_ID are defined and unique. */ #define FIXED_PARTITION_ID_COMMA(node_id) DT_FIXED_PARTITION_ID(node_id), @@ -3448,8 +3336,6 @@ ZTEST(devicetree_api, test_fixed_partitions) static const int ids[] = { DT_FOREACH_STATUS_OKAY_VARGS(fixed_partitions, DT_FOREACH_CHILD, FIXED_PARTITION_ID_COMMA) - DT_FOREACH_STATUS_OKAY_VARGS(fixed_subpartitions, DT_FOREACH_CHILD, - FIXED_PARTITION_ID_COMMA) }; bool found[ARRAY_SIZE(ids)] = { false }; @@ -3482,17 +3368,15 @@ ZTEST(devicetree_api, test_fixed_subpartitions) DT_MTD_FROM_FIXED_SUBPARTITION(TEST_SUBPARTITION_1))); /* Test DT_FIXED_SUBPARTITION_ADDR. */ - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_SUBPARTITION_COMBINED), 0x20001100); + zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_SUBPARTITION_COMBINED), 0x20000100); zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_0), DT_FIXED_PARTITION_ADDR(TEST_SUBPARTITION_COMBINED)); - zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_0), 0x20001100); - zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_1), 0x20001140); + zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_0), 0x20000100); + zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_1), 0x20000140); /* Check sizes match */ zassert_equal(DT_REG_SIZE(TEST_SUBPARTITION_COMBINED), (DT_REG_SIZE(TEST_SUBPARTITION_0) + DT_REG_SIZE(TEST_SUBPARTITION_1))); - zassert_equal(DT_REG_SIZE(TEST_SUBPARTITION_COMBINED), - (DT_REG_SIZE(TEST_SUBPARTITION_0) + DT_REG_SIZE(TEST_SUBPARTITION_1))); } ZTEST(devicetree_api, test_string_token) From 2dd0c254dcb68e36fafb3ec637475c6b80befca9 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Wed, 18 Mar 2026 08:07:29 +0000 Subject: [PATCH 11/63] Revert "[nrf fromlist] tests: drivers: flash: Fix invalid partition handling" This reverts commit a1bf1cd236a74e8398c6fee65be97df41b1102a5. Signed-off-by: Jamie McCrae --- tests/drivers/flash/erase_blocks/src/main.c | 3 +-- tests/drivers/flash/interface_test/src/main.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/drivers/flash/erase_blocks/src/main.c b/tests/drivers/flash/erase_blocks/src/main.c index d44eed15e4de..57edfee8fced 100644 --- a/tests/drivers/flash/erase_blocks/src/main.c +++ b/tests/drivers/flash/erase_blocks/src/main.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -27,7 +26,7 @@ LOG_MODULE_REGISTER(test_flash); #endif #define TEST_FLASH_PART_OFFSET \ - FIXED_PARTITION_NODE_OFFSET(TEST_FLASH_PART_NODE) + DT_REG_ADDR(TEST_FLASH_PART_NODE) #define TEST_FLASH_PART_SIZE \ DT_REG_SIZE(TEST_FLASH_PART_NODE) diff --git a/tests/drivers/flash/interface_test/src/main.c b/tests/drivers/flash/interface_test/src/main.c index 8b2627b4f787..461323e8863d 100644 --- a/tests/drivers/flash/interface_test/src/main.c +++ b/tests/drivers/flash/interface_test/src/main.c @@ -7,7 +7,6 @@ #include #include #include -#include #ifdef CONFIG_BOOTLOADER_MCUBOOT #define TEST_FLASH_PART_NODE DT_NODELABEL(boot_partition) @@ -15,7 +14,7 @@ #define TEST_FLASH_PART_NODE DT_NODELABEL(slot1_partition) #endif -#define TEST_FLASH_PART_OFFSET FIXED_PARTITION_NODE_OFFSET(TEST_FLASH_PART_NODE) +#define TEST_FLASH_PART_OFFSET DT_REG_ADDR(TEST_FLASH_PART_NODE) #define TEST_FLASH_PART_SIZE DT_REG_SIZE(TEST_FLASH_PART_NODE) #define TEST_FLASH_CONTROLLER_NODE DT_MTD_FROM_FIXED_PARTITION(TEST_FLASH_PART_NODE) From 27de25622e2b8d0278600f2057359b5b28e9a049 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Wed, 18 Mar 2026 08:07:32 +0000 Subject: [PATCH 12/63] Revert "[nrf fromlist] tests: drivers: flash_simulator: Fix invalid partition handling" This reverts commit 4cf767dcbd23fbe339914f9ce876e5016eb9762c. Signed-off-by: Jamie McCrae --- tests/drivers/flash_simulator/flash_sim_impl/src/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/drivers/flash_simulator/flash_sim_impl/src/main.c b/tests/drivers/flash_simulator/flash_sim_impl/src/main.c index 95dd3d92d92a..8fef1927a49a 100644 --- a/tests/drivers/flash_simulator/flash_sim_impl/src/main.c +++ b/tests/drivers/flash_simulator/flash_sim_impl/src/main.c @@ -7,7 +7,6 @@ #include #include #include -#include /* Warning: The test has been written for testing boards with single * instance of Flash Simulator device only. @@ -19,7 +18,7 @@ #else #define SOC_NV_FLASH_NODE DT_CHILD(DT_INST(0, zephyr_sim_flash), flash_sim_0) #endif /* CONFIG_ARCH_POSIX */ -#define FLASH_SIMULATOR_BASE_OFFSET FIXED_PARTITION_NODE_OFFSET(SOC_NV_FLASH_NODE) +#define FLASH_SIMULATOR_BASE_OFFSET DT_REG_ADDR(SOC_NV_FLASH_NODE) #define FLASH_SIMULATOR_ERASE_UNIT DT_PROP(SOC_NV_FLASH_NODE, erase_block_size) #define FLASH_SIMULATOR_PROG_UNIT DT_PROP(SOC_NV_FLASH_NODE, write_block_size) #define FLASH_SIMULATOR_FLASH_SIZE DT_REG_SIZE(SOC_NV_FLASH_NODE) From dc81a3c7870f0e928772cae6cf603c41ad3d5747 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Wed, 18 Mar 2026 08:07:35 +0000 Subject: [PATCH 13/63] Revert "[nrf fromlist] drivers: disk: flashdisk: Fix invalid partition handling" This reverts commit 276acc01ab32c8e3be33cb2b75388f8a2faf54a4. Signed-off-by: Jamie McCrae --- drivers/disk/flashdisk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/disk/flashdisk.c b/drivers/disk/flashdisk.c index 73832cdba358..bd5dc6a8f76a 100644 --- a/drivers/disk/flashdisk.c +++ b/drivers/disk/flashdisk.c @@ -523,7 +523,7 @@ DT_INST_FOREACH_STATUS_OKAY(DEFINE_FLASHDISKS_CACHE) .name = DT_INST_PROP(n, disk_name), \ }, \ .area_id = DT_FIXED_PARTITION_ID(PARTITION_PHANDLE(n)), \ - .offset = FIXED_PARTITION_NODE_OFFSET(PARTITION_PHANDLE(n)), \ + .offset = DT_REG_ADDR(PARTITION_PHANDLE(n)), \ .cache = flashdisk##n##_cache, \ .cache_size = sizeof(flashdisk##n##_cache), \ .size = DT_REG_SIZE(PARTITION_PHANDLE(n)), \ From 7d221db00d262d281a055d65333928dad0041eee Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Wed, 18 Mar 2026 08:07:39 +0000 Subject: [PATCH 14/63] Revert "[nrf fromlist] tests: shell: shell_flash: Fix invalid partition handling" This reverts commit 84262608b556028e028cde61c0b407070fc3796c. Signed-off-by: Jamie McCrae --- tests/subsys/shell/shell_flash/src/shell_flash_test.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/subsys/shell/shell_flash/src/shell_flash_test.c b/tests/subsys/shell/shell_flash/src/shell_flash_test.c index ff8d1bb0db93..f4c51f595146 100644 --- a/tests/subsys/shell/shell_flash/src/shell_flash_test.c +++ b/tests/subsys/shell/shell_flash/src/shell_flash_test.c @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -24,7 +23,7 @@ #else #define SOC_NV_FLASH_NODE DT_CHILD(DT_INST(0, zephyr_sim_flash), flash_sim_0) #endif /* CONFIG_ARCH_POSIX */ -#define FLASH_SIMULATOR_BASE_OFFSET FIXED_PARTITION_NODE_OFFSET(SOC_NV_FLASH_NODE) +#define FLASH_SIMULATOR_BASE_OFFSET DT_REG_ADDR(SOC_NV_FLASH_NODE) /* Test 'flash read' shell command */ ZTEST(shell_flash, test_flash_read) From 7bf23bf956d7110eb86a93b75bfc0d57e5e7d571 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Wed, 18 Mar 2026 08:07:41 +0000 Subject: [PATCH 15/63] Revert "[nrf fromlist] tests: storage: flash_map: Fix testing on sub-partitions" This reverts commit e12a466761eecb74d3e3f1565cbacaa0324cdbc5. Signed-off-by: Jamie McCrae --- tests/subsys/storage/flash_map/src/main.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/tests/subsys/storage/flash_map/src/main.c b/tests/subsys/storage/flash_map/src/main.c index aa47c9e0c70c..7075110bb0a7 100644 --- a/tests/subsys/storage/flash_map/src/main.c +++ b/tests/subsys/storage/flash_map/src/main.c @@ -169,17 +169,8 @@ ZTEST(flash_map, test_fixed_partition_node_macros) */ #if defined(CONFIG_TEST_FLASH_MAP_NODE_MACROS) /* Test against changes in API */ -#if DT_REG_ADDR(DT_PARENT(SLOT1_PARTITION_NODE)) - /* Sub-partition handling */ zassert_equal(FIXED_PARTITION_NODE_OFFSET(SLOT1_PARTITION_NODE), - (DT_REG_ADDR(SLOT1_PARTITION_NODE) - DT_REG_ADDR(DT_PARENT(SLOT1_PARTITION_NODE)))); -#else - /* Partition handling */ - zassert_equal(FIXED_PARTITION_NODE_OFFSET(SLOT1_PARTITION_NODE), - (DT_REG_ADDR(SLOT1_PARTITION_NODE) - DT_REG_ADDR(DT_PARENT( - DT_PARENT(SLOT1_PARTITION_NODE))))); -#endif - + DT_REG_ADDR(SLOT1_PARTITION_NODE)); zassert_equal(FIXED_PARTITION_NODE_SIZE(SLOT1_PARTITION_NODE), DT_REG_SIZE(SLOT1_PARTITION_NODE)); zassert_equal(FIXED_PARTITION_NODE_DEVICE(SLOT1_PARTITION_NODE), From d3affcbcec20254666bce241c7c177bcfa6fb3fc Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Fri, 27 Feb 2026 10:26:13 +0000 Subject: [PATCH 16/63] [nrf fromtree] tests: lib: devicetree: api: Add zephyr,mapped-partition tests Adds tests for this binding Signed-off-by: Jamie McCrae (cherry picked from commit 60285448ed1e532dca24b714fee3e1bd1a3776c3) --- tests/lib/devicetree/api/app.overlay | 91 +++++++++++++++ tests/lib/devicetree/api/src/main.c | 166 ++++++++++++++++++++++++--- 2 files changed, 240 insertions(+), 17 deletions(-) diff --git a/tests/lib/devicetree/api/app.overlay b/tests/lib/devicetree/api/app.overlay index f9b5bd8757c4..49ec63b96891 100644 --- a/tests/lib/devicetree/api/app.overlay +++ b/tests/lib/devicetree/api/app.overlay @@ -883,9 +883,45 @@ test-mtd@ffeeddcc { reg = <0xffeeddcc 0x1000>; + ranges = <0x0 0x0 0x100000>; #address-cells = <1>; #size-cells = <1>; + flash@0 { + compatible = "soc-nv-flash"; + reg = <0x0 0x100000>; + ranges; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; + + /* Purposely not using a partitions {} grouping node */ + partition@0 { + compatible = "zephyr,mapped-partition"; + label = "mapped-partition-1"; + reg = <0x00000000 0x0000c000>; + }; + + partition@c000 { + compatible = "zephyr,mapped-partition"; + label = "mapped-partition-2"; + reg = <0x0000c000 0x00076000>; + }; + + partition@82000 { + compatible = "zephyr,mapped-partition"; + label = "mapped-partition-3"; + reg = <0x00082000 0x00007000>; + }; + + partition@89000 { + compatible = "zephyr,mapped-partition"; + label = "disabled-mapped-partition"; + status = "disabled"; + reg = <0x00089000 0x00007000>; + }; + }; + flash@20000000 { compatible = "soc-nv-flash"; reg = <0x20000000 0x100>; @@ -929,6 +965,8 @@ test-mtd@33221100 { reg = <0x33221100 0x1000>; + #address-cells = <1>; + #size-cells = <1>; partitions { compatible = "fixed-partitions"; @@ -1002,6 +1040,59 @@ }; }; + /* Node purposely not put in test area due to lines being too long for compliance CI */ + test-mtd@12830 { + reg = <0x13830 0x1000>; + ranges = <0x10000000 0x10000000 0x100000>; + #address-cells = <1>; + #size-cells = <1>; + + flash@10000000 { + compatible = "soc-nv-flash"; + reg = <0x10000000 0x100000>; + ranges = <0x0 0x10000000 0x100000>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; + + partitions { + ranges; + #address-cells = <1>; + #size-cells = <1>; + + partition@f8000 { + compatible = "zephyr,mapped-partition"; + label = "mapped-partition-4"; + reg = <0x000f8000 0x00008000>; + ranges = <0x0 0x000f8000 0x00008000>; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + compatible = "zephyr,mapped-partition"; + label = "mapped-partition-5"; + reg = <0x00000000 0x00003000>; + ranges = <0x0 0x00000000 0x00003000>; + #address-cells = <1>; + #size-cells = <1>; + + partition@1000 { + compatible = "zephyr,mapped-partition"; + label = "mapped-partition-6"; + reg = <0x00001000 0x00001000>; + }; + }; + + partition@3000 { + compatible = "zephyr,mapped-partition"; + label = "mapped-partition-7"; + reg = <0x00003000 0x00002000>; + }; + }; + }; + }; + }; + interrupt-map-test { #address-cells = <2>; #size-cells = <0>; diff --git a/tests/lib/devicetree/api/src/main.c b/tests/lib/devicetree/api/src/main.c index 5d7ac3fee534..a2fb0aa5bba1 100644 --- a/tests/lib/devicetree/api/src/main.c +++ b/tests/lib/devicetree/api/src/main.c @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -98,6 +99,7 @@ #define TEST_MTD_0 DT_PATH(test, test_mtd_ffeeddcc) #define TEST_MTD_1 DT_PATH(test, test_mtd_33221100) +#define TEST_MTD_2 DT_PATH(test_mtd_12830) #define TEST_MEM_0 DT_CHILD(TEST_MTD_0, flash_20000000) @@ -112,6 +114,22 @@ #define TEST_SUBPARTITION_1 DT_PATH(test, test_mtd_ffeeddcc, flash_20000000, partitions, \ partition_100, partition_40) +#define TEST_FLASH_0 DT_PATH(test, test_mtd_ffeeddcc, flash_0) +#define TEST_FLASH_1 DT_PATH(test_mtd_12830, flash_10000000) + +#define TEST_MAPPED_PARTITION_1 DT_PATH(test, test_mtd_ffeeddcc, flash_0, partition_0) +#define TEST_MAPPED_PARTITION_2 DT_PATH(test, test_mtd_ffeeddcc, flash_0, partition_c000) +#define TEST_MAPPED_PARTITION_3 DT_PATH(test, test_mtd_ffeeddcc, flash_0, partition_82000) +#define TEST_MAPPED_PARTITION_4 DT_PATH(test_mtd_12830, flash_10000000, partitions, \ + partition_f8000) +#define TEST_MAPPED_PARTITION_5 DT_PATH(test_mtd_12830, flash_10000000, partitions, \ + partition_f8000, partition_0) +#define TEST_MAPPED_PARTITION_6 DT_PATH(test_mtd_12830, flash_10000000, partitions, \ + partition_f8000, partition_0, partition_1000) +#define TEST_MAPPED_PARTITION_7 DT_PATH(test_mtd_12830, flash_10000000, partitions, \ + partition_f8000, partition_3000) +#define TEST_DISABLED_MAPPED_PARTITION DT_PATH(test, test_mtd_ffeeddcc, flash_0, partition_89000) + #define TEST_GPIO_CONNECTOR DT_PATH(gpio_map_test, connector) #define TEST_INTERRUPT_NEXUS DT_PATH(interrupt_map_test, nexus) #define TEST_INTERRUPT_NEXUS_EMPTY DT_PATH(interrupt_map_test, empty) @@ -3329,23 +3347,6 @@ ZTEST(devicetree_api, test_fixed_partitions) zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_0), 0x20000000); zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_1), 0x200000c0); zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_2), 0x33291080); - - /* Test that all DT_FIXED_PARTITION_ID are defined and unique. */ -#define FIXED_PARTITION_ID_COMMA(node_id) DT_FIXED_PARTITION_ID(node_id), - - static const int ids[] = { - DT_FOREACH_STATUS_OKAY_VARGS(fixed_partitions, DT_FOREACH_CHILD, - FIXED_PARTITION_ID_COMMA) - }; - bool found[ARRAY_SIZE(ids)] = { false }; - - for (int i = 0; i < ARRAY_SIZE(ids); i++) { - zassert_between_inclusive(ids[i], 0, ARRAY_SIZE(ids) - 1, ""); - zassert_false(found[ids[i]]); - found[ids[i]] = true; - } - -#undef FIXED_PARTITION_ID_COMMA } ZTEST(devicetree_api, test_fixed_subpartitions) @@ -3379,6 +3380,137 @@ ZTEST(devicetree_api, test_fixed_subpartitions) (DT_REG_SIZE(TEST_SUBPARTITION_0) + DT_REG_SIZE(TEST_SUBPARTITION_1))); } +ZTEST(devicetree_api, test_mapped_partition) +{ + /* Test finding fixed partitions by the 'label' property. */ + zassert_false(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_0)); + zassert_true(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_1)); + zassert_true(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_1)); + zassert_true(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_2)); + zassert_true(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_3)); + zassert_true(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_4)); + zassert_true(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_5)); + zassert_true(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_6)); + zassert_true(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_7)); + zassert_true(DT_HAS_MAPPED_PARTITION_LABEL(disabled_mapped_partition)); + + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_1, + DT_NODE_BY_MAPPED_PARTITION_LABEL(mapped_partition_1))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_2, + DT_NODE_BY_MAPPED_PARTITION_LABEL(mapped_partition_2))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_3, + DT_NODE_BY_MAPPED_PARTITION_LABEL(mapped_partition_3))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_4, + DT_NODE_BY_MAPPED_PARTITION_LABEL(mapped_partition_4))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_5, + DT_NODE_BY_MAPPED_PARTITION_LABEL(mapped_partition_5))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_6, + DT_NODE_BY_MAPPED_PARTITION_LABEL(mapped_partition_6))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_7, + DT_NODE_BY_MAPPED_PARTITION_LABEL(mapped_partition_7))); + zassert_true(DT_SAME_NODE(TEST_DISABLED_MAPPED_PARTITION, + DT_NODE_BY_MAPPED_PARTITION_LABEL(disabled_mapped_partition))); + + zassert_true(DT_MAPPED_PARTITION_EXISTS(TEST_MAPPED_PARTITION_1)); + zassert_true(DT_MAPPED_PARTITION_EXISTS(TEST_MAPPED_PARTITION_2)); + zassert_true(DT_MAPPED_PARTITION_EXISTS(TEST_MAPPED_PARTITION_3)); + zassert_true(DT_MAPPED_PARTITION_EXISTS(TEST_MAPPED_PARTITION_4)); + zassert_true(DT_MAPPED_PARTITION_EXISTS(TEST_MAPPED_PARTITION_5)); + zassert_true(DT_MAPPED_PARTITION_EXISTS(TEST_MAPPED_PARTITION_6)); + zassert_true(DT_MAPPED_PARTITION_EXISTS(TEST_MAPPED_PARTITION_7)); + zassert_true(DT_MAPPED_PARTITION_EXISTS(TEST_DISABLED_MAPPED_PARTITION)); + + /* There should not be a node with `label = "mapped-partition-8"`. */ + zassert_false(DT_HAS_MAPPED_PARTITION_LABEL(mapped_partition_8)); + zassert_false(DT_NODE_EXISTS(DT_NODE_BY_MAPPED_PARTITION_LABEL(mapped_partition_8))); + + /* Test DT_MTD_FROM_MAPPED_PARTITION. */ + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_1))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_2))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_3))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_4))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_5))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_6))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_7))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_MAPPED_PARTITION(TEST_DISABLED_MAPPED_PARTITION))); + + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_1))); + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_2))); + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_3))); + zassert_true(DT_SAME_NODE(TEST_MTD_2, DT_MTD_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_4))); + zassert_true(DT_SAME_NODE(TEST_MTD_2, DT_MTD_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_5))); + zassert_true(DT_SAME_NODE(TEST_MTD_2, DT_MTD_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_6))); + zassert_true(DT_SAME_NODE(TEST_MTD_2, DT_MTD_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_7))); + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_MAPPED_PARTITION( + TEST_DISABLED_MAPPED_PARTITION))); + + /* Test DT_MEM_FROM_MAPPED_PARTITION. */ + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_1))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_2))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_3))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_4))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_5))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_6))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_MAPPED_PARTITION(TEST_MAPPED_PARTITION_7))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_MAPPED_PARTITION(TEST_DISABLED_MAPPED_PARTITION))); + + zassert_true(DT_SAME_NODE(TEST_FLASH_0, DT_MEM_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_1))); + zassert_true(DT_SAME_NODE(TEST_FLASH_0, DT_MEM_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_2))); + zassert_true(DT_SAME_NODE(TEST_FLASH_0, DT_MEM_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_3))); + zassert_true(DT_SAME_NODE(TEST_FLASH_1, DT_MEM_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_4))); + zassert_true(DT_SAME_NODE(TEST_FLASH_1, DT_MEM_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_5))); + zassert_true(DT_SAME_NODE(TEST_FLASH_1, DT_MEM_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_6))); + zassert_true(DT_SAME_NODE(TEST_FLASH_1, DT_MEM_FROM_MAPPED_PARTITION( + TEST_MAPPED_PARTITION_7))); + zassert_true(DT_SAME_NODE(TEST_FLASH_0, DT_MEM_FROM_MAPPED_PARTITION( + TEST_DISABLED_MAPPED_PARTITION))); + + /* Test DT_MAPPED_PARTITION_ADDR. */ + zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_MAPPED_PARTITION_1), 0x0); + zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_MAPPED_PARTITION_2), 0xc000); + zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_MAPPED_PARTITION_3), 0x82000); + zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_MAPPED_PARTITION_4), 0x100f8000); + zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_MAPPED_PARTITION_5), 0x100f8000); + zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_MAPPED_PARTITION_6), 0x100f9000); + zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_MAPPED_PARTITION_7), 0x100fb000); + zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_DISABLED_MAPPED_PARTITION), 0x89000); + + /* Test that all DT_MAPPED_PARTITION_ID are defined and unique. */ +#define FIXED_PARTITION_ID_COMMA(node_id) DT_FIXED_PARTITION_ID(node_id), +#define MAPPED_PARTITION_ID_COMMA(node_id) DT_MAPPED_PARTITION_ID(node_id), + + static const int ids[] = { + DT_FOREACH_STATUS_OKAY_VARGS(fixed_partitions, DT_FOREACH_CHILD, + FIXED_PARTITION_ID_COMMA) + DT_FOREACH_STATUS_OKAY_VARGS(fixed_subpartitions, DT_FOREACH_CHILD, + FIXED_PARTITION_ID_COMMA) + DT_FOREACH_STATUS_OKAY_VARGS(zephyr_mapped_partitions, DT_FOREACH_CHILD, + MAPPED_PARTITION_ID_COMMA) + }; + bool found[20] = { false }; + + for (int i = 0; i < ARRAY_SIZE(ids); i++) { + zassert_between_inclusive(ids[i], 0, ARRAY_SIZE(found) - 1, ""); + zassert_false(found[ids[i]]); + found[ids[i]] = true; + } + +#undef FIXED_PARTITION_ID_COMMA +} + ZTEST(devicetree_api, test_string_token) { #undef DT_DRV_COMPAT From bf075dde80acdcabe0e89e879b616e6ed580c011 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Fri, 27 Feb 2026 09:09:00 +0000 Subject: [PATCH 17/63] [nrf fromtree] dfu: img_util: flash_img: Add support for zephyr,mapped-partition Allows using this system with zephyr,mapped-partition bindings Signed-off-by: Jamie McCrae (cherry picked from commit 4b24aeec22877ca283567a17b38ee140171e1832) --- subsys/dfu/img_util/flash_img.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/subsys/dfu/img_util/flash_img.c b/subsys/dfu/img_util/flash_img.c index 2e6a5e7485fb..48a0897e8cf8 100644 --- a/subsys/dfu/img_util/flash_img.c +++ b/subsys/dfu/img_util/flash_img.c @@ -23,12 +23,17 @@ LOG_MODULE_REGISTER(flash_img, CONFIG_IMG_MANAGER_LOG_LEVEL); #include #endif +#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) +#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \ + DT_SAME_NODE(DT_CHOSEN(zephyr_code_partition), DT_NODELABEL(label)) +#else #define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \ DT_SAME_NODE(FIXED_PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)), \ FIXED_PARTITION_MTD(label)) && (FIXED_PARTITION_ADDRESS(label) <= \ (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) && \ FIXED_PARTITION_ADDRESS(label) + FIXED_PARTITION_SIZE(label) > \ (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET)) +#endif #if defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) && (CONFIG_TFM_MCUBOOT_IMAGE_NUMBER == 2) #define UPLOAD_FLASH_AREA_LABEL slot1_ns_partition From be15a09422a25e807d67f893f958c45f5fcc5b4e Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Mon, 23 Feb 2026 11:50:59 +0000 Subject: [PATCH 18/63] [nrf fromtree] mgmt: mcumgr: grp: img_mgmt: Add support for zephyr,mapped-partition Prevents checking if the flash offset Kconfig is defined Signed-off-by: Jamie McCrae (cherry picked from commit 872905f2f328930671d75b89d48814429c5d8582) --- subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c index edcacd4cfd8c..8de109718ada 100644 --- a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c +++ b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c @@ -43,6 +43,10 @@ #if !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD) +#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) +#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \ + DT_SAME_NODE(DT_CHOSEN(zephyr_code_partition), DT_NODELABEL(label)) +#else #ifndef CONFIG_FLASH_LOAD_OFFSET #error MCUmgr requires application to be built with CONFIG_FLASH_LOAD_OFFSET set \ to be able to figure out application running slot. @@ -54,6 +58,7 @@ (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) && \ FIXED_PARTITION_ADDRESS(label) + FIXED_PARTITION_SIZE(label) > \ (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET)) +#endif BUILD_ASSERT(sizeof(struct image_header) == IMAGE_HEADER_SIZE, "struct image_header not required size"); From dbfaa9be4b13bfc8f652bc0d37ad656fe6797f66 Mon Sep 17 00:00:00 2001 From: Valerio Setti Date: Thu, 30 Oct 2025 23:01:43 +0100 Subject: [PATCH 19/63] [nrf fromtree] secure_storage: add dependency for Settings backend Secure Storage is used as PSA ITS in builds where TF-M is not enabled, but it needs a storage backend where to physically save data. If CONFIG_SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_ZMS is used then its "depends on" guarantee that there is a partition to use as physical storage. If CONFIG_SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_SETTINGS is used instead we want to ensure that CONFIG_SETTINGS_NONE doesn't gets selected which would result in Settings not being able to store data anywhere. This commit add a depends_on for this last case. Signed-off-by: Valerio Setti (cherry picked from commit d07102ecf99e03ceef90fdf90e786dbe87396149) --- subsys/secure_storage/Kconfig.its_store | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/secure_storage/Kconfig.its_store b/subsys/secure_storage/Kconfig.its_store index c924def563fa..ba4c5c5c0e48 100644 --- a/subsys/secure_storage/Kconfig.its_store +++ b/subsys/secure_storage/Kconfig.its_store @@ -31,7 +31,7 @@ config SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_SETTINGS && $(dt_node_has_compat,$(dt_node_parent,$(DT_SETTINGS_PARTITIION)),fixed-partitions))\ || ($(dt_path_enabled,$(DT_STORAGE_PARTITION)) \ && $(dt_node_has_compat,$(dt_node_parent,$(DT_STORAGE_PARTITION)),fixed-partitions))) - depends on SETTINGS + depends on SETTINGS && !SETTINGS_NONE config SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_NONE bool "No ITS store module implementation" From 44b98cd085838e23966796236823f59423eaddf5 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Tue, 24 Feb 2026 16:31:07 +0000 Subject: [PATCH 20/63] [nrf fromtree] secure_storage: kconfig: Add support for zephyr,mapped-partition Adds support for this binding to the Kconfig Signed-off-by: Jamie McCrae (cherry picked from commit 0b6b5bfe34b146271f160214454510e501a6e7b1) --- subsys/secure_storage/Kconfig.its_store | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/subsys/secure_storage/Kconfig.its_store b/subsys/secure_storage/Kconfig.its_store index ba4c5c5c0e48..290111943495 100644 --- a/subsys/secure_storage/Kconfig.its_store +++ b/subsys/secure_storage/Kconfig.its_store @@ -8,12 +8,14 @@ DT_ITS_PARTITION := $(dt_chosen_path,secure_storage_its_partition) DT_CHOSEN_Z_SETTINGS_PARTITION := zephyr,settings-partition DT_SETTINGS_PARTITIION := $(dt_chosen_path,$(DT_CHOSEN_Z_SETTINGS_PARTITION)) DT_STORAGE_PARTITION := $(dt_nodelabel_path,storage_partition) +DT_COMPAT_Z_MAPPED_PARTITION := zephyr,mapped-partition config SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_ZMS bool "ITS store module implementation using ZMS for storage" depends on FLASH_HAS_DRIVER_ENABLED \ - && $(dt_path_enabled,$(DT_ITS_PARTITION)) \ - && $(dt_node_has_compat,$(dt_node_parent,$(DT_ITS_PARTITION)),fixed-partitions) + && $(dt_path_enabled,$(DT_ITS_PARTITION)) \ + && ($(dt_node_has_compat,$(dt_node_parent,$(DT_ITS_PARTITION)),fixed-partitions) \ + || $(dt_node_has_compat,$(DT_ITS_PARTITION),$(DT_COMPAT_Z_MAPPED_PARTITION))) depends on ZMS help This implementation of the ITS store module makes direct use of ZMS for storage. @@ -27,10 +29,12 @@ config SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_ZMS config SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_SETTINGS bool "ITS store module implementation using the settings subsystem for storage" depends on FLASH_HAS_DRIVER_ENABLED \ - && (($(dt_path_enabled,$(DT_SETTINGS_PARTITIION)) \ - && $(dt_node_has_compat,$(dt_node_parent,$(DT_SETTINGS_PARTITIION)),fixed-partitions))\ - || ($(dt_path_enabled,$(DT_STORAGE_PARTITION)) \ - && $(dt_node_has_compat,$(dt_node_parent,$(DT_STORAGE_PARTITION)),fixed-partitions))) + && ($(dt_path_enabled,$(DT_SETTINGS_PARTITIION)) \ + && ($(dt_node_has_compat,$(dt_node_parent,$(DT_SETTINGS_PARTITIION)),fixed-partitions) \ + || $(dt_node_has_compat,$(DT_SETTINGS_PARTITIION),$(DT_COMPAT_Z_MAPPED_PARTITION))) \ + || ($(dt_path_enabled,$(DT_STORAGE_PARTITION)) \ + && ($(dt_node_has_compat,$(dt_node_parent,$(DT_STORAGE_PARTITION)),fixed-partitions) \ + || $(dt_node_has_compat,$(DT_STORAGE_PARTITION),$(DT_COMPAT_Z_MAPPED_PARTITION))))) depends on SETTINGS && !SETTINGS_NONE config SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_NONE From 00e0dd444e14855ff9501bc5c9f1d7856009405c Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Fri, 23 Jan 2026 13:27:03 +0000 Subject: [PATCH 21/63] [nrf fromtree] west.yml: MCUboot synchronization from upstream Update Zephyr fork of MCUboot to revision: cb6e4ceaacd4dfe1e3cdeb92c7f5680f62967837 Brings following Zephyr relevant fixes: - 086a6efe boot: zephyr: sysbuild: cmake: Rework sysbuild hooks - 313311b8 boot: bootutil: loader: Add error codes to log messages - 65d7f3d3 ext: nrf: cc310_glue: Fix include path - b54b3284 boot: zephyr: cmake: Fix multitude of issues - 9c10463c boot: zephyr: kconfig: Misc. tidy - 4775b1d3 boot: zephyr: kconfig: Fix options being out of menu - e6067906 boot: zephyr: boot_serial_extension: Remove include - e479b4c0 boot: zephyr: Add ECDSA support using mbedTLS - 10270036 samples: zephyr: Remove hello-world - 31fcf095 boot: zephyr: Do not select RSA key exchange in BOOT_SIGNATURE_TYPE_RSA Signed-off-by: Jamie McCrae (cherry picked from commit 66ee2d2304eea0c1fa4508763f0b978d6681cea0) --- west.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/west.yml b/west.yml index 0beafdc411ba..afa2f15080ad 100644 --- a/west.yml +++ b/west.yml @@ -326,7 +326,7 @@ manifest: groups: - crypto - name: mcuboot - revision: 9ac72969f281491d677e669d053281fc2d538ed4 + revision: cb6e4ceaacd4dfe1e3cdeb92c7f5680f62967837 path: bootloader/mcuboot groups: - bootloader From c3a51537058a11c2c040ac56f663c03ca6f2d84d Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Wed, 28 Jan 2026 14:10:36 +0000 Subject: [PATCH 22/63] [nrf fromtree] west.yml: MCUboot synchronization from upstream Update Zephyr fork of MCUboot to revision: d9c2ba153128efd7c16db9f36dea4ee69f63c7f5 Brings following Zephyr relevant fixes: - d9c2ba15 boot: bootutil: Add missing swap offset file and fix RAM load - 9c45fb79 boot: bootutil: Fix extra . in logging output - 089dd179 boot: zephyr: Rename nRF54H Kconfig symbol usage - 6c294367 boot: zephyr: cmake: Fix Zephyr version file define Signed-off-by: Jamie McCrae (cherry picked from commit f37ec7ab852f309dd01f7fb6f29aebbac762196c) --- west.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/west.yml b/west.yml index afa2f15080ad..a65a9edbc6dc 100644 --- a/west.yml +++ b/west.yml @@ -326,7 +326,7 @@ manifest: groups: - crypto - name: mcuboot - revision: cb6e4ceaacd4dfe1e3cdeb92c7f5680f62967837 + revision: d9c2ba153128efd7c16db9f36dea4ee69f63c7f5 path: bootloader/mcuboot groups: - bootloader From 716cef032c6eaa5e319b36ccf1edf32f704ad662 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Fri, 6 Mar 2026 12:17:01 +0000 Subject: [PATCH 23/63] [nrf fromtree] west.yml: MCUboot synchronization from upstream Update Zephyr fork of MCUboot to revision: 6fc2d6b3b8bf86961fa066b828ff0b05c07a0c15 Brings following Zephyr relevant fixes: - 6fc2d6b3 boot: zephyr: kconfig: add choice for RSA crypto library - b3aad0f7 bootutil: remove useless code from bootutil_rsa_parse_public_key() - 6ba21a96 bootutil: update sha calls to legacy Mbed TLS - 7448115e imgtool: dumpinfo -f,--format option - a953b365 boot: bootutil: image_validate: Fix swap-offset pure mode address - 086c0b4d boot: zephyr: capture lost early and late log events - b893d34f boot: zephyr: cmake: Improve support for NVM device finding - 549182be boot: bootutil: image_ed25519: Fix inbuilt key usage - e1041fcb boot: zephyr: Add support for external PSA crypto library - fc649e9a boot: zephyr: Add support for inbuilt key - d5bf7a6a boot: bootutil: bootutil_find_key: Fix definition Signed-off-by: Jamie McCrae (cherry picked from commit db95825469fd0c17fe374120bd459e499026b5a8) --- west.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/west.yml b/west.yml index a65a9edbc6dc..454df0c3ca25 100644 --- a/west.yml +++ b/west.yml @@ -326,7 +326,7 @@ manifest: groups: - crypto - name: mcuboot - revision: d9c2ba153128efd7c16db9f36dea4ee69f63c7f5 + revision: 6fc2d6b3b8bf86961fa066b828ff0b05c07a0c15 path: bootloader/mcuboot groups: - bootloader From d1b86d4bf3412c147c2bac93473fe2d102b77da6 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Mon, 23 Feb 2026 11:52:14 +0000 Subject: [PATCH 24/63] [nrf fromtree] dts: nordic: nrf52840dk: Update to use zephyr,mapped-partitions Updates the dts nodes to move the flash0 device to the top level soc node and switches partitions to use the new zephyr,mapped-partition compatible. Also includes an MCUboot update to update to the new binding: west.yml: MCUboot synchronization from upstream Update Zephyr fork of MCUboot to revision: 9eac8cb5f4fedb3500986c5877277ef80606c4b0 Brings following Zephyr relevant fixes: - 2750a58c boot: zephyr: Remove invalid RISCV copying swap image to RAM code - 1d627c05 boot: bootutil: Include ih_protect_tlv_size in size validation - a4b43f26 boot: zephyr: cmake: handle devicetree compatible properties as lists - 15da362b boot: zephyr: Switch to partition macros without FIXED_ prefix - 302563c6 boot: zephyr: boards: Update nrf52840-board overlay bindings - ab12e5a0 boot: zephyr: use DT_REG_*() macros - fd6b7c9d boot: zephyr: remove forced sector max - f84b9d3f boot: zephyr: call LOG_PANIC before jumping to app to flush in flight logs Signed-off-by: Jamie McCrae (cherry picked from commit 00110538b1b5e2ac4ce9b8708a2102f812c69505) --- boards/nordic/nrf21540dk/nrf21540dk_nrf52840.dts | 6 +++++- .../nrf52840dongle/nrf52840dongle_nrf52840.dts | 6 +++++- .../nrf52840dongle_nrf52840_bare.dts | 6 +++++- dts/arm/nordic/nrf52840.dtsi | 12 +++++++++++- dts/arm/nordic/nrf52840_qfaa.dtsi | 15 --------------- dts/arm/nordic/nrf52840_qiaa.dtsi | 15 --------------- dts/vendor/nordic/nrf52840_partition.dtsi | 6 +++++- .../fs_sample/boards/nrf52840dk_nrf52840.overlay | 7 +++---- .../boards/nrf52840dk_nrf52840.overlay | 7 +++---- .../boards/nrf52840dk_nrf52840.overlay | 7 +++---- .../boards/nrf52840dk_nrf52840_mem.overlay | 7 +++---- .../boards/nrf52840dk_nrf52840_dual_slot.overlay | 9 +++++---- .../fcb/boards/nrf52840dk_nrf52840.overlay | 5 +---- .../fcb_init/src/settings_test_fcb_init.c | 9 +++++++-- west.yml | 2 +- 15 files changed, 57 insertions(+), 62 deletions(-) diff --git a/boards/nordic/nrf21540dk/nrf21540dk_nrf52840.dts b/boards/nordic/nrf21540dk/nrf21540dk_nrf52840.dts index 801782c35efe..e78122660716 100644 --- a/boards/nordic/nrf21540dk/nrf21540dk_nrf52840.dts +++ b/boards/nordic/nrf21540dk/nrf21540dk_nrf52840.dts @@ -273,21 +273,24 @@ fem_spi: &spi3 { &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x0000c000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x00076000>; }; slot1_partition: partition@82000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00082000 0x00076000>; }; @@ -302,6 +305,7 @@ fem_spi: &spi3 { * if enabled. */ storage_partition: partition@f8000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000f8000 0x00008000>; }; diff --git a/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840.dts b/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840.dts index e446c5aaf54e..3cb02df53c9d 100644 --- a/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840.dts +++ b/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840.dts @@ -12,7 +12,7 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; @@ -21,21 +21,25 @@ * be built with CDC ACM support and w/o optimizations. */ boot_partition: partition@1000 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00001000 0x0000f000>; }; slot0_partition: partition@10000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00010000 0x00066000>; }; slot1_partition: partition@76000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00076000 0x00066000>; }; storage_partition: partition@dc000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000dc000 0x00004000>; }; diff --git a/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_bare.dts b/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_bare.dts index b8b76a8e63be..74ac37ef0adb 100644 --- a/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_bare.dts +++ b/boards/nordic/nrf52840dongle/nrf52840dongle_nrf52840_bare.dts @@ -12,7 +12,7 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; @@ -20,21 +20,25 @@ * with an RTT console, CDC ACM support, and w/o optimizations. */ boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x00012000>; }; slot0_partition: partition@12000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00012000 0x00075000>; }; slot1_partition: partition@87000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00087000 0x00075000>; }; storage_partition: partition@fc000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000fc000 0x00004000>; }; diff --git a/dts/arm/nordic/nrf52840.dtsi b/dts/arm/nordic/nrf52840.dtsi index 15052e2e82a4..ee290fb74561 100644 --- a/dts/arm/nordic/nrf52840.dtsi +++ b/dts/arm/nordic/nrf52840.dtsi @@ -45,6 +45,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@10000000 { compatible = "nordic,nrf-ficr"; reg = <0x10000000 0x1000>; @@ -60,6 +62,8 @@ sram0: memory@20000000 { compatible = "mmio-sram"; + reg = <0x20000000 DT_SIZE_K(256)>; + ranges = <0x0 0x20000000 DT_SIZE_K(256)>; #address-cells = <1>; #size-cells = <1>; }; @@ -423,8 +427,9 @@ flash_controller: flash-controller@4001e000 { compatible = "nordic,nrf52-flash-controller"; reg = <0x4001e000 0x1000>; + ranges = <0x0 0x0 DT_SIZE_K(1024)>; partial-erase; - + status = "okay"; #address-cells = <1>; #size-cells = <1>; @@ -432,6 +437,11 @@ compatible = "soc-nv-flash"; erase-block-size = <4096>; write-block-size = <4>; + reg = <0x0 DT_SIZE_K(1024)>; + ranges; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; }; }; diff --git a/dts/arm/nordic/nrf52840_qfaa.dtsi b/dts/arm/nordic/nrf52840_qfaa.dtsi index 9c4b70a10d0b..9b7a8c105f13 100644 --- a/dts/arm/nordic/nrf52840_qfaa.dtsi +++ b/dts/arm/nordic/nrf52840_qfaa.dtsi @@ -7,19 +7,4 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - -&sram0 { - reg = <0x20000000 DT_SIZE_K(256)>; - ranges = <0x0 0x20000000 DT_SIZE_K(256)>; -}; - -/ { - soc { - compatible = "simple-bus"; - }; -}; - /delete-node/ &usbd; diff --git a/dts/arm/nordic/nrf52840_qiaa.dtsi b/dts/arm/nordic/nrf52840_qiaa.dtsi index 3ad3537a05d7..b83f0bde4033 100644 --- a/dts/arm/nordic/nrf52840_qiaa.dtsi +++ b/dts/arm/nordic/nrf52840_qiaa.dtsi @@ -7,15 +7,6 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - -&sram0 { - reg = <0x20000000 DT_SIZE_K(256)>; - ranges = <0x0 0x20000000 DT_SIZE_K(256)>; -}; - &power { reg0: regulator@40000580 { compatible = "nordic,nrf52x-regulator-hv"; @@ -24,9 +15,3 @@ status = "disabled"; }; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/vendor/nordic/nrf52840_partition.dtsi b/dts/vendor/nordic/nrf52840_partition.dtsi index 8b5df504d422..4d6c5d4b8557 100644 --- a/dts/vendor/nordic/nrf52840_partition.dtsi +++ b/dts/vendor/nordic/nrf52840_partition.dtsi @@ -14,21 +14,24 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x0000c000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x00076000>; }; slot1_partition: partition@82000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00082000 0x00076000>; }; @@ -43,6 +46,7 @@ * if enabled. */ storage_partition: partition@f8000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000f8000 0x00008000>; }; diff --git a/samples/subsys/fs/fs_sample/boards/nrf52840dk_nrf52840.overlay b/samples/subsys/fs/fs_sample/boards/nrf52840dk_nrf52840.overlay index fe4e532b471c..25473f52ddec 100644 --- a/samples/subsys/fs/fs_sample/boards/nrf52840dk_nrf52840.overlay +++ b/samples/subsys/fs/fs_sample/boards/nrf52840dk_nrf52840.overlay @@ -17,19 +17,18 @@ &flash0 { partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; reg = <0x0000c000 0x00066000>; }; slot1_partition: partition@72000 { + compatible = "zephyr,mapped-partition"; reg = <0x00072000 0x00066000>; }; storage_partition: partition@d8000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000d8000 0x00028000>; }; diff --git a/tests/boot/mcuboot_data_sharing/boards/nrf52840dk_nrf52840.overlay b/tests/boot/mcuboot_data_sharing/boards/nrf52840dk_nrf52840.overlay index 307d2b890fb0..69d15c05e194 100644 --- a/tests/boot/mcuboot_data_sharing/boards/nrf52840dk_nrf52840.overlay +++ b/tests/boot/mcuboot_data_sharing/boards/nrf52840dk_nrf52840.overlay @@ -42,21 +42,20 @@ &flash0 { partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x00020000>; }; slot0_partition: partition@20000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00020000 0x00022000>; }; slot1_partition: partition@42000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00042000 0x00023000>; }; diff --git a/tests/boot/mcuboot_recovery_retention/boards/nrf52840dk_nrf52840.overlay b/tests/boot/mcuboot_recovery_retention/boards/nrf52840dk_nrf52840.overlay index 89843ccf6875..ab88f44fb404 100644 --- a/tests/boot/mcuboot_recovery_retention/boards/nrf52840dk_nrf52840.overlay +++ b/tests/boot/mcuboot_recovery_retention/boards/nrf52840dk_nrf52840.overlay @@ -16,21 +16,20 @@ &flash0 { partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x00020000>; }; slot0_partition: partition@20000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00020000 0x00020000>; }; slot1_partition: partition@40000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00040000 0x00020000>; }; diff --git a/tests/boot/mcuboot_recovery_retention/boards/nrf52840dk_nrf52840_mem.overlay b/tests/boot/mcuboot_recovery_retention/boards/nrf52840dk_nrf52840_mem.overlay index a61ee5db8746..812cba932723 100644 --- a/tests/boot/mcuboot_recovery_retention/boards/nrf52840dk_nrf52840_mem.overlay +++ b/tests/boot/mcuboot_recovery_retention/boards/nrf52840dk_nrf52840_mem.overlay @@ -45,21 +45,20 @@ &flash0 { partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x00020000>; }; slot0_partition: partition@20000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00020000 0x00020000>; }; slot1_partition: partition@40000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00040000 0x00020000>; }; diff --git a/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/boards/nrf52840dk_nrf52840_dual_slot.overlay b/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/boards/nrf52840dk_nrf52840_dual_slot.overlay index 4d5de021baa4..f4d4ff21d4c8 100644 --- a/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/boards/nrf52840dk_nrf52840_dual_slot.overlay +++ b/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/boards/nrf52840dk_nrf52840_dual_slot.overlay @@ -10,31 +10,32 @@ &flash0 { partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x10000>; }; slot0_partition: partition@10000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00010000 0x40000>; }; slot1_partition: partition@50000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00050000 0x40000>; }; slot2_partition: partition@90000 { + compatible = "zephyr,mapped-partition"; label = "image-2"; reg = <0x00090000 0x30000>; }; slot3_partition: partition@c0000 { + compatible = "zephyr,mapped-partition"; label = "image-3"; reg = <0x000c0000 0x30000>; }; diff --git a/tests/subsys/settings/fcb/boards/nrf52840dk_nrf52840.overlay b/tests/subsys/settings/fcb/boards/nrf52840dk_nrf52840.overlay index dada2d62ce14..41f6de157b30 100644 --- a/tests/subsys/settings/fcb/boards/nrf52840dk_nrf52840.overlay +++ b/tests/subsys/settings/fcb/boards/nrf52840dk_nrf52840.overlay @@ -8,11 +8,8 @@ &flash0 { partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - storage_partition: partition@de000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000de000 0x00010000>; }; diff --git a/tests/subsys/settings/fcb_init/src/settings_test_fcb_init.c b/tests/subsys/settings/fcb_init/src/settings_test_fcb_init.c index 8e3be17c4b35..b7815a44ec3e 100644 --- a/tests/subsys/settings/fcb_init/src/settings_test_fcb_init.c +++ b/tests/subsys/settings/fcb_init/src/settings_test_fcb_init.c @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -34,16 +35,20 @@ static uint32_t val32; /* leverage that this area has to be embedded flash part */ #if CODE_PARTITION_EXISTS -#if DT_NODE_HAS_PROP(DT_GPARENT(CODE_PARTITION_NODE), write_block_size) +#if DT_NODE_HAS_COMPAT(CODE_PARTITION_NODE, zephyr_mapped_partition) && \ + DT_NODE_HAS_PROP(DT_MEM_FROM_FIXED_PARTITION(CODE_PARTITION_NODE), write_block_size) +#define FLASH_WRITE_BLOCK_SIZE \ + DT_PROP(DT_MEM_FROM_FIXED_PARTITION(CODE_PARTITION_NODE), write_block_size) +#elif DT_NODE_HAS_PROP(DT_GPARENT(CODE_PARTITION_NODE), write_block_size) #define FLASH_WRITE_BLOCK_SIZE \ DT_PROP(DT_GPARENT(CODE_PARTITION_NODE), write_block_size) +#endif static const volatile __attribute__((section(".rodata"))) __aligned(FLASH_WRITE_BLOCK_SIZE) uint8_t prepared_mark[FLASH_WRITE_BLOCK_SIZE] = {ERASED_VAL}; #else #error "Test not prepared to run from flash with no write-block-size property in DTS" #endif -#endif static int c1_set(const char *name, size_t len, settings_read_cb read_cb, void *cb_arg) diff --git a/west.yml b/west.yml index 454df0c3ca25..a65641a705bf 100644 --- a/west.yml +++ b/west.yml @@ -326,7 +326,7 @@ manifest: groups: - crypto - name: mcuboot - revision: 6fc2d6b3b8bf86961fa066b828ff0b05c07a0c15 + revision: 9eac8cb5f4fedb3500986c5877277ef80606c4b0 path: bootloader/mcuboot groups: - bootloader From 0417a27c2c41b24ee5990a013a7d423b0bc58a2e Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 26 Feb 2026 08:50:45 +0000 Subject: [PATCH 25/63] [nrf fromtree] dts: nordic: nrf5340: Update to use zephyr,mapped-partitions Updates the dts nodes to move the flash devices to the top level soc node and switches partitions to use the new zephyr,mapped-partition compatible. Signed-off-by: Jamie McCrae (cherry picked from commit 8116b005fdf263f8a730aa23729ed30d7bfe71e5) --- .../bl5340_dvk_nrf5340_cpunet_common.dtsi | 13 ++++------- .../nrf_bsim/nrf5340bsim_nrf5340_cpuapp.dts | 4 +++- .../nrf_bsim/nrf5340bsim_nrf5340_cpunet.dts | 2 +- .../nrf5340_audio_dk_nrf5340_cpunet.dts | 5 ++++- .../nrf5340dk/nrf5340dk_nrf5340_cpunet.dts | 5 ++++- .../nrf7002dk/nrf7002dk_nrf5340_cpunet.dts | 5 ++++- .../thingy53/thingy53_nrf5340_cpunet.dts | 5 ++++- .../pan1783_nrf5340_cpunet_common.dtsi | 5 ++++- .../raytac_an7002q_db_nrf5340_cpunet.dts | 5 ++++- ...tac_mdbt53_db_40_nrf5340_cpunet_common.dts | 5 ++++- ...ac_mdbt53v_db_40_nrf5340_cpunet_common.dts | 5 ++++- dts/arm/nordic/nrf5340_cpuapp.dtsi | 22 +++++++++++++++++++ dts/arm/nordic/nrf5340_cpuapp_ns.dtsi | 22 +++++++++++++++++++ dts/arm/nordic/nrf5340_cpuapp_ns_qkaa.dtsi | 10 --------- .../nordic/nrf5340_cpuapp_peripherals.dtsi | 15 ------------- dts/arm/nordic/nrf5340_cpuapp_qkaa.dtsi | 10 --------- dts/arm/nordic/nrf5340_cpunet.dtsi | 7 +++++- dts/arm/nordic/nrf5340_cpunet_qkaa.dtsi | 11 ---------- .../nordic/nrf5340_cpuapp_ns_partition.dtsi | 15 ++++++++++--- .../nordic/nrf5340_cpuapp_partition.dtsi | 6 ++++- ...nrf5340dk_nrf5340_cpuapp_dual_slot.overlay | 9 ++++---- 21 files changed, 112 insertions(+), 74 deletions(-) diff --git a/boards/ezurio/bl5340_dvk/bl5340_dvk_nrf5340_cpunet_common.dtsi b/boards/ezurio/bl5340_dvk/bl5340_dvk_nrf5340_cpunet_common.dtsi index b73f177a8d79..33619f57c7fb 100644 --- a/boards/ezurio/bl5340_dvk/bl5340_dvk_nrf5340_cpunet_common.dtsi +++ b/boards/ezurio/bl5340_dvk/bl5340_dvk_nrf5340_cpunet_common.dtsi @@ -31,36 +31,31 @@ }; &flash1 { - /* - * For more information, see: - * http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions - */ partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; - /* 48K */ boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; - /* 88K */ slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x16000>; }; - /* 88K */ slot1_partition: partition@22000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00022000 0x16000>; }; - /* 32K */ storage_partition: partition@38000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00038000 0x8000>; }; diff --git a/boards/native/nrf_bsim/nrf5340bsim_nrf5340_cpuapp.dts b/boards/native/nrf_bsim/nrf5340bsim_nrf5340_cpuapp.dts index 32ed9916a382..40f54dc265e8 100644 --- a/boards/native/nrf_bsim/nrf5340bsim_nrf5340_cpuapp.dts +++ b/boards/native/nrf_bsim/nrf5340bsim_nrf5340_cpuapp.dts @@ -94,13 +94,15 @@ &flash0 { reg = <0x00000000 DT_SIZE_K(1024)>; + ranges = <0x0 0x00000000 DT_SIZE_K(1024)>; partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; storage_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00000000 DT_SIZE_K(1024)>; }; diff --git a/boards/native/nrf_bsim/nrf5340bsim_nrf5340_cpunet.dts b/boards/native/nrf_bsim/nrf5340bsim_nrf5340_cpunet.dts index 94f1ee0ccbbd..f88051eab004 100644 --- a/boards/native/nrf_bsim/nrf5340bsim_nrf5340_cpunet.dts +++ b/boards/native/nrf_bsim/nrf5340bsim_nrf5340_cpunet.dts @@ -58,12 +58,12 @@ ranges = <0x0 0x01000000 DT_SIZE_K(256)>; partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; storage_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00000000 DT_SIZE_K(256)>; }; diff --git a/boards/nordic/nrf5340_audio_dk/nrf5340_audio_dk_nrf5340_cpunet.dts b/boards/nordic/nrf5340_audio_dk/nrf5340_audio_dk_nrf5340_cpunet.dts index 11d75635e32e..b5282d7aac67 100644 --- a/boards/nordic/nrf5340_audio_dk/nrf5340_audio_dk_nrf5340_cpunet.dts +++ b/boards/nordic/nrf5340_audio_dk/nrf5340_audio_dk_nrf5340_cpunet.dts @@ -58,27 +58,30 @@ arduino_spi: &spi0 { &flash1 { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x12000>; }; slot1_partition: partition@1e000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x0001e000 0x12000>; }; storage_partition: partition@3a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003a000 0x6000>; }; diff --git a/boards/nordic/nrf5340dk/nrf5340dk_nrf5340_cpunet.dts b/boards/nordic/nrf5340dk/nrf5340dk_nrf5340_cpunet.dts index 69c9cd860730..93a573e1bd9d 100644 --- a/boards/nordic/nrf5340dk/nrf5340dk_nrf5340_cpunet.dts +++ b/boards/nordic/nrf5340dk/nrf5340dk_nrf5340_cpunet.dts @@ -77,27 +77,30 @@ arduino_spi: &spi0 { &flash1 { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x17000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x17000>; }; storage_partition: partition@3a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003a000 0x6000>; }; diff --git a/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpunet.dts b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpunet.dts index 044e38e497e8..bca0b2a52e71 100644 --- a/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpunet.dts +++ b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpunet.dts @@ -151,27 +151,30 @@ arduino_spi: &spi0 { &flash1 { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x17000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x17000>; }; storage_partition: partition@3a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003a000 0x6000>; }; diff --git a/boards/nordic/thingy53/thingy53_nrf5340_cpunet.dts b/boards/nordic/thingy53/thingy53_nrf5340_cpunet.dts index d74952119839..22383728bf00 100644 --- a/boards/nordic/thingy53/thingy53_nrf5340_cpunet.dts +++ b/boards/nordic/thingy53/thingy53_nrf5340_cpunet.dts @@ -142,27 +142,30 @@ fem_spi: &spi0 { &flash1 { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x17000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x17000>; }; storage_partition: partition@3a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003a000 0x6000>; }; diff --git a/boards/panasonic/pan1783/pan1783_nrf5340_cpunet_common.dtsi b/boards/panasonic/pan1783/pan1783_nrf5340_cpunet_common.dtsi index f25de361d20c..7822e8920798 100644 --- a/boards/panasonic/pan1783/pan1783_nrf5340_cpunet_common.dtsi +++ b/boards/panasonic/pan1783/pan1783_nrf5340_cpunet_common.dtsi @@ -182,27 +182,30 @@ arduino_spi: &spi0 { &flash1 { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x17000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x17000>; }; storage_partition: partition@3a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003a000 0x6000>; }; diff --git a/boards/raytac/an7002q_db/raytac_an7002q_db_nrf5340_cpunet.dts b/boards/raytac/an7002q_db/raytac_an7002q_db_nrf5340_cpunet.dts index cd362309e198..76d5c739c245 100644 --- a/boards/raytac/an7002q_db/raytac_an7002q_db_nrf5340_cpunet.dts +++ b/boards/raytac/an7002q_db/raytac_an7002q_db_nrf5340_cpunet.dts @@ -122,27 +122,30 @@ &flash1 { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x17000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x17000>; }; storage_partition: partition@3a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003a000 0x6000>; }; diff --git a/boards/raytac/mdbt53_db_40/raytac_mdbt53_db_40_nrf5340_cpunet_common.dts b/boards/raytac/mdbt53_db_40/raytac_mdbt53_db_40_nrf5340_cpunet_common.dts index 85802f9c8766..7e2019e1e1fd 100644 --- a/boards/raytac/mdbt53_db_40/raytac_mdbt53_db_40_nrf5340_cpunet_common.dts +++ b/boards/raytac/mdbt53_db_40/raytac_mdbt53_db_40_nrf5340_cpunet_common.dts @@ -32,27 +32,30 @@ &flash1 { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x17000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x17000>; }; storage_partition: partition@3a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003a000 0x6000>; }; diff --git a/boards/raytac/mdbt53v_db_40/raytac_mdbt53v_db_40_nrf5340_cpunet_common.dts b/boards/raytac/mdbt53v_db_40/raytac_mdbt53v_db_40_nrf5340_cpunet_common.dts index 85802f9c8766..7e2019e1e1fd 100644 --- a/boards/raytac/mdbt53v_db_40/raytac_mdbt53v_db_40_nrf5340_cpunet_common.dts +++ b/boards/raytac/mdbt53v_db_40/raytac_mdbt53v_db_40_nrf5340_cpunet_common.dts @@ -32,27 +32,30 @@ &flash1 { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x17000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x17000>; }; storage_partition: partition@3a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003a000 0x6000>; }; diff --git a/dts/arm/nordic/nrf5340_cpuapp.dtsi b/dts/arm/nordic/nrf5340_cpuapp.dtsi index cca54846a8a7..47983b1ef5ac 100644 --- a/dts/arm/nordic/nrf5340_cpuapp.dtsi +++ b/dts/arm/nordic/nrf5340_cpuapp.dtsi @@ -39,6 +39,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@ff0000 { compatible = "nordic,nrf-ficr"; reg = <0xff0000 0x1000>; @@ -71,6 +73,26 @@ #include "nrf5340_cpuapp_peripherals.dtsi" }; + flash_controller: flash-controller@50039000 { + compatible = "nordic,nrf53-flash-controller"; + reg = <0x50039000 0x1000>; + ranges; + partial-erase; + #address-cells = <1>; + #size-cells = <1>; + + flash0: flash@0 { + compatible = "soc-nv-flash"; + erase-block-size = <4096>; + write-block-size = <4>; + reg = <0x0 DT_SIZE_K(1024)>; + ranges = <0x0 0x0 DT_SIZE_K(1024)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; + }; + }; + /* Additional Secure peripherals */ spu: spu@50003000 { diff --git a/dts/arm/nordic/nrf5340_cpuapp_ns.dtsi b/dts/arm/nordic/nrf5340_cpuapp_ns.dtsi index 2fe9dc6b7292..784a670fe03e 100644 --- a/dts/arm/nordic/nrf5340_cpuapp_ns.dtsi +++ b/dts/arm/nordic/nrf5340_cpuapp_ns.dtsi @@ -35,6 +35,8 @@ }; soc { + compatible = "simple-bus"; + sram0: memory@20000000 { compatible = "mmio-sram"; #address-cells = <1>; @@ -53,6 +55,26 @@ #include "nrf5340_cpuapp_peripherals.dtsi" }; + flash_controller: flash-controller@40039000 { + compatible = "nordic,nrf53-flash-controller"; + reg = <0x40039000 0x1000>; + ranges; + partial-erase; + #address-cells = <1>; + #size-cells = <1>; + + flash0: flash@0 { + compatible = "soc-nv-flash"; + erase-block-size = <4096>; + write-block-size = <4>; + reg = <0x0 DT_SIZE_K(1024)>; + ranges = <0x0 0x0 DT_SIZE_K(1024)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; + }; + }; + /* * GPIOTE1 is always accessible as a non-secure peripheral, * so we give it the 'gpiote' label for use when building diff --git a/dts/arm/nordic/nrf5340_cpuapp_ns_qkaa.dtsi b/dts/arm/nordic/nrf5340_cpuapp_ns_qkaa.dtsi index bdcd4d9d462c..aad593f7129a 100644 --- a/dts/arm/nordic/nrf5340_cpuapp_ns_qkaa.dtsi +++ b/dts/arm/nordic/nrf5340_cpuapp_ns_qkaa.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(512)>; ranges = <0x0 0x20000000 DT_SIZE_K(512)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi b/dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi index 31c3cd827d6e..46e2a0364758 100644 --- a/dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi +++ b/dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi @@ -530,21 +530,6 @@ usbreg: regulator@37000 { status = "okay"; }; -flash_controller: flash-controller@39000 { - compatible = "nordic,nrf53-flash-controller"; - reg = <0x39000 0x1000>; - partial-erase; - - #address-cells = <1>; - #size-cells = <1>; - - flash0: flash@0 { - compatible = "soc-nv-flash"; - erase-block-size = <4096>; - write-block-size = <4>; - }; -}; - kmu: kmu@39000 { compatible = "nordic,nrf-kmu"; reg = <0x39000 0x1000>; diff --git a/dts/arm/nordic/nrf5340_cpuapp_qkaa.dtsi b/dts/arm/nordic/nrf5340_cpuapp_qkaa.dtsi index cd9983d949ec..1a75ccd2d067 100644 --- a/dts/arm/nordic/nrf5340_cpuapp_qkaa.dtsi +++ b/dts/arm/nordic/nrf5340_cpuapp_qkaa.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(512)>; ranges = <0x0 0x20000000 DT_SIZE_K(512)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf5340_cpunet.dtsi b/dts/arm/nordic/nrf5340_cpunet.dtsi index 49348ff83991..b29a66012482 100644 --- a/dts/arm/nordic/nrf5340_cpunet.dtsi +++ b/dts/arm/nordic/nrf5340_cpunet.dtsi @@ -33,6 +33,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@1ff0000 { compatible = "nordic,nrf-ficr"; reg = <0x01ff0000 0x1000>; @@ -311,8 +313,8 @@ flash_controller: flash-controller@41080000 { compatible = "nordic,nrf53-flash-controller"; reg = <0x41080000 0x1000>; + ranges; partial-erase; - #address-cells = <1>; #size-cells = <1>; @@ -320,6 +322,9 @@ compatible = "soc-nv-flash"; erase-block-size = <2048>; write-block-size = <4>; + reg = <0x1000000 DT_SIZE_K(256)>; + ranges = <0x0 0x1000000 DT_SIZE_K(256)>; + status = "okay"; #address-cells = <1>; #size-cells = <1>; }; diff --git a/dts/arm/nordic/nrf5340_cpunet_qkaa.dtsi b/dts/arm/nordic/nrf5340_cpunet_qkaa.dtsi index 6c06e3479927..e5546c705c18 100644 --- a/dts/arm/nordic/nrf5340_cpunet_qkaa.dtsi +++ b/dts/arm/nordic/nrf5340_cpunet_qkaa.dtsi @@ -7,11 +7,6 @@ #include #include -&flash1 { - reg = <0x01000000 DT_SIZE_K(256)>; - ranges = <0x0 0x01000000 DT_SIZE_K(256)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(512)>; ranges = <0x0 0x20000000 DT_SIZE_K(512)>; @@ -21,9 +16,3 @@ reg = <0x21000000 DT_SIZE_K(64)>; ranges = <0x0 0x21000000 DT_SIZE_K(64)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/vendor/nordic/nrf5340_cpuapp_ns_partition.dtsi b/dts/vendor/nordic/nrf5340_cpuapp_ns_partition.dtsi index fdf17828390d..f03132baf5ab 100644 --- a/dts/vendor/nordic/nrf5340_cpuapp_ns_partition.dtsi +++ b/dts/vendor/nordic/nrf5340_cpuapp_ns_partition.dtsi @@ -25,17 +25,18 @@ * otherwise unused (32 KB) */ partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x10000>; }; slot0_partition: partition@10000 { - compatible = "fixed-subpartitions"; + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00010000 0x70000>; ranges = <0x0 0x10000 0x70000>; @@ -43,18 +44,20 @@ #size-cells = <1>; slot0_s_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0-secure"; reg = <0x00000000 0x40000>; }; slot0_ns_partition: partition@40000 { + compatible = "zephyr,mapped-partition"; label = "image-0-nonsecure"; reg = <0x00040000 0x30000>; }; }; slot1_partition: partition@80000 { - compatible = "fixed-subpartitions"; + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00080000 0x70000>; ranges = <0x0 0x80000 0x70000>; @@ -62,32 +65,38 @@ #size-cells = <1>; slot1_s_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-1-secure"; reg = <0x00000000 0x40000>; }; slot1_ns_partition: partition@40000 { + compatible = "zephyr,mapped-partition"; label = "image-1-nonsecure"; reg = <0x00040000 0x30000>; }; }; tfm_ps_partition: partition@f0000 { + compatible = "zephyr,mapped-partition"; label = "tfm-ps"; reg = <0x000f0000 0x00004000>; }; tfm_its_partition: partition@f4000 { + compatible = "zephyr,mapped-partition"; label = "tfm-its"; reg = <0x000f4000 0x00002000>; }; tfm_otp_partition: partition@f6000 { + compatible = "zephyr,mapped-partition"; label = "tfm-otp"; reg = <0x000f6000 0x00002000>; }; storage_partition: partition@f8000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000f8000 0x00008000>; }; diff --git a/dts/vendor/nordic/nrf5340_cpuapp_partition.dtsi b/dts/vendor/nordic/nrf5340_cpuapp_partition.dtsi index 37158c092b59..58a3284c24e2 100644 --- a/dts/vendor/nordic/nrf5340_cpuapp_partition.dtsi +++ b/dts/vendor/nordic/nrf5340_cpuapp_partition.dtsi @@ -9,26 +9,30 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x10000>; }; slot0_partition: partition@10000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00010000 0x74000>; }; slot1_partition: partition@84000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00084000 0x74000>; }; storage_partition: partition@f8000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000f8000 0x00008000>; }; diff --git a/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/boards/nrf5340dk_nrf5340_cpuapp_dual_slot.overlay b/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/boards/nrf5340dk_nrf5340_cpuapp_dual_slot.overlay index 4d5de021baa4..f4d4ff21d4c8 100644 --- a/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/boards/nrf5340dk_nrf5340_cpuapp_dual_slot.overlay +++ b/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/boards/nrf5340dk_nrf5340_cpuapp_dual_slot.overlay @@ -10,31 +10,32 @@ &flash0 { partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x10000>; }; slot0_partition: partition@10000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00010000 0x40000>; }; slot1_partition: partition@50000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00050000 0x40000>; }; slot2_partition: partition@90000 { + compatible = "zephyr,mapped-partition"; label = "image-2"; reg = <0x00090000 0x30000>; }; slot3_partition: partition@c0000 { + compatible = "zephyr,mapped-partition"; label = "image-3"; reg = <0x000c0000 0x30000>; }; From 3ef672b8fa7ddce3c0563b62d288485bf4247f71 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 26 Feb 2026 14:30:05 +0000 Subject: [PATCH 26/63] [nrf fromtree] dts: vendor: nordic: Rename nrf54l05 partition file Renames this file to have the CPU core in the filename to align with other files, this seemingly was missed when the other files were renamed Signed-off-by: Jamie McCrae (cherry picked from commit 62030ada2fbd6efced38ffe031ee2df3e75f230a) --- boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l05_cpuapp.dts | 2 +- .../{nrf54l05_partition.dtsi => nrf54l05_cpuapp_partition.dtsi} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename dts/vendor/nordic/{nrf54l05_partition.dtsi => nrf54l05_cpuapp_partition.dtsi} (100%) diff --git a/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l05_cpuapp.dts b/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l05_cpuapp.dts index 2c30c7270059..0e4ecf68ef29 100644 --- a/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l05_cpuapp.dts +++ b/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l05_cpuapp.dts @@ -26,4 +26,4 @@ }; /* Include default memory partition configuration file */ -#include +#include diff --git a/dts/vendor/nordic/nrf54l05_partition.dtsi b/dts/vendor/nordic/nrf54l05_cpuapp_partition.dtsi similarity index 100% rename from dts/vendor/nordic/nrf54l05_partition.dtsi rename to dts/vendor/nordic/nrf54l05_cpuapp_partition.dtsi From 5e4a82b3fe6a50b21f5bef059e205d5524a40a3e Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Tue, 10 Feb 2026 10:56:02 +0000 Subject: [PATCH 27/63] [nrf fromtree] dts: nordic: nrf54l15: Remove cpuflpr resource reservations Removes resource reservation for cpuflpr from the cpuapp build and only applies it when either of the flpr snippets are used Signed-off-by: Jamie McCrae (cherry picked from commit 6a6983b507b6fa4d6d69d27da594dd73908ebd3e) --- .../bl54l15_dvk_nrf54l10_cpuapp.dts | 6 ---- .../bl54l15_dvk_nrf54l15_cpuflpr.dts | 9 +---- .../bl54l15u_dvk_nrf54l15_cpuflpr.dts | 9 +---- .../nrf54l15dk/nrf54l15dk_nrf54l05_cpuapp.dts | 6 ---- .../nrf54l15dk/nrf54l15dk_nrf54l10_cpuapp.dts | 6 ---- .../nrf54l15dk_nrf54l15_cpuflpr.dts | 14 +------- .../nrf54l15tag_cpuflpr_common.dtsi | 2 +- .../nrf54l15tag_nrf54l15_cpuflpr.dts | 13 ------- .../panb611evb_nrf54l15_cpuflpr.dts | 2 +- .../raytac_an54lq_db_15_nrf54l15_cpuflpr.dts | 2 +- .../xiao_nrf54l15_nrf54l15_cpuflpr.dts | 2 +- .../ophelia4ev_nrf54l15_cpuflpr.dts | 2 +- dts/arm/nordic/nrf54l_05_10_15_cpuapp.dtsi | 5 --- dts/riscv/nordic/nrf54l15_cpuflpr.dtsi | 8 ----- dts/vendor/nordic/nrf54l05.dtsi | 33 +++--------------- .../nordic/nrf54l05_cpuapp_partition.dtsi | 6 +--- dts/vendor/nordic/nrf54l10.dtsi | 33 +++--------------- .../nordic/nrf54l10_cpuapp_partition.dtsi | 6 +--- dts/vendor/nordic/nrf54l15.dtsi | 33 +++--------------- .../nordic/nrf54l15_cpuapp_partition.dtsi | 18 ++++++++++ dts/vendor/nordic/nrf54l15_cpuflpr.dtsi | 34 +++++++++++++++++++ dts/vendor/nordic/nrf54l_05_10_15.dtsi | 2 ++ .../soc/nrf54l15_cpuapp.overlay | 15 ++++++++ .../nordic-flpr/soc/nrf54l15_cpuapp.overlay | 10 ++++++ .../boards/nrf54l15dk_nrf54l15_cpuapp.overlay | 16 ++------- 25 files changed, 104 insertions(+), 188 deletions(-) delete mode 100644 dts/riscv/nordic/nrf54l15_cpuflpr.dtsi create mode 100644 dts/vendor/nordic/nrf54l15_cpuflpr.dtsi diff --git a/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l10_cpuapp.dts b/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l10_cpuapp.dts index 96abc76fa453..a5df432a4c13 100644 --- a/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l10_cpuapp.dts +++ b/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l10_cpuapp.dts @@ -20,11 +20,5 @@ }; }; -/* FLPR not supported yet, give all SRAM and RRAM to the APP core */ -&cpuapp_sram { - reg = <0x20000000 DT_SIZE_K(192)>; - ranges = <0x0 0x20000000 DT_SIZE_K(192)>; -}; - /* Include default memory partition configuration file */ #include diff --git a/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l15_cpuflpr.dts b/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l15_cpuflpr.dts index c0584b08c98c..0f780f081f54 100644 --- a/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l15_cpuflpr.dts +++ b/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l15_cpuflpr.dts @@ -6,7 +6,7 @@ */ /dts-v1/; -#include +#include #include "bl54l15_dvk_common.dtsi" / { @@ -22,13 +22,6 @@ }; }; -&cpuflpr_sram { - status = "okay"; - /* size must be increased due to booting from SRAM */ - reg = <0x20028000 DT_SIZE_K(96)>; - ranges = <0x0 0x20028000 0x18000>; -}; - &cpuflpr_rram { partitions { compatible = "fixed-partitions"; diff --git a/boards/ezurio/bl54l15u_dvk/bl54l15u_dvk_nrf54l15_cpuflpr.dts b/boards/ezurio/bl54l15u_dvk/bl54l15u_dvk_nrf54l15_cpuflpr.dts index 2211743673c0..b35c2a411e01 100644 --- a/boards/ezurio/bl54l15u_dvk/bl54l15u_dvk_nrf54l15_cpuflpr.dts +++ b/boards/ezurio/bl54l15u_dvk/bl54l15u_dvk_nrf54l15_cpuflpr.dts @@ -6,7 +6,7 @@ */ /dts-v1/; -#include +#include #include "bl54l15u_dvk_common.dtsi" / { @@ -22,13 +22,6 @@ }; }; -&cpuflpr_sram { - status = "okay"; - /* size must be increased due to booting from SRAM */ - reg = <0x20028000 DT_SIZE_K(96)>; - ranges = <0x0 0x20028000 0x18000>; -}; - &cpuflpr_rram { partitions { compatible = "fixed-partitions"; diff --git a/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l05_cpuapp.dts b/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l05_cpuapp.dts index 0e4ecf68ef29..f09e6574cd79 100644 --- a/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l05_cpuapp.dts +++ b/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l05_cpuapp.dts @@ -19,11 +19,5 @@ }; }; -/* FLPR not supported yet, give all SRAM and RRAM to the APP core */ -&cpuapp_sram { - reg = <0x20000000 DT_SIZE_K(96)>; - ranges = <0x0 0x20000000 DT_SIZE_K(96)>; -}; - /* Include default memory partition configuration file */ #include diff --git a/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l10_cpuapp.dts b/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l10_cpuapp.dts index c94d2a178133..c7736a7f3ce0 100644 --- a/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l10_cpuapp.dts +++ b/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l10_cpuapp.dts @@ -19,11 +19,5 @@ }; }; -/* FLPR not supported yet, give all SRAM and RRAM to the APP core */ -&cpuapp_sram { - reg = <0x20000000 DT_SIZE_K(192)>; - ranges = <0x0 0x20000000 DT_SIZE_K(192)>; -}; - /* Include default memory partition configuration file */ #include diff --git a/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuflpr.dts b/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuflpr.dts index edaad821d37b..c5f6d29e205b 100644 --- a/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuflpr.dts +++ b/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuflpr.dts @@ -5,11 +5,9 @@ */ /dts-v1/; -#include +#include #include "nrf54l15dk_common.dtsi" -/delete-node/ &cpuflpr_sram; - / { model = "Nordic nRF54L15 DK nRF54L15 FLPR MCU"; compatible = "nordic,nrf54l15dk_nrf54l15-cpuflpr"; @@ -21,16 +19,6 @@ zephyr,flash = &cpuflpr_rram; zephyr,sram = &cpuflpr_sram; }; - - cpuflpr_sram: memory@20028000 { - compatible = "mmio-sram"; - /* Size must be increased due to booting from SRAM */ - reg = <0x20028000 DT_SIZE_K(96)>; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x0 0x20028000 0x18000>; - status = "okay"; - }; }; &cpuflpr_rram { diff --git a/boards/nordic/nrf54l15tag/nrf54l15tag_cpuflpr_common.dtsi b/boards/nordic/nrf54l15tag/nrf54l15tag_cpuflpr_common.dtsi index 96c440092450..1d41b30033ca 100644 --- a/boards/nordic/nrf54l15tag/nrf54l15tag_cpuflpr_common.dtsi +++ b/boards/nordic/nrf54l15tag/nrf54l15tag_cpuflpr_common.dtsi @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include +#include #include "nrf54l15tag_common.dtsi" diff --git a/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr.dts b/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr.dts index d1e39d3e5d96..26bdbe51a22d 100644 --- a/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr.dts +++ b/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr.dts @@ -11,19 +11,6 @@ / { model = "Nordic nRF54L15 TAG nRF54L15 FLPR MCU"; compatible = "nordic,nrf54l15tag_nrf54l15-cpuflpr"; - - soc { - /* Resize SRAM partition */ - /delete-node/ memory@2002f000; - - cpuflpr_sram: memory@20028000 { - compatible = "mmio-sram"; - reg = <0x20028000 DT_SIZE_K(96)>; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x0 0x20028000 0x18000>; - }; - }; }; &cpuflpr_rram { diff --git a/boards/panasonic/panb611evb/panb611evb_nrf54l15_cpuflpr.dts b/boards/panasonic/panb611evb/panb611evb_nrf54l15_cpuflpr.dts index 3dc55b73513d..a7806ec7a9dd 100644 --- a/boards/panasonic/panb611evb/panb611evb_nrf54l15_cpuflpr.dts +++ b/boards/panasonic/panb611evb/panb611evb_nrf54l15_cpuflpr.dts @@ -5,7 +5,7 @@ */ /dts-v1/; -#include +#include #include "panb611evb_nrf54l15_common.dtsi" / { diff --git a/boards/raytac/an54lq_db_15/raytac_an54lq_db_15_nrf54l15_cpuflpr.dts b/boards/raytac/an54lq_db_15/raytac_an54lq_db_15_nrf54l15_cpuflpr.dts index 76a52b128622..15ddffded120 100644 --- a/boards/raytac/an54lq_db_15/raytac_an54lq_db_15_nrf54l15_cpuflpr.dts +++ b/boards/raytac/an54lq_db_15/raytac_an54lq_db_15_nrf54l15_cpuflpr.dts @@ -6,7 +6,7 @@ */ /dts-v1/; -#include +#include #include "raytac_an54lq_db_15_common.dtsi" / { diff --git a/boards/seeed/xiao_nrf54l15/xiao_nrf54l15_nrf54l15_cpuflpr.dts b/boards/seeed/xiao_nrf54l15/xiao_nrf54l15_nrf54l15_cpuflpr.dts index 20a7b22e46c0..3ec808985f68 100644 --- a/boards/seeed/xiao_nrf54l15/xiao_nrf54l15_nrf54l15_cpuflpr.dts +++ b/boards/seeed/xiao_nrf54l15/xiao_nrf54l15_nrf54l15_cpuflpr.dts @@ -5,7 +5,7 @@ */ /dts-v1/; -#include +#include #include "xiao_nrf54l15_common.dtsi" / { diff --git a/boards/we/ophelia4ev/ophelia4ev_nrf54l15_cpuflpr.dts b/boards/we/ophelia4ev/ophelia4ev_nrf54l15_cpuflpr.dts index a22b84bc102c..3829ef5a5b65 100644 --- a/boards/we/ophelia4ev/ophelia4ev_nrf54l15_cpuflpr.dts +++ b/boards/we/ophelia4ev/ophelia4ev_nrf54l15_cpuflpr.dts @@ -5,7 +5,7 @@ */ /dts-v1/; -#include +#include #include "ophelia4ev_common.dtsi" / { diff --git a/dts/arm/nordic/nrf54l_05_10_15_cpuapp.dtsi b/dts/arm/nordic/nrf54l_05_10_15_cpuapp.dtsi index 6e0b57f0f0d4..a94b246e0fd1 100644 --- a/dts/arm/nordic/nrf54l_05_10_15_cpuapp.dtsi +++ b/dts/arm/nordic/nrf54l_05_10_15_cpuapp.dtsi @@ -13,11 +13,6 @@ nvic: &cpuapp_nvic {}; /delete-node/ &cpuflpr; /delete-node/ &cpuflpr_clic; -#ifndef USE_NON_SECURE_ADDRESS_MAP -/delete-node/ &cpuflpr_rram; -/delete-node/ &cpuflpr_sram; -#endif - / { chosen { zephyr,bt-hci = &bt_hci_sdc; diff --git a/dts/riscv/nordic/nrf54l15_cpuflpr.dtsi b/dts/riscv/nordic/nrf54l15_cpuflpr.dtsi deleted file mode 100644 index 4dedf1fbca55..000000000000 --- a/dts/riscv/nordic/nrf54l15_cpuflpr.dtsi +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (c) 2024 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include "nrf54l_05_10_15_cpuflpr.dtsi" diff --git a/dts/vendor/nordic/nrf54l05.dtsi b/dts/vendor/nordic/nrf54l05.dtsi index 8213db7612db..ed7cb38afb12 100644 --- a/dts/vendor/nordic/nrf54l05.dtsi +++ b/dts/vendor/nordic/nrf54l05.dtsi @@ -7,36 +7,11 @@ #include "nrf54l_05_10_15.dtsi" &cpuapp_sram { - reg = <0x20000000 DT_SIZE_K(72)>; - ranges = <0x0 0x20000000 DT_SIZE_K(72)>; -}; - -/* 72 + 24 = 96KB */ -/ { - soc { - cpuflpr_sram: memory@20012000 { - compatible = "mmio-sram"; - reg = <0x20012000 DT_SIZE_K(24)>; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x0 0x20012000 DT_SIZE_K(24)>; - }; - }; + reg = <0x20000000 DT_SIZE_K(96)>; + ranges = <0x0 0x20000000 DT_SIZE_K(96)>; }; &cpuapp_rram { - reg = <0x0 DT_SIZE_K(470)>; -}; - -/* 470 + 30 = 500KB */ -&rram_controller { - cpuflpr_rram: rram@75800 { - compatible = "soc-nv-flash"; - reg = <0x75800 DT_SIZE_K(30)>; - ranges = <0x0 0x75800 DT_SIZE_K(30)>; - #address-cells = <1>; - #size-cells = <1>; - erase-block-size = <4096>; - write-block-size = <16>; - }; + reg = <0x0 DT_SIZE_K(500)>; + ranges = <0x0 0x0 DT_SIZE_K(500)>; }; diff --git a/dts/vendor/nordic/nrf54l05_cpuapp_partition.dtsi b/dts/vendor/nordic/nrf54l05_cpuapp_partition.dtsi index aa2ea04bce0d..8fe2ad76c7cc 100644 --- a/dts/vendor/nordic/nrf54l05_cpuapp_partition.dtsi +++ b/dts/vendor/nordic/nrf54l05_cpuapp_partition.dtsi @@ -4,16 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -&cpuapp_rram { - reg = <0x0 DT_SIZE_K(500)>; -}; - -/* These partition sizes assume no FLPR area in RRAM */ &cpuapp_rram { partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; + ranges; boot_partition: partition@0 { label = "mcuboot"; diff --git a/dts/vendor/nordic/nrf54l10.dtsi b/dts/vendor/nordic/nrf54l10.dtsi index 1ef1e5fbba0c..fe94f299982b 100644 --- a/dts/vendor/nordic/nrf54l10.dtsi +++ b/dts/vendor/nordic/nrf54l10.dtsi @@ -7,36 +7,11 @@ #include "nrf54l_05_10_15.dtsi" &cpuapp_sram { - reg = <0x20000000 DT_SIZE_K(144)>; - ranges = <0x0 0x20000000 DT_SIZE_K(144)>; -}; - -/* 144 + 48 = 192KB */ -/ { - soc { - cpuflpr_sram: memory@20024000 { - compatible = "mmio-sram"; - reg = <0x20024000 DT_SIZE_K(48)>; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x0 0x20024000 DT_SIZE_K(48)>; - }; - }; + reg = <0x20000000 DT_SIZE_K(192)>; + ranges = <0x0 0x20000000 DT_SIZE_K(192)>; }; &cpuapp_rram { - reg = <0x0 DT_SIZE_K(950)>; -}; - -/* 950 + 62 = 1012KB */ -&rram_controller { - cpuflpr_rram: rram@ed800 { - compatible = "soc-nv-flash"; - reg = <0xed800 DT_SIZE_K(62)>; - ranges = <0x0 0xed800 DT_SIZE_K(62)>; - #address-cells = <1>; - #size-cells = <1>; - erase-block-size = <4096>; - write-block-size = <16>; - }; + reg = <0x0 DT_SIZE_K(1012)>; + ranges = <0x0 0x0 DT_SIZE_K(1012)>; }; diff --git a/dts/vendor/nordic/nrf54l10_cpuapp_partition.dtsi b/dts/vendor/nordic/nrf54l10_cpuapp_partition.dtsi index e73b1c5f0e3f..6b3b542831e3 100644 --- a/dts/vendor/nordic/nrf54l10_cpuapp_partition.dtsi +++ b/dts/vendor/nordic/nrf54l10_cpuapp_partition.dtsi @@ -4,16 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -&cpuapp_rram { - reg = <0x0 DT_SIZE_K(1012)>; -}; - -/* These partition sizes assume no FLPR area in RRAM */ &cpuapp_rram { partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; + ranges; boot_partition: partition@0 { label = "mcuboot"; diff --git a/dts/vendor/nordic/nrf54l15.dtsi b/dts/vendor/nordic/nrf54l15.dtsi index d6af3f385f60..ddd0651990dd 100644 --- a/dts/vendor/nordic/nrf54l15.dtsi +++ b/dts/vendor/nordic/nrf54l15.dtsi @@ -7,36 +7,11 @@ #include "nrf54l_05_10_15.dtsi" &cpuapp_sram { - reg = <0x20000000 DT_SIZE_K(188)>; - ranges = <0x0 0x20000000 DT_SIZE_K(188)>; -}; - -/* 188 + 68 = 256KB */ -/ { - soc { - cpuflpr_sram: memory@2002f000 { - compatible = "mmio-sram"; - reg = <0x2002f000 DT_SIZE_K(68)>; - #address-cells = <1>; - #size-cells = <1>; - ranges = <0x0 0x2002f000 DT_SIZE_K(68)>; - }; - }; + reg = <0x20000000 DT_SIZE_K(256)>; + ranges = <0x0 0x20000000 DT_SIZE_K(256)>; }; &cpuapp_rram { - reg = <0x0 DT_SIZE_K(1428)>; -}; - -/* 1428 + 96 = 1524KB */ -&rram_controller { - cpuflpr_rram: rram@165000 { - compatible = "soc-nv-flash"; - reg = <0x165000 DT_SIZE_K(96)>; - ranges = <0x0 0x165000 DT_SIZE_K(96)>; - #address-cells = <1>; - #size-cells = <1>; - erase-block-size = <4096>; - write-block-size = <16>; - }; + reg = <0x0 DT_SIZE_K(1524)>; + ranges = <0x0 0x0 DT_SIZE_K(1524)>; }; diff --git a/dts/vendor/nordic/nrf54l15_cpuapp_partition.dtsi b/dts/vendor/nordic/nrf54l15_cpuapp_partition.dtsi index 4988de3ed544..57450227c74c 100644 --- a/dts/vendor/nordic/nrf54l15_cpuapp_partition.dtsi +++ b/dts/vendor/nordic/nrf54l15_cpuapp_partition.dtsi @@ -9,12 +9,14 @@ compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; + ranges; boot_partition: partition@0 { label = "mcuboot"; reg = <0x0 DT_SIZE_K(64)>; }; +#ifdef WITH_FLPR_PARTITIONS slot0_partition: partition@10000 { label = "image-0"; reg = <0x10000 DT_SIZE_K(664)>; @@ -29,5 +31,21 @@ label = "storage"; reg = <0x15c000 DT_SIZE_K(36)>; }; +#else + slot0_partition: partition@10000 { + label = "image-0"; + reg = <0x10000 DT_SIZE_K(712)>; + }; + + slot1_partition: partition@c2000 { + label = "image-1"; + reg = <0xc2000 DT_SIZE_K(712)>; + }; + + storage_partition: partition@174000 { + label = "storage"; + reg = <0x174000 DT_SIZE_K(36)>; + }; +#endif }; }; diff --git a/dts/vendor/nordic/nrf54l15_cpuflpr.dtsi b/dts/vendor/nordic/nrf54l15_cpuflpr.dtsi new file mode 100644 index 000000000000..6e0b924b5c5f --- /dev/null +++ b/dts/vendor/nordic/nrf54l15_cpuflpr.dtsi @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +/* 188 + 68 = 256KB */ +/ { + soc { + cpuflpr_sram: memory@20028000 { + compatible = "mmio-sram"; + reg = <0x20028000 DT_SIZE_K(96)>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x2002f000 DT_SIZE_K(96)>; + }; + }; +}; + +/* 1428 + 96 = 1524KB */ +&rram_controller { + cpuflpr_rram: rram@165000 { + compatible = "soc-nv-flash"; + reg = <0x165000 DT_SIZE_K(96)>; + ranges = <0x0 0x165000 DT_SIZE_K(96)>; + #address-cells = <1>; + #size-cells = <1>; + erase-block-size = <4096>; + write-block-size = <16>; + }; +}; diff --git a/dts/vendor/nordic/nrf54l_05_10_15.dtsi b/dts/vendor/nordic/nrf54l_05_10_15.dtsi index 4e289e69c553..e4cf5ba10b2a 100644 --- a/dts/vendor/nordic/nrf54l_05_10_15.dtsi +++ b/dts/vendor/nordic/nrf54l_05_10_15.dtsi @@ -758,6 +758,8 @@ compatible = "soc-nv-flash"; erase-block-size = <4096>; write-block-size = <16>; + #address-cells = <1>; + #size-cells = <1>; }; }; diff --git a/snippets/nordic/nordic-flpr-xip/soc/nrf54l15_cpuapp.overlay b/snippets/nordic/nordic-flpr-xip/soc/nrf54l15_cpuapp.overlay index 74d9d477b19d..d3594b00aaaa 100644 --- a/snippets/nordic/nordic-flpr-xip/soc/nrf54l15_cpuapp.overlay +++ b/snippets/nordic/nordic-flpr-xip/soc/nrf54l15_cpuapp.overlay @@ -3,6 +3,18 @@ * SPDX-License-Identifier: Apache-2.0 */ +&cpuapp_sram { + reg = <0x20000000 DT_SIZE_K(188)>; + ranges = <0x0 0x20000000 DT_SIZE_K(188)>; +}; + +&cpuapp_rram { + reg = <0x0 DT_SIZE_K(1428)>; + ranges = <0x0 0x0 DT_SIZE_K(1428)>; + + /delete-node/ partitions; +}; + &rram_controller { cpuflpr_rram: rram@165000 { compatible = "soc-nv-flash"; @@ -26,3 +38,6 @@ &cpuapp_vevif_tx { status = "okay"; }; + +#define WITH_FLPR_PARTITIONS +#include diff --git a/snippets/nordic/nordic-flpr/soc/nrf54l15_cpuapp.overlay b/snippets/nordic/nordic-flpr/soc/nrf54l15_cpuapp.overlay index f429def60040..318a60b3698d 100644 --- a/snippets/nordic/nordic-flpr/soc/nrf54l15_cpuapp.overlay +++ b/snippets/nordic/nordic-flpr/soc/nrf54l15_cpuapp.overlay @@ -25,6 +25,13 @@ ranges = <0x0 0x20000000 0x28000>; }; +&cpuapp_rram { + reg = <0x0 DT_SIZE_K(1428)>; + ranges = <0x0 0x0 DT_SIZE_K(1428)>; + + /delete-node/ partitions; +}; + &rram_controller { cpuflpr_rram: rram@165000 { compatible = "soc-nv-flash"; @@ -45,3 +52,6 @@ &cpuapp_vevif_tx { status = "okay"; }; + +#define WITH_FLPR_PARTITIONS +#include diff --git a/tests/subsys/fs/littlefs/boards/nrf54l15dk_nrf54l15_cpuapp.overlay b/tests/subsys/fs/littlefs/boards/nrf54l15dk_nrf54l15_cpuapp.overlay index d7b166fa1e02..e99eb4091da9 100644 --- a/tests/subsys/fs/littlefs/boards/nrf54l15dk_nrf54l15_cpuapp.overlay +++ b/tests/subsys/fs/littlefs/boards/nrf54l15dk_nrf54l15_cpuapp.overlay @@ -4,17 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -/delete-node/ &slot1_partition; - -&cpuapp_rram { - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - small_partition: partition@b6000 { - label = "small"; - reg = <0x000b6000 0x00010000>; - }; - }; +small_partition: &slot1_partition { + label = "small"; + reg = <0xc2000 0x10000>; }; From 2d743cea74636fada1a6d79b4dcf0b8fadf0bb6d Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Wed, 18 Mar 2026 08:00:13 +0000 Subject: [PATCH 28/63] [nrf noup] dts: vendor: nordic: nrf7120/nrf54l: Ranges revert This is a partial revert of commit 3b3697732a76bf036d46241a1ca8187ca1d2e564 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, most of which are entirely irrelevant to NCS Signed-off-by: Jamie McCrae --- dts/vendor/nordic/nrf54l05_cpuapp_partition.dtsi | 1 - dts/vendor/nordic/nrf54l10_cpuapp_partition.dtsi | 1 - dts/vendor/nordic/nrf54l15_cpuapp_partition.dtsi | 1 - dts/vendor/nordic/nrf7120_cpuapp_ns_partition.dtsi | 1 - dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi | 1 - 5 files changed, 5 deletions(-) diff --git a/dts/vendor/nordic/nrf54l05_cpuapp_partition.dtsi b/dts/vendor/nordic/nrf54l05_cpuapp_partition.dtsi index 8fe2ad76c7cc..e5fbc2f16c9e 100644 --- a/dts/vendor/nordic/nrf54l05_cpuapp_partition.dtsi +++ b/dts/vendor/nordic/nrf54l05_cpuapp_partition.dtsi @@ -9,7 +9,6 @@ compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; - ranges; boot_partition: partition@0 { label = "mcuboot"; diff --git a/dts/vendor/nordic/nrf54l10_cpuapp_partition.dtsi b/dts/vendor/nordic/nrf54l10_cpuapp_partition.dtsi index 6b3b542831e3..b0c011d6ac9b 100644 --- a/dts/vendor/nordic/nrf54l10_cpuapp_partition.dtsi +++ b/dts/vendor/nordic/nrf54l10_cpuapp_partition.dtsi @@ -9,7 +9,6 @@ compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; - ranges; boot_partition: partition@0 { label = "mcuboot"; diff --git a/dts/vendor/nordic/nrf54l15_cpuapp_partition.dtsi b/dts/vendor/nordic/nrf54l15_cpuapp_partition.dtsi index 57450227c74c..9e356b4a0fc3 100644 --- a/dts/vendor/nordic/nrf54l15_cpuapp_partition.dtsi +++ b/dts/vendor/nordic/nrf54l15_cpuapp_partition.dtsi @@ -9,7 +9,6 @@ compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; - ranges; boot_partition: partition@0 { label = "mcuboot"; diff --git a/dts/vendor/nordic/nrf7120_cpuapp_ns_partition.dtsi b/dts/vendor/nordic/nrf7120_cpuapp_ns_partition.dtsi index 538091d11d4e..441c5c390ec2 100644 --- a/dts/vendor/nordic/nrf7120_cpuapp_ns_partition.dtsi +++ b/dts/vendor/nordic/nrf7120_cpuapp_ns_partition.dtsi @@ -51,7 +51,6 @@ compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; - ranges; /* This static layout needs to be the same with the upstream TF-M layout in the * header flash_layout.h of the relevant platform. Any updates in the layout diff --git a/dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi b/dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi index 64d5e69e2068..6df7b940c131 100644 --- a/dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi +++ b/dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi @@ -16,7 +16,6 @@ compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; - ranges; boot_partition: partition@0 { label = "mcuboot"; From 9083a75f883f4a950e5c1bc1b27822656492a1c2 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Fri, 27 Feb 2026 08:37:02 +0000 Subject: [PATCH 29/63] [nrf fromtree] include: storage: flash_map: Remove ranges for fixed-partitions Removes handling ranges for fixed-partitions as this has now moved over to the zephyr.mapped-partition binding Signed-off-by: Jamie McCrae (cherry picked from commit 61b7c0049c35e37606cb552d039e09a00826d290) --- include/zephyr/storage/flash_map.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/include/zephyr/storage/flash_map.h b/include/zephyr/storage/flash_map.h index f0cb4985eaee..df4e4ef63cd4 100644 --- a/include/zephyr/storage/flash_map.h +++ b/include/zephyr/storage/flash_map.h @@ -427,7 +427,9 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); #define PARTITION_NODE_ADDRESS(node) \ COND_CODE_1(DT_NODE_HAS_COMPAT(node, zephyr_mapped_partition), \ (DT_MAPPED_PARTITION_ADDR(node)), \ - (DT_REG_ADDR(node))) + (COND_CODE_1(DT_FIXED_SUBPARTITION_EXISTS(node), \ + (DT_FIXED_SUBPARTITION_ADDR(node)), \ + (DT_FIXED_PARTITION_ADDR(node))))) /** Deprecated macro, replace with PARTITION_NODE_ADDRESS() */ #define FIXED_PARTITION_NODE_ADDRESS(node) PARTITION_NODE_ADDRESS(node) __DEPRECATED_MACRO @@ -447,10 +449,7 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); #define PARTITION_NODE_OFFSET(node) \ COND_CODE_1(DT_NODE_HAS_COMPAT(node, zephyr_mapped_partition), \ (DT_MAPPED_PARTITION_OFFSET(node)), \ - (COND_CODE_1(DT_FIXED_SUBPARTITION_EXISTS(node), \ - (DT_PROP_BY_IDX(DT_PARENT(node), reg, 0) + \ - DT_PROP_BY_IDX(node, reg, 0)), \ - (DT_PROP_BY_IDX(node, reg, 0))))) + (DT_REG_ADDR(node))) /** Deprecated macro, replace with PARTITION_NODE_OFFSET() */ #define FIXED_PARTITION_NODE_OFFSET(label) PARTITION_NODE_OFFSET(label) __DEPRECATED_MACRO From 52e693248fcd65d3d43971b549e2fa4b5b8f80a0 Mon Sep 17 00:00:00 2001 From: Sylvio Alves Date: Tue, 27 Jan 2026 17:35:42 -0300 Subject: [PATCH 30/63] [nrf fromtree] soc: espressif: loader: use zephyr,code-partition for flash offset Use the zephyr,code-partition chosen node to determine the flash partition offset for IROM/DROM mapping. This enables Direct-XIP mode support where the slot1 variant image needs a different flash offset than slot0. Falls back to slot0_partition if zephyr,code-partition is not defined, maintaining backward compatibility with existing configurations. Signed-off-by: Sylvio Alves (cherry picked from commit 5b00645e6ecca5ad4b07ed7162411a54c99d6f28) --- soc/espressif/common/loader.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/soc/espressif/common/loader.c b/soc/espressif/common/loader.c index 74a3c977a42e..ca286b381486 100644 --- a/soc/espressif/common/loader.c +++ b/soc/espressif/common/loader.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -81,7 +82,11 @@ #define HDR_ATTR __attribute__((section(".entry_addr"))) __attribute__((used)) #if !defined(CONFIG_SOC_ESP32_APPCPU) && !defined(CONFIG_SOC_ESP32S3_APPCPU) +#if DT_NODE_EXISTS(DT_CHOSEN(zephyr_code_partition)) +#define PART_OFFSET DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition)) +#else #define PART_OFFSET FIXED_PARTITION_OFFSET(slot0_partition) +#endif #else #define PART_OFFSET FIXED_PARTITION_OFFSET(slot0_appcpu_partition) #endif From 21a040d61fb8f034a675704f1c5684a7f49fd670 Mon Sep 17 00:00:00 2001 From: Sylvio Alves Date: Fri, 13 Feb 2026 13:58:43 -0300 Subject: [PATCH 31/63] [nrf fromtree] soc: espressif: use ZSR_CPU_STR macro for cpu pointer register Replace hardcoded wsr.MISC0 with the build-generated ZSR_CPU_STR macro to write the correct Xtensa special register for the CPU pointer. Signed-off-by: Sylvio Alves (cherry picked from commit 3bef399524e46ae10bcd7736d07ae1db3a8a5128) --- soc/espressif/common/loader.c | 7 +++++-- soc/espressif/esp32/esp32-mp.c | 3 ++- soc/espressif/esp32/soc_appcpu.c | 3 ++- soc/espressif/esp32s3/soc_appcpu.c | 3 ++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/soc/espressif/common/loader.c b/soc/espressif/common/loader.c index ca286b381486..6f5856de9aa4 100644 --- a/soc/espressif/common/loader.c +++ b/soc/espressif/common/loader.c @@ -26,6 +26,9 @@ #include #include +#ifdef CONFIG_XTENSA +#include +#endif #if CONFIG_SOC_SERIES_ESP32C6 #include @@ -307,10 +310,10 @@ void __start(void) __asm__ __volatile__("wsr %0, PS" : : "r"(PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE)); /* Initialize the architecture CPU pointer. Some of the - * initialization code wants a valid arch_current_thread() before + * initialization code wants a valid arch_curr_cpu() before * arch_kernel_init() is invoked. */ - __asm__ __volatile__("wsr.MISC0 %0; rsync" : : "r"(&_kernel.cpus[0])); + __asm__ __volatile__("wsr %0, " ZSR_CPU_STR "; rsync" : : "r"(&_kernel.cpus[0])); #endif /* CONFIG_RISCV_GP */ diff --git a/soc/espressif/esp32/esp32-mp.c b/soc/espressif/esp32/esp32-mp.c index 55bc5fd028e4..9e39d9fd8eee 100644 --- a/soc/espressif/esp32/esp32-mp.c +++ b/soc/espressif/esp32/esp32-mp.c @@ -18,6 +18,7 @@ #include "esp_mcuboot_image.h" #include "esp_memory_utils.h" +#include #ifdef CONFIG_SMP @@ -94,7 +95,7 @@ static void appcpu_entry2(void) */ _cpu_t *cpu = &_kernel.cpus[1]; - __asm__ volatile("wsr.MISC0 %0" : : "r"(cpu)); + __asm__ volatile("wsr %0, " ZSR_CPU_STR : : "r"(cpu)); smp_log("ESP32: APPCPU running"); diff --git a/soc/espressif/esp32/soc_appcpu.c b/soc/espressif/esp32/soc_appcpu.c index a682a87753c6..ec46501e5d33 100644 --- a/soc/espressif/esp32/soc_appcpu.c +++ b/soc/espressif/esp32/soc_appcpu.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -83,7 +84,7 @@ void IRAM_ATTR __appcpu_start(void) * initialization code wants a valid _current before * z_prep_c() is invoked. */ - __asm__ __volatile__("wsr.MISC0 %0; rsync" : : "r"(&_kernel.cpus[1])); + __asm__ __volatile__("wsr %0, " ZSR_CPU_STR "; rsync" : : "r"(&_kernel.cpus[1])); core_intr_matrix_clear(); diff --git a/soc/espressif/esp32s3/soc_appcpu.c b/soc/espressif/esp32s3/soc_appcpu.c index 4cb0e404857e..fc7bb549b448 100644 --- a/soc/espressif/esp32s3/soc_appcpu.c +++ b/soc/espressif/esp32s3/soc_appcpu.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -68,7 +69,7 @@ void IRAM_ATTR __appcpu_start(void) * initialization code wants a valid _current before * arch_kernel_init() is invoked. */ - __asm__ __volatile__("wsr.MISC0 %0; rsync" : : "r"(&_kernel.cpus[1])); + __asm__ __volatile__("wsr %0, " ZSR_CPU_STR "; rsync" : : "r"(&_kernel.cpus[1])); core_intr_matrix_clear(); From f35748bf1de765c49b59963354f0be17ac5a57dd Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Wed, 18 Mar 2026 08:09:25 +0000 Subject: [PATCH 32/63] Revert "[nrf noup] drivers/flashdisk: Add support for Partition Manager" This reverts commit 97649f1cba744554f06675f4fa1aeabd2665852a. Signed-off-by: Jamie McCrae --- drivers/disk/flashdisk.c | 78 ---------------------------------------- 1 file changed, 78 deletions(-) diff --git a/drivers/disk/flashdisk.c b/drivers/disk/flashdisk.c index bd5dc6a8f76a..1959f94b0ed3 100644 --- a/drivers/disk/flashdisk.c +++ b/drivers/disk/flashdisk.c @@ -504,8 +504,6 @@ static const struct disk_operations flash_disk_ops = { .ioctl = disk_flash_access_ioctl, }; -#ifndef USE_PARTITION_MANAGER -/* The non-Partition manager, DTS based generators below */ #define DT_DRV_COMPAT zephyr_flash_disk #define PARTITION_PHANDLE(n) DT_PHANDLE_BY_IDX(DT_DRV_INST(n), partition, 0) @@ -547,82 +545,6 @@ DT_INST_FOREACH_STATUS_OKAY(VERIFY_CACHE_SIZE_IS_NOT_ZERO_IF_NOT_READ_ONLY) "Devicetree node " DT_NODE_PATH(DT_DRV_INST(n)) \ " has cache size which is not a multiple of its sector size"); DT_INST_FOREACH_STATUS_OKAY(VERIFY_CACHE_SIZE_IS_MULTIPLY_OF_SECTOR_SIZE) -#else /* ifndef USE_PARTITION_MANAGER */ -/* Partition Manager based generators below */ - -/* Gets the PM_..._EXTRA_PARAM_##param value */ -#define PM_FLASH_DISK_ENTRY_EXTRA_PARAM(name, param) PM_##name##_EXTRA_PARAM_disk_##param - -/* Gets the PM_..._NAME value which is originally cased, as in yaml, partition name */ -#define PM_FLASH_DISK_ENTRY_PARTITION_NAME(name) PM_##name##_NAME - -/* Generates flashdiskN_cache variable name, where N is partition ID */ -#define PM_FLASH_DISK_CACHE_VARIABLE(n) UTIL_CAT(flashdisk, UTIL_CAT(FIXED_PARTITION_ID(n), _cache)) - -/* Generate cache buffers */ -#define CACHE_SIZE(n) (COND_CODE_1(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, read_only), (0), (1)) * \ - PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, cache_size)) -#define DEFINE_FLASHDISKS_CACHE(n) \ - static uint8_t __aligned(4) PM_FLASH_DISK_CACHE_VARIABLE(n)[CACHE_SIZE(n)]; - -PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_CACHE) - -/* Generated single Flash Disk device data from Partition Manager partition. - * Partition is required to have type set to disk in partition definitions: - * type: disk - * and following extra params can be provided: - * extra_params: { - * name = "", - * cache_size = , - * sector_size = , - * read_only = - * } - * where: - * is mandatory device name that will be used by Disk Access and FAT FS to mount device; - * is cache r/w cache size, which is mandatory if read_only = 0 or not present, - * and should be multiple of ; - * is mandatory device sector size information, usually should be erase page size, - * for flash devices, for example 4096 bytes; - * read_only is optional, if not present then assumed false; can be 0(false) or 1(true). - */ -#define DEFINE_FLASHDISKS_DEVICE(n) \ -{ \ - .info = { \ - .ops = &flash_disk_ops, \ - .name = STRINGIFY(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, name)), \ - }, \ - .area_id = FIXED_PARTITION_ID(n), \ - .offset = FIXED_PARTITION_OFFSET(n), \ - .cache = PM_FLASH_DISK_CACHE_VARIABLE(n), \ - .cache_size = sizeof(PM_FLASH_DISK_CACHE_VARIABLE(n)), \ - .size = FIXED_PARTITION_SIZE(n), \ - .sector_size = PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, sector_size), \ -}, - -/* The bellow used PM_FOREACH_TYPE_disk is generated by Partition Manager foreach - * loop macro. The lower case _disk is type name for which the macro has been generated; - * partition entry can have multiple types set and foreach macro will be generated - * for every type found across partition definitions. - */ -static struct flashdisk_data flash_disks[] = { - PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_DEVICE) -}; - -#define VERIFY_CACHE_SIZE_IS_NOT_ZERO_IF_NOT_READ_ONLY(n) \ - COND_CODE_1(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, read_only), \ - (/* cache-size is not used for read-only disks */), \ - (BUILD_ASSERT(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, cache_size) != 0, \ - "Flash disk partition " STRINGIFY(PM_FLASH_DISK_ENTRY_PARTITION_NAME(n))\ - " must have non-zero cache-size");)) -PM_FOREACH_AFFILIATED_TO_disk(VERIFY_CACHE_SIZE_IS_NOT_ZERO_IF_NOT_READ_ONLY) - -#define VERIFY_CACHE_SIZE_IS_MULTIPLY_OF_SECTOR_SIZE(n) \ - BUILD_ASSERT(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, cache_size) % \ - PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, sector_size) == 0, \ - "Devicetree node " STRINGIFY(PM_FLASH_DISK_ENTRY_PARTITION_NAME(n)) \ - " has cache size which is not a multiple of its sector size"); -PM_FOREACH_AFFILIATED_TO_disk(VERIFY_CACHE_SIZE_IS_MULTIPLY_OF_SECTOR_SIZE) -#endif /* USE_PARTITION_MANAGER */ static int disk_flash_init(void) { From cda9b0d9b44b745225b85d90995d5d70e88794b9 Mon Sep 17 00:00:00 2001 From: Gerson Fernando Budke Date: Sat, 7 Feb 2026 18:39:00 +0100 Subject: [PATCH 33/63] [nrf fromtree] tests: secure_storage: psa: its: Use FIXED_PARTITION_MTD Use FIXED_PARTITION_MTD(storage_partition) instead of DEVICE_DT_GET(DT_CHOSEN(zephyr_flash_controller)) to obtain the flash device for erasing the storage partition. This correctly resolves the flash device that contains the storage partition, which may be on external flash rather than the internal flash controller. Signed-off-by: Gerson Fernando Budke (cherry picked from commit 7ef68a8276c3823c4dbcc2f4910836b335817c0c) --- tests/subsys/secure_storage/psa/its/src/main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/subsys/secure_storage/psa/its/src/main.c b/tests/subsys/secure_storage/psa/its/src/main.c index 712be32c7606..d5d6d0d5d7c5 100644 --- a/tests/subsys/secure_storage/psa/its/src/main.c +++ b/tests/subsys/secure_storage/psa/its/src/main.c @@ -9,11 +9,10 @@ /* The flash must be erased after this test suite is run for the write-once entry test to pass. */ #if !defined(CONFIG_BUILD_WITH_TFM) && defined(CONFIG_FLASH_PAGE_LAYOUT) && \ - DT_HAS_CHOSEN(zephyr_flash_controller) && \ - DT_FIXED_PARTITION_EXISTS(DT_NODELABEL(storage_partition)) + FIXED_PARTITION_EXISTS(DT_NODELABEL(storage_partition)) static int erase_flash(void) { - const struct device *const fdev = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash_controller)); + const struct device *const fdev = FIXED_PARTITION_MTD(storage_partition); int rc; rc = flash_flatten(fdev, FIXED_PARTITION_OFFSET(storage_partition), @@ -29,7 +28,7 @@ static int erase_flash(void) /* Low priority to ensure we run after any flash drivers are initialized */ SYS_INIT(erase_flash, POST_KERNEL, 100); -#endif /* !CONFIG_BUILD_WITH_TFM && CONFIG_FLASH_PAGE_LAYOUT */ +#endif /* !CONFIG_BUILD_WITH_TFM && CONFIG_FLASH_PAGE_LAYOUT && storage_partition */ ZTEST_SUITE(secure_storage_psa_its, NULL, NULL, NULL, NULL, NULL); From 5e994ddf5087a9e05b95036b76f45e5b8b0026b4 Mon Sep 17 00:00:00 2001 From: Tim Pambor Date: Thu, 29 Jan 2026 10:09:44 +0100 Subject: [PATCH 34/63] [nrf fromtree] drivers: flash: simulator: support multiple instances Rework flash simulator to use per-instance configuration, replacing single global state and enabling support for multiple independent simulator instances. Signed-off-by: Tim Pambor (cherry picked from commit 176a8806665323a5853e8c6345057124d23eea5c) --- drivers/flash/flash_simulator.c | 434 ++++++++++++++++++-------------- 1 file changed, 252 insertions(+), 182 deletions(-) diff --git a/drivers/flash/flash_simulator.c b/drivers/flash/flash_simulator.c index 22eeba1506fd..baf9ac93ee7b 100644 --- a/drivers/flash/flash_simulator.c +++ b/drivers/flash/flash_simulator.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2023-2024 Nordic Semiconductor ASA + * Copyright (c) 2026 CodeWrights GmbH * * SPDX-License-Identifier: Apache-2.0 */ @@ -24,33 +25,42 @@ #include "flash_simulator_native.h" #include "cmdline.h" #include "soc.h" -#define DEFAULT_FLASH_FILE_PATH "flash.bin" + +/* For backward compatibility, default file name for instance 0 is "flash.bin" */ +#define DEFAULT_FLASH_FILE_PATH(n) COND_CODE_0(n, ("flash.bin"), ("flash" #n ".bin")) #endif /* CONFIG_ARCH_POSIX */ -/* configuration derived from DT */ +struct flash_simulator_config { + uint8_t *prog_unit_buf; + const struct flash_parameters *flash_parameters; +#ifdef CONFIG_FLASH_SIMULATOR_CALLBACKS + const struct flash_simulator_params *flash_simulator_params; +#endif /* CONFIG_FLASH_SIMULATOR_CALLBACKS */ +#ifdef CONFIG_FLASH_PAGE_LAYOUT + const struct flash_pages_layout *pages_layout; +#endif /* CONFIG_FLASH_PAGE_LAYOUT */ #ifdef CONFIG_ARCH_POSIX -#define SOC_NV_FLASH_NODE DT_INST_CHILD(0, flash_0) -#else -#define SOC_NV_FLASH_NODE DT_INST_CHILD(0, flash_sim_0) + const char *flash_file_default_path; #endif /* CONFIG_ARCH_POSIX */ + size_t base_offset; + size_t erase_unit; + size_t flash_size; +}; -#define FLASH_SIMULATOR_BASE_OFFSET DT_REG_ADDR(SOC_NV_FLASH_NODE) -#define FLASH_SIMULATOR_ERASE_UNIT DT_PROP(SOC_NV_FLASH_NODE, erase_block_size) -#define FLASH_SIMULATOR_PROG_UNIT DT_PROP(SOC_NV_FLASH_NODE, write_block_size) -#define FLASH_SIMULATOR_FLASH_SIZE DT_REG_SIZE(SOC_NV_FLASH_NODE) - -#define FLASH_SIMULATOR_ERASE_VALUE \ - DT_PROP(DT_PARENT(SOC_NV_FLASH_NODE), erase_value) - -#define FLASH_SIMULATOR_PAGE_COUNT (FLASH_SIMULATOR_FLASH_SIZE / \ - FLASH_SIMULATOR_ERASE_UNIT) - -#if (FLASH_SIMULATOR_ERASE_UNIT % FLASH_SIMULATOR_PROG_UNIT) -#error "Erase unit must be a multiple of program unit" -#endif - -#define MOCK_FLASH(offset) (mock_flash + (offset)) +struct flash_simulator_data { + uint8_t *mock_flash; + bool flash_erase_at_start; +#ifdef CONFIG_ARCH_POSIX + int flash_fd; + const char *flash_file_path; + bool flash_rm_at_exit; + bool flash_in_ram; +#endif /* CONFIG_ARCH_POSIX */ +#ifdef CONFIG_FLASH_SIMULATOR_CALLBACKS + const struct flash_simulator_cb *flash_simulator_cbs; +#endif /* CONFIG_FLASH_SIMULATOR_CALLBACKS */ +}; /* maximum number of pages that can be tracked by the stats module */ #define STATS_PAGE_COUNT_THRESHOLD 256 @@ -141,60 +151,13 @@ STATS_NAME_END(flash_sim_thresholds); #endif /* CONFIG_FLASH_SIMULATOR_STATS */ - -#ifdef CONFIG_ARCH_POSIX -static uint8_t *mock_flash; -static int flash_fd = -1; -static const char *flash_file_path; -static bool flash_erase_at_start; -static bool flash_rm_at_exit; -static bool flash_in_ram; -#else -#if DT_NODE_HAS_PROP(DT_PARENT(SOC_NV_FLASH_NODE), memory_region) -#define FLASH_SIMULATOR_MREGION \ - LINKER_DT_NODE_REGION_NAME( \ - DT_PHANDLE(DT_PARENT(SOC_NV_FLASH_NODE), memory_region)) -static uint8_t mock_flash[FLASH_SIMULATOR_FLASH_SIZE] Z_GENERIC_SECTION(FLASH_SIMULATOR_MREGION); -#else -static uint8_t mock_flash[FLASH_SIMULATOR_FLASH_SIZE]; -#endif -#endif /* CONFIG_ARCH_POSIX */ - -uint8_t prog_unit_buf[FLASH_SIMULATOR_PROG_UNIT]; - -static DEVICE_API(flash, flash_sim_api); - -static const struct flash_parameters flash_sim_parameters = { - .write_block_size = FLASH_SIMULATOR_PROG_UNIT, - .erase_value = FLASH_SIMULATOR_ERASE_VALUE, - .caps = { -#if !defined(CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE) - .no_explicit_erase = false, -#endif - }, -}; - - -#ifdef CONFIG_FLASH_SIMULATOR_CALLBACKS -static const struct flash_simulator_params flash_sim_params = { - .memory_size = FLASH_SIMULATOR_FLASH_SIZE, - .base_offset = FLASH_SIMULATOR_BASE_OFFSET, - .erase_unit = FLASH_SIMULATOR_ERASE_UNIT, - .prog_unit = FLASH_SIMULATOR_PROG_UNIT, - .explicit_erase = IS_ENABLED(CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE), - .erase_value = FLASH_SIMULATOR_ERASE_VALUE, -}; -static const struct flash_simulator_cb *flash_simulator_cbs; -#endif /* CONFIG_FLASH_SIMULATOR_CALLBACKS */ - - static int flash_range_is_valid(const struct device *dev, off_t offset, size_t len) { - ARG_UNUSED(dev); + const struct flash_simulator_config *cfg = dev->config; - if ((offset < 0 || offset >= FLASH_SIMULATOR_FLASH_SIZE || - (FLASH_SIMULATOR_FLASH_SIZE - offset) < len)) { + if ((offset < 0 || offset >= cfg->flash_size || + (cfg->flash_size - offset) < len)) { return 0; } @@ -205,22 +168,23 @@ static int flash_sim_read(const struct device *dev, const off_t offset, void *data, const size_t len) { - ARG_UNUSED(dev); + const struct flash_simulator_config *cfg = dev->config; + struct flash_simulator_data *dev_data = dev->data; if (!flash_range_is_valid(dev, offset, len)) { return -EINVAL; } if (!IS_ENABLED(CONFIG_FLASH_SIMULATOR_UNALIGNED_READ)) { - if ((offset % FLASH_SIMULATOR_PROG_UNIT) || - (len % FLASH_SIMULATOR_PROG_UNIT)) { + if ((offset % cfg->flash_parameters->write_block_size) || + (len % cfg->flash_parameters->write_block_size)) { return -EINVAL; } } FLASH_SIM_STATS_INC(flash_sim_stats, flash_read_calls); - memcpy(data, MOCK_FLASH(offset), len); + memcpy(data, dev_data->mock_flash + offset, len); FLASH_SIM_STATS_INCN(flash_sim_stats, bytes_read, len); #ifdef CONFIG_FLASH_SIMULATOR_SIMULATE_TIMING @@ -235,14 +199,15 @@ static int flash_sim_read(const struct device *dev, const off_t offset, static int flash_sim_write(const struct device *dev, const off_t offset, const void *data, const size_t len) { - ARG_UNUSED(dev); + const struct flash_simulator_config *cfg = dev->config; + struct flash_simulator_data *dev_data = dev->data; if (!flash_range_is_valid(dev, offset, len)) { return -EINVAL; } - if ((offset % FLASH_SIMULATOR_PROG_UNIT) || - (len % FLASH_SIMULATOR_PROG_UNIT)) { + if ((offset % cfg->flash_parameters->write_block_size) || + (len % cfg->flash_parameters->write_block_size)) { return -EINVAL; } @@ -250,12 +215,15 @@ static int flash_sim_write(const struct device *dev, const off_t offset, #ifdef CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE /* check if any unit has been already programmed */ - memset(prog_unit_buf, FLASH_SIMULATOR_ERASE_VALUE, sizeof(prog_unit_buf)); + memset(cfg->prog_unit_buf, cfg->flash_parameters->erase_value, + cfg->flash_parameters->write_block_size); #else - memcpy(prog_unit_buf, MOCK_FLASH(offset), sizeof(prog_unit_buf)); + memcpy(cfg->prog_unit_buf, dev_data->mock_flash + offset, + cfg->flash_parameters->write_block_size); #endif - for (uint32_t i = 0; i < len; i += FLASH_SIMULATOR_PROG_UNIT) { - if (memcmp(prog_unit_buf, MOCK_FLASH(offset + i), sizeof(prog_unit_buf))) { + for (uint32_t i = 0; i < len; i += cfg->flash_parameters->write_block_size) { + if (memcmp(cfg->prog_unit_buf, dev_data->mock_flash + offset + i, + cfg->flash_parameters->write_block_size)) { FLASH_SIM_STATS_INC(flash_sim_stats, double_writes); #if !CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES return -EIO; @@ -283,7 +251,7 @@ static int flash_sim_write(const struct device *dev, const off_t offset, #ifdef CONFIG_FLASH_SIMULATOR_CALLBACKS flash_simulator_write_byte_cb_t write_cb = NULL; - const struct flash_simulator_cb *cb = flash_simulator_cbs; + const struct flash_simulator_cb *cb = dev_data->flash_simulator_cbs; if (cb != NULL) { write_cb = cb->write_byte; @@ -302,13 +270,13 @@ static int flash_sim_write(const struct device *dev, const off_t offset, uint8_t data_val = *((const uint8_t *)data + i); #ifdef CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE -#if FLASH_SIMULATOR_ERASE_VALUE == 0xFF - /* only pull bits to zero */ - data_val &= *(MOCK_FLASH(offset + i)); -#else - /* only pull bits to one */ - data_val |= *(MOCK_FLASH(offset + i)); -#endif + if (cfg->flash_parameters->erase_value == 0xff) { + /* only pull bits to zero */ + data_val &= *(dev_data->mock_flash + offset + i); + } else { + /* only pull bits to one */ + data_val |= *(dev_data->mock_flash + offset + i); + } #endif #ifdef CONFIG_FLASH_SIMULATOR_CALLBACKS if (write_cb != NULL) { @@ -320,7 +288,7 @@ static int flash_sim_write(const struct device *dev, const off_t offset, data_val = (uint8_t)ret; } #endif /* CONFIG_FLASH_SIMULATOR_CALLBACKS */ - *(MOCK_FLASH(offset + i)) = data_val; + *(dev_data->mock_flash + offset + i) = data_val; } FLASH_SIM_STATS_INCN(flash_sim_stats, bytes_written, len); @@ -337,11 +305,13 @@ static int flash_sim_write(const struct device *dev, const off_t offset, static int unit_erase(const struct device *dev, const uint32_t unit) { - const off_t unit_addr = unit * FLASH_SIMULATOR_ERASE_UNIT; + const struct flash_simulator_config *cfg = dev->config; + struct flash_simulator_data *dev_data = dev->data; + const off_t unit_addr = unit * cfg->erase_unit; #ifdef CONFIG_FLASH_SIMULATOR_CALLBACKS flash_simulator_erase_unit_cb_t erase_cb = NULL; - const struct flash_simulator_cb *cb = flash_simulator_cbs; + const struct flash_simulator_cb *cb = dev_data->flash_simulator_cbs; if (cb != NULL) { erase_cb = cb->erase_unit; @@ -352,21 +322,22 @@ static int unit_erase(const struct device *dev, const uint32_t unit) #endif /* CONFIG_FLASH_SIMULATOR_CALLBACKS */ /* erase the memory unit by setting it to erase value */ - memset(MOCK_FLASH(unit_addr), FLASH_SIMULATOR_ERASE_VALUE, - FLASH_SIMULATOR_ERASE_UNIT); + memset(dev_data->mock_flash + unit_addr, cfg->flash_parameters->erase_value, + cfg->erase_unit); return 0; } static int flash_sim_erase(const struct device *dev, const off_t offset, const size_t len) { + const struct flash_simulator_config *cfg = dev->config; + if (!flash_range_is_valid(dev, offset, len)) { return -EINVAL; } /* erase operation must be aligned to the erase unit boundary */ - if ((offset % FLASH_SIMULATOR_ERASE_UNIT) || - (len % FLASH_SIMULATOR_ERASE_UNIT)) { + if ((offset % cfg->erase_unit) || (len % cfg->erase_unit)) { return -EINVAL; } @@ -380,10 +351,10 @@ static int flash_sim_erase(const struct device *dev, const off_t offset, } #endif /* the first unit to be erased */ - uint32_t unit_start = offset / FLASH_SIMULATOR_ERASE_UNIT; + uint32_t unit_start = offset / cfg->erase_unit; /* erase as many units as necessary and increase their erase counter */ - for (uint32_t i = 0; i < len / FLASH_SIMULATOR_ERASE_UNIT; i++) { + for (uint32_t i = 0; i < len / cfg->erase_unit; i++) { int ret; ERASE_CYCLES_INC(unit_start + i); @@ -404,34 +375,31 @@ static int flash_sim_erase(const struct device *dev, const off_t offset, } #ifdef CONFIG_FLASH_PAGE_LAYOUT -static const struct flash_pages_layout flash_sim_pages_layout = { - .pages_count = FLASH_SIMULATOR_PAGE_COUNT, - .pages_size = FLASH_SIMULATOR_ERASE_UNIT, -}; - static void flash_sim_page_layout(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size) { - *layout = &flash_sim_pages_layout; + const struct flash_simulator_config *cfg = dev->config; + + *layout = cfg->pages_layout; *layout_size = 1; } #endif static int flash_sim_get_size(const struct device *dev, uint64_t *size) { - ARG_UNUSED(dev); + const struct flash_simulator_config *cfg = dev->config; - *size = FLASH_SIMULATOR_FLASH_SIZE; + *size = cfg->flash_size; return 0; } static const struct flash_parameters * flash_sim_get_parameters(const struct device *dev) { - ARG_UNUSED(dev); + const struct flash_simulator_config *cfg = dev->config; - return &flash_sim_parameters; + return cfg->flash_parameters; } static DEVICE_API(flash, flash_sim_api) = { @@ -450,15 +418,17 @@ static DEVICE_API(flash, flash_sim_api) = { static int flash_mock_init(const struct device *dev) { int rc; - ARG_UNUSED(dev); + const struct flash_simulator_config *cfg = dev->config; + struct flash_simulator_data *dev_data = dev->data; - if (flash_in_ram == false && flash_file_path == NULL) { - flash_file_path = DEFAULT_FLASH_FILE_PATH; + if (dev_data->flash_in_ram == false && dev_data->flash_file_path == NULL) { + dev_data->flash_file_path = cfg->flash_file_default_path; } - rc = flash_mock_init_native(flash_in_ram, &mock_flash, FLASH_SIMULATOR_FLASH_SIZE, - &flash_fd, flash_file_path, FLASH_SIMULATOR_ERASE_VALUE, - flash_erase_at_start); + rc = flash_mock_init_native(dev_data->flash_in_ram, &dev_data->mock_flash, cfg->flash_size, + &dev_data->flash_fd, dev_data->flash_file_path, + cfg->flash_parameters->erase_value, + dev_data->flash_erase_at_start); if (rc < 0) { return -EIO; @@ -467,21 +437,18 @@ static int flash_mock_init(const struct device *dev) } } -#else -#if DT_NODE_HAS_PROP(DT_PARENT(SOC_NV_FLASH_NODE), memory_region) -static int flash_mock_init(const struct device *dev) -{ - ARG_UNUSED(dev); - return 0; -} #else static int flash_mock_init(const struct device *dev) { - ARG_UNUSED(dev); - memset(mock_flash, FLASH_SIMULATOR_ERASE_VALUE, ARRAY_SIZE(mock_flash)); + const struct flash_simulator_config *cfg = dev->config; + struct flash_simulator_data *dev_data = dev->data; + + if (dev_data->flash_erase_at_start) { + memset(dev_data->mock_flash, cfg->flash_parameters->erase_value, cfg->flash_size); + } + return 0; } -#endif /* DT_NODE_HAS_PROP(DT_PARENT(SOC_NV_FLASH_NODE), memory_region) */ #endif /* CONFIG_ARCH_POSIX */ static int flash_init(const struct device *dev) @@ -492,72 +459,23 @@ static int flash_init(const struct device *dev) return flash_mock_init(dev); } -DEVICE_DT_INST_DEFINE(0, flash_init, NULL, - NULL, NULL, POST_KERNEL, CONFIG_FLASH_INIT_PRIORITY, - &flash_sim_api); - -#ifdef CONFIG_ARCH_POSIX - -static void flash_native_cleanup(void) -{ - flash_mock_cleanup_native(flash_in_ram, flash_fd, mock_flash, - FLASH_SIMULATOR_FLASH_SIZE, flash_file_path, - flash_rm_at_exit); -} - -static void flash_native_options(void) -{ - static struct args_struct_t flash_options[] = { - { .option = "flash", - .name = "path", - .type = 's', - .dest = (void *)&flash_file_path, - .descript = "Path to binary file to be used as flash, by default \"" - DEFAULT_FLASH_FILE_PATH "\""}, - { .is_switch = true, - .option = "flash_erase", - .type = 'b', - .dest = (void *)&flash_erase_at_start, - .descript = "Erase the flash content at startup" }, - { .is_switch = true, - .option = "flash_rm", - .type = 'b', - .dest = (void *)&flash_rm_at_exit, - .descript = "Remove the flash file when terminating the execution" }, - { .is_switch = true, - .option = "flash_in_ram", - .type = 'b', - .dest = (void *)&flash_in_ram, - .descript = "Instead of a file, keep the file content just in RAM. If this is " - "set, flash, flash_erase & flash_rm are ignored. The flash content" - " is always erased at startup" }, - ARG_TABLE_ENDMARKER - }; - - native_add_command_line_opts(flash_options); -} - -NATIVE_TASK(flash_native_options, PRE_BOOT_1, 1); -NATIVE_TASK(flash_native_cleanup, ON_EXIT, 1); - -#endif /* CONFIG_ARCH_POSIX */ - /* Extension to generic flash driver API */ void *z_impl_flash_simulator_get_memory(const struct device *dev, size_t *mock_size) { - ARG_UNUSED(dev); + const struct flash_simulator_config *cfg = dev->config; + struct flash_simulator_data *dev_data = dev->data; - *mock_size = FLASH_SIMULATOR_FLASH_SIZE; - return mock_flash; + *mock_size = cfg->flash_size; + return dev_data->mock_flash; } const struct flash_simulator_params *z_impl_flash_simulator_get_params(const struct device *dev) { - ARG_UNUSED(dev); + __maybe_unused const struct flash_simulator_config *cfg = dev->config; #ifdef CONFIG_FLASH_SIMULATOR_CALLBACKS - return &flash_sim_params; + return cfg->flash_simulator_params; #else return NULL; #endif @@ -567,8 +485,9 @@ const struct flash_simulator_params *z_impl_flash_simulator_get_params(const str void z_impl_flash_simulator_set_callbacks(const struct device *dev, const struct flash_simulator_cb *cb) { - ARG_UNUSED(dev); - flash_simulator_cbs = cb; + struct flash_simulator_data *dev_data = dev->data; + + dev_data->flash_simulator_cbs = cb; } #endif /* CONFIG_FLASH_SIMULATOR_CALLBACKS */ @@ -602,3 +521,154 @@ const struct flash_simulator_params *z_vrfy_flash_simulator_get_params(const str #include #endif /* CONFIG_USERSPACE */ + +#define SOC_NV_FLASH_COMPAT(n) COND_CODE_1(DT_NODE_HAS_COMPAT(n, soc_nv_flash), (n), ()) +#define SOC_NV_FLASH_NODE(n) DT_INST_FOREACH_CHILD_STATUS_OKAY(n, SOC_NV_FLASH_COMPAT) +#define FLASH_SIMULATOR_BASE_OFFSET(n) DT_REG_ADDR(SOC_NV_FLASH_NODE(n)) +#define FLASH_SIMULATOR_ERASE_UNIT(n) DT_PROP(SOC_NV_FLASH_NODE(n), erase_block_size) +#define FLASH_SIMULATOR_PROG_UNIT(n) DT_PROP(SOC_NV_FLASH_NODE(n), write_block_size) +#define FLASH_SIMULATOR_FLASH_SIZE(n) DT_REG_SIZE(SOC_NV_FLASH_NODE(n)) +#define FLASH_SIMULATOR_ERASE_VALUE(n) DT_INST_PROP(n, erase_value) +#define FLASH_SIMULATOR_PAGE_COUNT(n) \ + (FLASH_SIMULATOR_FLASH_SIZE(n) / FLASH_SIMULATOR_ERASE_UNIT(n)) + +#define MOCK_FLASH_SECTION(n) \ + COND_CODE_1(DT_INST_NODE_HAS_PROP(n, memory_region), \ + (Z_GENERIC_SECTION(LINKER_DT_NODE_REGION_NAME(DT_INST_PHANDLE(n, memory_region)))), ()) + +#define FLASH_SIMULATOR_INIT(n) \ + IF_DISABLED(CONFIG_ARCH_POSIX, ( \ + static uint8_t mock_flash_##n[FLASH_SIMULATOR_FLASH_SIZE(n)] MOCK_FLASH_SECTION(n);\ + )) \ + static uint8_t prog_unit_buf_##n[FLASH_SIMULATOR_PROG_UNIT(n)]; \ + static struct flash_simulator_data flash_simulator_data_##n = { \ + .mock_flash = COND_CODE_1(CONFIG_ARCH_POSIX, (NULL), (mock_flash_##n)), \ + .flash_erase_at_start = !DT_INST_NODE_HAS_PROP(n, memory_region), \ + IF_ENABLED(CONFIG_ARCH_POSIX, ( \ + .flash_fd = -1, \ + )) \ + }; \ + \ + static const struct flash_parameters flash_parameters_##n = { \ + .write_block_size = FLASH_SIMULATOR_PROG_UNIT(n), \ + .erase_value = FLASH_SIMULATOR_ERASE_VALUE(n), \ + .caps = { \ + .no_explicit_erase = !IS_ENABLED(CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE), \ + }, \ + }; \ + \ + IF_ENABLED(CONFIG_FLASH_SIMULATOR_CALLBACKS, ( \ + static const struct flash_simulator_params flash_simulator_params_##n = { \ + .memory_size = FLASH_SIMULATOR_FLASH_SIZE(n), \ + .base_offset = FLASH_SIMULATOR_BASE_OFFSET(n), \ + .erase_unit = FLASH_SIMULATOR_ERASE_UNIT(n), \ + .prog_unit = FLASH_SIMULATOR_PROG_UNIT(n), \ + .explicit_erase = IS_ENABLED(CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE), \ + .erase_value = FLASH_SIMULATOR_ERASE_VALUE(n), \ + }; \ + )) \ + \ + IF_ENABLED(CONFIG_FLASH_PAGE_LAYOUT, ( \ + static const struct flash_pages_layout flash_sim_pages_layout_##n = { \ + .pages_count = FLASH_SIMULATOR_PAGE_COUNT(n), \ + .pages_size = FLASH_SIMULATOR_ERASE_UNIT(n), \ + }; \ + )) \ + \ + static const struct flash_simulator_config flash_simulator_config_##n = { \ + .prog_unit_buf = prog_unit_buf_##n, \ + .flash_parameters = &flash_parameters_##n, \ + .base_offset = FLASH_SIMULATOR_BASE_OFFSET(n), \ + .erase_unit = FLASH_SIMULATOR_ERASE_UNIT(n), \ + .flash_size = FLASH_SIMULATOR_FLASH_SIZE(n), \ + IF_ENABLED(CONFIG_FLASH_SIMULATOR_CALLBACKS, ( \ + .flash_simulator_params = &flash_simulator_params_##n, \ + )) \ + IF_ENABLED(CONFIG_FLASH_PAGE_LAYOUT, ( \ + .pages_layout = &flash_sim_pages_layout_##n, \ + )) \ + IF_ENABLED(CONFIG_ARCH_POSIX, ( \ + .flash_file_default_path = DEFAULT_FLASH_FILE_PATH(n) \ + )) \ + }; \ + \ + BUILD_ASSERT((FLASH_SIMULATOR_ERASE_UNIT(n) % FLASH_SIMULATOR_PROG_UNIT(n)) == 0, \ + "Erase unit must be a multiple of program unit"); \ + \ + DEVICE_DT_INST_DEFINE(n, flash_init, NULL, &flash_simulator_data_##n, \ + &flash_simulator_config_##n, POST_KERNEL, \ + CONFIG_FLASH_INIT_PRIORITY, &flash_sim_api); + +DT_INST_FOREACH_STATUS_OKAY(FLASH_SIMULATOR_INIT); + +#ifdef CONFIG_ARCH_POSIX + +#define FLASH_SIMULATOR_CLEANUP(n) \ + flash_mock_cleanup_native( \ + flash_simulator_data_##n.flash_in_ram, flash_simulator_data_##n.flash_fd, \ + flash_simulator_data_##n.mock_flash, flash_simulator_config_##n.flash_size, \ + flash_simulator_data_##n.flash_file_path, \ + flash_simulator_data_##n.flash_rm_at_exit); + +static void flash_native_cleanup(void) +{ + DT_INST_FOREACH_STATUS_OKAY(FLASH_SIMULATOR_CLEANUP) +} + +#define FLASH_SIMULATOR_INSTANCE_COMMAND_LINE_OPTS(n, INST_NAME) \ + { \ + .option = INST_NAME, \ + .name = "path", \ + .type = 's', \ + .dest = (void *)&flash_simulator_data_##n.flash_file_path, \ + .descript = "Path to binary file to be used as flash by " INST_NAME \ + ", by default \"" DEFAULT_FLASH_FILE_PATH(n) "\"" \ + }, \ + { \ + .option = INST_NAME "_erase", \ + .is_switch = true, \ + .type = 'b', \ + .dest = (void *)&flash_simulator_data_##n.flash_erase_at_start, \ + .descript = "Erase the flash content of " INST_NAME " at startup" \ + }, \ + { \ + .option = INST_NAME "_rm", \ + .is_switch = true, \ + .type = 'b', \ + .dest = (void *)&flash_simulator_data_##n.flash_rm_at_exit, \ + .descript = "Remove the flash file of " INST_NAME " when terminating the " \ + "execution" \ + }, \ + { \ + .option = INST_NAME "_in_ram", \ + .is_switch = true, \ + .type = 'b', \ + .dest = (void *)&flash_simulator_data_##n.flash_in_ram, \ + .descript = "Instead of a file, keep the content of " INST_NAME " just in RAM. " \ + "If this is set, " INST_NAME ", " INST_NAME "_erase & " \ + INST_NAME "_rm are ignored. The flash content is always erased at startup." \ + }, + +#define FLASH_SIMULATOR_COMMAND_LINE_OPTS(n) \ + FLASH_SIMULATOR_INSTANCE_COMMAND_LINE_OPTS(n, DEVICE_DT_NAME(SOC_NV_FLASH_NODE(n))) + +static void flash_native_options(void) +{ + static struct args_struct_t flash_options[] = { + /* For backward compatibility, instance 0 is also available with "flash" */ + /* as command line option prefix. */ + COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT), ( + FLASH_SIMULATOR_INSTANCE_COMMAND_LINE_OPTS(0, "flash") + ), ()) + + DT_INST_FOREACH_STATUS_OKAY(FLASH_SIMULATOR_COMMAND_LINE_OPTS) + ARG_TABLE_ENDMARKER + }; + + native_add_command_line_opts(flash_options); +} + +NATIVE_TASK(flash_native_options, PRE_BOOT_1, 1); +NATIVE_TASK(flash_native_cleanup, ON_EXIT, 1); + +#endif /* CONFIG_ARCH_POSIX */ From a319b470d094c7f2b932892415fd23fbdf9c38a8 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Tue, 24 Feb 2026 15:32:09 +1000 Subject: [PATCH 35/63] [nrf fromtree] flash: simulator: PM support 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 (cherry picked from commit 08f9b85d3d11cc1a7e6fd2e657c9ebb181ecbd19) --- drivers/flash/flash_simulator.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/flash/flash_simulator.c b/drivers/flash/flash_simulator.c index baf9ac93ee7b..f2066b6ec4c9 100644 --- a/drivers/flash/flash_simulator.c +++ b/drivers/flash/flash_simulator.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -451,12 +452,24 @@ static int flash_mock_init(const struct device *dev) } #endif /* CONFIG_ARCH_POSIX */ +static int flash_sim_pm_control(const struct device *dev, enum pm_device_action action) +{ + /* No action needed, exists only to enable validating get/put balancing in tests */ + return 0; +} + static int flash_init(const struct device *dev) { + int rc; + FLASH_SIM_STATS_INIT_AND_REG(flash_sim_stats, STATS_SIZE_32, "flash_sim_stats"); FLASH_SIM_STATS_INIT_AND_REG(flash_sim_thresholds, STATS_SIZE_32, "flash_sim_thresholds"); - return flash_mock_init(dev); + rc = flash_mock_init(dev); + if (rc == 0) { + rc = pm_device_driver_init(dev, flash_sim_pm_control); + } + return rc; } /* Extension to generic flash driver API */ @@ -595,7 +608,8 @@ const struct flash_simulator_params *z_vrfy_flash_simulator_get_params(const str BUILD_ASSERT((FLASH_SIMULATOR_ERASE_UNIT(n) % FLASH_SIMULATOR_PROG_UNIT(n)) == 0, \ "Erase unit must be a multiple of program unit"); \ \ - DEVICE_DT_INST_DEFINE(n, flash_init, NULL, &flash_simulator_data_##n, \ + PM_DEVICE_DT_INST_DEFINE(n, flash_sim_pm_control); \ + DEVICE_DT_INST_DEFINE(n, flash_init, PM_DEVICE_DT_INST_GET(n), &flash_simulator_data_##n, \ &flash_simulator_config_##n, POST_KERNEL, \ CONFIG_FLASH_INIT_PRIORITY, &flash_sim_api); From 9b5478e38dae269a0f79e99910341bf5e59c3ec7 Mon Sep 17 00:00:00 2001 From: Seyoung Jeong Date: Fri, 6 Mar 2026 04:18:29 -0700 Subject: [PATCH 36/63] [nrf fromtree] drivers: flash: simulator: fix buggy per-instance erase 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 (cherry picked from commit fa0ed03c5b9ab6be0aaacb9ec0871d03abd1513b) --- drivers/flash/flash_simulator.c | 10 ++++++- .../flash_controller/zephyr,sim-flash.yaml | 7 +++++ .../flash_simulator/flash_sim_impl/src/main.c | 30 +++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/drivers/flash/flash_simulator.c b/drivers/flash/flash_simulator.c index f2066b6ec4c9..7fe32c8667a3 100644 --- a/drivers/flash/flash_simulator.c +++ b/drivers/flash/flash_simulator.c @@ -545,6 +545,14 @@ const struct flash_simulator_params *z_vrfy_flash_simulator_get_params(const str #define FLASH_SIMULATOR_PAGE_COUNT(n) \ (FLASH_SIMULATOR_FLASH_SIZE(n) / FLASH_SIMULATOR_ERASE_UNIT(n)) +/* Resolve the no_explicit_erase capability per device instance. + * DT_INST_PROP for a boolean type is 0 when absent, 1 when set in DTS, + * so a logical OR with the Kconfig fallback covers all cases correctly. + */ +#define FLASH_SIMULATOR_NO_EXPLICIT_ERASE(n) \ + (DT_INST_PROP(n, no_explicit_erase) || \ + !IS_ENABLED(CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE)) + #define MOCK_FLASH_SECTION(n) \ COND_CODE_1(DT_INST_NODE_HAS_PROP(n, memory_region), \ (Z_GENERIC_SECTION(LINKER_DT_NODE_REGION_NAME(DT_INST_PHANDLE(n, memory_region)))), ()) @@ -566,7 +574,7 @@ const struct flash_simulator_params *z_vrfy_flash_simulator_get_params(const str .write_block_size = FLASH_SIMULATOR_PROG_UNIT(n), \ .erase_value = FLASH_SIMULATOR_ERASE_VALUE(n), \ .caps = { \ - .no_explicit_erase = !IS_ENABLED(CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE), \ + .no_explicit_erase = FLASH_SIMULATOR_NO_EXPLICIT_ERASE(n), \ }, \ }; \ \ diff --git a/dts/bindings/flash_controller/zephyr,sim-flash.yaml b/dts/bindings/flash_controller/zephyr,sim-flash.yaml index 21b78b750126..f28e076a2fc0 100644 --- a/dts/bindings/flash_controller/zephyr,sim-flash.yaml +++ b/dts/bindings/flash_controller/zephyr,sim-flash.yaml @@ -16,3 +16,10 @@ properties: description: | Memory region used by the simulated flash memory. If this option is used the memory that is used by the simulated flash memory is not erased. + no-explicit-erase: + type: boolean + description: | + When set, this instance behaves as a RAM-like device that does not + require explicit erase before write. Overrides the global + CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE Kconfig option for this instance, + allowing different simulator instances to have different erase modes. diff --git a/tests/drivers/flash_simulator/flash_sim_impl/src/main.c b/tests/drivers/flash_simulator/flash_sim_impl/src/main.c index 8fef1927a49a..fc7390b61a5b 100644 --- a/tests/drivers/flash_simulator/flash_sim_impl/src/main.c +++ b/tests/drivers/flash_simulator/flash_sim_impl/src/main.c @@ -452,6 +452,36 @@ ZTEST(flash_sim_api, test_get_erase_value) FLASH_SIMULATOR_ERASE_VALUE); } +ZTEST(flash_sim_api, test_erase_capability) +{ + /* Verify that the runtime device capability matches the build configuration. + * This is the test that was missing and resulted in issue #100352 not being caught: + * the driver was incorrectly setting no_explicit_erase for all instances based + * on a global Kconfig rather than per-instance properties. + */ + const struct flash_parameters *fp = flash_get_parameters(flash_dev); + int erase_cap; + + zassert_not_null(fp, "flash_get_parameters() returned NULL"); + + erase_cap = flash_params_get_erase_cap(fp); + +#if defined(CONFIG_FLASH_SIMULATOR_EXPLICIT_ERASE) + /* Erase-type (classic Flash) device: must report explicit erase required */ + zassert_false(fp->caps.no_explicit_erase, + "Device is configured as explicit-erase but caps.no_explicit_erase=true"); + zassert_equal(FLASH_ERASE_C_EXPLICIT, erase_cap, + "Expected FLASH_ERASE_C_EXPLICIT (0x%x), got 0x%x", + FLASH_ERASE_C_EXPLICIT, erase_cap); +#else + /* RAM-like device: must report no explicit erase required */ + zassert_true(fp->caps.no_explicit_erase, + "Device is configured as RAM-like but caps.no_explicit_erase=false"); + zassert_equal(0, erase_cap, + "Expected erase capability 0 for RAM-like device, got 0x%x", erase_cap); +#endif +} + ZTEST(flash_sim_api, test_flash_fill) { off_t i; From 04b5b65eb09928e21b851d109f914500ba95ea2e Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 26 Feb 2026 14:07:03 +0000 Subject: [PATCH 37/63] [nrf fromtree] tests: drivers: flash: Update to support zephyr,mapped-partitions Updates these to support using this new binding whilst retaining support for fixed-partitions Signed-off-by: Jamie McCrae (cherry picked from commit c086f4daa26877007d5eba3ab60a5dc7cdf5565c) --- tests/drivers/flash/erase_blocks/src/main.c | 3 ++- tests/drivers/flash/interface_test/src/main.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/drivers/flash/erase_blocks/src/main.c b/tests/drivers/flash/erase_blocks/src/main.c index 57edfee8fced..d44eed15e4de 100644 --- a/tests/drivers/flash/erase_blocks/src/main.c +++ b/tests/drivers/flash/erase_blocks/src/main.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -26,7 +27,7 @@ LOG_MODULE_REGISTER(test_flash); #endif #define TEST_FLASH_PART_OFFSET \ - DT_REG_ADDR(TEST_FLASH_PART_NODE) + FIXED_PARTITION_NODE_OFFSET(TEST_FLASH_PART_NODE) #define TEST_FLASH_PART_SIZE \ DT_REG_SIZE(TEST_FLASH_PART_NODE) diff --git a/tests/drivers/flash/interface_test/src/main.c b/tests/drivers/flash/interface_test/src/main.c index 461323e8863d..8b2627b4f787 100644 --- a/tests/drivers/flash/interface_test/src/main.c +++ b/tests/drivers/flash/interface_test/src/main.c @@ -7,6 +7,7 @@ #include #include #include +#include #ifdef CONFIG_BOOTLOADER_MCUBOOT #define TEST_FLASH_PART_NODE DT_NODELABEL(boot_partition) @@ -14,7 +15,7 @@ #define TEST_FLASH_PART_NODE DT_NODELABEL(slot1_partition) #endif -#define TEST_FLASH_PART_OFFSET DT_REG_ADDR(TEST_FLASH_PART_NODE) +#define TEST_FLASH_PART_OFFSET FIXED_PARTITION_NODE_OFFSET(TEST_FLASH_PART_NODE) #define TEST_FLASH_PART_SIZE DT_REG_SIZE(TEST_FLASH_PART_NODE) #define TEST_FLASH_CONTROLLER_NODE DT_MTD_FROM_FIXED_PARTITION(TEST_FLASH_PART_NODE) From d3c9c40b0602dd4f65a4f357d38d60363be2666e Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 26 Feb 2026 14:07:45 +0000 Subject: [PATCH 38/63] [nrf fromtree] tests: drivers: flash_simulator: Support zephyr,mapped-partitions Updates this to support using this new binding whilst retaining support for fixed-partitions Signed-off-by: Jamie McCrae (cherry picked from commit 44b2f4c101d1c70fe9ea9072c4af29a9cb057730) --- tests/drivers/flash_simulator/flash_sim_impl/src/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/drivers/flash_simulator/flash_sim_impl/src/main.c b/tests/drivers/flash_simulator/flash_sim_impl/src/main.c index fc7390b61a5b..01ecdf293d55 100644 --- a/tests/drivers/flash_simulator/flash_sim_impl/src/main.c +++ b/tests/drivers/flash_simulator/flash_sim_impl/src/main.c @@ -7,6 +7,7 @@ #include #include #include +#include /* Warning: The test has been written for testing boards with single * instance of Flash Simulator device only. @@ -18,7 +19,7 @@ #else #define SOC_NV_FLASH_NODE DT_CHILD(DT_INST(0, zephyr_sim_flash), flash_sim_0) #endif /* CONFIG_ARCH_POSIX */ -#define FLASH_SIMULATOR_BASE_OFFSET DT_REG_ADDR(SOC_NV_FLASH_NODE) +#define FLASH_SIMULATOR_BASE_OFFSET FIXED_PARTITION_NODE_OFFSET(SOC_NV_FLASH_NODE) #define FLASH_SIMULATOR_ERASE_UNIT DT_PROP(SOC_NV_FLASH_NODE, erase_block_size) #define FLASH_SIMULATOR_PROG_UNIT DT_PROP(SOC_NV_FLASH_NODE, write_block_size) #define FLASH_SIMULATOR_FLASH_SIZE DT_REG_SIZE(SOC_NV_FLASH_NODE) From ed7c50ed6f41d8eb42bfcfcd71b7fb2a7300d927 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 26 Feb 2026 14:08:45 +0000 Subject: [PATCH 39/63] [nrf fromtree] drivers: disk: flashdisk: Support zephyr,mapped-partitions Updates this to support using this new binding whilst retaining support for fixed-partitions Signed-off-by: Jamie McCrae (cherry picked from commit 1b4d81cbbcef57b15bf6f59046e37b5f8f76f21a) --- drivers/disk/flashdisk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/disk/flashdisk.c b/drivers/disk/flashdisk.c index 1959f94b0ed3..68a63fce4c34 100644 --- a/drivers/disk/flashdisk.c +++ b/drivers/disk/flashdisk.c @@ -521,7 +521,7 @@ DT_INST_FOREACH_STATUS_OKAY(DEFINE_FLASHDISKS_CACHE) .name = DT_INST_PROP(n, disk_name), \ }, \ .area_id = DT_FIXED_PARTITION_ID(PARTITION_PHANDLE(n)), \ - .offset = DT_REG_ADDR(PARTITION_PHANDLE(n)), \ + .offset = FIXED_PARTITION_NODE_OFFSET(PARTITION_PHANDLE(n)), \ .cache = flashdisk##n##_cache, \ .cache_size = sizeof(flashdisk##n##_cache), \ .size = DT_REG_SIZE(PARTITION_PHANDLE(n)), \ From 8853d3a6ad1c4f11bbc02ca84c42c0bc8c058b9c Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Tue, 3 Mar 2026 10:18:19 +0000 Subject: [PATCH 40/63] [nrf noup] tree: Replace FIXED_PARTITION_* macro usage with PARTITION_* 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 (cherry picked from commit f22592cbc55f3adc0accdc75ab5471a0d69ac529) --- drivers/disk/flashdisk.c | 4 +- drivers/flash/flash_mcux_c40.c | 4 +- drivers/haptics/cs40l5x.c | 6 +- drivers/ieee802154/ieee802154_mcxw.c | 2 +- modules/canopennode/canopen_program.c | 6 +- .../espressif/flash_encryption/src/main.c | 2 +- .../espressif/flash_ipm/remote/src/main.c | 6 +- .../espressif/flash_memory_mapped/src/main.c | 4 +- .../reel_board/mesh_badge/src/reel_board.c | 6 +- samples/drivers/soc_flash_nrf/src/main.c | 4 +- samples/drivers/spi_flash/src/main.c | 2 +- samples/subsys/fs/format/src/main.c | 2 +- samples/subsys/fs/littlefs/src/main.c | 2 +- samples/subsys/fs/zms/src/main.c | 4 +- samples/subsys/mgmt/mcumgr/smp_svr/src/main.c | 2 +- samples/subsys/nvs/src/main.c | 4 +- samples/subsys/settings/src/main.c | 3 +- samples/subsys/usb/mass/src/main.c | 2 +- soc/adi/max32/mpu_regions.c | 6 +- soc/espressif/common/loader.c | 6 +- soc/espressif/esp32/esp32-mp.c | 6 +- soc/espressif/esp32s3/esp32s3-mp.c | 6 +- soc/nordic/nrf54h/soc.c | 18 +- subsys/bluetooth/mesh/shell/dfu.c | 2 +- .../coredump_backend_flash_partition.c | 6 +- subsys/dfu/boot/mcuboot.c | 94 ++++---- subsys/dfu/boot/mcuboot_priv.h | 8 +- subsys/dfu/boot/mcuboot_shell.c | 8 +- subsys/dfu/img_util/flash_img.c | 24 +-- subsys/fs/littlefs_fs.c | 2 +- subsys/fs/shell.c | 6 +- subsys/lorawan/services/frag_flash.c | 2 +- subsys/mgmt/hawkbit/hawkbit.c | 2 +- subsys/mgmt/hawkbit/hawkbit_firmware.c | 2 +- .../mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c | 80 +++---- .../mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c | 88 ++++---- .../mcumgr/grp/zephyr_basic/src/basic_mgmt.c | 2 +- subsys/mgmt/updatehub/updatehub_storage.h | 4 +- subsys/secure_storage/src/its/store/zms.c | 6 +- subsys/settings/src/settings_fcb.c | 4 +- subsys/settings/src/settings_nvs.c | 4 +- subsys/settings/src/settings_zms.c | 4 +- subsys/storage/flash_map/flash_map_default.c | 70 +++--- subsys/usb/device/class/dfu/usb_dfu.c | 18 +- subsys/usb/device_next/class/usbd_dfu_flash.c | 8 +- tests/bluetooth/mesh/blob_io_flash/src/main.c | 4 +- tests/boards/nrf/rram_throttling/src/main.c | 6 +- tests/drivers/flash/common/src/main.c | 6 +- tests/drivers/flash/erase_blocks/src/main.c | 4 +- tests/drivers/flash/interface_test/src/main.c | 4 +- tests/drivers/flash/negative_tests/src/main.c | 10 +- tests/drivers/flash/stm32/src/main.c | 8 +- .../flash_simulator/flash_sim_impl/src/main.c | 2 +- tests/lib/devicetree/api/src/main.c | 203 +++++++++++++----- tests/lib/gui/lvgl/src/main.c | 2 +- tests/net/lib/http_server/core/src/main.c | 2 +- tests/subsys/dfu/img_util/src/main.c | 22 +- tests/subsys/dfu/mcuboot/src/main.c | 4 +- tests/subsys/dfu/mcuboot_multi/src/main.c | 8 +- tests/subsys/fs/fcb/src/fcb_test.h | 2 +- tests/subsys/fs/littlefs/src/testfs_lfs.c | 6 +- .../fs/multi-fs/src/test_littlefs_mount.c | 2 +- .../subsys/fs/multi-fs/src/test_ram_backend.c | 4 +- tests/subsys/fs/multi-fs/src/test_utils.c | 2 +- tests/subsys/fs/nvs/src/main.c | 6 +- tests/subsys/fs/zms/src/main.c | 6 +- tests/subsys/llext/src/test_llext.c | 2 +- tests/subsys/lorawan/frag_decoder/src/main.c | 2 +- .../mgmt/mcumgr/img_mgmt_slot_info/src/main.c | 12 +- .../subsys/secure_storage/psa/its/src/main.c | 8 +- .../settings/fcb/src/settings_test_fcb.c | 2 +- .../fcb_init/src/settings_test_fcb_init.c | 10 +- .../file/src/settings_setup_littlefs.c | 2 +- .../functional/src/settings_basic_test.c | 4 +- tests/subsys/storage/flash_map/src/main.c | 86 ++++---- tests/subsys/storage/flash_map/src/main_sha.c | 6 +- 76 files changed, 553 insertions(+), 445 deletions(-) diff --git a/drivers/disk/flashdisk.c b/drivers/disk/flashdisk.c index 68a63fce4c34..bdb19fae1663 100644 --- a/drivers/disk/flashdisk.c +++ b/drivers/disk/flashdisk.c @@ -520,8 +520,8 @@ DT_INST_FOREACH_STATUS_OKAY(DEFINE_FLASHDISKS_CACHE) .ops = &flash_disk_ops, \ .name = DT_INST_PROP(n, disk_name), \ }, \ - .area_id = DT_FIXED_PARTITION_ID(PARTITION_PHANDLE(n)), \ - .offset = FIXED_PARTITION_NODE_OFFSET(PARTITION_PHANDLE(n)), \ + .area_id = DT_PARTITION_ID(PARTITION_PHANDLE(n)), \ + .offset = PARTITION_NODE_OFFSET(PARTITION_PHANDLE(n)), \ .cache = flashdisk##n##_cache, \ .cache_size = sizeof(flashdisk##n##_cache), \ .size = DT_REG_SIZE(PARTITION_PHANDLE(n)), \ diff --git a/drivers/flash/flash_mcux_c40.c b/drivers/flash/flash_mcux_c40.c index 075aca0c495d..781222afaf6b 100644 --- a/drivers/flash/flash_mcux_c40.c +++ b/drivers/flash/flash_mcux_c40.c @@ -336,8 +336,8 @@ static const struct flash_driver_api mcux_c40_api = { DT_SAME_NODE( \ DT_PARENT(DT_NODELABEL(lbl)), \ C40_FLASH_NODE(inst)), \ - ({ .off = (uint32_t)FIXED_PARTITION_OFFSET(lbl), \ - .len = (uint32_t)FIXED_PARTITION_SIZE(lbl), \ + ({ .off = (uint32_t)PARTITION_OFFSET(lbl), \ + .len = (uint32_t)PARTITION_SIZE(lbl), \ .name = #lbl },), \ ()) \ ), \ diff --git a/drivers/haptics/cs40l5x.c b/drivers/haptics/cs40l5x.c index 76111e902a5d..5cf14a828a52 100644 --- a/drivers/haptics/cs40l5x.c +++ b/drivers/haptics/cs40l5x.c @@ -2624,15 +2624,15 @@ __maybe_unused static int cs40l5x_deinit(const struct device *dev) (.interrupt_gpio = {.port = NULL, .pin = 0},)) #define HAPTICS_CS40L5X_FLASH_DEVICE(inst) \ - DEVICE_DT_GET_OR_NULL(DT_MTD_FROM_FIXED_PARTITION(DT_INST_PHANDLE(inst, flash_storage))) + DEVICE_DT_GET_OR_NULL(DT_MTD_FROM_PARTITION(DT_INST_PHANDLE(inst, flash_storage))) #define HAPTICS_CS40L5X_FLASH_OFFSET(inst) \ - FIXED_PARTITION_NODE_OFFSET(DT_INST_PHANDLE(inst, flash_storage)) + \ + PARTITION_NODE_OFFSET(DT_INST_PHANDLE(inst, flash_storage)) + \ DT_INST_PROP_OR(inst, flash_offset, 0) #define HAPTICS_CS40L5X_FLASH(inst) \ COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, flash_storage), \ - (COND_CODE_1(DT_FIXED_PARTITION_EXISTS(DT_INST_PHANDLE(inst, flash_storage)), \ + (COND_CODE_1(DT_PARTITION_EXISTS(DT_INST_PHANDLE(inst, flash_storage)), \ (.flash = HAPTICS_CS40L5X_FLASH_DEVICE(inst), \ .flash_offset = HAPTICS_CS40L5X_FLASH_OFFSET(inst),), \ (.flash = DEVICE_DT_GET(DT_INST_PHANDLE(inst, flash_storage)), \ diff --git a/drivers/ieee802154/ieee802154_mcxw.c b/drivers/ieee802154/ieee802154_mcxw.c index b724c3a5cb6a..49d6f1ead038 100644 --- a/drivers/ieee802154/ieee802154_mcxw.c +++ b/drivers/ieee802154/ieee802154_mcxw.c @@ -66,7 +66,7 @@ static uint16_t rf_compute_csl_phase(uint32_t aTimeUs); #endif /* CONFIG_IEEE802154_CSL_ENDPOINT */ /* Hardware parameters partition and offsets */ -#define HW_PARAMS_PARTITION_ID FIXED_PARTITION_ID(hw_params_partition) +#define HW_PARAMS_PARTITION_ID PARTITION_ID(hw_params_partition) #define MAC_ADDRESS_OFFSET 0x00 #define MAC_ADDRESS_LEN 8 diff --git a/modules/canopennode/canopen_program.c b/modules/canopennode/canopen_program.c index 5ad99c376283..c40e57cc2b52 100644 --- a/modules/canopennode/canopen_program.c +++ b/modules/canopennode/canopen_program.c @@ -189,7 +189,7 @@ static inline CO_SDO_abortCode_t canopen_program_cmd_clear(void) if (!IS_ENABLED(CONFIG_IMG_ERASE_PROGRESSIVELY)) { LOG_DBG("erasing flash area"); - err = boot_erase_img_bank(FIXED_PARTITION_ID(slot1_partition)); + err = boot_erase_img_bank(PARTITION_ID(slot1_partition)); if (err) { LOG_ERR("failed to erase image bank (err %d)", err); CO_errorReport(ctx.em, CO_EM_NON_VOLATILE_MEMORY, @@ -344,9 +344,9 @@ static CO_SDO_abortCode_t canopen_odf_1f56(CO_ODF_arg_t *odf_arg) * started upon receiveing the next 'start' command. */ if (ctx.flash_written) { - fa_id = FIXED_PARTITION_ID(slot1_partition); + fa_id = PARTITION_ID(slot1_partition); } else { - fa_id = FIXED_PARTITION_ID(slot0_partition); + fa_id = PARTITION_ID(slot0_partition); } err = boot_read_bank_header(fa_id, &header, sizeof(header)); diff --git a/samples/boards/espressif/flash_encryption/src/main.c b/samples/boards/espressif/flash_encryption/src/main.c index 07799dfe21ac..431696f4df5e 100644 --- a/samples/boards/espressif/flash_encryption/src/main.c +++ b/samples/boards/espressif/flash_encryption/src/main.c @@ -25,7 +25,7 @@ int main(void) { uint8_t buffer[32]; const struct device *flash_device; - off_t address = FIXED_PARTITION_OFFSET(storage_partition); + off_t address = PARTITION_OFFSET(storage_partition); flash_device = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash_controller)); if (!device_is_ready(flash_device)) { diff --git a/samples/boards/espressif/flash_ipm/remote/src/main.c b/samples/boards/espressif/flash_ipm/remote/src/main.c index 2e383ea19cb9..3b28831f3781 100644 --- a/samples/boards/espressif/flash_ipm/remote/src/main.c +++ b/samples/boards/espressif/flash_ipm/remote/src/main.c @@ -16,9 +16,9 @@ #define ASCII_PATTERN(i) ((uint8_t) i % 128) #define TEST_PARTITION storage_partition -#define TEST_PARTITION_DEVICE FIXED_PARTITION_DEVICE(TEST_PARTITION) -#define TEST_PARTITION_ADDRESS FIXED_PARTITION_ADDRESS(TEST_PARTITION) -#define TEST_PARTITION_SIZE FIXED_PARTITION_SIZE(TEST_PARTITION) +#define TEST_PARTITION_DEVICE PARTITION_DEVICE(TEST_PARTITION) +#define TEST_PARTITION_ADDRESS PARTITION_ADDRESS(TEST_PARTITION) +#define TEST_PARTITION_SIZE PARTITION_SIZE(TEST_PARTITION) #define PAGE_SIZE 0x1000 diff --git a/samples/boards/espressif/flash_memory_mapped/src/main.c b/samples/boards/espressif/flash_memory_mapped/src/main.c index f6124107bfe5..ec49a51a7a3d 100644 --- a/samples/boards/espressif/flash_memory_mapped/src/main.c +++ b/samples/boards/espressif/flash_memory_mapped/src/main.c @@ -22,8 +22,8 @@ int main(void) const struct device *flash_device; const void *mem_ptr; spi_flash_mmap_handle_t handle; - off_t address = FIXED_PARTITION_OFFSET(scratch_partition); - size_t size = FIXED_PARTITION_SIZE(scratch_partition); + off_t address = PARTITION_OFFSET(scratch_partition); + size_t size = PARTITION_SIZE(scratch_partition); flash_device = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash_controller)); if (!device_is_ready(flash_device)) { diff --git a/samples/boards/phytec/reel_board/mesh_badge/src/reel_board.c b/samples/boards/phytec/reel_board/mesh_badge/src/reel_board.c index b7e71e06e5a1..9fed36185ac7 100644 --- a/samples/boards/phytec/reel_board/mesh_badge/src/reel_board.c +++ b/samples/boards/phytec/reel_board/mesh_badge/src/reel_board.c @@ -25,9 +25,9 @@ #include "board.h" #define STORAGE_PARTITION storage_partition -#define STORAGE_PARTITION_DEV FIXED_PARTITION_DEVICE(STORAGE_PARTITION) -#define STORAGE_PARTITION_OFFSET FIXED_PARTITION_OFFSET(STORAGE_PARTITION) -#define STORAGE_PARTITION_SIZE FIXED_PARTITION_SIZE(STORAGE_PARTITION) +#define STORAGE_PARTITION_DEV PARTITION_DEVICE(STORAGE_PARTITION) +#define STORAGE_PARTITION_OFFSET PARTITION_OFFSET(STORAGE_PARTITION) +#define STORAGE_PARTITION_SIZE PARTITION_SIZE(STORAGE_PARTITION) enum font_size { FONT_SMALL = 0, diff --git a/samples/drivers/soc_flash_nrf/src/main.c b/samples/drivers/soc_flash_nrf/src/main.c index e509deda044a..73332d4c6a24 100644 --- a/samples/drivers/soc_flash_nrf/src/main.c +++ b/samples/drivers/soc_flash_nrf/src/main.c @@ -14,8 +14,8 @@ #include #define TEST_PARTITION storage_partition -#define TEST_PARTITION_OFFSET FIXED_PARTITION_OFFSET(TEST_PARTITION) -#define TEST_PARTITION_DEVICE FIXED_PARTITION_DEVICE(TEST_PARTITION) +#define TEST_PARTITION_OFFSET PARTITION_OFFSET(TEST_PARTITION) +#define TEST_PARTITION_DEVICE PARTITION_DEVICE(TEST_PARTITION) #if defined(CONFIG_SOC_NRF54H20) #define FLASH_PAGE_SIZE 2048 diff --git a/samples/drivers/spi_flash/src/main.c b/samples/drivers/spi_flash/src/main.c index b8721386af00..31cde69c6af7 100644 --- a/samples/drivers/spi_flash/src/main.c +++ b/samples/drivers/spi_flash/src/main.c @@ -17,7 +17,7 @@ defined(CONFIG_BOARD_ARTY_A7_DESIGNSTART_FPGA_CORTEX_M3) /* The FPGA bitstream is stored in the lower 536 sectors of the flash. */ #define SPI_FLASH_TEST_REGION_OFFSET \ - DT_REG_SIZE(DT_NODE_BY_FIXED_PARTITION_LABEL(fpga_bitstream)) + DT_REG_SIZE(DT_NODE_BY_PARTITION_LABEL(fpga_bitstream)) #elif defined(CONFIG_BOARD_NPCX9M6F_EVB) || \ defined(CONFIG_BOARD_NPCX7M6FB_EVB) #define SPI_FLASH_TEST_REGION_OFFSET 0x7F000 diff --git a/samples/subsys/fs/format/src/main.c b/samples/subsys/fs/format/src/main.c index dabc795fc568..7df2aa7e8e0c 100644 --- a/samples/subsys/fs/format/src/main.c +++ b/samples/subsys/fs/format/src/main.c @@ -20,7 +20,7 @@ #include #define MKFS_FS_TYPE FS_LITTLEFS -#define MKFS_DEV_ID FIXED_PARTITION_ID(storage_partition) +#define MKFS_DEV_ID PARTITION_ID(storage_partition) #define MKFS_FLAGS 0 #elif defined(CONFIG_FAT_FILESYSTEM_ELM) diff --git a/samples/subsys/fs/littlefs/src/main.c b/samples/subsys/fs/littlefs/src/main.c index e228baad1fa6..7e565cada935 100644 --- a/samples/subsys/fs/littlefs/src/main.c +++ b/samples/subsys/fs/littlefs/src/main.c @@ -268,7 +268,7 @@ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage); static struct fs_mount_t lfs_storage_mnt = { .type = FS_LITTLEFS, .fs_data = &storage, - .storage_dev = (void *)FIXED_PARTITION_ID(storage_partition), + .storage_dev = (void *)PARTITION_ID(storage_partition), .mnt_point = "/lfs", }; #endif /* PARTITION_NODE */ diff --git a/samples/subsys/fs/zms/src/main.c b/samples/subsys/fs/zms/src/main.c index a17ffd68f72d..6790b786ac2a 100644 --- a/samples/subsys/fs/zms/src/main.c +++ b/samples/subsys/fs/zms/src/main.c @@ -18,8 +18,8 @@ static struct zms_fs fs; #define ZMS_PARTITION storage_partition -#define ZMS_PARTITION_DEVICE FIXED_PARTITION_DEVICE(ZMS_PARTITION) -#define ZMS_PARTITION_OFFSET FIXED_PARTITION_OFFSET(ZMS_PARTITION) +#define ZMS_PARTITION_DEVICE PARTITION_DEVICE(ZMS_PARTITION) +#define ZMS_PARTITION_OFFSET PARTITION_OFFSET(ZMS_PARTITION) #define IP_ADDRESS_ID 1 #define KEY_VALUE_ID COND_CODE_1(CONFIG_ZMS_ID_64BIT, (0xbeefdead00000002ULL), (0xbeefdeadULL)) diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/src/main.c b/samples/subsys/mgmt/mcumgr/smp_svr/src/main.c index 2f33b436fe0c..9c7f06be8665 100644 --- a/samples/subsys/mgmt/mcumgr/smp_svr/src/main.c +++ b/samples/subsys/mgmt/mcumgr/smp_svr/src/main.c @@ -28,7 +28,7 @@ LOG_MODULE_REGISTER(smp_sample); #include "common.h" #define STORAGE_PARTITION_LABEL storage_partition -#define STORAGE_PARTITION_ID FIXED_PARTITION_ID(STORAGE_PARTITION_LABEL) +#define STORAGE_PARTITION_ID PARTITION_ID(STORAGE_PARTITION_LABEL) /* Define an example stats group; approximates seconds since boot. */ STATS_SECT_START(smp_svr_stats) diff --git a/samples/subsys/nvs/src/main.c b/samples/subsys/nvs/src/main.c index 222ebe0ac95d..a2682ef79c5e 100644 --- a/samples/subsys/nvs/src/main.c +++ b/samples/subsys/nvs/src/main.c @@ -49,8 +49,8 @@ static struct nvs_fs fs; #define NVS_PARTITION storage_partition -#define NVS_PARTITION_DEVICE FIXED_PARTITION_DEVICE(NVS_PARTITION) -#define NVS_PARTITION_OFFSET FIXED_PARTITION_OFFSET(NVS_PARTITION) +#define NVS_PARTITION_DEVICE PARTITION_DEVICE(NVS_PARTITION) +#define NVS_PARTITION_OFFSET PARTITION_OFFSET(NVS_PARTITION) #define ADDRESS_ID 1 #define KEY_ID 2 diff --git a/samples/subsys/settings/src/main.c b/samples/subsys/settings/src/main.c index e1fb1cf299f3..4b0dce2a058a 100644 --- a/samples/subsys/settings/src/main.c +++ b/samples/subsys/settings/src/main.c @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -18,7 +19,7 @@ #endif #define STORAGE_PARTITION storage_partition -#define STORAGE_PARTITION_ID FIXED_PARTITION_ID(STORAGE_PARTITION) +#define STORAGE_PARTITION_ID PARTITION_ID(STORAGE_PARTITION) #define GAMMA_DEFAULT_VAl 0 #define FAIL_MSG "fail (err %d)\n" diff --git a/samples/subsys/usb/mass/src/main.c b/samples/subsys/usb/mass/src/main.c index 97b357e88b7e..64c1984a89dd 100644 --- a/samples/subsys/usb/mass/src/main.c +++ b/samples/subsys/usb/mass/src/main.c @@ -36,7 +36,7 @@ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage); #endif #define STORAGE_PARTITION storage_partition -#define STORAGE_PARTITION_ID FIXED_PARTITION_ID(STORAGE_PARTITION) +#define STORAGE_PARTITION_ID PARTITION_ID(STORAGE_PARTITION) static struct fs_mount_t fs_mnt; diff --git a/soc/adi/max32/mpu_regions.c b/soc/adi/max32/mpu_regions.c index 020b5cf19126..b1b1ac7ccc31 100644 --- a/soc/adi/max32/mpu_regions.c +++ b/soc/adi/max32/mpu_regions.c @@ -30,9 +30,9 @@ * flash. */ static const struct arm_mpu_region mpu_regions[] = { -#if FIXED_PARTITION_EXISTS(storage_partition) -#define STORAGE_ADDR (CONFIG_FLASH_BASE_ADDRESS + FIXED_PARTITION_OFFSET(storage_partition)) -#define STORAGE_SIZE (FIXED_PARTITION_SIZE(storage_partition) >> 10) +#if PARTITION_EXISTS(storage_partition) +#define STORAGE_ADDR (CONFIG_FLASH_BASE_ADDRESS + PARTITION_OFFSET(storage_partition)) +#define STORAGE_SIZE (PARTITION_SIZE(storage_partition) >> 10) MAX32_MPU_REGION("FLASH", CONFIG_FLASH_BASE_ADDRESS, REGION_FLASH_ATTR, KB(CONFIG_FLASH_SIZE - STORAGE_SIZE)), MAX32_MPU_REGION("STORAGE", STORAGE_ADDR, MAX32_FLASH_NON_CACHEABLE, KB(STORAGE_SIZE)), diff --git a/soc/espressif/common/loader.c b/soc/espressif/common/loader.c index 6f5856de9aa4..d8f01606b718 100644 --- a/soc/espressif/common/loader.c +++ b/soc/espressif/common/loader.c @@ -88,10 +88,10 @@ #if DT_NODE_EXISTS(DT_CHOSEN(zephyr_code_partition)) #define PART_OFFSET DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition)) #else -#define PART_OFFSET FIXED_PARTITION_OFFSET(slot0_partition) +#define PART_OFFSET PARTITION_OFFSET(slot0_partition) #endif #else -#define PART_OFFSET FIXED_PARTITION_OFFSET(slot0_appcpu_partition) +#define PART_OFFSET PARTITION_OFFSET(slot0_appcpu_partition) #endif void __start(void); @@ -126,7 +126,7 @@ void map_rom_segments(int core, struct rom_segments *map) /* Traverse segments to fix flash offset changes due to post-build processing */ #ifndef CONFIG_BOOTLOADER_MCUBOOT esp_image_segment_header_t WORD_ALIGNED_ATTR segment_hdr; - size_t offset = FIXED_PARTITION_OFFSET(boot_partition); + size_t offset = PARTITION_OFFSET(boot_partition); bool checksum = false; unsigned int segments = 0; unsigned int ram_segments = 0; diff --git a/soc/espressif/esp32/esp32-mp.c b/soc/espressif/esp32/esp32-mp.c index 9e39d9fd8eee..f484440e4db3 100644 --- a/soc/espressif/esp32/esp32-mp.c +++ b/soc/espressif/esp32/esp32-mp.c @@ -351,9 +351,9 @@ static int load_segment(uint32_t src_addr, uint32_t src_len, uint32_t dst_addr) int IRAM_ATTR esp_appcpu_image_load(unsigned int hdr_offset, unsigned int *entry_addr) { - const uint32_t img_off = FIXED_PARTITION_OFFSET(slot0_appcpu_partition); - const uint32_t fa_size = FIXED_PARTITION_SIZE(slot0_appcpu_partition); - const uint8_t fa_id = FIXED_PARTITION_ID(slot0_appcpu_partition); + const uint32_t img_off = PARTITION_OFFSET(slot0_appcpu_partition); + const uint32_t fa_size = PARTITION_SIZE(slot0_appcpu_partition); + const uint8_t fa_id = PARTITION_ID(slot0_appcpu_partition); if (entry_addr == NULL) { ets_printf("Can't return the entry address. Aborting!\n"); diff --git a/soc/espressif/esp32s3/esp32s3-mp.c b/soc/espressif/esp32s3/esp32s3-mp.c index fadbd9224189..85e84b469807 100644 --- a/soc/espressif/esp32s3/esp32s3-mp.c +++ b/soc/espressif/esp32s3/esp32s3-mp.c @@ -68,9 +68,9 @@ static int load_segment(uint32_t src_addr, uint32_t src_len, uint32_t dst_addr) int IRAM_ATTR esp_appcpu_image_load(unsigned int hdr_offset, unsigned int *entry_addr) { - const uint32_t fa_offset = FIXED_PARTITION_OFFSET(slot0_appcpu_partition); - const uint32_t fa_size = FIXED_PARTITION_SIZE(slot0_appcpu_partition); - const uint8_t fa_id = FIXED_PARTITION_ID(slot0_appcpu_partition); + const uint32_t fa_offset = PARTITION_OFFSET(slot0_appcpu_partition); + const uint32_t fa_size = PARTITION_SIZE(slot0_appcpu_partition); + const uint8_t fa_id = PARTITION_ID(slot0_appcpu_partition); if (entry_addr == NULL) { ESP_EARLY_LOGE(TAG, "Can't return the entry address. Aborting!"); diff --git a/soc/nordic/nrf54h/soc.c b/soc/nordic/nrf54h/soc.c index 4f6c3b131a54..740d58d5a339 100644 --- a/soc/nordic/nrf54h/soc.c +++ b/soc/nordic/nrf54h/soc.c @@ -44,11 +44,11 @@ LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL); #define FLASH_LOAD_ADDRESS (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) #endif -#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \ - DT_SAME_NODE(FIXED_PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)), \ - FIXED_PARTITION_MTD(label)) && \ - (FIXED_PARTITION_ADDRESS(label) <= FLASH_LOAD_ADDRESS && \ - FIXED_PARTITION_ADDRESS(label) + FIXED_PARTITION_SIZE(label) > \ +#define PARTITION_IS_RUNNING_APP_PARTITION(label) \ + DT_SAME_NODE(PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)), \ + PARTITION_MTD(label)) && \ + (PARTITION_ADDRESS(label) <= FLASH_LOAD_ADDRESS && \ + PARTITION_ADDRESS(label) + PARTITION_SIZE(label) > \ FLASH_LOAD_ADDRESS) #define FICR_ADDR_GET(node_id, name) \ @@ -164,16 +164,16 @@ void soc_late_init_hook(void) void *radiocore_address = NULL; #if DT_NODE_EXISTS(DT_NODELABEL(cpurad_slot1_partition)) - if (FIXED_PARTITION_IS_RUNNING_APP_PARTITION(cpuapp_slot1_partition)) { - radiocore_address = (void *)(FIXED_PARTITION_ADDRESS(cpurad_slot1_partition) + + if (PARTITION_IS_RUNNING_APP_PARTITION(cpuapp_slot1_partition)) { + radiocore_address = (void *)(PARTITION_ADDRESS(cpurad_slot1_partition) + CONFIG_ROM_START_OFFSET); } else { - radiocore_address = (void *)(FIXED_PARTITION_ADDRESS(cpurad_slot0_partition) + + radiocore_address = (void *)(PARTITION_ADDRESS(cpurad_slot0_partition) + CONFIG_ROM_START_OFFSET); } #else radiocore_address = - (void *)(FIXED_PARTITION_ADDRESS(cpurad_slot0_partition) + CONFIG_ROM_START_OFFSET); + (void *)(PARTITION_ADDRESS(cpurad_slot0_partition) + CONFIG_ROM_START_OFFSET); #endif if (IS_ENABLED(CONFIG_SOC_NRF54H20_CPURAD_ENABLE_CHECK_VTOR) && diff --git a/subsys/bluetooth/mesh/shell/dfu.c b/subsys/bluetooth/mesh/shell/dfu.c index 4ff050f3e59a..e5884a01897a 100644 --- a/subsys/bluetooth/mesh/shell/dfu.c +++ b/subsys/bluetooth/mesh/shell/dfu.c @@ -136,7 +136,7 @@ void bt_mesh_shell_dfu_cmds_init(void) #if defined(CONFIG_BT_MESH_SHELL_DFU_SRV) && defined(CONFIG_BOOTLOADER_MCUBOOT) struct mcuboot_img_header img_header; - int err = boot_read_bank_header(FIXED_PARTITION_ID(slot0_partition), + int err = boot_read_bank_header(PARTITION_ID(slot0_partition), &img_header, sizeof(img_header)); if (!err) { struct shell_dfu_fwid *fwid = diff --git a/subsys/debug/coredump/coredump_backend_flash_partition.c b/subsys/debug/coredump/coredump_backend_flash_partition.c index c23fe82fecc3..25ec9711ba3d 100644 --- a/subsys/debug/coredump/coredump_backend_flash_partition.c +++ b/subsys/debug/coredump/coredump_backend_flash_partition.c @@ -32,9 +32,9 @@ LOG_MODULE_REGISTER(coredump, CONFIG_DEBUG_COREDUMP_LOG_LEVEL); * aligned to flash write size. */ #define FLASH_PARTITION coredump_partition -#define FLASH_PARTITION_ID FIXED_PARTITION_ID(FLASH_PARTITION) +#define FLASH_PARTITION_ID PARTITION_ID(FLASH_PARTITION) -#if !FIXED_PARTITION_EXISTS(FLASH_PARTITION) +#if !PARTITION_EXISTS(FLASH_PARTITION) #error "Need a fixed partition named 'coredump-partition'!" #else @@ -632,4 +632,4 @@ struct coredump_backend_api coredump_backend_flash_partition = { .cmd = coredump_flash_backend_cmd, }; -#endif /* FIXED_PARTITION_EXISTS(coredump_partition) */ +#endif /* PARTITION_EXISTS(coredump_partition) */ diff --git a/subsys/dfu/boot/mcuboot.c b/subsys/dfu/boot/mcuboot.c index 3750e44ac6b0..d754acc8d939 100644 --- a/subsys/dfu/boot/mcuboot.c +++ b/subsys/dfu/boot/mcuboot.c @@ -121,7 +121,7 @@ enum IMAGE_INDEXES { #define INVALID_SLOT_ID 255 #else /* Get active partition. zephyr,code-partition chosen node must be defined */ -#define ACTIVE_SLOT_FLASH_AREA_ID DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_code_partition)) +#define ACTIVE_SLOT_FLASH_AREA_ID DT_PARTITION_ID(DT_CHOSEN(zephyr_code_partition)) #endif #endif /* USE_PARTITION_MANAGER */ @@ -168,81 +168,81 @@ uint8_t boot_fetch_active_slot(void) /* Map slot number back to flash area ID */ switch (slot) { case 0: - return FIXED_PARTITION_ID(SLOT0_PARTITION); + return PARTITION_ID(SLOT0_PARTITION); -#if FIXED_PARTITION_EXISTS(SLOT1_PARTITION) +#if PARTITION_EXISTS(SLOT1_PARTITION) case 1: - return FIXED_PARTITION_ID(SLOT1_PARTITION); + return PARTITION_ID(SLOT1_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT2_PARTITION) +#if PARTITION_EXISTS(SLOT2_PARTITION) case 2: - return FIXED_PARTITION_ID(SLOT2_PARTITION); + return PARTITION_ID(SLOT2_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT3_PARTITION) +#if PARTITION_EXISTS(SLOT3_PARTITION) case 3: - return FIXED_PARTITION_ID(SLOT3_PARTITION); + return PARTITION_ID(SLOT3_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT4_PARTITION) +#if PARTITION_EXISTS(SLOT4_PARTITION) case 4: - return FIXED_PARTITION_ID(SLOT4_PARTITION); + return PARTITION_ID(SLOT4_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT5_PARTITION) +#if PARTITION_EXISTS(SLOT5_PARTITION) case 5: - return FIXED_PARTITION_ID(SLOT5_PARTITION); + return PARTITION_ID(SLOT5_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT6_PARTITION) +#if PARTITION_EXISTS(SLOT6_PARTITION) case 6: - return FIXED_PARTITION_ID(SLOT6_PARTITION); + return PARTITION_ID(SLOT6_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT7_PARTITION) +#if PARTITION_EXISTS(SLOT7_PARTITION) case 7: - return FIXED_PARTITION_ID(SLOT7_PARTITION); + return PARTITION_ID(SLOT7_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT8_PARTITION) +#if PARTITION_EXISTS(SLOT8_PARTITION) case 8: - return FIXED_PARTITION_ID(SLOT8_PARTITION); + return PARTITION_ID(SLOT8_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT9_PARTITION) +#if PARTITION_EXISTS(SLOT9_PARTITION) case 9: - return FIXED_PARTITION_ID(SLOT9_PARTITION); + return PARTITION_ID(SLOT9_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT10_PARTITION) +#if PARTITION_EXISTS(SLOT10_PARTITION) case 10: - return FIXED_PARTITION_ID(SLOT10_PARTITION); + return PARTITION_ID(SLOT10_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT11_PARTITION) +#if PARTITION_EXISTS(SLOT11_PARTITION) case 11: - return FIXED_PARTITION_ID(SLOT11_PARTITION); + return PARTITION_ID(SLOT11_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT12_PARTITION) +#if PARTITION_EXISTS(SLOT12_PARTITION) case 12: - return FIXED_PARTITION_ID(SLOT12_PARTITION); + return PARTITION_ID(SLOT12_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT13_PARTITION) +#if PARTITION_EXISTS(SLOT13_PARTITION) case 13: - return FIXED_PARTITION_ID(SLOT13_PARTITION); + return PARTITION_ID(SLOT13_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT14_PARTITION) +#if PARTITION_EXISTS(SLOT14_PARTITION) case 14: - return FIXED_PARTITION_ID(SLOT14_PARTITION); + return PARTITION_ID(SLOT14_PARTITION); #endif -#if FIXED_PARTITION_EXISTS(SLOT15_PARTITION) +#if PARTITION_EXISTS(SLOT15_PARTITION) case 15: - return FIXED_PARTITION_ID(SLOT15_PARTITION); + return PARTITION_ID(SLOT15_PARTITION); #endif default: @@ -268,34 +268,34 @@ size_t boot_get_image_start_offset(uint8_t area_id) size_t off = 0; int image = IMAGE_INDEX_INVALID; - if (area_id == FIXED_PARTITION_ID(slot1_partition)) { + if (area_id == PARTITION_ID(slot1_partition)) { image = IMAGE_INDEX_0; -#if FIXED_PARTITION_EXISTS(slot3_partition) - } else if (area_id == FIXED_PARTITION_ID(slot3_partition)) { +#if PARTITION_EXISTS(slot3_partition) + } else if (area_id == PARTITION_ID(slot3_partition)) { image = IMAGE_INDEX_1; #endif -#if FIXED_PARTITION_EXISTS(slot5_partition) - } else if (area_id == FIXED_PARTITION_ID(slot5_partition)) { +#if PARTITION_EXISTS(slot5_partition) + } else if (area_id == PARTITION_ID(slot5_partition)) { image = IMAGE_INDEX_2; #endif -#if FIXED_PARTITION_EXISTS(slot7_partition) - } else if (area_id == FIXED_PARTITION_ID(slot7_partition)) { +#if PARTITION_EXISTS(slot7_partition) + } else if (area_id == PARTITION_ID(slot7_partition)) { image = IMAGE_INDEX_3; #endif -#if FIXED_PARTITION_EXISTS(slot9_partition) - } else if (area_id == FIXED_PARTITION_ID(slot9_partition)) { +#if PARTITION_EXISTS(slot9_partition) + } else if (area_id == PARTITION_ID(slot9_partition)) { image = IMAGE_INDEX_4; #endif -#if FIXED_PARTITION_EXISTS(slot11_partition) - } else if (area_id == FIXED_PARTITION_ID(slot11_partition)) { +#if PARTITION_EXISTS(slot11_partition) + } else if (area_id == PARTITION_ID(slot11_partition)) { image = IMAGE_INDEX_5; #endif -#if FIXED_PARTITION_EXISTS(slot13_partition) - } else if (area_id == FIXED_PARTITION_ID(slot13_partition)) { +#if PARTITION_EXISTS(slot13_partition) + } else if (area_id == PARTITION_ID(slot13_partition)) { image = IMAGE_INDEX_6; #endif -#if FIXED_PARTITION_EXISTS(slot15_partition) - } else if (area_id == FIXED_PARTITION_ID(slot15_partition)) { +#if PARTITION_EXISTS(slot15_partition) + } else if (area_id == PARTITION_ID(slot15_partition)) { image = IMAGE_INDEX_7; #endif diff --git a/subsys/dfu/boot/mcuboot_priv.h b/subsys/dfu/boot/mcuboot_priv.h index 9f33c1bc5ec8..faeec105063c 100644 --- a/subsys/dfu/boot/mcuboot_priv.h +++ b/subsys/dfu/boot/mcuboot_priv.h @@ -18,10 +18,10 @@ #define SLOT1_LABEL slot1_partition #endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE */ -/* FIXED_PARTITION_ID() values used below are auto-generated by DT */ -#define FLASH_AREA_IMAGE_PRIMARY FIXED_PARTITION_ID(SLOT0_LABEL) -#if FIXED_PARTITION_EXISTS(SLOT1_LABEL) -#define FLASH_AREA_IMAGE_SECONDARY FIXED_PARTITION_ID(SLOT1_LABEL) +/* PARTITION_ID() values used below are auto-generated by DT */ +#define FLASH_AREA_IMAGE_PRIMARY PARTITION_ID(SLOT0_LABEL) +#if PARTITION_EXISTS(SLOT1_LABEL) +#define FLASH_AREA_IMAGE_SECONDARY PARTITION_ID(SLOT1_LABEL) #endif diff --git a/subsys/dfu/boot/mcuboot_shell.c b/subsys/dfu/boot/mcuboot_shell.c index be4e558713f1..583bc4778362 100644 --- a/subsys/dfu/boot/mcuboot_shell.c +++ b/subsys/dfu/boot/mcuboot_shell.c @@ -93,15 +93,15 @@ static int cmd_mcuboot_erase(const struct shell *sh, size_t argc, id = strtoul(argv[1], NULL, 0); /* Check if this is the parent (MCUboot) or own slot and if so, deny the request */ -#if FIXED_PARTITION_EXISTS(boot_partition) - if (id == FIXED_PARTITION_ID(boot_partition)) { +#if PARTITION_EXISTS(boot_partition) + if (id == PARTITION_ID(boot_partition)) { shell_error(sh, "Cannot erase boot partition"); return -EACCES; } #endif -#if DT_FIXED_PARTITION_EXISTS(DT_CHOSEN(zephyr_code_partition)) - if (id == DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_code_partition))) { +#if DT_PARTITION_EXISTS(DT_CHOSEN(zephyr_code_partition)) + if (id == DT_PARTITION_ID(DT_CHOSEN(zephyr_code_partition))) { shell_error(sh, "Cannot erase active partitions"); return -EACCES; } diff --git a/subsys/dfu/img_util/flash_img.c b/subsys/dfu/img_util/flash_img.c index 48a0897e8cf8..b28ff6872f1e 100644 --- a/subsys/dfu/img_util/flash_img.c +++ b/subsys/dfu/img_util/flash_img.c @@ -24,22 +24,22 @@ LOG_MODULE_REGISTER(flash_img, CONFIG_IMG_MANAGER_LOG_LEVEL); #endif #if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) -#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \ +#define PARTITION_IS_RUNNING_APP_PARTITION(label) \ DT_SAME_NODE(DT_CHOSEN(zephyr_code_partition), DT_NODELABEL(label)) #else -#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \ - DT_SAME_NODE(FIXED_PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)), \ - FIXED_PARTITION_MTD(label)) && (FIXED_PARTITION_ADDRESS(label) <= \ +#define PARTITION_IS_RUNNING_APP_PARTITION(label) \ + DT_SAME_NODE(PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)), \ + PARTITION_MTD(label)) && (PARTITION_ADDRESS(label) <= \ (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) && \ - FIXED_PARTITION_ADDRESS(label) + FIXED_PARTITION_SIZE(label) > \ + PARTITION_ADDRESS(label) + PARTITION_SIZE(label) > \ (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET)) #endif #if defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) && (CONFIG_TFM_MCUBOOT_IMAGE_NUMBER == 2) #define UPLOAD_FLASH_AREA_LABEL slot1_ns_partition #else -#if FIXED_PARTITION_EXISTS(slot1_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition) +#if PARTITION_EXISTS(slot1_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition) #define UPLOAD_FLASH_AREA_LABEL slot1_partition #else #define UPLOAD_FLASH_AREA_LABEL slot0_partition @@ -50,8 +50,8 @@ LOG_MODULE_REGISTER(flash_img, CONFIG_IMG_MANAGER_LOG_LEVEL); /* For RAM LOAD mode, the active image must be fetched from the bootloader */ #define UPLOAD_FLASH_AREA_ID flash_img_get_upload_slot() #else -/* FIXED_PARTITION_ID() values used below are auto-generated by DT */ -#define UPLOAD_FLASH_AREA_ID FIXED_PARTITION_ID(UPLOAD_FLASH_AREA_LABEL) +/* PARTITION_ID() values used below are auto-generated by DT */ +#define UPLOAD_FLASH_AREA_ID PARTITION_ID(UPLOAD_FLASH_AREA_LABEL) #endif /* CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD */ #define UPLOAD_FLASH_AREA_CONTROLLER \ DT_GPARENT(DT_NODELABEL(UPLOAD_FLASH_AREA_LABEL)) @@ -267,10 +267,10 @@ uint8_t flash_img_get_upload_slot(void) slot = boot_fetch_active_slot(); - if (slot == FIXED_PARTITION_ID(slot0_partition)) { - return FIXED_PARTITION_ID(slot1_partition); + if (slot == PARTITION_ID(slot0_partition)) { + return PARTITION_ID(slot1_partition); } - return FIXED_PARTITION_ID(slot0_partition); + return PARTITION_ID(slot0_partition); } #else /* CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD */ uint8_t flash_img_get_upload_slot(void) diff --git a/subsys/fs/littlefs_fs.c b/subsys/fs/littlefs_fs.c index bf60649e9b95..7abe4dea9295 100644 --- a/subsys/fs/littlefs_fs.c +++ b/subsys/fs/littlefs_fs.c @@ -1133,7 +1133,7 @@ struct fs_mount_t FS_FSTAB_ENTRY(DT_DRV_INST(inst)) = { \ .type = FS_LITTLEFS, \ .mnt_point = FSTAB_ENTRY_DT_INST_MOUNT_POINT(inst), \ .fs_data = &fs_data_##inst, \ - .storage_dev = (void *)DT_FIXED_PARTITION_ID(FS_PARTITION(inst)), \ + .storage_dev = (void *)DT_PARTITION_ID(FS_PARTITION(inst)), \ .flags = FSTAB_ENTRY_DT_MOUNT_FLAGS(DT_DRV_INST(inst)), \ }; diff --git a/subsys/fs/shell.c b/subsys/fs/shell.c index ebd33c2b7219..a93aabf0f926 100644 --- a/subsys/fs/shell.c +++ b/subsys/fs/shell.c @@ -63,11 +63,11 @@ static struct fs_mount_t littlefs_mnt = { #define STORAGE_PARTIION_NODE_ID DT_PHANDLE(DT_INST(0, zephyr_fstab_littlefs), partition) -#if DT_FIXED_PARTITION_EXISTS(STORAGE_PARTIION_NODE_ID) -#define STORAGE_PARTITION_ID DT_FIXED_PARTITION_ID(STORAGE_PARTIION_NODE_ID) +#if DT_PARTITION_EXISTS(STORAGE_PARTIION_NODE_ID) +#define STORAGE_PARTITION_ID DT_PARTITION_ID(STORAGE_PARTIION_NODE_ID) #else #define STORAGE_PARTITION storage_partition -#define STORAGE_PARTITION_ID FIXED_PARTITION_ID(STORAGE_PARTITION) +#define STORAGE_PARTITION_ID PARTITION_ID(STORAGE_PARTITION) #endif FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(lfs_data); diff --git a/subsys/lorawan/services/frag_flash.c b/subsys/lorawan/services/frag_flash.c index 71ea4adb9052..4e77f29dd4cb 100644 --- a/subsys/lorawan/services/frag_flash.c +++ b/subsys/lorawan/services/frag_flash.c @@ -15,7 +15,7 @@ LOG_MODULE_REGISTER(lorawan_frag_flash, CONFIG_LORAWAN_SERVICES_LOG_LEVEL); -#define TARGET_IMAGE_AREA FIXED_PARTITION_ID(slot1_partition) +#define TARGET_IMAGE_AREA PARTITION_ID(slot1_partition) struct frag_cache_entry { uint32_t addr; diff --git a/subsys/mgmt/hawkbit/hawkbit.c b/subsys/mgmt/hawkbit/hawkbit.c index c6493d95e463..028333bd925f 100644 --- a/subsys/mgmt/hawkbit/hawkbit.c +++ b/subsys/mgmt/hawkbit/hawkbit.c @@ -52,7 +52,7 @@ LOG_MODULE_REGISTER(hawkbit, CONFIG_HAWKBIT_LOG_LEVEL); #define HTTP_HEADER_CONTENT_TYPE_JSON "application/json;charset=UTF-8" #define SLOT1_LABEL slot1_partition -#define SLOT1_SIZE FIXED_PARTITION_SIZE(SLOT1_LABEL) +#define SLOT1_SIZE PARTITION_SIZE(SLOT1_LABEL) static uint32_t poll_sleep = (CONFIG_HAWKBIT_POLL_INTERVAL * SEC_PER_MIN); diff --git a/subsys/mgmt/hawkbit/hawkbit_firmware.c b/subsys/mgmt/hawkbit/hawkbit_firmware.c index f070fa65ea53..81ab00389ed5 100644 --- a/subsys/mgmt/hawkbit/hawkbit_firmware.c +++ b/subsys/mgmt/hawkbit/hawkbit_firmware.c @@ -12,7 +12,7 @@ bool hawkbit_get_firmware_version(char *version, int version_len) { struct mcuboot_img_header header; - if (boot_read_bank_header(FIXED_PARTITION_ID(slot0_partition), &header, + if (boot_read_bank_header(PARTITION_ID(slot0_partition), &header, sizeof(header)) != 0) { return false; } diff --git a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c index 8de109718ada..410c5a2c61c0 100644 --- a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c +++ b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c @@ -44,7 +44,7 @@ #if !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD) #if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) -#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \ +#define PARTITION_IS_RUNNING_APP_PARTITION(label) \ DT_SAME_NODE(DT_CHOSEN(zephyr_code_partition), DT_NODELABEL(label)) #else #ifndef CONFIG_FLASH_LOAD_OFFSET @@ -52,11 +52,11 @@ to be able to figure out application running slot. #endif -#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \ - DT_SAME_NODE(FIXED_PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)), \ - FIXED_PARTITION_MTD(label)) && (FIXED_PARTITION_ADDRESS(label) <= \ +#define PARTITION_IS_RUNNING_APP_PARTITION(label) \ + DT_SAME_NODE(PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)), \ + PARTITION_MTD(label)) && (PARTITION_ADDRESS(label) <= \ (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) && \ - FIXED_PARTITION_ADDRESS(label) + FIXED_PARTITION_SIZE(label) > \ + PARTITION_ADDRESS(label) + PARTITION_SIZE(label) > \ (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET)) #endif @@ -64,56 +64,56 @@ BUILD_ASSERT(sizeof(struct image_header) == IMAGE_HEADER_SIZE, "struct image_header not required size"); #if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER >= 2 -#if FIXED_PARTITION_EXISTS(slot0_ns_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot0_ns_partition) +#if PARTITION_EXISTS(slot0_ns_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot0_ns_partition) #define ACTIVE_IMAGE_IS 0 -#elif FIXED_PARTITION_EXISTS(slot0_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition) +#elif PARTITION_EXISTS(slot0_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition) #define ACTIVE_IMAGE_IS 0 -#elif FIXED_PARTITION_EXISTS(slot1_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot1_partition) +#elif PARTITION_EXISTS(slot1_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot1_partition) #define ACTIVE_IMAGE_IS 0 -#elif FIXED_PARTITION_EXISTS(slot2_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot2_partition) +#elif PARTITION_EXISTS(slot2_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot2_partition) #define ACTIVE_IMAGE_IS 1 -#elif FIXED_PARTITION_EXISTS(slot3_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot3_partition) +#elif PARTITION_EXISTS(slot3_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot3_partition) #define ACTIVE_IMAGE_IS 1 -#elif FIXED_PARTITION_EXISTS(slot4_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot4_partition) +#elif PARTITION_EXISTS(slot4_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot4_partition) #define ACTIVE_IMAGE_IS 2 -#elif FIXED_PARTITION_EXISTS(slot5_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot5_partition) +#elif PARTITION_EXISTS(slot5_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot5_partition) #define ACTIVE_IMAGE_IS 2 -#elif FIXED_PARTITION_EXISTS(slot6_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot6_partition) +#elif PARTITION_EXISTS(slot6_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot6_partition) #define ACTIVE_IMAGE_IS 3 -#elif FIXED_PARTITION_EXISTS(slot7_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot7_partition) +#elif PARTITION_EXISTS(slot7_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot7_partition) #define ACTIVE_IMAGE_IS 3 -#elif FIXED_PARTITION_EXISTS(slot8_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot8_partition) +#elif PARTITION_EXISTS(slot8_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot8_partition) #define ACTIVE_IMAGE_IS 4 -#elif FIXED_PARTITION_EXISTS(slot9_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot9_partition) +#elif PARTITION_EXISTS(slot9_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot9_partition) #define ACTIVE_IMAGE_IS 4 -#elif FIXED_PARTITION_EXISTS(slot10_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot10_partition) +#elif PARTITION_EXISTS(slot10_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot10_partition) #define ACTIVE_IMAGE_IS 5 -#elif FIXED_PARTITION_EXISTS(slot11_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot11_partition) +#elif PARTITION_EXISTS(slot11_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot11_partition) #define ACTIVE_IMAGE_IS 5 -#elif FIXED_PARTITION_EXISTS(slot12_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot12_partition) +#elif PARTITION_EXISTS(slot12_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot12_partition) #define ACTIVE_IMAGE_IS 6 -#elif FIXED_PARTITION_EXISTS(slot13_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot13_partition) +#elif PARTITION_EXISTS(slot13_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot13_partition) #define ACTIVE_IMAGE_IS 6 -#elif FIXED_PARTITION_EXISTS(slot14_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot14_partition) +#elif PARTITION_EXISTS(slot14_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot14_partition) #define ACTIVE_IMAGE_IS 7 -#elif FIXED_PARTITION_EXISTS(slot15_partition) && \ - FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot15_partition) +#elif PARTITION_EXISTS(slot15_partition) && \ + PARTITION_IS_RUNNING_APP_PARTITION(slot15_partition) #define ACTIVE_IMAGE_IS 7 #else #define ACTIVE_IMAGE_IS 0 @@ -256,7 +256,7 @@ int img_mgmt_active_slot(int image) slot = (int)temp_slot; #else /* This covers single image, including DirectXiP */ - if (FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot1_partition)) { + if (PARTITION_IS_RUNNING_APP_PARTITION(slot1_partition)) { slot = 1; } #endif diff --git a/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c b/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c index 39c3e06f65f4..e3a323b0b1b5 100644 --- a/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c +++ b/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c @@ -50,44 +50,44 @@ LOG_MODULE_DECLARE(mcumgr_img_grp, CONFIG_MCUMGR_GRP_IMG_LOG_LEVEL); * properly. */ #if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER >= 2 -BUILD_ASSERT(FIXED_PARTITION_EXISTS(SLOT2_PARTITION) && - FIXED_PARTITION_EXISTS(SLOT3_PARTITION), +BUILD_ASSERT(PARTITION_EXISTS(SLOT2_PARTITION) && + PARTITION_EXISTS(SLOT3_PARTITION), "Missing partitions?"); #endif #if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER >= 3 -BUILD_ASSERT(FIXED_PARTITION_EXISTS(SLOT4_PARTITION) && - FIXED_PARTITION_EXISTS(SLOT5_PARTITION), +BUILD_ASSERT(PARTITION_EXISTS(SLOT4_PARTITION) && + PARTITION_EXISTS(SLOT5_PARTITION), "Missing partitions?"); #endif #if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER >= 4 -BUILD_ASSERT(FIXED_PARTITION_EXISTS(SLOT6_PARTITION) && - FIXED_PARTITION_EXISTS(SLOT7_PARTITION), +BUILD_ASSERT(PARTITION_EXISTS(SLOT6_PARTITION) && + PARTITION_EXISTS(SLOT7_PARTITION), "Missing partitions?"); #endif #if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER >= 5 -BUILD_ASSERT(FIXED_PARTITION_EXISTS(SLOT8_PARTITION) && - FIXED_PARTITION_EXISTS(SLOT9_PARTITION), +BUILD_ASSERT(PARTITION_EXISTS(SLOT8_PARTITION) && + PARTITION_EXISTS(SLOT9_PARTITION), "Missing partitions?"); #endif #if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER >= 6 -BUILD_ASSERT(FIXED_PARTITION_EXISTS(SLOT10_PARTITION) && - FIXED_PARTITION_EXISTS(SLOT11_PARTITION), +BUILD_ASSERT(PARTITION_EXISTS(SLOT10_PARTITION) && + PARTITION_EXISTS(SLOT11_PARTITION), "Missing partitions?"); #endif #if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER >= 7 -BUILD_ASSERT(FIXED_PARTITION_EXISTS(SLOT12_PARTITION) && - FIXED_PARTITION_EXISTS(SLOT13_PARTITION), +BUILD_ASSERT(PARTITION_EXISTS(SLOT12_PARTITION) && + PARTITION_EXISTS(SLOT13_PARTITION), "Missing partitions?"); #endif #if CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER >= 8 -BUILD_ASSERT(FIXED_PARTITION_EXISTS(SLOT14_PARTITION) && - FIXED_PARTITION_EXISTS(SLOT15_PARTITION), +BUILD_ASSERT(PARTITION_EXISTS(SLOT14_PARTITION) && + PARTITION_EXISTS(SLOT15_PARTITION), "Missing partitions?"); #endif @@ -177,95 +177,95 @@ img_mgmt_flash_area_id(int slot) switch (slot) { case 0: - fa_id = FIXED_PARTITION_ID(SLOT0_PARTITION); + fa_id = PARTITION_ID(SLOT0_PARTITION); break; case 1: - fa_id = FIXED_PARTITION_ID(SLOT1_PARTITION); + fa_id = PARTITION_ID(SLOT1_PARTITION); break; #if !defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_FIRMWARE_UPDATER) -#if FIXED_PARTITION_EXISTS(SLOT2_PARTITION) +#if PARTITION_EXISTS(SLOT2_PARTITION) case 2: - fa_id = FIXED_PARTITION_ID(SLOT2_PARTITION); + fa_id = PARTITION_ID(SLOT2_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT3_PARTITION) +#if PARTITION_EXISTS(SLOT3_PARTITION) case 3: - fa_id = FIXED_PARTITION_ID(SLOT3_PARTITION); + fa_id = PARTITION_ID(SLOT3_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT4_PARTITION) +#if PARTITION_EXISTS(SLOT4_PARTITION) case 4: - fa_id = FIXED_PARTITION_ID(SLOT4_PARTITION); + fa_id = PARTITION_ID(SLOT4_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT5_PARTITION) +#if PARTITION_EXISTS(SLOT5_PARTITION) case 5: - fa_id = FIXED_PARTITION_ID(SLOT5_PARTITION); + fa_id = PARTITION_ID(SLOT5_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT6_PARTITION) +#if PARTITION_EXISTS(SLOT6_PARTITION) case 6: - fa_id = FIXED_PARTITION_ID(SLOT6_PARTITION); + fa_id = PARTITION_ID(SLOT6_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT7_PARTITION) +#if PARTITION_EXISTS(SLOT7_PARTITION) case 7: - fa_id = FIXED_PARTITION_ID(SLOT7_PARTITION); + fa_id = PARTITION_ID(SLOT7_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT8_PARTITION) +#if PARTITION_EXISTS(SLOT8_PARTITION) case 8: - fa_id = FIXED_PARTITION_ID(SLOT8_PARTITION); + fa_id = PARTITION_ID(SLOT8_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT9_PARTITION) +#if PARTITION_EXISTS(SLOT9_PARTITION) case 9: - fa_id = FIXED_PARTITION_ID(SLOT9_PARTITION); + fa_id = PARTITION_ID(SLOT9_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT10_PARTITION) +#if PARTITION_EXISTS(SLOT10_PARTITION) case 10: - fa_id = FIXED_PARTITION_ID(SLOT10_PARTITION); + fa_id = PARTITION_ID(SLOT10_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT11_PARTITION) +#if PARTITION_EXISTS(SLOT11_PARTITION) case 11: - fa_id = FIXED_PARTITION_ID(SLOT11_PARTITION); + fa_id = PARTITION_ID(SLOT11_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT12_PARTITION) +#if PARTITION_EXISTS(SLOT12_PARTITION) case 12: - fa_id = FIXED_PARTITION_ID(SLOT12_PARTITION); + fa_id = PARTITION_ID(SLOT12_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT13_PARTITION) +#if PARTITION_EXISTS(SLOT13_PARTITION) case 13: - fa_id = FIXED_PARTITION_ID(SLOT13_PARTITION); + fa_id = PARTITION_ID(SLOT13_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT14_PARTITION) +#if PARTITION_EXISTS(SLOT14_PARTITION) case 14: - fa_id = FIXED_PARTITION_ID(SLOT14_PARTITION); + fa_id = PARTITION_ID(SLOT14_PARTITION); break; #endif -#if FIXED_PARTITION_EXISTS(SLOT15_PARTITION) +#if PARTITION_EXISTS(SLOT15_PARTITION) case 15: - fa_id = FIXED_PARTITION_ID(SLOT15_PARTITION); + fa_id = PARTITION_ID(SLOT15_PARTITION); break; #endif diff --git a/subsys/mgmt/mcumgr/grp/zephyr_basic/src/basic_mgmt.c b/subsys/mgmt/mcumgr/grp/zephyr_basic/src/basic_mgmt.c index 9e9c17252e01..beacf91e3d7a 100644 --- a/subsys/mgmt/mcumgr/grp/zephyr_basic/src/basic_mgmt.c +++ b/subsys/mgmt/mcumgr/grp/zephyr_basic/src/basic_mgmt.c @@ -16,7 +16,7 @@ LOG_MODULE_REGISTER(mcumgr_zbasic_grp, CONFIG_MCUMGR_GRP_ZBASIC_LOG_LEVEL); #define ERASE_TARGET storage_partition -#define ERASE_TARGET_ID FIXED_PARTITION_ID(ERASE_TARGET) +#define ERASE_TARGET_ID PARTITION_ID(ERASE_TARGET) static int storage_erase(void) { diff --git a/subsys/mgmt/updatehub/updatehub_storage.h b/subsys/mgmt/updatehub/updatehub_storage.h index 081ad86d46b9..a158645a7670 100644 --- a/subsys/mgmt/updatehub/updatehub_storage.h +++ b/subsys/mgmt/updatehub/updatehub_storage.h @@ -13,8 +13,8 @@ extern "C" { #include #include -#define UPDATEHUB_SLOT_PARTITION_0 FIXED_PARTITION_ID(slot0_partition) -#define UPDATEHUB_SLOT_PARTITION_1 FIXED_PARTITION_ID(slot1_partition) +#define UPDATEHUB_SLOT_PARTITION_0 PARTITION_ID(slot0_partition) +#define UPDATEHUB_SLOT_PARTITION_1 PARTITION_ID(slot1_partition) struct updatehub_storage_context { struct flash_img_context flash_ctx; diff --git a/subsys/secure_storage/src/its/store/zms.c b/subsys/secure_storage/src/its/store/zms.c index 4778e0365e91..2e48444215f5 100644 --- a/subsys/secure_storage/src/its/store/zms.c +++ b/subsys/secure_storage/src/its/store/zms.c @@ -14,8 +14,8 @@ BUILD_ASSERT(CONFIG_SECURE_STORAGE_ITS_STORE_ZMS_SECTOR_SIZE #define PARTITION_DT_NODE DT_CHOSEN(secure_storage_its_partition) static struct zms_fs s_zms = { - .flash_device = FIXED_PARTITION_NODE_DEVICE(PARTITION_DT_NODE), - .offset = FIXED_PARTITION_NODE_OFFSET(PARTITION_DT_NODE), + .flash_device = PARTITION_NODE_DEVICE(PARTITION_DT_NODE), + .offset = PARTITION_NODE_OFFSET(PARTITION_DT_NODE), .sector_size = CONFIG_SECURE_STORAGE_ITS_STORE_ZMS_SECTOR_SIZE, }; @@ -23,7 +23,7 @@ static int init_zms(void) { int ret; - s_zms.sector_count = FIXED_PARTITION_NODE_SIZE(PARTITION_DT_NODE) / s_zms.sector_size; + s_zms.sector_count = PARTITION_NODE_SIZE(PARTITION_DT_NODE) / s_zms.sector_size; ret = zms_mount(&s_zms); if (ret) { diff --git a/subsys/settings/src/settings_fcb.c b/subsys/settings/src/settings_fcb.c index f58e4e3700b3..3c8e6ef31a20 100644 --- a/subsys/settings/src/settings_fcb.c +++ b/subsys/settings/src/settings_fcb.c @@ -18,9 +18,9 @@ LOG_MODULE_DECLARE(settings, CONFIG_SETTINGS_LOG_LEVEL); #if DT_HAS_CHOSEN(zephyr_settings_partition) -#define SETTINGS_PARTITION DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition)) +#define SETTINGS_PARTITION DT_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition)) #else -#define SETTINGS_PARTITION FIXED_PARTITION_ID(storage_partition) +#define SETTINGS_PARTITION PARTITION_ID(storage_partition) #endif #define SETTINGS_FCB_VERS 1 diff --git a/subsys/settings/src/settings_nvs.c b/subsys/settings/src/settings_nvs.c index 6764c7587a3b..a6539984d2f8 100644 --- a/subsys/settings/src/settings_nvs.c +++ b/subsys/settings/src/settings_nvs.c @@ -18,9 +18,9 @@ LOG_MODULE_DECLARE(settings, CONFIG_SETTINGS_LOG_LEVEL); #if DT_HAS_CHOSEN(zephyr_settings_partition) -#define SETTINGS_PARTITION DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition)) +#define SETTINGS_PARTITION DT_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition)) #else -#define SETTINGS_PARTITION FIXED_PARTITION_ID(storage_partition) +#define SETTINGS_PARTITION PARTITION_ID(storage_partition) #endif struct settings_nvs_read_fn_arg { diff --git a/subsys/settings/src/settings_zms.c b/subsys/settings/src/settings_zms.c index 485c2a68b086..b2ea12c42520 100644 --- a/subsys/settings/src/settings_zms.c +++ b/subsys/settings/src/settings_zms.c @@ -19,9 +19,9 @@ LOG_MODULE_DECLARE(settings, CONFIG_SETTINGS_LOG_LEVEL); #if DT_HAS_CHOSEN(zephyr_settings_partition) -#define SETTINGS_PARTITION DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition)) +#define SETTINGS_PARTITION DT_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition)) #else -#define SETTINGS_PARTITION FIXED_PARTITION_ID(storage_partition) +#define SETTINGS_PARTITION PARTITION_ID(storage_partition) #endif struct settings_zms_read_fn_arg { diff --git a/subsys/storage/flash_map/flash_map_default.c b/subsys/storage/flash_map/flash_map_default.c index 94069fb00653..3dbdc0367bce 100644 --- a/subsys/storage/flash_map/flash_map_default.c +++ b/subsys/storage/flash_map/flash_map_default.c @@ -13,11 +13,11 @@ #include #if CONFIG_FLASH_MAP_LABELS -#define FLASH_AREA_FOO(part, mtd_from_partition) \ - {.fa_id = DT_FIXED_PARTITION_ID(part), \ - .fa_off = FIXED_PARTITION_NODE_OFFSET(part), \ - .fa_dev = DEVICE_DT_GET(mtd_from_partition(part)), \ - .fa_size = DT_REG_SIZE(part), \ +#define FLASH_AREA_FOO(part, mtd_from_partition) \ + {.fa_id = DT_PARTITION_ID(part), \ + .fa_off = PARTITION_NODE_OFFSET(part), \ + .fa_dev = DEVICE_DT_GET(mtd_from_partition(part)), \ + .fa_size = DT_REG_SIZE(part), \ .fa_label = DT_PROP_OR(part, label, NULL), }, #define MAPPED_AREA(part) \ @@ -27,10 +27,10 @@ .fa_size = DT_REG_SIZE(part), \ .fa_label = DT_PROP_OR(part, label, NULL), }, #else -#define FLASH_AREA_FOO(part, mtd_from_partition) \ - {.fa_id = DT_FIXED_PARTITION_ID(part), \ - .fa_off = FIXED_PARTITION_NODE_OFFSET(part), \ - .fa_dev = DEVICE_DT_GET(mtd_from_partition(part)), \ +#define FLASH_AREA_FOO(part, mtd_from_partition) \ + {.fa_id = DT_PARTITION_ID(part), \ + .fa_off = PARTITION_NODE_OFFSET(part), \ + .fa_dev = DEVICE_DT_GET(mtd_from_partition(part)), \ .fa_size = DT_REG_SIZE(part), }, #define MAPPED_AREA(part) \ @@ -42,8 +42,8 @@ #define FLASH_AREA_FOOO(part) \ COND_CODE_1(DT_NODE_HAS_COMPAT(DT_PARENT(part), fixed_partitions), ( \ - COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_FIXED_PARTITION(part)), \ - (FLASH_AREA_FOO(part, DT_MTD_FROM_FIXED_PARTITION)), ())), ( \ + COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_PARTITION(part)), \ + (FLASH_AREA_FOO(part, DT_MTD_FROM_PARTITION)), ())), ( \ COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_FIXED_SUBPARTITION(part)), \ (FLASH_AREA_FOO(part, DT_MTD_FROM_FIXED_SUBPARTITION)), ()))) @@ -71,15 +71,15 @@ const struct flash_area *flash_map = default_flash_map; * objects referenced by code will be included into build. */ #define DEFINE_PARTITION(part) DEFINE_PARTITION_1(part, DT_DEP_ORD(part)) -#define DEFINE_PARTITION_1(part, ord) \ - COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_MAPPED_PARTITION(part)), \ +#define DEFINE_PARTITION_1(part, ord) \ + COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_PARTITION(part)), \ (DEFINE_PARTITION_0(part, ord)), ()) -#define DEFINE_PARTITION_0(part, ord) \ - const struct flash_area DT_CAT(global_zephyr_mapped_partition_ORD_, ord) = { \ - .fa_id = DT_MAPPED_PARTITION_ID(part), \ - .fa_off = MAPPED_PARTITION_NODE_OFFSET(part), \ - .fa_dev = DEVICE_DT_GET(DT_MTD_FROM_MAPPED_PARTITION(part)), \ - .fa_size = DT_REG_SIZE(part), \ +#define DEFINE_PARTITION_0(part, ord) \ + const struct flash_area DT_CAT(global_zephyr_mapped_partition_ORD_, ord) = { \ + .fa_id = DT_PARTITION_ID(part), \ + .fa_off = PARTITION_NODE_OFFSET(part), \ + .fa_dev = DEVICE_DT_GET(DT_MTD_FROM_PARTITION(part)), \ + .fa_size = DT_REG_SIZE(part), \ }; DT_FOREACH_STATUS_OKAY(zephyr_mapped_partition, DEFINE_PARTITION) @@ -89,30 +89,30 @@ DT_FOREACH_STATUS_OKAY(zephyr_mapped_partition, DEFINE_PARTITION) #undef DEFINE_PARTITION_0 #define DEFINE_PARTITION(part) DEFINE_PARTITION_1(part, DT_DEP_ORD(part)) -#define DEFINE_PARTITION_1(part, ord) \ - COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_FIXED_PARTITION(part)), \ +#define DEFINE_PARTITION_1(part, ord) \ + COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_PARTITION(part)), \ (DEFINE_PARTITION_0(part, ord)), ()) -#define DEFINE_PARTITION_0(part, ord) \ - const struct flash_area DT_CAT(global_fixed_partition_ORD_, ord) = { \ - .fa_id = DT_FIXED_PARTITION_ID(part), \ - .fa_off = FIXED_PARTITION_NODE_OFFSET(part), \ - .fa_dev = DEVICE_DT_GET(DT_MTD_FROM_FIXED_PARTITION(part)), \ - .fa_size = DT_REG_SIZE(part), \ +#define DEFINE_PARTITION_0(part, ord) \ + const struct flash_area DT_CAT(global_fixed_partition_ORD_, ord) = { \ + .fa_id = DT_FIXED_PARTITION_ID(part), \ + .fa_off = PARTITION_NODE_OFFSET(part), \ + .fa_dev = DEVICE_DT_GET(DT_MTD_FROM_PARTITION(part)), \ + .fa_size = DT_REG_SIZE(part), \ }; #define FOR_EACH_PARTITION_TABLE(table) DT_FOREACH_CHILD(table, DEFINE_PARTITION) DT_FOREACH_STATUS_OKAY(fixed_partitions, FOR_EACH_PARTITION_TABLE) #define DEFINE_SUBPARTITION(part) DEFINE_SUBPARTITION_1(part, DT_DEP_ORD(part)) -#define DEFINE_SUBPARTITION_1(part, ord) \ - COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_FIXED_SUBPARTITION(part)), \ +#define DEFINE_SUBPARTITION_1(part, ord) \ + COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_MTD_FROM_FIXED_SUBPARTITION(part)), \ (DEFINE_SUBPARTITION_0(part, ord)), ()) -#define DEFINE_SUBPARTITION_0(part, ord) \ - const struct flash_area DT_CAT(global_fixed_subpartition_ORD_, ord) = { \ - .fa_id = DT_FIXED_PARTITION_ID(part), \ - .fa_off = FIXED_PARTITION_NODE_OFFSET(part), \ - .fa_dev = DEVICE_DT_GET(DT_MTD_FROM_FIXED_SUBPARTITION(part)), \ - .fa_size = DT_REG_SIZE(part), \ +#define DEFINE_SUBPARTITION_0(part, ord) \ + const struct flash_area DT_CAT(global_fixed_subpartition_ORD_, ord) = { \ + .fa_id = DT_PARTITION_ID(part), \ + .fa_off = PARTITION_NODE_OFFSET(part), \ + .fa_dev = DEVICE_DT_GET(DT_MTD_FROM_FIXED_SUBPARTITION(part)), \ + .fa_size = DT_REG_SIZE(part), \ }; #define FOR_EACH_SUBPARTITION_TABLE(table) DT_FOREACH_CHILD(table, DEFINE_SUBPARTITION) diff --git a/subsys/usb/device/class/dfu/usb_dfu.c b/subsys/usb/device/class/dfu/usb_dfu.c index 3961e78531dc..e7c40abd4bd0 100644 --- a/subsys/usb/device/class/dfu/usb_dfu.c +++ b/subsys/usb/device/class/dfu/usb_dfu.c @@ -141,7 +141,7 @@ struct dev_dfu_mode_descriptor { struct usb_cfg_descriptor cfg_descr; struct usb_sec_dfu_config { struct usb_if_descriptor if0; -#if FIXED_PARTITION_EXISTS(SLOT1_PARTITION) +#if PARTITION_EXISTS(SLOT1_PARTITION) struct usb_if_descriptor if1; #endif struct dfu_runtime_descriptor dfu_descr; @@ -197,7 +197,7 @@ struct dev_dfu_mode_descriptor dfu_mode_desc = { .bInterfaceProtocol = DFU_MODE_PROTOCOL, .iInterface = 4, }, -#if FIXED_PARTITION_EXISTS(SLOT1_PARTITION) +#if PARTITION_EXISTS(SLOT1_PARTITION) .if1 = { .bLength = sizeof(struct usb_if_descriptor), .bDescriptorType = USB_DESC_INTERFACE, @@ -251,7 +251,7 @@ struct usb_string_desription { uint8_t bString[USB_BSTRING_LENGTH(FIRMWARE_IMAGE_0_LABEL)]; } __packed utf16le_image0; -#if FIXED_PARTITION_EXISTS(SLOT1_PARTITION) +#if PARTITION_EXISTS(SLOT1_PARTITION) struct image_1_descriptor { uint8_t bLength; uint8_t bDescriptorType; @@ -294,7 +294,7 @@ struct usb_string_desription string_descr = { .bDescriptorType = USB_DESC_STRING, .bString = FIRMWARE_IMAGE_0_LABEL, }, -#if FIXED_PARTITION_EXISTS(SLOT1_PARTITION) +#if PARTITION_EXISTS(SLOT1_PARTITION) /* Image 1 String Descriptor */ .utf16le_image1 = { .bLength = USB_STRING_DESCRIPTOR_LENGTH( @@ -327,10 +327,10 @@ struct dfu_data_t { uint16_t bwPollTimeout; }; -#if FIXED_PARTITION_EXISTS(SLOT1_PARTITION) - #define DOWNLOAD_FLASH_AREA_ID FIXED_PARTITION_ID(SLOT1_PARTITION) +#if PARTITION_EXISTS(SLOT1_PARTITION) + #define DOWNLOAD_FLASH_AREA_ID PARTITION_ID(SLOT1_PARTITION) #else - #define DOWNLOAD_FLASH_AREA_ID FIXED_PARTITION_ID(SLOT0_PARTITION) + #define DOWNLOAD_FLASH_AREA_ID PARTITION_ID(SLOT0_PARTITION) #endif @@ -813,9 +813,9 @@ static int dfu_custom_handle_req(struct usb_setup_packet *setup, switch (setup->wValue) { case 0: dfu_data.flash_area_id = - FIXED_PARTITION_ID(SLOT0_PARTITION); + PARTITION_ID(SLOT0_PARTITION); break; -#if FIXED_PARTITION_EXISTS(SLOT1_PARTITION) +#if PARTITION_EXISTS(SLOT1_PARTITION) case 1: dfu_data.flash_area_id = DOWNLOAD_FLASH_AREA_ID; break; diff --git a/subsys/usb/device_next/class/usbd_dfu_flash.c b/subsys/usb/device_next/class/usbd_dfu_flash.c index fea438bf3b26..c9130e820d15 100644 --- a/subsys/usb/device_next/class/usbd_dfu_flash.c +++ b/subsys/usb/device_next/class/usbd_dfu_flash.c @@ -136,18 +136,18 @@ static bool dfu_flash_next(void *const priv, return true; } -#if FIXED_PARTITION_EXISTS(slot0_partition) && defined(CONFIG_USBD_DFU_FLASH_SLOT0) +#if PARTITION_EXISTS(slot0_partition) && defined(CONFIG_USBD_DFU_FLASH_SLOT0) static struct usbd_dfu_flash_data slot0_data = { - .id = FIXED_PARTITION_ID(slot0_partition), + .id = PARTITION_ID(slot0_partition), }; USBD_DFU_DEFINE_IMG(slot0_image, "slot0_image", &slot0_data, dfu_flash_read, dfu_flash_write, dfu_flash_next); #endif -#if FIXED_PARTITION_EXISTS(slot1_partition) && defined(CONFIG_USBD_DFU_FLASH_SLOT1) +#if PARTITION_EXISTS(slot1_partition) && defined(CONFIG_USBD_DFU_FLASH_SLOT1) static struct usbd_dfu_flash_data slot1_data = { - .id = FIXED_PARTITION_ID(slot1_partition), + .id = PARTITION_ID(slot1_partition), }; USBD_DFU_DEFINE_IMG(slot1_image, "slot1_image", &slot1_data, diff --git a/tests/bluetooth/mesh/blob_io_flash/src/main.c b/tests/bluetooth/mesh/blob_io_flash/src/main.c index aa04ae2dd9dd..36b1afbe977b 100644 --- a/tests/bluetooth/mesh/blob_io_flash/src/main.c +++ b/tests/bluetooth/mesh/blob_io_flash/src/main.c @@ -11,8 +11,8 @@ #include "mesh/blob.h" #define SLOT1_PARTITION slot1_partition -#define SLOT1_PARTITION_ID FIXED_PARTITION_ID(SLOT1_PARTITION) -#define SLOT1_PARTITION_SIZE FIXED_PARTITION_SIZE(SLOT1_PARTITION) +#define SLOT1_PARTITION_ID PARTITION_ID(SLOT1_PARTITION) +#define SLOT1_PARTITION_SIZE PARTITION_SIZE(SLOT1_PARTITION) /* Chunk size is set to value that is not multiple of 4, to verify that chunks are written correctly * even if they are not aligned with word length used in flash */ diff --git a/tests/boards/nrf/rram_throttling/src/main.c b/tests/boards/nrf/rram_throttling/src/main.c index 9984f26787d0..a7cf0f028fd6 100644 --- a/tests/boards/nrf/rram_throttling/src/main.c +++ b/tests/boards/nrf/rram_throttling/src/main.c @@ -16,9 +16,9 @@ * fixed-partition nodes. */ #if defined(TEST_AREA) -#define TEST_AREA_OFFSET FIXED_PARTITION_OFFSET(TEST_AREA) -#define TEST_AREA_SIZE FIXED_PARTITION_SIZE(TEST_AREA) -#define TEST_AREA_DEVICE FIXED_PARTITION_DEVICE(TEST_AREA) +#define TEST_AREA_OFFSET PARTITION_OFFSET(TEST_AREA) +#define TEST_AREA_SIZE PARTITION_SIZE(TEST_AREA) +#define TEST_AREA_DEVICE PARTITION_DEVICE(TEST_AREA) #else #error "Unsupported configuration" #endif diff --git a/tests/drivers/flash/common/src/main.c b/tests/drivers/flash/common/src/main.c index 9c176f47d2a8..5e7b1c22e59a 100644 --- a/tests/drivers/flash/common/src/main.c +++ b/tests/drivers/flash/common/src/main.c @@ -38,10 +38,10 @@ */ #ifdef TEST_AREA -#define TEST_AREA_OFFSET FIXED_PARTITION_OFFSET(TEST_AREA) -#define TEST_AREA_SIZE FIXED_PARTITION_SIZE(TEST_AREA) +#define TEST_AREA_OFFSET PARTITION_OFFSET(TEST_AREA) +#define TEST_AREA_SIZE PARTITION_SIZE(TEST_AREA) #define TEST_AREA_MAX (TEST_AREA_OFFSET + TEST_AREA_SIZE) -#define TEST_AREA_DEVICE FIXED_PARTITION_DEVICE(TEST_AREA) +#define TEST_AREA_DEVICE PARTITION_DEVICE(TEST_AREA) #elif defined(TEST_AREA_DEV_NODE) diff --git a/tests/drivers/flash/erase_blocks/src/main.c b/tests/drivers/flash/erase_blocks/src/main.c index d44eed15e4de..2f40e769117c 100644 --- a/tests/drivers/flash/erase_blocks/src/main.c +++ b/tests/drivers/flash/erase_blocks/src/main.c @@ -27,7 +27,7 @@ LOG_MODULE_REGISTER(test_flash); #endif #define TEST_FLASH_PART_OFFSET \ - FIXED_PARTITION_NODE_OFFSET(TEST_FLASH_PART_NODE) + PARTITION_NODE_OFFSET(TEST_FLASH_PART_NODE) #define TEST_FLASH_PART_SIZE \ DT_REG_SIZE(TEST_FLASH_PART_NODE) @@ -36,7 +36,7 @@ LOG_MODULE_REGISTER(test_flash); (TEST_FLASH_PART_OFFSET + TEST_FLASH_PART_SIZE) #define TEST_FLASH_CONTROLLER_NODE \ - DT_MTD_FROM_FIXED_PARTITION(TEST_FLASH_PART_NODE) + DT_MTD_FROM_PARTITION(TEST_FLASH_PART_NODE) static const struct device *flash_controller = DEVICE_DT_GET(TEST_FLASH_CONTROLLER_NODE); static uint8_t test_write_block[512]; diff --git a/tests/drivers/flash/interface_test/src/main.c b/tests/drivers/flash/interface_test/src/main.c index 8b2627b4f787..4b37e86ca8b5 100644 --- a/tests/drivers/flash/interface_test/src/main.c +++ b/tests/drivers/flash/interface_test/src/main.c @@ -15,10 +15,10 @@ #define TEST_FLASH_PART_NODE DT_NODELABEL(slot1_partition) #endif -#define TEST_FLASH_PART_OFFSET FIXED_PARTITION_NODE_OFFSET(TEST_FLASH_PART_NODE) +#define TEST_FLASH_PART_OFFSET PARTITION_NODE_OFFSET(TEST_FLASH_PART_NODE) #define TEST_FLASH_PART_SIZE DT_REG_SIZE(TEST_FLASH_PART_NODE) -#define TEST_FLASH_CONTROLLER_NODE DT_MTD_FROM_FIXED_PARTITION(TEST_FLASH_PART_NODE) +#define TEST_FLASH_CONTROLLER_NODE DT_MTD_FROM_PARTITION(TEST_FLASH_PART_NODE) #define PATTERN_SIZE 256 diff --git a/tests/drivers/flash/negative_tests/src/main.c b/tests/drivers/flash/negative_tests/src/main.c index fa3723b52312..076f4d1e0b86 100644 --- a/tests/drivers/flash/negative_tests/src/main.c +++ b/tests/drivers/flash/negative_tests/src/main.c @@ -22,13 +22,13 @@ * fixed-partition nodes. */ #if defined(TEST_AREA) -#define TEST_AREA_OFFSET FIXED_PARTITION_OFFSET(TEST_AREA) -#define TEST_AREA_SIZE FIXED_PARTITION_SIZE(TEST_AREA) -#define TEST_AREA_DEVICE FIXED_PARTITION_DEVICE(TEST_AREA) +#define TEST_AREA_OFFSET PARTITION_OFFSET(TEST_AREA) +#define TEST_AREA_SIZE PARTITION_SIZE(TEST_AREA) +#define TEST_AREA_DEVICE PARTITION_DEVICE(TEST_AREA) #if defined(CONFIG_SOC_SERIES_NRF54L) || defined(CONFIG_SOC_FAMILY_MICROCHIP_SAM_D5X_E5X) -#define TEST_FLASH_START (DT_REG_ADDR(DT_MEM_FROM_FIXED_PARTITION(DT_NODELABEL(TEST_AREA)))) -#define TEST_FLASH_SIZE (DT_REG_SIZE(DT_MEM_FROM_FIXED_PARTITION(DT_NODELABEL(TEST_AREA)))) +#define TEST_FLASH_START (DT_REG_ADDR(DT_MEM_FROM_PARTITION(DT_NODELABEL(TEST_AREA)))) +#define TEST_FLASH_SIZE (DT_REG_SIZE(DT_MEM_FROM_PARTITION(DT_NODELABEL(TEST_AREA)))) #elif defined(CONFIG_SOC_NRF54H20) #define TEST_FLASH_START (DT_REG_ADDR(DT_PARENT(DT_PARENT(DT_NODELABEL(TEST_AREA))))) #define TEST_FLASH_SIZE (DT_REG_SIZE(DT_PARENT(DT_PARENT(DT_NODELABEL(TEST_AREA))))) diff --git a/tests/drivers/flash/stm32/src/main.c b/tests/drivers/flash/stm32/src/main.c index 4fd8de9b44dd..d23bbe3e561a 100644 --- a/tests/drivers/flash/stm32/src/main.c +++ b/tests/drivers/flash/stm32/src/main.c @@ -13,11 +13,11 @@ #include #define TEST_AREA storage_partition -#define TEST_AREA_OFFSET FIXED_PARTITION_OFFSET(TEST_AREA) -#define TEST_AREA_SIZE FIXED_PARTITION_SIZE(TEST_AREA) +#define TEST_AREA_OFFSET PARTITION_OFFSET(TEST_AREA) +#define TEST_AREA_SIZE PARTITION_SIZE(TEST_AREA) #define TEST_AREA_MAX (TEST_AREA_OFFSET + TEST_AREA_SIZE) -#define TEST_AREA_DEVICE FIXED_PARTITION_DEVICE(TEST_AREA) -#define TEST_AREA_DEVICE_REG DT_REG_ADDR(DT_MTD_FROM_FIXED_PARTITION(DT_NODELABEL(TEST_AREA))) +#define TEST_AREA_DEVICE PARTITION_DEVICE(TEST_AREA) +#define TEST_AREA_DEVICE_REG DT_REG_ADDR(DT_MTD_FROM_PARTITION(DT_NODELABEL(TEST_AREA))) #define EXPECTED_SIZE 512 diff --git a/tests/drivers/flash_simulator/flash_sim_impl/src/main.c b/tests/drivers/flash_simulator/flash_sim_impl/src/main.c index 01ecdf293d55..43ab17c7599b 100644 --- a/tests/drivers/flash_simulator/flash_sim_impl/src/main.c +++ b/tests/drivers/flash_simulator/flash_sim_impl/src/main.c @@ -19,7 +19,7 @@ #else #define SOC_NV_FLASH_NODE DT_CHILD(DT_INST(0, zephyr_sim_flash), flash_sim_0) #endif /* CONFIG_ARCH_POSIX */ -#define FLASH_SIMULATOR_BASE_OFFSET FIXED_PARTITION_NODE_OFFSET(SOC_NV_FLASH_NODE) +#define FLASH_SIMULATOR_BASE_OFFSET PARTITION_NODE_OFFSET(SOC_NV_FLASH_NODE) #define FLASH_SIMULATOR_ERASE_UNIT DT_PROP(SOC_NV_FLASH_NODE, erase_block_size) #define FLASH_SIMULATOR_PROG_UNIT DT_PROP(SOC_NV_FLASH_NODE, write_block_size) #define FLASH_SIMULATOR_FLASH_SIZE DT_REG_SIZE(SOC_NV_FLASH_NODE) diff --git a/tests/lib/devicetree/api/src/main.c b/tests/lib/devicetree/api/src/main.c index a2fb0aa5bba1..3ead4a70351c 100644 --- a/tests/lib/devicetree/api/src/main.c +++ b/tests/lib/devicetree/api/src/main.c @@ -3303,75 +3303,75 @@ ZTEST(devicetree_api, test_mbox) ZTEST(devicetree_api, test_fixed_partitions) { /* Test finding fixed partitions by the 'label' property. */ - zassert_true(DT_HAS_FIXED_PARTITION_LABEL(test_partition_0)); - zassert_true(DT_HAS_FIXED_PARTITION_LABEL(test_partition_1)); - zassert_true(DT_HAS_FIXED_PARTITION_LABEL(test_partition_2)); + zassert_true(DT_HAS_PARTITION_LABEL(test_partition_0)); + zassert_true(DT_HAS_PARTITION_LABEL(test_partition_1)); + zassert_true(DT_HAS_PARTITION_LABEL(test_partition_2)); zassert_true(DT_SAME_NODE(TEST_PARTITION_0, - DT_NODE_BY_FIXED_PARTITION_LABEL(test_partition_0))); + DT_NODE_BY_PARTITION_LABEL(test_partition_0))); zassert_true(DT_SAME_NODE(TEST_PARTITION_1, - DT_NODE_BY_FIXED_PARTITION_LABEL(test_partition_1))); + DT_NODE_BY_PARTITION_LABEL(test_partition_1))); zassert_true(DT_SAME_NODE(TEST_PARTITION_2, - DT_NODE_BY_FIXED_PARTITION_LABEL(test_partition_2))); + DT_NODE_BY_PARTITION_LABEL(test_partition_2))); - zassert_true(DT_FIXED_PARTITION_EXISTS(TEST_PARTITION_0)); - zassert_true(DT_FIXED_PARTITION_EXISTS(TEST_PARTITION_1)); - zassert_true(DT_FIXED_PARTITION_EXISTS(TEST_PARTITION_2)); + zassert_true(DT_PARTITION_EXISTS(TEST_PARTITION_0)); + zassert_true(DT_PARTITION_EXISTS(TEST_PARTITION_1)); + zassert_true(DT_PARTITION_EXISTS(TEST_PARTITION_2)); /* There should not be a node with `label = "test_partition_3"`. */ - zassert_false(DT_HAS_FIXED_PARTITION_LABEL(test_partition_3)); - zassert_false(DT_NODE_EXISTS(DT_NODE_BY_FIXED_PARTITION_LABEL(test_partition_3))); + zassert_false(DT_HAS_PARTITION_LABEL(test_partition_3)); + zassert_false(DT_NODE_EXISTS(DT_NODE_BY_PARTITION_LABEL(test_partition_3))); /* There is a node with `label = "FOO"`, but it is not a fixed partition. */ - zassert_false(DT_HAS_FIXED_PARTITION_LABEL(FOO)); - zassert_false(DT_NODE_EXISTS(DT_NODE_BY_FIXED_PARTITION_LABEL(FOO))); - - /* Test DT_MTD_FROM_FIXED_PARTITION. */ - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_PARTITION(TEST_PARTITION_0))); - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_PARTITION(TEST_PARTITION_1))); - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_PARTITION(TEST_PARTITION_2))); - - zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_FIXED_PARTITION(TEST_PARTITION_0))); - zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_FIXED_PARTITION(TEST_PARTITION_1))); - zassert_true(DT_SAME_NODE(TEST_MTD_1, DT_MTD_FROM_FIXED_PARTITION(TEST_PARTITION_2))); - - /* Test DT_MEM_FROM_FIXED_PARTITION. */ - zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_PARTITION(TEST_PARTITION_0))); - zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_PARTITION(TEST_PARTITION_1))); - zassert_false(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_PARTITION(TEST_PARTITION_2))); - - zassert_true(DT_SAME_NODE(TEST_MEM_0, DT_MEM_FROM_FIXED_PARTITION(TEST_PARTITION_0))); - zassert_true(DT_SAME_NODE(TEST_MEM_0, DT_MEM_FROM_FIXED_PARTITION(TEST_PARTITION_1))); - - /* Test DT_FIXED_PARTITION_ADDR. */ - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_0), 0x20000000); - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_1), 0x200000c0); - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_PARTITION_2), 0x33291080); + zassert_false(DT_HAS_PARTITION_LABEL(FOO)); + zassert_false(DT_NODE_EXISTS(DT_NODE_BY_PARTITION_LABEL(FOO))); + + /* Test DT_MTD_FROM_PARTITION. */ + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_PARTITION_0))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_PARTITION_1))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_PARTITION_2))); + + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_PARTITION(TEST_PARTITION_0))); + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_PARTITION(TEST_PARTITION_1))); + zassert_true(DT_SAME_NODE(TEST_MTD_1, DT_MTD_FROM_PARTITION(TEST_PARTITION_2))); + + /* Test DT_MEM_FROM_PARTITION. */ + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_PARTITION_0))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_PARTITION_1))); + zassert_false(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_PARTITION_2))); + + zassert_true(DT_SAME_NODE(TEST_MEM_0, DT_MEM_FROM_PARTITION(TEST_PARTITION_0))); + zassert_true(DT_SAME_NODE(TEST_MEM_0, DT_MEM_FROM_PARTITION(TEST_PARTITION_1))); + + /* Test DT_PARTITION_ADDR. */ + zassert_equal(DT_PARTITION_ADDR(TEST_PARTITION_0), 0x20000000); + zassert_equal(DT_PARTITION_ADDR(TEST_PARTITION_1), 0x200000c0); + zassert_equal(DT_PARTITION_ADDR(TEST_PARTITION_2), 0x33291080); } ZTEST(devicetree_api, test_fixed_subpartitions) { - zassert_true(DT_FIXED_PARTITION_EXISTS(TEST_SUBPARTITION_COMBINED)); + zassert_true(DT_PARTITION_EXISTS(TEST_SUBPARTITION_COMBINED)); zassert_true(DT_FIXED_SUBPARTITION_EXISTS(TEST_SUBPARTITION_0)); zassert_true(DT_FIXED_SUBPARTITION_EXISTS(TEST_SUBPARTITION_1)); /* Test DT_MEM_FROM_FIXED_SUBPARTITION. */ - zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_PARTITION(TEST_SUBPARTITION_COMBINED))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_SUBPARTITION_COMBINED))); zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_SUBPARTITION(TEST_SUBPARTITION_0))); zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_FIXED_SUBPARTITION(TEST_SUBPARTITION_1))); /* Test DT_MTD_FROM_FIXED_SUBPARTITION. */ - zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_PARTITION(TEST_SUBPARTITION_COMBINED))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_SUBPARTITION_COMBINED))); zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_SUBPARTITION(TEST_SUBPARTITION_0))); zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_FIXED_SUBPARTITION(TEST_SUBPARTITION_1))); zassert_true(DT_SAME_NODE( - DT_MTD_FROM_FIXED_PARTITION(TEST_SUBPARTITION_COMBINED), + DT_MTD_FROM_PARTITION(TEST_SUBPARTITION_COMBINED), DT_MTD_FROM_FIXED_SUBPARTITION(TEST_SUBPARTITION_1))); /* Test DT_FIXED_SUBPARTITION_ADDR. */ - zassert_equal(DT_FIXED_PARTITION_ADDR(TEST_SUBPARTITION_COMBINED), 0x20000100); + zassert_equal(DT_PARTITION_ADDR(TEST_SUBPARTITION_COMBINED), 0x20000100); zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_0), - DT_FIXED_PARTITION_ADDR(TEST_SUBPARTITION_COMBINED)); + DT_PARTITION_ADDR(TEST_SUBPARTITION_COMBINED)); zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_0), 0x20000100); zassert_equal(DT_FIXED_SUBPARTITION_ADDR(TEST_SUBPARTITION_1), 0x20000140); @@ -3487,18 +3487,125 @@ ZTEST(devicetree_api, test_mapped_partition) zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_MAPPED_PARTITION_6), 0x100f9000); zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_MAPPED_PARTITION_7), 0x100fb000); zassert_equal(DT_MAPPED_PARTITION_ADDR(TEST_DISABLED_MAPPED_PARTITION), 0x89000); +} + +ZTEST(devicetree_api, test_partition) +{ + zassert_false(DT_HAS_PARTITION_LABEL(mapped_partition_0)); + zassert_true(DT_HAS_PARTITION_LABEL(mapped_partition_1)); + zassert_true(DT_HAS_PARTITION_LABEL(mapped_partition_1)); + zassert_true(DT_HAS_PARTITION_LABEL(mapped_partition_2)); + zassert_true(DT_HAS_PARTITION_LABEL(mapped_partition_3)); + zassert_true(DT_HAS_PARTITION_LABEL(mapped_partition_4)); + zassert_true(DT_HAS_PARTITION_LABEL(mapped_partition_5)); + zassert_true(DT_HAS_PARTITION_LABEL(mapped_partition_6)); + zassert_true(DT_HAS_PARTITION_LABEL(mapped_partition_7)); + zassert_true(DT_HAS_PARTITION_LABEL(disabled_mapped_partition)); + + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_1, + DT_NODE_BY_PARTITION_LABEL(mapped_partition_1))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_2, + DT_NODE_BY_PARTITION_LABEL(mapped_partition_2))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_3, + DT_NODE_BY_PARTITION_LABEL(mapped_partition_3))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_4, + DT_NODE_BY_PARTITION_LABEL(mapped_partition_4))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_5, + DT_NODE_BY_PARTITION_LABEL(mapped_partition_5))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_6, + DT_NODE_BY_PARTITION_LABEL(mapped_partition_6))); + zassert_true(DT_SAME_NODE(TEST_MAPPED_PARTITION_7, + DT_NODE_BY_PARTITION_LABEL(mapped_partition_7))); + zassert_true(DT_SAME_NODE(TEST_DISABLED_MAPPED_PARTITION, + DT_NODE_BY_PARTITION_LABEL(disabled_mapped_partition))); + + zassert_true(DT_PARTITION_EXISTS(TEST_MAPPED_PARTITION_1)); + zassert_true(DT_PARTITION_EXISTS(TEST_MAPPED_PARTITION_2)); + zassert_true(DT_PARTITION_EXISTS(TEST_MAPPED_PARTITION_3)); + zassert_true(DT_PARTITION_EXISTS(TEST_MAPPED_PARTITION_4)); + zassert_true(DT_PARTITION_EXISTS(TEST_MAPPED_PARTITION_5)); + zassert_true(DT_PARTITION_EXISTS(TEST_MAPPED_PARTITION_6)); + zassert_true(DT_PARTITION_EXISTS(TEST_MAPPED_PARTITION_7)); + zassert_true(DT_PARTITION_EXISTS(TEST_DISABLED_MAPPED_PARTITION)); + + /* There should not be a node with `label = "mapped-partition-8"`. */ + zassert_false(DT_HAS_PARTITION_LABEL(mapped_partition_8)); + zassert_false(DT_NODE_EXISTS(DT_NODE_BY_PARTITION_LABEL(mapped_partition_8))); + + /* Test DT_MTD_FROM_PARTITION. */ + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_MAPPED_PARTITION_1))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_MAPPED_PARTITION_2))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_MAPPED_PARTITION_3))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_MAPPED_PARTITION_4))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_MAPPED_PARTITION_5))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_MAPPED_PARTITION_6))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_MAPPED_PARTITION_7))); + zassert_true(DT_NODE_EXISTS(DT_MTD_FROM_PARTITION(TEST_DISABLED_MAPPED_PARTITION))); + + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_PARTITION( + TEST_MAPPED_PARTITION_1))); + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_PARTITION( + TEST_MAPPED_PARTITION_2))); + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_PARTITION( + TEST_MAPPED_PARTITION_3))); + zassert_true(DT_SAME_NODE(TEST_MTD_2, DT_MTD_FROM_PARTITION( + TEST_MAPPED_PARTITION_4))); + zassert_true(DT_SAME_NODE(TEST_MTD_2, DT_MTD_FROM_PARTITION( + TEST_MAPPED_PARTITION_5))); + zassert_true(DT_SAME_NODE(TEST_MTD_2, DT_MTD_FROM_PARTITION( + TEST_MAPPED_PARTITION_6))); + zassert_true(DT_SAME_NODE(TEST_MTD_2, DT_MTD_FROM_PARTITION( + TEST_MAPPED_PARTITION_7))); + zassert_true(DT_SAME_NODE(TEST_MTD_0, DT_MTD_FROM_PARTITION( + TEST_DISABLED_MAPPED_PARTITION))); + + /* Test DT_MEM_FROM_PARTITION. */ + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_MAPPED_PARTITION_1))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_MAPPED_PARTITION_2))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_MAPPED_PARTITION_3))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_MAPPED_PARTITION_4))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_MAPPED_PARTITION_5))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_MAPPED_PARTITION_6))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_MAPPED_PARTITION_7))); + zassert_true(DT_NODE_EXISTS(DT_MEM_FROM_PARTITION(TEST_DISABLED_MAPPED_PARTITION))); + + zassert_true(DT_SAME_NODE(TEST_FLASH_0, DT_MEM_FROM_PARTITION( + TEST_MAPPED_PARTITION_1))); + zassert_true(DT_SAME_NODE(TEST_FLASH_0, DT_MEM_FROM_PARTITION( + TEST_MAPPED_PARTITION_2))); + zassert_true(DT_SAME_NODE(TEST_FLASH_0, DT_MEM_FROM_PARTITION( + TEST_MAPPED_PARTITION_3))); + zassert_true(DT_SAME_NODE(TEST_FLASH_1, DT_MEM_FROM_PARTITION( + TEST_MAPPED_PARTITION_4))); + zassert_true(DT_SAME_NODE(TEST_FLASH_1, DT_MEM_FROM_PARTITION( + TEST_MAPPED_PARTITION_5))); + zassert_true(DT_SAME_NODE(TEST_FLASH_1, DT_MEM_FROM_PARTITION( + TEST_MAPPED_PARTITION_6))); + zassert_true(DT_SAME_NODE(TEST_FLASH_1, DT_MEM_FROM_PARTITION( + TEST_MAPPED_PARTITION_7))); + zassert_true(DT_SAME_NODE(TEST_FLASH_0, DT_MEM_FROM_PARTITION( + TEST_DISABLED_MAPPED_PARTITION))); + + /* Test DT_PARTITION_ADDR. */ + zassert_equal(DT_PARTITION_ADDR(TEST_MAPPED_PARTITION_1), 0x0); + zassert_equal(DT_PARTITION_ADDR(TEST_MAPPED_PARTITION_2), 0xc000); + zassert_equal(DT_PARTITION_ADDR(TEST_MAPPED_PARTITION_3), 0x82000); + zassert_equal(DT_PARTITION_ADDR(TEST_MAPPED_PARTITION_4), 0x100f8000); + zassert_equal(DT_PARTITION_ADDR(TEST_MAPPED_PARTITION_5), 0x100f8000); + zassert_equal(DT_PARTITION_ADDR(TEST_MAPPED_PARTITION_6), 0x100f9000); + zassert_equal(DT_PARTITION_ADDR(TEST_MAPPED_PARTITION_7), 0x100fb000); + zassert_equal(DT_PARTITION_ADDR(TEST_DISABLED_MAPPED_PARTITION), 0x89000); - /* Test that all DT_MAPPED_PARTITION_ID are defined and unique. */ -#define FIXED_PARTITION_ID_COMMA(node_id) DT_FIXED_PARTITION_ID(node_id), -#define MAPPED_PARTITION_ID_COMMA(node_id) DT_MAPPED_PARTITION_ID(node_id), + /* Test that all DT_PARTITION_ID are defined and unique. */ +#define PARTITION_ID_COMMA(node_id) DT_PARTITION_ID(node_id), static const int ids[] = { DT_FOREACH_STATUS_OKAY_VARGS(fixed_partitions, DT_FOREACH_CHILD, - FIXED_PARTITION_ID_COMMA) + PARTITION_ID_COMMA) DT_FOREACH_STATUS_OKAY_VARGS(fixed_subpartitions, DT_FOREACH_CHILD, - FIXED_PARTITION_ID_COMMA) + PARTITION_ID_COMMA) DT_FOREACH_STATUS_OKAY_VARGS(zephyr_mapped_partitions, DT_FOREACH_CHILD, - MAPPED_PARTITION_ID_COMMA) + PARTITION_ID_COMMA) }; bool found[20] = { false }; @@ -3508,7 +3615,7 @@ ZTEST(devicetree_api, test_mapped_partition) found[ids[i]] = true; } -#undef FIXED_PARTITION_ID_COMMA +#undef PARTITION_ID_COMMA } ZTEST(devicetree_api, test_string_token) diff --git a/tests/lib/gui/lvgl/src/main.c b/tests/lib/gui/lvgl/src/main.c index 18b9f22c68c8..6b595d35f79e 100644 --- a/tests/lib/gui/lvgl/src/main.c +++ b/tests/lib/gui/lvgl/src/main.c @@ -44,7 +44,7 @@ static struct fs_mount_t mnt = { #define IMG_FILE_PATH "/mnt/img.bin" #define LVGL_PARTITION storage_partition -#define LVGL_PARTITION_ID FIXED_PARTITION_ID(LVGL_PARTITION) +#define LVGL_PARTITION_ID PARTITION_ID(LVGL_PARTITION) FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(cstorage); diff --git a/tests/net/lib/http_server/core/src/main.c b/tests/net/lib/http_server/core/src/main.c index c372f6c8b702..8fca6a80b6b1 100644 --- a/tests/net/lib/http_server/core/src/main.c +++ b/tests/net/lib/http_server/core/src/main.c @@ -2525,7 +2525,7 @@ ZTEST(server_function_tests_no_init, test_parse_http_frames) FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage); #define TEST_PARTITION storage_partition -#define TEST_PARTITION_ID FIXED_PARTITION_ID(TEST_PARTITION) +#define TEST_PARTITION_ID PARTITION_ID(TEST_PARTITION) #define LFS_MNTP "/littlefs" #define TEST_FILE "static_file.html" diff --git a/tests/subsys/dfu/img_util/src/main.c b/tests/subsys/dfu/img_util/src/main.c index c0b5d96daeb1..cd831f6a0595 100644 --- a/tests/subsys/dfu/img_util/src/main.c +++ b/tests/subsys/dfu/img_util/src/main.c @@ -13,18 +13,18 @@ #define SLOT0_PARTITION slot0_partition #define SLOT1_PARTITION slot1_partition -#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \ - DT_SAME_NODE(FIXED_PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)), \ - FIXED_PARTITION_MTD(label)) && \ - (FIXED_PARTITION_OFFSET(label) <= CONFIG_FLASH_LOAD_OFFSET && \ - FIXED_PARTITION_OFFSET(label) + FIXED_PARTITION_SIZE(label) > CONFIG_FLASH_LOAD_OFFSET) - -#if FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition) -#define UPLOAD_PARTITION_ID FIXED_PARTITION_ID(SLOT1_PARTITION) -#define RUNNING_PARTITION_ID FIXED_PARTITION_ID(SLOT0_PARTITION) +#define PARTITION_IS_RUNNING_APP_PARTITION(label) \ + DT_SAME_NODE(PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)), \ + PARTITION_MTD(label)) && \ + (PARTITION_OFFSET(label) <= CONFIG_FLASH_LOAD_OFFSET && \ + PARTITION_OFFSET(label) + PARTITION_SIZE(label) > CONFIG_FLASH_LOAD_OFFSET) + +#if PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition) +#define UPLOAD_PARTITION_ID PARTITION_ID(SLOT1_PARTITION) +#define RUNNING_PARTITION_ID PARTITION_ID(SLOT0_PARTITION) #else -#define UPLOAD_PARTITION_ID FIXED_PARTITION_ID(SLOT0_PARTITION) -#define RUNNING_PARTITION_ID FIXED_PARTITION_ID(SLOT1_PARTITION) +#define UPLOAD_PARTITION_ID PARTITION_ID(SLOT0_PARTITION) +#define RUNNING_PARTITION_ID PARTITION_ID(SLOT1_PARTITION) #endif diff --git a/tests/subsys/dfu/mcuboot/src/main.c b/tests/subsys/dfu/mcuboot/src/main.c index de40526dfc3e..8c42d23563a5 100644 --- a/tests/subsys/dfu/mcuboot/src/main.c +++ b/tests/subsys/dfu/mcuboot/src/main.c @@ -12,8 +12,8 @@ #define SLOT0_PARTITION slot0_partition #define SLOT1_PARTITION slot1_partition -#define SLOT0_PARTITION_ID FIXED_PARTITION_ID(SLOT0_PARTITION) -#define SLOT1_PARTITION_ID FIXED_PARTITION_ID(SLOT1_PARTITION) +#define SLOT0_PARTITION_ID PARTITION_ID(SLOT0_PARTITION) +#define SLOT1_PARTITION_ID PARTITION_ID(SLOT1_PARTITION) #define BOOT_MAGIC_VAL_W0 0xf395c277 #define BOOT_MAGIC_VAL_W1 0x7fefd260 diff --git a/tests/subsys/dfu/mcuboot_multi/src/main.c b/tests/subsys/dfu/mcuboot_multi/src/main.c index d99a6a74e899..47dd360f23e9 100644 --- a/tests/subsys/dfu/mcuboot_multi/src/main.c +++ b/tests/subsys/dfu/mcuboot_multi/src/main.c @@ -76,8 +76,8 @@ static void _test_request_upgrade_n(uint8_t fa_id, int img_index, int confirmed) ZTEST(mcuboot_multi, test_request_upgrade_multi) { - _test_request_upgrade_n(FIXED_PARTITION_ID(slot1_partition), 0, 0); - _test_request_upgrade_n(FIXED_PARTITION_ID(slot3_partition), 1, 1); + _test_request_upgrade_n(PARTITION_ID(slot1_partition), 0, 0); + _test_request_upgrade_n(PARTITION_ID(slot3_partition), 1, 1); } static void _test_write_confirm_n(uint8_t fa_id, int img_index) @@ -122,8 +122,8 @@ static void _test_write_confirm_n(uint8_t fa_id, int img_index) ZTEST(mcuboot_multi, test_write_confirm_multi) { - _test_write_confirm_n(FIXED_PARTITION_ID(slot0_partition), 0); - _test_write_confirm_n(FIXED_PARTITION_ID(slot2_partition), 1); + _test_write_confirm_n(PARTITION_ID(slot0_partition), 0); + _test_write_confirm_n(PARTITION_ID(slot2_partition), 1); } ZTEST_SUITE(mcuboot_multi, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/subsys/fs/fcb/src/fcb_test.h b/tests/subsys/fs/fcb/src/fcb_test.h index 9ae833991b66..cd7f2cc6804c 100644 --- a/tests/subsys/fs/fcb/src/fcb_test.h +++ b/tests/subsys/fs/fcb/src/fcb_test.h @@ -21,7 +21,7 @@ extern "C" { #endif #define TEST_FCB_FLASH_AREA slot1_partition -#define TEST_FCB_FLASH_AREA_ID FIXED_PARTITION_ID(TEST_FCB_FLASH_AREA) +#define TEST_FCB_FLASH_AREA_ID PARTITION_ID(TEST_FCB_FLASH_AREA) extern struct fcb test_fcb; #if defined(CONFIG_FCB_ALLOW_FIXED_ENDMARKER) diff --git a/tests/subsys/fs/littlefs/src/testfs_lfs.c b/tests/subsys/fs/littlefs/src/testfs_lfs.c index bde73b87caa1..bb6a2eaa21c3 100644 --- a/tests/subsys/fs/littlefs/src/testfs_lfs.c +++ b/tests/subsys/fs/littlefs/src/testfs_lfs.c @@ -10,13 +10,13 @@ #include "testfs_lfs.h" #define SMALL_PARTITION small_partition -#define SMALL_PARTITION_ID FIXED_PARTITION_ID(SMALL_PARTITION) +#define SMALL_PARTITION_ID PARTITION_ID(SMALL_PARTITION) #define MEDIUM_PARTITION medium_partition -#define MEDIUM_PARTITION_ID FIXED_PARTITION_ID(MEDIUM_PARTITION) +#define MEDIUM_PARTITION_ID PARTITION_ID(MEDIUM_PARTITION) #define LARGE_PARTITION large_partition -#define LARGE_PARTITION_ID FIXED_PARTITION_ID(LARGE_PARTITION) +#define LARGE_PARTITION_ID PARTITION_ID(LARGE_PARTITION) FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(small); struct fs_mount_t testfs_small_mnt = { diff --git a/tests/subsys/fs/multi-fs/src/test_littlefs_mount.c b/tests/subsys/fs/multi-fs/src/test_littlefs_mount.c index c92bebd7f9fc..4fb397a5d2ee 100644 --- a/tests/subsys/fs/multi-fs/src/test_littlefs_mount.c +++ b/tests/subsys/fs/multi-fs/src/test_littlefs_mount.c @@ -16,7 +16,7 @@ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage); #define TEST_PARTITION storage_partition -#define TEST_PARTITION_ID FIXED_PARTITION_ID(TEST_PARTITION) +#define TEST_PARTITION_ID PARTITION_ID(TEST_PARTITION) struct fs_mount_t littlefs_mnt = { .type = FS_LITTLEFS, diff --git a/tests/subsys/fs/multi-fs/src/test_ram_backend.c b/tests/subsys/fs/multi-fs/src/test_ram_backend.c index d391412512cb..0f3b9ca59993 100644 --- a/tests/subsys/fs/multi-fs/src/test_ram_backend.c +++ b/tests/subsys/fs/multi-fs/src/test_ram_backend.c @@ -13,8 +13,8 @@ #include #define TEST_PARTITION storage_partition -#define TEST_PARTITION_ID FIXED_PARTITION_ID(TEST_PARTITION) -#define TEST_PARTITION_SIZE FIXED_PARTITION_SIZE(TEST_PARTITION) +#define TEST_PARTITION_ID PARTITION_ID(TEST_PARTITION) +#define TEST_PARTITION_SIZE PARTITION_SIZE(TEST_PARTITION) static uint8_t rambuf[TEST_PARTITION_SIZE]; diff --git a/tests/subsys/fs/multi-fs/src/test_utils.c b/tests/subsys/fs/multi-fs/src/test_utils.c index 579007ab8ff2..05b7ab38b04d 100644 --- a/tests/subsys/fs/multi-fs/src/test_utils.c +++ b/tests/subsys/fs/multi-fs/src/test_utils.c @@ -11,7 +11,7 @@ #include #define TEST_PARTITION storage_partition -#define TEST_PARTITION_ID FIXED_PARTITION_ID(TEST_PARTITION) +#define TEST_PARTITION_ID PARTITION_ID(TEST_PARTITION) int check_file_dir_exists(const char *fpath) { diff --git a/tests/subsys/fs/nvs/src/main.c b/tests/subsys/fs/nvs/src/main.c index 3d2254ada929..87963bf06c45 100644 --- a/tests/subsys/fs/nvs/src/main.c +++ b/tests/subsys/fs/nvs/src/main.c @@ -16,10 +16,10 @@ #include "nvs_priv.h" #define TEST_NVS_FLASH_AREA storage_partition -#define TEST_NVS_FLASH_AREA_OFFSET FIXED_PARTITION_OFFSET(TEST_NVS_FLASH_AREA) -#define TEST_NVS_FLASH_AREA_ID FIXED_PARTITION_ID(TEST_NVS_FLASH_AREA) +#define TEST_NVS_FLASH_AREA_OFFSET PARTITION_OFFSET(TEST_NVS_FLASH_AREA) +#define TEST_NVS_FLASH_AREA_ID PARTITION_ID(TEST_NVS_FLASH_AREA) #define TEST_NVS_FLASH_AREA_DEV \ - DEVICE_DT_GET(DT_MTD_FROM_FIXED_PARTITION(DT_NODELABEL(TEST_NVS_FLASH_AREA))) + DEVICE_DT_GET(DT_MTD_FROM_PARTITION(DT_NODELABEL(TEST_NVS_FLASH_AREA))) #define TEST_DATA_ID 1 #define TEST_SECTOR_COUNT 5U diff --git a/tests/subsys/fs/zms/src/main.c b/tests/subsys/fs/zms/src/main.c index 06d20f6153b6..fd58f42fb4c8 100644 --- a/tests/subsys/fs/zms/src/main.c +++ b/tests/subsys/fs/zms/src/main.c @@ -17,9 +17,9 @@ #include "zms_priv.h" #define TEST_ZMS_AREA storage_partition -#define TEST_ZMS_AREA_OFFSET FIXED_PARTITION_OFFSET(TEST_ZMS_AREA) -#define TEST_ZMS_AREA_ID FIXED_PARTITION_ID(TEST_ZMS_AREA) -#define TEST_ZMS_AREA_DEV DEVICE_DT_GET(DT_MTD_FROM_FIXED_PARTITION(DT_NODELABEL(TEST_ZMS_AREA))) +#define TEST_ZMS_AREA_OFFSET PARTITION_OFFSET(TEST_ZMS_AREA) +#define TEST_ZMS_AREA_ID PARTITION_ID(TEST_ZMS_AREA) +#define TEST_ZMS_AREA_DEV DEVICE_DT_GET(DT_MTD_FROM_PARTITION(DT_NODELABEL(TEST_ZMS_AREA))) #define TEST_DATA_ID 1 #define TEST_SECTOR_COUNT 5U diff --git a/tests/subsys/llext/src/test_llext.c b/tests/subsys/llext/src/test_llext.c index a7cf0032059f..81cb60772901 100644 --- a/tests/subsys/llext/src/test_llext.c +++ b/tests/subsys/llext/src/test_llext.c @@ -627,7 +627,7 @@ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage); static struct fs_mount_t mp = { .type = FS_LITTLEFS, .fs_data = &storage, - .storage_dev = (void *)FIXED_PARTITION_ID(storage_partition), + .storage_dev = (void *)PARTITION_ID(storage_partition), .mnt_point = "/lfs", }; diff --git a/tests/subsys/lorawan/frag_decoder/src/main.c b/tests/subsys/lorawan/frag_decoder/src/main.c index 34beb61e2b35..aaf4910c39f8 100644 --- a/tests/subsys/lorawan/frag_decoder/src/main.c +++ b/tests/subsys/lorawan/frag_decoder/src/main.c @@ -28,7 +28,7 @@ #define FRAG_TRANSPORT_PORT (201) #define FRAG_SESSION_INDEX (1) -#define TARGET_IMAGE_AREA FIXED_PARTITION_ID(slot1_partition) +#define TARGET_IMAGE_AREA PARTITION_ID(slot1_partition) /* below array would normally hold the actual firmware binary */ static uint8_t fw_uncoded[FIRMWARE_SIZE]; diff --git a/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/src/main.c b/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/src/main.c index c3cdc4d11343..a676c4b83ae2 100644 --- a/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/src/main.c +++ b/tests/subsys/mgmt/mcumgr/img_mgmt_slot_info/src/main.c @@ -38,13 +38,13 @@ struct partition_entries_t { }; struct partition_entries_t partition_entries[] = { - { FIXED_PARTITION_ID(slot0_partition), 0 }, - { FIXED_PARTITION_ID(slot1_partition), 0 }, -#if FIXED_PARTITION_EXISTS(slot2_partition) - { FIXED_PARTITION_ID(slot2_partition), 0 }, + { PARTITION_ID(slot0_partition), 0 }, + { PARTITION_ID(slot1_partition), 0 }, +#if PARTITION_EXISTS(slot2_partition) + { PARTITION_ID(slot2_partition), 0 }, #endif -#if FIXED_PARTITION_EXISTS(slot3_partition) - { FIXED_PARTITION_ID(slot3_partition), 0 }, +#if PARTITION_EXISTS(slot3_partition) + { PARTITION_ID(slot3_partition), 0 }, #endif }; diff --git a/tests/subsys/secure_storage/psa/its/src/main.c b/tests/subsys/secure_storage/psa/its/src/main.c index d5d6d0d5d7c5..aeca82fdd6f3 100644 --- a/tests/subsys/secure_storage/psa/its/src/main.c +++ b/tests/subsys/secure_storage/psa/its/src/main.c @@ -9,14 +9,14 @@ /* The flash must be erased after this test suite is run for the write-once entry test to pass. */ #if !defined(CONFIG_BUILD_WITH_TFM) && defined(CONFIG_FLASH_PAGE_LAYOUT) && \ - FIXED_PARTITION_EXISTS(DT_NODELABEL(storage_partition)) + PARTITION_EXISTS(DT_NODELABEL(storage_partition)) static int erase_flash(void) { - const struct device *const fdev = FIXED_PARTITION_MTD(storage_partition); + const struct device *const fdev = PARTITION_MTD(storage_partition); int rc; - rc = flash_flatten(fdev, FIXED_PARTITION_OFFSET(storage_partition), - FIXED_PARTITION_SIZE(storage_partition)); + rc = flash_flatten(fdev, PARTITION_OFFSET(storage_partition), + PARTITION_SIZE(storage_partition)); if (rc < 0) { TC_PRINT("Failed to flatten the storage partition (%d) !", rc); return rc; diff --git a/tests/subsys/settings/fcb/src/settings_test_fcb.c b/tests/subsys/settings/fcb/src/settings_test_fcb.c index 1b3097c6f8b3..0710d1b16469 100644 --- a/tests/subsys/settings/fcb/src/settings_test_fcb.c +++ b/tests/subsys/settings/fcb/src/settings_test_fcb.c @@ -12,7 +12,7 @@ #include #define TEST_PARTITION storage_partition -#define TEST_PARTITION_ID FIXED_PARTITION_ID(TEST_PARTITION) +#define TEST_PARTITION_ID PARTITION_ID(TEST_PARTITION) uint8_t val8; uint8_t val8_un; diff --git a/tests/subsys/settings/fcb_init/src/settings_test_fcb_init.c b/tests/subsys/settings/fcb_init/src/settings_test_fcb_init.c index b7815a44ec3e..9c5bc5463841 100644 --- a/tests/subsys/settings/fcb_init/src/settings_test_fcb_init.c +++ b/tests/subsys/settings/fcb_init/src/settings_test_fcb_init.c @@ -19,11 +19,11 @@ #define TEST_PARTITION storage_partition #define CODE_PARTITION slot0_partition -#define TEST_PARTITION_ID FIXED_PARTITION_ID(TEST_PARTITION) +#define TEST_PARTITION_ID PARTITION_ID(TEST_PARTITION) #define CODE_PARTITION_NODE DT_NODELABEL(CODE_PARTITION) -#define CODE_PARTITION_ID FIXED_PARTITION_ID(CODE_PARTITION) -#define CODE_PARTITION_EXISTS FIXED_PARTITION_EXISTS(CODE_PARTITION) +#define CODE_PARTITION_ID PARTITION_ID(CODE_PARTITION) +#define CODE_PARTITION_EXISTS PARTITION_EXISTS(CODE_PARTITION) static uint32_t val32; @@ -36,9 +36,9 @@ static uint32_t val32; /* leverage that this area has to be embedded flash part */ #if CODE_PARTITION_EXISTS #if DT_NODE_HAS_COMPAT(CODE_PARTITION_NODE, zephyr_mapped_partition) && \ - DT_NODE_HAS_PROP(DT_MEM_FROM_FIXED_PARTITION(CODE_PARTITION_NODE), write_block_size) + DT_NODE_HAS_PROP(DT_MEM_FROM_PARTITION(CODE_PARTITION_NODE), write_block_size) #define FLASH_WRITE_BLOCK_SIZE \ - DT_PROP(DT_MEM_FROM_FIXED_PARTITION(CODE_PARTITION_NODE), write_block_size) + DT_PROP(DT_MEM_FROM_PARTITION(CODE_PARTITION_NODE), write_block_size) #elif DT_NODE_HAS_PROP(DT_GPARENT(CODE_PARTITION_NODE), write_block_size) #define FLASH_WRITE_BLOCK_SIZE \ DT_PROP(DT_GPARENT(CODE_PARTITION_NODE), write_block_size) diff --git a/tests/subsys/settings/file/src/settings_setup_littlefs.c b/tests/subsys/settings/file/src/settings_setup_littlefs.c index 5e1705b876bf..9f88a503a9b6 100644 --- a/tests/subsys/settings/file/src/settings_setup_littlefs.c +++ b/tests/subsys/settings/file/src/settings_setup_littlefs.c @@ -10,7 +10,7 @@ #include #define LITTLEFS_PARTITION settings_file_partition -#define LITTLEFS_PARTITION_ID FIXED_PARTITION_ID(LITTLEFS_PARTITION) +#define LITTLEFS_PARTITION_ID PARTITION_ID(LITTLEFS_PARTITION) /* LittleFS work area struct */ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(cstorage); diff --git a/tests/subsys/settings/functional/src/settings_basic_test.c b/tests/subsys/settings/functional/src/settings_basic_test.c index da00b1e7237d..a495b188f94a 100644 --- a/tests/subsys/settings/functional/src/settings_basic_test.c +++ b/tests/subsys/settings/functional/src/settings_basic_test.c @@ -19,7 +19,7 @@ LOG_MODULE_REGISTER(settings_basic_test); #if defined(CONFIG_SETTINGS_FCB) || defined(CONFIG_SETTINGS_NVS) || defined(CONFIG_SETTINGS_ZMS) #include #if DT_HAS_CHOSEN(zephyr_settings_partition) -#define TEST_FLASH_AREA_ID DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition)) +#define TEST_FLASH_AREA_ID DT_PARTITION_ID(DT_CHOSEN(zephyr_settings_partition)) #endif #elif defined(CONFIG_SETTINGS_FILE) #include @@ -56,7 +56,7 @@ LOG_MODULE_REGISTER(settings_basic_test); #ifndef TEST_FLASH_AREA_ID #define TEST_FLASH_AREA storage_partition -#define TEST_FLASH_AREA_ID FIXED_PARTITION_ID(TEST_FLASH_AREA) +#define TEST_FLASH_AREA_ID PARTITION_ID(TEST_FLASH_AREA) #endif /* The standard test expects a cleared flash area. Make sure it has diff --git a/tests/subsys/storage/flash_map/src/main.c b/tests/subsys/storage/flash_map/src/main.c index 7075110bb0a7..b44499ec8340 100644 --- a/tests/subsys/storage/flash_map/src/main.c +++ b/tests/subsys/storage/flash_map/src/main.c @@ -12,11 +12,11 @@ #include #define SLOT1_PARTITION slot1_partition -#define SLOT1_PARTITION_ID FIXED_PARTITION_ID(SLOT1_PARTITION) -#define SLOT1_PARTITION_DEV FIXED_PARTITION_DEVICE(SLOT1_PARTITION) +#define SLOT1_PARTITION_ID PARTITION_ID(SLOT1_PARTITION) +#define SLOT1_PARTITION_DEV PARTITION_DEVICE(SLOT1_PARTITION) #define SLOT1_PARTITION_NODE DT_NODELABEL(SLOT1_PARTITION) -#define SLOT1_PARTITION_OFFSET FIXED_PARTITION_OFFSET(SLOT1_PARTITION) -#define SLOT1_PARTITION_SIZE FIXED_PARTITION_SIZE(SLOT1_PARTITION) +#define SLOT1_PARTITION_OFFSET PARTITION_OFFSET(SLOT1_PARTITION) +#define SLOT1_PARTITION_SIZE PARTITION_SIZE(SLOT1_PARTITION) #define FLASH_AREA_COPY_SIZE MIN((SLOT1_PARTITION_SIZE / 2), 128) @@ -37,20 +37,20 @@ ZTEST(flash_map, test_flash_area_disabled_device) int rc; /* Test that attempting to open a disabled flash area fails */ - rc = flash_area_open(FIXED_PARTITION_ID(disabled_a), &fa); + rc = flash_area_open(PARTITION_ID(disabled_a), &fa); zassert_equal(rc, -ENOENT, "Open did not fail"); - rc = flash_area_open(FIXED_PARTITION_ID(disabled_a_a), &fa); + rc = flash_area_open(PARTITION_ID(disabled_a_a), &fa); zassert_equal(rc, -ENOENT, "Open did not fail"); - rc = flash_area_open(FIXED_PARTITION_ID(disabled_a_b), &fa); + rc = flash_area_open(PARTITION_ID(disabled_a_b), &fa); zassert_equal(rc, -ENOENT, "Open did not fail"); - rc = flash_area_open(FIXED_PARTITION_ID(disabled_b), &fa); + rc = flash_area_open(PARTITION_ID(disabled_b), &fa); zassert_equal(rc, -ENOENT, "Open did not fail"); - rc = flash_area_open(FIXED_PARTITION_ID(disabled_b_a), &fa); + rc = flash_area_open(PARTITION_ID(disabled_b_a), &fa); zassert_equal(rc, -ENOENT, "Open did not fail"); - rc = flash_area_open(FIXED_PARTITION_ID(disabled_b_b), &fa); + rc = flash_area_open(PARTITION_ID(disabled_b_b), &fa); zassert_equal(rc, -ENOENT, "Open did not fail"); - /* Note lack of tests for FIXED_PARTITION(...) instantiation, + /* Note lack of tests for PARTITION(...) instantiation, * because this macro will fail, at compile time, if node does not * exist or is disabled. */ @@ -71,7 +71,7 @@ ZTEST(flash_map, test_flash_area_device_is_ready) * all devices are already initialized and ready. */ zassert_true(flash_area_device_is_ready( - FIXED_PARTITION(SLOT1_PARTITION))); + PARTITION(SLOT1_PARTITION))); } static void layout_match(const struct device *flash_dev, uint32_t sec_cnt) @@ -104,7 +104,7 @@ ZTEST(flash_map, test_flash_area_get_sectors) uint32_t sec_cnt; int rc; - fa = FIXED_PARTITION(SLOT1_PARTITION); + fa = PARTITION(SLOT1_PARTITION); zassert_true(flash_area_device_is_ready(fa)); @@ -129,7 +129,7 @@ ZTEST(flash_map, test_flash_area_sectors) int rc; const struct device *flash_dev_a = SLOT1_PARTITION_DEV; - fa = FIXED_PARTITION(SLOT1_PARTITION); + fa = PARTITION(SLOT1_PARTITION); zassert_true(flash_area_device_is_ready(fa)); @@ -151,7 +151,7 @@ ZTEST(flash_map, test_flash_area_erased_val) const struct flash_area *fa; uint8_t val; - fa = FIXED_PARTITION(SLOT1_PARTITION); + fa = PARTITION(SLOT1_PARTITION); val = flash_area_erased_val(fa); @@ -169,16 +169,16 @@ ZTEST(flash_map, test_fixed_partition_node_macros) */ #if defined(CONFIG_TEST_FLASH_MAP_NODE_MACROS) /* Test against changes in API */ - zassert_equal(FIXED_PARTITION_NODE_OFFSET(SLOT1_PARTITION_NODE), + zassert_equal(PARTITION_NODE_OFFSET(SLOT1_PARTITION_NODE), DT_REG_ADDR(SLOT1_PARTITION_NODE)); - zassert_equal(FIXED_PARTITION_NODE_SIZE(SLOT1_PARTITION_NODE), + zassert_equal(PARTITION_NODE_SIZE(SLOT1_PARTITION_NODE), DT_REG_SIZE(SLOT1_PARTITION_NODE)); - zassert_equal(FIXED_PARTITION_NODE_DEVICE(SLOT1_PARTITION_NODE), - DEVICE_DT_GET(DT_MTD_FROM_FIXED_PARTITION(SLOT1_PARTITION_NODE))); + zassert_equal(PARTITION_NODE_DEVICE(SLOT1_PARTITION_NODE), + DEVICE_DT_GET(DT_MTD_FROM_PARTITION(SLOT1_PARTITION_NODE))); /* Taking by node and taking by label should give same device */ - zassert_equal(FIXED_PARTITION_BY_NODE(DT_NODELABEL(SLOT1_PARTITION)), - FIXED_PARTITION(SLOT1_PARTITION)); + zassert_equal(PARTITION_BY_NODE(DT_NODELABEL(SLOT1_PARTITION)), + PARTITION(SLOT1_PARTITION)); #else ztest_test_skip(); #endif @@ -192,31 +192,31 @@ ZTEST(flash_map, test_fixed_subpartition_node_macros) */ #if defined(CONFIG_TEST_FLASH_MAP_NODE_MACROS) /* Test that both partitions and subpartitions exist */ - zassert_true(FIXED_PARTITION_EXISTS(disabled_a)); - zassert_true(FIXED_PARTITION_EXISTS(disabled_a_a)); - zassert_true(FIXED_PARTITION_EXISTS(disabled_a_b)); + zassert_true(PARTITION_EXISTS(disabled_a)); + zassert_true(PARTITION_EXISTS(disabled_a_a)); + zassert_true(PARTITION_EXISTS(disabled_a_b)); /* Test that the subpartition offset is relative to the parent */ - zassert_equal(FIXED_PARTITION_OFFSET(disabled_b), - FIXED_PARTITION_OFFSET(disabled_b_a)); - zassert_equal(FIXED_PARTITION_OFFSET(disabled_b) + 0x100, - FIXED_PARTITION_OFFSET(disabled_b_b)); - zassert_equal(FIXED_PARTITION_NODE_OFFSET(DT_NODELABEL(disabled_b)), - FIXED_PARTITION_NODE_OFFSET(DT_NODELABEL(disabled_b_a))); + zassert_equal(PARTITION_OFFSET(disabled_b), + PARTITION_OFFSET(disabled_b_a)); + zassert_equal(PARTITION_OFFSET(disabled_b) + 0x100, + PARTITION_OFFSET(disabled_b_b)); + zassert_equal(PARTITION_NODE_OFFSET(DT_NODELABEL(disabled_b)), + PARTITION_NODE_OFFSET(DT_NODELABEL(disabled_b_a))); zassert_equal( - FIXED_PARTITION_NODE_OFFSET(DT_NODELABEL(disabled_b)) + 0x100, - FIXED_PARTITION_NODE_OFFSET(DT_NODELABEL(disabled_b_b))); + PARTITION_NODE_OFFSET(DT_NODELABEL(disabled_b)) + 0x100, + PARTITION_NODE_OFFSET(DT_NODELABEL(disabled_b_b))); /* Test that the subpartition address is relative to the parent */ - zassert_equal(FIXED_PARTITION_ADDRESS(disabled_b), - FIXED_PARTITION_ADDRESS(disabled_b_a)); - zassert_equal(FIXED_PARTITION_ADDRESS(disabled_b) + 0x100, - FIXED_PARTITION_ADDRESS(disabled_b_b)); - zassert_equal(FIXED_PARTITION_NODE_ADDRESS(DT_NODELABEL(disabled_b)), - FIXED_PARTITION_NODE_ADDRESS(DT_NODELABEL(disabled_b_a))); + zassert_equal(PARTITION_ADDRESS(disabled_b), + PARTITION_ADDRESS(disabled_b_a)); + zassert_equal(PARTITION_ADDRESS(disabled_b) + 0x100, + PARTITION_ADDRESS(disabled_b_b)); + zassert_equal(PARTITION_NODE_ADDRESS(DT_NODELABEL(disabled_b)), + PARTITION_NODE_ADDRESS(DT_NODELABEL(disabled_b_a))); zassert_equal( - FIXED_PARTITION_NODE_ADDRESS(DT_NODELABEL(disabled_b)) + 0x100, - FIXED_PARTITION_NODE_ADDRESS(DT_NODELABEL(disabled_b_b))); + PARTITION_NODE_ADDRESS(DT_NODELABEL(disabled_b)) + 0x100, + PARTITION_NODE_ADDRESS(DT_NODELABEL(disabled_b_b))); #else ztest_test_skip(); #endif @@ -230,7 +230,7 @@ ZTEST(flash_map, test_flash_area_erase_and_flatten) const struct flash_area *fa; const struct device *flash_dev; - fa = FIXED_PARTITION(SLOT1_PARTITION); + fa = PARTITION(SLOT1_PARTITION); /* First erase the area so it's ready for use. */ flash_dev = flash_area_get_device(fa); @@ -299,7 +299,7 @@ ZTEST(flash_map, test_flash_area_copy) int rc; /* Get source and destination flash areas */ - fa = FIXED_PARTITION(SLOT1_PARTITION); + fa = PARTITION(SLOT1_PARTITION); /* First erase the area so it's ready for use. */ rc = flash_area_erase(fa, 0, fa->fa_size); @@ -327,7 +327,7 @@ ZTEST(flash_map, test_parameter_overflows) uint8_t dst_buf[FLASH_AREA_COPY_SIZE]; int rc; - fa = FIXED_PARTITION(SLOT1_PARTITION); + fa = PARTITION(SLOT1_PARTITION); /* -1 cast to size_t gives us max size_t value, added to offset of 1, * it will overflow to 0. */ diff --git a/tests/subsys/storage/flash_map/src/main_sha.c b/tests/subsys/storage/flash_map/src/main_sha.c index ae2dc6b2acf4..3cc9945f2cf3 100644 --- a/tests/subsys/storage/flash_map/src/main_sha.c +++ b/tests/subsys/storage/flash_map/src/main_sha.c @@ -12,10 +12,10 @@ #include #define SLOT1_PARTITION slot1_partition -#define SLOT1_PARTITION_ID FIXED_PARTITION_ID(SLOT1_PARTITION) -#define SLOT1_PARTITION_DEV FIXED_PARTITION_DEVICE(SLOT1_PARTITION) +#define SLOT1_PARTITION_ID PARTITION_ID(SLOT1_PARTITION) +#define SLOT1_PARTITION_DEV PARTITION_DEVICE(SLOT1_PARTITION) #define SLOT1_PARTITION_NODE DT_NODELABEL(SLOT1_PARTITION) -#define SLOT1_PARTITION_OFFSET FIXED_PARTITION_OFFSET(SLOT1_PARTITION) +#define SLOT1_PARTITION_OFFSET PARTITION_OFFSET(SLOT1_PARTITION) ZTEST(flash_map_sha, test_flash_area_check_int_sha256) { From 19086a0e0cf60f56f62ca95f8cb094f10713f660 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 26 Feb 2026 09:02:10 +0000 Subject: [PATCH 41/63] [nrf fromtree] kconfig: Change invalid flash code partition to fixed 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 (cherry picked from commit 1d32ca8c624ca03ea7baa7d80475ca8e1cf7fdfa) --- Kconfig.zephyr | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/Kconfig.zephyr b/Kconfig.zephyr index 9c8584184a02..722880dce22d 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -111,18 +111,17 @@ config FLASH_USES_MAPPED_PARTITION fixed-partitions and should not be relied upon outside of the zephyr build system and will be removed in future. -config FLASH_CODE_PARTITION_ADDRESS_INVALID +config FLASH_CODE_PARTITION_USING_FIXED_PARTITIONS bool - default y if XIP && $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) < FLASH_BASE_ADDRESS + default y if XIP && \ + $(dt_chosen_has_compat,$(dt_node_parent,$(dt_chosen_path,$(DT_CHOSEN_Z_CODE_PARTITION))),fixed-partitions) || \ + $(dt_chosen_has_compat,$(dt_node_parent,$(dt_chosen_path,$(DT_CHOSEN_Z_CODE_PARTITION))),fixed-subpartitions) depends on USE_DT_CODE_PARTITION select DEPRECATED help - If this item is selected, it is likely selected because your board/SoC/base DTS files - are wrong and have a flash memory that does not start at absolute address 0x0 and: - * Do not have a ``ranges <>;`` property in the flash node passing down the address - and size to child nodes - * Do not have a ``ranges;`` property in the partitions node passing down the previous - ranges to child nodes + If this item is selected then it is because your device is using ``fixed-partitions`` or + ``fixed-subpartitions`` for partition layout, this has been replaced with + ``zephyr,mapped-partitions``. Support for this will be removed and required that your files be updated correctly for a future release, check the Zephyr 4.4 migration notes. @@ -130,10 +129,7 @@ config FLASH_CODE_PARTITION_ADDRESS_INVALID config FLASH_LOAD_OFFSET # Only user-configurable when USE_DT_CODE_PARTITION is disabled hex "Kernel load offset" if !USE_DT_CODE_PARTITION - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) \ - if FLASH_CODE_PARTITION_ADDRESS_INVALID - default $(sub_hex, $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)), \ - $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_FLASH))) if USE_DT_CODE_PARTITION + default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) if USE_DT_CODE_PARTITION default 0 help This option specifies the byte offset from the beginning of flash that From a65ed76d8f60c975a27a77d86c6b7c90f8f22c57 Mon Sep 17 00:00:00 2001 From: Dominik Ermel Date: Thu, 13 Jul 2023 13:42:10 +0000 Subject: [PATCH 42/63] [nrf noup] drivers/flashdisk: Add support for Partition Manager The commits adds support for generating flash disks from Partition Manager defined partitions. Signed-off-by: Dominik Ermel (cherry picked from commit 80eff8d743a831977cb4caab3a07b288362618a0) --- drivers/disk/flashdisk.c | 78 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/drivers/disk/flashdisk.c b/drivers/disk/flashdisk.c index bdb19fae1663..a23b719d4291 100644 --- a/drivers/disk/flashdisk.c +++ b/drivers/disk/flashdisk.c @@ -504,6 +504,8 @@ static const struct disk_operations flash_disk_ops = { .ioctl = disk_flash_access_ioctl, }; +#ifndef USE_PARTITION_MANAGER +/* The non-Partition manager, DTS based generators below */ #define DT_DRV_COMPAT zephyr_flash_disk #define PARTITION_PHANDLE(n) DT_PHANDLE_BY_IDX(DT_DRV_INST(n), partition, 0) @@ -545,6 +547,82 @@ DT_INST_FOREACH_STATUS_OKAY(VERIFY_CACHE_SIZE_IS_NOT_ZERO_IF_NOT_READ_ONLY) "Devicetree node " DT_NODE_PATH(DT_DRV_INST(n)) \ " has cache size which is not a multiple of its sector size"); DT_INST_FOREACH_STATUS_OKAY(VERIFY_CACHE_SIZE_IS_MULTIPLY_OF_SECTOR_SIZE) +#else /* ifndef USE_PARTITION_MANAGER */ +/* Partition Manager based generators below */ + +/* Gets the PM_..._EXTRA_PARAM_##param value */ +#define PM_FLASH_DISK_ENTRY_EXTRA_PARAM(name, param) PM_##name##_EXTRA_PARAM_disk_##param + +/* Gets the PM_..._NAME value which is originally cased, as in yaml, partition name */ +#define PM_FLASH_DISK_ENTRY_PARTITION_NAME(name) PM_##name##_NAME + +/* Generates flashdiskN_cache variable name, where N is partition ID */ +#define PM_FLASH_DISK_CACHE_VARIABLE(n) UTIL_CAT(flashdisk, UTIL_CAT(FIXED_PARTITION_ID(n), _cache)) + +/* Generate cache buffers */ +#define CACHE_SIZE(n) (COND_CODE_1(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, read_only), (0), (1)) * \ + PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, cache_size)) +#define DEFINE_FLASHDISKS_CACHE(n) \ + static uint8_t __aligned(4) PM_FLASH_DISK_CACHE_VARIABLE(n)[CACHE_SIZE(n)]; + +PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_CACHE) + +/* Generated single Flash Disk device data from Partition Manager partition. + * Partition is required to have type set to disk in partition definitions: + * type: disk + * and following extra params can be provided: + * extra_params: { + * name = "", + * cache_size = , + * sector_size = , + * read_only = + * } + * where: + * is mandatory device name that will be used by Disk Access and FAT FS to mount device; + * is cache r/w cache size, which is mandatory if read_only = 0 or not present, + * and should be multiple of ; + * is mandatory device sector size information, usually should be erase page size, + * for flash devices, for example 4096 bytes; + * read_only is optional, if not present then assumed false; can be 0(false) or 1(true). + */ +#define DEFINE_FLASHDISKS_DEVICE(n) \ +{ \ + .info = { \ + .ops = &flash_disk_ops, \ + .name = STRINGIFY(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, name)), \ + }, \ + .area_id = FIXED_PARTITION_ID(n), \ + .offset = FIXED_PARTITION_OFFSET(n), \ + .cache = PM_FLASH_DISK_CACHE_VARIABLE(n), \ + .cache_size = sizeof(PM_FLASH_DISK_CACHE_VARIABLE(n)), \ + .size = FIXED_PARTITION_SIZE(n), \ + .sector_size = PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, sector_size), \ +}, + +/* The bellow used PM_FOREACH_TYPE_disk is generated by Partition Manager foreach + * loop macro. The lower case _disk is type name for which the macro has been generated; + * partition entry can have multiple types set and foreach macro will be generated + * for every type found across partition definitions. + */ +static struct flashdisk_data flash_disks[] = { + PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_DEVICE) +}; + +#define VERIFY_CACHE_SIZE_IS_NOT_ZERO_IF_NOT_READ_ONLY(n) \ + COND_CODE_1(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, read_only), \ + (/* cache-size is not used for read-only disks */), \ + (BUILD_ASSERT(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, cache_size) != 0, \ + "Flash disk partition " STRINGIFY(PM_FLASH_DISK_ENTRY_PARTITION_NAME(n))\ + " must have non-zero cache-size");)) +PM_FOREACH_AFFILIATED_TO_disk(VERIFY_CACHE_SIZE_IS_NOT_ZERO_IF_NOT_READ_ONLY) + +#define VERIFY_CACHE_SIZE_IS_MULTIPLY_OF_SECTOR_SIZE(n) \ + BUILD_ASSERT(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, cache_size) % \ + PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, sector_size) == 0, \ + "Devicetree node " STRINGIFY(PM_FLASH_DISK_ENTRY_PARTITION_NAME(n)) \ + " has cache size which is not a multiple of its sector size"); +PM_FOREACH_AFFILIATED_TO_disk(VERIFY_CACHE_SIZE_IS_MULTIPLY_OF_SECTOR_SIZE) +#endif /* USE_PARTITION_MANAGER */ static int disk_flash_init(void) { From 21d68f9e0e93c75d34dc67128c6bc8e961c4ed31 Mon Sep 17 00:00:00 2001 From: Sigvart Hovland Date: Fri, 3 May 2019 14:21:52 +0200 Subject: [PATCH 43/63] [nrf noup] tree-wide: support NCS Partition Manager (PM) definitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Andrzej Puzdrowski Signed-off-by: Håkon Øye Amundsen Signed-off-by: Ioannis Glaropoulos Signed-off-by: Joakim Andersson Signed-off-by: Johann Fischer Signed-off-by: Martí Bolívar Signed-off-by: Ole Sæther Signed-off-by: Robert Lubos Signed-off-by: Sebastian Bøe Signed-off-by: Sigvart Hovland Signed-off-by: Thomas Stenersen Signed-off-by: Torsten Rasmussen Signed-off-by: Øyvind Rønningstad Signed-off-by: Trond Einar Snekvik Signed-off-by: Gerard Marull-Paretas Signed-off-by: Tomasz Moń Signed-off-by: Dominik Ermel Signed-off-by: Jamie McCrae (cherry picked from commit 19efc58959be53320f4de816d0b74c1d49d80485) --- arch/arm/core/mpu/arm_mpu_regions.c | 13 +++++ cmake/linker/ld/target.cmake | 1 + cmake/linker/lld/target.cmake | 1 + cmake/modules/kernel.cmake | 4 ++ drivers/flash/soc_flash_nrf.c | 11 ++++ drivers/flash/soc_flash_nrf_rram.c | 11 ++++ .../arch/arm/cortex_m/scripts/linker.ld | 50 +++++++++++++++++++ include/zephyr/storage/flash_map.h | 6 +++ lib/heap/Kconfig | 2 +- lib/libc/common/source/stdlib/malloc.c | 18 ++++++- subsys/dfu/boot/mcuboot_shell.c | 40 +++++++++++++++ subsys/fs/littlefs_fs.c | 7 ++- subsys/ipc/rpmsg_service/rpmsg_backend.h | 27 ++++++++++ 13 files changed, 187 insertions(+), 4 deletions(-) diff --git a/arch/arm/core/mpu/arm_mpu_regions.c b/arch/arm/core/mpu/arm_mpu_regions.c index 4771c5914ce6..71c0a9a2b739 100644 --- a/arch/arm/core/mpu/arm_mpu_regions.c +++ b/arch/arm/core/mpu/arm_mpu_regions.c @@ -8,6 +8,9 @@ #include #include +#if USE_PARTITION_MANAGER +#include +#endif #ifdef CONFIG_ARM_MPU_SRAM_WRITE_THROUGH #define ARM_MPU_SRAM_REGION_ATTR REGION_RAM_WT_ATTR @@ -30,6 +33,14 @@ static const struct arm_mpu_region mpu_regions[] = { /* Region 1 */ MPU_REGION_ENTRY("SRAM_0", +#if USE_PARTITION_MANAGER + PM_SRAM_ADDRESS, +#if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE) + REGION_RAM_ATTR(PM_SRAM_ADDRESS, PM_SRAM_SIZE)), +#else + REGION_RAM_ATTR(REGION_SRAM_SIZE)), +#endif +#else CONFIG_SRAM_BASE_ADDRESS, #if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE) ARM_MPU_SRAM_REGION_ATTR(CONFIG_SRAM_BASE_ADDRESS, @@ -37,6 +48,8 @@ static const struct arm_mpu_region mpu_regions[] = { #else ARM_MPU_SRAM_REGION_ATTR(REGION_SRAM_SIZE)), #endif + +#endif /* USE_PARTITION_MANAGER */ }; const struct arm_mpu_config mpu_config = { diff --git a/cmake/linker/ld/target.cmake b/cmake/linker/ld/target.cmake index 592596576d11..ccf6a1903162 100644 --- a/cmake/linker/ld/target.cmake +++ b/cmake/linker/ld/target.cmake @@ -80,6 +80,7 @@ macro(configure_linker_script linker_script_gen linker_pass_define) ${current_includes} ${soc_linker_script_includes} ${template_script_defines} + -DUSE_PARTITION_MANAGER=$ -E ${LINKER_SCRIPT} -P # Prevent generation of debug `#line' directives. -o ${linker_script_gen} diff --git a/cmake/linker/lld/target.cmake b/cmake/linker/lld/target.cmake index 96df1c123796..fe8aad62c73d 100644 --- a/cmake/linker/lld/target.cmake +++ b/cmake/linker/lld/target.cmake @@ -52,6 +52,7 @@ macro(configure_linker_script linker_script_gen linker_pass_define) -imacros ${AUTOCONF_H} ${current_includes} ${template_script_defines} + -DUSE_PARTITION_MANAGER=$ -E ${LINKER_SCRIPT} -P # Prevent generation of debug `#line' directives. -o ${linker_script_gen} diff --git a/cmake/modules/kernel.cmake b/cmake/modules/kernel.cmake index af9c85d80e35..83c3e4bcb846 100644 --- a/cmake/modules/kernel.cmake +++ b/cmake/modules/kernel.cmake @@ -256,3 +256,7 @@ if("${CMAKE_EXTRA_GENERATOR}" STREQUAL "Eclipse CDT4") include(${ZEPHYR_BASE}/cmake/ide/eclipse_cdt4_generator_amendment.cmake) eclipse_cdt4_generator_amendment(1) endif() + +if(ZEPHYR_NRF_MODULE_DIR) + include(${ZEPHYR_NRF_MODULE_DIR}/cmake/partition_manager.cmake) +endif() diff --git a/drivers/flash/soc_flash_nrf.c b/drivers/flash/soc_flash_nrf.c index f6b8a6f5eef3..27fda598be20 100644 --- a/drivers/flash/soc_flash_nrf.c +++ b/drivers/flash/soc_flash_nrf.c @@ -36,6 +36,11 @@ LOG_MODULE_REGISTER(flash_nrf); #define SOC_NV_FLASH_NODE DT_INST(0, soc_nv_flash) +#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER +#include +#include +#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER */ + #ifndef CONFIG_SOC_FLASH_NRF_RADIO_SYNC_NONE #define FLASH_SLOT_WRITE 7500 #if defined(CONFIG_SOC_FLASH_NRF_PARTIAL_ERASE) @@ -165,6 +170,12 @@ static int flash_nrf_read(const struct device *dev, off_t addr, } #endif +#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER && PM_APP_ADDRESS + if (addr < PM_APP_ADDRESS) { + return soc_secure_mem_read(data, (void *)addr, len); + } +#endif + nrf_nvmc_buffer_read(data, (uint32_t)addr, len); return 0; diff --git a/drivers/flash/soc_flash_nrf_rram.c b/drivers/flash/soc_flash_nrf_rram.c index 9f0e24dc33d5..84c7e958f3cd 100644 --- a/drivers/flash/soc_flash_nrf_rram.c +++ b/drivers/flash/soc_flash_nrf_rram.c @@ -54,6 +54,11 @@ LOG_MODULE_REGISTER(flash_nrf_rram, CONFIG_FLASH_LOG_LEVEL); #define WRITE_BLOCK_SIZE_FROM_DT DT_PROP(RRAM, write_block_size) #define ERASE_VALUE 0xFF +#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER +#include +#include +#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER */ + #ifdef CONFIG_MULTITHREADING static struct k_sem sem_lock; #define SYNC_INIT() k_sem_init(&sem_lock, 1, 1) @@ -292,6 +297,12 @@ static int nrf_rram_read(const struct device *dev, off_t addr, void *data, size_ } addr += RRAM_START; +#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER && PM_APP_ADDRESS + if (addr < PM_APP_ADDRESS) { + return soc_secure_mem_read(data, (void *)addr, len); + } +#endif + memcpy(data, (void *)addr, len); return 0; diff --git a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld index 0663ac97653e..13f428b26960 100644 --- a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld +++ b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld @@ -34,6 +34,39 @@ #define ROMSTART_REGION ROMABLE_REGION #endif +#if USE_PARTITION_MANAGER + +#include + +#if CONFIG_NCS_IS_VARIANT_IMAGE && defined(PM_S0_ID) +/* We are linking against S1, create symbol containing the flash ID of S0. + * This is used when writing code operating on the "other" slot. + */ +_image_1_primary_slot_id = PM_S0_ID; + +#else /* ! CONFIG_NCS_IS_VARIANT_IMAGE */ + +#ifdef PM_S1_ID +/* We are linking against S0, create symbol containing the flash ID of S1. + * This is used when writing code operating on the "other" slot. + */ +_image_1_primary_slot_id = PM_S1_ID; +#endif /* PM_S1_ID */ + +#endif /* CONFIG_NCS_IS_VARIANT_IMAGE */ + +#define ROM_ADDR PM_ADDRESS +#define ROM_SIZE PM_SIZE + +#if defined(CONFIG_PM_USE_CONFIG_SRAM_SIZE) +#define RAM_SIZE CONFIG_PM_SRAM_SIZE +#else +#define RAM_SIZE PM_SRAM_SIZE +#endif +#define RAM_ADDR PM_SRAM_ADDRESS + +#else /* ! USE_PARTITION_MANAGER */ + #if defined(CONFIG_ROM_END_OFFSET) #define ROM_END_OFFSET CONFIG_ROM_END_OFFSET #else @@ -60,6 +93,23 @@ #define RAM_SIZE (CONFIG_SRAM_SIZE * 1K) #define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS +#endif /* USE_PARTITION_MANAGER */ + +#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_ccm), okay) +#define CCM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ccm)) +#define CCM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ccm)) +#endif + +#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_itcm), okay) +#define ITCM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_itcm)) +#define ITCM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_itcm)) +#endif + +#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_dtcm), okay) +#define DTCM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_dtcm)) +#define DTCM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_dtcm)) +#endif + #if defined(CONFIG_CUSTOM_SECTION_ALIGN) _region_min_align = CONFIG_CUSTOM_SECTION_MIN_ALIGN_SIZE; #else diff --git a/include/zephyr/storage/flash_map.h b/include/zephyr/storage/flash_map.h index df4e4ef63cd4..2befcef56453 100644 --- a/include/zephyr/storage/flash_map.h +++ b/include/zephyr/storage/flash_map.h @@ -351,6 +351,10 @@ const char *flash_area_label(const struct flash_area *fa); */ uint8_t flash_area_erased_val(const struct flash_area *fa); +#if USE_PARTITION_MANAGER +#include +#else + /** * Returns non-0 value if partition of given DTS node label exists. * @@ -624,6 +628,8 @@ DT_FOREACH_STATUS_OKAY(fixed_subpartitions, FOR_EACH_SUBPARTITION_TABLE) #undef FOR_EACH_SUBPARTITION_TABLE /** @endcond */ +#endif /* USE_PARTITION_MANAGER */ + #ifdef __cplusplus } #endif diff --git a/lib/heap/Kconfig b/lib/heap/Kconfig index 0d97da3e340b..9a39ab8ad73b 100644 --- a/lib/heap/Kconfig +++ b/lib/heap/Kconfig @@ -81,7 +81,7 @@ config HEAP_LISTENER choice prompt "Supported heap sizes" depends on !64BIT - default SYS_HEAP_SMALL_ONLY if (SRAM_SIZE <= 256) + default SYS_HEAP_SMALL_ONLY if (SRAM_SIZE <= 256) && !PARTITION_MANAGER_ENABLED default SYS_HEAP_AUTO help Heaps using reduced-size chunk headers can accommodate so called diff --git a/lib/libc/common/source/stdlib/malloc.c b/lib/libc/common/source/stdlib/malloc.c index 2b01e152f009..2821ae8173ac 100644 --- a/lib/libc/common/source/stdlib/malloc.c +++ b/lib/libc/common/source/stdlib/malloc.c @@ -25,6 +25,20 @@ #include LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL); +#if USE_PARTITION_MANAGER + +#include + +#define RAM_SIZE PM_SRAM_SIZE +#define RAM_ADDR PM_SRAM_ADDRESS + +#else /* ! USE_PARTITION_MANAGER */ + +#define RAM_SIZE (KB((size_t) CONFIG_SRAM_SIZE)) +#define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS + +#endif /* USE_PARTITION_MANAGER */ + #ifdef CONFIG_COMMON_LIBC_MALLOC #if (CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE != 0) @@ -106,8 +120,8 @@ static POOL_SECTION unsigned char __aligned(HEAP_ALIGN) malloc_arena[HEAP_SIZE]; extern char _heap_sentry[]; # define HEAP_SIZE ROUND_DOWN((POINTER_TO_UINT(_heap_sentry) - HEAP_BASE), HEAP_ALIGN) # else -# define HEAP_SIZE ROUND_DOWN((KB((size_t) CONFIG_SRAM_SIZE) - \ - ((size_t) HEAP_BASE - (size_t) CONFIG_SRAM_BASE_ADDRESS)), HEAP_ALIGN) +# define HEAP_SIZE ROUND_DOWN((RAM_SIZE - \ + ((size_t) HEAP_BASE - (size_t) RAM_ADDR)), HEAP_ALIGN) # endif /* else CONFIG_XTENSA */ # endif /* else CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE > 0 */ diff --git a/subsys/dfu/boot/mcuboot_shell.c b/subsys/dfu/boot/mcuboot_shell.c index 583bc4778362..06eb79baa92b 100644 --- a/subsys/dfu/boot/mcuboot_shell.c +++ b/subsys/dfu/boot/mcuboot_shell.c @@ -20,6 +20,16 @@ #endif #endif +#if USE_PARTITION_MANAGER +#include + +#ifdef CONFIG_NCS_IS_VARIANT_IMAGE +#define ACTIVE_IMAGE_ID PM_MCUBOOT_SECONDARY_ID +#else +#define ACTIVE_IMAGE_ID PM_MCUBOOT_PRIMARY_ID +#endif +#endif + struct area_desc { const char *name; unsigned int id; @@ -93,6 +103,35 @@ static int cmd_mcuboot_erase(const struct shell *sh, size_t argc, id = strtoul(argv[1], NULL, 0); /* Check if this is the parent (MCUboot) or own slot and if so, deny the request */ +#if USE_PARTITION_MANAGER +#ifdef PM_MCUBOOT_ID + if (id == PM_MCUBOOT_ID || id == PM_MCUBOOT_PAD_ID) { + shell_error(sh, "Cannot erase boot partition"); + return -EACCES; + } +#endif + +#ifdef PM_APP_ID + if (id == PM_APP_ID) { + shell_error(sh, "Cannot erase this area"); + return -EACCES; + } +#endif + +#ifdef PM_MCUBOOT_PRIMARY_APP_ID + if (id == PM_MCUBOOT_PRIMARY_APP_ID) { + shell_error(sh, "Cannot erase this area"); + return -EACCES; + } +#endif + +#ifdef ACTIVE_IMAGE_ID + if (id == ACTIVE_IMAGE_ID) { + shell_error(sh, "Cannot erase active partitions"); + return -EACCES; + } +#endif +#else #if PARTITION_EXISTS(boot_partition) if (id == PARTITION_ID(boot_partition)) { shell_error(sh, "Cannot erase boot partition"); @@ -105,6 +144,7 @@ static int cmd_mcuboot_erase(const struct shell *sh, size_t argc, shell_error(sh, "Cannot erase active partitions"); return -EACCES; } +#endif #endif err = boot_erase_img_bank(id); diff --git a/subsys/fs/littlefs_fs.c b/subsys/fs/littlefs_fs.c index 7abe4dea9295..0bd75a349b76 100644 --- a/subsys/fs/littlefs_fs.c +++ b/subsys/fs/littlefs_fs.c @@ -1133,7 +1133,12 @@ struct fs_mount_t FS_FSTAB_ENTRY(DT_DRV_INST(inst)) = { \ .type = FS_LITTLEFS, \ .mnt_point = FSTAB_ENTRY_DT_INST_MOUNT_POINT(inst), \ .fs_data = &fs_data_##inst, \ - .storage_dev = (void *)DT_PARTITION_ID(FS_PARTITION(inst)), \ + .storage_dev = (void *) \ + COND_CODE_1(USE_PARTITION_MANAGER, \ + (COND_CODE_1(PARTITION_EXISTS(littlefs_storage), \ + (PARTITION_ID(littlefs_storage)), \ + (PARTITION_ID(storage)))), \ + (DT_FIXED_PARTITION_ID(FS_PARTITION(inst)))), \ .flags = FSTAB_ENTRY_DT_MOUNT_FLAGS(DT_DRV_INST(inst)), \ }; diff --git a/subsys/ipc/rpmsg_service/rpmsg_backend.h b/subsys/ipc/rpmsg_service/rpmsg_backend.h index a74e46b85207..9996e1d74d9b 100644 --- a/subsys/ipc/rpmsg_service/rpmsg_backend.h +++ b/subsys/ipc/rpmsg_service/rpmsg_backend.h @@ -13,8 +13,35 @@ extern "C" { #endif +#if CONFIG_PARTITION_MANAGER_ENABLED + +#include "pm_config.h" + +#if defined(PM_RPMSG_NRF53_SRAM_ADDRESS) || defined(PM__RPMSG_NRF53_SRAM_ADDRESS) + +#if defined(PM_RPMSG_NRF53_SRAM_ADDRESS) +#define VDEV_START_ADDR PM_RPMSG_NRF53_SRAM_ADDRESS +#define VDEV_SIZE PM_RPMSG_NRF53_SRAM_SIZE +#else +/* The current image is a child image in a different domain than the image + * which defined the required values. To reach the values of the parent domain + * we use the 'PM__' variant of the define. + */ +#define VDEV_START_ADDR PM__RPMSG_NRF53_SRAM_ADDRESS +#define VDEV_SIZE PM__RPMSG_NRF53_SRAM_SIZE +#endif /* defined(PM_RPMSG_NRF53_SRAM_ADDRESS) */ + +#else #define VDEV_START_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ipc_shm)) #define VDEV_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ipc_shm)) +#endif /* defined(PM_RPMSG_NRF53_SRAM_ADDRESS) || defined(PM__RPMSG_NRF53_SRAM_ADDRESS) */ + +#else + +#define VDEV_START_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ipc_shm)) +#define VDEV_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ipc_shm)) + +#endif /* CONFIG_PARTITION_MANAGER_ENABLED */ #define VDEV_STATUS_ADDR VDEV_START_ADDR #define VDEV_STATUS_SIZE 0x400 From 12a52849f494bc67a67a0829e9b9b45d03619d1d Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 19 Mar 2026 12:45:46 +0000 Subject: [PATCH 44/63] [nrf fromtree] include: arch: arm: cortex_m: linker: Fix non-XIP usage Fixes wrongly using the mapped partition parts if XIP is not enabled, when it should use RAM instead Signed-off-by: Jamie McCrae (cherry picked from commit 294755aeaf4a987b80658e91ef5ce3d42a717620) --- include/zephyr/arch/arm/cortex_m/scripts/linker.ld | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld index 13f428b26960..c798f0a8fd1c 100644 --- a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld +++ b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld @@ -27,7 +27,7 @@ #define RAMABLE_REGION RAM /* Region of the irq vectors and boot-vector SP/PC */ -#if defined(CONFIG_ROMSTART_RELOCATION_ROM) +#if defined(CONFIG_ROMSTART_RELOCATION_ROM) && defined(CONFIG_XIP) #define ROMSTART_ADDR CONFIG_ROMSTART_REGION_ADDRESS #define ROMSTART_SIZE (CONFIG_ROMSTART_REGION_SIZE * 1K) #else From c726fae5d4e1e40b2bcb305b98f24bea8988fd75 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 12 Mar 2026 09:52:10 +0000 Subject: [PATCH 45/63] [nrf fromtree] arch: arm: cortex_a_r: linker: Add support for zephyr,mapped-partition Adds support for using this new binding Signed-off-by: Jamie McCrae (cherry picked from commit 09e73db07a80abb2e8b37ec6764e71b947620539) --- .../arch/arm/cortex_a_r/scripts/linker.ld | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld b/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld index cd3bc8e1cd0b..7da87f8702e2 100644 --- a/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld +++ b/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld @@ -34,23 +34,28 @@ #define ROMSTART_REGION ROMABLE_REGION #endif -#if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) - #define ROM_ADDR RAM_ADDR -#else - #define ROM_ADDR (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) -#endif - #if defined(CONFIG_ROM_END_OFFSET) #define ROM_END_OFFSET CONFIG_ROM_END_OFFSET #else #define ROM_END_OFFSET 0 #endif +#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) && defined(CONFIG_XIP) +#define ROM_ADDR (DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition))) +#define ROM_SIZE (DT_REG_SIZE(DT_CHOSEN(zephyr_code_partition)) - ROM_END_OFFSET) +#else +#if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) +#define ROM_ADDR RAM_ADDR +#else +#define ROM_ADDR (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) +#endif + #if CONFIG_FLASH_LOAD_SIZE > 0 #define ROM_SIZE (CONFIG_FLASH_LOAD_SIZE - ROM_END_OFFSET) #else #define ROM_SIZE (CONFIG_FLASH_SIZE*1K - CONFIG_FLASH_LOAD_OFFSET - ROM_END_OFFSET) #endif +#endif /* defined(CONFIG_FLASH_USES_MAPPED_PARTITION) */ #define RAM_SIZE (CONFIG_SRAM_SIZE * 1K) #define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS From ba9c5f99dfc7a37e2ac0d8c27f890aa543adabfb Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 12 Mar 2026 09:52:27 +0000 Subject: [PATCH 46/63] [nrf fromtree] arch: arm: arm64: linker: Add support for zephyr,mapped-partition Adds support for using this new binding Signed-off-by: Jamie McCrae (cherry picked from commit f75c444c8c5af9ecdbcd3dc893394b08e5a5a032) --- include/zephyr/arch/arm64/scripts/linker.ld | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/include/zephyr/arch/arm64/scripts/linker.ld b/include/zephyr/arch/arm64/scripts/linker.ld index 3475e5310e6e..93c8b2f5db64 100644 --- a/include/zephyr/arch/arm64/scripts/linker.ld +++ b/include/zephyr/arch/arm64/scripts/linker.ld @@ -26,23 +26,28 @@ #endif #define RAMABLE_REGION RAM -#if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) - #define ROM_ADDR RAM_ADDR -#else - #define ROM_ADDR (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) -#endif - #if defined(CONFIG_ROM_END_OFFSET) #define ROM_END_OFFSET CONFIG_ROM_END_OFFSET #else #define ROM_END_OFFSET 0 #endif +#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) && defined(CONFIG_XIP) +#define ROM_ADDR (DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition))) +#define ROM_SIZE (DT_REG_SIZE(DT_CHOSEN(zephyr_code_partition)) - ROM_END_OFFSET) +#else +#if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) +#define ROM_ADDR RAM_ADDR +#else +#define ROM_ADDR (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) +#endif + #if CONFIG_FLASH_LOAD_SIZE > 0 #define ROM_SIZE (CONFIG_FLASH_LOAD_SIZE - ROM_END_OFFSET) #else #define ROM_SIZE (CONFIG_FLASH_SIZE * 1K - CONFIG_FLASH_LOAD_OFFSET - ROM_END_OFFSET) #endif +#endif /* defined(CONFIG_FLASH_USES_MAPPED_PARTITION) */ #define RAM_SIZE (CONFIG_SRAM_SIZE * 1K) #define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS From 0f3fb4107c74d5d9dca993897a56b2dd2c939e3c Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 12 Mar 2026 09:52:41 +0000 Subject: [PATCH 47/63] [nrf fromtree] arch: arm: riscv: linker: Add support for zephyr,mapped-partition Adds support for using this new binding Signed-off-by: Jamie McCrae (cherry picked from commit 8dcea32c8dd158dd5814e650a78e9f700d0875cc) --- include/zephyr/arch/riscv/common/linker.ld | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/zephyr/arch/riscv/common/linker.ld b/include/zephyr/arch/riscv/common/linker.ld index f134d609f03b..2f87e4a828da 100644 --- a/include/zephyr/arch/riscv/common/linker.ld +++ b/include/zephyr/arch/riscv/common/linker.ld @@ -35,6 +35,10 @@ #define ROM_END_OFFSET 0 #endif +#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) && defined(CONFIG_XIP) +#define ROM_BASE (DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition))) +#define ROM_SIZE (DT_REG_SIZE(DT_CHOSEN(zephyr_code_partition)) - ROM_END_OFFSET) +#else /* defined(CONFIG_FLASH_USES_MAPPED_PARTITION) && defined(CONFIG_XIP) */ #if defined(CONFIG_FLASH_LOAD_OFFSET) #define FLASH_LOAD_OFFSET CONFIG_FLASH_LOAD_OFFSET #else @@ -81,6 +85,7 @@ #define ROM_BASE CONFIG_SRAM_BASE_ADDRESS #define ROM_SIZE (KB(CONFIG_SRAM_SIZE) - ROM_END_OFFSET) #endif /* CONFIG_XIP */ +#endif /* defined(CONFIG_FLASH_USES_MAPPED_PARTITION) && defined(CONFIG_XIP) */ #define RAM_BASE CONFIG_SRAM_BASE_ADDRESS #define RAM_SIZE KB(CONFIG_SRAM_SIZE) From 73122475dccde1234b71755b0710d8d6c8f7285b Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Fri, 6 Mar 2026 13:47:05 +0000 Subject: [PATCH 48/63] [nrf fromtree] cmake: linker_script: arm: Add support for zephyr,mapped-partition Adds support for using this new binding Signed-off-by: Jamie McCrae (cherry picked from commit 96137acb4c4531ef213790381979b7780dbd22c7) --- cmake/linker_script/arm/linker.cmake | 35 ++++++++++++++++++---------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/cmake/linker_script/arm/linker.cmake b/cmake/linker_script/arm/linker.cmake index ff0c5da48460..8449997f4a87 100644 --- a/cmake/linker_script/arm/linker.cmake +++ b/cmake/linker_script/arm/linker.cmake @@ -33,23 +33,34 @@ endif() zephyr_linker_include_var(VAR APP_SHARED_ALIGN_BYTES VALUE ${region_min_align}) zephyr_linker_include_var(VAR SMEM_PARTITION_ALIGN_BYTES VALUE ${MPU_ALIGN_BYTES}) -# Note, the `+ 0` in formulas below avoids errors in cases where a Kconfig -# variable is undefined and thus expands to nothing. -math(EXPR FLASH_ADDR - "${CONFIG_FLASH_BASE_ADDRESS} + ${CONFIG_FLASH_LOAD_OFFSET} + 0" - OUTPUT_FORMAT HEXADECIMAL -) +if(CONFIG_FLASH_USES_MAPPED_PARTITION) + dt_chosen(chosen_partition_path PROPERTY "zephyr,code-partition") + dt_reg_addr(FLASH_ADDR PATH "${chosen_partition_path}") + dt_reg_size(chosen_partition_size PATH "${chosen_partition_path}") -if(CONFIG_FLASH_LOAD_SIZE GREATER 0) math(EXPR FLASH_SIZE - "(${CONFIG_FLASH_LOAD_SIZE} + 0) - (${CONFIG_ROM_END_OFFSET} + 0)" - OUTPUT_FORMAT HEXADECIMAL + "(${chosen_partition_size} + 0) - (${CONFIG_ROM_END_OFFSET} + 0)" + OUTPUT_FORMAT HEXADECIMAL ) else() - math(EXPR FLASH_SIZE - "(${CONFIG_FLASH_SIZE} + 0) * 1024 - (${CONFIG_FLASH_LOAD_OFFSET} + 0) - (${CONFIG_ROM_END_OFFSET} + 0)" - OUTPUT_FORMAT HEXADECIMAL + # Note, the `+ 0` in formulas below avoids errors in cases where a Kconfig + # variable is undefined and thus expands to nothing. + math(EXPR FLASH_ADDR + "${CONFIG_FLASH_BASE_ADDRESS} + ${CONFIG_FLASH_LOAD_OFFSET} + 0" + OUTPUT_FORMAT HEXADECIMAL ) + + if(CONFIG_FLASH_LOAD_SIZE GREATER 0) + math(EXPR FLASH_SIZE + "(${CONFIG_FLASH_LOAD_SIZE} + 0) - (${CONFIG_ROM_END_OFFSET} + 0)" + OUTPUT_FORMAT HEXADECIMAL + ) + else() + math(EXPR FLASH_SIZE + "(${CONFIG_FLASH_SIZE} + 0) * 1024 - (${CONFIG_FLASH_LOAD_OFFSET} + 0) - (${CONFIG_ROM_END_OFFSET} + 0)" + OUTPUT_FORMAT HEXADECIMAL + ) + endif() endif() set(RAM_ADDR ${CONFIG_SRAM_BASE_ADDRESS}) From 973d2dd45123c0d435d5ca8dc707fc531a257721 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 26 Feb 2026 11:43:35 +0000 Subject: [PATCH 49/63] [nrf fromtree] dts: nordic: nrf51: Update to use zephyr,mapped-partitions Updates the dts nodes switch partitions to use the new zephyr,mapped-partition compatible. Signed-off-by: Jamie McCrae (cherry picked from commit b5611a6bfc13eda8970b5ec9ff1f61b163f1e9f6) --- boards/nordic/nrf51dk/nrf51dk_nrf51822.dts | 6 +++++- boards/nordic/nrf51dongle/nrf51dongle_nrf51822.dts | 6 +++++- dts/arm/nordic/nrf51822.dtsi | 7 ++++++- dts/arm/nordic/nrf51822_qfaa.dtsi | 7 +------ dts/arm/nordic/nrf51822_qfab.dtsi | 7 +------ dts/arm/nordic/nrf51822_qfac.dtsi | 7 +------ 6 files changed, 19 insertions(+), 21 deletions(-) diff --git a/boards/nordic/nrf51dk/nrf51dk_nrf51822.dts b/boards/nordic/nrf51dk/nrf51dk_nrf51822.dts index c5c288182791..38d3182050bd 100644 --- a/boards/nordic/nrf51dk/nrf51dk_nrf51822.dts +++ b/boards/nordic/nrf51dk/nrf51dk_nrf51822.dts @@ -160,26 +160,30 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x8000>; }; slot0_partition: partition@8000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00008000 0x1b000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x1b000>; }; storage_partition: partition@3e000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003e000 0x00002000>; }; diff --git a/boards/nordic/nrf51dongle/nrf51dongle_nrf51822.dts b/boards/nordic/nrf51dongle/nrf51dongle_nrf51822.dts index 07de5fadcaab..be2f3677c507 100644 --- a/boards/nordic/nrf51dongle/nrf51dongle_nrf51822.dts +++ b/boards/nordic/nrf51dongle/nrf51dongle_nrf51822.dts @@ -88,26 +88,30 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x8000>; }; slot0_partition: partition@8000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00008000 0x1b000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x1b000>; }; storage_partition: partition@3e000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003e000 0x00002000>; }; diff --git a/dts/arm/nordic/nrf51822.dtsi b/dts/arm/nordic/nrf51822.dtsi index 5644ea2787bf..d5445555787f 100644 --- a/dts/arm/nordic/nrf51822.dtsi +++ b/dts/arm/nordic/nrf51822.dtsi @@ -32,6 +32,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@10000000 { compatible = "nordic,nrf-ficr"; reg = <0x10000000 0x1000>; @@ -309,7 +311,7 @@ flash_controller: flash-controller@4001e000 { compatible = "nordic,nrf51-flash-controller"; reg = <0x4001e000 0x1000>; - + ranges; #address-cells = <1>; #size-cells = <1>; @@ -317,6 +319,9 @@ compatible = "soc-nv-flash"; erase-block-size = <1024>; write-block-size = <4>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; }; }; diff --git a/dts/arm/nordic/nrf51822_qfaa.dtsi b/dts/arm/nordic/nrf51822_qfaa.dtsi index b2ce647684e9..c2166a6134c7 100644 --- a/dts/arm/nordic/nrf51822_qfaa.dtsi +++ b/dts/arm/nordic/nrf51822_qfaa.dtsi @@ -9,15 +9,10 @@ &flash0 { reg = <0x00000000 DT_SIZE_K(256)>; + ranges = <0x0 0x00000000 DT_SIZE_K(256)>; }; &sram0 { reg = <0x20000000 DT_SIZE_K(16)>; ranges = <0x0 0x20000000 DT_SIZE_K(16)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf51822_qfab.dtsi b/dts/arm/nordic/nrf51822_qfab.dtsi index d4327bb2b755..89d26d0daf5b 100644 --- a/dts/arm/nordic/nrf51822_qfab.dtsi +++ b/dts/arm/nordic/nrf51822_qfab.dtsi @@ -9,15 +9,10 @@ &flash0 { reg = <0x00000000 DT_SIZE_K(128)>; + ranges = <0x0 0x00000000 DT_SIZE_K(128)>; }; &sram0 { reg = <0x20000000 DT_SIZE_K(16)>; ranges = <0x0 0x20000000 DT_SIZE_K(16)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf51822_qfac.dtsi b/dts/arm/nordic/nrf51822_qfac.dtsi index f41890945e47..350d552e6661 100644 --- a/dts/arm/nordic/nrf51822_qfac.dtsi +++ b/dts/arm/nordic/nrf51822_qfac.dtsi @@ -9,15 +9,10 @@ &flash0 { reg = <0x00000000 DT_SIZE_K(256)>; + ranges = <0x0 0x00000000 DT_SIZE_K(256)>; }; &sram0 { reg = <0x20000000 DT_SIZE_K(32)>; ranges = <0x0 0x20000000 DT_SIZE_K(32)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; From 3035ea93f2adbe7459f620f66653a4095e983376 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 26 Feb 2026 11:43:53 +0000 Subject: [PATCH 50/63] [nrf fromtree] dts: nordic: nrf52: Update to use zephyr,mapped-partitions Updates the dts nodes switch partitions to use the new zephyr,mapped-partition compatible. Signed-off-by: Jamie McCrae (cherry picked from commit ab202cdb5e329ec0dd830845fdeb0864e3661578) --- boards/nordic/nrf52833dk/nrf52833dk_nrf52820.dts | 6 +++++- boards/nordic/nrf52833dk/nrf52833dk_nrf52833.dts | 6 +++++- boards/nordic/nrf52840dk/nrf52840dk_nrf52811.dts | 6 +++++- boards/nordic/nrf52dk/nrf52dk_nrf52805.dts | 6 +++++- boards/nordic/nrf52dk/nrf52dk_nrf52810.dts | 6 +++++- boards/nordic/nrf52dk/nrf52dk_nrf52832.dts | 6 +++++- boards/nordic/thingy52/thingy52_nrf52832.dts | 7 ++++++- dts/arm/nordic/nrf52805.dtsi | 9 ++++++++- dts/arm/nordic/nrf52805_caaa.dtsi | 10 ---------- dts/arm/nordic/nrf52810.dtsi | 9 ++++++++- dts/arm/nordic/nrf52810_qfaa.dtsi | 10 ---------- dts/arm/nordic/nrf52811.dtsi | 9 ++++++++- dts/arm/nordic/nrf52811_qfaa.dtsi | 10 ---------- dts/arm/nordic/nrf52820.dtsi | 9 ++++++++- dts/arm/nordic/nrf52820_qdaa.dtsi | 10 ---------- dts/arm/nordic/nrf52832.dtsi | 7 ++++++- dts/arm/nordic/nrf52832_ciaa.dtsi | 7 +------ dts/arm/nordic/nrf52832_qfaa.dtsi | 7 +------ dts/arm/nordic/nrf52832_qfab.dtsi | 7 +------ dts/arm/nordic/nrf52833.dtsi | 9 ++++++++- dts/arm/nordic/nrf52833_qdaa.dtsi | 10 ---------- dts/arm/nordic/nrf52833_qiaa.dtsi | 10 ---------- dts/arm/nordic/nrf52840.dtsi | 5 ++--- 23 files changed, 87 insertions(+), 94 deletions(-) diff --git a/boards/nordic/nrf52833dk/nrf52833dk_nrf52820.dts b/boards/nordic/nrf52833dk/nrf52833dk_nrf52820.dts index 6516a779928f..8bc2bda0660d 100644 --- a/boards/nordic/nrf52833dk/nrf52833dk_nrf52820.dts +++ b/boards/nordic/nrf52833dk/nrf52833dk_nrf52820.dts @@ -161,26 +161,30 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x17000>; }; slot1_partition: partition@23000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00023000 0x17000>; }; storage_partition: partition@3a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0003a000 0x00006000>; }; diff --git a/boards/nordic/nrf52833dk/nrf52833dk_nrf52833.dts b/boards/nordic/nrf52833dk/nrf52833dk_nrf52833.dts index 098632f622b5..90609c425755 100644 --- a/boards/nordic/nrf52833dk/nrf52833dk_nrf52833.dts +++ b/boards/nordic/nrf52833dk/nrf52833dk_nrf52833.dts @@ -231,26 +231,30 @@ arduino_spi: &spi3 { &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x37000>; }; slot1_partition: partition@43000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00043000 0x37000>; }; storage_partition: partition@7a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0007a000 0x00006000>; }; diff --git a/boards/nordic/nrf52840dk/nrf52840dk_nrf52811.dts b/boards/nordic/nrf52840dk/nrf52840dk_nrf52811.dts index 6dc7731389f8..61904879381b 100644 --- a/boards/nordic/nrf52840dk/nrf52840dk_nrf52811.dts +++ b/boards/nordic/nrf52840dk/nrf52840dk_nrf52811.dts @@ -164,26 +164,30 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0xe000>; }; slot1_partition: partition@1a000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x0001a000 0xe000>; }; storage_partition: partition@28000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00028000 0x00008000>; }; diff --git a/boards/nordic/nrf52dk/nrf52dk_nrf52805.dts b/boards/nordic/nrf52dk/nrf52dk_nrf52805.dts index a27bae1c72cf..704f11325b86 100644 --- a/boards/nordic/nrf52dk/nrf52dk_nrf52805.dts +++ b/boards/nordic/nrf52dk/nrf52dk_nrf52805.dts @@ -139,26 +139,30 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0xe000>; }; slot1_partition: partition@1a000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x0001a000 0xe000>; }; storage_partition: partition@28000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00028000 0x00008000>; }; diff --git a/boards/nordic/nrf52dk/nrf52dk_nrf52810.dts b/boards/nordic/nrf52dk/nrf52dk_nrf52810.dts index 8c72a1b5fa30..699694bcb00d 100644 --- a/boards/nordic/nrf52dk/nrf52dk_nrf52810.dts +++ b/boards/nordic/nrf52dk/nrf52dk_nrf52810.dts @@ -141,26 +141,30 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0xe000>; }; slot1_partition: partition@1a000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x0001a000 0xe000>; }; storage_partition: partition@28000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00028000 0x00008000>; }; diff --git a/boards/nordic/nrf52dk/nrf52dk_nrf52832.dts b/boards/nordic/nrf52dk/nrf52dk_nrf52832.dts index 9f1b167c2165..5dc66561195e 100644 --- a/boards/nordic/nrf52dk/nrf52dk_nrf52832.dts +++ b/boards/nordic/nrf52dk/nrf52dk_nrf52832.dts @@ -228,26 +228,30 @@ arduino_spi: &spi2 { &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x37000>; }; slot1_partition: partition@43000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00043000 0x37000>; }; storage_partition: partition@7a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0007a000 0x00006000>; }; diff --git a/boards/nordic/thingy52/thingy52_nrf52832.dts b/boards/nordic/thingy52/thingy52_nrf52832.dts index a023b06e55b9..1fa794e84f06 100644 --- a/boards/nordic/thingy52/thingy52_nrf52832.dts +++ b/boards/nordic/thingy52/thingy52_nrf52832.dts @@ -195,26 +195,30 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0xc000>; }; slot0_partition: partition@c000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000c000 0x32000>; }; slot1_partition: partition@3e000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x0003e000 0x32000>; }; scratch_partition: partition@70000 { + compatible = "zephyr,mapped-partition"; label = "image-scratch"; reg = <0x00070000 0xa000>; }; @@ -227,6 +231,7 @@ * if enabled. */ storage_partition: partition@7a000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x0007a000 0x00006000>; }; diff --git a/dts/arm/nordic/nrf52805.dtsi b/dts/arm/nordic/nrf52805.dtsi index 0d564955f8c1..ce9ce4e0f816 100644 --- a/dts/arm/nordic/nrf52805.dtsi +++ b/dts/arm/nordic/nrf52805.dtsi @@ -37,6 +37,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@10000000 { compatible = "nordic,nrf-ficr"; reg = <0x10000000 0x1000>; @@ -318,8 +320,8 @@ flash_controller: flash-controller@4001e000 { compatible = "nordic,nrf52-flash-controller"; reg = <0x4001e000 0x1000>; + ranges; partial-erase; - #address-cells = <1>; #size-cells = <1>; @@ -327,6 +329,11 @@ compatible = "soc-nv-flash"; erase-block-size = <4096>; write-block-size = <4>; + reg = <0x00000000 DT_SIZE_K(192)>; + ranges = <0x0 0x00000000 DT_SIZE_K(192)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; }; }; diff --git a/dts/arm/nordic/nrf52805_caaa.dtsi b/dts/arm/nordic/nrf52805_caaa.dtsi index 38daaff88d0e..c796fa94acf2 100644 --- a/dts/arm/nordic/nrf52805_caaa.dtsi +++ b/dts/arm/nordic/nrf52805_caaa.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(192)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(24)>; ranges = <0x0 0x20000000 DT_SIZE_K(24)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52810.dtsi b/dts/arm/nordic/nrf52810.dtsi index d95751752109..95e636ac2cb5 100644 --- a/dts/arm/nordic/nrf52810.dtsi +++ b/dts/arm/nordic/nrf52810.dtsi @@ -45,6 +45,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@10000000 { compatible = "nordic,nrf-ficr"; reg = <0x10000000 0x1000>; @@ -348,8 +350,8 @@ flash_controller: flash-controller@4001e000 { compatible = "nordic,nrf52-flash-controller"; reg = <0x4001e000 0x1000>; + ranges; partial-erase; - #address-cells = <1>; #size-cells = <1>; @@ -357,6 +359,11 @@ compatible = "soc-nv-flash"; erase-block-size = <4096>; write-block-size = <4>; + reg = <0x00000000 DT_SIZE_K(192)>; + ranges = <0x0 0x00000000 DT_SIZE_K(192)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; }; }; diff --git a/dts/arm/nordic/nrf52810_qfaa.dtsi b/dts/arm/nordic/nrf52810_qfaa.dtsi index 344eca772f37..6c5484ae4e2c 100644 --- a/dts/arm/nordic/nrf52810_qfaa.dtsi +++ b/dts/arm/nordic/nrf52810_qfaa.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(192)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(24)>; ranges = <0x0 0x20000000 DT_SIZE_K(24)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52811.dtsi b/dts/arm/nordic/nrf52811.dtsi index 5c55cf44edcf..b46e9c19a2fc 100644 --- a/dts/arm/nordic/nrf52811.dtsi +++ b/dts/arm/nordic/nrf52811.dtsi @@ -45,6 +45,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@10000000 { compatible = "nordic,nrf-ficr"; reg = <0x10000000 0x1000>; @@ -375,8 +377,8 @@ flash_controller: flash-controller@4001e000 { compatible = "nordic,nrf52-flash-controller"; reg = <0x4001e000 0x1000>; + ranges; partial-erase; - #address-cells = <1>; #size-cells = <1>; @@ -384,6 +386,11 @@ compatible = "soc-nv-flash"; erase-block-size = <4096>; write-block-size = <4>; + reg = <0x00000000 DT_SIZE_K(192)>; + ranges = <0x0 0x00000000 DT_SIZE_K(192)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; }; }; diff --git a/dts/arm/nordic/nrf52811_qfaa.dtsi b/dts/arm/nordic/nrf52811_qfaa.dtsi index 18eacff06234..e22d206cbabc 100644 --- a/dts/arm/nordic/nrf52811_qfaa.dtsi +++ b/dts/arm/nordic/nrf52811_qfaa.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(192)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(24)>; ranges = <0x0 0x20000000 DT_SIZE_K(24)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52820.dtsi b/dts/arm/nordic/nrf52820.dtsi index d67d81686a4a..2ba1de52bd99 100644 --- a/dts/arm/nordic/nrf52820.dtsi +++ b/dts/arm/nordic/nrf52820.dtsi @@ -44,6 +44,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@10000000 { compatible = "nordic,nrf-ficr"; reg = <0x10000000 0x1000>; @@ -386,8 +388,8 @@ flash_controller: flash-controller@4001e000 { compatible = "nordic,nrf52-flash-controller"; reg = <0x4001e000 0x1000>; + ranges; partial-erase; - #address-cells = <1>; #size-cells = <1>; @@ -395,6 +397,11 @@ compatible = "soc-nv-flash"; erase-block-size = <4096>; write-block-size = <4>; + reg = <0x00000000 DT_SIZE_K(256)>; + ranges = <0x0 0x00000000 DT_SIZE_K(256)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; }; }; diff --git a/dts/arm/nordic/nrf52820_qdaa.dtsi b/dts/arm/nordic/nrf52820_qdaa.dtsi index 585926d1a166..3f94d2637c59 100644 --- a/dts/arm/nordic/nrf52820_qdaa.dtsi +++ b/dts/arm/nordic/nrf52820_qdaa.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(256)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(32)>; ranges = <0x0 0x20000000 DT_SIZE_K(32)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52832.dtsi b/dts/arm/nordic/nrf52832.dtsi index a127ffb194d9..cfef9324daaf 100644 --- a/dts/arm/nordic/nrf52832.dtsi +++ b/dts/arm/nordic/nrf52832.dtsi @@ -45,6 +45,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@10000000 { compatible = "nordic,nrf-ficr"; reg = <0x10000000 0x1000>; @@ -415,7 +417,7 @@ flash_controller: flash-controller@4001e000 { compatible = "nordic,nrf52-flash-controller"; reg = <0x4001e000 0x1000>; - + ranges; #address-cells = <1>; #size-cells = <1>; @@ -423,6 +425,9 @@ compatible = "soc-nv-flash"; erase-block-size = <4096>; write-block-size = <4>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; }; }; diff --git a/dts/arm/nordic/nrf52832_ciaa.dtsi b/dts/arm/nordic/nrf52832_ciaa.dtsi index 28848a4d1213..e9f8c99279ea 100644 --- a/dts/arm/nordic/nrf52832_ciaa.dtsi +++ b/dts/arm/nordic/nrf52832_ciaa.dtsi @@ -9,15 +9,10 @@ &flash0 { reg = <0x00000000 DT_SIZE_K(512)>; + ranges = <0x0 0x00000000 DT_SIZE_K(512)>; }; &sram0 { reg = <0x20000000 DT_SIZE_K(64)>; ranges = <0x0 0x20000000 DT_SIZE_K(64)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52832_qfaa.dtsi b/dts/arm/nordic/nrf52832_qfaa.dtsi index 28848a4d1213..e9f8c99279ea 100644 --- a/dts/arm/nordic/nrf52832_qfaa.dtsi +++ b/dts/arm/nordic/nrf52832_qfaa.dtsi @@ -9,15 +9,10 @@ &flash0 { reg = <0x00000000 DT_SIZE_K(512)>; + ranges = <0x0 0x00000000 DT_SIZE_K(512)>; }; &sram0 { reg = <0x20000000 DT_SIZE_K(64)>; ranges = <0x0 0x20000000 DT_SIZE_K(64)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52832_qfab.dtsi b/dts/arm/nordic/nrf52832_qfab.dtsi index 5c0d3dd8abdb..1daf479f8bea 100644 --- a/dts/arm/nordic/nrf52832_qfab.dtsi +++ b/dts/arm/nordic/nrf52832_qfab.dtsi @@ -9,15 +9,10 @@ &flash0 { reg = <0x00000000 DT_SIZE_K(256)>; + ranges = <0x0 0x00000000 DT_SIZE_K(256)>; }; &sram0 { reg = <0x20000000 DT_SIZE_K(32)>; ranges = <0x0 0x20000000 DT_SIZE_K(32)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52833.dtsi b/dts/arm/nordic/nrf52833.dtsi index 33df68336231..11b3e5c0d348 100644 --- a/dts/arm/nordic/nrf52833.dtsi +++ b/dts/arm/nordic/nrf52833.dtsi @@ -45,6 +45,8 @@ }; soc { + compatible = "simple-bus"; + ficr: ficr@10000000 { compatible = "nordic,nrf-ficr"; reg = <0x10000000 0x1000>; @@ -432,8 +434,8 @@ flash_controller: flash-controller@4001e000 { compatible = "nordic,nrf52-flash-controller"; reg = <0x4001e000 0x1000>; + ranges; partial-erase; - #address-cells = <1>; #size-cells = <1>; @@ -441,6 +443,11 @@ compatible = "soc-nv-flash"; erase-block-size = <4096>; write-block-size = <4>; + reg = <0x00000000 DT_SIZE_K(512)>; + ranges = <0x0 0x00000000 DT_SIZE_K(512)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; }; }; diff --git a/dts/arm/nordic/nrf52833_qdaa.dtsi b/dts/arm/nordic/nrf52833_qdaa.dtsi index 2c4ebaa0014a..c18fda8a0f08 100644 --- a/dts/arm/nordic/nrf52833_qdaa.dtsi +++ b/dts/arm/nordic/nrf52833_qdaa.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(512)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(128)>; ranges = <0x0 0x20000000 DT_SIZE_K(128)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52833_qiaa.dtsi b/dts/arm/nordic/nrf52833_qiaa.dtsi index 2b15451b3306..e6487d077f9c 100644 --- a/dts/arm/nordic/nrf52833_qiaa.dtsi +++ b/dts/arm/nordic/nrf52833_qiaa.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(512)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(128)>; ranges = <0x0 0x20000000 DT_SIZE_K(128)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf52840.dtsi b/dts/arm/nordic/nrf52840.dtsi index ee290fb74561..6ef3d3e0bb6a 100644 --- a/dts/arm/nordic/nrf52840.dtsi +++ b/dts/arm/nordic/nrf52840.dtsi @@ -427,9 +427,8 @@ flash_controller: flash-controller@4001e000 { compatible = "nordic,nrf52-flash-controller"; reg = <0x4001e000 0x1000>; - ranges = <0x0 0x0 DT_SIZE_K(1024)>; + ranges; partial-erase; - status = "okay"; #address-cells = <1>; #size-cells = <1>; @@ -438,7 +437,7 @@ erase-block-size = <4096>; write-block-size = <4>; reg = <0x0 DT_SIZE_K(1024)>; - ranges; + ranges = <0x0 0x0 DT_SIZE_K(1024)>; status = "okay"; #address-cells = <1>; #size-cells = <1>; From 28bf7afe0920eda91821c1ca9bc164af43ceff04 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 26 Feb 2026 11:44:18 +0000 Subject: [PATCH 51/63] [nrf fromtree] dts: nordic: nrf91: Update to use zephyr,mapped-partitions Updates the dts nodes switch partitions to use the new zephyr,mapped-partition compatible. Signed-off-by: Jamie McCrae (cherry picked from commit 1a9f1b640f9510b6448849fc767601cf5b3d3968) --- dts/arm/nordic/nrf91.dtsi | 22 ++++++++++++++++++++++ dts/arm/nordic/nrf9131_laca.dtsi | 10 ---------- dts/arm/nordic/nrf9131_ns_laca.dtsi | 10 ---------- dts/arm/nordic/nrf9151_laca.dtsi | 10 ---------- dts/arm/nordic/nrf9151_ns_laca.dtsi | 10 ---------- dts/arm/nordic/nrf9160_ns_sica.dtsi | 10 ---------- dts/arm/nordic/nrf9160_sica.dtsi | 10 ---------- dts/arm/nordic/nrf9161_laca.dtsi | 10 ---------- dts/arm/nordic/nrf9161_ns_laca.dtsi | 10 ---------- dts/arm/nordic/nrf91_ns.dtsi | 22 ++++++++++++++++++++++ dts/arm/nordic/nrf91_peripherals.dtsi | 15 --------------- dts/vendor/nordic/nrf91xx_partition.dtsi | 15 ++++++++++++--- 12 files changed, 56 insertions(+), 98 deletions(-) diff --git a/dts/arm/nordic/nrf91.dtsi b/dts/arm/nordic/nrf91.dtsi index 74afa25f76a7..b384ccb38beb 100644 --- a/dts/arm/nordic/nrf91.dtsi +++ b/dts/arm/nordic/nrf91.dtsi @@ -33,6 +33,8 @@ }; soc { + compatible = "simple-bus"; + sram0: memory@20000000 { compatible = "mmio-sram"; #address-cells = <1>; @@ -49,6 +51,26 @@ #include "nrf91_peripherals.dtsi" }; + flash_controller: flash-controller@50039000 { + compatible = "nordic,nrf91-flash-controller"; + reg = <0x50039000 0x1000>; + ranges; + partial-erase; + #address-cells = <1>; + #size-cells = <1>; + + flash0: flash@0 { + compatible = "soc-nv-flash"; + erase-block-size = <4096>; + write-block-size = <4>; + reg = <0x00000000 DT_SIZE_K(1024)>; + ranges = <0x0 0x00000000 DT_SIZE_K(1024)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; + }; + }; + /* Additional Secure peripherals */ cryptocell: crypto@50840000 { compatible = "arm,cryptocell-310"; diff --git a/dts/arm/nordic/nrf9131_laca.dtsi b/dts/arm/nordic/nrf9131_laca.dtsi index 30c526af5d32..cfeaffb87285 100644 --- a/dts/arm/nordic/nrf9131_laca.dtsi +++ b/dts/arm/nordic/nrf9131_laca.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(256)>; ranges = <0x0 0x20000000 DT_SIZE_K(256)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf9131_ns_laca.dtsi b/dts/arm/nordic/nrf9131_ns_laca.dtsi index ab95bee3deb0..6069f8b6c926 100644 --- a/dts/arm/nordic/nrf9131_ns_laca.dtsi +++ b/dts/arm/nordic/nrf9131_ns_laca.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(256)>; ranges = <0x0 0x20000000 DT_SIZE_K(256)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf9151_laca.dtsi b/dts/arm/nordic/nrf9151_laca.dtsi index 30c526af5d32..cfeaffb87285 100644 --- a/dts/arm/nordic/nrf9151_laca.dtsi +++ b/dts/arm/nordic/nrf9151_laca.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(256)>; ranges = <0x0 0x20000000 DT_SIZE_K(256)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf9151_ns_laca.dtsi b/dts/arm/nordic/nrf9151_ns_laca.dtsi index ab95bee3deb0..6069f8b6c926 100644 --- a/dts/arm/nordic/nrf9151_ns_laca.dtsi +++ b/dts/arm/nordic/nrf9151_ns_laca.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(256)>; ranges = <0x0 0x20000000 DT_SIZE_K(256)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf9160_ns_sica.dtsi b/dts/arm/nordic/nrf9160_ns_sica.dtsi index 3fad45ebb2d9..a2b3025a694a 100644 --- a/dts/arm/nordic/nrf9160_ns_sica.dtsi +++ b/dts/arm/nordic/nrf9160_ns_sica.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(256)>; ranges = <0x0 0x20000000 DT_SIZE_K(256)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf9160_sica.dtsi b/dts/arm/nordic/nrf9160_sica.dtsi index e00d03fb5afc..f7db48076e33 100644 --- a/dts/arm/nordic/nrf9160_sica.dtsi +++ b/dts/arm/nordic/nrf9160_sica.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(256)>; ranges = <0x0 0x20000000 DT_SIZE_K(256)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf9161_laca.dtsi b/dts/arm/nordic/nrf9161_laca.dtsi index 30c526af5d32..cfeaffb87285 100644 --- a/dts/arm/nordic/nrf9161_laca.dtsi +++ b/dts/arm/nordic/nrf9161_laca.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(256)>; ranges = <0x0 0x20000000 DT_SIZE_K(256)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf9161_ns_laca.dtsi b/dts/arm/nordic/nrf9161_ns_laca.dtsi index ab95bee3deb0..6069f8b6c926 100644 --- a/dts/arm/nordic/nrf9161_ns_laca.dtsi +++ b/dts/arm/nordic/nrf9161_ns_laca.dtsi @@ -7,17 +7,7 @@ #include #include -&flash0 { - reg = <0x00000000 DT_SIZE_K(1024)>; -}; - &sram0 { reg = <0x20000000 DT_SIZE_K(256)>; ranges = <0x0 0x20000000 DT_SIZE_K(256)>; }; - -/ { - soc { - compatible = "simple-bus"; - }; -}; diff --git a/dts/arm/nordic/nrf91_ns.dtsi b/dts/arm/nordic/nrf91_ns.dtsi index 7d52cd28902c..20c962595d9b 100644 --- a/dts/arm/nordic/nrf91_ns.dtsi +++ b/dts/arm/nordic/nrf91_ns.dtsi @@ -33,6 +33,8 @@ }; soc { + compatible = "simple-bus"; + sram0: memory@20000000 { compatible = "mmio-sram"; #address-cells = <1>; @@ -49,6 +51,26 @@ #include "nrf91_peripherals.dtsi" }; + flash_controller: flash-controller@40039000 { + compatible = "nordic,nrf91-flash-controller"; + reg = <0x40039000 0x1000>; + ranges; + partial-erase; + #address-cells = <1>; + #size-cells = <1>; + + flash0: flash@0 { + compatible = "soc-nv-flash"; + erase-block-size = <4096>; + write-block-size = <4>; + reg = <0x00000000 DT_SIZE_K(1024)>; + ranges = <0x0 0x00000000 DT_SIZE_K(1024)>; + status = "okay"; + #address-cells = <1>; + #size-cells = <1>; + }; + }; + /* * GPIOTE1 is always accessible as a non-secure peripheral, * so we give it the 'gpiote' label for use when building diff --git a/dts/arm/nordic/nrf91_peripherals.dtsi b/dts/arm/nordic/nrf91_peripherals.dtsi index 1108b6f66501..d7a8f8b7d0af 100644 --- a/dts/arm/nordic/nrf91_peripherals.dtsi +++ b/dts/arm/nordic/nrf91_peripherals.dtsi @@ -4,21 +4,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -flash_controller: flash-controller@39000 { - compatible = "nordic,nrf91-flash-controller"; - reg = <0x39000 0x1000>; - partial-erase; - - #address-cells = <1>; - #size-cells = <1>; - - flash0: flash@0 { - compatible = "soc-nv-flash"; - erase-block-size = <4096>; - write-block-size = <4>; - }; -}; - adc: adc@e000 { compatible = "nordic,nrf-saadc"; reg = <0xe000 0x1000>; diff --git a/dts/vendor/nordic/nrf91xx_partition.dtsi b/dts/vendor/nordic/nrf91xx_partition.dtsi index f1984fb85a53..2b86c62fe4ee 100644 --- a/dts/vendor/nordic/nrf91xx_partition.dtsi +++ b/dts/vendor/nordic/nrf91xx_partition.dtsi @@ -25,17 +25,18 @@ * otherwise unused (32 KB) */ partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x10000>; }; slot0_partition: partition@10000 { - compatible = "fixed-subpartitions"; + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00010000 0x70000>; ranges = <0x0 0x10000 0x70000>; @@ -43,18 +44,20 @@ #size-cells = <1>; slot0_s_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0-secure"; reg = <0x00000000 0x40000>; }; slot0_ns_partition: partition@40000 { + compatible = "zephyr,mapped-partition"; label = "image-0-nonsecure"; reg = <0x00040000 0x30000>; }; }; slot1_partition: partition@80000 { - compatible = "fixed-subpartitions"; + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00080000 0x70000>; ranges = <0x0 0x80000 0x70000>; @@ -62,32 +65,38 @@ #size-cells = <1>; slot1_s_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-1-secure"; reg = <0x00000000 0x40000>; }; slot1_ns_partition: partition@40000 { + compatible = "zephyr,mapped-partition"; label = "image-1-nonsecure"; reg = <0x00040000 0x30000>; }; }; tfm_ps_partition: partition@f0000 { + compatible = "zephyr,mapped-partition"; label = "tfm-ps"; reg = <0x000f0000 0x00004000>; }; tfm_its_partition: partition@f4000 { + compatible = "zephyr,mapped-partition"; label = "tfm-its"; reg = <0x000f4000 0x00002000>; }; tfm_otp_partition: partition@f6000 { + compatible = "zephyr,mapped-partition"; label = "tfm-otp"; reg = <0x000f6000 0x00002000>; }; storage_partition: partition@f8000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000f8000 0x00008000>; }; From 9240013e0a922313424347e6d2eb05436db90ee9 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 26 Feb 2026 11:44:37 +0000 Subject: [PATCH 52/63] [nrf fromtree] dts: nordic: nrf54lm20: Update to use zephyr,mapped-partitions Updates the dts nodes switch partitions to use the new zephyr,mapped-partition compatible. Signed-off-by: Jamie McCrae (cherry picked from commit 6b34b4d013bcab0a6d8f0e546e8a8e58cc5394f0) --- .../nordic/nrf54lm20dk/nrf54lm20_a_b_cpuflpr_common.dtsi | 1 + dts/vendor/nordic/nrf54lm20_a_b.dtsi | 1 + dts/vendor/nordic/nrf54lm20_a_b_cpuapp_ns_partition.dtsi | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/boards/nordic/nrf54lm20dk/nrf54lm20_a_b_cpuflpr_common.dtsi b/boards/nordic/nrf54lm20dk/nrf54lm20_a_b_cpuflpr_common.dtsi index f7969b3de49c..a84d2623fd94 100644 --- a/boards/nordic/nrf54lm20dk/nrf54lm20_a_b_cpuflpr_common.dtsi +++ b/boards/nordic/nrf54lm20dk/nrf54lm20_a_b_cpuflpr_common.dtsi @@ -19,6 +19,7 @@ ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/dts/vendor/nordic/nrf54lm20_a_b.dtsi b/dts/vendor/nordic/nrf54lm20_a_b.dtsi index 889935b46bd3..e4619349a3ca 100644 --- a/dts/vendor/nordic/nrf54lm20_a_b.dtsi +++ b/dts/vendor/nordic/nrf54lm20_a_b.dtsi @@ -888,6 +888,7 @@ rram_controller: rram-controller@5004e000 { compatible = "nordic,rram-controller"; reg = <0x5004e000 0x1000>; + ranges; interrupts = <78 NRF_DEFAULT_IRQ_PRIORITY>; #address-cells = <1>; #size-cells = <1>; diff --git a/dts/vendor/nordic/nrf54lm20_a_b_cpuapp_ns_partition.dtsi b/dts/vendor/nordic/nrf54lm20_a_b_cpuapp_ns_partition.dtsi index ea354b033632..cfdb6c56097f 100644 --- a/dts/vendor/nordic/nrf54lm20_a_b_cpuapp_ns_partition.dtsi +++ b/dts/vendor/nordic/nrf54lm20_a_b_cpuapp_ns_partition.dtsi @@ -48,7 +48,7 @@ * otherwise unused (32 KB) */ partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; @@ -59,31 +59,37 @@ * needs to happen both in the flash_layout.h and in this file at the same time. */ slot0_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000000 DT_SIZE_K(512)>; }; tfm_ps_partition: partition@80000 { + compatible = "zephyr,mapped-partition"; label = "tfm-ps"; reg = <0x00080000 DT_SIZE_K(16)>; }; tfm_its_partition: partition@84000 { + compatible = "zephyr,mapped-partition"; label = "tfm-its"; reg = <0x00084000 DT_SIZE_K(16)>; }; tfm_otp_partition: partition@88000 { + compatible = "zephyr,mapped-partition"; label = "tfm-otp"; reg = <0x00088000 DT_SIZE_K(8)>; }; slot0_ns_partition: partition@8a000 { + compatible = "zephyr,mapped-partition"; label = "image-0-nonsecure"; reg = <0x0008a000 DT_SIZE_K(1452)>; }; storage_partition: partition@1f5000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x001f5000 DT_SIZE_K(32)>; }; From 2e7df7c25d837c1efbfec4f08c1f2cfd56de056a Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 26 Feb 2026 10:41:13 +0000 Subject: [PATCH 53/63] [nrf fromtree] dts: nordic: nrf54l[05,10,15]: Update to use zephyr,mapped-partitions Updates the dts nodes switch partitions to use the new zephyr,mapped-partition compatible. Signed-off-by: Jamie McCrae (cherry picked from commit 3ac85125450c73c3345342978bbcc27ec3fa14b8) --- .../bl54l15_dvk_nrf54l15_cpuflpr.dts | 2 +- .../bl54l15u_dvk_nrf54l15_cpuflpr.dts | 2 +- .../nrf54l15dk_nrf54l15_cpuflpr.dts | 1 + .../nrf54l15tag_nrf54l15_cpuflpr.dts | 1 + .../nrf54l15tag_nrf54l15_cpuflpr_xip.dts | 1 + .../panb611evb_nrf54l15_cpuflpr.dts | 2 +- .../raytac_an54lq_db_15_nrf54l15_cpuflpr.dts | 2 +- .../xiao_nrf54l15_nrf54l15_cpuflpr.dts | 2 +- .../ophelia4ev_nrf54l15_cpuflpr.dts | 2 +- dts/vendor/nordic/nrf54l10_cpuapp_ns.dtsi | 11 +---- .../nordic/nrf54l10_cpuapp_ns_partition.dtsi | 8 +++- dts/vendor/nordic/nrf54l15_cpuapp_ns.dtsi | 11 +---- .../nordic/nrf54l15_cpuapp_ns_partition.dtsi | 8 +++- .../nordic/nrf54l15_cpuapp_partition.dtsi | 8 +++- dts/vendor/nordic/nrf54l_05_10_15.dtsi | 4 +- .../boards/nrf54l15dk_nrf54l15_cpuapp.overlay | 7 ++- .../boards/ophelia4ev_nrf54l15_cpuapp.overlay | 46 +------------------ samples/subsys/fs/fs_sample/sample.yaml | 9 ++-- 18 files changed, 43 insertions(+), 84 deletions(-) diff --git a/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l15_cpuflpr.dts b/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l15_cpuflpr.dts index 0f780f081f54..df912059cc65 100644 --- a/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l15_cpuflpr.dts +++ b/boards/ezurio/bl54l15_dvk/bl54l15_dvk_nrf54l15_cpuflpr.dts @@ -24,12 +24,12 @@ &cpuflpr_rram { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/boards/ezurio/bl54l15u_dvk/bl54l15u_dvk_nrf54l15_cpuflpr.dts b/boards/ezurio/bl54l15u_dvk/bl54l15u_dvk_nrf54l15_cpuflpr.dts index b35c2a411e01..f51574f254c0 100644 --- a/boards/ezurio/bl54l15u_dvk/bl54l15u_dvk_nrf54l15_cpuflpr.dts +++ b/boards/ezurio/bl54l15u_dvk/bl54l15u_dvk_nrf54l15_cpuflpr.dts @@ -24,12 +24,12 @@ &cpuflpr_rram { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuflpr.dts b/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuflpr.dts index c5f6d29e205b..f4cef37e5282 100644 --- a/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuflpr.dts +++ b/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuflpr.dts @@ -29,6 +29,7 @@ ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr.dts b/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr.dts index 26bdbe51a22d..8839a482e027 100644 --- a/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr.dts +++ b/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr.dts @@ -21,6 +21,7 @@ ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr_xip.dts b/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr_xip.dts index 26bdbe51a22d..8839a482e027 100644 --- a/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr_xip.dts +++ b/boards/nordic/nrf54l15tag/nrf54l15tag_nrf54l15_cpuflpr_xip.dts @@ -21,6 +21,7 @@ ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/boards/panasonic/panb611evb/panb611evb_nrf54l15_cpuflpr.dts b/boards/panasonic/panb611evb/panb611evb_nrf54l15_cpuflpr.dts index a7806ec7a9dd..fad9a3dd9a39 100644 --- a/boards/panasonic/panb611evb/panb611evb_nrf54l15_cpuflpr.dts +++ b/boards/panasonic/panb611evb/panb611evb_nrf54l15_cpuflpr.dts @@ -30,12 +30,12 @@ &cpuflpr_rram { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/boards/raytac/an54lq_db_15/raytac_an54lq_db_15_nrf54l15_cpuflpr.dts b/boards/raytac/an54lq_db_15/raytac_an54lq_db_15_nrf54l15_cpuflpr.dts index 15ddffded120..5bd51f2f41d7 100644 --- a/boards/raytac/an54lq_db_15/raytac_an54lq_db_15_nrf54l15_cpuflpr.dts +++ b/boards/raytac/an54lq_db_15/raytac_an54lq_db_15_nrf54l15_cpuflpr.dts @@ -31,12 +31,12 @@ &cpuflpr_rram { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/boards/seeed/xiao_nrf54l15/xiao_nrf54l15_nrf54l15_cpuflpr.dts b/boards/seeed/xiao_nrf54l15/xiao_nrf54l15_nrf54l15_cpuflpr.dts index 3ec808985f68..0905ecb7b649 100644 --- a/boards/seeed/xiao_nrf54l15/xiao_nrf54l15_nrf54l15_cpuflpr.dts +++ b/boards/seeed/xiao_nrf54l15/xiao_nrf54l15_nrf54l15_cpuflpr.dts @@ -28,12 +28,12 @@ &cpuflpr_rram { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/boards/we/ophelia4ev/ophelia4ev_nrf54l15_cpuflpr.dts b/boards/we/ophelia4ev/ophelia4ev_nrf54l15_cpuflpr.dts index 3829ef5a5b65..12db2ac98511 100644 --- a/boards/we/ophelia4ev/ophelia4ev_nrf54l15_cpuflpr.dts +++ b/boards/we/ophelia4ev/ophelia4ev_nrf54l15_cpuflpr.dts @@ -32,12 +32,12 @@ &cpuflpr_rram { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; cpuflpr_code_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0 DT_SIZE_K(96)>; }; diff --git a/dts/vendor/nordic/nrf54l10_cpuapp_ns.dtsi b/dts/vendor/nordic/nrf54l10_cpuapp_ns.dtsi index 1ee743b11786..e4c4601defc8 100644 --- a/dts/vendor/nordic/nrf54l10_cpuapp_ns.dtsi +++ b/dts/vendor/nordic/nrf54l10_cpuapp_ns.dtsi @@ -4,13 +4,4 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "nrf54l_05_10_15.dtsi" - -&cpuapp_sram { - reg = <0x20000000 DT_SIZE_K(192)>; - ranges = <0x0 0x20000000 DT_SIZE_K(192)>; -}; - -&cpuapp_rram { - reg = <0x0 DT_SIZE_K(1012)>; -}; +#include "nrf54l10.dtsi" diff --git a/dts/vendor/nordic/nrf54l10_cpuapp_ns_partition.dtsi b/dts/vendor/nordic/nrf54l10_cpuapp_ns_partition.dtsi index 92bcd8bb8a30..c88800205b4b 100644 --- a/dts/vendor/nordic/nrf54l10_cpuapp_ns_partition.dtsi +++ b/dts/vendor/nordic/nrf54l10_cpuapp_ns_partition.dtsi @@ -35,7 +35,7 @@ &cpuapp_rram { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; @@ -46,31 +46,37 @@ * needs to happen both in the flash_layout.h and in this file at the same time. */ slot0_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000000 DT_SIZE_K(384)>; }; tfm_ps_partition: partition@60000 { + compatible = "zephyr,mapped-partition"; label = "tfm-ps"; reg = <0x00060000 DT_SIZE_K(16)>; }; tfm_its_partition: partition@64000 { + compatible = "zephyr,mapped-partition"; label = "tfm-its"; reg = <0x00064000 DT_SIZE_K(16)>; }; tfm_otp_partition: partition@68000 { + compatible = "zephyr,mapped-partition"; label = "tfm-otp"; reg = <0x00068000 DT_SIZE_K(8)>; }; slot0_ns_partition: partition@6a000 { + compatible = "zephyr,mapped-partition"; label = "image-0-nonsecure"; reg = <0x0006a000 DT_SIZE_K(556)>; }; storage_partition: partition@f5000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000f5000 DT_SIZE_K(32)>; }; diff --git a/dts/vendor/nordic/nrf54l15_cpuapp_ns.dtsi b/dts/vendor/nordic/nrf54l15_cpuapp_ns.dtsi index a96865325b8a..f09cee88c69c 100644 --- a/dts/vendor/nordic/nrf54l15_cpuapp_ns.dtsi +++ b/dts/vendor/nordic/nrf54l15_cpuapp_ns.dtsi @@ -4,13 +4,4 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "nrf54l_05_10_15.dtsi" - -&cpuapp_sram { - reg = <0x20000000 DT_SIZE_K(256)>; - ranges = <0x0 0x20000000 DT_SIZE_K(256)>; -}; - -&cpuapp_rram { - reg = <0x0 DT_SIZE_K(1524)>; -}; +#include "nrf54l15.dtsi" diff --git a/dts/vendor/nordic/nrf54l15_cpuapp_ns_partition.dtsi b/dts/vendor/nordic/nrf54l15_cpuapp_ns_partition.dtsi index ab1f686caa24..1794c49c031f 100644 --- a/dts/vendor/nordic/nrf54l15_cpuapp_ns_partition.dtsi +++ b/dts/vendor/nordic/nrf54l15_cpuapp_ns_partition.dtsi @@ -46,7 +46,7 @@ * otherwise unused (32 KB) */ partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; @@ -57,31 +57,37 @@ * needs to happen both in the flash_layout.h and in this file at the same time. */ slot0_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000000 DT_SIZE_K(512)>; }; tfm_ps_partition: partition@80000 { + compatible = "zephyr,mapped-partition"; label = "tfm-ps"; reg = <0x00080000 DT_SIZE_K(16)>; }; tfm_its_partition: partition@84000 { + compatible = "zephyr,mapped-partition"; label = "tfm-its"; reg = <0x00084000 DT_SIZE_K(16)>; }; tfm_otp_partition: partition@88000 { + compatible = "zephyr,mapped-partition"; label = "tfm-otp"; reg = <0x00088000 DT_SIZE_K(8)>; }; slot0_ns_partition: partition@8a000 { + compatible = "zephyr,mapped-partition"; label = "image-0-nonsecure"; reg = <0x0008a000 DT_SIZE_K(940)>; }; storage_partition: partition@175000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000175000 DT_SIZE_K(32)>; }; diff --git a/dts/vendor/nordic/nrf54l15_cpuapp_partition.dtsi b/dts/vendor/nordic/nrf54l15_cpuapp_partition.dtsi index 9e356b4a0fc3..96f8e7910556 100644 --- a/dts/vendor/nordic/nrf54l15_cpuapp_partition.dtsi +++ b/dts/vendor/nordic/nrf54l15_cpuapp_partition.dtsi @@ -6,42 +6,48 @@ &cpuapp_rram { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x0 DT_SIZE_K(64)>; }; #ifdef WITH_FLPR_PARTITIONS slot0_partition: partition@10000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x10000 DT_SIZE_K(664)>; }; slot1_partition: partition@b6000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0xb6000 DT_SIZE_K(664)>; }; storage_partition: partition@15c000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x15c000 DT_SIZE_K(36)>; }; #else slot0_partition: partition@10000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x10000 DT_SIZE_K(712)>; }; slot1_partition: partition@c2000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0xc2000 DT_SIZE_K(712)>; }; storage_partition: partition@174000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x174000 DT_SIZE_K(36)>; }; diff --git a/dts/vendor/nordic/nrf54l_05_10_15.dtsi b/dts/vendor/nordic/nrf54l_05_10_15.dtsi index e4cf5ba10b2a..5714aa79c191 100644 --- a/dts/vendor/nordic/nrf54l_05_10_15.dtsi +++ b/dts/vendor/nordic/nrf54l_05_10_15.dtsi @@ -750,14 +750,16 @@ rram_controller: rram-controller@5004b000 { compatible = "nordic,rram-controller"; reg = <0x5004b000 0x1000>; + ranges; #address-cells = <1>; #size-cells = <1>; interrupts = <75 NRF_DEFAULT_IRQ_PRIORITY>; - cpuapp_rram: rram@0 { + cpuapp_rram: flash@0 { compatible = "soc-nv-flash"; erase-block-size = <4096>; write-block-size = <16>; + status = "okay"; #address-cells = <1>; #size-cells = <1>; }; diff --git a/samples/subsys/fs/fs_sample/boards/nrf54l15dk_nrf54l15_cpuapp.overlay b/samples/subsys/fs/fs_sample/boards/nrf54l15dk_nrf54l15_cpuapp.overlay index b44427b19b9d..49a3ace82730 100644 --- a/samples/subsys/fs/fs_sample/boards/nrf54l15dk_nrf54l15_cpuapp.overlay +++ b/samples/subsys/fs/fs_sample/boards/nrf54l15dk_nrf54l15_cpuapp.overlay @@ -14,19 +14,18 @@ &cpuapp_rram { partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - slot0_partition: partition@10000 { + compatible = "zephyr,mapped-partition"; reg = <0x00010000 DT_SIZE_K(300)>; }; slot1_partition: partition@5b000 { + compatible = "zephyr,mapped-partition"; reg = <0x0005b000 DT_SIZE_K(300)>; }; storage_partition: partition@a6000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000a6000 DT_SIZE_K(128)>; }; diff --git a/samples/subsys/fs/fs_sample/boards/ophelia4ev_nrf54l15_cpuapp.overlay b/samples/subsys/fs/fs_sample/boards/ophelia4ev_nrf54l15_cpuapp.overlay index 1afd8bf74b46..e26399cd4c4e 100644 --- a/samples/subsys/fs/fs_sample/boards/ophelia4ev_nrf54l15_cpuapp.overlay +++ b/samples/subsys/fs/fs_sample/boards/ophelia4ev_nrf54l15_cpuapp.overlay @@ -1,45 +1 @@ -/* - * Copyright (c) 2025 Würth Elektronik eiSos GmbH & Co. KG - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/* Because FAT FS needs at least 64kiB partition and default - * storage_partition is 36kiB for this board, we need to reorganize - * partitions to get at least 64KiB. - */ -/delete-node/ &slot0_partition; -/delete-node/ &slot1_partition; -/delete-node/ &storage_partition; - -&cpuapp_rram { - partitions { - compatible = "fixed-partitions"; - - #address-cells = <1>; - #size-cells = <1>; - - slot0_partition: partition@10000 { - reg = <0x00010000 DT_SIZE_K(300)>; - }; - - slot1_partition: partition@5b000 { - reg = <0x0005b000 DT_SIZE_K(300)>; - }; - - storage_partition: partition@a6000 { - label = "storage"; - reg = <0x000a6000 DT_SIZE_K(128)>; - }; - }; -}; - -/ { - msc_disk0 { - status = "okay"; - compatible = "zephyr,flash-disk"; - partition = <&storage_partition>; - disk-name = "SD"; - cache-size = <512>; - }; -}; +#include "nrf54l15dk_nrf54l15_cpuapp.overlay" diff --git a/samples/subsys/fs/fs_sample/sample.yaml b/samples/subsys/fs/fs_sample/sample.yaml index e1b9b56e6e8f..c750cecc1f7f 100644 --- a/samples/subsys/fs/fs_sample/sample.yaml +++ b/samples/subsys/fs/fs_sample/sample.yaml @@ -58,12 +58,11 @@ tests: extra_args: - EXTRA_CONF_FILE=boards/nrf52840dk_nrf52840_ram_disk.conf - DTC_OVERLAY_FILE=boards/nrf52840dk_nrf52840_ram_disk_region.overlay - sample.filesystem.fat_fs.nrf54l15dk: + sample.filesystem.fat_fs.nrf54l15: build_only: true - platform_allow: nrf54l15dk/nrf54l15/cpuapp - sample.filesystem.fat_fs.ophelia4ev: - build_only: true - platform_allow: ophelia4ev/nrf54l15/cpuapp + platform_allow: + - nrf54l15dk/nrf54l15/cpuapp + - ophelia4ev/nrf54l15/cpuapp sample.filesystem.fat_fs.nrf52840dk_nrf52840.qspi: build_only: true platform_allow: nrf52840dk/nrf52840 From 14bde75eed50618ca1d229403d424efaeaf2da57 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 19 Mar 2026 07:38:03 +0000 Subject: [PATCH 54/63] [nrf fromtree] tests: Adapt nRF52 board overlays to use new binding Uses the newly introduced zephyr,mapped-partition binding, as the board has switched to using it Signed-off-by: Jamie McCrae (cherry picked from commit b0f647d0e2d99e122bd82799ece318bbb14cfdc5) --- tests/subsys/dfu/mcuboot_multi/nrf52840dk_nrf52840.overlay | 7 ++++++- tests/subsys/settings/fcb/boards/nrf52dk_nrf52832.overlay | 3 ++- .../functional/fcb/boards/nrf52840dk_nrf52840.overlay | 3 ++- .../functional/fcb/boards/nrf52dk_nrf52832.overlay | 3 ++- .../settings/functional/file/nrf52840dk_nrf52840.overlay | 3 ++- .../settings/functional/file/nrf52dk_nrf52832.overlay | 3 ++- .../settings/retention/boards/nrf52840dk_nrf52840.overlay | 1 + 7 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/subsys/dfu/mcuboot_multi/nrf52840dk_nrf52840.overlay b/tests/subsys/dfu/mcuboot_multi/nrf52840dk_nrf52840.overlay index e46c6318792c..90628e17dbc7 100644 --- a/tests/subsys/dfu/mcuboot_multi/nrf52840dk_nrf52840.overlay +++ b/tests/subsys/dfu/mcuboot_multi/nrf52840dk_nrf52840.overlay @@ -10,31 +10,36 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 0x00010000>; }; slot0_partition: partition@10000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00010000 0x0000a000>; }; slot1_partition: partition@1a000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x0001a000 0x0000a000>; }; slot2_partition: partition@24000 { + compatible = "zephyr,mapped-partition"; label = "image-2"; reg = <0x00024000 0x0000a000>; }; slot3_partition: partition@2e000 { + compatible = "zephyr,mapped-partition"; label = "image-3"; reg = <0x0002e000 0x0000a000>; }; diff --git a/tests/subsys/settings/fcb/boards/nrf52dk_nrf52832.overlay b/tests/subsys/settings/fcb/boards/nrf52dk_nrf52832.overlay index e3706968b5b0..19a7ac2ff723 100644 --- a/tests/subsys/settings/fcb/boards/nrf52dk_nrf52832.overlay +++ b/tests/subsys/settings/fcb/boards/nrf52dk_nrf52832.overlay @@ -9,11 +9,12 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; storage_partition: partition@70000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00070000 0x10000>; }; diff --git a/tests/subsys/settings/functional/fcb/boards/nrf52840dk_nrf52840.overlay b/tests/subsys/settings/functional/fcb/boards/nrf52840dk_nrf52840.overlay index dada2d62ce14..9e7fe1185124 100644 --- a/tests/subsys/settings/functional/fcb/boards/nrf52840dk_nrf52840.overlay +++ b/tests/subsys/settings/functional/fcb/boards/nrf52840dk_nrf52840.overlay @@ -8,11 +8,12 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; storage_partition: partition@de000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000de000 0x00010000>; }; diff --git a/tests/subsys/settings/functional/fcb/boards/nrf52dk_nrf52832.overlay b/tests/subsys/settings/functional/fcb/boards/nrf52dk_nrf52832.overlay index e3706968b5b0..19a7ac2ff723 100644 --- a/tests/subsys/settings/functional/fcb/boards/nrf52dk_nrf52832.overlay +++ b/tests/subsys/settings/functional/fcb/boards/nrf52dk_nrf52832.overlay @@ -9,11 +9,12 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; storage_partition: partition@70000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00070000 0x10000>; }; diff --git a/tests/subsys/settings/functional/file/nrf52840dk_nrf52840.overlay b/tests/subsys/settings/functional/file/nrf52840dk_nrf52840.overlay index dada2d62ce14..9e7fe1185124 100644 --- a/tests/subsys/settings/functional/file/nrf52840dk_nrf52840.overlay +++ b/tests/subsys/settings/functional/file/nrf52840dk_nrf52840.overlay @@ -8,11 +8,12 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; storage_partition: partition@de000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x000de000 0x00010000>; }; diff --git a/tests/subsys/settings/functional/file/nrf52dk_nrf52832.overlay b/tests/subsys/settings/functional/file/nrf52dk_nrf52832.overlay index e3706968b5b0..19a7ac2ff723 100644 --- a/tests/subsys/settings/functional/file/nrf52dk_nrf52832.overlay +++ b/tests/subsys/settings/functional/file/nrf52dk_nrf52832.overlay @@ -9,11 +9,12 @@ &flash0 { partitions { - compatible = "fixed-partitions"; + ranges; #address-cells = <1>; #size-cells = <1>; storage_partition: partition@70000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00070000 0x10000>; }; diff --git a/tests/subsys/settings/retention/boards/nrf52840dk_nrf52840.overlay b/tests/subsys/settings/retention/boards/nrf52840dk_nrf52840.overlay index 37bae45ab120..53049260d6f7 100644 --- a/tests/subsys/settings/retention/boards/nrf52840dk_nrf52840.overlay +++ b/tests/subsys/settings/retention/boards/nrf52840dk_nrf52840.overlay @@ -22,6 +22,7 @@ #size-cells = <1>; settings_partition0: settings_partition@0 { + compatible = "zephyr,mapped-partition"; compatible = "zephyr,retention"; status = "okay"; reg = <0x0 0x1000>; From 423712d187285642fef7cf24fd20acffe6bd3e92 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Fri, 20 Mar 2026 08:13:46 +0000 Subject: [PATCH 55/63] [nrf fromtree] dts: nordic: nrf54h20/nrf9280: Update to use zephyr,mapped-partitions Updates the dts nodes switch partitions to use the new zephyr,mapped-partition compatible. Signed-off-by: Jamie McCrae (cherry picked from commit cdc480afb65c406db575652f98ce86959aeb2fe1) --- .../nrf54h20dk_nrf54h20-memory_map.dtsi | 20 +++++++++++++++++-- .../nrf9280pdk_nrf9280-memory_map.dtsi | 14 +++++++++++-- drivers/flash/soc_flash_nrf_mram.c | 10 ++++++---- dts/vendor/nordic/nrf54h20.dtsi | 16 +++++++++++---- dts/vendor/nordic/nrf9280.dtsi | 16 +++++++++++---- 5 files changed, 60 insertions(+), 16 deletions(-) diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map.dtsi b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map.dtsi index 91ee56a6ecc8..23ff92dc56fc 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map.dtsi +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map.dtsi @@ -127,60 +127,72 @@ &mram1x { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; cpuapp_boot_partition: partition@30000 { + compatible = "zephyr,mapped-partition"; reg = <0x30000 DT_SIZE_K(64)>; }; cpuapp_slot0_partition: partition@40000 { + compatible = "zephyr,mapped-partition"; reg = <0x40000 DT_SIZE_K(328)>; }; cpurad_slot0_partition: partition@92000 { + compatible = "zephyr,mapped-partition"; reg = <0x92000 DT_SIZE_K(328)>; }; cpuppr_code_partition: partition@e4000 { + compatible = "zephyr,mapped-partition"; reg = <0xe4000 DT_SIZE_K(64)>; }; cpuflpr_code_partition: partition@f4000 { + compatible = "zephyr,mapped-partition"; reg = <0xf4000 DT_SIZE_K(48)>; }; cpuapp_slot1_partition: partition@100000 { + compatible = "zephyr,mapped-partition"; reg = <0x100000 DT_SIZE_K(328)>; }; cpurad_slot1_partition: partition@152000 { + compatible = "zephyr,mapped-partition"; reg = <0x152000 DT_SIZE_K(328)>; }; storage_partition: partition@1a4000 { + compatible = "zephyr,mapped-partition"; reg = <0x1a4000 DT_SIZE_K(40)>; }; periphconf_partition: partition@1ae000 { + compatible = "zephyr,mapped-partition"; reg = <0x1ae000 DT_SIZE_K(8)>; }; secondary_partition: partition@1b0000 { + compatible = "zephyr,mapped-partition"; reg = <0x1b0000 DT_SIZE_K(64)>; }; secondary_periphconf_partition: partition@1c0000 { + compatible = "zephyr,mapped-partition"; reg = <0x1c0000 DT_SIZE_K(8)>; }; mpcconf_partition: partition@1c2000 { + compatible = "zephyr,mapped-partition"; reg = <0x1c2000 512>; }; secondary_mpcconf_partition: partition@1c2200 { + compatible = "zephyr,mapped-partition"; reg = <0x1c2200 512>; }; @@ -190,25 +202,29 @@ * there is no more space after secure_storage_partition. */ secure_storage_partition: partition@1fd000 { - compatible = "fixed-subpartitions"; + compatible = "zephyr,mapped-partition"; reg = <0x1fd000 DT_SIZE_K(12)>; ranges = <0x0 0x1fd000 0x3000>; #address-cells = <1>; #size-cells = <1>; cpuapp_crypto_partition: partition@0 { + compatible = "zephyr,mapped-partition"; reg = <0x0 DT_SIZE_K(4)>; }; cpurad_crypto_partition: partition@1000 { + compatible = "zephyr,mapped-partition"; reg = <0x1000 DT_SIZE_K(4)>; }; cpuapp_its_partition: partition@2000 { + compatible = "zephyr,mapped-partition"; reg = <0x2000 DT_SIZE_K(2)>; }; cpurad_its_partition: partition@2800 { + compatible = "zephyr,mapped-partition"; reg = <0x2800 DT_SIZE_K(2)>; }; }; diff --git a/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280-memory_map.dtsi b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280-memory_map.dtsi index 4be968ed3df2..0840127adf92 100644 --- a/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280-memory_map.dtsi +++ b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280-memory_map.dtsi @@ -186,44 +186,52 @@ &mram1x { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; cpuapp_boot_partition: partition@312000 { + compatible = "zephyr,mapped-partition"; reg = <0x312000 DT_SIZE_K(64)>; }; cpuapp_slot0_partition: partition@322000 { + compatible = "zephyr,mapped-partition"; reg = <0x322000 DT_SIZE_K(336)>; }; cpuapp_slot1_partition: partition@376000 { + compatible = "zephyr,mapped-partition"; reg = <0x376000 DT_SIZE_K(440)>; }; cpuppr_code_partition: partition@3e4000 { + compatible = "zephyr,mapped-partition"; reg = <0x3e4000 DT_SIZE_K(64)>; }; cpuflpr_code_partition: partition@3f4000 { + compatible = "zephyr,mapped-partition"; reg = <0x3f4000 DT_SIZE_K(48)>; }; cpurad_slot0_partition: partition@400000 { + compatible = "zephyr,mapped-partition"; reg = <0x400000 DT_SIZE_K(336)>; }; cpurad_slot1_partition: partition@454000 { + compatible = "zephyr,mapped-partition"; reg = <0x454000 DT_SIZE_K(336)>; }; storage_partition: partition@600000 { + compatible = "zephyr,mapped-partition"; reg = <0x600000 DT_SIZE_K(40)>; }; periphconf_partition: partition@60a000 { + compatible = "zephyr,mapped-partition"; reg = <0x60a000 DT_SIZE_K(8)>; }; @@ -231,17 +239,19 @@ * it resides in the beginning of MRAM11 in storage partition. */ secure_storage_partition: partition@60c000 { - compatible = "fixed-subpartitions"; + compatible = "zephyr,mapped-partition"; reg = <0x60c000 DT_SIZE_K(8)>; ranges = <0x0 0x60c000 0x2000>; #address-cells = <1>; #size-cells = <1>; cpuapp_crypto_partition: partition@0 { + compatible = "zephyr,mapped-partition"; reg = <0x0 DT_SIZE_K(4)>; }; cpuapp_its_partition: partition@1000 { + compatible = "zephyr,mapped-partition"; reg = <0x1000 DT_SIZE_K(4)>; }; }; diff --git a/drivers/flash/soc_flash_nrf_mram.c b/drivers/flash/soc_flash_nrf_mram.c index 51331786dcf5..3fad53d31dd1 100644 --- a/drivers/flash/soc_flash_nrf_mram.c +++ b/drivers/flash/soc_flash_nrf_mram.c @@ -14,14 +14,16 @@ LOG_MODULE_REGISTER(flash_nrf_mram, CONFIG_FLASH_LOG_LEVEL); #define DT_DRV_COMPAT nordic_mram -#define MRAM_START DT_INST_REG_ADDR(0) -#define MRAM_SIZE DT_INST_REG_SIZE(0) +#define MRAM_NVM_CHILD_NODE DT_INST_CHILD(0, mram_memory_0) + +#define MRAM_START DT_REG_ADDR(MRAM_NVM_CHILD_NODE) +#define MRAM_SIZE DT_REG_SIZE(MRAM_NVM_CHILD_NODE) #define MRAM_WORD_SIZE 16 #define MRAM_WORD_MASK 0xf -#define WRITE_BLOCK_SIZE DT_INST_PROP_OR(0, write_block_size, MRAM_WORD_SIZE) -#define ERASE_BLOCK_SIZE DT_INST_PROP_OR(0, erase_block_size, WRITE_BLOCK_SIZE) +#define WRITE_BLOCK_SIZE DT_PROP_OR(MRAM_NVM_CHILD_NODE, write_block_size, MRAM_WORD_SIZE) +#define ERASE_BLOCK_SIZE DT_PROP_OR(MRAM_NVM_CHILD_NODE, erase_block_size, WRITE_BLOCK_SIZE) #define ERASE_VALUE 0xff diff --git a/dts/vendor/nordic/nrf54h20.dtsi b/dts/vendor/nordic/nrf54h20.dtsi index e4a8096701be..cf0821d36e7d 100644 --- a/dts/vendor/nordic/nrf54h20.dtsi +++ b/dts/vendor/nordic/nrf54h20.dtsi @@ -268,14 +268,22 @@ #address-cells = <1>; #size-cells = <1>; - mram1x: mram@e000000 { + mram1x_controller: mram-controller@5f092000 { compatible = "nordic,mram"; - reg = <0xe000000 DT_SIZE_K(2048)>; + reg = <0x5f092000 0x2000>; ranges = <0x0 0xe000000 DT_SIZE_K(2048)>; - erase-block-size = <4096>; - write-block-size = <16>; #address-cells = <1>; #size-cells = <1>; + + mram1x: mram-memory@0 { + compatible = "soc-nv-flash"; + reg = <0 DT_SIZE_K(2048)>; + ranges; + erase-block-size = <4096>; + write-block-size = <16>; + #address-cells = <1>; + #size-cells = <1>; + }; }; uicr: uicr@fff8000 { diff --git a/dts/vendor/nordic/nrf9280.dtsi b/dts/vendor/nordic/nrf9280.dtsi index 0e196147880c..5ee45960e828 100644 --- a/dts/vendor/nordic/nrf9280.dtsi +++ b/dts/vendor/nordic/nrf9280.dtsi @@ -136,14 +136,22 @@ #address-cells = <1>; #size-cells = <1>; - mram1x: mram@e000000 { + mram1x_controller: mram-controller@5f092000 { compatible = "nordic,mram"; - reg = <0xe000000 DT_SIZE_K(8192)>; + reg = <0x5f092000 0x2000>; ranges = <0x0 0xe000000 DT_SIZE_K(8192)>; - erase-block-size = <4096>; - write-block-size = <16>; #address-cells = <1>; #size-cells = <1>; + + mram1x: mram-memory@0 { + compatible = "soc-nv-flash"; + reg = <0x0 DT_SIZE_K(8192)>; + ranges; + erase-block-size = <4096>; + write-block-size = <16>; + #address-cells = <1>; + #size-cells = <1>; + }; }; uicr: uicr@fff8000 { From 82fe97ab96bb96ebb316de2ca3428bde52da6237 Mon Sep 17 00:00:00 2001 From: Robert Robinson Date: Wed, 25 Feb 2026 15:58:05 +0000 Subject: [PATCH 56/63] [nrf fromtree] dts: nordic: nrf7120: Update MRAM partitions MRAM sizes were wrongly defined in .dtsi files and so required updating. Signed-off-by: Robert Robinson (cherry picked from commit edc63785b1fb248b5d6ce5b2fea2404777dc79bd) --- dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi b/dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi index 6df7b940c131..70ce6068265c 100644 --- a/dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi +++ b/dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi @@ -27,12 +27,12 @@ reg = <0x00010000 DT_SIZE_K(1988)>; }; - slot1_partition: partition@202000 { + slot1_partition: partition@201000 { label = "image-1"; reg = <0x00201000 DT_SIZE_K(1988)>; }; - storage_partition: partition@3f4000 { + storage_partition: partition@3f2000 { label = "storage"; reg = <0x003f2000 DT_SIZE_K(36)>; }; From 1e9f983283de361fb83676bfc7aa4cffeaccc663 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Fri, 20 Mar 2026 08:16:52 +0000 Subject: [PATCH 57/63] [nrf fromtree] dts: nordic: nrf7120: Update to use zephyr,mapped-partitions Updates the dts nodes switch partitions to use the new zephyr,mapped-partition compatible. Signed-off-by: Jamie McCrae (cherry picked from commit e79a144a36986ce22a299d98b0938fd1feb46738) --- boards/nordic/nrf7120dk/nrf7120dk_nrf7120_cpuflpr.dts | 2 +- dts/vendor/nordic/nrf7120_cpuapp_ns_partition.dtsi | 8 +++++++- dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi | 10 +++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/boards/nordic/nrf7120dk/nrf7120dk_nrf7120_cpuflpr.dts b/boards/nordic/nrf7120dk/nrf7120dk_nrf7120_cpuflpr.dts index b8132ee9ef3c..6da7f6794ba4 100644 --- a/boards/nordic/nrf7120dk/nrf7120dk_nrf7120_cpuflpr.dts +++ b/boards/nordic/nrf7120dk/nrf7120dk_nrf7120_cpuflpr.dts @@ -31,12 +31,12 @@ &cpuflpr_mram { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; ranges; cpuflpr_code_partition: partition@0 { + compatible = "nordic,mapped-partition"; label = "image-0"; reg = <0 DT_SIZE_K(116)>; }; diff --git a/dts/vendor/nordic/nrf7120_cpuapp_ns_partition.dtsi b/dts/vendor/nordic/nrf7120_cpuapp_ns_partition.dtsi index 441c5c390ec2..e9155960313e 100644 --- a/dts/vendor/nordic/nrf7120_cpuapp_ns_partition.dtsi +++ b/dts/vendor/nordic/nrf7120_cpuapp_ns_partition.dtsi @@ -48,9 +48,9 @@ * otherwise unused (32 KB) */ partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; + ranges; /* This static layout needs to be the same with the upstream TF-M layout in the * header flash_layout.h of the relevant platform. Any updates in the layout @@ -58,31 +58,37 @@ */ slot0_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x0000000 DT_SIZE_K(512)>; }; tfm_ps_partition: partition@80000 { + compatible = "zephyr,mapped-partition"; label = "tfm-ps"; reg = <0x00080000 DT_SIZE_K(16)>; }; tfm_its_partition: partition@84000 { + compatible = "zephyr,mapped-partition"; label = "tfm-its"; reg = <0x00084000 DT_SIZE_K(16)>; }; tfm_otp_partition: partition@88000 { + compatible = "zephyr,mapped-partition"; label = "tfm-otp"; reg = <0x00088000 DT_SIZE_K(8)>; }; slot0_ns_partition: partition@8a000 { + compatible = "zephyr,mapped-partition"; label = "image-0-nonsecure"; reg = <0x0008a000 DT_SIZE_K(844)>; }; storage_partition: partition@15d000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x00015d000 DT_SIZE_K(32)>; }; diff --git a/dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi b/dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi index 70ce6068265c..480f784223f2 100644 --- a/dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi +++ b/dts/vendor/nordic/nrf7120_cpuapp_partition.dtsi @@ -6,33 +6,33 @@ * Default memory partitioning for nRF7120 application CPU. */ -&cpuapp_mram { - reg = <0x0 DT_SIZE_K(4076)>; -}; - /* These partition sizes assume no FLPR area in MRAM */ &cpuapp_mram { partitions { - compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; + ranges; boot_partition: partition@0 { + compatible = "zephyr,mapped-partition"; label = "mcuboot"; reg = <0x00000000 DT_SIZE_K(64)>; }; slot0_partition: partition@10000 { + compatible = "zephyr,mapped-partition"; label = "image-0"; reg = <0x00010000 DT_SIZE_K(1988)>; }; slot1_partition: partition@201000 { + compatible = "zephyr,mapped-partition"; label = "image-1"; reg = <0x00201000 DT_SIZE_K(1988)>; }; storage_partition: partition@3f2000 { + compatible = "zephyr,mapped-partition"; label = "storage"; reg = <0x003f2000 DT_SIZE_K(36)>; }; From 62c56ae9b1509d905d7fcf307fa40c9af494adc4 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Wed, 18 Mar 2026 12:09:59 +0000 Subject: [PATCH 58/63] [nrf fromtree] include: devicetree: Add missing partition.h include Adds this include, which was missed in a previous commit Signed-off-by: Jamie McCrae (cherry picked from commit c9607b67d8775e0b01d0f3e1d149c25c55229997) --- include/zephyr/devicetree.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/zephyr/devicetree.h b/include/zephyr/devicetree.h index cafcdeaba3f6..d0ce598b5f88 100644 --- a/include/zephyr/devicetree.h +++ b/include/zephyr/devicetree.h @@ -5697,5 +5697,6 @@ #include #include #include +#include #endif /* ZEPHYR_INCLUDE_DEVICETREE_H_ */ From 349a030c404ca74ed0c2243566cd66407d019228 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Mon, 23 Mar 2026 08:19:11 +0000 Subject: [PATCH 59/63] [nrf fromlist] dts: vendor: nordic: Fix typo of dts name Fixes a typo, from flash to rram Upstream PR #: 106057 Signed-off-by: Jamie McCrae --- dts/vendor/nordic/nrf54l_05_10_15.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dts/vendor/nordic/nrf54l_05_10_15.dtsi b/dts/vendor/nordic/nrf54l_05_10_15.dtsi index 5714aa79c191..2a6c72959008 100644 --- a/dts/vendor/nordic/nrf54l_05_10_15.dtsi +++ b/dts/vendor/nordic/nrf54l_05_10_15.dtsi @@ -755,7 +755,7 @@ #size-cells = <1>; interrupts = <75 NRF_DEFAULT_IRQ_PRIORITY>; - cpuapp_rram: flash@0 { + cpuapp_rram: rram@0 { compatible = "soc-nv-flash"; erase-block-size = <4096>; write-block-size = <16>; From 0d635c161b0912b732e7129225426f0a6aaadc2d Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Mon, 23 Mar 2026 08:36:33 +0000 Subject: [PATCH 60/63] [nrf fromlist] dts: bindings: mtd: fixed-(sub)partitions: Add missing 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 --- dts/bindings/mtd/fixed-partitions.yaml | 2 ++ dts/bindings/mtd/fixed-subpartitions.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/dts/bindings/mtd/fixed-partitions.yaml b/dts/bindings/mtd/fixed-partitions.yaml index 365762bf8df3..fd791e93b1a7 100644 --- a/dts/bindings/mtd/fixed-partitions.yaml +++ b/dts/bindings/mtd/fixed-partitions.yaml @@ -53,6 +53,8 @@ description: | compatible: "fixed-partitions" +include: base.yaml + properties: "#address-cells": type: int diff --git a/dts/bindings/mtd/fixed-subpartitions.yaml b/dts/bindings/mtd/fixed-subpartitions.yaml index ac70d1815f7b..42d985d34612 100644 --- a/dts/bindings/mtd/fixed-subpartitions.yaml +++ b/dts/bindings/mtd/fixed-subpartitions.yaml @@ -32,6 +32,8 @@ description: | compatible: "fixed-subpartitions" +include: base.yaml + properties: label: type: string From 33fdf05178bf6fbed05e7dc66f48af4a0d9c63f1 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Mon, 23 Mar 2026 08:22:36 +0000 Subject: [PATCH 61/63] [nrf fromlist] zephyr: arch: arm: cortex_m: linker: Add missing XIP check 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 --- include/zephyr/arch/arm/cortex_m/scripts/linker.ld | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld index c798f0a8fd1c..f6b7c3649745 100644 --- a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld +++ b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld @@ -73,7 +73,7 @@ _image_1_primary_slot_id = PM_S1_ID; #define ROM_END_OFFSET 0 #endif -#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) +#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) && defined(CONFIG_XIP) #define ROM_ADDR (DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition))) #define ROM_SIZE (DT_REG_SIZE(DT_CHOSEN(zephyr_code_partition)) - ROM_END_OFFSET) #else From f77738586adab8dc6ee16bddc238e59329110447 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Mon, 23 Mar 2026 08:33:22 +0000 Subject: [PATCH 62/63] [nrf fromlist] include: storage: flash_map: Fix PARTITION_NODE_OFFSET 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 --- include/zephyr/storage/flash_map.h | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/include/zephyr/storage/flash_map.h b/include/zephyr/storage/flash_map.h index 2befcef56453..819f94182474 100644 --- a/include/zephyr/storage/flash_map.h +++ b/include/zephyr/storage/flash_map.h @@ -398,13 +398,7 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); * * @return offset, as defined for the partition in DTS. */ -#define PARTITION_OFFSET(label) \ - COND_CODE_1(DT_NODE_HAS_COMPAT(DT_NODELABEL(label), zephyr_mapped_partition), \ - (DT_MAPPED_PARTITION_OFFSET(DT_NODELABEL(label))), \ - (COND_CODE_1(DT_FIXED_SUBPARTITION_EXISTS(DT_NODELABEL(label)), \ - (DT_PROP_BY_IDX(DT_PARENT(DT_NODELABEL(label)), reg, 0) + \ - DT_PROP_BY_IDX(DT_NODELABEL(label), reg, 0)), \ - (DT_PROP_BY_IDX(DT_NODELABEL(label), reg, 0))))) +#define PARTITION_OFFSET(label) PARTITION_NODE_OFFSET(DT_NODELABEL(label)) /** Deprecated macro, replace with PARTITION_OFFSET() */ #define FIXED_PARTITION_OFFSET(label) PARTITION_OFFSET(label) __DEPRECATED_MACRO @@ -450,10 +444,12 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); * * @return offset, as defined for the partition in DTS. */ -#define PARTITION_NODE_OFFSET(node) \ - COND_CODE_1(DT_NODE_HAS_COMPAT(node, zephyr_mapped_partition), \ - (DT_MAPPED_PARTITION_OFFSET(node)), \ - (DT_REG_ADDR(node))) +#define PARTITION_NODE_OFFSET(node) \ + COND_CASE_1(DT_NODE_HAS_COMPAT(node, zephyr_mapped_partition), \ + (DT_MAPPED_PARTITION_OFFSET(node)), \ + DT_FIXED_SUBPARTITION_EXISTS(node), \ + (DT_PROP_BY_IDX(DT_PARENT(node), reg, 0) + DT_PROP_BY_IDX(node, reg, 0)), \ + ((DT_PROP_BY_IDX(node, reg, 0)))) /** Deprecated macro, replace with PARTITION_NODE_OFFSET() */ #define FIXED_PARTITION_NODE_OFFSET(label) PARTITION_NODE_OFFSET(label) __DEPRECATED_MACRO From 81d66cd2a4c38e76d28f2b638be8486c6777771a Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Tue, 24 Mar 2026 13:45:44 +0000 Subject: [PATCH 63/63] [nrf fromlist] dfu: img_util: Fix partition detection 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 --- subsys/dfu/img_util/flash_img.c | 9 --------- tests/subsys/dfu/img_util/src/main.c | 7 ++----- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/subsys/dfu/img_util/flash_img.c b/subsys/dfu/img_util/flash_img.c index b28ff6872f1e..75bf36a92eb3 100644 --- a/subsys/dfu/img_util/flash_img.c +++ b/subsys/dfu/img_util/flash_img.c @@ -23,17 +23,8 @@ LOG_MODULE_REGISTER(flash_img, CONFIG_IMG_MANAGER_LOG_LEVEL); #include #endif -#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)) -#else -#define PARTITION_IS_RUNNING_APP_PARTITION(label) \ - DT_SAME_NODE(PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)), \ - PARTITION_MTD(label)) && (PARTITION_ADDRESS(label) <= \ - (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET) && \ - PARTITION_ADDRESS(label) + PARTITION_SIZE(label) > \ - (CONFIG_FLASH_BASE_ADDRESS + CONFIG_FLASH_LOAD_OFFSET)) -#endif #if defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) && (CONFIG_TFM_MCUBOOT_IMAGE_NUMBER == 2) #define UPLOAD_FLASH_AREA_LABEL slot1_ns_partition diff --git a/tests/subsys/dfu/img_util/src/main.c b/tests/subsys/dfu/img_util/src/main.c index cd831f6a0595..039954f14d57 100644 --- a/tests/subsys/dfu/img_util/src/main.c +++ b/tests/subsys/dfu/img_util/src/main.c @@ -13,11 +13,8 @@ #define SLOT0_PARTITION slot0_partition #define SLOT1_PARTITION slot1_partition -#define PARTITION_IS_RUNNING_APP_PARTITION(label) \ - DT_SAME_NODE(PARTITION_NODE_MTD(DT_CHOSEN(zephyr_code_partition)), \ - PARTITION_MTD(label)) && \ - (PARTITION_OFFSET(label) <= CONFIG_FLASH_LOAD_OFFSET && \ - PARTITION_OFFSET(label) + PARTITION_SIZE(label) > CONFIG_FLASH_LOAD_OFFSET) +#define PARTITION_IS_RUNNING_APP_PARTITION(label) \ + DT_SAME_NODE(DT_CHOSEN(zephyr_code_partition), DT_NODELABEL(label)) #if PARTITION_IS_RUNNING_APP_PARTITION(slot0_partition) #define UPLOAD_PARTITION_ID PARTITION_ID(SLOT1_PARTITION)