Skip to contentSkip to conversation

Add support for FLexSPI Boot for i.MX8m

PATCH Superseded Mamta Shukla 1 participant 8 messages Jun 9, 2022

Subsystems (2)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add support for FLexSPI Boot for i.MX8m

This series of patch adds support for generating FlexSPI Header file and booting from QSPI on i.MX8m.

Changes in v2:
-Add check for error in case open() for fspi_fd in imx8mkimage.c fails -Remove extra line in commit message
-Remove extra line in imx8mm_evk_fspi_defconfig
-New patch in series to add an entry for imx8mm_evk_fspi_defconfig in board/freescale/imx8mm_evk/MAINTAINERS
-New patch in series to add instructions to build and boot from QSPI Flash

Mamta Shukla (7):
tools: mkimage: Add support to generate FlexSPI Header for i.MX8m
dts: imx8mm-uboot: Add support to pack FlexSPI Header using binman
configs: Add config for enabling FSPI boot option for i.MX8m
board: freescale: Add QSPI Boot support in spl for i.MX8m
configs: imx8mm: Define CONFIG_SYS_UBOOT_BASE for i.MX8m
board: freescale: Add entry for imx8mm_evk_fspi_defconfig
doc: board: nxp: Add instructions to boot from QSPI

 arch/arm/dts/imx8mm-u-boot.dtsi               |  22 +++-
 board/freescale/imx8mm_evk/MAINTAINERS        |   1 +
 .../imx8mm_evk/imximage-8mm-lpddr4-fspi.cfg   |   9 ++
 board/freescale/imx8mm_evk/spl.c              |   2 +
 configs/imx8mm_evk_fspi_defconfig             | 115 ++++++++++++++++++
 doc/board/nxp/imx8mm_evk.rst                  |  38 +++++-
 include/configs/imx8mm_evk.h                  |   7 +-
 include/imximage.h                            |  38 ++++++
 tools/Kconfig                                 |  59 +++++++++
 tools/imx8mimage.c                            |  81 +++++++++++-
 10 files changed, 364 insertions(+), 8 deletions(-)
 create mode 100644 board/freescale/imx8mm_evk/imximage-8mm-lpddr4-fspi.cfg
 create mode 100644 configs/imx8mm_evk_fspi_defconfig
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/7 tools: mkimage: Add support to generate FlexSPI Header for i.MX8m

Add struct with Flex SPI Configuration Block and enable generating fspi header using mkimage.

Refer i.MX 8M Mini Application Processor Reference Manual for detailed information about parameters for FlexSPI Configuration block.

---
v2:
-Add check for error in case open() for fspi_fd in imx8mkimage.c fails

 include/imximage.h | 38 ++++++++++++++++++++++
 tools/Kconfig      | 59 +++++++++++++++++++++++++++++++++
 tools/imx8mimage.c | 81 +++++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 174 insertions(+), 4 deletions(-)
include/imximage.h +38 -0
index 5a812f5a10..c1ecc0b7cb 100644
@@ -201,6 +201,44 @@ struct imx_header {
 	} header;
 };
 
