Skip to contentSkip to conversation

imx9{4,5}: Add Quickboot support

PATCH Superseded Simona Toaca (OSS) 5 participants 15 messages Mar 10 – Mar 12

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover imx9{4,5}: Add Quickboot support

From: Simona Toaca <[email protected]>

This patch series adds support for saving DDR training data to non-volatile memory on iMX94 and iMX95 platforms. The purpose is running DDR Quickboot flow on next reboot.

The process is as follows:
- OEI runs Training flow for the DDRPHY
- OEI saves the data from training to volatile memory
- U-Boot can then save it to non-volatile memory (e.g. SD)
- OEI loads the data from NVM at cold reboot and runs Quickboot flow

By skipping training, a much lower boot time is achieved.

Simona Toaca (5):
imx9: Add support for saving DDR training data to NVM
arm: mach-imx: Add command to expose QB functionality
imx9: Enable QB data saving for iMX9{4,5} EVK
board: nxp: imx9{4,5}_evk: Add qb save option in SPL
doc: board: nxp: Add Quickboot documentation

 arch/arm/include/asm/arch-imx9/ddr.h |  52 +++-
 arch/arm/include/asm/mach-imx/qb.h   |  15 +
 arch/arm/mach-imx/Kconfig            |  15 +
 arch/arm/mach-imx/Makefile           |   1 +
 arch/arm/mach-imx/cmd_qb.c           | 132 ++++++++
 arch/arm/mach-imx/imx9/Makefile      |  12 +-
 arch/arm/mach-imx/imx9/qb.c          | 439 +++++++++++++++++++++++++++
 arch/arm/mach-imx/imx9/scmi/soc.c    |   9 +
 board/nxp/imx94_evk/spl.c            |   6 +-
 board/nxp/imx95_evk/spl.c            |   6 +-
 configs/imx943_evk_defconfig         |   1 +
 configs/imx95_15x15_evk_defconfig    |   1 +
 configs/imx95_evk.config             |   1 +
 doc/board/nxp/index.rst              |   1 +
 doc/board/nxp/qb.rst                 |  33 ++
 drivers/ddr/imx/imx9/Kconfig         |   8 +
 drivers/ddr/imx/phy/Kconfig          |   7 +
 17 files changed, 734 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/include/asm/mach-imx/qb.h
 create mode 100644 arch/arm/mach-imx/cmd_qb.c
 create mode 100644 arch/arm/mach-imx/imx9/qb.c
 create mode 100644 doc/board/nxp/qb.rst
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/5 imx9: Add support for saving DDR training data to NVM

From: Simona Toaca <[email protected]>

DDR training data can be saved to NVM and be available to OEI at boot time, which will trigger QuickBoot flow.

Supported platforms: iMX94, iMX95
Supported storage types: eMMC, SD, SPI flash.

---
 arch/arm/include/asm/arch-imx9/ddr.h |  52 +++-
 arch/arm/include/asm/mach-imx/qb.h   |  13 +
 arch/arm/mach-imx/imx9/Makefile      |   8 +-
 arch/arm/mach-imx/imx9/qb.c          | 430 +++++++++++++++++++++++++++
 arch/arm/mach-imx/imx9/scmi/soc.c    |   9 +
 drivers/ddr/imx/imx9/Kconfig         |   8 +
 drivers/ddr/imx/phy/Kconfig          |   7 +
 7 files changed, 524 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/include/asm/mach-imx/qb.h
 create mode 100644 arch/arm/mach-imx/imx9/qb.c
arch/arm/include/asm/arch-imx9/ddr.h +51 -1
index a8e3f7354c7..a0eea6852d2 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Copyright 2022 NXP
+ * Copyright 2022-2025 NXP
  */
 
 #ifndef __ASM_ARCH_IMX8M_DDR_H
