diff --git a/scripts/dts/python-devicetree/src/devicetree/edtlib.py b/scripts/dts/python-devicetree/src/devicetree/edtlib.py index b52a516d454463..0eb8dd832d190d 100644 --- a/scripts/dts/python-devicetree/src/devicetree/edtlib.py +++ b/scripts/dts/python-devicetree/src/devicetree/edtlib.py @@ -2061,6 +2061,10 @@ def _init_graph(self) -> None: # first time the scc_order property is read. for node in self.nodes: + # Always insert root node + if not node.parent: + self._graph.add_node(node) + # A Node always depends on its parent. for child in node.children.values(): self._graph.add_edge(child, node) diff --git a/scripts/dts/python-devicetree/src/devicetree/grutils.py b/scripts/dts/python-devicetree/src/devicetree/grutils.py index c3ce825b2029fd..452ee4aaaae96a 100644 --- a/scripts/dts/python-devicetree/src/devicetree/grutils.py +++ b/scripts/dts/python-devicetree/src/devicetree/grutils.py @@ -26,6 +26,12 @@ def __init__(self, root=None): self.__reverse_map = collections.defaultdict(set) self.__nodes = set() + def add_node(self, node): + """ + Add a node without any target to the graph. + """ + self.__nodes.add(node) + def add_edge(self, source, target): """ Add a directed edge from the C{source} to the C{target}.