summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <[email protected]>2022-01-09 20:14:02 -0700
committerSimon Glass <[email protected]>2022-01-25 12:36:11 -0700
commitf75db1e9960bca5b287d3471819e451f03cd4bd7 (patch)
treeb54130de97f4b48f6d50cb0cf5a55a0329b7c248 /tools
parent532ae7043005fb05a7bfa708fdf3fef5c637dd38 (diff)
binman: Convert to using the mkimage bintool
Update the fit and mkimage entry types to use this bintool, instead of running mkimage directly. This simplifies the code and provides more consistency as well as supporting missing bintools. Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'tools')
-rw-r--r--tools/binman/etype/fit.py20
-rw-r--r--tools/binman/etype/mkimage.py13
2 files changed, 27 insertions, 6 deletions
diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index b41187df80a..6e5f020c502 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -134,6 +134,7 @@ class Entry_fit(Entry):
self._fdts = fdts.split()
self._fit_default_dt = self.GetEntryArgsOrProps([EntryArg('default-dt',
str)])[0]
+ self.mkimage = None
def ReadNode(self):
self.ReadEntries()
@@ -250,13 +251,21 @@ class Entry_fit(Entry):
tools.WriteFile(input_fname, data)
tools.WriteFile(output_fname, data)
- args = []
+ args = {}
ext_offset = self._fit_props.get('fit,external-offset')
if ext_offset is not None:
- args += ['-E', '-p', '%x' % fdt_util.fdt32_to_cpu(ext_offset.value)]
- tools.Run('mkimage', '-t', '-F', output_fname, *args)
+ args = {
+ 'external': True,
+ 'pad': fdt_util.fdt32_to_cpu(ext_offset.value)
+ }
+ if self.mkimage.run(reset_timestamp=True, output_fname=output_fname,
+ **args) is not None:
+ self.SetContents(tools.ReadFile(output_fname))
+ else:
+ # Bintool is missing; just use empty data as the output
+ self.record_missing_bintool(self.mkimage)
+ self.SetContents(tools.GetBytes(0, 1024))
- self.SetContents(tools.ReadFile(output_fname))
return True
def _BuildInput(self, fdt):
@@ -295,3 +304,6 @@ class Entry_fit(Entry):
def SetAllowMissing(self, allow_missing):
for section in self._fit_sections.values():
section.SetAllowMissing(allow_missing)
+
+ def AddBintools(self, tools):
+ self.mkimage = self.AddBintool(tools, 'mkimage')
diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py
index 190398728ec..201ee4b5696 100644
--- a/tools/binman/etype/mkimage.py
+++ b/tools/binman/etype/mkimage.py
@@ -51,8 +51,14 @@ class Entry_mkimage(Entry):
input_fname = tools.GetOutputFilename('mkimage.%s' % uniq)
tools.WriteFile(input_fname, data)
output_fname = tools.GetOutputFilename('mkimage-out.%s' % uniq)
- tools.Run('mkimage', '-d', input_fname, *self._args, output_fname)
- self.SetContents(tools.ReadFile(output_fname))
+ if self.mkimage.run_cmd('-d', input_fname, *self._args,
+ output_fname) is not None:
+ self.SetContents(tools.ReadFile(output_fname))
+ else:
+ # Bintool is missing; just use the input data as the output
+ self.record_missing_bintool(self.mkimage)
+ self.SetContents(data)
+
return True
def ReadEntries(self):
@@ -81,3 +87,6 @@ class Entry_mkimage(Entry):
"""
for entry in self._mkimage_entries.values():
entry.CheckFakedBlobs(faked_blobs_list)
+
+ def AddBintools(self, tools):
+ self.mkimage = self.AddBintool(tools, 'mkimage')