From mboxrd@z Thu Jan 1 00:00:00 1970 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 E3FA6C433F5 for ; Mon, 16 May 2022 11:08:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AAD00841EC; Mon, 16 May 2022 13:08:33 +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="nBFbcSam"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="KAp/U2Gy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 06E2184092; Mon, 16 May 2022 13:08:19 +0200 (CEST) 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 5363683F6C for ; Mon, 16 May 2022 13:08:13 +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 compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id E0A9532005D8; Mon, 16 May 2022 07:08:10 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Mon, 16 May 2022 07:08:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mirx.dev; 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=fm3; t=1652699290; x=1652785690; bh=1V ZFmQ7id2VqiEw1totjWapKXF3sRvtMLqjHI2mN0FE=; b=nBFbcSam7nQG/vvIO/ Wqc9iomXtQcFa2sLtLWPm9cLQ7vtmR3xWcKQVTqx1uQ1TaJXeQ7Fx4tQMtEV+2Bj hJ1gaE8AlQBMaiURgej22y5arN1CUjbQK+u2af2aVg/L/thgs7ArtQfdseweUv5J ZzSDR/xLX3UUSUCwlHB25yEwXb2kNhKvhVFQEkrApjEar47W5gZFviZTLjxh/NR6 VozrZnfQZH2cjm3cKM13WsKSfbT/iT9MxGpSQuqaupmLfpxnD1xKzzlE9p/DM6Yq xVQh44CD0gPfCI0X7/w17dyo8SHuKml5ef9fW7Z5J75qbLDfV6O/K7vDkTtUE1c/ rdMg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; 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:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1652699290; x=1652785690; bh=1VZFmQ7id2VqiEw1totjWapKXF3sRvtMLqj HI2mN0FE=; b=KAp/U2GyKUZ7d2EYhGwhmFP1rdlb+sXdXwKJFeH8jYm1dw9J70v w1qI8+8ZOZ6PFpIxZbbYv8h5YeAHAKvCCO8JZuqBkHR8EPkpExhSRjpj1Qk8PN2y s2KJkvEejravFOA4+4/5SemJVep4+iz8ZDKuvwyYMjmv41Zj1vLXrn1LBDDgzCYr Z8Pih+35kTBmXJeLcmHcVLyBGrWG12C06Aa+90O6bKZXveNDwzySdip0+h7+rnCJ Bkds60B0pf4Enih7G2khyma+qrgEB894IvhduOyYiXdRlMimD9dnNYlIQ2ONVvFi w/V5aRJU2XoYEuaVsjgY3VRZK950hKEfjJg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrheehgdefhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeetnhgurhgv ficutegssghothhtuceorghnughrvgifsehmihhrgidruggvvheqnecuggftrfgrthhtvg hrnhepudfgfedvgeetkeejleeuheekhffhgfdvgeehhfetkeevgfeukeekiedtieehffev necuffhomhgrihhnpehmkhhimhgrghgvrdhruhhnnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomheprghnughrvgifsehmihhrgidruggvvh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 16 May 2022 07:08:06 -0400 (EDT) From: Andrew Abbott To: U-Boot Mailing List Cc: Jagan Teki , Johan Jonker , Simon Glass , Samuel Dionne-Riel , Peter Robinson , Kever Yang , Philipp Tomsich , Andrew Abbott , Alper Nebi Yasak , Heiko Thiery Subject: [RFC PATCH v2 1/8] binman: mkimage: Support ':'-separated inputs Date: Mon, 16 May 2022 21:07:05 +1000 Message-Id: <20220516110712.178958-2-andrew@mirx.dev> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220516110712.178958-1-andrew@mirx.dev> References: <20220516110712.178958-1-andrew@mirx.dev> 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.5 at phobos.denx.de X-Virus-Status: Clean mkimage supports combining multiple input binaries separating them with colons (':'). This is used at least for Rockchip platforms to encode payload offsets and sizes in the image header. It is required for Rockchip SPI boot since for the rkspi format, after the input binary combining, the entire image is spread across only the first 2K bytes of each 4K block. Previous to this change, multiple inputs to a binman mkimage node would just be concatenated and the combined input would be passed as the -d argument to mkimage. Now, the inputs are instead passed colon-separated. Signed-off-by: Andrew Abbott --- This is a bit of a messy implementation for now and would probably break existing uses of mkimage that rely on the concatenation behaviour. Questions: - Should this be a separate entry type, or an option to the mkimage entry type that enables this behaviour? - What kind of test(s) should I add? (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): self.ReadEntries() def ObtainContents(self): - # Use a non-zero size for any fake files to keep mkimage happy - data, input_fname, uniq = self.collect_contents_to_file( - self._mkimage_entries.values(), 'mkimage', 1024) - if data is None: - return False - output_fname = 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 first data + # file as the "init" and the second as "boot" and sets the image header + # accordingly, then makes the image so that only the first 2 KiB of each + # 4KiB block is used. + + data_filenames = [] + for entry in self._mkimage_entries.values(): + # First get the input data and put it in a file. If any entry is not + # available, try later. + if not entry.ObtainContents(): + return False + + input_fname = tools.get_output_filename('mkimage-in.%s' % entry.GetUniqueName()) + data_filenames.append(input_fname) + tools.write_file(input_fname, entry.GetData()) + + output_fname = tools.get_output_filename('mkimage-out.%s' % self.GetUniqueName()) + 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 output self.record_missing_bintool(self.mkimage) - self.SetContents(data) - - return True + return False def ReadEntries(self): """Read the subnodes to find out what should go in this image""" -- 2.36.0