Update regular expression in str2ident to replace percent sign (%)
character when creating identifiers.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Add gen defines and bnf for DT_BINDING_COMPAT_*, which allows
for getting a node's compatible string at compile time. Adds
DT_BINDING_COMPAT_TOKEN, DT_BINDING_COMPAT_UPPER_TOKEN, and
DT_BINDING_COMPAT_UNQUOTED.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Perry Naseck <pnaseck@media.mit.edu>
Zephyr's devicetree tooling parses and generates macros
for the ranges property but has no equivalent support for
dma-ranges, even though both are defined the same way by
the Devicetree Specification (§2.3.9) and edtlib.py already
has the machinery to parse address-translation triplets.
This adds the same pipeline that already exists for ranges.
edtlib.py now parses dma-ranges into Node. dma_ranges using
the same cell-based translation logic as Node via a new
_init_dma_ranges() method.
gen_defines.py emits DT_N_..._DMA_RANGES_* macros for each node
with a dma-ranges property through a new write_dma_ranges() function.
devicetree.h gains the DT_DMA_RANGES_* public API, including HAS_IDX,
CHILD_BUS_ADDRESS_BY_IDX, PARENT_BUS_ADDRESS_BY_IDX, LENGTH_BY_IDX,
NUM_DMA_RANGE, and FOREACH_DMA_RANGE. base.yaml documents the dma-ranges
property per DT spec §2.3.9.
Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
The required-with-a-default check runs on the property settings
left after includes are merged, so a binding that inherits a
default and deliberately overrides it with required was reported
even though nothing is wrong.
That combination is well defined: the required check runs first
and errors out when the property is absent, so the inherited
default never applies. Keep a copy of the properties declared
locally and warn only when both settings come from the same file.
Included files are merged into the raw contents in place, which
also covers any nested child binding, so the copy is taken before
the merge and handed down to each child binding in turn. A child
binding which is only inherited declares nothing of its own and
so gets an empty copy. Add tests covering the reported and the
exempt cases, up to the grandchild binding level.
Assisted-by: Claude Code:opus-4-8
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Update "out_dt_define" macro to allow integer types
as the value parameter. Prevents unneeded warning
when "val" is specified as an integer.
Signed-off-by: Omar Naffaa <onaffaa@qti.qualcomm.com>
Add a test to check that putting common
cpu props in the parent cpus node works.
Assisted-by: GitHub Copilot:GPT-5.3-Codex
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
This allows to put common props of
cpu nodes in the parent cpus node, as
specified in the devicetree spec in 3.8.
Assisted-by: GitHub Copilot:GPT-5.3-Codex
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Move `phy-handle` to use the dependency-mode prop
key instead of the hardcoded code.
Because all ethernet drivers only need to use the
phy-handle in the iface init, we can ignore the
phy-handle dependency completly instead of only
ignoring it if the phy-handle pointing to a child
node of the ethernet node.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
add dependency-mode prop key, so it can be
changed what dependency a phandle
in the dt introduces. With this it can be set
in the dt binding that a phandle is f.e. ignored
when the dt ordinal is calculated.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Emit a warning trace message when a DT property is required but
also provides a default value.
Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
Fixes this missing output, which helps with repducible build
debugging, to use the zephyr prefix when the bindings are located
there irrespective of if the (long deprecated) environmental value
is set
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Add devicetree reader macros for counter capture. These include
an index for the channel number and default flags. These are
intended to eventually to be used within drivers for timestamp
capturing.
Signed-off-by: Ryan McClelland <rymcclel@gmail.com>
Generates a new file for use by the build system which lists all
the paths to dts bindings used in a build, then from CMake adds a
dependency to these files so that if they are modified, CMake will
re-run.
This has been implemented by adding support to edtlib to output
details on bindings and binding paths inside of the python code
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Add optional min-len/max-len properties to edtlib spec to specify a valid
length range for array type values. Basically same as 7ddcb93d4a but
for prop length.
Assisted-by: Gemini
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Fix devicetree coding style regarding whitespaces through the tree.
This affects code snippets inside documentation, comments, error messages
as to encourage a style that passes CI. Follow-up of #101619
Signed-off-by: Josuah Demangeon <me@josuah.net>
Add the `DT_NODELABEL_C_TOKEN` and
`DT_NODELABEL_C_TOKEN_BY_IDX` macros to retrieve
the C symbolic name of a node.
Signed-off-by: James Roy <rruuaanng@outlook.com>
Update the const value validation, to also include falsy constants, and
check for plain integer types in case of int/array property type.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
If the binding has a default property that is an int or an array of
integers, we verify for plain ints.
As bool is a subclass of int in Python we should check for non boolean
values.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Add optional min/max properties to edtlib spec to specify a valid range for
int or array type values.
Assisted-by: Claude:claude-sonnet-4.6
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Add a test case verifying that a parenthesized expression evaluating to
a negative value (e.g. `(4 - 6)`) is preserved as signed when decoded
via to_num(signed_aware=True) and to_nums(signed_aware=True), extending
the existing coverage for negative literals like `(-1)`.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Linter not ensures that > and ] have no white spaces when these are
preceded with a block comment.
Signed-off-by: Kyle Bonnici <kylebonnici@hotmail.com>
Add generated macros for counting nodes on a specific bus under a bus
controller:
- DT_(INST_)DESCENDANT_NUM_ON_BUS()
- DT_(INST_)DESCENDANT_NUM_ON_BUS_STATUS_OKAY()
The count intentionally walks descendants instead of only direct children.
This covers common devicetree structures where helper/container nodes sit
between a controller and the actual on-bus device nodes.
Traversal stops at child bus-controller nodes, so devices behind sub-buses
are not counted in the parent controller's result.
Also add edtlib Node.on_bus resolution, validated against the parent bus
controller bus types, so generation uses the resolved on-bus value.
Signed-off-by: Swift Tian <swift.tian@ambiq.com>
Make sure we cover different types of signed_aware parsing. Negative
literals like (-1) or a hex value like 0xFFFFFFFF should result in
different values.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Add negative and negative-array properties to the test binding and
test DTS to verify that signed integer literals are correctly
propagated through edtlib as negative Python integers.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Track the byte offsets of cells parsed from negative literals
(e.g. (-1)) in a new _signed_cell_offsets set on Property. Expose
this via a signed_aware parameter on to_num() and to_nums(): when
True, each cell is interpreted as signed only if it was written as a
negative literal, leaving positive and hex values unsigned.
Update edtlib to pass signed_aware=True when reading "int" and "array"
typed properties so binding values reflect the sign as written in the DTS
source.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Instead of writing one item for each set_target_properties()
set_target_properties(${DEVICETREE_TARGET} PROPERTIES <item1>)
set_target_properties(${DEVICETREE_TARGET} PROPERTIES <item2>)
...
set_target_properties(${DEVICETREE_TARGET} PROPERTIES <itemN>)
Write one set_target_properties which contains all items:
set_target_properties(${DEVICETREE_TARGET}
PROPERTIES
<item1>
<item2>
...
<itemN>
)
Later when edt.pickle.cmake is included in extensions.cmake
via include(${gen_dts_cmake_output})
CMake will process the file much faster.
Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
Make sure that we don't allow bindings which manually
specify any defaults for the status
properties. See DTSpec 2.3.4.
Signed-off-by: Kyle Bonnici <kylebonnici@hotmail.com>
The status property indicates the operational status of a device.
The lack of a status property should be treated as
if the property existed with the value of "okay".
We are currently allowing defaults.
This is a continuation of
https://github.com/zephyrproject-rtos/zephyr/pull/104931
Signed-off-by: Kyle Bonnici <kylebonnici@hotmail.com>
Add quotes around binding file paths in error messages for better
readability and consistency. Also normalize paths using os.path.normpath
to ensure consistent path separators across platforms.
Signed-off-by: Yves Wang <zhengjia.wang@nxp.com>
Introduce DT_FOREACH_REG and DT_INST_FOREACH_REG macros to enable
iteration over reg entries in devicetree nodes by invoking a user-
supplied macro per entry. Add support for macros accepting a
separator and variadic arguments with the new DT_FOREACH_REG_SEP,
DT_FOREACH_REG_VARGS, and DT_FOREACH_REG_SEP_VARGS macros, as well
as their DT_INST_ variants.
The DT_FOREACH_REG macro mirrors the behavior of the ranges property.
Update the devicetree macro generation logic in gen_defines.py to
emit the new macro variants. Document the additions by expanding the
Augmented Backus-Naur Form grammar in macros.bnf. Add detailed
comments with usage examples and parameter details for all new macros.
Expand test coverage with new overlay nodes and dedicated tests to
verify macro correctness and behavior, across various node scenarios
including multi-register, single-register, and nodes lacking reg
properties.
Signed-off-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Signed-off-by: Svitlana Drozd <svitlana_drozd@epam.com>
The spec makes it clear that node address can be omitted from node path
if not unambiguous see 2.2.3. Path Names
> A unit address may be omitted if the full path to the node is
unambiguous.
e.g.
````
/ {
foo@10 {};
}
```
both paths -> /foo and /foo@10 should work.
Signed-off-by: Kyle Bonnici <kylebonnici@hotmail.com>
IMO the spec is clear about the case insensitivity. The node address
must be match the reg value see 2.2.1.1. Node Name Requirements
> The unit-address must match the first address specified in the reg
property of the node.
reg property is a prop-encoded array and by definition.
reg = <0xA> or reg = <0xa> are the same. hence Both foo@a and foo@A
are the same.
Signed-off-by: Kyle Bonnici <kylebonnici@hotmail.com>
According to the DT spec the 'phy-handle' phandle prop
is required, when a phy is used. As this phy could be
a child, we have to filter it out to not get a cycle in the graph.
This allows the phy to be a child of the eternet controller,
when using the 'phy-handle' dt prop.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Extend the special casing of specifer space to include io-channels,
making the implementation a bit more easily scalable for the
future as well. This allows defining io-channels like gpios,
prepending a name like foo-io-channels, which is useful when
multiple groups of io-channels need to be defined for a node:
foo {
bar-io-channels = <&baz 0>, <&baz 1>;
qiz-io-channels = <&baz 2>, <&baz 3>;
};
This is useful for defining channels to be read in parralel
sequences.
Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
Adds support for outputting partition information on this new
compatible, to match fixed-partitions
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Make sure that we don't allow bindings which manually
specify any defaults for the #address-cells or #size-cells
properties. See DTSpec 2.3.5.
Signed-off-by: Martí Bolívar <marti.bolivar@oss.qualcomm.com>
The devicetree specification section 2.3.5 says:
The #address-cells and #size-cells properties are not inherited
from ancestors in the devicetree. They shall be explicitly
defined.
A DTSpec-compliant boot program shall supply #address-cells and
#size-cells on all nodes that have children.
If missing, a client program should assume a default value of 2
for #address-cells, and a value of 1 for #size- cells.
We are currently allowing defaults -- and notably, different defaults
from those recommended in the spec -- in the zephyr bindings for these
properties to pass without complaint.
Further, allowing the user to specify a default other than the
recommendations by the spec would be a bad design decision in my
opinion.
Handle this by erroring out explicitly when we try to set these
defaults in a binding. It's fine for people to do things like define
descriptions for these properties in a binding for some specific
compatible, but it's a footgun to allow bindings that would seem to
allow overruling the specification's explicit recommendation.
Signed-off-by: Martí Bolívar <marti.bolivar@oss.qualcomm.com>
Commit f55358bcbf changed all hex values to
use lowercase characters. Update the test accordingly.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Apply chnages from dts-linter 0.3.9.
Improve compliance with DTS Coding Style which says that:
4) Hex values in properties, e.g. “reg”, shall use lowercase hex.
The address part can be padded with leading zeros.
Signed-off-by: Kyle Bonnici <kylebonnici@hotmail.com>