From patchwork Sat Jan 21 23:25:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1730096 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=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm1 header.b=ZDGkfXDN; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=nriJ6oSB; 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 4NzstK26MTz23gM for ; Sun, 22 Jan 2023 10:25:45 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 692368556B; Sun, 22 Jan 2023 00:25:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.b="ZDGkfXDN"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="nriJ6oSB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9F5128539D; Sun, 22 Jan 2023 00:25:27 +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 wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BDD788539D for ; Sun, 22 Jan 2023 00:25:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id C6AA1320046F; Sat, 21 Jan 2023 18:25:20 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sat, 21 Jan 2023 18:25:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1674343520; x=1674429920; bh=Bq W1Oo1HNK7xySy6ddiNwQj6krtwuO7zLuiwVK3egko=; b=ZDGkfXDNLmTJzGnFtG BdduCZbTFhJEtHfurqGH6PfLMdpHSg4eSwy2PARKMt8H16aHaaDYQ8EaF03giKxN Yvh/ax2kquRLU517mZ3f5+y+lIld5jW2hmH2ZbgTobm+K46pbJ6eOUN41Y55LgEY LeC8Xs4sMRaPKIwJVFOGEibsiEJsT9902edyJSz3YuIJ3pydGARvk38KyxT1WS4t n1pzwE8oj/Pe+6SDmOrkoBAyJKU++kp9teYEbtlr5QvjETVNOABL20dNDQXVZ8HG WRNOFIriBoHGhmUGItpk6PHb9qtcQ/anYX6YxI3B+wIuJ1gXJxLEbizhq+GMBiqZ w7+Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1674343520; x=1674429920; bh=BqW1Oo1HNK7xy Sy6ddiNwQj6krtwuO7zLuiwVK3egko=; b=nriJ6oSBul7L3CUqoso8d3pHtbcTC 3PJ3JxOlGCDKL+74XxS266m1GCESX5pgeBwhCIVqjZhL39/JVEuFY7ySIJ4Di8o/ b0VUtnQeDxEIkPMTlLF4AxBg8frJ56wHMxez4x1tggww2B2CG7PZRUKgstabi12v A0HeijWV3xW902UPjLbWbj9zavz8KBlaeb4lXAhxyxWQg7/nkSzVLPgtmVVA4cX1 MdU9OWIwQEWPPe5Go67S13Cm7AINWuFfjd6GKAebsvDgHpHNlhWiXTE6O6Sx3YHF JEjVqACBpgVX1vpA9ni3NjZiuMWocFSk2JR2xmzzrZCMiMek/SwbSC3zw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudduhedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 21 Jan 2023 18:25:19 -0500 (EST) From: Samuel Holland To: Andre Przywara , Jagan Teki , Simon Glass Cc: Samuel Holland , Alper Nebi Yasak , Icenowy Zheng , Jesse Taube , u-boot@lists.denx.de Subject: [PATCH 1/2] binman: Add 'min-size' entry property Date: Sat, 21 Jan 2023 17:25:16 -0600 Message-Id: <20230121232518.49723-2-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20230121232518.49723-1-samuel@sholland.org> References: <20230121232518.49723-1-samuel@sholland.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.6 at phobos.denx.de X-Virus-Status: Clean This property sets the minimum size of an entry, including padding but not alignment. It can be used to reserve space for growth of an entry, or to enforce a minimum offset for later entries in the section. Signed-off-by: Samuel Holland Reviewed-by: Simon Glass Reviewed-by: Simon Glass --- tools/binman/binman.rst | 8 ++++++++ tools/binman/entry.py | 4 ++++ tools/binman/ftest.py | 21 +++++++++++++++++---- tools/binman/test/009_pack_extra.dts | 7 +++++++ 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst index fa8abdcd86..03a99a19bc 100644 --- a/tools/binman/binman.rst +++ b/tools/binman/binman.rst @@ -615,6 +615,14 @@ size: this size. If this is not provided, it will be set to the size of the contents. +min-size: + Sets the minimum size of the entry. This size includes explicit padding + ('pad-before' and 'pad-after'), but not padding added to meet alignment + requirements. While this does not affect the contents of the entry within + binman itself (the padding is performed only when its parent section is + assembled), the end result will be that the entry ends with the padding + bytes, so may grow. Defaults to 0. + pad-before: Padding before the contents of the entry. Normally this is 0, meaning that the contents start at the beginning of the entry. This can be used diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 5d8696e32a..5eacc5fa6c 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -49,6 +49,7 @@ class Entry(object): offset: Offset of entry within the section, None if not known yet (in which case it will be calculated by Pack()) size: Entry size in bytes, None if not known + min_size: Minimum entry size in bytes pre_reset_size: size as it was before ResetForPack(). This allows us to keep track of the size we started with and detect size changes uncomp_size: Size of uncompressed data in bytes, if the entry is @@ -114,6 +115,7 @@ class Entry(object): self.name = node and (name_prefix + node.name) or 'none' self.offset = None self.size = None + self.min_size = 0 self.pre_reset_size = None self.uncomp_size = None self.data = None @@ -270,6 +272,7 @@ class Entry(object): self.Raise("Please use 'extend-size' instead of 'expand-size'") self.offset = fdt_util.GetInt(self._node, 'offset') self.size = fdt_util.GetInt(self._node, 'size') + self.min_size = fdt_util.GetInt(self._node, 'min-size', 0) self.orig_offset = fdt_util.GetInt(self._node, 'orig-offset') self.orig_size = fdt_util.GetInt(self._node, 'orig-size') if self.GetImage().copy_to_orig: @@ -507,6 +510,7 @@ class Entry(object): else: self.offset = tools.align(offset, self.align) needed = self.pad_before + self.contents_size + self.pad_after + needed = max(needed, self.min_size) needed = tools.align(needed, self.align_size) size = self.size if not size: diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index be0aea49ce..93b332972a 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -883,9 +883,9 @@ class TestFunctional(unittest.TestCase): self.assertIn('image', control.images) image = control.images['image'] entries = image.GetEntries() - self.assertEqual(5, len(entries)) + self.assertEqual(6, len(entries)) - # First u-boot with padding before and after + # First u-boot with padding before and after (included in minimum size) self.assertIn('u-boot', entries) entry = entries['u-boot'] self.assertEqual(0, entry.offset) @@ -934,8 +934,17 @@ class TestFunctional(unittest.TestCase): self.assertEqual(U_BOOT_DATA + tools.get_bytes(0, 64 - len(U_BOOT_DATA)), data[pos:pos + entry.size]) + # Sixth u-boot with both minimum size and aligned size + self.assertIn('u-boot-min-size', entries) + entry = entries['u-boot-min-size'] + self.assertEqual(128, entry.offset) + self.assertEqual(32, entry.size) + self.assertEqual(U_BOOT_DATA, entry.data[:len(U_BOOT_DATA)]) + self.assertEqual(U_BOOT_DATA + tools.get_bytes(0, 32 - len(U_BOOT_DATA)), + data[pos:pos + entry.size]) + self.CheckNoGaps(entries) - self.assertEqual(128, image.size) + self.assertEqual(160, image.size) dtb = fdt.Fdt(out_dtb_fname) dtb.Scan() @@ -943,7 +952,7 @@ class TestFunctional(unittest.TestCase): expected = { 'image-pos': 0, 'offset': 0, - 'size': 128, + 'size': 160, 'u-boot:image-pos': 0, 'u-boot:offset': 0, @@ -964,6 +973,10 @@ class TestFunctional(unittest.TestCase): 'u-boot-align-both:image-pos': 64, 'u-boot-align-both:offset': 64, 'u-boot-align-both:size': 64, + + 'u-boot-min-size:image-pos': 128, + 'u-boot-min-size:offset': 128, + 'u-boot-min-size:size': 32, } self.assertEqual(expected, props) diff --git a/tools/binman/test/009_pack_extra.dts b/tools/binman/test/009_pack_extra.dts index 1b31555771..8d6f4910c9 100644 --- a/tools/binman/test/009_pack_extra.dts +++ b/tools/binman/test/009_pack_extra.dts @@ -6,6 +6,7 @@ binman { u-boot { + min-size = <12>; pad-before = <3>; pad-after = <5>; }; @@ -31,5 +32,11 @@ align = <64>; align-end = <128>; }; + + u-boot-min-size { + type = "u-boot"; + min-size = <24>; + align-size = <16>; + }; }; };