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 D87CFC433EF for ; Sun, 22 May 2022 00:03:23 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 951C280583; Sun, 22 May 2022 02:03:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=mirx.dev 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=mirx.dev header.i=@mirx.dev header.b="H69EiwWI"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="PlOEHIfo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F149180583; Sun, 22 May 2022 02:03:19 +0200 (CEST) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (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 E23A6801F5 for ; Sun, 22 May 2022 02:03:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=mirx.dev Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=andrew@mirx.dev Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 6B1665C0159; Sat, 21 May 2022 20:03:14 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sat, 21 May 2022 20:03:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mirx.dev; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1653177794; x= 1653264194; bh=KkCa2OaFdxpG+EyGzh5vAQvNCrOoUW9fPFVFD3agHlM=; b=H 69EiwWI540fksGIAGnOstSVa7dkRZyiOs7jr8bXhoxVllkfViqaCDyEit7L+Vrtj CbCxbcmZ34dXK9GO/8zwU13XvYet5szHK9oxNMYO9v1BRUXrdRs7YmbXvgFiikSa +XBMUaz24xUO4HFtw301rbYf31rFOvcDX3eka3fbpqVLAR6OSDYb1xIS54RJl4xL E+etyeba7YrX/hlIg2xG+pEUVcEZb/Y5owPontObK5xAuAwkz3CzJUj0WIdvmVE+ HGzRcp/3AIriOvKA0AQnt4iO6kgT/6g7ke7whvO4QonAYcD7cGK+krDxYl5m0Sbg V8Bt84Hb03F4QjXA8zhUQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type: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=fm1; t=1653177794; x= 1653264194; bh=KkCa2OaFdxpG+EyGzh5vAQvNCrOoUW9fPFVFD3agHlM=; b=P lOEHIfoocAIgLI0g7hHvP0q4C804K+i341AWlwDQ1q3VuiQQhJBTnRXnA3xGC4E2 /ngV0QgEsnpi/LUW26v6l1TacnAg4cjcUnY6eAM9C4S9Cj3LrlwAJKhNa54sbkQ7 Dmp2Vsrk+Lg7bC2OXiCXbpVZ0ks+6ZpMlMxtz4479e1ebaAvV4dRC/gMHVqHtd1F 8SZDls3ctsmdaXG/BwI1DFnGSQ3A0RVWYEV0QpxM4jMvdOIVKvjFRRAra/7RekMM w3KRzYJqpyWrD/6xM5PlHkDAmNaPSv9o3cPvGAgC17P+K0ees1yGQWz4PQp4Gkd5 4YDTUOGnh18Lg4N1Bawqw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrieejgddvkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpegggfgtfffkvefuhffvofhfjgesthhqredtredtjeenucfhrhhomhepfdetnhgu rhgvficutegssghothhtfdcuoegrnhgurhgvfiesmhhirhigrdguvghvqeenucggtffrrg htthgvrhhnpeffffektdeuffefkefghffhgffgvdekkeevvdeuiedvheekudejgfeiudej ieekgeenucffohhmrghinhepkhgvrhhnvghlrdhorhhgpdhmkhhimhgrghgvrdhruhhnne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghnughr vgifsehmihhrgidruggvvh X-ME-Proxy: Feedback-ID: i9671468b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 21 May 2022 20:03:10 -0400 (EDT) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Sun, 22 May 2022 10:03:08 +1000 Message-Id: Cc: "Jagan Teki" , "Johan Jonker" , "Simon Glass" , "Samuel Dionne-Riel" , "Peter Robinson" , "Kever Yang" , "Philipp Tomsich" , "Heiko Thiery" , "U-Boot Mailing List" Subject: Re: [RFC PATCH v2 1/8] binman: mkimage: Support ':'-separated inputs From: "Andrew Abbott" To: "Alper Nebi Yasak" X-Mailer: aerc 0.9.0 References: <20220516110712.178958-1-andrew@mirx.dev> <20220516110712.178958-2-andrew@mirx.dev> <08cd5c3b-acb3-1ae1-e7fa-99eef9c47255@gmail.com> In-Reply-To: <08cd5c3b-acb3-1ae1-e7fa-99eef9c47255@gmail.com> 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 On Thu May 19, 2022 at 9:36 PM AEST, Alper Nebi Yasak wrote: > Also see another attempt for this [1] and the comments to that for a > more complete picture, though I'll try writing all the points here anyway= . > > [1] binman: support mkimage separate files > https://lore.kernel.org/u-boot/20220304195641.1993688-1-pgwipeout@gmail.c= om/ > > > --- > > This is a bit of a messy implementation for now and would probably brea= k > > existing uses of mkimage that rely on the concatenation behaviour. > > I did a `git grep -C10 mkimage -- **/dts/*` and it doesn't look like > anything uses it yet. Except for binman/test/156_mkimage.dts, which > doesn't exactly test the concatenation. I did similar and came to the same conclusion, but I figured I'd ask just in case it's used somewhere I hadn't found, or it's being relied on outside of the U-Boot repository. > You can add a 'separate-files' device-tree property like in [1]. I'm > actually OK with this separate-files being the default and only behavior > (concatenation can be done via an inner section), but I'm not sure Simon > would agree. Similar thoughts here, especially since we couldn't find anything relying on the concatenation behaviour. > > - What kind of test(s) should I add? > > At the minimum, a test using separate-files with multiple input entries. > You can do something like the _HandleGbbCommand in ftest.py to capture > and check the arguments that'll be passed to mkimage. > > I think that'll be enough, but try to run `binman test -T` and check for > 100% coverage with all tests succeeding. > > > (no changes since v1) > > > > tools/binman/etype/mkimage.py | 33 +++++++++++++++++++++------------ > > 1 file changed, 21 insertions(+), 12 deletions(-) > > > > diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage= .py > > index 5f6def2287..8cea618fbd 100644 > > --- a/tools/binman/etype/mkimage.py > > +++ b/tools/binman/etype/mkimage.py > > @@ -51,21 +51,30 @@ class Entry_mkimage(Entry): > > Expand the docstring with an explanation of the new behavior, and run > `binman entry-docs >tools/binman/entries.rst` to update it there as well. > > > self.ReadEntries() > > > > def ObtainContents(self): > > - # Use a non-zero size for any fake files to keep mkimage happy > > - data, input_fname, uniq =3D self.collect_contents_to_file( > > - self._mkimage_entries.values(), 'mkimage', 1024) > > - if data is None: > > - return False > > - output_fname =3D tools.get_output_filename('mkimage-out.%s' % = uniq) > > - if self.mkimage.run_cmd('-d', input_fname, *self._args, > > - output_fname) is not None: > > + # For multiple inputs to mkimage, we want to separate them by = colons. > > + # This is needed for eg. the rkspi format, which treats the fi= rst data > > + # file as the "init" and the second as "boot" and sets the ima= ge header > > + # accordingly, then makes the image so that only the first 2 K= iB of each > > + # 4KiB block is used. > > + > > + data_filenames =3D [] > > + for entry in self._mkimage_entries.values(): > > + # First get the input data and put it in a file. If any en= try is not > > + # available, try later. > > + if not entry.ObtainContents(): > > + return False > > + > > + input_fname =3D tools.get_output_filename('mkimage-in.%s' = % entry.GetUniqueName()) > > + data_filenames.append(input_fname) > > + tools.write_file(input_fname, entry.GetData()) > > Something like collect_contents_to_file([entry], f'mkimage-in-{idx}', > 1024) would be better here. At least, the files must not be empty (or > mkimage exits with an error), where entry.GetData() can be b''. > > > + > > + output_fname =3D tools.get_output_filename('mkimage-out.%s' % = self.GetUniqueName()) > > Should be an f-string. > > > + if self.mkimage.run_cmd('-d', ":".join(data_filenames), *self.= _args, output_fname): > > self.SetContents(tools.read_file(output_fname)) > > + return True > > else: > > - # Bintool is missing; just use the input data as the outpu= t > > self.record_missing_bintool(self.mkimage) > > - self.SetContents(data) > > - > > - return True > > + return False > > This case must set some dummy contents (I'd guess b'' is fine) and > return True. (False here roughly means "try again later".) > > > > > def ReadEntries(self): > > """Read the subnodes to find out what should go in this image"= "" Thanks for your review! I'll make these updates in the next version.