+typedef struct {
+	uint8_t tag[4];
+	uint8_t version[4];
+	uint8_t reserved_1[4];
+	uint8_t read_sample;
+	uint8_t datahold;
+	uint8_t datasetup;
+	uint8_t coladdrwidth;
+	uint8_t devcfgenable;
+	uint8_t reserved_2[3];
+	uint8_t devmodeseq[4];
+	uint8_t devmodearg[4];
+	uint8_t cmd_enable;
+	uint8_t reserved_3[3];
+	uint8_t cmd_seq[16] ;
+	uint8_t cmd_arg[16];
+	uint8_t controllermisc[4];
+	uint8_t dev_type;
+	uint8_t sflash_pad;
+	uint8_t serial_clk;
+	uint8_t lut_custom ;
+	uint8_t reserved_4[8];
+	uint8_t sflashA1[4];
+	uint8_t sflashA2[4];
+	uint8_t sflashB1[4];
+	uint8_t sflashB2[4];
+	uint8_t cspadover[4];
+	uint8_t sclkpadover[4];
+	uint8_t datapadover[4];
+	uint8_t dqspadover[4];
+	uint8_t timeout[4];
+	uint8_t commandInt[4];
+	uint8_t datavalid[4];
+	uint8_t busyoffset[2];
+	uint8_t busybitpolarity[2];
+	uint8_t lut[256];
+} __attribute__((packed)) fspi_conf;
+
 typedef void (*set_dcd_val_t)(struct imx_header *imxhdr,
 					char *name, int lineno,
 					int fld, uint32_t value,
tools/Kconfig +59 -0

63 lines not on this page · raw message

tools/imx8mimage.c +77 -4

107 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 2/7 dts: imx8mm-uboot: Add support to pack FlexSPI Header using binman

In reply to Mamta Shukla

Add definition for FSPI configuration block and subsequently new offsets for u-boot-spl and u-boot-itb for CONFIG_FSPI_HEADER option.

---
(no changes since v1)

 arch/arm/dts/imx8mm-u-boot.dtsi | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
arch/arm/dts/imx8mm-u-boot.dtsi +21 -1
index 9f66cdb65a..178f974f70 100644
@@ -150,7 +150,26 @@
 		filename = "flash.bin";
 		pad-byte = <0x00>;
 
-		spl {
+#ifdef CONFIG_FSPI_CONF_HEADER
+        fspi_conf_block {
+            filename = CONFIG_FSPI_CONF_FILE;
+            type = "blob-ext";
+            size = <0x1000>;
+        };
+
+        spl {
+            filename = "spl.bin";
+            offset = <0x1000>;
+            type = "blob-ext";
+        };
+
+        binman_uboot: uboot {
+            filename = "u-boot.itb";
+            offset = <0x58C00>;
+            type = "blob-ext";
+        };
+#else
+        spl {
 			filename = "spl.bin";
 			offset = <0x0>;
 			type = "blob-ext";
@@ -161,6 +180,7 @@
 			offset = <0x57c00>;
 			type = "blob-ext";
 		};
+#endif
 	};
 };
 
Signature · 1 line
2.25.1
#3 lore raw

PATCH v2 3/7 configs: Add config for enabling FSPI boot option for i.MX8m

In reply to Mamta Shukla

Add imx8mm_evk_fspi_defconfig to build QSPI boot image.
This config is based on imx8mm_evk_defconfig with addtional config options for FSPI Header,SPL offset and imx-image config to boot from FSPI.

---
v2:
-Remove extra line in commit message
-Remove extra line in imx8mm_evk_fspi_defconfig
-New patch in series to add an entry for imx8mm_evk_fspi_defconfig in board/freescale/imx8mm_evk/MAINTAINERS

.../imx8mm_evk/imximage-8mm-lpddr4-fspi.cfg | 9 ++

 configs/imx8mm_evk_fspi_defconfig             | 115 ++++++++++++++++++
 2 files changed, 124 insertions(+)
 create mode 100644 board/freescale/imx8mm_evk/imximage-8mm-lpddr4-fspi.cfg
 create mode 100644 configs/imx8mm_evk_fspi_defconfig
board/freescale/imx8mm_evk/imximage-8mm-lpddr4-fspi.cfg new file +9 -0
new file mode 100644
index 0000000000..ddcbd11eea
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2021 NXP
+ */
+
+#define __ASSEMBLY__
+
+BOOT_FROM	fspi
+LOADER		u-boot-spl-ddr.bin	0x7E2000
configs/imx8mm_evk_fspi_defconfig new file +115 -0

115 lines not on this page · raw message

Signature · 1 line
2.25.1
#4 lore raw

PATCH v2 4/7 board: freescale: Add QSPI Boot support in spl for i.MX8m

In reply to Mamta Shukla

Add QSPI Boot option in u-boot-spl for i.MX8m EVK.

---
(no changes since v1)

 board/freescale/imx8mm_evk/spl.c | 2 ++
 1 file changed, 2 insertions(+)
board/freescale/imx8mm_evk/spl.c +2 -0
index 4d96324685..e2eb1426c8 100644
@@ -39,6 +39,8 @@ int spl_board_boot_device(enum boot_device boot_dev_spl)
 	case SD3_BOOT:
 	case MMC3_BOOT:
 		return BOOT_DEVICE_MMC2;
+	case QSPI_BOOT:
+		return BOOT_DEVICE_NOR;
 	default:
 		return BOOT_DEVICE_NONE;
 	}
Signature · 1 line
2.25.1
#5 lore raw

PATCH v2 5/7 configs: imx8mm: Define CONFIG_SYS_UBOOT_BASE for i.MX8m

In reply to Mamta Shukla

The macro CONFIG_SYS_UBOOT_BASE is used by SPL loaders "NOR" and "XIP" to determine the base address of u-boot.

