Skip to content

Commit 0907a05

Browse files
mbolivarcfriedt
authored andcommitted
scripts: dts: fix CMake DT API helper for compatible properties
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 <[email protected]>
1 parent e88be20 commit 0907a05

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

scripts/dts/gen_dts_cmake.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,8 @@ def main():
134134
cmake_prop = f'DT_PROP|{node.path}|{item}'
135135
cmake_props.append(f'"{cmake_prop}" "{escape(cmake_value)}"')
136136

137-
if item == 'compatible':
138-
# compatibles is always an array
139-
for comp in node.props[item].val:
140-
compatible2paths[comp].append(node.path)
137+
for comp in node.compats:
138+
compatible2paths[comp].append(node.path)
141139

142140
if node.regs is not None:
143141
cmake_props.append(f'"DT_REG|{node.path}|NUM" "{len(node.regs)}"')

0 commit comments

Comments
 (0)