@@ -100,6 +100,56 @@ struct dram_timing_info {
 
 extern struct dram_timing_info dram_timing;
 
+#if IS_ENABLED(CONFIG_IMX95) || IS_ENABLED(CONFIG_IMX94) /* CONFIG_IMX95 || CONFIG_IMX94 */
+#if IS_ENABLED(CONFIG_IMX_SNPS_DDR_PHY_QB_GEN)
+/* Quick Boot related */
+#define DDRPHY_QB_CSR_SIZE	5168
+#define DDRPHY_QB_ACSM_SIZE	4 * 1024
+#define DDRPHY_QB_MSB_SIZE	0x200
+#define DDRPHY_QB_PSTATES	0
+#define DDRPHY_QB_PST_SIZE	DDRPHY_QB_PSTATES * 4 * 1024
+
+/**
+ * This structure needs to be aligned with the one in OEI.
+ */
+struct ddrphy_qb_state {
+	u32 crc;		  /** Used for ensuring integrity in DRAM */
+#define MAC_LENGTH              8 /** 256 bits, 32-bit aligned */
+	u32 mac[MAC_LENGTH];
+	u8 TrainedVREFCA_A0;
+	u8 TrainedVREFCA_A1;
+	u8 TrainedVREFCA_B0;
+	u8 TrainedVREFCA_B1;
+	u8 TrainedVREFDQ_A0;
+	u8 TrainedVREFDQ_A1;
+	u8 TrainedVREFDQ_B0;
+	u8 TrainedVREFDQ_B1;
+	u8 TrainedVREFDQU_A0;
+	u8 TrainedVREFDQU_A1;
+	u8 TrainedVREFDQU_B0;
+	u8 TrainedVREFDQU_B1;
+	u8 TrainedDRAMDFE_A0;
+	u8 TrainedDRAMDFE_A1;
+	u8 TrainedDRAMDFE_B0;
+	u8 TrainedDRAMDFE_B1;
+	u8 TrainedDRAMDCA_A0;
+	u8 TrainedDRAMDCA_A1;
+	u8 TrainedDRAMDCA_B0;
+	u8 TrainedDRAMDCA_B1;
+	u16 QBPllUPllProg0;
+	u16 QBPllUPllProg1;
+	u16 QBPllUPllProg2;
+	u16 QBPllUPllProg3;
+	u16 QBPllCtrl1;
+	u16 QBPllCtrl4;
+	u16 QBPllCtrl5;
+	u16 csr[DDRPHY_QB_CSR_SIZE];
+	u16 acsm[DDRPHY_QB_ACSM_SIZE];
+	u16 pst[DDRPHY_QB_PST_SIZE];
+};
+#endif /* #if IS_ENABLED(CONFIG_IMX_SNPS_DDR_PHY_QB_GEN)  */
+#endif /* #if IS_ENABLED(CONFIG_IMX95) || IS_ENABLED(CONFIG_IMX94) */
+
 void ddr_load_train_firmware(enum fw_type type);
 int ddr_init(struct dram_timing_info *timing_info);
 int ddr_cfg_phy(struct dram_timing_info *timing_info);
arch/arm/include/asm/mach-imx/qb.h new file +13 -0
new file mode 100644
index 00000000000..5efe68f0a60
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2026 NXP
+ */
+
+#ifndef __IMX_QB_H__
+#define __IMX_QB_H__
+
+#include <stdbool.h>
+
+bool qb_check(void);
+int  qb(int qb_dev, int qb_bootdev, bool save);
+#endif
arch/arm/mach-imx/imx9/Makefile +6 -2
index 53cc97c6b47..3018d128a36 100644
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
-# Copyright 2022 NXP
+# Copyright 2022,2026 NXP
 
 obj-y += lowlevel_init.o
 
@@ -12,4 +12,8 @@ endif
 
 ifneq ($(CONFIG_SPL_BUILD),y)
 obj-y += imx_bootaux.o
-endif
\ No newline at end of file
+endif
+
+ifeq ($(CONFIG_IMX_SNPS_DDR_PHY_QB_GEN),y)
+obj-y += qb.o
+endif
arch/arm/mach-imx/imx9/qb.c new file +430 -0

430 lines not on this page · raw message

arch/arm/mach-imx/imx9/scmi/soc.c +9 -0
index 17269ddd2fc..eb9bfe19a69 100644
@@ -281,6 +281,15 @@ static struct mm_region imx9_mem_map[] = {
 			 PTE_BLOCK_NON_SHARE |
 			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
 	}, {
+#if IS_ENABLED(CONFIG_IMX_SNPS_DDR_PHY_QB_GEN)
+		/* QB data */
+		.virt = CONFIG_SAVED_QB_STATE_BASE,
+		.phys = CONFIG_SAVED_QB_STATE_BASE,
+		.size = 0x200000UL,	/* 2M */
+		.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+			 PTE_BLOCK_OUTER_SHARE
+	}, {
+#endif /* CONFIG_IMX_SNPS_DDR_PHY_QB_GEN */
 		/* empty entry to split table entry 5 if needed when TEEs are used */
 		0,
 	}, {
drivers/ddr/imx/imx9/Kconfig +8 -0
index 0a45340ffb6..7c244ddb5dd 100644
@@ -29,4 +29,12 @@ config SAVED_DRAM_TIMING_BASE
 	  info into memory for low power use.
 	default 0x2051C000
 
+config SAVED_QB_STATE_BASE
+	hex "Define the base address for saved QuickBoot state"
+	depends on IMX_SNPS_DDR_PHY_QB_GEN
+	help
+	  Once DRAM is trained, need to save the dram related timing
+	  info into memory in order to be reachable from U-Boot.
+	default 0x8fe00000
+
 endmenu
drivers/ddr/imx/phy/Kconfig +7 -0
index d3e589b23c4..e8d0c005689 100644
@@ -2,3 +2,10 @@ config IMX_SNPS_DDR_PHY
 	bool "i.MX Snopsys DDR PHY"
 	help
 	  Select the DDR PHY driver support on i.MX8M and i.MX9 SOC.
+
+config IMX_SNPS_DDR_PHY_QB_GEN
+	bool "i.MX Synopsys DDR PHY training data saving for QuickBoot mode"
+	depends on IMX94 || IMX95
+	help
+	  Select the DDR PHY training data saving for
+	  QuickBoot support on i.MX9 SOC.
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/5 arm: mach-imx: Add command to expose QB functionality

In reply to Simona Toaca (OSS)

From: Simona Toaca <[email protected]>

This command exposes 3 methods:
- check -> checks if the data in volatile memory is valid
- save -> saves the data to non-volatile memory and erases the data in volatile memory
- erase -> erases the data in non-volatile memory

cmd_qb can be used either directly in the U-Boot console or in an uuu script to save the QB data during flashing. It supports specifying a different boot medium than the current boot device for saving the data.

---
 arch/arm/mach-imx/Kconfig       |   8 ++
 arch/arm/mach-imx/Makefile      |   1 +
 arch/arm/mach-imx/cmd_qb.c      | 132 ++++++++++++++++++++++++++++++++
 arch/arm/mach-imx/imx9/Makefile |   4 +-
 4 files changed, 144 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-imx/cmd_qb.c
arch/arm/mach-imx/Kconfig +8 -0
index e4014226582..17aad696648 100644
@@ -71,6 +71,14 @@ config CSF_SIZE
 	  Define the maximum size for Command Sequence File (CSF) binary
 	  this information is used to define the image boot data.
 
+config CMD_IMX_QB
+	bool "Support the 'qb' command"
+	default y
+	depends on IMX_SNPS_DDR_PHY_QB_GEN && (IMX95 || IMX94)
+	help
+	  Enable qb command to write DDR quick boot training data
+	  to boot device.
+
 config CMD_BMODE
 	bool "Support the 'bmode' command"
 	default y
arch/arm/mach-imx/Makefile +1 -0
index 0f6e737c0b9..dfa9eca43eb 100644
@@ -82,6 +82,7 @@ obj-$(CONFIG_CMD_BMODE) += cmd_bmode.o
 obj-$(CONFIG_CMD_HDMIDETECT) += cmd_hdmidet.o
 obj-$(CONFIG_CMD_DEKBLOB) += cmd_dek.o
 obj-$(CONFIG_CMD_NANDBCB) += cmd_nandbcb.o
+obj-$(CONFIG_CMD_IMX_QB) += cmd_qb.o
 endif
 
 ifeq ($(CONFIG_XPL_BUILD),y)
arch/arm/mach-imx/cmd_qb.c new file +132 -0

132 lines not on this page · raw message

arch/arm/mach-imx/imx9/Makefile +3 -1
index 3018d128a36..7dee144e0f4 100644
@@ -15,5 +15,7 @@ obj-y += imx_bootaux.o
 endif
 
 ifeq ($(CONFIG_IMX_SNPS_DDR_PHY_QB_GEN),y)
-obj-y += qb.o
+ifneq ($(CONFIG_XPL_BUILD),y)
+obj-$(CONFIG_CMD_IMX_QB) += qb.o
+endif
 endif
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/5 imx9: Enable QB data saving for iMX9{4,5} EVK

In reply to Simona Toaca (OSS)

From: Simona Toaca <[email protected]>

Add the necessary options for enabling DDR training data saving to NVM and running QuickBoot flow.

---
 configs/imx943_evk_defconfig      | 1 +
 configs/imx95_15x15_evk_defconfig | 1 +
 configs/imx95_evk.config          | 1 +
 3 files changed, 3 insertions(+)
configs/imx943_evk_defconfig +1 -0
index ef4f9a8fcbc..57d4240ba26 100644
@@ -96,6 +96,7 @@ CONFIG_SPL_CLK_CCF=y
 CONFIG_CLK_CCF=y
 CONFIG_CLK_SCMI=y
 CONFIG_SPL_CLK_SCMI=y
+CONFIG_IMX_SNPS_DDR_PHY_QB_GEN=y
 CONFIG_SPL_FIRMWARE=y
 # CONFIG_SCMI_AGENT_SMCCC is not set
 CONFIG_IMX_RGPIO2P=y
configs/imx95_15x15_evk_defconfig +1 -0
index 38a855417d0..03c9b71f8bd 100644
@@ -100,6 +100,7 @@ CONFIG_SPL_CLK_CCF=y
 CONFIG_CLK_SCMI=y
 CONFIG_SPL_CLK_SCMI=y
 CONFIG_CLK_IMX95_BLKCTRL=y
+CONFIG_IMX_SNPS_DDR_PHY_QB_GEN=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_SPL_FIRMWARE=y
configs/imx95_evk.config +1 -0
index 3db583cce59..b34d3f9c935 100644
@@ -101,6 +101,7 @@ CONFIG_SPL_CLK_CCF=y
 CONFIG_CLK_CCF=y
 CONFIG_CLK_SCMI=y
 CONFIG_SPL_CLK_SCMI=y
+CONFIG_IMX_SNPS_DDR_PHY_QB_GEN=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
 CONFIG_SPL_FIRMWARE=y
Signature · 1 line
2.43.0
#4 lore raw

PATCH 4/5 board: nxp: imx9{4,5}_evk: Add qb save option in SPL

In reply to Simona Toaca (OSS)

From: Simona Toaca <[email protected]>

Call qb save automatically in the board-specific spl_board_init(), if SPL_QB option is enabled. This makes sure qb_save is called before any image loading is done by the SPL.

---
 arch/arm/include/asm/mach-imx/qb.h | 2 ++
 arch/arm/mach-imx/Kconfig          | 7 +++++++
 arch/arm/mach-imx/imx9/Makefile    | 4 +++-
 arch/arm/mach-imx/imx9/qb.c        | 9 +++++++++
 board/nxp/imx94_evk/spl.c          | 6 +++++-
 board/nxp/imx95_evk/spl.c          | 6 +++++-
 6 files changed, 31 insertions(+), 3 deletions(-)
arch/arm/include/asm/mach-imx/qb.h +2 -0
index 5efe68f0a60..4f923d79e7a 100644
@@ -10,4 +10,6 @@
 
 bool qb_check(void);
 int  qb(int qb_dev, int qb_bootdev, bool save);
+void spl_qb_save(void);
+
 #endif
arch/arm/mach-imx/Kconfig +7 -0
index 17aad696648..069b25c6241 100644
@@ -71,6 +71,13 @@ config CSF_SIZE
 	  Define the maximum size for Command Sequence File (CSF) binary
 	  this information is used to define the image boot data.
 
+config SPL_IMX_QB
+	bool "Run qb save during SPL"
+	default n
+	depends on SPL && IMX_SNPS_DDR_PHY_QB_GEN && (IMX95 || IMX94)
+	help
+	  Run qb save on bootdev automatically during SPL.
+
 config CMD_IMX_QB
 	bool "Support the 'qb' command"
 	default y
arch/arm/mach-imx/imx9/Makefile +3 -1
index 7dee144e0f4..3207013812a 100644
@@ -15,7 +15,9 @@ obj-y += imx_bootaux.o
 endif
 
 ifeq ($(CONFIG_IMX_SNPS_DDR_PHY_QB_GEN),y)
-ifneq ($(CONFIG_XPL_BUILD),y)
+ifeq ($(CONFIG_XPL_BUILD),y)
+obj-$(CONFIG_SPL_IMX_QB) += qb.o
+else
 obj-$(CONFIG_CMD_IMX_QB) += qb.o
 endif
 endif
arch/arm/mach-imx/imx9/qb.c +9 -0
index fc01d8e22e9..79573741d39 100644
@@ -428,3 +428,12 @@ int qb(int qb_dev, int qb_bootdev, bool save)
 
 	return 0;
 }
+
+void spl_qb_save(void)
+{
+	int dev = spl_boot_device();
+
+	/** Save QB data on current boot device */
+	if (qb(dev, dev, true))
+		printf("QB save failed\n");
+}
board/nxp/imx94_evk/spl.c +5 -1
index cc5b7f9ef0f..1d25795eb17 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright 2025 NXP
+ * Copyright 2025-2026 NXP
  */
 
 #include <hang.h>
@@ -14,6 +14,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/mach-imx/boot_mode.h>
 #include <asm/mach-imx/ele_api.h>
+#include <asm/mach-imx/qb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -44,6 +45,9 @@ void spl_board_init(void)
 	ret = ele_start_rng();
 	if (ret)
 		printf("Fail to start RNG: %d\n", ret);
+
+	if (IS_ENABLED(CONFIG_SPL_IMX_QB))
+		spl_qb_save();
 }
 
 /* SCMI support by default */
board/nxp/imx95_evk/spl.c +5 -1
index 761a1a4a0f6..35e4458f2b7 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright 2025 NXP
+ * Copyright 2025-2026 NXP
  */
 
 #include <hang.h>
@@ -13,6 +13,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/mach-imx/boot_mode.h>
 #include <asm/mach-imx/ele_api.h>
+#include <asm/mach-imx/qb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -41,6 +42,9 @@ void spl_board_init(void)
 	ret = ele_start_rng();
 	if (ret)
 		printf("Fail to start RNG: %d\n", ret);
+
+	if (IS_ENABLED(CONFIG_SPL_IMX_QB))
+		spl_qb_save();
 }
 
 void board_init_f(ulong dummy)
Signature · 1 line
2.43.0
#5 lore raw

Re: [PATCH 4/5] board: nxp: imx9{4,5}_evk: Add qb save option in SPL

Quoted 99 lines · Simona Toaca (OSS)

From: Simona Toaca <[email protected]>

Call qb save automatically in the board-specific spl_board_init(), if SPL_QB option is enabled. This makes sure qb_save is called before any image loading is done by the SPL.

---
 arch/arm/include/asm/mach-imx/qb.h | 2 ++
 arch/arm/mach-imx/Kconfig          | 7 +++++++
 arch/arm/mach-imx/imx9/Makefile    | 4 +++-
 arch/arm/mach-imx/imx9/qb.c        | 9 +++++++++
 board/nxp/imx94_evk/spl.c          | 6 +++++-
 board/nxp/imx95_evk/spl.c          | 6 +++++-
 6 files changed, 31 insertions(+), 3 deletions(-)
