From patchwork Tue Aug 16 08:41:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 1666730 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=weidmueller.onmicrosoft.com header.i=@weidmueller.onmicrosoft.com header.a=rsa-sha256 header.s=selector1-weidmueller-onmicrosoft-com header.b=QnlSzyRp; dkim-atps=neutral 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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4M6Pmc0x0Bz1yft for ; Tue, 16 Aug 2022 18:42:56 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ECD3B848F3; Tue, 16 Aug 2022 10:42:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=weidmueller.com 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=weidmueller.onmicrosoft.com header.i=@weidmueller.onmicrosoft.com header.b="QnlSzyRp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F1999848FB; Tue, 16 Aug 2022 10:42:39 +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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04hn0227.outbound.protection.outlook.com [52.100.18.227]) (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 E798484541 for ; Tue, 16 Aug 2022 10:42:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=weidmueller.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=stefan.herbrechtsmeier-oss@weidmueller.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OEW8tj/mkTrZlvIpgAdAnwF2sdKvQgPHRvAj+GIjIU8N1KDAyZuR82RVZ7xfQHNDdCq2FmbRvCbaZGP9Wm87C7JjtfJBLZVBo6XKlcTtsvT+C/9aeSPV6lPx3j9Nw26b3BphqD4LGoUUkwXhE45yfu8ZJj5MjEaAjQsZvI3/Rh9M9FKU9d34qLdsrGMbZVI1xdJaGEJeYe2Ye8mnnTDyHASReEhGaw77PFOPyPB1e7815Sha7e0+09/P13yzg1FXvmPCRcyD/+baYKty32vY1VQkK+wUaUqtV/SAmECvgU9ggvcf7v3NmXDpKbpqRDRG4vTYoEGTDQJCQ5FfDlhjsw== 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=ECxbSGvDBt/pjhpzMaDatTnmcEH6tGwIeo3w+vwPfQk=; b=GqkN+XEFmp+Aldnuy0D88aC/pq8O0crEQBjDw8ukjWWCbVMDqkuJaMYDwCtxKPEp/57GEdmBT5CK5e1Yh03tsUOsNQUTRAL5Rxj62ZuL76IqMZuUHQhoaFw1s8b2rESonGac/nMloosLLDDWITJlheesU+I8SIDXC0wJ8x5uD2CYPMR0s5ueKg2drcVe8cP0gJOfAMXQwnd6AyNxIPdQ+ULIPB4igduyf2R+rkUhcqfnBOlDQixipHAFWF7Gdwo/mmR0vROT7ERC2B8gtsfEfQFzmcDUbGbl8s4o58OHJ1s8mrzmSi3khfGR5mkDrQgHXt2xonuurHl0eUVRuelJ4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=weidmueller.com; dmarc=pass action=none header.from=weidmueller.com; dkim=pass header.d=weidmueller.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weidmueller.onmicrosoft.com; s=selector1-weidmueller-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ECxbSGvDBt/pjhpzMaDatTnmcEH6tGwIeo3w+vwPfQk=; b=QnlSzyRp0/KKNQ+5VOgF8b3C3Ov25t2KHJkFBny5o+1Sv18bR0KgKHqBc4txLqkNYtQ5JaqEEYFGYea+EIh2hdieWbfLgoZzRFoEJ3NEMqFVv/BTOZnr51z+2jevGbPZMN0uZWjgfDiXa7JGPG2fGjOgizWcfcRmk74Df+EkIWU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=weidmueller.com; Received: from PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) by AM6PR08MB3096.eurprd08.prod.outlook.com (2603:10a6:209:43::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.17; Tue, 16 Aug 2022 08:42:33 +0000 Received: from PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f95b:2e64:9ee6:4d44]) by PAXPR08MB6969.eurprd08.prod.outlook.com ([fe80::f95b:2e64:9ee6:4d44%3]) with mapi id 15.20.5525.011; Tue, 16 Aug 2022 08:42:33 +0000 From: Stefan Herbrechtsmeier To: u-boot@lists.denx.de Cc: Stefan Herbrechtsmeier , Alper Nebi Yasak , Simon Glass Subject: [PATCH v4 02/13] binman: Add length header attribute to dtb entry Date: Tue, 16 Aug 2022 10:41:59 +0200 Message-Id: <20220816084210.14972-2-stefan.herbrechtsmeier-oss@weidmueller.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220816084210.14972-1-stefan.herbrechtsmeier-oss@weidmueller.com> References: <20220816084210.14972-1-stefan.herbrechtsmeier-oss@weidmueller.com> X-ClientProxiedBy: FR0P281CA0139.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::14) To PAXPR08MB6969.eurprd08.prod.outlook.com (2603:10a6:102:1d8::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9184a1ed-12d5-4fd5-1ef1-08da7f634303 X-MS-TrafficTypeDiagnostic: AM6PR08MB3096:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VjJeKuusSeT4thdN742jV08EonXOya/7ut2h7TxC0xyAaEUgB0YTeuUvx6E7Myz9MH6BHHgzX8k8e5EgEWCr2mR45gxGH8xxPISkwk38awb+hPo90ft6NJXoe6T79TlwqQR6dlhK4GYFcW3PBYt9o/SbPsgvEcTF6Eq+UxYbE5gtWqA72v9cyTddVsOYmzDRi5JSNhW/YQEKMDvFEMPwTObQ/whtTJ6LooZOT8tA7Ex/Rv3XdqQOuUcGKJ0AWl6Wtykvlwmlg/mi/esskx1eTBb2482+97649LTDdrbEDI9HnGhiFroHw7vIohmu5NA6bPMrZJRJYL059/qtlYwgiM3zhcyxHmXz5Tb52QPYJMD7yi/ISsjDM7wWRa1TDQVnkiAHzV7xlfX7pibtafslN8wXipHlwoat87we+fVd4fb6kpdf1AwvJZe779kTDkQY+N4M+YR5AWnHmOumy9bl062tuLqQiuZ++gd2zkVL8IE1VmCxnI3CTG6I4uaUQoXr4AiqeQvYQchLswELQajOmVOuayRX919DK6HN3YAli4aH2wmDnzg+0fuh8vXJ3Yn6i+s5zuMVo13QyOE7+RF9p2D2XTfVkVPA0kiNFhRqUFPjR7Zj8QB43beqDFNby3BZU2Jme+4bRaySmj0FdM5Oah9fxnUbIfy9bIAKBpVva5CQBzMAFn8zw2lcrYGjWrJuTwV5MmsFIFAfGyS72cLoCIKsrrFZpKyTzUlnanR/F6E/o4wI2cvmmZXyjmQZgXoAzFKElTKq0vz5EmktfUgEPpfKafA7Ogtz8gxCzETaBblYj2fHAckoOZLTnHtVycBP1QUlZZNg3OiLxcdy9vvXqRX9fGdAE3583e9WUbeaa9/wVjfQJ0Xbf3fCyq3zTgavI8o3gbQGQmmXnMpt9yye6wpnm12sCgdSx31Rmm0PRpwJNq/5Vln6uXdwkbbHBzGXWnLXBaAjA7dasz9ELq4hdy2k9mRUbHCE5bgyM9DH6Yg/QdrAJV7ECMEXy4t6Gy81hBvM2GSQT18M50DaCjieoQJSrpgK+Eg2HufAyKPHfnDdH6CgWbqj/OqEcshwLFwxZnY+JI/WMyp686Z12Gqjv2wZiIsGKcEytpibmr2WkMf9nVjMKJrdXp096QC34SLzOhrvKSURjU0ETo2QCxvtkg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:5; SRV:; IPV:NLI; SFV:SPM; H:PAXPR08MB6969.eurprd08.prod.outlook.com; PTR:; CAT:OSPM; SFS:(13230016)(4636009)(136003)(396003)(376002)(366004)(346002)(39860400002)(6666004)(66556008)(66476007)(38100700002)(38350700002)(478600001)(8676002)(8936002)(66946007)(6486002)(5660300002)(54906003)(4326008)(6506007)(316002)(186003)(26005)(6512007)(2616005)(36756003)(1076003)(83380400001)(86362001)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88wUkqNYLH5DoOyK/7UKuhPA4KX6kePj78s3VI6mULoiErQiCjpVdqvvjgDzYzALCgoqzu0emcRZsJd8DjFQ9+QLyf7yLtM1xNv2nzDWOOxhGtQa3MOOB34jrtQjDrtJx2R1aA14LEKsqqeVppLmscEk7YKAYCo1C7iRYqVupGXRPJR5qkKl04UIwBT5RFPtjcmpLbIyaPqieCMkIzAjvwn2rJzym4MfVfVqnWlRwiPMBPROfL7L6GjMmiC2M6u+utd/WBCf/laPpBywgpuLoiTrG6BKHgLhqz1VWtLX5tjhs87FLzCQENvgt/QrjNilB367uln4rWkTP+wGXbX+S7yIZF1BgTkYvADNXppIMJ2KpPeOK/pf8+4rXESzsoisycOXXfSfkezG3PVi5QiTg8mEdWQAywXwwtWhcBkI9jaMXDTNjQmZ/iHD7tCgctgC7dRlmwZM9T8nUSwowD/CR6O3ZJenmkc0vVMwTw36DvvThNQaaZokrLl52BUd5clU3s3BO26HFKRXEJxXnBv3oTP3aEn/nFXnV5ytkKhh59rW735LT5cwQ3seApts4IZmLKwIbq7mRt6TnvOSzei1pu2EMrP2qy4Jq+XIGADmEq3LVSthjdEWyUAJtf2EtzGYLOJwcmsZdnZlVXw== X-OriginatorOrg: weidmueller.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9184a1ed-12d5-4fd5-1ef1-08da7f634303 X-MS-Exchange-CrossTenant-AuthSource: PAXPR08MB6969.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2022 08:42:33.1626 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e4289438-1c5f-4c95-a51a-ee553b8b18ec X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AphPwtGydfrfwElwQYhRaPo/p86zNzsXYCjhtxrT4ShyQYmT0tQ+V/z41ZdR+rGo4/1ikrfo/bEZkX84f6RNFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3096 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.6 at phobos.denx.de X-Virus-Status: Clean From: Stefan Herbrechtsmeier Add an optional length header attribute to the device tree blob entry class based on the compressed data header from the utilities to compress and decompress data. If needed the header could be enabled with the following attribute beside the compress attribute: prepend = "length"; The header was introduced as part of commit eb0f4a4cb402 ("binman: Support replacing data in a cbfs") to allow device tree entries to be larger than the compressed contents. Regarding the commit "this is necessary to cope with a compressed device tree being updated in such a way that it shrinks after the entry size is already set (an obscure case)". This case need to be fixed without influence any compressed data by itself. Signed-off-by: Stefan Herbrechtsmeier --- (no changes since v3) Changes in v3: - Move comp_util.py changes (drop with_header) into separate commits. Changes in v2: - Reworked to make the feature optional. tools/binman/entries.rst | 3 +++ tools/binman/etype/blob_dtb.py | 24 +++++++++++++++++++ tools/binman/ftest.py | 22 +++++++++++++++++ .../test/235_compress_prepend_length_dtb.dts | 17 +++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 tools/binman/test/235_compress_prepend_length_dtb.dts diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst index 782bff1f8d..c9336d1bb4 100644 --- a/tools/binman/entries.rst +++ b/tools/binman/entries.rst @@ -216,6 +216,9 @@ This is a blob containing a device tree. The contents of the blob are obtained from the list of available device-tree files, managed by the 'state' module. +Additional Properties / Entry arguments: + - prepend: Header type to use: + length: 32-bit length header .. _etype_blob_ext: diff --git a/tools/binman/etype/blob_dtb.py b/tools/binman/etype/blob_dtb.py index 4159e3032a..4fd2ecda83 100644 --- a/tools/binman/etype/blob_dtb.py +++ b/tools/binman/etype/blob_dtb.py @@ -7,6 +7,8 @@ from binman.entry import Entry from binman.etype.blob import Entry_blob +from dtoc import fdt_util +import struct # This is imported if needed state = None @@ -17,6 +19,9 @@ class Entry_blob_dtb(Entry_blob): This is a blob containing a device tree. The contents of the blob are obtained from the list of available device-tree files, managed by the 'state' module. + + Additional attributes: + prepend: Header used (e.g. 'length') """ def __init__(self, section, etype, node): # Put this here to allow entry-docs and help to work without libfdt @@ -25,6 +30,15 @@ class Entry_blob_dtb(Entry_blob): super().__init__(section, etype, node) + self.prepend = None + + def ReadNode(self): + super().ReadNode() + self.prepend = fdt_util.GetString(self._node, 'prepend') + if self.prepend and self.prepend not in ['length']: + self.Raise("Invalid prepend in '%s': '%s'" % + (self._node.name, self.prepend)) + def ObtainContents(self): """Get the device-tree from the list held by the 'state' module""" self._filename = self.GetDefaultFilename() @@ -35,6 +49,9 @@ class Entry_blob_dtb(Entry_blob): """Re-read the DTB contents so that we get any calculated properties""" _, indata = state.GetFdtContents(self.GetFdtEtype()) data = self.CompressData(indata) + if self.prepend == 'length': + hdr = struct.pack('; + #size-cells = <1>; + + binman { + u-boot { + }; + u-boot-dtb { + compress = "lz4"; + prepend = "length"; + }; + }; +};