For "NOR" on i.MX8MM it is the base address of QSPI0 plus the offset of the flattened image tree blob.
Although QSPI0_AMBA_BASE is used to define CONFIG_SYS_UBOOT_BASE in multiple board header files for i.MX8MM, it is not specified.

Specify offset of flattened image tree blob (needs to be set to same value as specified in 'binman' node), base address of QSPI0 and size of FlexSPI configuration block.

---
(no changes since v1)

 include/configs/imx8mm_evk.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
include/configs/imx8mm_evk.h +6 -1
index 5e8f19c43f..1b8d6e6b9f 100644
@@ -13,8 +13,13 @@
 #define CONFIG_SYS_BOOTM_LEN		(64 * SZ_1M)
 #define CONFIG_SPL_MAX_SIZE		(148 * 1024)
 #define CONFIG_SYS_MONITOR_LEN		SZ_512K
+#define UBOOT_ITB_OFFSET 0x57C00
+#define QSPI0_AMBA_BASE			0x08000000
+#define FSPI_CONF_BLOCK_SIZE		0x1000
+#define UBOOT_ITB_OFFSET_FSPI	\
+	(UBOOT_ITB_OFFSET + FSPI_CONF_BLOCK_SIZE)
 #define CONFIG_SYS_UBOOT_BASE	\
-	(QSPI0_AMBA_BASE + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512)
+		(QSPI0_AMBA_BASE + UBOOT_ITB_OFFSET_FSPI)
 
 #ifdef CONFIG_SPL_BUILD
 #define CONFIG_SPL_STACK		0x920000
Signature · 1 line
2.25.1
#6 lore raw

PATCH v2 6/7 board: freescale: Add entry for imx8mm_evk_fspi_defconfig

In reply to Mamta Shukla

Add entry for imx8mm_evk_fspi_defconfig in
board/freescale/imx8mm_evk/MAINTAINERS

---
 board/freescale/imx8mm_evk/MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
board/freescale/imx8mm_evk/MAINTAINERS +1 -0
index b031bb0674..875adf58ee 100644
@@ -4,3 +4,4 @@ S:	Maintained
 F:	board/freescale/imx8mm_evk/
 F:	include/configs/imx8mm_evk.h
 F:	configs/imx8mm_evk_defconfig
+F:  configs/imx8mm_evk_fspi_defconfig
Signature · 1 line
2.25.1
#7 lore raw

PATCH v2 7/7 doc: board: nxp: Add instructions to boot from QSPI

In reply to Mamta Shukla

Add instructions to build and boot from QSPI Flash.

---
 doc/board/nxp/imx8mm_evk.rst | 38 ++++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)
doc/board/nxp/imx8mm_evk.rst +36 -2
index b9e67b954f..ea7153a69b 100644
@@ -35,8 +35,8 @@ Get the ddr firmware
    $ ./firmware-imx-8.9
    $ cp firmware-imx-8.9/firmware/ddr/synopsys/lpddr4*.bin $(builddir)
 
-Build U-Boot
-------------
+Build U-Boot for sd card
+--------------------------
 
 .. code-block:: bash
 
@@ -53,3 +53,37 @@ Burn the flash.bin to MicroSD card offset 33KB:
 Boot
 ----
 Set Boot switch to SD boot
+
+Build U-Boot for qspi flash  card
+------------------------------------
+
+.. code-block:: bash
+
+   $ export CROSS_COMPILE=aarch64-poky-linux-
+   $ make imx8mm_evk_fspi_defconfig
+   $ make
+
+Currently, there is no direct support to write to QSPI Flash.
+Copy flash.bin to ${loadaddr} either from sd card or over network and then copy to
+qspi flash 
+
+From sd card to memory
+
+.. code-block:: bash
+    
+    $mmc dev 1
+    $mmc read ${loadaddr} 0x00 <size_of_flash.bin/512>
+
+.. code-block:: bash
+
+   $ sf probe
+   $ sf erase 0 <size_of_flash.bin_in_hex>
+   $ sf write $loadaddr 0x00 <size_of_flash.bin_in_hex>
+   
+Boot from QSPI Flash
+-----------------------
+Set Boot Switch to QSPI Flash
+
+Pin configuration for imx8mm_revC evk to boot from qspi flash
+SW1101: 0110xxxxxx
+SW1102: 00100x0010
Signature · 1 line
2.25.1