Processing involves copying each subnode of the template node into the
target node.
- For now this is not done recursively, so templates must be at the top level
- of the binman image.
+ This is done recursively, so templates can be at any level of the binman
+ image, e.g. inside a section.
See 'Templates' in the Binman documnentation for details.
"""
tmpl = fdt_util.GetPhandleList(node, 'insert-template')
if tmpl:
node.copy_subnodes_from_phandles(tmpl)
+ _ProcessTemplates(node)
def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded):
"""Prepare the images to be processed and select the device tree
tools.write_file(fname, fit_data)
out = tools.run('dumpimage', '-l', fname)
+ def testTemplateSection(self):
+ """Test using a template in a section (not at top level)"""
+ TestFunctional._MakeInputFile('vga2.bin', b'#' + VGA_DATA)
+ data = self._DoReadFile('289_template_section.dts')
+ first = U_BOOT_DATA + VGA_DATA + U_BOOT_DTB_DATA
+ second = U_BOOT_DATA + b'#' + VGA_DATA + U_BOOT_DTB_DATA
+ self.assertEqual(U_BOOT_IMG_DATA + first + second + first, data)
+
if __name__ == "__main__":
unittest.main()
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ binman {
+ u-boot-img {
+ };
+
+ common_part: template {
+ u-boot {
+ };
+
+ intel-vga {
+ filename = "vga.bin";
+ };
+ };
+
+ first {
+ type = "section";
+ insert-template = <&common_part>;
+
+ u-boot-dtb {
+ };
+ };
+
+ section {
+ second {
+ type = "section";
+ insert-template = <&common_part>;
+
+ u-boot-dtb {
+ };
+
+ intel-vga {
+ filename = "vga2.bin";
+ };
+ };
+ };
+
+ second {
+ type = "section";
+ insert-template = <&common_part>;
+
+ u-boot-dtb {
+ };
+ };
+ };
+};