arch/arm/include/asm/mach-imx/qb.h +2 -0
index 5efe68f0a60..4f923d79e7a 100644
@@ -10,4 +10,6 @@
 
 bool qb_check(void);
 int  qb(int qb_dev, int qb_bootdev, bool save);
+void spl_qb_save(void);
+
 #endif
arch/arm/mach-imx/Kconfig +7 -0
index 17aad696648..069b25c6241 100644
@@ -71,6 +71,13 @@ config CSF_SIZE
 	  Define the maximum size for Command Sequence File (CSF) binary
 	  this information is used to define the image boot data.
 
+config SPL_IMX_QB
+	bool "Run qb save during SPL"
+	default n
+	depends on SPL && IMX_SNPS_DDR_PHY_QB_GEN && (IMX95 || IMX94)
+	help
+	  Run qb save on bootdev automatically during SPL.
+
 config CMD_IMX_QB
 	bool "Support the 'qb' command"
 	default y
arch/arm/mach-imx/imx9/Makefile +3 -1
index 7dee144e0f4..3207013812a 100644
@@ -15,7 +15,9 @@ obj-y += imx_bootaux.o
 endif
 
 ifeq ($(CONFIG_IMX_SNPS_DDR_PHY_QB_GEN),y)
-ifneq ($(CONFIG_XPL_BUILD),y)
+ifeq ($(CONFIG_XPL_BUILD),y)
+obj-$(CONFIG_SPL_IMX_QB) += qb.o
+else
 obj-$(CONFIG_CMD_IMX_QB) += qb.o
 endif
 endif
arch/arm/mach-imx/imx9/qb.c +9 -0
index fc01d8e22e9..79573741d39 100644
@@ -428,3 +428,12 @@ int qb(int qb_dev, int qb_bootdev, bool save)
 
 	return 0;
 }
+
+void spl_qb_save(void)
+{
+	int dev = spl_boot_device();
+
+	/** Save QB data on current boot device */
+	if (qb(dev, dev, true))
+		printf("QB save failed\n");
+}
board/nxp/imx94_evk/spl.c +2 -1
index cc5b7f9ef0f..1d25795eb17 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright 2025 NXP
+ * Copyright 2025-2026 NXP
  */
 
 #include <hang.h>
@@ -14,6 +14,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/mach-imx/boot_mode.h>
 #include <asm/mach-imx/ele_api.h>
+#include <asm/mach-imx/qb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 

board/nxp/imx94_evk/spl.c void spl_board_init(void) · line 50

Quoted 6 lines
board/nxp/imx94_evk/spl.c +3 -0
@@ -44,6 +45,9 @@ void spl_board_init(void)
 	ret = ele_start_rng();
 	if (ret)
 		printf("Fail to start RNG: %d\n", ret);
+
+	if (IS_ENABLED(CONFIG_SPL_IMX_QB))
+		spl_qb_save();

