summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJonas Karlman <jonas@kwiboo.se>2023-01-21 22:01:39 +0300
committerSimon Glass <sjg@chromium.org>2023-01-26 20:47:45 +0300
commit9b2fd2d22852ee70c07934a78314b01ad9b96b62 (patch)
tree816a6684c429c68242cb5297b7258b98e75afe08 /tools
parent27e0fb3b0823519aea2d42cd8bde20234dd87cef (diff)
downloadu-boot-9b2fd2d22852ee70c07934a78314b01ad9b96b62.tar.xz
binman: Add support for align argument to mkimage tool
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@kwiboo.se> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/binman/btool/mkimage.py5
-rw-r--r--tools/binman/entries.rst5
-rw-r--r--tools/binman/etype/fit.py8
-rw-r--r--tools/binman/ftest.py16
-rw-r--r--tools/binman/test/275_fit_align.dts59
5 files changed, 92 insertions, 1 deletions
diff --git a/tools/binman/btool/mkimage.py b/tools/binman/btool/mkimage.py
index da5f344162..d5b407c554 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
Args:
@@ -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
signatures
+ 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):
args.append('-E')
if pad:
args += ['-p', f'{pad:x}']
+ if align:
+ args += ['-B', f'{align:x}']
if reset_timestamp:
args.append('-t')
if output_fname:
diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index 2b32c131ed..8f11189b7b 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -604,6 +604,11 @@ The top-level 'fit' node supports the following special properties:
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.
+
fit,fdt-list
Indicates the entry argument which provides the list of device tree
files for the gen-fdt-nodes operation (as below). This is often
diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index 0e9d81b9e8..df1ce81f9c 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.
+
fit,fdt-list
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
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index be0aea49ce..f0d0afd5b8 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -6309,6 +6309,22 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
self.assertEqual(base + 8, inset.image_pos);
self.assertEqual(4, inset.size);
+ def testFitAlign(self):
+ """Test an image with an FIT with aligned external data"""
+ data = self._DoReadFile('275_fit_align.dts')
+ self.assertEqual(4096, len(data))
+
+ dtb = fdt.Fdt.FromData(data)
+ dtb.Scan()
+
+ props = self._GetPropTree(dtb, ['data-position'])
+ expected = {
+ 'u-boot:data-position': 1024,
+ 'fdt-1:data-position': 2048,
+ 'fdt-2:data-position': 3072,
+ }
+ self.assertEqual(expected, props)
+
if __name__ == "__main__":
unittest.main()
diff --git a/tools/binman/test/275_fit_align.dts b/tools/binman/test/275_fit_align.dts
new file mode 100644
index 0000000000..c7b06e390f
--- /dev/null
+++ b/tools/binman/test/275_fit_align.dts
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ binman {
+ fit {
+ description = "test desc";
+ #address-cells = <1>;
+ fit,external-offset = <1024>;
+ fit,align = <1024>;
+
+ images {
+ u-boot {
+ description = "test u-boot";
+ type = "standalone";
+ arch = "arm64";
+ os = "u-boot";
+ compression = "none";
+ load = <00000000>;
+ entry = <00000000>;
+
+ u-boot-nodtb {
+ };
+ };
+
+ fdt-1 {
+ description = "test fdt";
+ type = "flat_dt";
+ compression = "none";
+
+ u-boot-dtb {
+ };
+ };
+
+ fdt-2 {
+ description = "test fdt";
+ type = "flat_dt";
+ compression = "none";
+
+ u-boot-dtb {
+ };
+ };
+ };
+
+ configurations {
+ default = "config-1";
+ config-1 {
+ description = "test config";
+ fdt = "fdt-1";
+ firmware = "u-boot";
+ };
+ };
+ };
+ };
+};