Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04981EB64DC for ; Tue, 11 Jul 2023 15:03:41 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DFF50868D0; Tue, 11 Jul 2023 17:00:38 +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="nJQyolip"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AB50A868BC; Tue, 11 Jul 2023 17:00:27 +0200 (CEST) Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) (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 40BF7868C9 for ; Tue, 11 Jul 2023 17:00:02 +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-x130.google.com with SMTP id e9e14a558f8ab-345e55a62d8so22295705ab.3 for ; Tue, 11 Jul 2023 08:00:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689087600; x=1691679600; 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=D3FYzrjz5MGo4VInjax8pKGazCKlcpfQOLaaqNduuhc=; b=nJQyolipbyYuRVUqoY2QohzPMzxNLkA66uT8wmNnwPTQG8VjcpkSrO2ju2g8USFgqS piK5Cl1bAME2hqWtwkSlDizHrBn3ixkzrjuzFd2mqJT5mMLIQQryA94B31DkDlKMN/7X 6M/b419/Pd0PPxaq9smVk8+LzF9NZ627CBcEc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689087600; x=1691679600; 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=D3FYzrjz5MGo4VInjax8pKGazCKlcpfQOLaaqNduuhc=; b=JJ3VdxlAHtPE3TpWKvi7SSM1Jn/IkrjlaSqnMSjZ4O1KNHnQhZEIY7pB9dwMXkHLny vrIDyaq5tPi9jRaUwbBIMMaxf4cFUyji+7c/ctzt30WKZsBRHrQ8qIcdaULLS+f8j2t1 cmJTYggSR7me10b6QmYSkdSn8sxo/SsuKL9An4ZW04WPvoQbah+xej0M4UsPlcwXAblE urO6BIgDANs+j5D9A0vS04ydFo7E1rt1jXzxBVsC3lhNkdmcrFBRshiLihNKz65BYV05 D45lnfVA6FrirWxmh+oPlYanSekPXzpP/SnyYgPBO9ujMwRFTLMZw+UvWjBytOgWRcIT DYbg== X-Gm-Message-State: ABy/qLYUkwEJhF5+oUekqqUzNTbVZAufdHPgwOprccOoXHd5uzA2V6Re Ix80UVWycqsI6SnxWIYA/LSCOlKzZtCTUHkZenY= X-Google-Smtp-Source: APBJJlHSWAs6KLN0CrhM8vLUMQs6D2N3yTiAAmU9kkDeS8E4CrsCK9OX4nhBU2weMnvYymcYOWm3bA== X-Received: by 2002:a92:ca91:0:b0:345:b923:971a with SMTP id t17-20020a92ca91000000b00345b923971amr15197342ilo.0.1689087600167; Tue, 11 Jul 2023 08:00:00 -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 v6-20020a92cd46000000b00338a1272ce1sm658881ilq.52.2023.07.11.07.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jul 2023 07:59:59 -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 v4 18/20] binman: Support templates at any level Date: Tue, 11 Jul 2023 08:59:20 -0600 Message-ID: <20230711145935.2289816-19-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.390.g38632f3daf-goog In-Reply-To: <20230711145935.2289816-1-sjg@chromium.org> References: <20230711145935.2289816-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- (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 { + }; + }; + }; +}; -- 2.41.0.390.g38632f3daf-goog