Does it write to MMC/NOR/SD at every boot? Is that necessary if a quick boot was performed and the data has not changed?

Quoted 24 lines
board/nxp/imx94_evk/spl.c +0 -0
 }
 
 /* SCMI support by default */
board/nxp/imx95_evk/spl.c +2 -1
index 761a1a4a0f6..35e4458f2b7 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright 2025 NXP
+ * Copyright 2025-2026 NXP
  */
 
 #include <hang.h>
@@ -13,6 +13,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/mach-imx/boot_mode.h>
 #include <asm/mach-imx/ele_api.h>
+#include <asm/mach-imx/qb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 

board/nxp/imx95_evk/spl.c void spl_board_init(void) · line 50

Quoted 9 lines
board/nxp/imx95_evk/spl.c +3 -0
@@ -41,6 +42,9 @@ void spl_board_init(void)
 	ret = ele_start_rng();
 	if (ret)
 		printf("Fail to start RNG: %d\n", ret);
+
+	if (IS_ENABLED(CONFIG_SPL_IMX_QB))
+		spl_qb_save();
 }
 
 void board_init_f(ulong dummy)

Kind regards,
Emanuele

#6 lore raw

Re: [PATCH 4/5] board: nxp: imx9{4,5}_evk: Add qb save option in SPL

Hi Emanuele,

Quoted 101 lines · Emanuele Ghidoli
Quoted 98 lines · Simona Toaca (OSS)

From: Simona Toaca <[email protected]>

Call qb save automatically in the board-specific spl_board_init(), if SPL_QB option is enabled. This makes sure qb_save is called before any image loading is done by the SPL.

---
 arch/arm/include/asm/mach-imx/qb.h | 2 ++
 arch/arm/mach-imx/Kconfig          | 7 +++++++
 arch/arm/mach-imx/imx9/Makefile    | 4 +++-
 arch/arm/mach-imx/imx9/qb.c        | 9 +++++++++
 board/nxp/imx94_evk/spl.c          | 6 +++++-
 board/nxp/imx95_evk/spl.c          | 6 +++++-
 6 files changed, 31 insertions(+), 3 deletions(-)
arch/arm/include/asm/mach-imx/qb.h +2 -0
index 5efe68f0a60..4f923d79e7a 100644
@@ -10,4 +10,6 @@
 
 bool qb_check(void);
 int  qb(int qb_dev, int qb_bootdev, bool save);
+void spl_qb_save(void);
+
 #endif
arch/arm/mach-imx/Kconfig +7 -0
index 17aad696648..069b25c6241 100644
@@ -71,6 +71,13 @@ config CSF_SIZE
 	  Define the maximum size for Command Sequence File (CSF) binary
 	  this information is used to define the image boot data.
 
+config SPL_IMX_QB
+	bool "Run qb save during SPL"
+	default n
+	depends on SPL && IMX_SNPS_DDR_PHY_QB_GEN && (IMX95 || IMX94)
+	help
+	  Run qb save on bootdev automatically during SPL.
+
 config CMD_IMX_QB
 	bool "Support the 'qb' command"
 	default y
arch/arm/mach-imx/imx9/Makefile +3 -1
index 7dee144e0f4..3207013812a 100644
@@ -15,7 +15,9 @@ obj-y += imx_bootaux.o
 endif
 
 ifeq ($(CONFIG_IMX_SNPS_DDR_PHY_QB_GEN),y)
-ifneq ($(CONFIG_XPL_BUILD),y)
+ifeq ($(CONFIG_XPL_BUILD),y)
+obj-$(CONFIG_SPL_IMX_QB) += qb.o
+else
 obj-$(CONFIG_CMD_IMX_QB) += qb.o
 endif
 endif
arch/arm/mach-imx/imx9/qb.c +9 -0
index fc01d8e22e9..79573741d39 100644
@@ -428,3 +428,12 @@ int qb(int qb_dev, int qb_bootdev, bool save)
 
 	return 0;
 }
+
+void spl_qb_save(void)
+{
+	int dev = spl_boot_device();
+
+	/** Save QB data on current boot device */
+	if (qb(dev, dev, true))
+		printf("QB save failed\n");
+}
board/nxp/imx94_evk/spl.c +2 -1
index cc5b7f9ef0f..1d25795eb17 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright 2025 NXP
+ * Copyright 2025-2026 NXP
  */
 
 #include <hang.h>
@@ -14,6 +14,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/mach-imx/boot_mode.h>
 #include <asm/mach-imx/ele_api.h>
+#include <asm/mach-imx/qb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
Quoted 10 lines

board/nxp/imx94_evk/spl.c void spl_board_init(void) · line 50

Quoted 7 lines
board/nxp/imx94_evk/spl.c +3 -0
@@ -44,6 +45,9 @@ void spl_board_init(void)
 	ret = ele_start_rng();
 	if (ret)
 		printf("Fail to start RNG: %d\n", ret);
+
+	if (IS_ENABLED(CONFIG_SPL_IMX_QB))
+		spl_qb_save();

Does it write to MMC/NOR/SD at every boot? Is that necessary if a quick boot was performed and the data has not changed?

Quoted 1 line
board/nxp/imx94_evk/spl.c +0 -0
 }

No, the qb() method calls qb_check, which returns true only if OEI saved valid data to volatile memory (meaning it has run Training flow). So, if Quickboot flow is run, the data in volatile memory is not valid, qb_check fails -> qb returns and does not write anything to the NVM.

Also, another thing to keep in mind is that after a successfull qb save, the data in volatile memory is invalidated -> qb check will fail as well even if OEI doesn't run (so on a warm reboot).

Quoted 31 lines
Quoted 31 lines
board/nxp/imx94_evk/spl.c +0 -0
 /* SCMI support by default */
board/nxp/imx95_evk/spl.c +5 -1
index 761a1a4a0f6..35e4458f2b7 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright 2025 NXP
+ * Copyright 2025-2026 NXP
  */
 
 #include <hang.h>
@@ -13,6 +13,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/mach-imx/boot_mode.h>
 #include <asm/mach-imx/ele_api.h>
+#include <asm/mach-imx/qb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -41,6 +42,9 @@ void spl_board_init(void)
 	ret = ele_start_rng();
 	if (ret)
 		printf("Fail to start RNG: %d\n", ret);
+
+	if (IS_ENABLED(CONFIG_SPL_IMX_QB))
+		spl_qb_save();
 }
 
Quoted 5 lines

board/nxp/imx95_evk/spl.c void spl_board_init(void) · line 50

Quoted 1 line
board/nxp/imx95_evk/spl.c +0 -0
 void board_init_f(ulong dummy)

Kind regards,
Emanuele

Best regards,
Simona

#7 lore raw

Re: [PATCH 4/5] board: nxp: imx9{4,5}_evk: Add qb save option in SPL

Quoted 10 lines · Simona Toaca
Quoted 9 lines · Emanuele Ghidoli
Quoted 8 lines · Simona Toaca (OSS)

From: Simona Toaca <[email protected]>

Call qb save automatically in the board-specific spl_board_init(), if SPL_QB option is enabled. This makes sure qb_save is called before any image loading is done by the SPL.

...

Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
board/nxp/imx94_evk/spl.c +0 -0
index cc5b7f9ef0f..1d25795eb17 100644
@@ -44,6 +45,9 @@ void spl_board_init(void)
Quoted 9 lines

board/nxp/imx94_evk/spl.c void spl_board_init(void) · line 50

Quoted 6 lines
board/nxp/imx94_evk/spl.c +3 -0
 	ret = ele_start_rng();
 	if (ret)
 		printf("Fail to start RNG: %d\n", ret);
+
+	if (IS_ENABLED(CONFIG_SPL_IMX_QB))
+		spl_qb_save();

Does it write to MMC/NOR/SD at every boot? Is that necessary if a quick boot was performed and the data has not changed?

Quoted 1 line
board/nxp/imx94_evk/spl.c +0 -0
 }
Quoted 8 lines

No, the qb() method calls qb_check, which returns true only if OEI saved valid data to volatile memory (meaning it has run Training flow). So, if Quickboot flow is run, the data in volatile memory is not valid, qb_check fails -> qb returns and does not write anything to the NVM.

Also, another thing to keep in mind is that after a successfull qb save, the data in volatile memory is invalidated -> qb check will fail as well even if OEI doesn't run (so on a warm reboot).

Do you think that this is something that should be generally enabled on any i.MX95 boards? Emanuele?

Francesco

#8 lore raw

Re: [PATCH 4/5] board: nxp: imx9{4,5}_evk: Add qb save option in SPL

Hi Francesco,

Quoted 33 lines · Francesco Dolcini
Quoted 10 lines · Simona Toaca
Quoted 9 lines · Emanuele Ghidoli
Quoted 8 lines · Simona Toaca (OSS)

From: Simona Toaca <[email protected]>

Call qb save automatically in the board-specific spl_board_init(), if SPL_QB option is enabled. This makes sure qb_save is called before any image loading is done by the SPL.

...

Quoted 19 lines
Quoted 5 lines
Quoted 5 lines
board/nxp/imx94_evk/spl.c +0 -0
index cc5b7f9ef0f..1d25795eb17 100644
@@ -44,6 +45,9 @@ void spl_board_init(void)
Quoted 9 lines

board/nxp/imx94_evk/spl.c void spl_board_init(void) · line 50

Quoted 6 lines
board/nxp/imx94_evk/spl.c +3 -0
 	ret = ele_start_rng();
 	if (ret)
 		printf("Fail to start RNG: %d\n", ret);
+
+	if (IS_ENABLED(CONFIG_SPL_IMX_QB))
+		spl_qb_save();

Does it write to MMC/NOR/SD at every boot? Is that necessary if a quick boot was performed and the data has not changed?

Quoted 1 line
board/nxp/imx94_evk/spl.c +0 -0
 }

No, the qb() method calls qb_check, which returns true only if OEI saved valid data to volatile memory (meaning it has run Training flow). So, if Quickboot flow is run, the data in volatile memory is not valid, qb_check fails -> qb returns and does not write anything to the NVM.

Quoted 9 lines
Quoted 3 lines

Also, another thing to keep in mind is that after a successfull qb save, the data in volatile memory is invalidated -> qb check will fail as well even if OEI doesn't run (so on a warm reboot).

Do you think that this is something that should be generally enabled on any i.MX95 boards? Emanuele?

Francesco

I think it depends on the usecase.

Enabling QB in SPL is useful for:
- automating the save
- being able to skip U-Boot proper

Enabling CMD_IMX_QB:
- lets the user save the data during flashing
- lets the user save the data to a different
boot device.

If SPL QB is enabled, the qb save command is only useful in the uuu script.

I will add these comments to the documentation as well.

Another thing is that if SPL_IMX_QB is enabled, other config options also have to be enabled depending on the boot device (for example, as I have also written in the documentation, SPL_MMC_WRITE for MMC boot devices).

I should mention that this functionality is tested on latest iMX95 rev: B0 (if talking about 95) and has to be in sync with OEI.

Best regards,
Simona

reviewer
#9 lore raw

Re: [PATCH 4/5] board: nxp: imx9{4,5}_evk: Add qb save option in SPL

In reply to Simona Toaca (OSS)
Quoted 7 lines · Simona Toaca (OSS)

From: Simona Toaca <[email protected]>

Call qb save automatically in the board-specific spl_board_init(), if SPL_QB option is enabled. This makes sure qb_save is called before any image loading is done by the SPL.

Why do we need this? What does "QB" mean?

Please improve the commit message by providing more context and an explanation of what you want to achieve.

Quoted 26 lines
---
 arch/arm/include/asm/mach-imx/qb.h | 2 ++
 arch/arm/mach-imx/Kconfig          | 7 +++++++
 arch/arm/mach-imx/imx9/Makefile    | 4 +++-
 arch/arm/mach-imx/imx9/qb.c        | 9 +++++++++
 board/nxp/imx94_evk/spl.c          | 6 +++++-
 board/nxp/imx95_evk/spl.c          | 6 +++++-
 6 files changed, 31 insertions(+), 3 deletions(-)
arch/arm/include/asm/mach-imx/qb.h +2 -0
index 5efe68f0a60..4f923d79e7a 100644
@@ -10,4 +10,6 @@
 
 bool qb_check(void);
 int  qb(int qb_dev, int qb_bootdev, bool save);
+void spl_qb_save(void);
+
 #endif
arch/arm/mach-imx/Kconfig +0 -0
index 17aad696648..069b25c6241 100644

arch/arm/mach-imx/Kconfig config CSF_SIZE · line 75

Quoted 5 lines
arch/arm/mach-imx/Kconfig +2 -0
@@ -71,6 +71,13 @@ config CSF_SIZE
          Define the maximum size for Command Sequence File (CSF) binary
          this information is used to define the image boot data.
 
+config SPL_IMX_QB
+       bool "Run qb save during SPL"

What does "qb save" mean? Please explain here and in the commit message.

How does a user know if "qb save" should run in SPL or not?

arch/arm/mach-imx/Kconfig config CSF_SIZE · line 76

Quoted 1 line
arch/arm/mach-imx/Kconfig +1 -0
+       default n

No need to pass "default n". Drop it.

arch/arm/mach-imx/Kconfig config CSF_SIZE · line 81

Quoted 5 lines
arch/arm/mach-imx/Kconfig +5 -0
+void spl_qb_save(void)
+{
+       int dev = spl_boot_device();
+
+       /** Save QB data on current boot device */

Please use a single /* instead of /**

#10 lore raw

Re: [PATCH 4/5] board: nxp: imx9{4,5}_evk: Add qb save option in SPL

Hi Fabio,

Thank you for the review, I will fix these issues in the next version.

Best regards,
Simona

Quoted 62 lines · Fabio Estevam
Quoted 7 lines · Simona Toaca (OSS)

From: Simona Toaca <[email protected]>

Call qb save automatically in the board-specific spl_board_init(), if SPL_QB option is enabled. This makes sure qb_save is called before any image loading is done by the SPL.

Why do we need this? What does "QB" mean?

Please improve the commit message by providing more context and an explanation of what you want to achieve.

Quoted 26 lines
---
 arch/arm/include/asm/mach-imx/qb.h | 2 ++
 arch/arm/mach-imx/Kconfig          | 7 +++++++
 arch/arm/mach-imx/imx9/Makefile    | 4 +++-
 arch/arm/mach-imx/imx9/qb.c        | 9 +++++++++
 board/nxp/imx94_evk/spl.c          | 6 +++++-
 board/nxp/imx95_evk/spl.c          | 6 +++++-
 6 files changed, 31 insertions(+), 3 deletions(-)
arch/arm/include/asm/mach-imx/qb.h +2 -0
index 5efe68f0a60..4f923d79e7a 100644
@@ -10,4 +10,6 @@
 
 bool qb_check(void);
 int  qb(int qb_dev, int qb_bootdev, bool save);
+void spl_qb_save(void);
+
 #endif
arch/arm/mach-imx/Kconfig +0 -0
index 17aad696648..069b25c6241 100644

arch/arm/mach-imx/Kconfig config CSF_SIZE · line 75

Quoted 5 lines
arch/arm/mach-imx/Kconfig +2 -0
@@ -71,6 +71,13 @@ config CSF_SIZE
          Define the maximum size for Command Sequence File (CSF) binary
          this information is used to define the image boot data.
 
+config SPL_IMX_QB
+       bool "Run qb save during SPL"

What does "qb save" mean? Please explain here and in the commit message.

How does a user know if "qb save" should run in SPL or not?

arch/arm/mach-imx/Kconfig config CSF_SIZE · line 76

Quoted 1 line
arch/arm/mach-imx/Kconfig +1 -0
+       default n

No need to pass "default n". Drop it.

arch/arm/mach-imx/Kconfig config CSF_SIZE · line 81

Quoted 5 lines
arch/arm/mach-imx/Kconfig +5 -0
+void spl_qb_save(void)
+{
+       int dev = spl_boot_device();
+
+       /** Save QB data on current boot device */

Please use a single /* instead of /**

#11 lore raw

PATCH 5/5 doc: board: nxp: Add Quickboot documentation

In reply to Simona Toaca (OSS)

From: Simona Toaca <[email protected]>

Add instructions on how to use U-Boot to save
DDR training data to NVM.

---
 doc/board/nxp/index.rst |  1 +
 doc/board/nxp/qb.rst    | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)
 create mode 100644 doc/board/nxp/qb.rst
doc/board/nxp/index.rst +1 -0
index 01d3468a47d..7e3e5e29880 100644
@@ -29,3 +29,4 @@ NXP Semiconductors
    mx6ullevk
    rproc
    psb
+   qb
doc/board/nxp/qb.rst new file +33 -0
new file mode 100644
index 00000000000..ba673ecff24
@@ -0,0 +1,33 @@
+.. SPDX-License-Identifier: GPL-2.0+
+   Copyright 2026 NXP
+
+DDR QuickBoot flow
+------------------
+
+Some NXP boards (which use OEI - iMX943, iMX95) support saving DDR
+training data to non-volatile memory, which is then available to OEI
+at next cold reboot. OEI uses the saved data to run Quickboot flow and
+avoid training the DDR again. This significantly reduces the boot time.
+
+There are 2 ways to save this data:
+
+1. automatically, in SPL (by enabling CONFIG_SPL_IMX_QB)
+
+- this will save the data on the current boot device (e.g. SD)
+- other configs specific to the boot device need to be enabled (CONFIG_SPL_MMC_WRITE for saving to eMMC/SD)
+
+2. using qb command in U-Boot console (by enabling CONFIG_CMD_IMX_QB)
+
+- supports saving on the current boot device, or on another, specified device.
+- if flashing via uuu, the command can be added in an uuu script (boot device needs to be specified)
+- after save, the data in volatile memory is erased, so saving can happen only once per DDR training
+
+::
+
+        # To save/erase on current boot device
+        => qb save/erase
+
+        # To save/erase on other boot device
+        => qb save/erase mmc 0 # eMMC
+        => qb save/erase mmc 1 # SD
+        => qb save/erase spi   # NOR SPI
Signature · 1 line
2.43.0
#12 lore raw
In reply to Simona Toaca (OSS)
Quoted 6 lines · Simona Toaca (OSS)

From: Simona Toaca <[email protected]>

This patch series adds support for saving DDR training data to non-volatile memory on iMX94 and iMX95 platforms. The purpose is running DDR Quickboot flow on next reboot.

Quoted 7 lines

The process is as follows:
- OEI runs Training flow for the DDRPHY
- OEI saves the data from training to volatile memory
- U-Boot can then save it to non-volatile memory (e.g. SD)
- OEI loads the data from NVM at cold reboot and runs Quickboot flow

By skipping training, a much lower boot time is achieved.

How does this interact with authenticated boot ? I wonder if, in case the entire bootloader stack is authenticated, the attacker can tamper with the saved QB data (which do not seem to be authenticated) and cause bitflips to occur in DRAM, which could then allow them to bypass authentication in follow up stages which execute from DRAM ?

Are the QB data protected/authenticated in any way against tampering ?

#13 lore raw

Hi Marek,

Quoted 13 lines · Marek Vasut
Quoted 12 lines · Simona Toaca (OSS)

From: Simona Toaca <[email protected]>

This patch series adds support for saving DDR training data to non-volatile memory on iMX94 and iMX95 platforms. The purpose is running DDR Quickboot flow on next reboot.

The process is as follows:
- OEI runs Training flow for the DDRPHY
- OEI saves the data from training to volatile memory
- U-Boot can then save it to non-volatile memory (e.g. SD)
- OEI loads the data from NVM at cold reboot and runs Quickboot flow

Quoted 8 lines
Quoted 1 line

By skipping training, a much lower boot time is achieved.

How does this interact with authenticated boot ? I wonder if, in case the entire bootloader stack is authenticated, the attacker can tamper with the saved QB data (which do not seem to be authenticated) and cause bitflips to occur in DRAM, which could then allow them to bypass authentication in follow up stages which execute from DRAM ?

Are the QB data protected/authenticated in any way against tampering ?

In U-Boot there is no authentication for qb, it's just the CRC that is used to ensure the qb data was not overwritten by another (non-malicious) entity.

OEI is the first boot component that runs during the bootflow and is in charge of verifying if the data stored in NVM is valid or not. With the exception of iMX95 A0/A1, which use a CRC as well for this purpose, the other boards (iMX95 B0, iMX943, etc.) use ELE to verify a MAC stored in the qb_state structure. This provides the authentication part.

If someone tampers with the data and it somehow gets saved to NVM, the worst case scenario is that Training flow will run instead of the Quickboot flow. I am not sure that it can have any other impact. Especially in the case where SPL saves qb data, the DRAM address can then be used for image loading without worrying about qb or what data had been written there.

Kind regards,
Simona

#14 lore raw

On 3/12/26 12:47 PM, Simona Toaca wrote:

Hello Simona,

Quoted 21 lines · Marek Vasut
Quoted 20 lines · Simona Toaca (OSS)
Quoted 6 lines

From: Simona Toaca <[email protected]>

This patch series adds support for saving DDR training data to non-volatile memory on iMX94 and iMX95 platforms. The purpose is running DDR Quickboot flow on next reboot.

Quoted 7 lines

The process is as follows:
- OEI runs Training flow for the DDRPHY
- OEI saves the data from training to volatile memory
- U-Boot can then save it to non-volatile memory (e.g. SD)
- OEI loads the data from NVM at cold reboot and runs Quickboot flow

By skipping training, a much lower boot time is achieved.

How does this interact with authenticated boot ? I wonder if, in case the entire bootloader stack is authenticated, the attacker can tamper with the saved QB data (which do not seem to be authenticated) and cause bitflips to occur in DRAM, which could then allow them to bypass authentication in follow up stages which execute from DRAM ?

Quoted 4 lines
Quoted 1 line

Are the QB data protected/authenticated in any way against tampering ?

In U-Boot there is no authentication for qb, it's just the CRC that is used to ensure the qb data was not overwritten by another (non-malicious) entity.

Ouch

Quoted 5 lines

OEI is the first boot component that runs during the bootflow and is in charge of verifying if the data stored in NVM is valid or not. With the exception of iMX95 A0/A1, which use a CRC as well for this purpose, the other boards (iMX95 B0, iMX943, etc.) use ELE to verify a MAC stored in the qb_state structure. This provides the authentication part.

I see, understood and thank you for clarifying this. This part kept coming up in various discussions, so it would be nice to have this at least in the commit message, for future reference.

Thank you !