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 E12BDC001B0 for ; Sun, 23 Jul 2023 03:44:24 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2F79A8661B; Sun, 23 Jul 2023 05:44:21 +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="LFDE9KVw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9616E8664F; Sun, 23 Jul 2023 05:44:15 +0200 (CEST) Received: from mail-oa1-x34.google.com (mail-oa1-x34.google.com [IPv6:2001:4860:4864:20::34]) (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 2C9A4865F0 for ; Sun, 23 Jul 2023 05:44:13 +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-oa1-x34.google.com with SMTP id 586e51a60fabf-1b038d7a5faso2561772fac.1 for ; Sat, 22 Jul 2023 20:44:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690083851; x=1690688651; 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=CgIv0XauZpc+dcf0EnqHtpNaactyn424AlRKknXAruw=; b=LFDE9KVw3j0Ds8Av53eir9TGZa4rB0msl/aW24Q1sSgog3ocnzeRRoJqZQmR9qnEB2 XF2WiLxfBzx0nlE2k1bxUh8mLyacK88HRnZAukMzZEq/kgwYmZomdM3ntU4f2Sf8NXxs Dgr8N/WjNKgCO8adrou7F8Id0L6aCtV3zwpts= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690083851; x=1690688651; 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=CgIv0XauZpc+dcf0EnqHtpNaactyn424AlRKknXAruw=; b=iTG1/cVmGcHUAujA4suqAoPGxMZKDhLYFvQDC9Jx0WsgAkv+Q1i1m9qSYmMDMAeV0A WUYwQsPdjps3Rr1tVrAEDlcgfIJ+K8b5Qpj6X9nuk8ponsJVrShbEHO76csI8I0OgJ+v BohaWkn8Vt2HP58+aOfHeMiEblulof2gNi0x2N5oFlYKGolqledhVXjjNU8duBDT6hKY 0krkYPyoQ0ko3A1sJ7tWUuR/9nLnzMksSzB9/n1W26p0a+wDgVthOXykvmlKcbtXnN/2 VAZ1sFQFJHwuet0oUCxvbzRLlg8esSu+94DvTcKGAB4nTucNAlbySv+p8XOw4MK7tOSj KXsA== X-Gm-Message-State: ABy/qLYSIbwGwUA1LexVvDde1R/xHIuEtvvBWkTfvO36G5nX2TBFygGv vRINTfFSZIF84W8tT21rYeRu9T2fFutoUfwj+/Y= X-Google-Smtp-Source: APBJJlFCjSflyE71L7GwsEJVfzSsx7KEBeDdT4RhfQiFz6dtJ6vkJtAha60RxUdyWOg7OBiwfkP3Ug== X-Received: by 2002:a05:6870:9a24:b0:1bb:11bd:d44 with SMTP id fo36-20020a0568709a2400b001bb11bd0d44mr7338009oab.9.1690083851636; Sat, 22 Jul 2023 20:44:11 -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 a11-20020a056638018b00b0042b3e04510asm2077384jaq.98.2023.07.22.20.44.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jul 2023 20:44:11 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Alper Nebi Yasak , Neha Malcom Francis , Stefan Herbrechtsmeier , Philippe Reynes , Peng Fan , Simon Glass Subject: [PATCH v2 1/6] binman: Produce a template-file after processing Date: Sat, 22 Jul 2023 21:43:52 -0600 Message-ID: <20230723034406.87673-2-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230723034406.87673-1-sjg@chromium.org> References: <20230723034406.87673-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 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 --- (no changes since v1) tools/binman/binman.rst | 4 ++++ tools/binman/control.py | 14 ++++++++++++-- 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 8f57b6cfc76f..67bc3e87531b 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 25e66814837d..9a9a4817eeaf 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -486,6 +486,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. @@ -498,11 +501,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 @@ -546,7 +553,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 e53181afb78a..80d41cf5c35f 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -6793,6 +6793,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') -- 2.41.0.487.g6d72f3e995-goog