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 6D62AC433EF for ; Mon, 10 Jan 2022 03:19:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 752148327E; Mon, 10 Jan 2022 04:16:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="R8pjvi5N"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3E10081C08; Mon, 10 Jan 2022 04:15:46 +0100 (CET) Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (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 F3DBA81DE4 for ; Mon, 10 Jan 2022 04:15:21 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12d.google.com with SMTP id o1so10024355ilo.6 for ; Sun, 09 Jan 2022 19:15:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b3bBK5rTsFb/4Djo4Q1LO4i/dD3BVufclHYIXiyYUeM=; b=R8pjvi5NAIK+GaU3TTiMO+By1/LiLjgOjwVVGRRCrtgVyuYUDpK9rIrpGUB13TvUKQ enxIrRasZX9FfJXARN87rIgRrbJg1wc8V2WEdRB7wRPqgrJhuNKzDZFndynVZWWDgsk4 r6H/rLo145nDXenx/bWTQkgkWFDJuZBYz9/nc= 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=b3bBK5rTsFb/4Djo4Q1LO4i/dD3BVufclHYIXiyYUeM=; b=t9/GjUDFymweBLkDlWMPcwQQ//KyRLrhQEoT9EO90dTiA+ClXo4M4683SPMZZKT0EG M4/fASrVYKzYvlEgTr7GRXX2yMvCiw1yDzolLdezQuvj44IUwn4ypJ/IOymGx9cWX3uH sBgVwDP0X1odPW6HMgJ7D6+aTQuMi6C9PSfL1nTdS1h4fX1CmBzEC79wtGIlvgJZAPz3 bxiR32FzYVSntpXgOMj9RBWR4Sf7PXBHdER9CpFDfxV3IQOGJUq+0Hv6jqjjgZI4RzHf 05ixMCTtZuE6MnAIz/WBdxr05aBHzYQhmJjvplRApzQ71Xp+QT6EYJBTyAqjz7A6oz0f 74Vg== X-Gm-Message-State: AOAM533N38IVK/KeRHZbKXeCimHvNQFSPSvpA+QrejcJsliTUa+/EaH/ zIPLBIlnFLDvFSX4+P96gfh80OaLVbogqA== X-Google-Smtp-Source: ABdhPJw+X2IpyygtTKmp05APg5R3HDtKTIbht0Dw75hms3Fkj08vM8qrm+u/LeWvPzU2kYAsQCm1Jw== X-Received: by 2002:a05:6e02:b2f:: with SMTP id e15mr35229475ilu.110.1641784520671; Sun, 09 Jan 2022 19:15:20 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id d16sm3542182ioy.29.2022.01.09.19.15.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 19:15:20 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH v2 21/38] binman: Add a bintool implementation for mkimage Date: Sun, 9 Jan 2022 20:13:56 -0700 Message-Id: <20220110031413.1970836-22-sjg@chromium.org> X-Mailer: git-send-email 2.34.1.575.g55b058a8bb-goog In-Reply-To: <20220110031413.1970836-1-sjg@chromium.org> References: <20220110031413.1970836-1-sjg@chromium.org> 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.2 at phobos.denx.de X-Virus-Status: Clean Add a Bintool for this, which is used to build images for use by U-Boot. It supports the features needed by binman as well as installing via the u-boot-tools packages. Although this is built in the U-Boot tree, it is still useful to install a binary on the system. Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/btool/mkimage.py | 80 +++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 tools/binman/btool/mkimage.py diff --git a/tools/binman/btool/mkimage.py b/tools/binman/btool/mkimage.py new file mode 100644 index 00000000000..c85bfe053cf --- /dev/null +++ b/tools/binman/btool/mkimage.py @@ -0,0 +1,80 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2022 Google LLC +# +"""Bintool implementation for mkimage""" + +import re + +from binman import bintool + +class Bintoolmkimage(bintool.Bintool): + """Image generation for U-Boot + + This bintool supports running `mkimage` with some basic parameters as + neeed by binman. + + Normally binman uses the mkimage built by U-Boot. But when run outside the + U-Boot build system, binman can use the version installed in your system. + Support is provided for fetching this on Debian-like systems, using apt. + """ + def __init__(self, name): + super().__init__(name, 'Generate image for U-Boot') + + # pylint: disable=R0913 + def run(self, reset_timestamp=False, output_fname=None, external=False, + pad=None, version=False): + """Run mkimage + + Args: + reset_timestamp: True to update the timestamp in the FIT + output_fname: Output filename to write to + external: True to create an 'external' FIT, where the binaries are + located outside the main data structure + pad: Bytes to use for padding the FIT devicetree output. This allows + other things to be easily added later, if required, such as + signatures + version: True to get the mkimage version + """ + args = [] + if external: + args.append('-E') + if pad: + args += ['-p', f'{pad:x}'] + if reset_timestamp: + args.append('-t') + if output_fname: + args += ['-F', output_fname] + if version: + args.append('-V') + return self.run_cmd(*args) + + def fetch(self, method): + """Fetch handler for mkimage + + This installs mkimage using the apt utility. + + Args: + method (FETCH_...): Method to use + + Returns: + True if the file was fetched and now installed, None if a method + other than FETCH_BIN was requested + + Raises: + Valuerror: Fetching could not be completed + """ + if method != bintool.FETCH_BIN: + return None + return self.apt_install('u-boot-tools') + + def version(self): + """Version handler for mkimage + + Returns: + str: Version string for mkimage + """ + out = self.run(version=True).strip() + if not out: + return super().version() + m_version = re.match(r'mkimage version (.*)', out) + return m_version.group(1) if m_version else out -- 2.34.1.575.g55b058a8bb-goog