imx9{4,5,52}: Add Quickboot support
Subsystems (3)
v4 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 v4:
- add IMX_QB macro to include qb.c based on the boot phase
- change qb_ prefix to imx_qb_ for qb.c methods, to
be more specific
- add boot device macro to string conversion for the case where the device is not explicitly specified
- pass quickboot args as strings and parse them in qb.c using blk_device_get_by_str/blk_device_part_str (if they are blk devices). This enables specifying mmc 0:2 for the boot1 partition of the eMMC device.
- use blk device API instead of mmc-specific
- use SPI DM methods for spi flash read/write
- use malloc for storing container header instead of kmalloc
- add eMMC hwpart usage to the documentation
- sent the qb-unrelated patches separately
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 (4):
imx9: Add support for saving DDR training data to NVM
arm: mach-imx: Add command to expose QB functionality
board: nxp: imx9{4,5,52}_evk: Add qb save option in SPL
doc: board: nxp: Add Quickboot documentation
arch/arm/include/asm/arch-imx9/ddr.h | 48 +++- arch/arm/include/asm/mach-imx/qb.h | 15 + arch/arm/mach-imx/Kconfig | 28 ++ arch/arm/mach-imx/Makefile | 1 + arch/arm/mach-imx/cmd_qb.c | 102 +++++++ arch/arm/mach-imx/imx9/Makefile | 6 +- arch/arm/mach-imx/imx9/qb.c | 403 +++++++++++++++++++++++++++ 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 +- doc/board/nxp/index.rst | 1 + doc/board/nxp/quickboot.rst | 59 ++++ drivers/ddr/imx/imx9/Kconfig | 7 + 14 files changed, 688 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/quickboot.rst
Signature · 1 line
2.43.0
PATCH v4 1/4 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 SoCs, 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/Kconfig | 9 + arch/arm/mach-imx/imx9/Makefile | 6 +- arch/arm/mach-imx/imx9/qb.c | 403 +++++++++++++++++++++++++++ arch/arm/mach-imx/imx9/scmi/soc.c | 7 + drivers/ddr/imx/imx9/Kconfig | 7 + 7 files changed, 492 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 imx_qb_check (void ); +int imx_qb (const char *ifname,const char *dev,bool save); +void spl_imx_qb_save (void ); + +#endif
arch/arm/mach-imx/Kconfig +9 -0
@@ -71,6 +71,15 @@ config CSF_SIZE Define the maximum size for Command Sequence File (CSF) binary this information is used to define the image boot data. +config IMX_QB + bool "Support Quickboot flow for Synopsis DDR PHY on iMX platforms" + default y + depends on IMX94 || IMX95 || IMX952 + help + Enable the logic for saving DDR training data from volatile + memory to non-volatile storage. OEI uses the saved data to + run Quickboot flow and skip re-training the DDR PHY. + config CMD_BMODE bool "Support the 'bmode' command" default y
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-$(CONFIG_$(PHASE_)IMX_QB) += qb.o
arch/arm/mach-imx/imx9/qb.c new file +403 -0
403 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 after DRAM is trained, need to save the dram related timming info into memory for low power use. +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
Re: [PATCH v4 1/4] imx9: Add support for saving DDR training data to NVM
Quoted 30 lines · Simona Toaca (OSS)
From: Simona Toaca <[email protected]>
arch/arm/include/asm/arch-imx9/ddr.h +28
-0+/** +* 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;
arch/arm/include/asm/arch-imx9/ddr.h struct dram_timing_info { · line 147
Quoted 10 lines
arch/arm/include/asm/arch-imx9/ddr.h +10
-0+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 ]; +};
Hi Simona,
Would you consider reserving a small u16 board-defined field at the end of struct ddrphy_qb_state? Something like:
u16 board_ddr_config; /* board-defined tag, opaque to U-Boot */
Use case: boards that carry multiple LPDDR configurations (single-/dual-rank, different sizes, ...). At QuickBoot time the boot code needs to know which configuration produced the persisted PHY training data, in order to load the matching timing table before DDRC init, in OEI. A 16-bit board-defined identifier is enough; the value is opaque to U-Boot.
A generic placeholder is equally fine for our purpose, so each board/vendor can use it as they see fit.
Cost on the persisted blob is essentially zero: mac[] (u32) forces 4-byte struct alignment, which already leaves 2 bytes of trailing padding in the current layout. Adding a u16 field there does not change sizeof(struct ddrphy_qb_state) nor the on-storage size.
Thanks,
Emanuele
Re: [PATCH v4 1/4] imx9: Add support for saving DDR training data to NVM
Hello Emanuele,
Quoted 14 lines · Emanuele Ghidoli
Quoted 11 lines · Simona Toaca (OSS)
From: Simona Toaca <[email protected]>
arch/arm/include/asm/arch-imx9/ddr.h +9
-0+/** +* 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;
[...]
Quoted 9 lines
arch/arm/include/asm/arch-imx9/ddr.h struct dram_timing_info { · line 147
Quoted 3 lines
arch/arm/include/asm/arch-imx9/ddr.h +3
-0+u16 acsm[DDRPHY_QB_ACSM_SIZE ]; +u16 pst[DDRPHY_QB_PST_SIZE ]; +};Hi Simona,
Would you consider reserving a small u16 board-defined field at the end of struct
ddrphy_qb_state? Something like:
Quoted 9 lines
u16
board_ddr_config; /* board-defined tag, opaque to U-Boot */Use case: boards that carry multiple LPDDR configurations (single-/dual-rank, different sizes, ...). At QuickBoot time the boot code needs to know which configuration produced the persisted PHY training data, in order to load the matching timing table before DDRC init, in OEI. A 16-bit board-defined identifier is enough; the value is opaque to U-Boot.
I am taking into consideration adding such a field into qb_state in the future, but for now we do not support a mechanism for deciding the dram timing at runtime.
Quoted 8 lines
A generic placeholder is equally fine for our purpose, so each board/vendor can use it as they see fit.
Cost on the persisted blob is essentially zero: mac[] (u32) forces 4-byte struct alignment, which already leaves 2 bytes of trailing padding in the current layout. Adding a u16 field there does not change
sizeof(struct ddrphy_qb_state)nor the on-storage size.
It means that U-Boot will save those 2 bytes anyway into NVM, so as long as no other changes are made to the structure, it should be ok for your usecase.
Best regards,
Simona
Re: [PATCH v4 1/4] imx9: Add support for saving DDR training data to NVM
Quoted 35 lines · Simona Toaca
Quoted 14 lines · Emanuele Ghidoli
Quoted 11 lines · Simona Toaca (OSS)
From: Simona Toaca <[email protected]>
arch/arm/include/asm/arch-imx9/ddr.h +9
-0+/** +* 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;[...]
Quoted 9 lines
arch/arm/include/asm/arch-imx9/ddr.h struct dram_timing_info { · line 147
Quoted 3 lines
arch/arm/include/asm/arch-imx9/ddr.h +3
-0+u16 acsm[DDRPHY_QB_ACSM_SIZE ]; +u16 pst[DDRPHY_QB_PST_SIZE ]; +};Hi Simona,
Would you consider reserving a small u16 board-defined field at the end of struct
ddrphy_qb_state? Something like:Quoted 9 lines
u16
board_ddr_config; /* board-defined tag, opaque to U-Boot */Use case: boards that carry multiple LPDDR configurations (single-/dual-rank, different sizes, ...). At QuickBoot time the boot code needs to know which configuration produced the persisted PHY training data, in order to load the matching timing table before DDRC init, in OEI. A 16-bit board-defined identifier is enough; the value is opaque to U-Boot.
Quoted 3 lines
I am taking into consideration adding such a field into
qb_statein the future, but for now we do not support a mechanism for deciding the dram timing at runtime.
The reality is that we are forking your OEI (AFAIK you do not take patches) to support our boards and our use case. So we (Toradex) have it already, and it is working 100% fine.
What is tricky here is that this structure is an ABI / contract between the OEI firmware and U-Boot.
Just to anticipate your potential answer, our boards just work with mainline U-Boot, so asking us to have a patch and fork U-Boot is not an option.
Francesco
Re: [PATCH v4 1/4] imx9: Add support for saving DDR training data to NVM
In reply to Simona Toaca (OSS)Quoted 45 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 SoCs, 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]>--- arch/arm/include/asm/arch-imx9/ddr.h | 48 +++- arch/arm/include/asm/mach-imx/qb.h | 15 + arch/arm/mach-imx/Kconfig | 9 + arch/arm/mach-imx/imx9/Makefile | 6 +- arch/arm/mach-imx/imx9/qb.c | 403 +++++++++++++++++++++++++++ arch/arm/mach-imx/imx9/scmi/soc.c | 7 + drivers/ddr/imx/imx9/Kconfig | 7 + 7 files changed, 492 insertions(+), 3 deletions(-) create mode 100644 arch/arm/include/asm/mach-imx/qb.h create mode 100644 arch/arm/mach-imx/imx9/qb.carch/arm/include/asm/arch-imx9/ddr.h +1
-1@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0+ */ /* -* Copyright 2022 NXP +* Copyright 2022-2026 NXP */ #ifndef __ASM_ARCH_IMX8M_DDR_H
arch/arm/include/asm/arch-imx9/ddr.h struct dram_timing_info { · line 108
Quoted 9 lines
arch/arm/include/asm/arch-imx9/ddr.h +6
-0@@ -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)
[..]
Sorry for basic question, in case OEI layer changes format due to one of other reason then how you are making sure, struct ddrphy_qb_state is aligned
+ * This structure needs to be aligned with the one in OEI.
[..]
arch/arm/include/asm/arch-imx9/ddr.h struct dram_timing_info { · line 119
Quoted 11 lines
arch/arm/include/asm/arch-imx9/ddr.h +11
-0+ +bool imx_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. +*/
In case OEI layer using saved DDR training data, then will passed CRC will be zero ?
arch/arm/include/asm/arch-imx9/ddr.h struct dram_timing_info { · line 120
Quoted 1 line
arch/arm/include/asm/arch-imx9/ddr.h +1
-0+ qb_state = (struct ddrphy_qb_state *)CONFIG_QB_SAVED_STATE_BASE ;
If yes then you can return from here, if no CRC found instead of doing crc calculation.
Quoted 9 lines
arch/arm/include/asm/arch-imx9/ddr.h +9
-0+ 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; +} +
[..]
arch/arm/include/asm/arch-imx9/ddr.h
Quoted 6 lines
arch/arm/include/asm/arch-imx9/ddr.h +6
-0+ +void spl_imx_qb_save (void ) +{ +/* Save QB data on current boot device */ +if (imx_qb ("auto" ,"" , true)) +printf ("QB save failed\n" );
In case, of 3rd boot or so, there is no need to save training data, whereas you will return error, in case this feature is auto enabled.
Quoted 1 line
+}
[..]
Re: [PATCH v4 1/4] imx9: Add support for saving DDR training data to NVM
Hello Kumar,
Quoted 13 lines · Udit
Quoted 10 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 10 lines
arch/arm/include/asm/arch-imx9/ddr.h struct dram_timing_info { · line 108
Quoted 2 lines
arch/arm/include/asm/arch-imx9/ddr.h +2
-0+#define DDRPHY_QB_PSTATES 0 +#define DDRPHY_QB_PST_SIZE (DDRPHY_QB_PSTATES * 4 * 1024)[..]
Sorry for basic question, in case OEI layer changes format due to one of other reason then how you are making sure, structddrphy_qb_stateis aligned+ * This structure needs to be aligned with the one in OEI.
For now, the structure is stable. If anything changes, I will take care to update U-Boot accordingly.
Quoted 17 lines
[..]
arch/arm/mach-imx/imx9/qb.c line 84
Quoted 11 lines
arch/arm/mach-imx/imx9/qb.c new file +11
-0+ +bool imx_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. +*/ In case OEI layer using saved DDR training data, then will passed CRC will be zero ?
No, the data in DRAM isn't guaranteed to be 0 after 'qb save' and then reset. It is 0 only immediately after a successful 'qb save'.
Quoted 4 lines
arch/arm/mach-imx/imx9/qb.c line 85
Quoted 1 line
arch/arm/mach-imx/imx9/qb.c new file +1
-0+ qb_state = (struct ddrphy_qb_state *)CONFIG_QB_SAVED_STATE_BASE ;If yes then you can return from here, if no CRC found instead of doing crc calculation.
Agreed, but the CRC32 doesn't add significant overhead and, more often than not, the data will not be 0, but something else.
Quoted 11 lines
Quoted 10 lines
arch/arm/mach-imx/imx9/qb.c new file +9
-0+ 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; +} +[..]
Quoted 10 lines
arch/arm/mach-imx/imx9/qb.c line 402
Quoted 6 lines
arch/arm/mach-imx/imx9/qb.c new file +6
-0+ +void spl_imx_qb_save (void ) +{ +/* Save QB data on current boot device */ +if (imx_qb ("auto" ,"" , true)) +printf ("QB save failed\n" );In case, of 3rd boot or so, there is no need to save training data, whereas you will return error, in case this feature is auto enabled.
There is no way to tell from U-Boot if Quickboot flow was run or not, so that is why 'qb save' is tried everytime. The data in DRAM can be invalid for 2 reasons:
- it was saved by Training flow, but it got corrupted/got saved wrong
- Quickboot flow was run so no data was saved - this doesn't mean that the data in DRAM will be 0
Quoted 2 lines
Quoted 1 line
+}
[..]
Best regards,
Simona
Re: [PATCH v4 1/4] imx9: Add support for saving DDR training data to NVM
Hello Simona,
Quoted 21 lines · Simona Toaca
Quoted 11 lines · Udit
Quoted 10 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 8 lines
arch/arm/include/asm/arch-imx9/ddr.h struct dram_timing_info { · line 108
Quoted 2 lines
arch/arm/include/asm/arch-imx9/ddr.h +2
-0+#define DDRPHY_QB_PSTATES 0 +#define DDRPHY_QB_PST_SIZE (DDRPHY_QB_PSTATES * 4 * 1024)[..]
Sorry for basic question, in case OEI layer changes format due to one of other reason then how you are making sure, structddrphy_qb_stateis aligned
Quoted 4 lines
Quoted 2 lines
+ * This structure needs to be aligned with the one in OEI.
For now, the structure is stable. If anything changes, I will take care to update U-Boot accordingly.
Did you consider Emanuele's email in which he thinks that what we have today should already be changed?
And how do you handle a mix of U-Boot vs OEI version? How can you ensure that those are compatible? To me this is a mess. You are building an ABI between U-Boot and the OEI.
Francesco
Re: [PATCH v4 1/4] imx9: Add support for saving DDR training data to NVM
Hello Simona,
Quoted 24 lines · Francesco Dolcini
Hello Simona,
Quoted 21 lines · Simona Toaca
Quoted 11 lines · Udit
Quoted 10 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 8 lines
arch/arm/include/asm/arch-imx9/ddr.h struct dram_timing_info { · line 108
Quoted 2 lines
arch/arm/include/asm/arch-imx9/ddr.h +2
-0+#define DDRPHY_QB_PSTATES 0 +#define DDRPHY_QB_PST_SIZE (DDRPHY_QB_PSTATES * 4 * 1024)[..]
Sorry for basic question, in case OEI layer changes format due to one of other reason then how you are making sure, structddrphy_qb_stateis aligned
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
+ * This structure needs to be aligned with the one in OEI.
For now, the structure is stable. If anything changes, I will take care to update U-Boot accordingly.
Did you consider Emanuele's email in which he thinks that what we have today should already be changed?
Following up on this, we moved on with a different approach that does not require changing this data structure.
You can have a look at our implementation here, https://git.toradex.com/imx-oei-toradex.git/,
if you are interested.
Francesco
Re: [PATCH v4 1/4] imx9: Add support for saving DDR training data to NVM
In reply to Simona ToacaHi Simona,
Quoted 25 lines · Simona Toaca
Hello Kumar,
Quoted 13 lines · Udit
Quoted 10 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 8 lines
arch/arm/include/asm/arch-imx9/ddr.h struct dram_timing_info { · line 108
Quoted 2 lines
arch/arm/include/asm/arch-imx9/ddr.h +2
-0+#define DDRPHY_QB_PSTATES 0 +#define DDRPHY_QB_PST_SIZE (DDRPHY_QB_PSTATES * 4 * 1024)[..]
Sorry for basic question, in case OEI layer changes format due to one of other reason then how you are making sure, structddrphy_qb_stateis aligned
Quoted 4 lines
Quoted 2 lines
+ * This structure needs to be aligned with the one in OEI.
For now, the structure is stable. If anything changes, I will take care to update U-Boot accordingly.
Hmm, you might break backward compatibility in case of change in struct. Or you can think of some abstracted struct, which will take care of changes in OEI.
Something like
struct {
qb_version;
qb_data_pointer;
qb_data_size;
}
Quoted 17 lines
Quoted 17 lines
[..]
arch/arm/mach-imx/imx9/qb.c line 84
Quoted 11 lines
arch/arm/mach-imx/imx9/qb.c new file +11
-0+ +bool imx_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. +*/ In case OEI layer using saved DDR training data, then will passed CRC will be zero ?
Quoted 2 lines
No, the data in DRAM isn't guaranteed to be 0 after 'qb save' and then reset. It is 0 only immediately after a successful 'qb save'.
Ok then then you are making sure, if boot is from qb firmware then u-boot has a way to detect this ?
Quoted 7 lines
Quoted 5 lines
arch/arm/mach-imx/imx9/qb.c line 85
Quoted 2 lines
arch/arm/mach-imx/imx9/qb.c new file +1
-0+ qb_state = (struct ddrphy_qb_state *)CONFIG_QB_SAVED_STATE_BASE ;If yes then you can return from here, if no CRC found instead of doing crc calculation.
Agreed, but the CRC32 doesn't add significant overhead and, more often than not, the data will not be 0, but something else.
you can think to remove this, it may save few nS or uS in boot.
Quoted 21 lines
Quoted 11 lines
Quoted 10 lines
arch/arm/mach-imx/imx9/qb.c new file +9
-0+ 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; +} +[..]
Quoted 10 lines
arch/arm/mach-imx/imx9/qb.c line 402
Quoted 6 lines
arch/arm/mach-imx/imx9/qb.c new file +6
-0+ +void spl_imx_qb_save (void ) +{ +/* Save QB data on current boot device */ +if (imx_qb ("auto" ,"" , true)) +printf ("QB save failed\n" );In case, of 3rd boot or so, there is no need to save training data, whereas you will return error, in case this feature is auto enabled.
Quoted 7 lines
There is no way to tell from U-Boot if Quickboot flow was run or not, so that is why 'qb save' is tried everytime. The data in DRAM can be invalid for 2 reasons:
- it was saved by Training flow, but it got corrupted/got saved wrong
- Quickboot flow was run so no data was saved - this doesn't mean that the data in DRAM will be 0
No further comments on this, As long as, you are making sure, above print will come only if QB save really failed.
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
+}
[..]
Best regards,
Simona
Re: [PATCH v4 1/4] imx9: Add support for saving DDR training data to NVM
In reply to Simona Toaca (OSS)On 4/30/26 10:33 AM, Simona Toaca (OSS) wrote:
[...]
Quoted 14 lines
arch/arm/mach-imx/imx9/qb.c new file +14
-0+static int imx_qb_spi (bool save) +{ +struct udevice *flash; +u64 offset; +int ret; + +if (!CONFIG_IS_ENABLED (SPI )) { +printf ("SPI not enabled\n" ); +return -EOPNOTSUPP ; + } + + ret =uclass_first_device_err (UCLASS_SPI_FLASH , &flash); +if (ret) { +printf ("SPI flash not found.\n" );
arch/arm/mach-imx/imx9/qb.c line 345
Quoted 10 lines
arch/arm/mach-imx/imx9/qb.c new file +10
-0+return -ENODEV ; + } + + ret =imx_qb_get_qbdata_offset (flash,SPI_DEV , &offset); +if (ret) { +printf ("get_qbdata_offset failed, ret = %d\n" , ret); +return ret; + } + + ret =spi_flash_erase_dm (flash, offset,QB_STATE_LOAD_SIZE );
Can you please double-check whether "offset" here is always aligned to 64 kiB (SPI NOR erase block size) ? If not, this erase here will fail.
Thank you
Re: [PATCH v4 1/4] imx9: Add support for saving DDR training data to NVM
Hi Marek,
Quoted 10 lines · Marek Vasut
On 4/30/26 10:33 AM, Simona Toaca (OSS) wrote:
[...]
Quoted 6 lines
arch/arm/mach-imx/imx9/qb.c new file +6
-0+static int imx_qb_spi (bool save) +{ +struct udevice *flash; +u64 offset; +int ret; +
[...]
Quoted 11 lines
arch/arm/mach-imx/imx9/qb.c line 345
Quoted 7 lines
arch/arm/mach-imx/imx9/qb.c new file +7
-0+ ret =imx_qb_get_qbdata_offset (flash,SPI_DEV , &offset); +if (ret) { +printf ("get_qbdata_offset failed, ret = %d\n" , ret); +return ret; + } + + ret =spi_flash_erase_dm (flash, offset,QB_STATE_LOAD_SIZE );Can you please double-check whether "offset" here is always aligned to 64 kiB (SPI NOR erase block size) ? If not, this erase here will fail.
Thank you
The erase size of the SPI NOR should actually be 4kiB. I added a patch a while back enabling SFDP support, so that the erase size is parsed correctly and this does not fail. I only enabled it on U-Boot, but if you are using SPL you should enable it there too.
The only reason why I did not enable it for SPL is that there seems to not be any defconfig for iMX95/943/952 for booting from SPI NOR.
Trying 'qb save spi' from eMMC on an iMX943 EVK (with SFDP enabled):
u-boot=> qb save spi
SF: Detected mt35xu512aba with page size 256 Bytes, erase size 4 KiB, total 64 MiB
u-boot=> echo $?
0
Without SFDP, 'sf probe' reports 128kiB erase size, not 64kiB.
I also do not see why I would check if the offset is a multiple of the erase size, since the erase fails gracefully.
Best regards,
Simona
Re: [PATCH v4 1/4] imx9: Add support for saving DDR training data to NVM
On 6/2/26 3:46 PM, Simona Toaca wrote:
Hi,
Quoted 7 lines
Quoted 5 lines
arch/arm/mach-imx/imx9/qb.c line 345
Quoted 1 line
arch/arm/mach-imx/imx9/qb.c new file +1
-0+ ret =spi_flash_erase_dm (flash, offset,QB_STATE_LOAD_SIZE );Can you please double-check whether "offset" here is always aligned to 64 kiB (SPI NOR erase block size) ? If not, this erase here will fail.
Thank you
The erase size of the SPI NOR should actually be 4kiB.
That does not apply to all devices. I assume to align this data to 64 kiB offset, I would need a replacement AHAB container?
Quoted 15 lines
I added
a patch a while back enabling SFDP support, so that the erase size is parsed correctly and this does not fail. I only enabled it on U-Boot, but if you are using SPL you should enable it there too.The only reason why I did not enable it for SPL is that there seems to not be any defconfig for iMX95/943/952 for booting from SPI NOR.
Trying 'qb save spi' from eMMC on an iMX943 EVK (with SFDP enabled):
u-boot=> qb save spi
SF: Detected mt35xu512aba with page size 256 Bytes, erase size 4 KiB, total 64 MiB
u-boot=> echo $?
0
Quoted 4 lines
Without SFDP, 'sf probe' reports 128kiB erase size, not 64kiB.
I also do not see why I would check if the offset is a multiple of the erase size, since the erase fails gracefully.
My understanding is, that the erase operation should erase the QB data from the SPI NOR, not ignore failure and keep the data there ?
Re: [PATCH v4 1/4] imx9: Add support for saving DDR training data to NVM
Quoted 29 lines · Marek Vasut
On 6/2/26 3:46 PM, Simona Toaca wrote:
Hi,
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
+ ret =
spi_flash_erase_dm(flash, offset, QB_STATE_LOAD_SIZE);Can you please double-check whether "offset" here is always aligned to 64 kiB (SPI NOR erase block size) ? If not, this erase here will fail.
Thank you
The erase size of the SPI NOR should actually be 4kiB.
That does not apply to all devices. I assume to align this data to 64 kiB offset, I would need a replacement AHAB container?
Quoted 15 lines
I added
a patch a while back enabling SFDP support, so that the erase size is parsed correctly and this does not fail. I only enabled it on U-Boot, but if you are using SPL you should enable it there too.The only reason why I did not enable it for SPL is that there seems to not be any defconfig for iMX95/943/952 for booting from SPI NOR.
Trying 'qb save spi' from eMMC on an iMX943 EVK (with SFDP enabled):
u-boot=> qb save spi
SF: Detected mt35xu512aba with page size 256 Bytes, erase size 4 KiB, total 64 MiB
u-boot=> echo $?
0
Quoted 5 lines
Quoted 4 lines
Without SFDP, 'sf probe' reports 128kiB erase size, not 64kiB.
I also do not see why I would check if the offset is a multiple of the erase size, since the erase fails gracefully.
My understanding is, that the erase operation should erase the QB data from the SPI NOR, not ignore failure and keep the data there ?
It seems that on iMX95 B0, the DDR_DUMMY offset is 0x76400 (aligned to 1 kiB, which is too low):
"
$ hexdump -vC flash.bin | grep -A 1 ^00008000
00008000 02 a0 02 87 10 00 00 00 00 00 00 05 90 02 00 00
00008010 00 64 07 00 00 00 00 00 00 00 00 00 00 00 00 00
^^^^^^^^^^^
"But if I add the patch below, the offset gets aligned to 64 kiB at 0x78000:
"
$ hexdump -vC flash.bin | grep -A 1 ^00008000
00008000 02 a0 02 87 10 00 00 00 00 00 00 05 90 02 00 00
00008010 00 80 07 00 00 00 00 00 00 00 00 00 00 00 00 00
^^^^^^^^^^^
"This makes the "qb save" work reliably even on SPI NOR, because the erase block is aligned to 64 kiB instead of 1 kiB as it was before. Maybe we need such an alignment change ?
"
tools/imx8image.c +7 -0
@@ -9,6 +9,13 @@#include <image.h> #include <linux/sizes.h> +#define roundup (x, y) ( \ +{ \ + const typeof(y) __y = y; \ + (((x) + (__y - 1)) / __y) * __y; \ +} \ +) +static int p_idx;static int sector_size;static soc_type_t soc;
@@ -647,7 +654,7 @@ static void set_image_array_entry(flash_header_v3_t *container,/* if at least 2 images in container, [0] and
[1] */
boot_img_t *ddr_dummy =
&container->img[container->num_images - 1];
if ((ddr_dummy->hab_flags & 0x0F) ==
IMG_TYPE_DDR_DUMMY) {
- ddr_dummy->offset = img->offset + img->size;
+ ddr_dummy->offset = roundup(img->offset + img->size, 65536);
set_image_hash(ddr_dummy, "/dev/null",
IMAGE_HASH_ALGO_DEFAULT);
}
}"
Re: [PATCH v4 1/4] imx9: Add support for saving DDR training data to NVM
Quoted 5 lines · Marek Vasut
Quoted 4 lines · Marek Vasut
On 6/2/26 3:46 PM, Simona Toaca wrote:
Hi,
[...]
Quoted 27 lines
Quoted 27 lines
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
+ ret =
spi_flash_erase_dm(flash, offset, QB_STATE_LOAD_SIZE);Can you please double-check whether "offset" here is always aligned to 64
kiB (SPI NOR erase block size) ? If not, this erase here will fail.Thank you
The erase size of the SPI NOR should actually be 4kiB.
That does not apply to all devices. I assume to align this data to 64 kiB offset, I would need a replacement AHAB container?
Quoted 15 lines
I added
a patch a while back enabling SFDP support, so that the erase size is parsed correctly and this does not fail. I only enabled it on U-Boot, but if you are using SPL you should enable it there too.The only reason why I did not enable it for SPL is that there seems to not be any defconfig for iMX95/943/952 for booting from SPI NOR.
Trying 'qb save spi' from eMMC on an iMX943 EVK (with SFDP enabled):
u-boot=> qb save spi
SF: Detected mt35xu512aba with page size 256 Bytes, erase size 4 KiB, total 64 MiB
u-boot=> echo $?
0
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Without SFDP, 'sf probe' reports 128kiB erase size, not 64kiB.
I also do not see why I would check if the offset is a multiple of the erase size, since the erase fails gracefully.
My understanding is, that the erase operation should erase the QB data from the SPI NOR, not ignore failure and keep the data there ?
If there is data in SPI NOR it means that a previous write was successful, thus the erase shouldn't fail (as the write method in qb save also uses erase).
Quoted 3 lines
It seems that on iMX95 B0, the
DDR_DUMMYoffset is0x76400(aligned to 1 kiB, which is too low):
Yes, this is indeed too low. We align our DDR_DUMMY offset to 0x1000 (4KiB) in imx-mkimage, I see that here is not the case. At the same time, aligning it everytime (even for eMMC/SD case) to 64KiB seems overkill.
Quoted 4 lines
This makes the "qb save" work reliably even on SPI NOR, because the erase block is aligned to 64 kiB instead of 1 kiB as it was before. Maybe we need such an alignment change ?
My suggestion is that we align it with what happens in imx-mkimage and make ddr_dummy take an additional argument specifying the alignment. (and leave 4KiB default alignment in the dtsi, which should be fine if SFDP is used).
If you're ok with this, I will start working on a patch.
[...]
Regards,
Simona
Re: [PATCH v4 1/4] imx9: Add support for saving DDR training data to NVM
On 6/3/26 3:31 PM, Simona Toaca wrote:
[...]
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
I also do not see why I would check if the offset is a multiple of the erase size, since the erase fails gracefully.
My understanding is, that the erase operation should erase the QB data from the SPI NOR, not ignore failure and keep the data there ?
If there is data in SPI NOR it means that a previous write was successful, thus the erase shouldn't fail (as the write method in qb save also uses erase).
It is possible to write to a non-erased SPI NOR, even at unaligned address. It is not possible to erase at unaligned address.
Quoted 5 lines
Quoted 2 lines
It seems that on iMX95 B0, the
DDR_DUMMYoffset is0x76400(aligned to 1 kiB, which is too low):Yes, this is indeed too low. We align our
DDR_DUMMYoffset to0x1000(4KiB) in imx-mkimage, I see that here is not the case. At the same time, aligning it everytime (even for eMMC/SD case) to 64KiB seems overkill.
Are you testing this patchset with upstream U-Boot mkimage ?
Quoted 10 lines
Quoted 3 lines
This makes the "qb save" work reliably even on SPI NOR, because the erase block is aligned to 64 kiB instead of 1 kiB as it was before. Maybe we need such an alignment change ?
My suggestion is that we align it with what happens in imx-mkimage and make
ddr_dummytake an additional argument specifying the alignment. (and leave 4KiB default alignment in the dtsi, which should be fine if SFDP is used).If you're ok with this, I will start working on a patch.
This is fine by me, thank you.
Re: [PATCH v4 1/4] imx9: Add support for saving DDR training data to NVM
Quoted 1 line · Marek Vasut
On 6/3/26 3:31 PM, Simona Toaca wrote:
[...]
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
It seems that on iMX95 B0, the
DDR_DUMMYoffset is0x76400(aligned to 1 kiB, which is too low):Yes, this is indeed too low. We align our
DDR_DUMMYoffset to0x1000(4KiB) in imx-mkimage, I see that here is not the case. At the same time, aligning it everytime (even for eMMC/SD case) to 64KiB seems overkill.Are you testing this patchset with upstream U-Boot mkimage ?
I tested it with U-Boot mkimage on SD/eMMC. For saving to SPI NOR, I was not aware of the 'fspi' option in the dtsi, so I used imx-mkimage, not expecting things to be different regarding DDR DUMMY in upstream U-Boot mkimage.
Thank you for catching this issue.
Regards,
Simona
PATCH v4 2/4 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 | 102 +++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 arch/arm/mach-imx/cmd_qb.c
arch/arm/mach-imx/Kconfig +11 -0
@@ -80,6 +80,17 @@ config IMX_QB memory to non-volatile storage. OEI uses the saved data to run Quickboot flow and skip re-training the DDR PHY. +config CMD_IMX_QB + bool "Support the 'qb' command" + default y + depends on IMX_QB + 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's + first bootable partition (e.g. boot0 for eMMC). 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 +102 -0
102 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v4 3/4 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 ++++++++ board/nxp/imx94_evk/spl.c | 6 +++++- board/nxp/imx952_evk/spl.c | 4 ++++ board/nxp/imx95_evk/spl.c | 6 +++++- 4 files changed, 22 insertions(+), 2 deletions(-)
arch/arm/mach-imx/Kconfig +8 -0
@@ -80,6 +80,14 @@ config IMX_QB memory to non-volatile storage. OEI uses the saved data to run Quickboot flow and skip re-training the DDR PHY. +config SPL_IMX_QB + bool "Run qb save during SPL" + depends on SPL && IMX_QB + 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
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_imx_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_imx_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_imx_qb_save (); }void board_init_f (ulong dummy)
Signature · 1 line
2.43.0
PATCH v4 4/4 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/quickboot.rst | 59 +++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 doc/board/nxp/quickboot.rst
doc/board/nxp/index.rst +1 -0
@@ -30,3 +30,4 @@ NXP Semiconductors mx6ullevk rproc psb + quickboot
doc/board/nxp/quickboot.rst new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
2.43.0
Hi Simona
Quoted 5 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, iMX95 and iMX952 platforms. The purpose is running DDR Quickboot flow on next reboot.
First thanks for this series,
Since this is DDR IP feature, could you think to make this generic instead of board/arch specific.
Quoted 73 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 flowBy skipping training, a much lower boot time is achieved.
Changes for v4:
- addIMX_QBmacro to includeqb.cbased on the boot phase
- changeqb_prefix toimx_qb_forqb.cmethods, to
be more specific
- add boot device macro to string conversion for the case where the device is not explicitly specified
- pass quickboot args as strings and parse them inqb.cusing blk_device_get_by_str/blk_device_part_str (if they are blk devices). This enables specifying mmc 0:2 for the boot1 partition of the eMMC device.
- use blk device API instead of mmc-specific
- use SPI DM methods for spi flash read/write
- use malloc for storing container header instead of kmalloc
- add eMMC hwpart usage to the documentation
- sent the qb-unrelated patches separatelyChanges for v3:
- Rebased and added support for iMX952
- RemovedIMX_SNPS_DDR_PHY_QB_GENmacro, as it was not useful -> nowCMD_QBis enabled by default on the supported boards
- Removed unnecessary #ifdefs -> replaced with if (CONFIG..)
- Replacedspi_flash_probewithudevice_first_device_errto avoid using SPI macros that needed ifdefs, since there is only one SPI flash device available.
- Adnotated qb methods withqb_to be easier to see in asm dump
- Removed explicit pointer casts from (void *)
- Replaced customqb_crc32with the U-Boot one
- Made eveythingsnake_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 inKconfigChanges for v2:
- Improved documentation to clarify the questions asked
- Detailed log messages for all commits
- DetailedKconfigoptions forSPL_IMX_QBandCMD_IMX_QB
- Fixed the mentioned coding style issuesSimona Toaca (4):
imx9: Add support for saving DDR training data to NVM
arm: mach-imx: Add command to expose QB functionality
board: nxp: imx9{4,5,52}_evk: Add qb save option in SPL
doc: board: nxp: Add Quickboot documentationarch/arm/include/asm/arch-imx9/ddr.h | 48 +++- arch/arm/include/asm/mach-imx/qb.h | 15 + arch/arm/mach-imx/Kconfig | 28 ++ arch/arm/mach-imx/Makefile | 1 + arch/arm/mach-imx/cmd_qb.c | 102 +++++++ arch/arm/mach-imx/imx9/Makefile | 6 +- arch/arm/mach-imx/imx9/qb.c | 403 +++++++++++++++++++++++++++ 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 +- doc/board/nxp/index.rst | 1 + doc/board/nxp/quickboot.rst | 59 ++++ drivers/ddr/imx/imx9/Kconfig | 7 + 14 files changed, 688 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/quickboot.rst