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>
diff --git a/tools/binman/control.py b/tools/binman/control.py
index 963f9b9..da33c88 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -57,7 +57,7 @@
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 @@
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 @@
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: