Zephyr API Documentation 4.0.0-rc2
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Devicetree Fixed Partition API

Macros

#define DT_NODE_BY_FIXED_PARTITION_LABEL(label)
 Get a node identifier for a fixed partition with a given label property.
 
#define DT_HAS_FIXED_PARTITION_LABEL(label)
 Test if a fixed partition with a given label property exists.
 
#define DT_FIXED_PARTITION_EXISTS(node_id)
 Test if fixed-partition compatible node exists.
 
#define DT_FIXED_PARTITION_ID(node_id)
 Get a numeric identifier for a fixed partition.
 
#define DT_MEM_FROM_FIXED_PARTITION(node_id)
 Get the node identifier of the flash memory for a partition.
 
#define DT_MTD_FROM_FIXED_PARTITION(node_id)
 Get the node identifier of the flash controller for a partition.
 
#define DT_FIXED_PARTITION_ADDR(node_id)
 Get the absolute address of a fixed partition.
 

Detailed Description

Macro Definition Documentation

◆ DT_FIXED_PARTITION_ADDR

#define DT_FIXED_PARTITION_ADDR ( node_id)

#include <zephyr/devicetree/fixed-partitions.h>

Value:
#define DT_MEM_FROM_FIXED_PARTITION(node_id)
Get the node identifier of the flash memory for a partition.
Definition fixed-partitions.h:86
#define DT_REG_ADDR(node_id)
Get a node's (only) register block address.
Definition devicetree.h:2433

Get the absolute address of a fixed partition.

Example devicetree fragment:

&flash_controller {
        flash@1000000 {
                compatible = "soc-nv-flash";
                partitions {
                        compatible = "fixed-partitions";
                        storage_partition: partition@3a000 {
                                label = "storage";
                        };
                };
        };
};

Here, the "storage" partition is seen to belong to flash memory starting at address 0x1000000. The partition's unit address of 0x3a000 represents an offset inside that flash memory.

Example usage:

DT_FIXED_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 fixed-partitions child node
Returns
the partition's offset plus the base address of the flash node containing it.

◆ DT_FIXED_PARTITION_EXISTS

#define DT_FIXED_PARTITION_EXISTS ( node_id)

#include <zephyr/devicetree/fixed-partitions.h>

Value:
DT_NODE_HAS_COMPAT(DT_PARENT(node_id), fixed_partitions)
#define DT_NODE_HAS_COMPAT(node_id, compat)
Does a devicetree node match a compatible?
Definition devicetree.h:3644
#define DT_PARENT(node_id)
Get a node identifier for a parent node.
Definition devicetree.h:357

Test if fixed-partition compatible node exists.

Parameters
node_idDTS node to test
Returns
1 if node exists and is fixed-partition compatible, 0 otherwise.

◆ DT_FIXED_PARTITION_ID

#define DT_FIXED_PARTITION_ID ( node_id)

#include <zephyr/devicetree/fixed-partitions.h>

Value:
DT_CAT(node_id, _PARTITION_ID)

Get a numeric identifier for a fixed partition.

Parameters
node_idnode identifier for a fixed-partitions child node
Returns
the partition's ID, a unique zero-based index number

◆ DT_HAS_FIXED_PARTITION_LABEL

#define DT_HAS_FIXED_PARTITION_LABEL ( label)

#include <zephyr/devicetree/fixed-partitions.h>

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

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

Parameters
labellowercase-and-underscores label property value
Returns
1 if any "fixed-partitions" child node has the given label, 0 otherwise.

◆ DT_MEM_FROM_FIXED_PARTITION

#define DT_MEM_FROM_FIXED_PARTITION ( node_id)

#include <zephyr/devicetree/fixed-partitions.h>

Value:
COND_CODE_1(DT_NODE_HAS_COMPAT(DT_GPARENT(node_id), soc_nv_flash), (DT_GPARENT(node_id)), \
#define DT_INVALID_NODE
Name for an invalid node identifier.
Definition devicetree.h:83
#define DT_GPARENT(node_id)
Get a node identifier for a grandparent node.
Definition devicetree.h:382
#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:195

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

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

◆ DT_MTD_FROM_FIXED_PARTITION

#define DT_MTD_FROM_FIXED_PARTITION ( node_id)

#include <zephyr/devicetree/fixed-partitions.h>

Value:
#define DT_NODE_EXISTS(node_id)
Does a node identifier refer to a node?
Definition devicetree.h:3537

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

Parameters
node_idnode identifier for a fixed-partitions child node
Returns
the node identifier of the memory technology device that contains the fixed-partitions node.

◆ DT_NODE_BY_FIXED_PARTITION_LABEL

#define DT_NODE_BY_FIXED_PARTITION_LABEL ( label)

#include <zephyr/devicetree/fixed-partitions.h>

Value:
DT_CAT(DT_COMPAT_fixed_partitions_LABEL_, label)

Get a node identifier for a fixed partition with a given label property.

Example devicetree fragment:

flash@... {
         partitions {
                 compatible = "fixed-partitions";
                 boot_partition: partition@0 {
                         label = "mcuboot";
                 };
                 slot0_partition: partition@c000 {
                         label = "image-0";
                 };
                 ...
         };
};

Example usage:

DT_NODE_BY_FIXED_PARTITION_LABEL(mcuboot) // node identifier for boot_partition
DT_NODE_BY_FIXED_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