Zephyr API Documentation 4.4.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Devicetree Mapped Partition API

Macros

#define DT_NODE_BY_MAPPED_PARTITION_LABEL(label)
 Get a node identifier for a mapped partition with a given label property.
#define DT_HAS_MAPPED_PARTITION_LABEL(label)
 Test if a mapped partition with a given label property exists.
#define DT_MAPPED_PARTITION_EXISTS(node_id)
 Test if zephyr,mapped-partition compatible node exists.
#define DT_MAPPED_PARTITION_ID(node_id)
 Get a numeric identifier for a mapped partition.
#define DT_MEM_FROM_MAPPED_PARTITION(node_id)
 Get the node identifier of the NVM memory for a partition.
#define DT_MTD_FROM_MAPPED_PARTITION(node_id)
 Get the node identifier of the NVM controller for a partition.
#define DT_MAPPED_PARTITION_ADDR(node_id)
 Get the absolute address of a mapped partition.
#define DT_MAPPED_PARTITION_OFFSET(node_id)
 Get the offset address of a mapped partition from the NVM node.

Detailed Description

Macro Definition Documentation

◆ DT_HAS_MAPPED_PARTITION_LABEL

#define DT_HAS_MAPPED_PARTITION_LABEL ( label)

#include <zephyr/devicetree/mapped-partition.h>

Value:
IS_ENABLED(DT_CAT3(DT_COMPAT_zephyr_mapped_partition_LABEL_, label, _EXISTS))
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition util_macro.h:154

Test if a mapped partition with a given label property exists.

Parameters
labellowercase-and-underscores label property value.
Returns
1 if the device has a "zephyr,mapped-partition" compatible, 0 otherwise.

◆ DT_MAPPED_PARTITION_ADDR

#define DT_MAPPED_PARTITION_ADDR ( node_id)

#include <zephyr/devicetree/mapped-partition.h>

Value:
DT_REG_ADDR(node_id)
#define DT_REG_ADDR(node_id)
Get a node's (only) register block address.
Definition devicetree.h:2509

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.

Parameters
node_idnode identifier for a zephyr,mapped-partition node
Returns
the partition's unit address.

◆ DT_MAPPED_PARTITION_EXISTS

#define DT_MAPPED_PARTITION_EXISTS ( node_id)

#include <zephyr/devicetree/mapped-partition.h>

Value:
DT_NODE_HAS_COMPAT(node_id, zephyr_mapped_partition)
#define DT_NODE_HAS_COMPAT(node_id, compat)
Does a devicetree node match a compatible?
Definition devicetree.h:3936

Test if zephyr,mapped-partition compatible node exists.

Parameters
node_idDTS node to test.
Returns
1 if node exists and has a zephyr,mapped-partition compatible, 0 otherwise.

◆ DT_MAPPED_PARTITION_ID

#define DT_MAPPED_PARTITION_ID ( node_id)

#include <zephyr/devicetree/mapped-partition.h>

Value:
DT_CAT(node_id, _PARTITION_ID)

Get a numeric identifier for a mapped partition.

Parameters
node_idnode identifier for a zephyr,mapped-partition node.
Returns
the partition's ID, a unique zero-based index number.

◆ DT_MAPPED_PARTITION_OFFSET

#define DT_MAPPED_PARTITION_OFFSET ( node_id)

#include <zephyr/devicetree/mapped-partition.h>

Value:
#define DT_MEM_FROM_MAPPED_PARTITION(node_id)
Get the node identifier of the NVM memory for a partition.
Definition mapped-partition.h:94

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.

Parameters
node_idnode identifier for a zephyr,mapped-partition node
Returns
the partition's offset from the memory device.

◆ DT_MEM_FROM_MAPPED_PARTITION

#define DT_MEM_FROM_MAPPED_PARTITION ( node_id)

#include <zephyr/devicetree/mapped-partition.h>

Value:
COND_CODE_1(DT_NODE_HAS_COMPAT(DT_CAT(node_id, _NVM_DEVICE), soc_nv_flash), \
(DT_CAT(node_id, _NVM_DEVICE)), \
#define DT_INVALID_NODE
Name for an invalid node identifier.
Definition devicetree.h:84
#define COND_CODE_1(_flag, _if_1_code, _else_code)
Insert code depending on whether _flag expands to 1 or not.
Definition util_macro.h:209

Get the node identifier of the NVM memory for a partition.

Parameters
node_idnode identifier for a zephyr,mapped-partition node.
Returns
the node identifier of the internal memory that contains the zephyr,mapped-partition node, or DT_INVALID_NODE if it doesn't exist.

◆ DT_MTD_FROM_MAPPED_PARTITION

#define DT_MTD_FROM_MAPPED_PARTITION ( node_id)

#include <zephyr/devicetree/mapped-partition.h>

Value:
#define DT_PARENT(node_id)
Get a node identifier for a parent node.
Definition devicetree.h:375

Get the node identifier of the NVM controller for a partition.

Parameters
node_idnode identifier for a zephyr,mapped-partition node.
Returns
the node identifier of the memory technology device that contains the zephyr,mapped-partition node.

◆ DT_NODE_BY_MAPPED_PARTITION_LABEL

#define DT_NODE_BY_MAPPED_PARTITION_LABEL ( label)

#include <zephyr/devicetree/mapped-partition.h>

Value:
DT_CAT(DT_COMPAT_zephyr_mapped_partition_LABEL_, label)

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
Parameters
labellowercase-and-underscores label property value.
Returns
a node identifier for the partition with that label property.