diff options
author | Simon Glass <sjg@chromium.org> | 2023-07-22 21:43:52 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2023-08-02 12:05:57 -0600 |
commit | b2f47a599cad3b618c6d7b4356ea6ea2625309c0 (patch) | |
tree | d525d85bdce3272e4dbe34cf48fb74e63abd83a6 /tools | |
parent | 491f90e0510577baa99c218d75a3fad02df27221 (diff) | |
download | u-boot-b2f47a599cad3b618c6d7b4356ea6ea2625309c0.zip u-boot-b2f47a599cad3b618c6d7b4356ea6ea2625309c0.tar.gz u-boot-b2f47a599cad3b618c6d7b4356ea6ea2625309c0.tar.bz2 |
binman: Produce a template-file after processing
This file aids debugging when binman fails to get far enough to write out
the final devicetree file. Write it immediate after template processing.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/binman/binman.rst | 4 | ||||
-rw-r--r-- | tools/binman/control.py | 14 | ||||
-rw-r--r-- | tools/binman/ftest.py | 9 |
3 files changed, 25 insertions, 2 deletions
diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst index 8f57b6c..67bc3e8 100644 --- a/tools/binman/binman.rst +++ b/tools/binman/binman.rst @@ -1256,6 +1256,10 @@ Properties in the template node are inserted into the destination node if they do not exist there. In the example above, `some-property` is added to each of `spi-image` and `mmc-image`. +The initial devicetree produced by the templating process is written to the +`u-boot.dtb.tmpl1` file. This can be useful to see what is going on if there is +a failure before the final `u-boot.dtb.out` file is written. + Note that template nodes are not removed from the binman description at present. diff --git a/tools/binman/control.py b/tools/binman/control.py index 2aa6307..963f9b9 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -494,6 +494,9 @@ def _ProcessTemplates(parent): Args: parent: Binman node to process (typically /binman) + Returns: + bool: True if any templates were processed + Search though each target node looking for those with an 'insert-template' property. Use that as a list of references to template nodes to use to adjust the target node. @@ -506,11 +509,15 @@ def _ProcessTemplates(parent): See 'Templates' in the Binman documnentation for details. """ + found = False for node in parent.subnodes: tmpl = fdt_util.GetPhandleList(node, 'insert-template') if tmpl: node.copy_subnodes_from_phandles(tmpl) - _ProcessTemplates(node) + found = True + + found |= _ProcessTemplates(node) + return found def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded): """Prepare the images to be processed and select the device tree @@ -554,7 +561,10 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded): raise ValueError("Device tree '%s' does not have a 'binman' " "node" % dtb_fname) - _ProcessTemplates(node) + if _ProcessTemplates(node): + dtb.Sync(True) + fname = tools.get_output_filename('u-boot.dtb.tmpl1') + tools.write_file(fname, dtb.GetContents()) images = _ReadImageDesc(node, use_expanded) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 0e026ec..b15f5ac 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -6862,6 +6862,15 @@ fdt fdtmap Extract the devicetree blob from the fdtmap second = U_BOOT_DATA + b'#' + VGA_DATA + U_BOOT_DTB_DATA self.assertEqual(U_BOOT_IMG_DATA + first + second, data) + dtb_fname1 = tools.get_output_filename('u-boot.dtb.tmpl1') + self.assertTrue(os.path.exists(dtb_fname1)) + dtb = fdt.Fdt.FromData(tools.read_file(dtb_fname1)) + dtb.Scan() + node1 = dtb.GetNode('/binman/template') + self.assertTrue(node1) + vga = dtb.GetNode('/binman/first/intel-vga') + self.assertTrue(vga) + def testTemplateBlobMulti(self): """Test using a template with 'multiple-images' enabled""" TestFunctional._MakeInputFile('my-blob.bin', b'blob') |