Skip to contentSkip to conversation

imx: imxrt1050-evk: Add support for SPI flash booting

PATCH In review Jesse Taube 3 participants 7 messages Feb 19, 2024 – Feb 24, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/2 imx: imxrt1050-evk: Add support for SPI flash booting

Add support for booting the imxrt1050-evk from spi.
Add imximage config and the ability for SPL to boot from NOR. Enable binman in Kconfig and device tree for imxrt* as it is used to prepend fspi_header.bin to SPL and u-boot.img.

---
V1 -> V2:
- Add defconfig to MAINTAINERS
- Change Copyright of imximage-nor.cfg to myself
- Fix spelling and grammar
- Use imperative mood
V2 -> V3:
- Enabled binman for imxrt*
V3 -> V4:
- Mention binman in commit description
- Squash enabled binman and this commit

---
 arch/arm/dts/imxrt1020-evk-u-boot.dtsi        |   4 +
 arch/arm/dts/imxrt1050-evk-u-boot.dtsi        |  31 ++++++
 arch/arm/dts/imxrt1170-evk-u-boot.dtsi        |   4 +
 arch/arm/mach-imx/imxrt/Kconfig               |   1 +
 board/freescale/imxrt1050-evk/MAINTAINERS     |   1 +
 .../freescale/imxrt1050-evk/imximage-nor.cfg  |  42 ++++++++
 board/freescale/imxrt1050-evk/imximage.cfg    |  10 +-
 board/freescale/imxrt1050-evk/imxrt1050-evk.c |   7 +-
 configs/imxrt1050-evk_defconfig               |   8 +-
 configs/imxrt1050-evk_fspi_defconfig          | 100 ++++++++++++++++++
 include/configs/imxrt1050-evk.h               |   6 ++
 11 files changed, 208 insertions(+), 6 deletions(-)
 create mode 100644 board/freescale/imxrt1050-evk/imximage-nor.cfg
 create mode 100644 configs/imxrt1050-evk_fspi_defconfig
