From patchwork Tue Mar 1 02:48:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Geis X-Patchwork-Id: 1599177 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=pSh2RpZh; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K7Dtr4dnwz9s0r for ; Tue, 1 Mar 2022 22:05:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3C7B783C59; Tue, 1 Mar 2022 03:48:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="pSh2RpZh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A6A6283C80; Tue, 1 Mar 2022 03:48:46 +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,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 26AAC83BBE for ; Tue, 1 Mar 2022 03:48:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pgwipeout@gmail.com Received: by mail-qt1-x82e.google.com with SMTP id a1so4325383qta.13 for ; Mon, 28 Feb 2022 18:48:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KTKmgQ8hF0wjeQjjF9+OHM2bQC+K+iSNO82dt1D0Xdc=; b=pSh2RpZhSyengLbSA0cw2TOj2MaIpyThMlBSI92igw5sA8YOnGq7VN3WjQ7rR+Zy45 TmNJW7rYxuiYETPliGcSmL39Z5iC0bcExbMF/XRM/gaAyPnbclTg9VczD2vAQSuW3OZf NBUr1GFd81nDj3q2mWIJAGw7GD9nPYjG5vW9Be/eGUkJ51KlCz5/pK7l63lxXKrw5sqU QhHxCf0oHzv12LIPdpClODCgF2+F3h2CEPHysM14MpOCl4WsuowUu6iO9DHIt8EYWDJS YpUqDKYL4UuIWaUtSegwcw4dVBtefcsHle+pEV2Vtv6RL8VkJ0pphur95WgQBsbatgXC AfoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KTKmgQ8hF0wjeQjjF9+OHM2bQC+K+iSNO82dt1D0Xdc=; b=1hcjlro+GZ9chJ4llmRz/o+bIKZ8EnWEMnXRKnKnwrP0mYX87DC5xnhpy3m27OP/Yr NHrLkJqxJi4BylRgShsizchZpYTzWHE1d8tZvoI1ONdzR8t5yOK+GfLyCf3vtXsHoaO9 Vg86NK68D59lp1VoX4aww760TVYkOHi/sIL/GIVjXIRwTbo2ngBjwqFrHNnDH8aGkDv5 rcAP9pU60AZ3lpS5zTY6hC8NHxY9X9Yz2SfhDsajjJC6JY35C2np97HKWW9y+r0XPVcd aaN918wXCU8adr6uHlBFMVkbGX0rQObvC+kmK2hpYqIkYmuAVw2eiLeLQcuZwbb0Aboa jfNA== X-Gm-Message-State: AOAM533ZdUajNw+ivia4EtHzV3cAWR7ixfhfovjwSgOIqGl9es2BzoCp Q/Uk7CDsvLtCl9qT+LHqyWQZ5e1c7CnXkg== X-Google-Smtp-Source: ABdhPJxBXifkg+B7p89QuXs7WpjsQ5kHobV/kmu1nApcKBWNlZzH4AJ65oK2pmrxNO66AMSWQaxP3g== X-Received: by 2002:a05:622a:118c:b0:2dd:7c52:c0c0 with SMTP id m12-20020a05622a118c00b002dd7c52c0c0mr18548505qtk.142.1646102920750; Mon, 28 Feb 2022 18:48:40 -0800 (PST) Received: from master-x64.sparksnet ([2601:153:980:85b1::10]) by smtp.gmail.com with ESMTPSA id bm1-20020a05620a198100b0047bf910892bsm5947336qkb.65.2022.02.28.18.48.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 18:48:40 -0800 (PST) From: Peter Geis To: u-boot@lists.denx.de, sjg@chromium.org Cc: Peter Geis Subject: [RFC] [PATCH] binman: support mkimage split files Date: Mon, 28 Feb 2022 21:48:26 -0500 Message-Id: <20220301024826.1228290-1-pgwipeout@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220223230040.159317-1-sjg@chromium.org> References: <20220223230040.159317-1-sjg@chromium.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.5 at phobos.denx.de X-Virus-Status: Clean Good Evening, I successfully tested your v2 patch series to create a bootable sdcard image out of the box for rockpro64-rk3399. Unfortunately, rk356x and rk3399-spi modes are broken, due to the inability to pass multiple images to mkimage at the same time. rk3399-spi mode is already supported manually, see: https://elixir.bootlin.com/u-boot/v2022.04-rc3/source/doc/board/rockchip/rockchip.rst#L182 rk356x is currently only supported manually, the image built by the old Makefile method is non functional. (u-boot-rockchip.bin) Knowing absolutely nothing about python, I've hacked together something that works for splitting the image in the way mkimage expects. The file name passed to mkimage with the -d flag is: ./mkimage.simple-bin.mkimage.1:./mkimage.simple-bin.mkimage.2 I definitely don't expect this to be accepted as is, I just use it as an example of what we need to fully support this in binman. Adding the following allows me to build images automatically for rk356x: mkimage { args = "-n", CONFIG_SYS_SOC, "-T", "rksd"; mkimage,separate_files; ddrl { type = "blob-ext"; filename = "rk3568_ddr_1560MHz_v1.12.bin"; }; u-boot-spl { }; }; This is my first attempt to use in-reply-to, so I hope this works. Thanks, Peter Geis Signed-off-by: Peter Geis --- tools/binman/entry.py | 43 ++++++++++++++++++++++++++--------- tools/binman/etype/mkimage.py | 3 ++- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 249f117ace56..48e552fc6af3 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -114,6 +114,8 @@ class Entry(object): self.bintools = {} self.missing_bintools = [] self.update_hash = True + self.fname_tmp = str() + self.index = 0 @staticmethod def FindEntryClass(etype, expanded): @@ -1134,7 +1136,7 @@ features to produce new behaviours. """ self.update_hash = update_hash - def collect_contents_to_file(self, entries, prefix, fake_size=0): + def collect_contents_to_file(self, entries, prefix, fake_size=0, separate=False): """Put the contents of a list of entries into a file Args: @@ -1152,13 +1154,32 @@ features to produce new behaviours. str: Unique portion of filename (or None if no data) """ data = b'' - for entry in entries: - # First get the input data and put it in a file. If not available, - # try later. - if not entry.ObtainContents(fake_size=fake_size): - return None, None, None - data += entry.GetData() - uniq = self.GetUniqueName() - fname = tools.get_output_filename(f'{prefix}.{uniq}') - tools.write_file(fname, data) - return data, fname, uniq + if separate is False: + for entry in entries: + # First get the input data and put it in a file. If not available, + # try later. + if not entry.ObtainContents(fake_size=fake_size): + return None, None, None + data += entry.GetData() + uniq = self.GetUniqueName() + fname = tools.get_output_filename(f'{prefix}.{uniq}') + tools.write_file(fname, data) + return data, fname, uniq + else: + for entry in entries: + self.index = (self.index + 1) + if (self.index > 2): + print('BINMAN Warn: mkimage only supports a maximum of two separate files') + break + # First get the input data and put it in a file. If not available, + # try later. + if not entry.ObtainContents(fake_size=fake_size): + return None, None, None + data = entry.GetData() + uniq = self.GetUniqueName() + fname = tools.get_output_filename(f'{prefix}.{uniq}.{self.index}') + tools.write_file(fname, data) + self.fname_tmp = [''.join(self.fname_tmp),fname] + fname = ':'.join(self.fname_tmp) + uniq = self.GetUniqueName() + return data, fname, uniq diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py index 5f6def2287f6..ce5f6b6b543a 100644 --- a/tools/binman/etype/mkimage.py +++ b/tools/binman/etype/mkimage.py @@ -46,6 +46,7 @@ class Entry_mkimage(Entry): def __init__(self, section, etype, node): super().__init__(section, etype, node) self._args = fdt_util.GetArgs(self._node, 'args') + self._mkimage_separate = fdt_util.GetBool(self._node, 'mkimage,separate_files') self._mkimage_entries = OrderedDict() self.align_default = None self.ReadEntries() @@ -53,7 +54,7 @@ class Entry_mkimage(Entry): 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) + self._mkimage_entries.values(), 'mkimage', 1024, self._mkimage_separate) if data is None: return False output_fname = tools.get_output_filename('mkimage-out.%s' % uniq)