aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-01-09 20:14:01 -0700
committerSimon Glass <sjg@chromium.org>2022-01-25 12:36:11 -0700
commit532ae7043005fb05a7bfa708fdf3fef5c637dd38 (patch)
tree6fcc4d0caeaaafda297a4756d1d3fa3d8ccc4d50 /tools
parenta104bb2b485c5991750d7bf16294707e7e377ed8 (diff)
downloadu-boot-532ae7043005fb05a7bfa708fdf3fef5c637dd38.zip
u-boot-532ae7043005fb05a7bfa708fdf3fef5c637dd38.tar.gz
u-boot-532ae7043005fb05a7bfa708fdf3fef5c637dd38.tar.bz2
binman: Convert to using the ifwitool bintool
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/binman/etype/intel_ifwi.py25
-rw-r--r--tools/binman/ftest.py4
-rw-r--r--tools/patman/tools.py31
3 files changed, 21 insertions, 39 deletions
diff --git a/tools/binman/etype/intel_ifwi.py b/tools/binman/etype/intel_ifwi.py
index ecbd78d..ed14046 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 92bcb74..f543d17 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 a27db05..072b024 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