summaryrefslogtreecommitdiff
path: root/tools/binman/control.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-07-22 21:43:56 -0600
committerSimon Glass <sjg@chromium.org>2023-08-02 12:05:57 -0600
commitaf41b24ebac86f25145f39f4eec4467d4c501bed (patch)
tree52998ca4575604cd2b58593e4fe0311106cb40d6 /tools/binman/control.py
parent589c2d9e514412aba4556d06ce3bdfb9c8800fa1 (diff)
binman: Remove templates after use
It is not necessary to keep templates around after they have been processed. They can cause confusion and potentially duplicate phandles. Remove them. Use the same means of detecting a template node in _ReadImageDesc so that the two places are consistent. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/control.py')
-rw-r--r--tools/binman/control.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/tools/binman/control.py b/tools/binman/control.py
index 963f9b96638..da33c88883e 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -57,7 +57,7 @@ def _ReadImageDesc(binman_node, use_expanded):
images = OrderedDict()
if 'multiple-images' in binman_node.props:
for node in binman_node.subnodes:
- if 'template' not in node.name:
+ if not node.name.startswith('template'):
images[node.name] = Image(node.name, node,
use_expanded=use_expanded)
else:
@@ -519,6 +519,13 @@ def _ProcessTemplates(parent):
found |= _ProcessTemplates(node)
return found
+def _RemoveTemplates(parent):
+ """Remove any templates in the binman description
+ """
+ for node in parent.subnodes:
+ if node.name.startswith('template'):
+ node.Delete()
+
def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded):
"""Prepare the images to be processed and select the device tree
@@ -566,6 +573,11 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded):
fname = tools.get_output_filename('u-boot.dtb.tmpl1')
tools.write_file(fname, dtb.GetContents())
+ _RemoveTemplates(node)
+ dtb.Sync(True)
+ fname = tools.get_output_filename('u-boot.dtb.tmpl2')
+ tools.write_file(fname, dtb.GetContents())
+
images = _ReadImageDesc(node, use_expanded)
if select_images: