summaryrefslogtreecommitdiff
path: root/tools/binman
diff options
context:
space:
mode:
authorMarek Vasut <[email protected]>2026-05-30 19:08:24 +0200
committerFabio Estevam <[email protected]>2026-06-04 17:26:40 -0300
commit822a98588d16e5542b4e4d9d23c19a8ee7e93040 (patch)
tree6c9a7df086c6a69842d223aa0d7fbdeb63e9d06b /tools/binman
parentcdb9e79056dcc94440202845a75a31e4e40cc3a2 (diff)
binman: imx8mimage: Handle nxp,boot-from = "fspi"
Boot from FSPI requires additional 448 Byte long header, with U-Boot SPL starting at offset 0x1000. Currently, both i.MX8MM and i.MX8MN attempt to generate this header using fspi_conf_block with filename pointing at CONFIG_FSPI_CONF_FILE file. This does not work, for two reasons. First, the CONFIG_FSPI_CONF_FILE is generated by mkimage -T imx8mimage and may not be available yet when the fspi_conf_block is evaluated. That leads to a race condition where highly parallel builds fail to find the CONFIG_FSPI_CONF_FILE, which is usually called fspi_header.bin, on first build attempt. Second, binman gets confused and patches incorrect offset of DDR PHY firmware blobs into U-Boot SPL, the offset is incremented by exactly 0x1000 which is the size of fspi_conf_block. Fix both problems at once, make imx8mimage handle the generated FSPI header and prepend it in front of the imx8mimage processed data. This way, the race condition is solved, because the data generated by the imx8mimage are surely combined only after mkimage -T imx8mimage ran. The binman offset calculation is also solved, because there is no fspi_conf_block node in the DT anymore. Signed-off-by: Marek Vasut <[email protected]>
Diffstat (limited to 'tools/binman')
-rw-r--r--tools/binman/etype/nxp_imx8mimage.py14
-rw-r--r--tools/binman/ftest.py14
-rw-r--r--tools/binman/test/vendor/nxp_imx8m_fspi.dts18
-rw-r--r--tools/binman/test/vendor/nxp_imx8m_fspi_fail.dts18
-rw-r--r--tools/binman/test/vendor/nxp_imx8m_fspi_pass.dts18
5 files changed, 81 insertions, 1 deletions
diff --git a/tools/binman/etype/nxp_imx8mimage.py b/tools/binman/etype/nxp_imx8mimage.py
index 8ad177b3b65..25c43438a87 100644
--- a/tools/binman/etype/nxp_imx8mimage.py
+++ b/tools/binman/etype/nxp_imx8mimage.py
@@ -7,6 +7,8 @@
# configuration file and input data.
#
+import os
+
from collections import OrderedDict
from binman.entry import Entry
@@ -23,6 +25,8 @@ class Entry_nxp_imx8mimage(Entry_mkimage):
- nxp,boot-from - device to boot from (e.g. 'sd')
- nxp,loader-address - loader address (SPL text base)
- nxp,rom-version - BootROM version ('2' for i.MX8M Nano and Plus)
+ - nxp,fspi-header-filename - FSPI header file name (CONFIG_FSPI_CONF_FILE).
+ Used only if 'nxp,boot-from == "fspi"' .
"""
def __init__(self, section, etype, node):
@@ -33,6 +37,7 @@ class Entry_nxp_imx8mimage(Entry_mkimage):
def ReadNode(self):
super().ReadNode()
self.boot_from = fdt_util.GetString(self._node, 'nxp,boot-from')
+ self.fspi_header = fdt_util.GetString(self._node, 'nxp,fspi-header-filename', 'fspi_header.bin')
self.loader_address = fdt_util.GetInt(self._node, 'nxp,loader-address')
self.rom_version = fdt_util.GetInt(self._node, 'nxp,rom-version')
self.ReadEntries()
@@ -52,7 +57,14 @@ class Entry_nxp_imx8mimage(Entry_mkimage):
args = ['-d', input_fname, '-n', cfg_fname, '-T', 'imx8mimage',
output_fname]
if self.mkimage.run_cmd(*args) is not None:
- return tools.read_file(output_fname)
+ outdata = tools.read_file(output_fname)
+ if self.boot_from == 'fspi':
+ spidata = tools.read_file(os.path.join(tools.get_output_dir(), self.fspi_header))
+ if len(spidata) != 448:
+ raise ValueError("FSPI header is not 448 Bytes long")
+ spidata += tools.get_bytes(0, 0x1000 - len(spidata))
+ outdata = spidata + outdata
+ return outdata
else:
# Bintool is missing; just use the input data as the output
self.record_missing_bintool(self.mkimage)
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 9a3811c1732..bf98b268ac1 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -8099,6 +8099,20 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
result = cst.fetch(bintool.FETCH_BUILD)
self.assertEqual(('cst', None), result)
+ def testNxpImx8MFSPI(self):
+ """Test that binman can produce an iMX8m FSPI image"""
+ testdir = tempfile.mkdtemp(prefix='binman.')
+
+ tools.write_file(os.path.join(testdir, 'fspi_header.bin'), tools.get_bytes(0, 448))
+ with terminal.capture():
+ self._DoTestFile('vendor/nxp_imx8m_fspi.dts', output_dir=testdir)
+ self._DoTestFile('vendor/nxp_imx8m_fspi_pass.dts', output_dir=testdir)
+
+ tools.write_file(os.path.join(testdir, 'fspi_header_fail.bin'), tools.get_bytes(0, 4097))
+ with terminal.capture():
+ with self.assertRaises(ValueError) as e:
+ self._DoTestFile('vendor/nxp_imx8m_fspi_fail.dts', output_dir=testdir)
+
def testNxpHeaderDdrfw(self):
"""Test that binman can add a header to DDR PHY firmware images"""
data = self._DoReadFile('vendor/nxp_ddrfw_imx95.dts')
diff --git a/tools/binman/test/vendor/nxp_imx8m_fspi.dts b/tools/binman/test/vendor/nxp_imx8m_fspi.dts
new file mode 100644
index 00000000000..ae6cc5981e6
--- /dev/null
+++ b/tools/binman/test/vendor/nxp_imx8m_fspi.dts
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ binman {
+ nxp-imx8mimage {
+ args; /* TODO: Needed by mkimage etype superclass */
+ nxp,boot-from = "fspi";
+ nxp,fspi-header-filename = "fspi_header.bin";
+ nxp,rom-version = <1>;
+ nxp,loader-address = <0x10>;
+ };
+ };
+};
diff --git a/tools/binman/test/vendor/nxp_imx8m_fspi_fail.dts b/tools/binman/test/vendor/nxp_imx8m_fspi_fail.dts
new file mode 100644
index 00000000000..5a0d758e5a3
--- /dev/null
+++ b/tools/binman/test/vendor/nxp_imx8m_fspi_fail.dts
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ binman {
+ nxp-imx8mimage {
+ args; /* TODO: Needed by mkimage etype superclass */
+ nxp,boot-from = "fspi";
+ nxp,fspi-header-filename = "fspi_header_fail.bin";
+ nxp,rom-version = <2>;
+ nxp,loader-address = <0x10>;
+ };
+ };
+};
diff --git a/tools/binman/test/vendor/nxp_imx8m_fspi_pass.dts b/tools/binman/test/vendor/nxp_imx8m_fspi_pass.dts
new file mode 100644
index 00000000000..448d93d277a
--- /dev/null
+++ b/tools/binman/test/vendor/nxp_imx8m_fspi_pass.dts
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ binman {
+ nxp-imx8mimage {
+ args; /* TODO: Needed by mkimage etype superclass */
+ nxp,boot-from = "fspi";
+ /* Default nxp,fspi-header-filename = "fspi_header.bin"; */
+ nxp,rom-version = <2>;
+ nxp,loader-address = <0x10>;
+ };
+ };
+};