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 8CA4EC433EF for ; Mon, 25 Apr 2022 00:04:21 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B28F583DA2; Mon, 25 Apr 2022 02:04:12 +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="IKUVsezL"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="A7/qoROs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6A2D383D07; Mon, 25 Apr 2022 02:04:07 +0200 (CEST) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) (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 7FBDF83AC6 for ; Mon, 25 Apr 2022 02:04:00 +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.west.internal (Postfix) with ESMTP id 1EB463201D90; Sun, 24 Apr 2022 20:03:58 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 24 Apr 2022 20:03:59 -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=1650845037; x=1650931437; bh=YG E+BcdH5v8nBaslnGm4+LdUPG/OFxoeqXDsjqzOlxc=; b=IKUVsezLUkV/CaUI4o hcxf41cGu2HwNseQrcNw+64VDh8d8mRpB+8FyWam1rVuSF3zKlguf+Y6+E03PXIL czwKNUI5jtZE5J19IcUdAGO/6BhYJkXeq9lwzW3mb5xzutoRaTf+espBCnOUUGyS QlNUN4K0erytwzc0p43kG4KOiBeTNKiGlv5EeBB3/3SEHwzcgb4An7v4hAlPbRQ8 DYeE2Vt++1wL24DJ5ZNe3S748Bayi+UfOLWZeZtCPmwPce9tD+GZwdf34sTBZSdr p0ZovYT/tRgQ97sIu6ZhTX95Fy3ZyA7OShDDwDpktNMH1Rq135Zvf7dgN5ocSpOF iLCQ== 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= 1650845037; x=1650931437; bh=YGE+BcdH5v8nBaslnGm4+LdUPG/OFxoeqXD sjqzOlxc=; b=A7/qoROsBW72WyVJYfaF8vx7JNZVyNwaUf+6eMZXlJTFZsgHT0U J8vYEK9wTT5bsbx4867v7VBkK93lyjZcdnP24hrhjljp/7b77ZUT9TNUWGZLMcx7 bsxpIPvSoWREXLeZc84Rs2IId4HUmtc4VGj0Kxo4ojI0FD+wsMEecNBRvmtQJR9h LOZeDWlTXCvM3YUZ9wJOLQXByJoKNhqOpk0pGIen/SNkmlF77ZZWhe9dkv8Xgx4K 0UmpNNicc3BdNSiQhosfkcnVOs8Vy4FQd2Lm3jc7jidMAruennMSGIdxXCp8qWmF uVsH+EJprgKkVcdPQ3shc3CfxRK3OvOgEzg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedruddtgdefudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeetnhgurhgv ficutegssghothhtuceorghnughrvgifsehmihhrgidruggvvheqnecuggftrfgrthhtvg hrnhepudfgfedvgeetkeejleeuheekhffhgfdvgeehhfetkeevgfeukeekiedtieehffev necuffhomhgrihhnpehmkhhimhgrghgvrdhruhhnnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomheprghnughrvgifsehmihhrgidruggvvh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 24 Apr 2022 20:03:53 -0400 (EDT) From: Andrew Abbott To: u-boot@lists.denx.de Cc: Andrew Abbott , Simon Glass , Philipp Tomsich , Kever Yang , Peter Robinson , Akash Gajjar , Jagan Teki , Samuel Dionne-Riel Subject: [RFC PATCH 1/8] binman: mkimage: Support ':'-separated inputs Date: Mon, 25 Apr 2022 10:03:22 +1000 Message-Id: <20220425000329.28124-2-andrew@mirx.dev> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220425000329.28124-1-andrew@mirx.dev> References: <20220425000329.28124-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? --- 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.35.3