binman: imx8mimage: Handle nxp,boot-from = "fspi"
Subsystems (2)
PATCH 1/3 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.
---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Adam Ford <[email protected]>
Cc: Alexander Koch <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
--- tools/binman/etype/nxp_imx8mimage.py | 8 +++++++- tools/binman/ftest.py | 5 +++++ tools/binman/test/351_nxp_imx8m_fspi.dts | 18 ++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tools/binman/test/351_nxp_imx8m_fspi.dts
tools/binman/etype/nxp_imx8mimage.py +7 -1
@@ -33,6 +33,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') 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 +53,12 @@ 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' and self.fspi_header: + spidata = tools.read_file(self.fspi_header) + if len(spidata) < 0x1000: + spidata += tools.get_bytes(0, 0x1000 - len(spidata)) + return spidata + outdata else: # Bintool is missing; just use the input data as the output self.record_missing_bintool(self.mkimage)
tools/binman/ftest.py +5 -0
@@ -8099,6 +8099,11 @@ 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""" + TestFunctional._MakeInputFile('fspi_header.bin', tools.get_bytes(0, 448)) + self._DoTestFile('351_nxp_imx8m_fspi.dts') + def testNxpHeaderDdrfw(self): """Test that binman can add a header to DDR PHY firmware images""" data = self._DoReadFile('vendor/nxp_ddrfw_imx95.dts')
tools/binman/test/351_nxp_imx8m_fspi.dts new file +18 -0
@@ -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 = <2>; + nxp,loader-address = <0x10>; + }; + }; +};
Signature · 1 line
2.53.0
PATCH 2/3 arm64: dts: imx8mm: Generate FSPI header using binman imx8mimage
The binman imx8mimage now correctly handles generated fspi_header.bin in its imx8mimage etype. Make use of this, remove fspi_conf_block in favor of generated fspi_header.bin, and configure imx8mimage accordingly.
---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Adam Ford <[email protected]>
Cc: Alexander Koch <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
--- arch/arm/dts/imx8mm-u-boot.dtsi | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
arch/arm/dts/imx8mm-u-boot.dtsi +5 -8
@@ -50,14 +50,6 @@ section { pad-byte = <0x00>; -#ifdef CONFIG_FSPI_CONF_HEADER - fspi_conf_block { - filename = CONFIG_FSPI_CONF_FILE; - type = "blob-ext"; - size = <0x1000>; - }; -#endif - #ifdef CONFIG_IMX_HAB nxp-imx8mcst@0 { filename = "u-boot-spl-mkimage.signed.bin";
@@ -68,7 +60,12 @@ binman_imx_spl: nxp-imx8mimage { filename = "u-boot-spl-mkimage.bin"; +#ifdef CONFIG_FSPI_CONF_HEADER + nxp,boot-from = "fspi"; + nxp,fspi-header-filename = CONFIG_FSPI_CONF_FILE; +#else nxp,boot-from = "sd"; +#endif nxp,rom-version = <1>; nxp,loader-address = <CONFIG_SPL_TEXT_BASE>; args; /* Needed by mkimage etype superclass */
Signature · 1 line
2.53.0
PATCH 3/3 arm64: dts: imx8mn: Generate FSPI header using binman imx8mimage
In reply to Marek VasutThe binman imx8mimage now correctly handles generated fspi_header.bin in its imx8mimage etype. Make use of this, remove fspi_conf_block in favor of generated fspi_header.bin, and configure imx8mimage accordingly.
---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Adam Ford <[email protected]>
Cc: Alexander Koch <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
--- arch/arm/dts/imx8mn-u-boot.dtsi | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
arch/arm/dts/imx8mn-u-boot.dtsi +5 -8
@@ -104,14 +104,6 @@ section { pad-byte = <0x00>; -#ifdef CONFIG_FSPI_CONF_HEADER - fspi_conf_block { - filename = CONFIG_FSPI_CONF_FILE; - type = "blob-ext"; - offset = <0x400>; - }; -#endif - #ifdef CONFIG_IMX_HAB nxp-imx8mcst@0 { filename = "u-boot-spl-mkimage.signed.bin";
@@ -122,7 +114,12 @@ binman_imx_spl: nxp-imx8mimage { filename = "u-boot-spl-mkimage.bin"; +#ifdef CONFIG_FSPI_CONF_HEADER + nxp,boot-from = "fspi"; + nxp,fspi-header-filename = CONFIG_FSPI_CONF_FILE; +#else nxp,boot-from = "sd"; +#endif nxp,rom-version = <2>; nxp,loader-address = <CONFIG_SPL_TEXT_BASE>; args; /* Needed by mkimage etype superclass */
Signature · 1 line
2.53.0
Quoted 32 lines · Marek Vasut
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 usingfspi_conf_blockwith filename pointing atCONFIG_FSPI_CONF_FILEfile. This does not work, for two reasons.First, the
CONFIG_FSPI_CONF_FILEis generated by mkimage -T imx8mimage and may not be available yet when thefspi_conf_blockis evaluated. That leads to a race condition where highly parallel builds fail to find theCONFIG_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
0x1000which is the size offspi_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_blocknode in the DT anymore.Signed-off-by Marek Vasut <[email protected]>---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Adam Ford <[email protected]>
Cc: Alexander Koch <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
Quoted 4 lines
--- tools/binman/etype/nxp_imx8mimage.py | 8 +++++++- tools/binman/ftest.py | 5 +++++ tools/binman/test/351_nxp_imx8m_fspi.dts | 18 ++++++++++++++++++
Tests finally have subdirectories instead of the frequently conflicting numerical prefix, please pick a subdirectory of tools/binman/test/ for this for v2, and include a short cover letter as well, thanks!
Signature · 1 line
Tom