arch/arm/dts/imxrt1020-evk-u-boot.dtsi +4 -0
index 46928c07e9..e246de0299 100644
@@ -5,6 +5,10 @@
  */
 
 / {
+	binman: binman {
+		multiple-images;
+	};
+
 	chosen {
 		bootph-pre-ram;
 	};
arch/arm/dts/imxrt1050-evk-u-boot.dtsi +31 -0
index a9095e736b..3f54411b7b 100644
@@ -8,6 +8,10 @@
 #include "imxrt1050-pinfunc.h"
 
 / {
+	binman: binman {
+		multiple-images;
+	};
+
 	aliases {
 		display0 = &lcdif;
 		usbphy0 = &usbphy1;
@@ -113,6 +117,33 @@
 	};
 };
 
+&binman {
+#ifdef CONFIG_FSPI_CONF_HEADER
+	imx-boot {
+		filename = "flash.bin";
+		pad-byte = <0x00>;
+
+		fspi_conf_block {
+			filename = CONFIG_FSPI_CONF_FILE;
+			type = "blob-ext";
+			offset = <0x0>;
+		};
+
+		spl {
+			filename = "SPL";
+			offset = <0x1000>;
+			type = "blob-ext";
+		};
+
+		binman_uboot: uboot {
+			filename = "u-boot.img";
+			offset = <0x10000>;
+			type = "blob-ext";
+		};
+	};
+#endif
+};
+
 &osc {
 	bootph-pre-ram;
 };
arch/arm/dts/imxrt1170-evk-u-boot.dtsi +4 -0
index f923a14301..6e892c1af7 100644
@@ -6,6 +6,10 @@
  */
 
 / {
+	binman: binman {
+		multiple-images;
+	};
+
 	chosen {
 		bootph-pre-ram;
 	};
arch/arm/mach-imx/imxrt/Kconfig +1 -0
index c1d6b09e77..ccccf702f6 100644
@@ -2,6 +2,7 @@ if ARCH_IMXRT
 
 config IMXRT
 	bool
+	select BINMAN
 	select SYS_FSL_ERRATUM_ESDHC135
 
 config IMXRT1020
board/freescale/imxrt1050-evk/MAINTAINERS +1 -0
index a872855452..890825b39a 100644
@@ -4,3 +4,4 @@ S:	Maintained
 F:	board/freescale/imxrt1050-evk
 F:	include/configs/imxrt1050-evk.h
 F:	configs/imxrt1050-evk_defconfig
+F:	configs/imxrt1050-evk_fspi_defconfig
board/freescale/imxrt1050-evk/imximage-nor.cfg new file +42 -0

42 lines not on this page · raw message

board/freescale/imxrt1050-evk/imximage.cfg +8 -2
index f1f09fd7eb..b30d852194 100644
@@ -29,7 +29,13 @@ BOOT_FROM	sd
  *	value	  value to be stored in the register
  */
 
-/* Set all FlexRAM as OCRAM(01b) */
-DATA 4 0x400AC044 0x55555555
+/*
+ * 0x400AC044 is used to configure the flexram.
+ * Unfortunately setting all to OCRAM only works for MMC
+ * and setting all to DTCM only works for FLEXSPI NOR.
+ * This configuration fortunately works for both SPI and MMC.
+*/
+/* Set first two banks FlexRAM as OCRAM(01b) and the rest to DTCM(10b) */
+DATA 4 0x400AC044 0x55aaaaaa
 /* Use FLEXRAM_BANK_CFG to config FlexRAM */
 SET_BIT 4 0x400AC040 0x4
board/freescale/imxrt1050-evk/imxrt1050-evk.c +6 -1
index 4b82ee5e9c..4cc3defc88 100644
@@ -68,7 +68,12 @@ void spl_board_init(void)
 
 u32 spl_boot_device(void)
 {
-	return BOOT_DEVICE_MMC1;
+	/* There is no way to find the boot device so look if there is a valid IVT in RAM for MMC */
+	u32 nor_ivt = *(u32 *)(CONFIG_SYS_LOAD_ADDR - 0xC00);
+
+	if (nor_ivt == 0x402000d1)
+		return BOOT_DEVICE_MMC1;
+	return BOOT_DEVICE_NOR;
 }
 #endif
 
configs/imxrt1050-evk_defconfig +5 -3
index 8b5ce4e735..086fc47ec2 100644
@@ -10,21 +10,22 @@ CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x20280000
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x20020000
 CONFIG_ENV_OFFSET=0x80000
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imxrt1050-evk"
-CONFIG_SPL_TEXT_BASE=0x20209000
+CONFIG_SPL_TEXT_BASE=0x20002000
 CONFIG_TARGET_IMXRT1050_EVK=y
 CONFIG_SPL_MMC=y
 CONFIG_SPL_SERIAL=y
 CONFIG_SPL_SIZE_LIMIT=0x20000
 CONFIG_SPL=y
-CONFIG_SYS_LOAD_ADDR=0x20209000
+CONFIG_SYS_LOAD_ADDR=0x20002000
 CONFIG_HAVE_SYS_UBOOT_START=y
 CONFIG_SYS_UBOOT_START=0x800023FD
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_SD_BOOT=y
+CONFIG_SPI_BOOT=y
 # CONFIG_USE_BOOTCOMMAND is not set
 CONFIG_SYS_CBSIZE=256
 CONFIG_SYS_PBSIZE=276
@@ -36,6 +37,7 @@ CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x100
+CONFIG_SPL_NOR_SUPPORT=y
 # CONFIG_BOOTM_NETBSD is not set
 # CONFIG_BOOTM_PLAN9 is not set
 # CONFIG_BOOTM_RTEMS is not set
configs/imxrt1050-evk_fspi_defconfig new file +100 -0

100 lines not on this page · raw message

include/configs/imxrt1050-evk.h +6 -0
index 2af2dde2ae..b370e25105 100644
@@ -25,4 +25,10 @@
 		"stderr=serial,vidconsole\0"
 #endif
 
+/*
+ * Address of U-Boot for SPI NOR boot
+ */
+
+#define CFG_SYS_UBOOT_BASE			0x60010000
+
 #endif /* __IMXRT1050_EVK_H */
Signature · 1 line
2.43.0
#1 lore raw

PATCH v4 2/2 imx: imxrt1050-evk: Add documentation for SPI boot

Add documentation for SPI boot.

---
V1 -> V2:
- Change s/Adds/Add
- Change imxrt1050-evk_spi to fspi
- Fix spelling and grammar
- Mention the SPI NOR flash part number
V2 -> V3:
- No changes
V3 -> V4:
- No changes

---
 doc/board/nxp/imxrt1050-evk.rst | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
doc/board/nxp/imxrt1050-evk.rst +30 -0
index c1fb48f0cd..e0cafe1035 100644
@@ -39,3 +39,33 @@ switch label numbers reference).
   The USB console connector is the one close the ethernet connector
 
 - Insert the micro SD card in the board, power it up and U-Boot messages should come up.
+
+
+How to use U-Boot with SPI flash on NXP i.MXRT1050 EVK
+------------------------------------------------------
+
+- Build U-Boot for i.MXRT1050 EVK:
+
+.. code-block:: bash
+
+   $ make mrproper
+   $ make imxrt1050-evk_fspi_defconfig
+   $ make
+
+This will generate SPL, uboot.img, fspi_header.bin, and the final image (flash.bin).
+
+To boot from SPI flash on other boards, you may need to change the flash header config,
+which is specific to your flash chip, in Kconfig.
+The flash config is 4K in size and is documented on page 217 of the imxrt1050 RM.
+The default flash chip on the i.MXRT1050 EVK is the S26KS512SDPBHI02 HYPERFLASH.
+
+- Jumper settings::
+
+   SW7: 0 1 1 0
+
+where 0 means bottom position and 1 means top position (from the
+switch label numbers reference).
+
+- Connect the USB cable between the EVK and the PC for the console.
+
+- Use either JTAG or SWD to write `flash.bin` to the NOR. I used Mcuexpresso IDE's GUI flash tool.
Signature · 1 line
2.43.0
reviewer
#2 lore raw
In reply to Jesse Taube
Quoted 7 lines · Jesse Taube

Add support for booting the imxrt1050-evk from spi.
Add imximage config and the ability for SPL to boot from NOR. Enable binman in Kconfig and device tree for imxrt* as it is used to prepend fspi_header.bin to SPL and u-boot.img.

I see the following warning when applying this series:

$ git am v4-1-2-imx-imxrt1050-evk-Add-support-for-SPI-flash-booting.patch
Applying: imx: imxrt1050-evk: Add support for SPI flash booting
.git/rebase-apply/patch:175: new blank line at EOF.
+
warning: 1 line adds whitespace errors.
Applying: imx: imxrt1050-evk: Add documentation for SPI boot

checkpatch also complains:

CHECK: From:/Signed-off-by: email comments mismatch: 'From: Jesse Taube <[email protected]>' != 'Signed-off-by: Jesse Taube <[email protected]>'

author
#3 lore raw
Quoted 10 lines · Fabio Estevam
Quoted 7 lines · Jesse Taube

Add support for booting the imxrt1050-evk from spi.
Add imximage config and the ability for SPL to boot from NOR. Enable binman in Kconfig and device tree for imxrt* as it is used to prepend fspi_header.bin to SPL and u-boot.img.

Quoted 9 lines

I see the following warning when applying this series:

$ git am v4-1-2-imx-imxrt1050-evk-Add-support-for-SPI-flash-booting.patch
Applying: imx: imxrt1050-evk: Add support for SPI flash booting
.git/rebase-apply/patch:175: new blank line at EOF.
+
warning: 1 line adds whitespace errors.
Applying: imx: imxrt1050-evk: Add documentation for SPI boot

Sorry, I somehow added an extra line at the end of board/freescale/imxrt1050-evk/imximage-nor.cfg.
Do you want a v5...
or sed -i -z 's/\n\n$/\n/' board/freescale/imxrt1050-evk/imximage-nor.cfg && git commit -a --amend --no-edit

Quoted 5 lines

checkpatch also complains:

CHECK: From:/Signed-off-by: email comments mismatch: 'From: Jesse Taube <[email protected]>' != 'Signed-off-by: Jesse Taube <[email protected]>'

Huh, this is very interesting and I haven't noticed before. When sending git send-email lowercases my email. It seems like all my commits are like this.
Do you want this fixed?

reviewer
#4 lore raw
Quoted 4 lines · Jesse T

Huh, this is very interesting and I haven't noticed before. When sending git send-email lowercases my email. It seems like all my commits are like this.
Do you want this fixed?

Please fix both issues and submit a v5.

reviewer
#5 lore raw
Quoted 1 line · Fabio Estevam

Please fix both issues and submit a v5.

I have fixed these issues myself and applied it, thanks.

#6 lore raw
In reply to Jesse Taube

Hi Jesse

Quoted 186 lines · Jesse Taube

Add support for booting the imxrt1050-evk from spi.
Add imximage config and the ability for SPL to boot from NOR. Enable binman in Kconfig and device tree for imxrt* as it is used to prepend fspi_header.bin to SPL and u-boot.img.

---
V1 -> V2:
- Add defconfig to MAINTAINERS
- Change Copyright of imximage-nor.cfg to myself
- Fix spelling and grammar
- Use imperative mood
V2 -> V3:
- Enabled binman for imxrt*
V3 -> V4:
- Mention binman in commit description
- Squash enabled binman and this commit

---
  arch/arm/dts/imxrt1020-evk-u-boot.dtsi        |   4 +
  arch/arm/dts/imxrt1050-evk-u-boot.dtsi        |  31 ++++++
  arch/arm/dts/imxrt1170-evk-u-boot.dtsi        |   4 +
  arch/arm/mach-imx/imxrt/Kconfig               |   1 +
  board/freescale/imxrt1050-evk/MAINTAINERS     |   1 +
  .../freescale/imxrt1050-evk/imximage-nor.cfg  |  42 ++++++++
  board/freescale/imxrt1050-evk/imximage.cfg    |  10 +-
  board/freescale/imxrt1050-evk/imxrt1050-evk.c |   7 +-
  configs/imxrt1050-evk_defconfig               |   8 +-
  configs/imxrt1050-evk_fspi_defconfig          | 100 ++++++++++++++++++
  include/configs/imxrt1050-evk.h               |   6 ++
  11 files changed, 208 insertions(+), 6 deletions(-)

create mode 100644 board/freescale/imxrt1050-evk/imximage-nor.cfg create mode 100644 configs/imxrt1050-evk_fspi_defconfig

arch/arm/dts/imxrt1020-evk-u-boot.dtsi +4 -0
index 46928c07e9..e246de0299 100644
@@ -5,6 +5,10 @@
   */
 
  / {
+	binman: binman {
+		multiple-images;
+	};
+
  	chosen {
  		bootph-pre-ram;
  	};
arch/arm/dts/imxrt1050-evk-u-boot.dtsi +31 -0
index a9095e736b..3f54411b7b 100644
@@ -8,6 +8,10 @@
  #include "imxrt1050-pinfunc.h"
 
  / {
+	binman: binman {
+		multiple-images;
+	};
+
  	aliases {
  		display0 = &lcdif;
  		usbphy0 = &usbphy1;
@@ -113,6 +117,33 @@
  	};
  };
 
+&binman {
+#ifdef CONFIG_FSPI_CONF_HEADER
+	imx-boot {
+		filename = "flash.bin";
+		pad-byte = <0x00>;
+
+		fspi_conf_block {
+			filename = CONFIG_FSPI_CONF_FILE;
+			type = "blob-ext";
+			offset = <0x0>;
+		};
+
+		spl {
+			filename = "SPL";
+			offset = <0x1000>;
+			type = "blob-ext";
+		};
+
+		binman_uboot: uboot {
+			filename = "u-boot.img";
+			offset = <0x10000>;
+			type = "blob-ext";
+		};
+	};
+#endif
+};
+
  &osc {
  	bootph-pre-ram;
  };
arch/arm/dts/imxrt1170-evk-u-boot.dtsi +4 -0
index f923a14301..6e892c1af7 100644
@@ -6,6 +6,10 @@
   */
 
  / {
+	binman: binman {
+		multiple-images;
+	};
+
  	chosen {
  		bootph-pre-ram;
  	};
arch/arm/mach-imx/imxrt/Kconfig +1 -0
index c1d6b09e77..ccccf702f6 100644
@@ -2,6 +2,7 @@ if ARCH_IMXRT
 
  config IMXRT
  	bool
+	select BINMAN
  	select SYS_FSL_ERRATUM_ESDHC135
 
  config IMXRT1020
board/freescale/imxrt1050-evk/MAINTAINERS +1 -0
index a872855452..890825b39a 100644
@@ -4,3 +4,4 @@ S:	Maintained
  F:	board/freescale/imxrt1050-evk
  F:	include/configs/imxrt1050-evk.h
  F:	configs/imxrt1050-evk_defconfig
+F:	configs/imxrt1050-evk_fspi_defconfig
board/freescale/imxrt1050-evk/imximage-nor.cfg new file +42 -0
new file mode 100644
index 0000000000..3b80e1f178
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2024
+ * Author(s): Jesse Taube <[email protected]>
+ */
+
+#include <config.h>
+
+/* image version */
+
+IMAGE_VERSION 2
+
+/*
+ * Boot Device : one of
+ * spi/sd/nand/onenand, qspi/nor
+ */
+
+BOOT_FROM	nor
+
+/*
+ * Device Configuration Data (DCD)
+ *
+ * Each entry must have the format:
+ * Addr-type           Address        Value
+ *
+ * where:
+ *	Addr-type register length (1,2 or 4 bytes)
+ *	Address	  absolute address of the register
+ *	value	  value to be stored in the register
+ */
+
+/*
+ * 0x400AC044 is used to configure the flexram.
+ * Unfortunately setting all to OCRAM only works for MMC
+ * and setting all to DTCM only works for FLEXSPI NOR.
+ * This configuration fortunately works for both SPI and MMC.
+*/
+/* Set first two banks FlexRAM as OCRAM(01b) and the rest to DTCM(10b) */
+DATA 4 0x400AC044 0x55aaaaaa
+/* Use FLEXRAM_BANK_CFG to config FlexRAM */
+SET_BIT 4 0x400AC040 0x4
+
board/freescale/imxrt1050-evk/imximage.cfg +0 -0
index f1f09fd7eb..b30d852194 100644

board/freescale/imxrt1050-evk/imximage.cfg BOOT_FROM sd · line 30

Quoted 2 lines
board/freescale/imxrt1050-evk/imximage.cfg +0 -0
@@ -29,7 +29,13 @@ BOOT_FROM	sd
   *	value	  value to be stored in the register
   */

As a future plan do you think of moving .cfg files to within binman; you can see 'ti-board-config' entry as an example (tools/binman/etype/ti_board_config.py)

[...]

Signature · 2 lines
Thanking You
Neha Malcom Francis