[PATCH 0/4] Fix FSPI booting on i.MX8M Mini and Nano

When the binman tools was upgraded to use imx8mimage, it appears to have changed how the code and/or boot ROM search the blob for the objects within the binary blob which broke bootin from FSPI on Mini and Nano.
Instead of reverting the use of imx8mimage, create two files where the first one lacks the flexspi configuration table, and a second file which contains the flexspi configuration table plus the contents of flash.bin. Keeping this information from imx8mimage appears to work since the code reading from the FSPI seems to already compensate for the adjusted offsets.
On the Nano, the flash.bin file is identical between the fspi mode and the sd mode, so this series allows us to remove an extra defconfig file since the objects built are virtually the same between SD and FSPI because the boot ROM is a little newer than Mini.
Adam Ford (4): arm64: dts: imx8mn: Fix FSPI booting configs: imx8mn_beacon: Enable FSPI_CONF_HEADER configs: imx8mn_beacon: Remove imx8mn_beacon_fspi_defconfig arm64: dts: imx8mm: Fix FSPI booting
arch/arm/dts/imx8mm-u-boot.dtsi | 259 +++++++++++++------------- arch/arm/dts/imx8mn-u-boot.dtsi | 266 ++++++++++++++------------- configs/imx8mn_beacon_defconfig | 2 + configs/imx8mn_beacon_fspi_defconfig | 152 --------------- 4 files changed, 275 insertions(+), 404 deletions(-) delete mode 100644 configs/imx8mn_beacon_fspi_defconfig

When FSPI_CONF_HEADER is set, the binary needs to be built such that there is a configuration file located at 0x400 and the start of the file that would normally be flash.bin starts at 0x1000. This used to be done properly until the device tree was converted to nxp_imx8mimage.
Building these with the offsets built into the binman device tree changes impacts how the actual image is built and the locations of the various blobs aren't fetched properly and booting fails.
Fix this by building a standard image as if it were to boot from eMMC or SD, then use that image as the input for a second image which adds this FSPI header at 0x400, and then places the standard image at offset 0x1000. This also has the benefit of being able to create both SD/eMMC image at the same time as a fspi image called flexspi.bin.
Fixes: 37e50627efac ("ARM: dts: imx: Convert i.MX8M flash.bin image generation to binman") Signed-off-by: Adam Ford aford173@gmail.com --- arch/arm/dts/imx8mn-u-boot.dtsi | 266 +++++++++++++++++--------------- 1 file changed, 138 insertions(+), 128 deletions(-)
diff --git a/arch/arm/dts/imx8mn-u-boot.dtsi b/arch/arm/dts/imx8mn-u-boot.dtsi index 6875c6d44f..157e6b9a26 100644 --- a/arch/arm/dts/imx8mn-u-boot.dtsi +++ b/arch/arm/dts/imx8mn-u-boot.dtsi @@ -91,185 +91,195 @@ };
&binman { - filename = "flash.bin"; - section { - pad-byte = <0x00>; + multiple-images;
-#ifdef CONFIG_FSPI_CONF_HEADER - fspi_conf_block { - filename = CONFIG_FSPI_CONF_FILE; - type = "blob-ext"; - offset = <0x400>; - }; -#endif + standard_image: image1 { + filename = "flash.bin"; + section { + pad-byte = <0x00>;
#ifdef CONFIG_IMX_HAB - nxp-imx8mcst@0 { - filename = "u-boot-spl-mkimage.signed.bin"; - nxp,loader-address = <CONFIG_SPL_TEXT_BASE>; - nxp,unlock; - args; /* Needed by mkimage etype superclass */ -#endif - - binman_imx_spl: nxp-imx8mimage { - filename = "u-boot-spl-mkimage.bin"; - nxp,boot-from = "sd"; - nxp,rom-version = <2>; + nxp-imx8mcst@0 { + filename = "u-boot-spl-mkimage.signed.bin"; nxp,loader-address = <CONFIG_SPL_TEXT_BASE>; + nxp,unlock; args; /* Needed by mkimage etype superclass */ +#endif
- section { - filename = "u-boot-spl-ddr.bin"; - pad-byte = <0xff>; - align-size = <4>; - align = <4>; - - u-boot-spl { - align-end = <4>; - filename = "u-boot-spl.bin"; - }; + binman_imx_spl: nxp-imx8mimage { + filename = "u-boot-spl-mkimage.bin"; + nxp,boot-from = "sd"; + nxp,rom-version = <2>; + nxp,loader-address = <CONFIG_SPL_TEXT_BASE>; + args; /* Needed by mkimage etype superclass */ + + section { + filename = "u-boot-spl-ddr.bin"; + pad-byte = <0xff>; + align-size = <4>; + align = <4>; + + u-boot-spl { + align-end = <4>; + filename = "u-boot-spl.bin"; + };
- ddr-1d-imem-fw { + ddr-1d-imem-fw { #ifdef CONFIG_IMX8M_LPDDR4 - filename = "lpddr4_pmu_train_1d_imem.bin"; + filename = "lpddr4_pmu_train_1d_imem.bin"; #elif CONFIG_IMX8M_DDR4 - filename = "ddr4_imem_1d_201810.bin"; + filename = "ddr4_imem_1d_201810.bin"; #else - filename = "ddr3_imem_1d.bin"; + filename = "ddr3_imem_1d.bin"; #endif - type = "blob-ext"; - align-end = <4>; - }; + type = "blob-ext"; + align-end = <4>; + };
- ddr-1d-dmem-fw { + ddr-1d-dmem-fw { #ifdef CONFIG_IMX8M_LPDDR4 - filename = "lpddr4_pmu_train_1d_dmem.bin"; + filename = "lpddr4_pmu_train_1d_dmem.bin"; #elif CONFIG_IMX8M_DDR4 - filename = "ddr4_dmem_1d_201810.bin"; + filename = "ddr4_dmem_1d_201810.bin"; #else - filename = "ddr3_dmem_1d.bin"; + filename = "ddr3_dmem_1d.bin"; #endif - type = "blob-ext"; - align-end = <4>; - }; + type = "blob-ext"; + align-end = <4>; + };
#if defined(CONFIG_IMX8M_LPDDR4) || defined(CONFIG_IMX8M_DDR4) - ddr-2d-imem-fw { + ddr-2d-imem-fw { #ifdef CONFIG_IMX8M_LPDDR4 - filename = "lpddr4_pmu_train_2d_imem.bin"; + filename = "lpddr4_pmu_train_2d_imem.bin"; #else - filename = "ddr4_imem_2d_201810.bin"; + filename = "ddr4_imem_2d_201810.bin"; #endif - type = "blob-ext"; - align-end = <4>; - }; + type = "blob-ext"; + align-end = <4>; + };
- ddr-2d-dmem-fw { + ddr-2d-dmem-fw { #ifdef CONFIG_IMX8M_LPDDR4 - filename = "lpddr4_pmu_train_2d_dmem.bin"; + filename = "lpddr4_pmu_train_2d_dmem.bin"; #else - filename = "ddr4_dmem_2d_201810.bin"; + filename = "ddr4_dmem_2d_201810.bin"; #endif - type = "blob-ext"; - align-end = <4>; - }; + type = "blob-ext"; + align-end = <4>; + }; #endif + }; }; - };
#ifdef CONFIG_IMX_HAB - }; + };
- nxp-imx8mcst@1 { - filename = "u-boot-fit.signed.bin"; - nxp,loader-address = <CONFIG_SPL_LOAD_FIT_ADDRESS>; -#ifdef CONFIG_FSPI_CONF_HEADER - offset = <0x59000>; -#else - offset = <0x58000>; -#endif - args; /* Needed by mkimage etype superclass */ + nxp-imx8mcst@1 { + filename = "u-boot-fit.signed.bin"; + nxp,loader-address = <CONFIG_SPL_LOAD_FIT_ADDRESS>; + offset = <0x58000>; + args; /* Needed by mkimage etype superclass */ #endif
- binman_imx_fit: fit { - description = "Configuration to load ATF before U-Boot"; - filename = "u-boot.itb"; + binman_imx_fit: fit { + description = "Configuration to load ATF before U-Boot"; + filename = "u-boot.itb"; #ifndef CONFIG_IMX_HAB - fit,external-offset = <CONFIG_FIT_EXTERNAL_OFFSET>; + fit,external-offset = <CONFIG_FIT_EXTERNAL_OFFSET>; #endif - fit,fdt-list = "of-list"; - #address-cells = <1>; -#ifdef CONFIG_FSPI_CONF_HEADER - offset = <0x59000>; -#else - offset = <0x58000>; -#endif - - images { - uboot { - arch = "arm64"; - compression = "none"; - description = "U-Boot (64-bit)"; - load = <CONFIG_TEXT_BASE>; - type = "standalone"; - - uboot-blob { - filename = "u-boot-nodtb.bin"; - type = "blob-ext"; + fit,fdt-list = "of-list"; + #address-cells = <1>; + offset = <0x58000>; + + images { + uboot { + arch = "arm64"; + compression = "none"; + description = "U-Boot (64-bit)"; + load = <CONFIG_TEXT_BASE>; + type = "standalone"; + + uboot-blob { + filename = "u-boot-nodtb.bin"; + type = "blob-ext"; + }; }; - };
#ifndef CONFIG_ARMV8_PSCI - atf { - arch = "arm64"; - compression = "none"; - description = "ARM Trusted Firmware"; - entry = <0x960000>; - load = <0x960000>; - type = "firmware"; - - atf-blob { - filename = "bl31.bin"; - type = "atf-bl31"; + atf { + arch = "arm64"; + compression = "none"; + description = "ARM Trusted Firmware"; + entry = <0x960000>; + load = <0x960000>; + type = "firmware"; + + atf-blob { + filename = "bl31.bin"; + type = "atf-bl31"; + }; }; - }; #endif
- binman_fip: fip { - arch = "arm64"; - compression = "none"; - description = "Trusted Firmware FIP"; - load = <0x40310000>; - type = "firmware"; - }; + binman_fip: fip { + arch = "arm64"; + compression = "none"; + description = "Trusted Firmware FIP"; + load = <0x40310000>; + type = "firmware"; + };
- @fdt-SEQ { - compression = "none"; - description = "NAME"; - type = "flat_dt"; + @fdt-SEQ { + compression = "none"; + description = "NAME"; + type = "flat_dt";
- uboot-fdt-blob { - filename = "u-boot.dtb"; - type = "blob-ext"; + uboot-fdt-blob { + filename = "u-boot.dtb"; + type = "blob-ext"; + }; }; }; - };
- configurations { - default = "@config-DEFAULT-SEQ"; + configurations { + default = "@config-DEFAULT-SEQ";
- @config-SEQ { - description = "NAME"; - fdt = "fdt-SEQ"; - firmware = "uboot"; + @config-SEQ { + description = "NAME"; + fdt = "fdt-SEQ"; + firmware = "uboot"; #ifndef CONFIG_ARMV8_PSCI - loadables = "atf"; + loadables = "atf"; #endif + }; }; }; - }; #ifdef CONFIG_IMX_HAB - }; + }; #endif + }; + }; + +#ifdef CONFIG_FSPI_CONF_HEADER + flexspi_image: image2 { + filename = "flexspi.bin"; + section { + pad-byte = <0x00>; + + fspi_conf_block { + filename = CONFIG_FSPI_CONF_FILE; + type = "blob-ext"; + offset = <0x400>; + }; + + flashbin { + filename = "flash.bin"; + type = "blob-ext"; + offset = <0x1000>; + }; + }; + }; +#endif };

On 11/9/24 9:06 PM, Adam Ford wrote:
When FSPI_CONF_HEADER is set, the binary needs to be built such that there is a configuration file located at 0x400 and the start of the file that would normally be flash.bin starts at 0x1000. This used to be done properly until the device tree was converted to nxp_imx8mimage.
Building these with the offsets built into the binman device tree changes impacts how the actual image is built and the locations of the various blobs aren't fetched properly and booting fails.
Fix this by building a standard image as if it were to boot from eMMC or SD, then use that image as the input for a second image
This seems like a workaround for some broken offset calculation in binman ?

On Sat, Nov 9, 2024 at 7:34 PM Marek Vasut marex@denx.de wrote:
On 11/9/24 9:06 PM, Adam Ford wrote:
When FSPI_CONF_HEADER is set, the binary needs to be built such that there is a configuration file located at 0x400 and the start of the file that would normally be flash.bin starts at 0x1000. This used to be done properly until the device tree was converted to nxp_imx8mimage.
Building these with the offsets built into the binman device tree changes impacts how the actual image is built and the locations of the various blobs aren't fetched properly and booting fails.
Fix this by building a standard image as if it were to boot from eMMC or SD, then use that image as the input for a second image
This seems like a workaround for some broken offset calculation in binman ?
This used to work until it was migrated to nxp_imx8mimage. The blobs appear to be at the proper offsets, but the contents of what's stored at those offsets are not the same.
If you're going to claim there is a bug somewhere, I would argue that it's somewhere i nxp_imx8mimage. However, if you look at this series, the added benefit is the ability for Nano to be able to build both a SD/eMMC image and FSPI images with one config which allows for the elimination of extra defconfig files. I am guessing Plus would have a similar benefit since they have similar bootloaders.
adam

On 11/10/24 2:15 PM, Adam Ford wrote:
On Sat, Nov 9, 2024 at 7:34 PM Marek Vasut marex@denx.de wrote:
On 11/9/24 9:06 PM, Adam Ford wrote:
When FSPI_CONF_HEADER is set, the binary needs to be built such that there is a configuration file located at 0x400 and the start of the file that would normally be flash.bin starts at 0x1000. This used to be done properly until the device tree was converted to nxp_imx8mimage.
Building these with the offsets built into the binman device tree changes impacts how the actual image is built and the locations of the various blobs aren't fetched properly and booting fails.
Fix this by building a standard image as if it were to boot from eMMC or SD, then use that image as the input for a second image
This seems like a workaround for some broken offset calculation in binman ?
This used to work until it was migrated to nxp_imx8mimage. The blobs appear to be at the proper offsets, but the contents of what's stored at those offsets are not the same.
I know, this is what Lukasz reported too.
If you're going to claim there is a bug somewhere, I would argue that it's somewhere i nxp_imx8mimage
I agree with that claim. Well, by extension, the problem might also be in binman itself.
. However, if you look at this series, the added benefit is the ability for Nano to be able to build both a SD/eMMC image and FSPI images with one config which allows for the elimination of extra defconfig files. I am guessing Plus would have a similar benefit since they have similar bootloaders.
This I do not agree with. If the intent is to generate two images, then there should be two full binman descriptors, one for each image (one for flash-plain.bin and one for flash-fspi.bin or some such naming).
Can you try and fix the FSPI generation first, so an FSPI compatible flash.bin can be generated using binman only, without the dependency on processing non-FSPI compatible flash.bin ? I think the intention of binman was to replace all that ad-hoc pre/postprocessing of blobs.

On Sun, Nov 10, 2024 at 10:42 AM Marek Vasut marex@denx.de wrote:
On 11/10/24 2:15 PM, Adam Ford wrote:
On Sat, Nov 9, 2024 at 7:34 PM Marek Vasut marex@denx.de wrote:
On 11/9/24 9:06 PM, Adam Ford wrote:
When FSPI_CONF_HEADER is set, the binary needs to be built such that there is a configuration file located at 0x400 and the start of the file that would normally be flash.bin starts at 0x1000. This used to be done properly until the device tree was converted to nxp_imx8mimage.
Building these with the offsets built into the binman device tree changes impacts how the actual image is built and the locations of the various blobs aren't fetched properly and booting fails.
Fix this by building a standard image as if it were to boot from eMMC or SD, then use that image as the input for a second image
This seems like a workaround for some broken offset calculation in binman ?
This used to work until it was migrated to nxp_imx8mimage. The blobs appear to be at the proper offsets, but the contents of what's stored at those offsets are not the same.
I know, this is what Lukasz reported too.
If you're going to claim there is a bug somewhere, I would argue that it's somewhere i nxp_imx8mimage
I agree with that claim. Well, by extension, the problem might also be in binman itself.
. However, if you look at this series, the added benefit is the ability for Nano to be able to build both a SD/eMMC image and FSPI images with one config which allows for the elimination of extra defconfig files. I am guessing Plus would have a similar benefit since they have similar bootloaders.
This I do not agree with. If the intent is to generate two images, then there should be two full binman descriptors, one for each image (one for flash-plain.bin and one for flash-fspi.bin or some such naming).
Can you try and fix the FSPI generation first, so an FSPI compatible
I am not a python programmer, and I couldn't determine what was going on.
flash.bin can be generated using binman only, without the dependency on processing non-FSPI compatible flash.bin ? I think the intention of binman was to replace all that ad-hoc pre/postprocessing of blobs.

On 11/10/24 6:21 PM, Adam Ford wrote:
On Sun, Nov 10, 2024 at 10:42 AM Marek Vasut marex@denx.de wrote:
On 11/10/24 2:15 PM, Adam Ford wrote:
On Sat, Nov 9, 2024 at 7:34 PM Marek Vasut marex@denx.de wrote:
On 11/9/24 9:06 PM, Adam Ford wrote:
When FSPI_CONF_HEADER is set, the binary needs to be built such that there is a configuration file located at 0x400 and the start of the file that would normally be flash.bin starts at 0x1000. This used to be done properly until the device tree was converted to nxp_imx8mimage.
Building these with the offsets built into the binman device tree changes impacts how the actual image is built and the locations of the various blobs aren't fetched properly and booting fails.
Fix this by building a standard image as if it were to boot from eMMC or SD, then use that image as the input for a second image
This seems like a workaround for some broken offset calculation in binman ?
This used to work until it was migrated to nxp_imx8mimage. The blobs appear to be at the proper offsets, but the contents of what's stored at those offsets are not the same.
I know, this is what Lukasz reported too.
If you're going to claim there is a bug somewhere, I would argue that it's somewhere i nxp_imx8mimage
I agree with that claim. Well, by extension, the problem might also be in binman itself.
. However, if you look at this series, the added benefit is the ability for Nano to be able to build both a SD/eMMC image and FSPI images with one config which allows for the elimination of extra defconfig files. I am guessing Plus would have a similar benefit since they have similar bootloaders.
This I do not agree with. If the intent is to generate two images, then there should be two full binman descriptors, one for each image (one for flash-plain.bin and one for flash-fspi.bin or some such naming).
Can you try and fix the FSPI generation first, so an FSPI compatible
I am not a python programmer, and I couldn't determine what was going on.
I am hoping Simon could offer some input here ...
Can you try the attached diff on MX8MM (use "git show -w" to view the diff better) ? It will generate two files, flash.bin and flash-fspi.bin , the later should have the fspi header and maybe even correct offsets?
Applies on top of 56accc56b9aa ("bios_emulator: fix first argument of pci_{read,write}_config_* function calls") .
I noticed that there is some dependency issue where fspi_header.bin may not be generated yet when binman is triggered -- that needs to be fixed. You can detect the failure by running 'hexdump -C flash-fspi.bin | head' , if there is no FCFB header then this failure occurred. The easiest way to work around this is to run 'rm flash.bin ; make flash.bin'. The real fix is likely a matter of some Makefile tweak.

On Sun, Nov 10, 2024 at 6:49 PM Marek Vasut marex@denx.de wrote:
On 11/10/24 6:21 PM, Adam Ford wrote:
On Sun, Nov 10, 2024 at 10:42 AM Marek Vasut marex@denx.de wrote:
On 11/10/24 2:15 PM, Adam Ford wrote:
On Sat, Nov 9, 2024 at 7:34 PM Marek Vasut marex@denx.de wrote:
On 11/9/24 9:06 PM, Adam Ford wrote:
When FSPI_CONF_HEADER is set, the binary needs to be built such that there is a configuration file located at 0x400 and the start of the file that would normally be flash.bin starts at 0x1000. This used to be done properly until the device tree was converted to nxp_imx8mimage.
Building these with the offsets built into the binman device tree changes impacts how the actual image is built and the locations of the various blobs aren't fetched properly and booting fails.
Fix this by building a standard image as if it were to boot from eMMC or SD, then use that image as the input for a second image
This seems like a workaround for some broken offset calculation in binman ?
This used to work until it was migrated to nxp_imx8mimage. The blobs appear to be at the proper offsets, but the contents of what's stored at those offsets are not the same.
I know, this is what Lukasz reported too.
If you're going to claim there is a bug somewhere, I would argue that it's somewhere i nxp_imx8mimage
I agree with that claim. Well, by extension, the problem might also be in binman itself.
. However, if you look at this series, the added benefit is the ability for Nano to be able to build both a SD/eMMC image and FSPI images with one config which allows for the elimination of extra defconfig files. I am guessing Plus would have a similar benefit since they have similar bootloaders.
This I do not agree with. If the intent is to generate two images, then there should be two full binman descriptors, one for each image (one for flash-plain.bin and one for flash-fspi.bin or some such naming).
Can you try and fix the FSPI generation first, so an FSPI compatible
I am not a python programmer, and I couldn't determine what was going on.
I am hoping Simon could offer some input here ...
Can you try the attached diff on MX8MM (use "git show -w" to view the diff better) ? It will generate two files, flash.bin and flash-fspi.bin , the later should have the fspi header and maybe even correct offsets?
I reset my branch to to U-Boot master from wedneday a7a96a37cbd8 "Merge https://source.denx.de/u-boot/custodians/u-boot-riscv")
I verified the FCFB header is present. Unfortunately, when I burn the FSPI on my 8MM and attempt to boot, nothing happens.
However, I changed the "nxp,boot-from" parameter to "fspi" and it booted!
U-Boot SPL 2025.01-rc1-00168-ga7a96a37cbd8-dirty (Nov 10 2024 - 19:27:21 -0600) WDT: Started watchdog@30280000 with servicing every 1000ms (60s timeout) SEC0: RNG instantiated Trying to boot from NOR <snip>
I looked at your patch, and noticed your FIXME. Once we get the code working, we'll likely need a way to pass the header offset, because it's different between Mini (0x0) and Nano / Plus (0x400).
I'd like to suggest we #iifndef the section filename where "flash.bin" currently sits, and remove it if we are building for flexspi. This way we get what you originally requested, which is a single binary. I have attached my diff file, so you can see my proposal. I am happy to test either Mini or Nano, but I am traveling this week starting Wednesday afternoon (US Central time) until Sunday night, so I won't be able to test in that window.
Let me know how/if you want to proceed.
Thanks for looking into this.
adam
Applies on top of 56accc56b9aa ("bios_emulator: fix first argument of pci_{read,write}_config_* function calls") .
I noticed that there is some dependency issue where fspi_header.bin may not be generated yet when binman is triggered -- that needs to be fixed. You can detect the failure by running 'hexdump -C flash-fspi.bin | head' , if there is no FCFB header then this failure occurred. The easiest way to work around this is to run 'rm flash.bin ; make flash.bin'. The real fix is likely a matter of some Makefile tweak.

On 11/11/24 2:46 AM, Adam Ford wrote:
[...]
I am hoping Simon could offer some input here ...
Can you try the attached diff on MX8MM (use "git show -w" to view the diff better) ? It will generate two files, flash.bin and flash-fspi.bin , the later should have the fspi header and maybe even correct offsets?
I reset my branch to to U-Boot master from wedneday a7a96a37cbd8 "Merge https://source.denx.de/u-boot/custodians/u-boot-riscv")
I verified the FCFB header is present. Unfortunately, when I burn the FSPI on my 8MM and attempt to boot, nothing happens.
However, I changed the "nxp,boot-from" parameter to "fspi" and it booted!
Uh oh, look at tools/imx8mimage.c and search for both 'fspi' and 'CONFIG_FSPI_CONF_HEADER' . I have a feeling that building with the CONFIG_FSPI_CONF_HEADER changes mkimage -T imx8mimage behavior, which may even interfere with binman.
Can you try and remove all the CONFIG_FSPI_CONF_HEADER stuff from imx8mimage.c , so it doesn't accidentally generate FSPI header, but keeps the fspi 0x1000 offset ?
U-Boot SPL 2025.01-rc1-00168-ga7a96a37cbd8-dirty (Nov 10 2024 - 19:27:21 -0600) WDT: Started watchdog@30280000 with servicing every 1000ms (60s timeout) SEC0: RNG instantiated Trying to boot from NOR
<snip>
I looked at your patch, and noticed your FIXME. Once we get the code working, we'll likely need a way to pass the header offset, because it's different between Mini (0x0) and Nano / Plus (0x400).
Try and add offset=<0x400> into fspi_conf_block {} for MX8MN/MP .
I'd like to suggest we #iifndef the section filename where "flash.bin" currently sits, and remove it if we are building for flexspi. This way we get what you originally requested, which is a single binary.
I was hoping we would be able to generate both SD capable and FSPI capable boot blob at the same time, maybe we can even do it with one binman description.
I have attached my diff file, so you can see my proposal. I am happy to test either Mini or Nano, but I am traveling this week starting Wednesday afternoon (US Central time) until Sunday night, so I won't be able to test in that window.
No worries
Let me know how/if you want to proceed.
I suspect a patch to imx8mimage.c to remove the fspi stuff would be good, and then DT changes are also fine. I am not sure about the python part though.
Thanks for looking into this.
You're welcome
[...]

The binman device tree can generate both the FSPI version and the SD/eMMC binaries at the same time. Since the imx8mn_beacon board supports the FSPI booting, enable the config option.
Signed-off-by: Adam Ford aford173@gmail.com --- configs/imx8mn_beacon_defconfig | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/configs/imx8mn_beacon_defconfig b/configs/imx8mn_beacon_defconfig index aa8341226a..6f66d3e748 100644 --- a/configs/imx8mn_beacon_defconfig +++ b/configs/imx8mn_beacon_defconfig @@ -149,3 +149,5 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5 CONFIG_CI_UDC=y # CONFIG_WATCHDOG_AUTOSTART is not set CONFIG_IMX_WATCHDOG=y +CONFIG_FSPI_CONF_HEADER=y +CONFIG_FSPI_CONF_FILE="fspi_header.bin"

Since the binman device tree can build both SD and eMMC binaries, and the FSP_CONF_HEADER is now present in the imx8mn_beacon_defconfig, imx8mn_beacon_fspi_defconfig is unnecessary.
Signed-off-by: Adam Ford aford173@gmail.com --- configs/imx8mn_beacon_fspi_defconfig | 152 --------------------------- 1 file changed, 152 deletions(-) delete mode 100644 configs/imx8mn_beacon_fspi_defconfig
diff --git a/configs/imx8mn_beacon_fspi_defconfig b/configs/imx8mn_beacon_fspi_defconfig deleted file mode 100644 index 3a92f0ba3b..0000000000 --- a/configs/imx8mn_beacon_fspi_defconfig +++ /dev/null @@ -1,152 +0,0 @@ -CONFIG_ARM=y -CONFIG_ARCH_IMX8M=y -CONFIG_TEXT_BASE=0x40200000 -CONFIG_SYS_MALLOC_LEN=0x2000000 -CONFIG_SPL_GPIO=y -CONFIG_SPL_LIBCOMMON_SUPPORT=y -CONFIG_SPL_LIBGENERIC_SUPPORT=y -CONFIG_NR_DRAM_BANKS=1 -CONFIG_ENV_SOURCE_FILE="imx8mn_beacon" -CONFIG_SF_DEFAULT_SPEED=40000000 -CONFIG_ENV_SIZE=0x2000 -CONFIG_ENV_OFFSET=0xFFFFDE00 -CONFIG_DM_GPIO=y -CONFIG_DEFAULT_DEVICE_TREE="freescale/imx8mn-beacon-kit" -CONFIG_SPL_TEXT_BASE=0x912000 -CONFIG_TARGET_IMX8MN_BEACON=y -CONFIG_OF_LIBFDT_OVERLAY=y -CONFIG_DM_RESET=y -CONFIG_SYS_MONITOR_LEN=524288 -CONFIG_SPL_SERIAL=y -CONFIG_SPL_DRIVERS_MISC=y -CONFIG_SPL_STACK=0x980000 -CONFIG_SPL_HAS_BSS_LINKER_SECTION=y -CONFIG_SPL_BSS_START_ADDR=0x950000 -CONFIG_SPL_BSS_MAX_SIZE=0x2000 -CONFIG_SYS_BOOTM_LEN=0x800000 -CONFIG_SYS_LOAD_ADDR=0x42000000 -CONFIG_SPL=y -CONFIG_SPL_IMX_ROMAPI_LOADADDR=0x48000000 -CONFIG_SYS_MEMTEST_START=0x40000000 -CONFIG_SYS_MEMTEST_END=0x44000000 -CONFIG_REMAKE_ELF=y -CONFIG_FIT=y -CONFIG_FIT_EXTERNAL_OFFSET=0x3000 -CONFIG_SPL_LOAD_FIT=y -CONFIG_OF_SYSTEM_SETUP=y -CONFIG_USE_BOOTCOMMAND=y -CONFIG_BOOTCOMMAND="mmc dev ${mmcdev}; if mmc rescan; then if run loadbootscript; then run bootscript; else if run loadimage; then run mmcboot; else run netboot; fi; fi; else booti ${loadaddr} - ${fdt_addr}; fi" -CONFIG_DEFAULT_FDT_FILE="imx8mn-beacon-kit.dtb" -CONFIG_SYS_CBSIZE=2048 -CONFIG_SYS_PBSIZE=2074 -CONFIG_SPL_MAX_SIZE=0x25000 -CONFIG_SPL_BOARD_INIT=y -CONFIG_SPL_BOOTROM_SUPPORT=y -# CONFIG_SPL_SHARES_INIT_SP_ADDR is not set -CONFIG_SPL_SYS_MALLOC=y -CONFIG_SPL_HAS_CUSTOM_MALLOC_START=y -CONFIG_SPL_CUSTOM_SYS_MALLOC_ADDR=0x42200000 -CONFIG_SPL_SYS_MALLOC_SIZE=0x80000 -CONFIG_SPL_SYS_MMCSD_RAW_MODE=y -CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x300 -CONFIG_SPL_I2C=y -CONFIG_SPL_POWER=y -CONFIG_SPL_WATCHDOG=y -CONFIG_HUSH_PARSER=y -CONFIG_SYS_PROMPT="u-boot=> " -# CONFIG_BOOTM_NETBSD is not set -# CONFIG_CMD_EXPORTENV is not set -# CONFIG_CMD_IMPORTENV is not set -CONFIG_CMD_ERASEENV=y -# CONFIG_CMD_CRC32 is not set -CONFIG_CMD_MEMTEST=y -CONFIG_CMD_CLK=y -CONFIG_CMD_FUSE=y -CONFIG_CMD_GPIO=y -CONFIG_CMD_I2C=y -CONFIG_CMD_MMC=y -CONFIG_CMD_PART=y -CONFIG_CMD_SPI=y -CONFIG_CMD_DHCP=y -CONFIG_CMD_MII=y -CONFIG_CMD_PING=y -CONFIG_CMD_CACHE=y -CONFIG_CMD_REGULATOR=y -CONFIG_CMD_EXT2=y -CONFIG_CMD_EXT4=y -CONFIG_CMD_EXT4_WRITE=y -CONFIG_CMD_FAT=y -CONFIG_OF_CONTROL=y -CONFIG_SPL_OF_CONTROL=y -CONFIG_ENV_OVERWRITE=y -CONFIG_ENV_IS_NOWHERE=y -CONFIG_ENV_IS_IN_MMC=y -CONFIG_SYS_RELOC_GD_ENV_ADDR=y -CONFIG_SYS_MMC_ENV_DEV=2 -CONFIG_SYS_MMC_ENV_PART=2 -CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y -CONFIG_USE_ETHPRIME=y -CONFIG_ETHPRIME="FEC" -CONFIG_NET_RANDOM_ETHADDR=y -CONFIG_SPL_DM=y -CONFIG_REGMAP=y -CONFIG_SYSCON=y -CONFIG_SPL_CLK_IMX8MN=y -CONFIG_CLK_IMX8MN=y -CONFIG_USB_FUNCTION_FASTBOOT=y -CONFIG_FASTBOOT_BUF_ADDR=0x42800000 -CONFIG_FASTBOOT_BUF_SIZE=0x40000000 -CONFIG_FASTBOOT_FLASH=y -CONFIG_FASTBOOT_FLASH_MMC_DEV=0 -CONFIG_MXC_GPIO=y -CONFIG_DM_PCA953X=y -CONFIG_DM_I2C=y -CONFIG_SUPPORT_EMMC_BOOT=y -CONFIG_MMC_IO_VOLTAGE=y -CONFIG_MMC_UHS_SUPPORT=y -CONFIG_MMC_HS400_ES_SUPPORT=y -CONFIG_MMC_HS400_SUPPORT=y -CONFIG_FSL_USDHC=y -CONFIG_MTD=y -CONFIG_DM_MTD=y -CONFIG_DM_SPI_FLASH=y -CONFIG_SPI_FLASH_BAR=y -CONFIG_SPI_FLASH_STMICRO=y -CONFIG_SPI_FLASH_MTD=y -CONFIG_PHYLIB=y -CONFIG_PHY_ATHEROS=y -CONFIG_PHY_GIGE=y -CONFIG_FEC_MXC=y -CONFIG_MII=y -CONFIG_PINCTRL=y -CONFIG_SPL_PINCTRL=y -CONFIG_PINCTRL_IMX8M=y -CONFIG_DM_PMIC=y -# CONFIG_SPL_PMIC_CHILDREN is not set -CONFIG_DM_PMIC_BD71837=y -CONFIG_SPL_DM_PMIC_BD71837=y -CONFIG_DM_REGULATOR=y -CONFIG_DM_REGULATOR_BD71837=y -CONFIG_DM_REGULATOR_FIXED=y -CONFIG_DM_REGULATOR_GPIO=y -CONFIG_DM_SERIAL=y -CONFIG_MXC_UART=y -CONFIG_SPI=y -CONFIG_DM_SPI=y -CONFIG_NXP_FSPI=y -CONFIG_SYSRESET=y -CONFIG_SPL_SYSRESET=y -CONFIG_SYSRESET_PSCI=y -CONFIG_SYSRESET_WATCHDOG=y -CONFIG_DM_THERMAL=y -CONFIG_USB=y -# CONFIG_SPL_DM_USB is not set -CONFIG_USB_EHCI_HCD=y -CONFIG_USB_GADGET=y -CONFIG_USB_GADGET_MANUFACTURER="FSL" -CONFIG_USB_GADGET_VENDOR_NUM=0x0525 -CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5 -CONFIG_CI_UDC=y -CONFIG_IMX_WATCHDOG=y -CONFIG_FSPI_CONF_HEADER=y -CONFIG_FSPI_CONF_FILE="fspi_header.bin"

When FSPI_CONF_HEADER is set, the binary needs to be built such that there is a configuration file prepended at location 0. The start of the file that would normally be flash.bin starts at 0x1000. This used to be done properly until the device tree was converted to nxp_imx8mimage.
Building these with the offsets built into the binman device tree changes impacts how the actual image is built and the locations of the various blobs aren't fetched properly and booting fails.
Fix this by building flash.bin as if the prepended header did not exist, then assemble a second file called flexspi.bin which has the contents of flash.bin starting at address 0x1000 with the FSPI header at address 0. Unlike Nano, which has a different rev of the boot ROM, the "nxp,boot-from" parameter needs to be set to fspi instead of sd.
Fixes: 37e50627efac ("ARM: dts: imx: Convert i.MX8M flash.bin image generation to binman") Signed-off-by: Adam Ford aford173@gmail.com --- arch/arm/dts/imx8mm-u-boot.dtsi | 259 +++++++++++++++++--------------- 1 file changed, 135 insertions(+), 124 deletions(-)
diff --git a/arch/arm/dts/imx8mm-u-boot.dtsi b/arch/arm/dts/imx8mm-u-boot.dtsi index d31bc82253..83593026b0 100644 --- a/arch/arm/dts/imx8mm-u-boot.dtsi +++ b/arch/arm/dts/imx8mm-u-boot.dtsi @@ -42,165 +42,176 @@ };
&binman { - filename = "flash.bin"; - section { - pad-byte = <0x00>; + multiple-images;
-#ifdef CONFIG_FSPI_CONF_HEADER - fspi_conf_block { - filename = CONFIG_FSPI_CONF_FILE; - type = "blob-ext"; - size = <0x1000>; - }; -#endif + standard_image: image1 { + filename = "flash.bin"; + section { + pad-byte = <0x00>;
#ifdef CONFIG_IMX_HAB - nxp-imx8mcst@0 { - filename = "u-boot-spl-mkimage.signed.bin"; - nxp,loader-address = <CONFIG_SPL_TEXT_BASE>; - nxp,unlock; - args; /* Needed by mkimage etype superclass */ -#endif - - binman_imx_spl: nxp-imx8mimage { - filename = "u-boot-spl-mkimage.bin"; - nxp,boot-from = "sd"; - nxp,rom-version = <1>; + nxp-imx8mcst@0 { + filename = "u-boot-spl-mkimage.signed.bin"; nxp,loader-address = <CONFIG_SPL_TEXT_BASE>; + nxp,unlock; args; /* Needed by mkimage etype superclass */ +#endif
- section { - align = <4>; - align-size = <4>; - filename = "u-boot-spl-ddr.bin"; - pad-byte = <0xff>; - - u-boot-spl { - align-end = <4>; - filename = "u-boot-spl.bin"; - }; + binman_imx_spl: nxp-imx8mimage { + filename = "u-boot-spl-mkimage.bin"; +#ifdef CONFIG_FSPI_CONF_HEADER + nxp,boot-from = "fspi"; +#else + nxp,boot-from = "sd"; +#endif + nxp,rom-version = <1>; + nxp,loader-address = <CONFIG_SPL_TEXT_BASE>; + args; /* Needed by mkimage etype superclass */ + + section { + align = <4>; + align-size = <4>; + filename = "u-boot-spl-ddr.bin"; + pad-byte = <0xff>; + + u-boot-spl { + align-end = <4>; + filename = "u-boot-spl.bin"; + };
- ddr-1d-imem-fw { - filename = "lpddr4_pmu_train_1d_imem.bin"; - align-end = <4>; - type = "blob-ext"; - }; + ddr-1d-imem-fw { + filename = "lpddr4_pmu_train_1d_imem.bin"; + align-end = <4>; + type = "blob-ext"; + };
- ddr-1d-dmem-fw { - filename = "lpddr4_pmu_train_1d_dmem.bin"; - align-end = <4>; - type = "blob-ext"; - }; + ddr-1d-dmem-fw { + filename = "lpddr4_pmu_train_1d_dmem.bin"; + align-end = <4>; + type = "blob-ext"; + };
- ddr-2d-imem-fw { - filename = "lpddr4_pmu_train_2d_imem.bin"; - align-end = <4>; - type = "blob-ext"; - }; + ddr-2d-imem-fw { + filename = "lpddr4_pmu_train_2d_imem.bin"; + align-end = <4>; + type = "blob-ext"; + };
- ddr-2d-dmem-fw { - filename = "lpddr4_pmu_train_2d_dmem.bin"; - align-end = <4>; - type = "blob-ext"; + ddr-2d-dmem-fw { + filename = "lpddr4_pmu_train_2d_dmem.bin"; + align-end = <4>; + type = "blob-ext"; + }; }; }; - }; #ifdef CONFIG_IMX_HAB - }; - - nxp-imx8mcst@1 { - filename = "u-boot-fit.signed.bin"; - nxp,loader-address = <CONFIG_SPL_LOAD_FIT_ADDRESS>; -#ifdef CONFIG_FSPI_CONF_HEADER - offset = <0x58C00>; -#else - offset = <0x57c00>; -#endif - - args; /* Needed by mkimage etype superclass */ -#endif + };
- binman_imx_fit: fit { - description = "Configuration to load ATF before U-Boot"; - filename = "u-boot.itb"; -#ifndef CONFIG_IMX_HAB - fit,external-offset = <CONFIG_FIT_EXTERNAL_OFFSET>; -#endif - fit,fdt-list = "of-list"; - #address-cells = <1>; -#ifdef CONFIG_FSPI_CONF_HEADER - offset = <0x58C00>; -#else + nxp-imx8mcst@1 { + filename = "u-boot-fit.signed.bin"; + nxp,loader-address = <CONFIG_SPL_LOAD_FIT_ADDRESS>; offset = <0x57c00>; + args; /* Needed by mkimage etype superclass */ #endif - - images { - uboot { - arch = "arm64"; - compression = "none"; - description = "U-Boot (64-bit)"; - load = <CONFIG_TEXT_BASE>; - type = "standalone"; - - uboot-blob { - filename = "u-boot-nodtb.bin"; - type = "blob-ext"; + binman_imx_fit: fit { + description = "Configuration to load ATF before U-Boot"; + filename = "u-boot.itb"; +#ifndef CONFIG_IMX_HAB + fit,external-offset = <CONFIG_FIT_EXTERNAL_OFFSET>; + #endif + fit,fdt-list = "of-list"; + #address-cells = <1>; + offset = <0x57c00>; + + images { + uboot { + arch = "arm64"; + compression = "none"; + description = "U-Boot (64-bit)"; + load = <CONFIG_TEXT_BASE>; + type = "standalone"; + + uboot-blob { + filename = "u-boot-nodtb.bin"; + type = "blob-ext"; + }; }; - };
#ifndef CONFIG_ARMV8_PSCI - atf { - arch = "arm64"; - compression = "none"; - description = "ARM Trusted Firmware"; - entry = <0x920000>; - load = <0x920000>; - type = "firmware"; - - atf-blob { - filename = "bl31.bin"; - type = "atf-bl31"; + atf { + arch = "arm64"; + compression = "none"; + description = "ARM Trusted Firmware"; + entry = <0x920000>; + load = <0x920000>; + type = "firmware"; + + atf-blob { + filename = "bl31.bin"; + type = "atf-bl31"; + }; }; - }; #endif
- binman_fip: fip { - arch = "arm64"; - compression = "none"; - description = "Trusted Firmware FIP"; - load = <0x40310000>; - type = "firmware"; - }; + binman_fip: fip { + arch = "arm64"; + compression = "none"; + description = "Trusted Firmware FIP"; + load = <0x40310000>; + type = "firmware"; + };
- @fdt-SEQ { - compression = "none"; - description = "NAME"; - type = "flat_dt"; + @fdt-SEQ { + compression = "none"; + description = "NAME"; + type = "flat_dt";
- uboot-fdt-blob { - filename = "u-boot.dtb"; - type = "blob-ext"; + uboot-fdt-blob { + filename = "u-boot.dtb"; + type = "blob-ext"; + }; }; }; - };
- configurations { - default = "@config-DEFAULT-SEQ"; + configurations { + default = "@config-DEFAULT-SEQ";
- @config-SEQ { - description = "NAME"; - fdt = "fdt-SEQ"; - firmware = "uboot"; + @config-SEQ { + description = "NAME"; + fdt = "fdt-SEQ"; + firmware = "uboot"; #ifndef CONFIG_ARMV8_PSCI - loadables = "atf"; + loadables = "atf"; #endif + }; }; }; - }; #ifdef CONFIG_IMX_HAB - }; + }; #endif + }; }; + +#ifdef CONFIG_FSPI_CONF_HEADER + flexspi_image: image2 { + filename = "flexspi.bin"; + section { + pad-byte = <0x00>; + + fspi_conf_block { + filename = CONFIG_FSPI_CONF_FILE; + type = "blob-ext"; + }; + + flashbin { + filename = "flash.bin"; + type = "blob-ext"; + offset = <0x1000>; + }; + }; + + }; +#endif };
&clk {
participants (2)
-
Adam Ford
-
Marek Vasut