[PATCH 1/3] tools: binman: control.py: Propagate bootph-* properties to supernodes

Simon Glass sjg at chromium.org
Wed Apr 23 14:29:32 CEST 2025


From: Moteen Shah <m-shah at ti.com>

Add a function to scan through all the nodes in the device-tree
recusively for bootph-* property. If found, propagate it to all
of its parent nodes up the hierarchy.

Signed-off-by: Moteen Shah <m-shah at ti.com>
Signed-off-by: Simon Glass <sjg at chromium.org>
---

 tools/binman/control.py | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/tools/binman/control.py b/tools/binman/control.py
index 81f61e3e152..b703bdf482e 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -530,6 +530,35 @@ def _RemoveTemplates(parent):
     for node in del_nodes:
         node.Delete()
 
+def prop_bootph_to_parent(node, prop):
+    """Propagates bootph-* property to all the parent
+    nodes up the hierarchy
+    """
+    parent = node.parent
+    if parent == None or parent.props.get(prop):
+       return
+
+    while parent:
+        parent.AddEmptyProp(prop, 0)
+        parent = parent.parent
+
+def scan_and_prop_bootph(node):
+    """Scan the device tree and set the bootph-* property if its present
+    in subnode
+
+    This is used to set the bootph-* property in the parent node if a
+    "bootph-*" property is found in any of the subnodes of the parent
+    node.
+    """
+    bootph_prop = ['bootph-all', 'bootph-some-ram', 'bootph-pre-ram', 'bootph-pre-sram']
+
+    for props in bootph_prop:
+        if node.props.get(props):
+            prop_bootph_to_parent(node, props)
+
+    for subnode in node.subnodes:
+       scan_and_prop_bootph(subnode)
+
 def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, indir):
     """Prepare the images to be processed and select the device tree
 
@@ -567,8 +596,10 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, ind
         indir = []
     dtb_fname = fdt_util.EnsureCompiled(dtb_fname, indir=indir)
     fname = tools.get_output_filename('u-boot.dtb.out')
-    tools.write_file(fname, tools.read_file(dtb_fname))
-    dtb = fdt.FdtScan(fname)
+    dtb = fdt.FdtScan(dtb_fname)
+    scan_and_prop_bootph(dtb.GetRoot())
+    dtb.Sync(True)
+    tools.write_file(dtb_fname, dtb.GetContents())
 
     node = _FindBinmanNode(dtb)
     if not node:
-- 
2.43.0

base-commit: 4446bc331c65d3efb8a9321d6368c61edb56479b
branch: try-ti2


More information about the U-Boot mailing list