From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Simon Glass <sjg@chromium.org>
Subject: [PATCH v2 26/38] binman: Convert to using the ifwitool bintool
Date: Sun, 9 Jan 2022 20:14:01 -0700 [thread overview]
Message-ID: <20220110031413.1970836-27-sjg@chromium.org> (raw)
In-Reply-To: <20220110031413.1970836-1-sjg@chromium.org>
Update the ifwi entry type to use this bintool, instead of running
ifwitool directly. This simplifies the code and provides more
consistency as well as supporting missing bintools.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
(no changes since v1)
tools/binman/etype/intel_ifwi.py | 25 +++++++++++++++++++------
tools/binman/ftest.py | 4 ++--
tools/patman/tools.py | 31 -------------------------------
3 files changed, 21 insertions(+), 39 deletions(-)
diff --git a/tools/binman/etype/intel_ifwi.py b/tools/binman/etype/intel_ifwi.py
index ecbd78df5e5..ed14046ba6e 100644
--- a/tools/binman/etype/intel_ifwi.py
+++ b/tools/binman/etype/intel_ifwi.py
@@ -59,15 +59,23 @@ class Entry_intel_ifwi(Entry_blob_ext):
if self._convert_fit:
inname = self._pathname
outname = tools.GetOutputFilename('ifwi.bin')
- tools.RunIfwiTool(inname, tools.CMD_CREATE, outname)
+ if self.ifwitool.create_ifwi(inname, outname) is None:
+ # Bintool is missing; just create a zeroed ifwi.bin
+ self.record_missing_bintool(self.ifwitool)
+ self.SetContents(tools.GetBytes(0, 1024))
+
self._filename = 'ifwi.bin'
self._pathname = outname
else:
# Provide a different code path here to ensure we have test coverage
outname = self._pathname
- # Delete OBBP if it is there, then add the required new items.
- tools.RunIfwiTool(outname, tools.CMD_DELETE, subpart='OBBP')
+ # Delete OBBP if it is there, then add the required new items
+ if self.ifwitool.delete_subpart(outname, 'OBBP') is None:
+ # Bintool is missing; just use zero data
+ self.record_missing_bintool(self.ifwitool)
+ self.SetContents(tools.GetBytes(0, 1024))
+ return True
for entry in self._ifwi_entries.values():
# First get the input data and put it in a file
@@ -76,9 +84,11 @@ class Entry_intel_ifwi(Entry_blob_ext):
input_fname = tools.GetOutputFilename('input.%s' % uniq)
tools.WriteFile(input_fname, data)
- tools.RunIfwiTool(outname,
- tools.CMD_REPLACE if entry._ifwi_replace else tools.CMD_ADD,
- input_fname, entry._ifwi_subpart, entry._ifwi_entry_name)
+ # At this point we know that ifwitool is present, so we don't need
+ # to check for None here
+ self.ifwitool.add_subpart(
+ outname, entry._ifwi_subpart, entry._ifwi_entry_name,
+ input_fname, entry._ifwi_replace)
self.ReadBlobContents()
return True
@@ -132,3 +142,6 @@ class Entry_intel_ifwi(Entry_blob_ext):
if not self.missing:
for entry in self._ifwi_entries.values():
entry.WriteSymbols(self)
+
+ def AddBintools(self, tools):
+ self.ifwitool = self.AddBintool(tools, 'ifwitool')
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 92bcb740884..f543d173997 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -2314,8 +2314,8 @@ class TestFunctional(unittest.TestCase):
# We expect to find the TPL wil in subpart IBBP entry IBBL
image_fname = tools.GetOutputFilename('image.bin')
tpl_fname = tools.GetOutputFilename('tpl.out')
- tools.RunIfwiTool(image_fname, tools.CMD_EXTRACT, fname=tpl_fname,
- subpart='IBBP', entry_name='IBBL')
+ ifwitool = bintool.Bintool.create('ifwitool')
+ ifwitool.extract(image_fname, 'IBBP', 'IBBL', tpl_fname)
tpl_data = tools.ReadFile(tpl_fname)
self.assertEqual(U_BOOT_TPL_DATA, tpl_data[:len(U_BOOT_TPL_DATA)])
diff --git a/tools/patman/tools.py b/tools/patman/tools.py
index a27db05ff2a..072b024646d 100644
--- a/tools/patman/tools.py
+++ b/tools/patman/tools.py
@@ -596,37 +596,6 @@ def Decompress(indata, algo, with_header=True):
raise ValueError("Unknown algorithm '%s'" % algo)
return data
-CMD_CREATE, CMD_DELETE, CMD_ADD, CMD_REPLACE, CMD_EXTRACT = range(5)
-
-IFWITOOL_CMDS = {
- CMD_CREATE: 'create',
- CMD_DELETE: 'delete',
- CMD_ADD: 'add',
- CMD_REPLACE: 'replace',
- CMD_EXTRACT: 'extract',
- }
-
-def RunIfwiTool(ifwi_file, cmd, fname=None, subpart=None, entry_name=None):
- """Run ifwitool with the given arguments:
-
- Args:
- ifwi_file: IFWI file to operation on
- cmd: Command to execute (CMD_...)
- fname: Filename of file to add/replace/extract/create (None for
- CMD_DELETE)
- subpart: Name of sub-partition to operation on (None for CMD_CREATE)
- entry_name: Name of directory entry to operate on, or None if none
- """
- args = ['ifwitool', ifwi_file]
- args.append(IFWITOOL_CMDS[cmd])
- if fname:
- args += ['-f', fname]
- if subpart:
- args += ['-n', subpart]
- if entry_name:
- args += ['-d', '-e', entry_name]
- Run(*args)
-
def ToHex(val):
"""Convert an integer value (or None) to a string
--
2.34.1.575.g55b058a8bb-goog
next prev parent reply other threads:[~2022-01-10 3:19 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-10 3:13 [PATCH v2 00/38] binman: Add support for bintools and missing tools Simon Glass
2022-01-10 3:13 ` [PATCH v2 01/38] Makefile: Fake external blobs by default with binman Simon Glass
2022-01-26 15:37 ` Simon Glass
2022-10-10 10:15 ` Rasmus Villemoes
2022-10-10 14:25 ` Tom Rini
2022-10-10 15:19 ` Simon Glass
2022-10-10 15:24 ` Tom Rini
2022-10-10 15:33 ` Simon Glass
2022-10-10 15:36 ` Tom Rini
2022-10-10 15:43 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 02/38] binman: Tweak elf tests for a toolchain change Simon Glass
2022-01-26 15:37 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 03/38] mkimage: Show the external-offset error Simon Glass
2022-01-26 15:37 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 04/38] binman: Expand the external FIT test a little Simon Glass
2022-01-26 15:37 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 05/38] patman: Allow running a tool and returning the full result Simon Glass
2022-01-26 15:37 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 06/38] buildman: Move the download function to tools Simon Glass
2022-01-26 15:37 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 07/38] patman: Tidy up the download function a little Simon Glass
2022-01-26 15:37 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 08/38] patman: Add a function to find a tool on the path Simon Glass
2022-01-26 15:37 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 09/38] binman: Write fake blobs to the output directory Simon Glass
2022-01-10 3:13 ` [PATCH v2 10/38] binman: Drop the image name from the fake-blob message Simon Glass
2022-01-26 15:37 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 11/38] binman: Allow faked blobs in blob-ext-list Simon Glass
2022-01-26 15:37 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 12/38] binman: Correct path for fip_util Simon Glass
2022-01-26 15:37 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 13/38] binman: Add installation instructions Simon Glass
2022-01-26 15:37 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 14/38] binman: Add support for bintools Simon Glass
2022-01-26 15:37 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 15/38] binman: Plumb in " Simon Glass
2022-01-26 15:37 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 16/38] binman: Add tests for bintool Simon Glass
2022-01-26 15:37 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 17/38] binman: Add a bintool implementation for cbfstool Simon Glass
2022-01-26 15:37 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 18/38] binman: Add a bintool implementation for fiptool Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 19/38] binman: Add a bintool implementation for futility Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 20/38] binman: Add a bintool implementation for ifwitool Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 21/38] binman: Add a bintool implementation for mkimage Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 22/38] binman: Enable bintool tests including cmdline processing Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 23/38] binman: Convert to using the CBFS bintool Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:13 ` [PATCH v2 24/38] binman: Convert to using the FIP bintool Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:14 ` [PATCH v2 25/38] binman: Convert to using the futility bintool Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:14 ` Simon Glass [this message]
2022-01-26 15:36 ` [PATCH v2 26/38] binman: Convert to using the ifwitool bintool Simon Glass
2022-01-10 3:14 ` [PATCH v2 27/38] binman: Convert to using the mkimage bintool Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:14 ` [PATCH v2 28/38] binman: Move compression into binman Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:14 ` [PATCH v2 29/38] binman: Tidy up pylint warnings in comp_util Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:14 ` [PATCH v2 30/38] binman: Add a bintool implementation for lz4 Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:14 ` [PATCH v2 31/38] binman: Convert to using the lz4 bintool Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:14 ` [PATCH v2 32/38] binman: Add a bintool implementation for lzma_alone Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:14 ` [PATCH v2 33/38] binman: Convert to using the lzma_alone bintool Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:14 ` [PATCH v2 34/38] binman: Plumb in support for missing bintools Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:14 ` [PATCH v2 35/38] binman: Complete test coverage of comp_util Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:14 ` [PATCH v2 36/38] binman: Add a command to generate bintool docs Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:14 ` [PATCH v2 37/38] binman: Add documentation for bintools Simon Glass
2022-01-26 15:36 ` Simon Glass
2022-01-10 3:14 ` [PATCH v2 38/38] RFC: Move Odroid-C2 to use binman to produce the image Simon Glass
2022-01-21 2:02 ` [PATCH v2 00/38] binman: Add support for bintools and missing tools Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220110031413.1970836-27-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox