From patchwork Fri Jan 28 19:37:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 1585896 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=siemens.com header.i=@siemens.com header.a=rsa-sha256 header.s=selector2 header.b=s75+tEZY; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jlnn74XcSz9t3b for ; Sat, 29 Jan 2022 06:38:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A711A81F9A; Fri, 28 Jan 2022 20:38:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=siemens.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=siemens.com header.i=@siemens.com header.b="s75+tEZY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 890E6820F8; Fri, 28 Jan 2022 20:37:59 +0100 (CET) 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,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on20600.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1b::600]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D76FE8169D for ; Fri, 28 Jan 2022 20:37:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=siemens.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jan.kiszka@siemens.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kD3OK74nKuLL8SQ4JVkKiuAbXm4/eqtYEarsf90Yji7HCA6IENgR0GY14VrE5x+cZKGcB1isEEqtxklJXdYw8V6JrqtZDWt8DXTKbqhJzcTWEuCZxybyfbJANq0e0Cy2t8pbXJS2hJTn8ArR8nOziGLNWL2TONkncD0ngqU40bE3d6PYl+e+a9EY4MMmdZsdcn7PYDSOYAz1TUFnpnGC580Zv5asxJhYTowwrI34KbnllCbNsJJ06x2f9ejAEVI/QLnOKITETiH2UF1LS0L+XGUdCXceBGCXNVf6UKOkQ96R944cVBLpp4hVHReBAIfYZxh45REbOWGEevjClWFJCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2968BNcoYDES9qEHyh68qksJto7CcCvnVoLFWajH0e8=; b=S0B8KdIThg8YhI1uWwjMLEuTlQtl5JGibSuxzKTWi8tN4xB/OPcWNqfYXSVLP66Xn1tr6/Pr+YSSGIoMpcXChM0NKprPEDtffS2hmdWRz2ly7S8wB9SapYf6zy6VccwDct9bQQe7TkgMY8nlQJJoiZGPBOz05oIbnJoT7qdwM0vcX+rQxlck+9Ib9EtgXKe1zWWXLu0z1FUYqt7uCMaBffUQ85oCUWMITzDGoChn3hMx9MzzwZSIrVoFFAn+w4g+1By1nrQunkwcVST58l1D/jf0XVnju8VpQhnZwG+Xtb0oAM8OjlvJtiD5iL7Ux6HpRin6imSke0BwyuZDXNChkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 194.138.21.72) smtp.rcpttodomain=chromium.org smtp.mailfrom=siemens.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=siemens.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2968BNcoYDES9qEHyh68qksJto7CcCvnVoLFWajH0e8=; b=s75+tEZYRbZCLh8s0ceXN1ZLunT8WC3ipDrHYVU0qfuaLQfaFYQbPQy6KtS9qmFpELHMcTFXs25czAMx322bSDnKmWG006FGiKBL+wqmqzIj+UdV5sC9Sm60gqC9e6ZjlmqDI8uqETcZX4M//O+GNiOIKBcTwRo1cVtEszStO3xIT6yZvZqJMb1LWwcEmrYJnniC5xMVSTwyLCYgrkXpF+lrBIvHvPxcLzNTXrV9ikAbfr5LdV9+QfNsKbjF5nD/v2sZyfrtRthtaksqsOuv1YcmFCCvjPWnkOK+EZH2LMSKg+T3UYOo6vqtCOnlXeUTQ1CB2jE+3kl22EmMLbwY6A== Received: from DB9PR01CA0008.eurprd01.prod.exchangelabs.com (2603:10a6:10:1d8::13) by DB9PR10MB4937.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:2c2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Fri, 28 Jan 2022 19:37:55 +0000 Received: from DB5EUR01FT016.eop-EUR01.prod.protection.outlook.com (2603:10a6:10:1d8:cafe::37) by DB9PR01CA0008.outlook.office365.com (2603:10a6:10:1d8::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Fri, 28 Jan 2022 19:37:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 194.138.21.72) smtp.mailfrom=siemens.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=siemens.com; Received-SPF: Pass (protection.outlook.com: domain of siemens.com designates 194.138.21.72 as permitted sender) receiver=protection.outlook.com; client-ip=194.138.21.72; helo=hybrid.siemens.com; Received: from hybrid.siemens.com (194.138.21.72) by DB5EUR01FT016.mail.protection.outlook.com (10.152.4.255) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Fri, 28 Jan 2022 19:37:55 +0000 Received: from DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) by DEMCHDC9SMA.ad011.siemens.net (194.138.21.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.18; Fri, 28 Jan 2022 20:37:55 +0100 Received: from [167.87.0.32] (167.87.0.32) by DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Fri, 28 Jan 2022 20:37:54 +0100 Message-ID: <8d5198e1-7b6e-f08e-47eb-06d41ab0dff8@siemens.com> Date: Fri, 28 Jan 2022 20:37:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 From: Jan Kiszka Subject: [PATCH] binman: Skip node generation for images read from files Content-Language: en-US To: Simon Glass , U-Boot Mailing List X-Originating-IP: [167.87.0.32] X-ClientProxiedBy: DEMCHDC89YA.ad011.siemens.net (139.25.226.104) To DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d38a7bd4-d4fb-4588-8e25-08d9e295ae9a X-MS-TrafficTypeDiagnostic: DB9PR10MB4937:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LOK3Neqxtaxh76j3GnRhSIGawJTkDrIWosInwJ8UhV87wzBGf/Ka4CkBI4VYMZ9WDRPBihUn9G/gGcj/LcaC9XPhYicLQjw1Ajc7aALZZQz02BQCjR1t4ouMJNBhrFZKjNENkLCPFfOKSCx4CPD5Xyrypctq7sU5bEfEFPOX2TGgHwOoFaDtlRSKgQR8QdRVSf3XSd7g65q/BniVLD9+McE0mZq0IrnAugRjwzGVDqBPEs4Bv6gRrRPoH538HE91JmnrkkOeeY9UecUxDlkTR7INIkv+axNqW7xupAZttsf8CkSwailUxqwbJCd3zy7oib3mInd3/tGYKgShSEdg4Hsyy4V4mS8OEMfJF0SbTexiMcwMdIaShSgV/5haF07IqyKFUsG2iOEDUysixigvgtjVzAMSO6CR/miachGl3XaomN8Mx3IVKNl5ImEKqmDjJeYn3wfJrFHiT3CJaEoDgasOiiVdqtdnk0MTeN1FTW8sNWJ0pSnanOLh5CfG+ilF94fBmkGkU23YsXLMaSlOMRucmn10zVo1/cn3Wlcj6Sz0s2ACAD9GCWuPPHCbGBG1rkAb2JrVdhAIhYzQZR5+4Wa2vNHXUtFGLMFeG4qH9zSIr48jeRzbxNYH03eWtpe4/ZXu2JkbGqTLzwyXn+sGOmhQkueHOorSs8Vj8u+1NDqeUriVuPrbudU6wQCSP68xmb94+ev7WCIETCM9Qxd1DEo2EkN2vBORMaeseQeTntGPNgZRLrng1hlsTwQmc+sRwihxCtGap3esdJzmwAZ+tA== X-Forefront-Antispam-Report: CIP:194.138.21.72; CTRY:DE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:hybrid.siemens.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(2906002)(40460700003)(8936002)(8676002)(31686004)(70206006)(36756003)(110136005)(316002)(16576012)(70586007)(86362001)(44832011)(31696002)(508600001)(6706004)(336012)(83380400001)(356005)(81166007)(186003)(26005)(47076005)(2616005)(956004)(16526019)(36860700001)(5660300002)(82960400001)(82310400004)(3940600001)(36900700001)(43740500002)(20210929001); DIR:OUT; SFP:1101; X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2022 19:37:55.6306 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d38a7bd4-d4fb-4588-8e25-08d9e295ae9a X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=38ae3bcd-9579-4fd4-adda-b42e1495d55a; Ip=[194.138.21.72]; Helo=[hybrid.siemens.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR01FT016.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR10MB4937 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.5 at phobos.denx.de X-Virus-Status: Clean From: Jan Kiszka We can and should run the node generator only when creating a new image. When we read it back, there is no need to generate nodes - they already exits, and binman does not dive that deep into the image - and there is no way to provide the required fdt-list. So store the mode in the image object so that Entry_fit can simply skip generator nodes when reading them from an fdtmap. This unbreaks all read-backs of images that contain generator nodes in their fdtmap. To confirm this, add a corresponding test case. Signed-off-by: Jan Kiszka Reviewed-by: Simon Glass Tested-by: Simon Glass --- tools/binman/etype/fit.py | 2 +- tools/binman/ftest.py | 18 ++++++++++++++++++ tools/binman/image.py | 9 +++++++-- tools/binman/test/219_fit_gennode.dts | 24 ++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 tools/binman/test/219_fit_gennode.dts diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index 6e5f020c502..6ad4a686df5 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -194,7 +194,7 @@ class Entry_fit(Entry): # the FIT (e.g. "/images/kernel/u-boot"), so don't call # fsw.add_node() or _AddNode() for it. pass - elif subnode.name.startswith('@'): + elif self.GetImage().generate and subnode.name.startswith('@'): if self._fdts: # Generate notes for each FDT for seq, fdt_fname in enumerate(self._fdts): diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index ca200ae9f8f..5400f76c676 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -5100,6 +5100,24 @@ fdt fdtmap Extract the devicetree blob from the fdtmap self.assertIn('Documentation is missing for modules: mkimage', str(e.exception)) + def testListWithGenNode(self): + """Check handling of an FDT map when the section cannot be found""" + entry_args = { + 'of-list': 'test-fdt1 test-fdt2', + } + data = self._DoReadFileDtb( + '219_fit_gennode.dts', + entry_args=entry_args, + use_real_dtb=True, + extra_indirs=[os.path.join(self._indir, TEST_FDT_SUBDIR)]) + + try: + tmpdir, updated_fname = self._SetupImageInTmpdir() + with test_util.capture_sys_output() as (stdout, stderr): + self._RunBinman('ls', '-i', updated_fname) + finally: + shutil.rmtree(tmpdir) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/image.py b/tools/binman/image.py index 0f0c1d29e80..cb5279c7ead 100644 --- a/tools/binman/image.py +++ b/tools/binman/image.py @@ -67,9 +67,13 @@ class Image(section.Entry_section): does not exist in binman. This is useful if an image was created by binman a newer version of binman but we want to list it in an older version which does not support all the entry types. + generate: If true, generator nodes are processed. If false they are + ignored which is useful when an existing image is read back from a + file. """ def __init__(self, name, node, copy_to_orig=True, test=False, - ignore_missing=False, use_expanded=False, missing_etype=False): + ignore_missing=False, use_expanded=False, missing_etype=False, + generate=True): super().__init__(None, 'section', node, test=test) self.copy_to_orig = copy_to_orig self.name = 'main-section' @@ -83,6 +87,7 @@ class Image(section.Entry_section): self.use_expanded = use_expanded self.test_section_timeout = False self.bintools = {} + self.generate = generate if not test: self.ReadNode() @@ -131,7 +136,7 @@ class Image(section.Entry_section): # Return an Image with the associated nodes root = dtb.GetRoot() image = Image('image', root, copy_to_orig=False, ignore_missing=True, - missing_etype=True) + missing_etype=True, generate=False) image.image_node = fdt_util.GetString(root, 'image-node', 'image') image.fdtmap_dtb = dtb diff --git a/tools/binman/test/219_fit_gennode.dts b/tools/binman/test/219_fit_gennode.dts new file mode 100644 index 00000000000..7820c472808 --- /dev/null +++ b/tools/binman/test/219_fit_gennode.dts @@ -0,0 +1,24 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + fit { + description = "test-desc"; + #address-cells = <1>; + fit,fdt-list = "of-list"; + + images { + @fdt-SEQ { + description = "fdt-NAME.dtb"; + type = "flat_dt"; + compression = "none"; + }; + }; + }; + fdtmap { + }; + }; +};