From patchwork Tue Jul 18 13:24:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1809290 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=hyFJ/fIV; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R50C121Qfz20Cs for ; Tue, 18 Jul 2023 23:28:29 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D7CDE86763; Tue, 18 Jul 2023 15:25:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="hyFJ/fIV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 320FC866F0; Tue, 18 Jul 2023 15:25:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F26E78671F for ; Tue, 18 Jul 2023 15:25:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x133.google.com with SMTP id e9e14a558f8ab-3476d0b5295so25877615ab.1 for ; Tue, 18 Jul 2023 06:25:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689686716; x=1692278716; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gz5+oMXkYKLDVtbRKBbHNewaPFVWIe1r2R14aC4vybI=; b=hyFJ/fIVS15Ot7UCEFNtEVbFFeZE4q5Oemq0rdl8rveucPgRL9kY5J57n/VTBlCpEG kZ4ilDQpv6LPVeAGEob4sAbLfsbjLnFASI0/WFusK1XdLIuSHYp4QexHZIqhLdas/Z4w 1T+VZTHPzaqLoJTn/MOA1FdiqoCIEV51GiLw8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689686716; x=1692278716; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gz5+oMXkYKLDVtbRKBbHNewaPFVWIe1r2R14aC4vybI=; b=hXsRtKZIEvPKKSxdAETJ8pD0ixmdWlxcOT5k1Ut2o+sE5NCkbekhxpvph11kw8gWmi Zy/+KC6KGItkOKEkHI1YlMyZ4p30SUqRe2OhcI6aqC6k3SnxPNiv4Lfxji5QgRbEo9+a io0X9Beps32oIkDY/AH6bcttpxdjf38PBnC17CCnQ6pmkDLxfNAGVhBaOkZBed6X7Dsm BxmXvJdr2DTDGmEdJApuPJmkU5Qny/aSgJBxfHVm0Db5dSDe6I9H3mdXOVsl+ljUEnYd qZiiFCGB2k4QmB/n/C9oTAYP3O0WZZT6E/NFWvhGhahrUjPzEFZqfBw+Z5fkF6Sugqy/ 349w== X-Gm-Message-State: ABy/qLYEkj3463SjXTzXCWzViwP4nzTefPl40wSWlD7x507wpunc9RJU duDWL57iTe0ePvJR3rBngUDjVR2rkNC3UWJftrQ= X-Google-Smtp-Source: APBJJlEHSIfSYL+WNDRLZ5uiDefxA/VYvErXw3pofjMVkTilKvBDZI3wypzKIuilQGFgMpKhEBOn1g== X-Received: by 2002:a05:6e02:1546:b0:346:4283:de9c with SMTP id j6-20020a056e02154600b003464283de9cmr2795363ilu.11.1689686716592; Tue, 18 Jul 2023 06:25:16 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id z15-20020a92bf0f000000b00338a1272ce1sm697656ilh.52.2023.07.18.06.25.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 06:25:16 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Marek Vasut , Jan Kiszka , Simon Glass , Alper Nebi Yasak , Neha Malcom Francis , Peng Fan , Philippe Reynes , Stefan Herbrechtsmeier Subject: [PATCH v5 18/20] binman: Support templates at any level Date: Tue, 18 Jul 2023 07:24:07 -0600 Message-ID: <20230718132453.626947-19-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.455.g037347b96a-goog In-Reply-To: <20230718132453.626947-1-sjg@chromium.org> References: <20230718132453.626947-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Allow templates to be used inside a section, not just in the top-level /binman node. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/control.py | 5 ++- tools/binman/ftest.py | 8 ++++ tools/binman/test/289_template_section.dts | 52 ++++++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 tools/binman/test/289_template_section.dts diff --git a/tools/binman/control.py b/tools/binman/control.py index f92c152285ce..25e66814837d 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -493,8 +493,8 @@ def _ProcessTemplates(parent): 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. """ @@ -502,6 +502,7 @@ def _ProcessTemplates(parent): 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 diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index dfca6316624c..e96223cbd892 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -6812,6 +6812,14 @@ fdt fdtmap Extract the devicetree blob from the fdtmap 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() diff --git a/tools/binman/test/289_template_section.dts b/tools/binman/test/289_template_section.dts new file mode 100644 index 000000000000..8a744a0cf686 --- /dev/null +++ b/tools/binman/test/289_template_section.dts @@ -0,0 +1,52 @@ +// 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 { + }; + }; + }; +};