[PATCH 1/4] binman: Add support for align argument to mkimage tool

Jonas Karlman jonas at kwiboo.se
Tue Jan 17 23:54:46 CET 2023

Add support to indicate what alignment to use for the FIT and its
external data. Pass the alignment to mkimage via the -B flag.

Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
 tools/binman/btool/mkimage.py | 5 ++++-
 tools/binman/etype/fit.py     | 8 ++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/tools/binman/btool/mkimage.py b/tools/binman/btool/mkimage.py
index da5f344162..663ed16b65 100644
--- a/tools/binman/btool/mkimage.py
+++ b/tools/binman/btool/mkimage.py
@@ -22,7 +22,7 @@ class Bintoolmkimage(bintool.Bintool):
     # pylint: disable=R0913
     def run(self, reset_timestamp=False, output_fname=None, external=False,
-            pad=None):
+            pad=None, align=None):
         """Run mkimage
@@ -33,6 +33,7 @@ class Bintoolmkimage(bintool.Bintool):
             pad: Bytes to use for padding the FIT devicetree output. This allows
                 other things to be easily added later, if required, such as
+            align: Bytes to use for alignment of the FIT and its external data
             version: True to get the mkimage version
         args = []
@@ -40,6 +41,8 @@ class Bintoolmkimage(bintool.Bintool):
         if pad:
             args += ['-p', f'{pad:x}']
+        if align:
+            args += ['-B', f'{align:x}']
         if reset_timestamp:
         if output_fname:
diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index f0e3fd1a09..deec27bee3 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -70,6 +70,11 @@ class Entry_fit(Entry_section):
             Indicates that the contents of the FIT are external and provides the
             external offset. This is passed to mkimage via the -E and -p flags.
+        fit,align
+            Indicates what alignment to use for the FIT and its external data,
+            and provides the alignment to use. This is passed to mkimage via
+            the -B flag.
             Indicates the entry argument which provides the list of device tree
             files for the gen-fdt-nodes operation (as below). This is often
@@ -423,6 +428,9 @@ class Entry_fit(Entry_section):
                 'external': True,
                 'pad': fdt_util.fdt32_to_cpu(ext_offset.value)
+        align = self._fit_props.get('fit,align')
+        if align is not None:
+            args.update({'align': fdt_util.fdt32_to_cpu(align.value)})
         if self.mkimage.run(reset_timestamp=True, output_fname=output_fname,
                             **args) is None:
             # Bintool is missing; just use empty data as the output

More information about the U-Boot mailing list