Skip to content

Conversation

tomchy
Copy link
Contributor

@tomchy tomchy commented Oct 2, 2025

…roperties

Our build system DT API has a dt_comp_path() function used to look up paths of nodes with a given compatible. This relies on the generated edt.pickle.cmake file in the build directory to look inside the concrete devicetree for the current application build.

The script gen_dts_cmake.py is responsible for generating edt.pickle.cmake. It currently generates the data needed by dt_comp_path() by looking inside each edtlib.Node object's "props" attribute. This attribute in turn is fed by the "properties:" key in the node's YAML binding. This leads to an edge case which is breaking the dt_comp_path() API.

In most cases, we don't notice this edge case because base.yaml, which is included by nearly all bindings, has a definition for "compatible" in its "properties:" map. However, bindings are not required to include base.yaml, and bindings do not have to explicitliy define a "compatible" entry in their "properties:". An example of a binding that does neither is fixed-partitions.yaml: it only has #address-cells and #size-cells in its "properties:".

Nonetheless, "compatible:" is always a valid property name because it's defined in the DT spec, and we should make the CMake API robustly detect all nodes with a given compatible, regardless of whether that node's binding explicitly defines it or not.

To make this happen, rely on the edtlib.Node.compats attribute instead of edtlib.Node.props. The compats attribute is always defined even if the node's YAML binding doesn't have an explicit entry for "compatible".

Upstream PR #: 96875

@tomchy tomchy force-pushed the bugfix/dts/NCSDK-NONE_fix_partition_compatibles branch from 905c407 to ab11037 Compare October 3, 2025 08:53
…roperties

Our build system DT API has a dt_comp_path() function used to look up
paths of nodes with a given compatible. This relies on the generated
edt.pickle.cmake file in the build directory to look inside the
concrete devicetree for the current application build.

The script gen_dts_cmake.py is responsible for generating
edt.pickle.cmake. It currently generates the data needed by
dt_comp_path() by looking inside each edtlib.Node object's "props"
attribute. This attribute in turn is fed by the "properties:" key in
the node's YAML binding. This leads to an edge case which is breaking
the dt_comp_path() API.

In most cases, we don't notice this edge case because base.yaml, which
is included by nearly all bindings, has a definition for "compatible"
in its "properties:" map. However, bindings are not required to
include base.yaml, and bindings do not have to explicitliy define a
"compatible" entry in their "properties:". An example of a binding
that does neither is fixed-partitions.yaml: it only has #address-cells
and #size-cells in its "properties:".

Nonetheless, "compatible:" is always a valid property name because
it's defined in the DT spec, and we should make the CMake API robustly
detect all nodes with a given compatible, regardless of whether that
node's binding explicitly defines it or not.

To make this happen, rely on the edtlib.Node.compats attribute instead
of edtlib.Node.props. The compats attribute is always defined even if
the node's YAML binding doesn't have an explicit entry for
"compatible".

Signed-off-by: Martí Bolívar <marti.bolivar@oss.qualcomm.com>
Signed-off-by: Tomasz Chyrowicz <tomasz.chyrowicz@nordicsemi.no>
(cherry picked from commit 0907a05baf062e0029f37e4601ad6715d1a2cf1a)
@tomchy tomchy force-pushed the bugfix/dts/NCSDK-NONE_fix_partition_compatibles branch from ab11037 to f454147 Compare October 6, 2025 07:40
@tomchy tomchy changed the title [nrf fromlist] scripts: dts: fix CMake DT API helper for compatible p… [nrf fromtree] scripts: dts: fix CMake DT API helper for compatible p… Oct 6, 2025
@nordicjm nordicjm merged commit d47f109 into nrfconnect:main Oct 6, 2025
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants