imx9{4,5,52}: Add Quickboot support
Subsystems (3)
v3 cover imx9{4,5,52}: Add Quickboot support
From: Simona Toaca <[email protected]>
This patch series adds support for saving DDR training data to non-volatile memory on iMX94, iMX95 and iMX952 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.
Changes for v3:
- Rebased and added support for iMX952
- Removed IMX_SNPS_DDR_PHY_QB_GEN macro, as it was not useful -> now CMD_QB is enabled by default on the supported boards
- Removed unnecessary #ifdefs -> replaced with if (CONFIG..)
- Replaced spi_flash_probe with udevice_first_device_err to avoid using SPI macros that needed ifdefs, since there is only one SPI flash device available.
- Adnotated qb methods with qb_ to be easier to see in asm dump
- Removed explicit pointer casts from (void *)
- Replaced custom qb_crc32 with the U-Boot one
- Made eveything snake_case
- Enabled SFDP support for iMX943/95, as it is necessary for proper erase size parsing (and is already present in iMX952 config)
- Improved documentation - explanation about the space in bootloader
- Added commit fixing a style issue in Kconfig
Changes for v2:
- Improved documentation to clarify the questions asked
- Detailed log messages for all commits
- Detailed Kconfig options for SPL_IMX_QB and CMD_IMX_QB
- Fixed the mentioned coding style issues
Simona Toaca (6):
imx9: Add support for saving DDR training data to NVM
arm: mach-imx: Add command to expose QB functionality
configs: imx9{43, 5}: Enable SPI SFDP support
board: nxp: imx9{4,5,52}_evk: Add qb save option in SPL
doc: board: nxp: Add Quickboot documentation
drivers: ddr: imx: Fix Kconfig for SAVED_DRAM_TIMING_BASE
arch/arm/include/asm/arch-imx9/ddr.h | 48 +++- arch/arm/include/asm/mach-imx/qb.h | 15 ++ arch/arm/mach-imx/Kconfig | 19 ++ arch/arm/mach-imx/Makefile | 1 + arch/arm/mach-imx/cmd_qb.c | 132 ++++++++++ arch/arm/mach-imx/imx9/Makefile | 10 +- arch/arm/mach-imx/imx9/qb.c | 379 +++++++++++++++++++++++++++ arch/arm/mach-imx/imx9/scmi/soc.c | 7 + board/nxp/imx94_evk/spl.c | 6 +- board/nxp/imx952_evk/spl.c | 4 + 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 | 54 ++++ drivers/ddr/imx/imx9/Kconfig | 9 +- 17 files changed, 688 insertions(+), 6 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
PATCH v3 1/6 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.
U-Boot only checks for data integrity (CRC32), while OEI is in charge of authentication when it tries to load the data from NVM.
On iMX95 A0/A1, 'authentication' is done via another CRC32. On the other boards, authentication is done by using ELE to check the MAC stored in the ddrphy_qb_state structure.
Supported platforms: iMX94, iMX95, iMX952 (using OEI) Supported storage types: eMMC, SD, SPI flash.
--- arch/arm/include/asm/arch-imx9/ddr.h | 48 +++- arch/arm/include/asm/mach-imx/qb.h | 15 ++ arch/arm/mach-imx/imx9/Makefile | 6 +- arch/arm/mach-imx/imx9/qb.c | 379 +++++++++++++++++++++++++++ arch/arm/mach-imx/imx9/scmi/soc.c | 7 + drivers/ddr/imx/imx9/Kconfig | 7 + 6 files changed, 459 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 +47 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0+ */ /* -* Copyright 2022 NXP +* Copyright 2022-2026 NXP */ #ifndef __ASM_ARCH_IMX8M_DDR_H
@@ -100,6 +100,52 @@ struct dram_timing_info {extern struct dram_timing_info dram_timing; +/* 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 ];/* For 95A0/1 use mac[0] to keep CRC32 value */ +u8 trained_vrefca_a0; +u8 trained_vrefca_a1; +u8 trained_vrefca_b0; +u8 trained_vrefca_b1; +u8 trained_vrefdq_a0; +u8 trained_vrefdq_a1; +u8 trained_vrefdq_b0; +u8 trained_vrefdq_b1; +u8 trained_vrefdqu_a0; +u8 trained_vrefdqu_a1; +u8 trained_vrefdqu_b0; +u8 trained_vrefdqu_b1; +u8 trained_dramdfe_a0; +u8 trained_dramdfe_a1; +u8 trained_dramdfe_b0; +u8 trained_dramdfe_b1; +u8 trained_dramdca_a0; +u8 trained_dramdca_a1; +u8 trained_dramdca_b0; +u8 trained_dramdca_b1; +u16 qb_pll_upll_prog0; +u16 qb_pll_upll_prog1; +u16 qb_pll_upll_prog2; +u16 qb_pll_upll_prog3; +u16 qb_pll_ctrl1; +u16 qb_pll_ctrl4; +u16 qb_pll_ctrl5; +u16 csr[DDRPHY_QB_CSR_SIZE ]; +u16 acsm[DDRPHY_QB_ACSM_SIZE ]; +u16 pst[DDRPHY_QB_PST_SIZE ]; +}; +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 +15 -0
@@ -0,0 +1,15 @@ +/* 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,bool save); +void spl_qb_save (void ); + +#endif
arch/arm/mach-imx/imx9/Makefile +4 -2
@@ -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,6 @@ endif ifneq ($(CONFIG_SPL_BUILD),y) obj-y += imx_bootaux.o -endif +endif + +obj-y += qb.o
arch/arm/mach-imx/imx9/qb.c new file +379 -0
379 lines not on this page · raw message
arch/arm/mach-imx/imx9/scmi/soc.c +7 -0
@@ -310,6 +310,13 @@ static struct mm_region imx9_mem_map[] = { .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | PTE_BLOCK_NON_SHARE | PTE_BLOCK_PXN | PTE_BLOCK_UXN + }, { +/* QB data */ + .virt = CONFIG_QB_SAVED_STATE_BASE, + .phys = CONFIG_QB_SAVED_STATE_BASE, + .size = 0x200000UL, /* 2M */ + .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | + PTE_BLOCK_OUTER_SHARE }, {/* empty entry to split table entry 5 if needed when TEEs are used */ 0,
drivers/ddr/imx/imx9/Kconfig +7 -0
@@ -29,4 +29,11 @@ config SAVED_DRAM_TIMING_BASE info into memory for low power use. default 0x2051C000 +config QB_SAVED_STATE_BASE + hex "Define the base address for saved QuickBoot state" + default 0x8fe00000 + help + Once DRAM is trained, the resulted training info is + saved into memory in order to be reachable from U-Boot. + endmenu
Signature · 1 line
2.43.0
PATCH v3 2/6 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 (integrity check)
- 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 | 11 +++ arch/arm/mach-imx/Makefile | 1 + arch/arm/mach-imx/cmd_qb.c | 132 ++++++++++++++++++++++++++++++++ arch/arm/mach-imx/imx9/Makefile | 4 +- 4 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-imx/cmd_qb.c
arch/arm/mach-imx/Kconfig +11 -0
@@ -71,6 +71,17 @@ 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 IMX94 || IMX95 || IMX952 + help + Enable qb command to write/erase DDR quick boot training + data to/from a chosen boot device. Using 'qb save/erase' + without arguments implies using the current boot device. + For use in uuu scripts, the boot device must be specified + explicitly. + config CMD_BMODE bool "Support the 'bmode' command" default y
arch/arm/mach-imx/Makefile +1 -0
@@ -80,6 +80,7 @@ endif ifneq ($(CONFIG_XPL_BUILD),y) obj-$(CONFIG_CMD_BMODE) += cmd_bmode.o obj-$(CONFIG_CMD_HDMIDETECT) += cmd_hdmidet.o +obj-$(CONFIG_CMD_IMX_QB) += cmd_qb.o obj-$(CONFIG_CMD_DEKBLOB) += cmd_dek.o obj-$(CONFIG_CMD_NANDBCB) += cmd_nandbcb.o endif
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
@@ -14,4 +14,6 @@ ifneq ($(CONFIG_SPL_BUILD),y) obj-y += imx_bootaux.o endif -obj-y += qb.o +ifneq ($(CONFIG_XPL_BUILD),y) +obj-$(CONFIG_CMD_IMX_QB) += qb.o +endif
Signature · 1 line
2.43.0
PATCH v3 3/6 configs: imx9{43, 5}: Enable SPI SFDP support
In reply to Simona Toaca (OSS)From: Simona Toaca <[email protected]>
In the context of saving Quickboot data to SPI
NOR, this option needs to be enabled so that the
erase size is parsed correctly.
--- 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
@@ -109,6 +109,7 @@ CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_FSL_USDHC=y CONFIG_MTD=y CONFIG_DM_SPI_FLASH=y +CONFIG_SPI_FLASH_SFDP_SUPPORT=y CONFIG_SPI_FLASH_SOFT_RESET=y CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT=y CONFIG_SPI_FLASH_STMICRO=y
configs/imx95_15x15_evk_defconfig +1 -0
@@ -120,6 +120,7 @@ CONFIG_MMC_HS400_SUPPORT=y CONFIG_FSL_USDHC=y CONFIG_MTD=y CONFIG_DM_SPI_FLASH=y +CONFIG_SPI_FLASH_SFDP_SUPPORT=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_PHYLIB=y CONFIG_PHY_AQUANTIA=y
configs/imx95_evk.config +1 -0
@@ -121,6 +121,7 @@ CONFIG_MMC_HS400_SUPPORT=y CONFIG_FSL_USDHC=y CONFIG_MTD=y CONFIG_DM_SPI_FLASH=y +CONFIG_SPI_FLASH_SFDP_SUPPORT=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_MT35XU=y CONFIG_PHYLIB=y
Signature · 1 line
2.43.0
PATCH v3 4/6 board: nxp: imx9{4, 5, 52}_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_IMX_QB option is enabled. This makes sure qb_save is called before any image loading is done by the SPL. This option is also suitable for the case where U-Boot proper is missing (Falcon mode).
qb save refers to saving DDR training data to NVM, so that OEI runs Quickboot flow on next reboot, skipping full training and achieveing a lower boot time.
--- arch/arm/mach-imx/Kconfig | 8 ++++++++ arch/arm/mach-imx/imx9/Makefile | 4 +++- board/nxp/imx94_evk/spl.c | 6 +++++- board/nxp/imx952_evk/spl.c | 4 ++++ board/nxp/imx95_evk/spl.c | 6 +++++- 5 files changed, 25 insertions(+), 3 deletions(-)
arch/arm/mach-imx/Kconfig +8 -0
@@ -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 SPL_IMX_QB + bool "Run qb save during SPL" + depends on SPL && (IMX94 || IMX95 || IMX952) + help + Automatically save DDR training data (Quickboot data) + to current boot device when needed (when OEI runs Training + flow and saves qb data to volatile memory). + config CMD_IMX_QB bool "Support the 'qb' command" default y
arch/arm/mach-imx/imx9/Makefile +3 -1
@@ -14,6 +14,8 @@ ifneq ($(CONFIG_SPL_BUILD),y) obj-y += imx_bootaux.o endif -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
board/nxp/imx94_evk/spl.c +5 -1
@@ -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 (); }static void xspi_nor_reset (void )
board/nxp/imx952_evk/spl.c +4 -0
@@ -8,6 +8,7 @@#include <asm/gpio.h> #include <asm/mach-imx/boot_mode.h> #include <asm/mach-imx/ele_api.h> +#include <asm/mach-imx/qb.h> #include <asm/sections.h> #include <hang.h> #include <init.h>
@@ -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 (); }static void xspi_nor_reset (void )
board/nxp/imx95_evk/spl.c +5 -1
@@ -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
PATCH v3 5/6 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 and explain the saving
process.
--- doc/board/nxp/index.rst | 1 + doc/board/nxp/qb.rst | 54 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 doc/board/nxp/qb.rst
doc/board/nxp/index.rst +1 -0
@@ -30,3 +30,4 @@ NXP Semiconductors mx6ullevk rproc psb + qb
doc/board/nxp/qb.rst new file +54 -0
54 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v3 6/6 drivers: ddr: imx: Fix Kconfig for SAVED_DRAM_TIMING_BASE
In reply to Simona Toaca (OSS)From: Simona Toaca <[email protected]>
The 'default' directive should be before 'help'.
--- drivers/ddr/imx/imx9/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ddr/imx/imx9/Kconfig +1 -1
@@ -24,10 +24,10 @@ config IMX9_DRAM_INLINE_ECC config SAVED_DRAM_TIMING_BASE hex "Define the base address for saved dram timing" + default 0x2051C000 help after DRAM is trained, need to save the dram related timming info into memory for low power use. - default 0x2051C000 config QB_SAVED_STATE_BASE hex "Define the base address for saved QuickBoot state"
Signature · 1 line
2.43.0
Re: [PATCH v3 1/6] imx9: Add support for saving DDR training data to NVM
In reply to Simona Toaca (OSS)Quoted 11 lines · Simona Toaca (OSS)
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.
U-Boot only checks for data integrity (CRC32), while OEI is in charge of authentication when it tries to load the data from NVM.
On iMX95 A0/A1, 'authentication' is done via another CRC32. On the other boards, authentication is done by
On the other ... SoC revisions (not boards) , ... ?
[...]
Quoted 16 lines
+++
b/arch/arm/include/asm/arch-imx9/ddr.harch/arm/include/asm/arch-imx9/ddr.h +4
-1@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0+ */ /* -* Copyright 2022 NXP +* Copyright 2022-2026 NXP */ #ifndef __ASM_ARCH_IMX8M_DDR_H@@ -100,6 +100,52 @@ struct dram_timing_info {extern struct dram_timing_info dram_timing; +/* Quick Boot related */ +#define DDRPHY_QB_CSR_SIZE 5168 +#define DDRPHY_QB_ACSM_SIZE (4 * 1024)
arch/arm/include/asm/arch-imx9/ddr.h struct dram_timing_info { · line 115
Quoted 10 lines
arch/arm/include/asm/arch-imx9/ddr.h +10
-0+#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 */
Please indent with tabs.
Quoted 1 line
arch/arm/include/asm/arch-imx9/ddr.h +1
-0+u32 mac[MAC_LENGTH ];/* For 95A0/1 use mac[0] to keep CRC32 value */
[...]
Quoted 5 lines
+++
b/arch/arm/include/asm/mach-imx/qb.harch/arm/include/asm/mach-imx/qb.h new file +3
-0@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright 2026 NXP
arch/arm/include/asm/mach-imx/qb.h line 13
Quoted 10 lines
arch/arm/include/asm/mach-imx/qb.h new file +10
-0+*/ + +#ifndef __IMX_QB_H__ +#define __IMX_QB_H__ + +#include <stdbool.h> + +bool qb_check (void ); +int qb (int qb_dev,bool save); +void spl_qb_save (void );
Please call the functions something less opaque than "qb()" , imx_qb_*() would alrady be so much better.
[...]
Quoted 56 lines
arch/arm/mach-imx/imx9/qb.c new file +50
-0@@ -0,0 +1,379 @@ +// SPDX-License-Identifier: GPL-2.0+ +/** +* Copyright 2024-2026 NXP +*/ +#include <dm/device-internal.h> +#include <dm/uclass.h> +#include <errno.h> +#include <imx_container.h> +#include <linux/bitfield.h> +#include <mmc.h> +#include <spi_flash.h> +#include <spl.h> +#include <stdlib.h> +#include <u-boot/crc.h> + +#include <asm/arch/ddr.h> +#include <asm/mach-imx/boot_mode.h> +#include <asm/mach-imx/sys_proto.h> + +#define QB_STATE_LOAD_SIZE SZ_64K + +#define MMC_DEV 0 +#define QSPI_DEV 1 + +#define IMG_FLAGS_IMG_TYPE_MASK 0xF +#define IMG_FLAGS_IMG_TYPE (x) FIELD_GET(IMG_FLAGS_IMG_TYPE_MASK, (x)) + +#define IMG_TYPE_DDR_TDATA_DUMMY 0xD/* dummy DDR training data image */ + +bool qb_check (void ) +{ +struct ddrphy_qb_state *qb_state; +u32 size, crc; + +/** +* Ensure CRC is not empty, the reason is that +* the data is invalidated after first save run +* or after it is overwritten. +*/ + qb_state = (struct ddrphy_qb_state *)CONFIG_QB_SAVED_STATE_BASE ; + size =sizeof (struct ddrphy_qb_state ) -sizeof (qb_state->crc); + crc =crc32 (0 , (u8 *)qb_state->mac, size); + +if (!qb_state->crc || crc != qb_state->crc) +return false; + +return true; +} + +static unsigned long qb_get_boot_device_offset (void *dev,int dev_type)
arch/arm/mach-imx/imx9/qb.c line 60
Quoted 10 lines
arch/arm/mach-imx/imx9/qb.c new file +10
-0+{ +unsigned long offset =0 ; +struct mmc *mmc; + +switch (dev_type) { +case MMC_DEV : + mmc = dev; + +if (IS_SD (mmc) || mmc->part_config ==MMCPART_NOAVAILABLE ) { + offset =CONTAINER_HDR_MMCSD_OFFSET ;
Multiple return in this case will make the function simpler:
return CONTAINER_HDR_MMCSD_OFFSET;
arch/arm/mach-imx/imx9/qb.c line 61
Quoted 1 line
arch/arm/mach-imx/imx9/qb.c new file +1
-0+ }else {
No need for } else { anymore.
arch/arm/mach-imx/imx9/qb.c line 65
Quoted 4 lines
arch/arm/mach-imx/imx9/qb.c new file +4
-0+u8 part =EXT_CSD_EXTRACT_BOOT_PART (mmc->part_config); + +if (part ==EMMC_BOOT_PART_BOOT1 || part ==EMMC_BOOT_PART_BOOT2 ) + offset =CONTAINER_HDR_EMMC_OFFSET ;
return CONTAINER_HDR_EMMC_OFFSET;
arch/arm/mach-imx/imx9/qb.c line 67
Quoted 2 lines
arch/arm/mach-imx/imx9/qb.c new file +2
-0+else + offset =CONTAINER_HDR_MMCSD_OFFSET ;
return CONTAINER_HDR_MMCSD_OFFSET;
Quoted 11 lines
arch/arm/mach-imx/imx9/qb.c new file +11
-0+ } +break ; +case QSPI_DEV : + offset =CONTAINER_HDR_QSPI_OFFSET ; +break ; +default : +return -EOPNOTSUPP ; + } + +return offset; +}
[...]
arch/arm/mach-imx/imx9/qb.c line 119
Quoted 6 lines
arch/arm/mach-imx/imx9/qb.c new file +6
-0+static int get_dev_qbdata_offset (void *dev,int dev_type,unsigned long offset, +u32 *qbdata_offset) +{ +int ret = -EOPNOTSUPP ; +u16 ctnr_hdr_align =CONTAINER_HDR_ALIGNMENT ; +void *buf =kmalloc (ctnr_hdr_align,GFP_KERNEL );
Can you use buffer on stack ? u8 buf[CONTAINER_HDR_ALIGNMENT]; ? That would allow you to remove all the goto statements.
If not, use malloc() not kmalloc().
arch/arm/mach-imx/imx9/qb.c line 122
Quoted 2 lines
arch/arm/mach-imx/imx9/qb.c new file +2
-0+if (!buf) { +printf ("kmalloc buffer failed\n" );
if malloc fails, so will printing, so drop this print and return -ENOMEM only.
Quoted 45 lines
arch/arm/mach-imx/imx9/qb.c new file +45
-0+return -ENOMEM ; + } + +switch (dev_type) { +case MMC_DEV : +unsigned long count =0 ; +struct mmc *mmc = dev; + +if (!(CONFIG_IS_ENABLED (DM_MMC ) &&CONFIG_IS_ENABLED (MMC_WRITE ))) + goto get_dev_qbdata_offset_exit; + + count =blk_dread (mmc_get_blk_desc (mmc), + offset / mmc->read_bl_len, + ctnr_hdr_align / mmc->read_bl_len, + buf); +if (count ==0 ) { +printf ("Read container image from MMC/SD failed\n" ); + ret = -EIO ; + goto get_dev_qbdata_offset_exit; + } +break ; +case QSPI_DEV : +if (!CONFIG_IS_ENABLED (SPI )) + goto get_dev_qbdata_offset_exit; + + ret =spi_flash_read (dev, offset, + ctnr_hdr_align, buf); +if (ret) { +printf ("Read container header from QSPI failed\n" ); + ret = -EIO ; + goto get_dev_qbdata_offset_exit; + } +break ; +default : +printf ("Support for device %d not enabled\n" , dev_type); + goto get_dev_qbdata_offset_exit; + } + + ret =qb_parse_container (buf, qbdata_offset); + +get_dev_qbdata_offset_exit: +free (buf); + +return ret; +}
[...]
arch/arm/mach-imx/imx9/qb.c line 377
Quoted 6 lines
arch/arm/mach-imx/imx9/qb.c new file +6
-0+void spl_qb_save (void ) +{ +int dev =spl_boot_device (); + +/* Save QB data on current boot device */ +if (qb (dev, true))
Please call this function something less opaque than "qb()" , pick something more descriptive.
Quoted 2 lines
arch/arm/mach-imx/imx9/qb.c new file +2
-0+printf ("QB save failed\n" ); +}
[...]
Re: [PATCH v3 2/6] arm: mach-imx: Add command to expose QB functionality
In reply to Simona Toaca (OSS)On 4/2/26 11:40 AM, Simona Toaca (OSS) wrote:
[...]
Quoted 11 lines
arch/arm/mach-imx/cmd_qb.c new file +11
-0+static void parse_qb_args (int argc,char *const argv[], +int *qb_dev,int qb_bootdev) +{ +long dev =-1 ; +char *interface ="" ; + +if (argc <2 ) { +/* qb save -> use boot device */ + *qb_dev = qb_bootdev; + }else { + interface = argv[1 ];
arch/arm/mach-imx/cmd_qb.c line 51
Quoted 10 lines
arch/arm/mach-imx/cmd_qb.c new file +10
-0+ } + +if (argc ==3 ) + dev =simple_strtol (argv[2 ],NULL ,10 ); + +if (!strcmp (interface,"mmc" ) && dev >=0 && + dev <= (BOOT_DEVICE_MMC2_2 -BOOT_DEVICE_MMC1 )) + *qb_dev =BOOT_DEVICE_MMC1 + dev; +else if (!strcmp (interface,"spi" )) + *qb_dev =BOOT_DEVICE_SPI ;
if (!strcmp(interface, "spi")) {
*qb_dev = BOOT_DEVICE_SPI;
} else {
blk_get_device_by_str(interface, argv[2], ...); -> This will handle all block devices and all block device
names and format strings of those, no need to write yet another ad-hoc decoder for those by hand. Then use blk_dread()/blk_dwrite() to access block storage.
}
[...]
Re: [PATCH v3 3/6] configs: imx9{43, 5}: Enable SPI SFDP support
In reply to Simona Toaca (OSS)Quoted 7 lines · Simona Toaca (OSS)
From: Simona Toaca <[email protected]>
In the context of saving Quickboot data to SPI
NOR, this option needs to be enabled so that the
erase size is parsed correctly.Signed-off-by Simona Toaca <[email protected]>
This really has nothing to do with quickboot, this is a generic fix, so please send this separately with updated commit message, so it can go in quickly.
Re: [PATCH v3 4/6] board: nxp: imx9{4,5,52}_evk: Add qb save option in SPL
In reply to Simona Toaca (OSS)On 4/2/26 11:40 AM, Simona Toaca (OSS) wrote:
[...]
Quoted 21 lines
+++ b/arch/arm/mach-imx/Kconfig
arch/arm/mach-imx/Kconfig +8
-0@@ -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 SPL_IMX_QB + bool "Run qb save during SPL" + depends on SPL && (IMX94 || IMX95 || IMX952) + help + Automatically save DDR training data (Quickboot data) + to current boot device when needed (when OEI runs Training + flow and saves qb data to volatile memory). + config CMD_IMX_QB bool "Support the 'qb' command" default yarch/arm/mach-imx/imx9/Makefile +0
-0
arch/arm/mach-imx/imx9/Makefile ifneq ($(CONFIG_SPL_BUILD),y) · line 21
Quoted 9 lines
arch/arm/mach-imx/imx9/Makefile +3
-1@@ -14,6 +14,8 @@ ifneq ($(CONFIG_SPL_BUILD),y) obj-y += imx_bootaux.o endif -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
The qb.o should not be gated beyond CONFIG_CMD_IMX_QB , the CONFIG_CMD_IMX_QB is used to gate cmd_qb.o . Fix this and introduce CONFIG_IMX_QB to gate the core code, then do this to simplify the conditional:
obj-$(CONFIG_$(PHASE_)IMX_QB += qb.o
...
Also, changes to arch/ should be part of 1/6 .
Re: [PATCH v3 6/6] drivers: ddr: imx: Fix Kconfig for SAVED_DRAM_TIMING_BASE
In reply to Simona Toaca (OSS)Quoted 5 lines · Simona Toaca (OSS)
From: Simona Toaca <[email protected]>
The 'default' directive should be before 'help'.
Signed-off-by Simona Toaca <[email protected]>
Please send this fix separately, so this can go in quickly. Thanks
Re: [PATCH v3 5/6] doc: board: nxp: Add Quickboot documentation
In reply to Simona Toaca (OSS)On 4/2/26 11:40 AM, Simona Toaca (OSS) wrote:
[...]
doc/board/nxp/qb.rst line 7
Quoted 4 lines
doc/board/nxp/qb.rst new file +4
-0+DDR QuickBoot flow +------------------ + +Some NXP boards (which use OEI - iMX943, iMX95, iMX952 etc.) support saving
boards or SoCs ? I think SoCs ?
doc/board/nxp/qb.rst line 20
Quoted 13 lines
doc/board/nxp/qb.rst new file +13
-0+DDR training data (collected by OEI during Training flow) from volatile +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. + +The location of the qb data in NVM is a space left in the bootloader by +mkimage, with the size of 64K. The qb command searches for this space to +save the data. Thus, the NVM should also be a boot device. + +U-Boot provides no authentication for qb data, only its integrity +is verified via the CRC32. The authentication is done in OEI. With +the exception of iMX95 A0/A1, which use CRC32 as well for verifying +the data, the rest of the boards use ELE to verify the MAC stored
SoCs or SoC revisions ?
[...]
Quoted 6 lines
+2. using qb command in U-Boot console (by enabling
CONFIG_CMD_IMX_QB)doc/board/nxp/qb.rst new file +5
-0+ +- 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) +- use 'qb erase' to force DDR re-training +- use for: saving qb data during flashing / controlling the NVM to save to / forcing re-training
doc/board/nxp/qb.rst line 54
Quoted 10 lines
doc/board/nxp/qb.rst new file +10
-0+ +:: + + # 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
It would be good to have a way to instruct QB to save the data into backup location.
Fabio Estevam
reviewerRe: [PATCH v3 5/6] doc: board: nxp: Add Quickboot documentation
In reply to Simona Toaca (OSS)doc/board/nxp/index.rst NXP Semiconductors · line 33
Quoted 9 lines · Simona Toaca (OSS)
doc/board/nxp/index.rst +1
-0@@ -30,3 +30,4 @@ NXP Semiconductors mx6ullevk rproc psb + qb
'qb' is too cryptic. Please spell it as 'Quickboot'
doc/board/nxp/qb.rst
Quoted 1 line
doc/board/nxp/qb.rst +0
-0
Same here: quickboot.rst
doc/board/nxp/qb.rst line 7
Quoted 12 lines
new file mode 100644
index 00000000000..07953a1b7e9doc/board/nxp/qb.rst new file +7
-0@@ -0,0 +1,54 @@ +.. SPDX-License-Identifier: GPL-2.0+ + Copyright 2026 NXP + +DDR QuickBoot flow +------------------ + +Some NXP boards (which use OEI - iMX943, iMX95, iMX952 etc.) support saving
s/boards/SoCs
doc/board/nxp/qb.rst line 13
Quoted 6 lines
doc/board/nxp/qb.rst new file +6
-0+DDR training data (collected by OEI during Training flow) from volatile +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. + +The location of the qb data in NVM is a space left in the bootloader by
Please use 'Quickboot' for consistency and clarity throughout this document.
Re: [PATCH v3 1/6] imx9: Add support for saving DDR training data to NVM
In reply to Simona Toaca (OSS)Hi,
Quoted 21 lines · Simona Toaca (OSS)
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.
U-Boot only checks for data integrity (CRC32), while OEI is in charge of authentication when it tries to load the data from NVM.
On iMX95 A0/A1, 'authentication' is done via another CRC32. On the other boards, authentication is done by using ELE to check the MAC stored in the
ddrphy_qb_statestructure.Supported platforms: iMX94, iMX95, iMX952 (using OEI) Supported storage types: eMMC, SD, SPI flash.
Signed-off-by Viorel Suman <[email protected]>Signed-off-by Ye Li <[email protected]>Signed-off-by Simona Toaca <[email protected]>
Quoted 10 lines
--- arch/arm/include/asm/arch-imx9/ddr.h | 48 +++- arch/arm/include/asm/mach-imx/qb.h | 15 ++ arch/arm/mach-imx/imx9/Makefile | 6 +- arch/arm/mach-imx/imx9/qb.c | 379 +++++++++++++++++++++++++++ arch/arm/mach-imx/imx9/scmi/soc.c | 7 + drivers/ddr/imx/imx9/Kconfig | 7 + 6 files changed, 459 insertions(+), 3 deletions(-) create mode 100644 arch/arm/include/asm/mach-imx/qb.h create mode 100644 arch/arm/mach-imx/imx9/qb.c
Note that this feature is present on x86 boards already.
I wonder if we could make this more generic? E.g. it could be a function of UCLASS_RAM ? I could do the x86 part to try it out if you like.
Regards,
Simon
Re: [PATCH v3 1/6] imx9: Add support for saving DDR training data to NVM
Hi Simon,
Quoted 36 lines · Simon Glass
Hi,
Quoted 21 lines · Simona Toaca (OSS)
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.
U-Boot only checks for data integrity (CRC32), while OEI is in charge of authentication when it tries to load the data from NVM.
On iMX95 A0/A1, 'authentication' is done via another CRC32. On the other boards, authentication is done by using ELE to check the MAC stored in the
ddrphy_qb_statestructure.Supported platforms: iMX94, iMX95, iMX952 (using OEI) Supported storage types: eMMC, SD, SPI flash.
Signed-off-by Viorel Suman <[email protected]>Signed-off-by Ye Li <[email protected]>Signed-off-by Simona Toaca <[email protected]>Quoted 10 lines
--- arch/arm/include/asm/arch-imx9/ddr.h | 48 +++- arch/arm/include/asm/mach-imx/qb.h | 15 ++ arch/arm/mach-imx/imx9/Makefile | 6 +- arch/arm/mach-imx/imx9/qb.c | 379 +++++++++++++++++++++++++++ arch/arm/mach-imx/imx9/scmi/soc.c | 7 + drivers/ddr/imx/imx9/Kconfig | 7 + 6 files changed, 459 insertions(+), 3 deletions(-) create mode 100644 arch/arm/include/asm/mach-imx/qb.h create mode 100644 arch/arm/mach-imx/imx9/qb.c
Quoted 6 lines
Note that this feature is present on x86 boards already.
I wonder if we could make this more generic? E.g. it could be a function of
UCLASS_RAM? I could do the x86 part to try it out if you like.
Can you please point me to the implementation for x86? This Quickboot feature is specific to Synopsis DDR PHYs, and the location where we save this data is specific to iMX9 series (since it is needed by OEI). I need a bit more details about what you mean.
Thank you,
Simona
Re: [PATCH v3 1/6] imx9: Add support for saving DDR training data to NVM
Hi Simona,
Quoted 47 lines · Simona Toaca
Hi Simon,
Quoted 36 lines · Simon Glass
Hi,
Quoted 21 lines · Simona Toaca (OSS)
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.
U-Boot only checks for data integrity (CRC32), while OEI is in charge of authentication when it tries to load the data from NVM.
On iMX95 A0/A1, 'authentication' is done via another CRC32. On the other boards, authentication is done by using ELE to check the MAC stored in the
ddrphy_qb_statestructure.Supported platforms: iMX94, iMX95, iMX952 (using OEI) Supported storage types: eMMC, SD, SPI flash.
Signed-off-by Viorel Suman <[email protected]>Signed-off-by Ye Li <[email protected]>Signed-off-by Simona Toaca <[email protected]>Quoted 10 lines
--- arch/arm/include/asm/arch-imx9/ddr.h | 48 +++- arch/arm/include/asm/mach-imx/qb.h | 15 ++ arch/arm/mach-imx/imx9/Makefile | 6 +- arch/arm/mach-imx/imx9/qb.c | 379 +++++++++++++++++++++++++++ arch/arm/mach-imx/imx9/scmi/soc.c | 7 + drivers/ddr/imx/imx9/Kconfig | 7 + 6 files changed, 459 insertions(+), 3 deletions(-) create mode 100644 arch/arm/include/asm/mach-imx/qb.h create mode 100644 arch/arm/mach-imx/imx9/qb.cQuoted 6 lines
Note that this feature is present on x86 boards already.
I wonder if we could make this more generic? E.g. it could be a function of
UCLASS_RAM? I could do the x86 part to try it out if you like.
Quoted 4 lines
Can you please point me to the implementation for x86? This Quickboot feature is specific to Synopsis DDR PHYs, and the location where we save this data is specific to iMX9 series (since it is needed by OEI). I need a bit more details about what you mean.
Yes, if you look at mrccache_save() you will see how this works. It is controlled by a flash layout within the SPI-flash node:
spi: spi {
#address-cells = <1>;
#size-cells = <0>;
compatible = "intel,ich9-spi";
spi-flash@0 {
#address-cells = <1>;
#size-cells = <1>;
reg = <0>;
m25p,fast-read;
compatible = "winbond,w25q64dw",
"jedec,spi-nor";
memory-map = <0xff800000 0x00800000>;
rw-mrc-cache {
label = "rw-mrc-cache";
reg = <0x005e0000 0x00010000>;
};
};};
Regards,
Simon
Re: [PATCH v3 1/6] imx9: Add support for saving DDR training data to NVM
Hi,
Quoted 20 lines · Simon Glass
Hi Simona,
Quoted 17 lines · Simona Toaca
Hi Simon,
Quoted 13 lines · Simon Glass
Hi,
Quoted 9 lines · Simona Toaca (OSS)
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.
U-Boot only checks for data integrity (CRC32), while OEI is in charge of authentication when it tries to load the data from NVM.
[ ... ]
Quoted 15 lines
Quoted 11 lines
Quoted 6 lines
Note that this feature is present on x86 boards already.
I wonder if we could make this more generic? E.g. it could be a function of
UCLASS_RAM? I could do the x86 part to try it out if you like.Can you please point me to the implementation for x86? This Quickboot feature is specific to Synopsis DDR PHYs, and the location where we save this data is specific to iMX9 series (since it is needed by OEI). I need a bit more details about what you mean.
Yes, if you look at
mrccache_save()you will see how this works. It is controlled by a flash layout within the SPI-flash node:
Quoted 15 lines
spi: spi {
#address-cells = <1>;
#size-cells = <0>;
compatible = "intel,ich9-spi";
spi-flash@0 {
#address-cells = <1>;
#size-cells = <1>;
reg = <0>;
m25p,fast-read;
compatible = "winbond,w25q64dw",
"jedec,spi-nor";
memory-map = <0xff800000 0x00800000>;
rw-mrc-cache {
label = "rw-mrc-cache";
reg = <0x005e0000 0x00010000>;[ ... ]
Sorry for the late reply.
By 'UCLASS_RAM' you mean having a SoC-specific RAM driver (e.g. 'imx9_dram') that implements 'get_info' and a set of methods for training data check/save/erase?
mrccache does not have the checking/erasing option, but it has mrccache_reserve/mrccache_get_region public methods that do not have an equivalent in quickboot.
In this context, it feels like the exposed methods for dealing with training data do not have a unified interface, so in reality the only common ground is the 'save' method, and that would also need parameters for specifying the boot device to save to (as this is an option in qb, but not in mrc).
Also, because you mentioned the SPI flash node for specifying the saving location in SPI, this wouldn't work for the i.MX quickboot implementation. The saving location is a space in the bootloader that depends on the other components' sizes, so it is not a fixed addres.
Best regards,
Simona
Re: [PATCH v3 1/6] imx9: Add support for saving DDR training data to NVM
Hi Simona,
Quoted 76 lines · Simona Toaca
Hi,
Quoted 20 lines · Simon Glass
Hi Simona,
Quoted 17 lines · Simona Toaca
Hi Simon,
Quoted 13 lines · Simon Glass
Hi,
Quoted 9 lines · Simona Toaca (OSS)
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.
U-Boot only checks for data integrity (CRC32), while OEI is in charge of authentication when it tries to load the data from NVM.
[ ... ]
Quoted 15 lines
Quoted 11 lines
Quoted 6 lines
Note that this feature is present on x86 boards already.
I wonder if we could make this more generic? E.g. it could be a function of
UCLASS_RAM? I could do the x86 part to try it out if you like.Can you please point me to the implementation for x86? This Quickboot feature is specific to Synopsis DDR PHYs, and the location where we save this data is specific to iMX9 series (since it is needed by OEI). I need a bit more details about what you mean.
Yes, if you look at
mrccache_save()you will see how this works. It is controlled by a flash layout within the SPI-flash node:Quoted 15 lines
spi: spi { #address-cells = <1>; #size-cells = <0>; compatible = "intel,ich9-spi"; spi-flash@0 { #address-cells = <1>; #size-cells = <1>; reg = <0>; m25p,fast-read; compatible = "winbond,w25q64dw", "jedec,spi-nor"; memory-map = <0xff800000 0x00800000>; rw-mrc-cache { label = "rw-mrc-cache"; reg = <0x005e0000 0x00010000>;[ ... ]
Sorry for the late reply.
By '
UCLASS_RAM' you mean having a SoC-specific RAM driver (e.g. 'imx9_dram') that implements 'get_info' and a set of methods for training data check/save/erase?mrccache does not have the checking/erasing option, but it has mrccache_reserve/mrccache_get_region public methods that do not have an equivalent in quickboot.
In this context, it feels like the exposed methods for dealing with training data do not have a unified interface, so in reality the only common ground is the 'save' method, and that would also need parameters for specifying the boot device to save to (as this is an option in qb, but not in mrc).
Quoted 4 lines
Also, because you mentioned the SPI flash node for specifying the saving location in SPI, this wouldn't work for the i.MX quickboot implementation. The saving location is a space in the bootloader that depends on the other components' sizes, so it is not a fixed addres.
Yes that's what I mean by uclass RAM. Yes, at the moment it does not have methods for caching the parameters, but it could be added.
If you have the energy and interest to design something here, please do. I could convert x86 over to use it.
But it's up to you.
Regards,
Simon