arm: snapdragon: Add snagboot support for Lemans-EVK
v10 cover arm: snapdragon: Add snagboot support for Lemans-EVK
This series adds support for running U-Boot in snagboot mode on Qualcomm Snapdragon platforms, targeting the Lemans-EVK board.
Snagboot (https://github.com/bootlin/snagboot) is a recovery and reflashing tool that works through the SoC boot ROM. On Qualcomm SoCs, snagrecover loads XBL over Sahara in EDL mode to initialise DDR and then loads U-Boot into DDR, where it enters fastboot so that snagflash can write the images. Support for the Lemans-EVK (IQ9075) is in the snagboot tree, see the Qualcomm IQ9075 sections of
https://github.com/bootlin/snagboot/blob/main/docs/snagrecover.md
See also the doc/board/qualcomm/snagboot.rst added in patch 7 for usage and build steps.
XBL leaves the MMU enabled and does not set up PSCI firmware or Command DB in this flow, so the series adds a QCOM_SNAGBOOT_MODE option, an early MMU disable, and a defconfig and config fragment for Lemans-EVK.
Tested on Lemans-EVK board.
---
Changes in v10:
- Drop the CONFIG_ARM_SMCCC guards patch, SYSRESET_PSCI is already
off in snagboot mode so the PSCI functions are not built
- Depend on ENV_IS_DEFAULT instead of selecting ENV_IS_NOWHERE
- Drop depends on !ENV_IS_IN_SCSI, !PSCI_RESET, !SAVE_PREV_BL_INITRAMFS_START_ADDR, COUNTER_FREQUENCY != 0 and
TEXT_BASE != 0
- Replace the cmd-db.c change with a patch that lets QCOM_RPMH build
without QCOM_COMMAND_DB, and disable QCOM_COMMAND_DB in the snagboot
config fragment
- Fix the title underline in the snagboot doc
- Shorten the cover letter and link to the snagrecover IQ9075 docs
- Link to v9: https://lore.kernel.org/r/[email protected]
Changes in v9:
- Drop the assumption that snagboot mode needs IOMMU disabled:
QCOM_SNAGBOOT_MODE no longer depends on !IOMMU and
qcom-snagboot.config no longer sets CONFIG_IOMMU=n
- Link to v8: https://lore.kernel.org/r/[email protected]
Changes in v8:
- Make changes in documentation
- Link to v7: https://lore.kernel.org/r/[email protected]
Changes in v7:
- Rebased on top of latest main branch
- Link to v6: https://lore.kernel.org/r/[email protected]
Changes in v6:
- Forget to send summary in v5 cover letter, no other changes in v6
- Link to v5: https://marc.info/?l=u-boot&m=178577208345353&w=2
Changes in v5:
- Make QCOM_BOOT0_SNAGBOOT_MODE as hidden config dependent on
QCOM_SNAGBOOT_MODE
- Disable C (Dcache) bit of SCTLR_EL3 register during MMU disable
- Remove now unused QCOM_COMMAND_DB_OPTIONAL Kconfig definition
- Disable unnecessar I2C configs (for Snagboot) in Qcom Snagboot
config fragment
- Add build steps for compiling U-Boot for Snagboot mode in
Qcom Snagboot doc
- Link to v4: https://lore.kernel.org/u-boot/[email protected]/
Changes in v4:
- Renamed QCOM_SNAGBOOT_SUPPORT to QCOM_SNAGBOOT_MODE
- Make SYSRESET_PSCI dependent on QCOM_SNAGBOOT_MODE
- Place Snagboot related configs in seperate config fragment
called configs/qcom-snagboot.config
- Include above config fragment in
configs/qcom_lemans_snagboot_defconfig
- Removed Lemans EVK override dtsi: arch/arm/dts/lemans-evk-u-boot.dtsi
- Removed QCOM_COMMAND_DB_OPTIONAL as now we use
CONFIG_QCOM_SNAGBOOT_MODE
- Added documentation on U-Boot for Snagboot
- Link to v3: https://lore.kernel.org/u-boot/[email protected]/
Changes in v3:
- Brought the MMU disable logic under CONFIG_QCOM_SNAGBOOT_SUPPORT
ifdef condition
- Moved the MMU disable codes to a new seperate file
- Used "if (IS_ENABLED(CONFIG_QCOM_COMMAND_DB_OPTIONAL))" instead
of #ifdef
- Removed enabling QCOM_COMMAND_DB_OPTIONAL, ENABLE_ARM_SOC_BOOT0_HOOK
and SKIP_RELOCATE as they are now automatically enabled by
QCOM_SNAGBOOT_SUPPORT selection
- Removed updating MAINTAINERS as the defconfig file is picked up by
the "N: qcom" line
- Link to v2: https://lore.kernel.org/u-boot/[email protected]/
Changes in v2:
- Changed SYSRESET_PSCI from 'select' to 'imply'
- Guard show_psci_version() and qcom_psci_fixup() with CONFIG_ARM_SMCCC
- Disables the MMU and invalidates TLBs at the earliest entry point
- Add qcom_lemans_snagboot_defconfig for Lemans-EVK
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/
---
Balaji Selvanathan (7):
arm: snapdragon: Make SYSRESET_PSCI optional
arm: snapdragon: Disable MMU early before U-Boot reset vector
arm: snapdragon: Add CONFIG_QCOM_SNAGBOOT_MODE option
soc: qcom: Allow RPMh to be built without Command DB
arch: arm: dts: remove Lemans EVK override DTS
configs: add qcom_lemans_snagboot_defconfig for Lemans-EVK
doc: qualcomm: Add snagboot mode documentation
arch/arm/Kconfig | 2 +- arch/arm/dts/lemans-evk-u-boot.dtsi | 19 ----- arch/arm/mach-snapdragon/Kconfig | 14 ++++ arch/arm/mach-snapdragon/include/mach/boot0.h | 2 + .../mach-snapdragon/include/mach/snagboot_boot0.h | 27 +++++++ configs/qcom-snagboot.config | 25 +++++++ configs/qcom_lemans_snagboot_defconfig | 8 +++ doc/board/qualcomm/index.rst | 1 + doc/board/qualcomm/snagboot.rst | 84 ++++++++++++++++++++++ drivers/soc/qcom/Kconfig | 1 - include/soc/qcom/cmd-db.h | 7 ++ 11 files changed, 169 insertions(+), 21 deletions(-)
---
base-commit: 3401e006432abcbf7d73d7210f10df157f990ed3
change-id: 20260731-snagboot-4e9f66f0252d
Best regards,
Signature · 1 line
Balaji Selvanathan <[email protected]>
PATCH v10 1/7 arm: snapdragon: Make SYSRESET_PSCI optional
In snagboot mode, there is no PSCI firmware and U-Boot will crash if it attempts to make PSCI calls so disable it in this case.
---
Changes in v7:
- Make id dependent on both !QCOM_SNAGBOOT_MODE && !SPL
Changes in v5:
- No changes
Changes in v4:
- Make SYSRESET_PSCI dependent on QCOM_SNAGBOOT_MODE
Changes in v3:
- No changes
Changes in v2:
- Newly introduced in v2
--- arch/arm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/Kconfig +1 -1
@@ -1150,7 +1150,7 @@ config ARCH_SNAPDRAGON select SAVE_PREV_BL_FDT_ADDR if !ENABLE_ARM_SOC_BOOT0_HOOK select LINUX_KERNEL_IMAGE_HEADER if !ENABLE_ARM_SOC_BOOT0_HOOK select SYSRESET - select SYSRESET_PSCI if !SPL + select SYSRESET_PSCI if !QCOM_SNAGBOOT_MODE && !SPL select ANDROID_BOOT_IMAGE_IGNORE_BLOB_ADDR select MMU_PGPROT select SUPPORT_SPL
Signature · 1 line
2.34.1
PATCH v10 2/7 arm: snapdragon: Disable MMU early before U-Boot reset vector
In reply to Balaji SelvanathanWhen U-Boot is loaded by XBL in Snagboot mode, XBL leaves the MMU enabled with its own page tables. This causes stale TLB entries and incorrect memory mappings when U-Boot initializes its own MMU.
Disable the MMU and invalidate TLBs before branching to the reset vector. This ensures a clean MMU state for U-Boot initialization in Snagboot mode.
---
Changes in v10:
- Rebase to latest boot0.h file
- Add missing newline at end of snagboot_boot0.h
Changes in v7:
- No changes
Changes iv v5:
- Clear C bit (Dcache enable) also during MMU disable
Changes iv v4:
- Remove handling for EL1 or EL2 entry as for Snagboot we would only enter U-Boot in EL3 from previous bootloader
Changes in v3:
- Brought the MMU disable logic under CONFIG_QCOM_SNAGBOOT_SUPPORT ifdef condition
- Moved the MMU disable codes to a new seperate file
Changes in v2:
- Newly introduced in v2
--- arch/arm/mach-snapdragon/include/mach/boot0.h | 2 ++ .../mach-snapdragon/include/mach/snagboot_boot0.h | 27 ++++++++++++++++++++++ 2 files changed, 29 insertions(+)
arch/arm/mach-snapdragon/include/mach/boot0.h +2 -0
@@ -10,6 +10,8 @@#include "msm8916_boot0.h" #elif defined(CONFIG_QCOM_EL2_GUNYAH_EXIT_SUPPORT )#include "gunyah_exit_boot0.h" +#elif defined(CONFIG_QCOM_BOOT0_SNAGBOOT_MODE ) +#include "snagboot_boot0.h" #else b reset#endif
arch/arm/mach-snapdragon/include/mach/snagboot_boot0.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Early MMU Disable for Snagboot Mode +* +* Disable MMU at the earliest possible point for EL3 entry. +* Snagboot mode always enters U-Boot at EL3. +* +* After disabling MMU, invalidate TLB to clear any stale entries that might +* cause issues when MMU is re-enabled later. +*/ + +mrs x0, CurrentEL + cmp x0, #(3 << 2) /* Verify EL3 entry */ + b.ne reset /* Unexpected: not at EL3 */ + + /* Disable MMU at EL3 */ + mrs x0, sctlr_el3 + bic x0, x0, #1 /* Clear M bit (MMU enable) */ + bic x0, x0, #(1 << 2) /* Clear C bit (Dcache enable) */ + bic x0, x0, #(1 << 19) /* Clear WXN bit (Write XOR Execute) */ + msr sctlr_el3, x0 + isb + /* Invalidate entire TLB for all ELs */ + tlbi alle3 + dsb sy + isb + b reset
Signature · 1 line
2.34.1
PATCH v10 3/7 arm: snapdragon: Add CONFIG_QCOM_SNAGBOOT_MODE option
In reply to Balaji SelvanathanAdd CONFIG_QCOM_SNAGBOOT_MODE to enable snagboot mode on Qualcomm platforms. This config automatically selects the required dependencies for Snagboot mode.
Add QCOM_BOOT0_SNAGBOOT_MODE as a hidden boot0.h config, selected automatically by QCOM_SNAGBOOT_MODE. This boot0.h config is for disabling MMU at the start of U-Boot execution.
---
Changes in v10:
- Depend on ENV_IS_DEFAULT instead of selecting ENV_IS_NOWHERE and depending on !ENV_IS_IN_SCSI
- Drop depends on COUNTER_FREQUENCY != 0
- Drop depends on TEXT_BASE != 0x0
- Drop depends on !PSCI_RESET and !SAVE_PREV_BL_INITRAMFS_START_ADDR
Changes in v9:
- Remove depends on !IOMMU from QCOM_SNAGBOOT_MODE
Changes in v7:
- No changes
Changes in v5:
- Made QCOM_BOOT0_SNAGBOOT_MODE dependent on QCOM_SNAGBOOT_MODE so it is not exposed to users
- Add dependencies for QCOM_SNAGBOOT_MODE explicitly as "depends"
Changes in v4:
- Renamed QCOM_SNAGBOOT_SUPPORT to QCOM_SNAGBOOT_MODE
- Added QCOM_BOOT0_SNAGBOOT_MODE for boot0.h which gets selected by QCOM_SNAGBOOT_MODE
- Document the platform-specific requirements and configs that must be disabled in snagboot mode.
Changes in v3:
- Newly introduced in v3
--- arch/arm/mach-snapdragon/Kconfig | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/arm/mach-snapdragon/Kconfig +14 -0
@@ -90,4 +90,18 @@ config QCOM_EL2_GUNYAH_EXIT_SUPPORT endchoice +config QCOM_BOOT0_SNAGBOOT_MODE + bool + depends on QCOM_SNAGBOOT_MODE + +config QCOM_SNAGBOOT_MODE + bool "Build U-Boot for Snagboot mode loading" + select QCOM_BOOT0_SNAGBOOT_MODE + select ENABLE_ARM_SOC_BOOT0_HOOK + select SKIP_RELOCATE + depends on ENV_IS_DEFAULT + help + Build U-Boot to be loaded in Snagboot mode on Qualcomm platforms + for device/factory provisioning using fastboot. + endif
Signature · 1 line
2.34.1
PATCH v10 4/7 soc: qcom: Allow RPMh to be built without Command DB
In reply to Balaji SelvanathanQCOM_RPMH depends on QCOM_COMMAND_DB, so the RPMh RSC device and the children it binds, such as the clock and power domain devices, are only built when Command DB is enabled. rpmh-rsc.c itself never calls into Command DB, only the RPMh users do.
In some scenarios, such as Snagboot mode, no Command DB data is available, so there is nothing for the driver to read. The RPMh RSC device and its clock children are still needed there, for example the rpmhcc clock used by UFS.
Remove the dependency of QCOM_RPMH on QCOM_COMMAND_DB, and add stubs for cmd_db_read_slave_id() and cmd_db_read_aux_data() so that the RPMh users still build when QCOM_COMMAND_DB is disabled.
The stubs return CMD_DB_HW_INVALID and an error pointer, and cmd_db_read_addr() already returns 0. The power domain, regulator and interconnect users therefore fail to probe with an error message, which is what they already do when Command DB has no data.
---
Changes in v10:
- Newly added in v10, replaces the cmd-db.c change in v9
--- drivers/soc/qcom/Kconfig | 1 - include/soc/qcom/cmd-db.h | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/soc/qcom/Kconfig +0 -1
@@ -20,7 +20,6 @@ config QCOM_COMMAND_DB config QCOM_RPMH bool "Qualcomm RPMh support" - depends on QCOM_COMMAND_DB help Say y here to support the Qualcomm RPMh (resource peripheral manager) if you need to control regulators on Qualcomm platforms, say y here.
include/soc/qcom/cmd-db.h +7 -0
@@ -28,5 +28,12 @@ const void *cmd_db_read_aux_data(const char *resource_id, size_t *len);static inline u32 cmd_db_read_addr (const char *resource_id) {return 0 ; } +static inline enum cmd_db_hw_type cmd_db_read_slave_id (const char *resource_id) +{return CMD_DB_HW_INVALID ; } + +static inline const void *cmd_db_read_aux_data (const char *resource_id, +size_t *len) +{return ERR_PTR (-ENODEV ); } +#endif /* CONFIG_QCOM_COMMAND_DB */ #endif /* __QCOM_COMMAND_DB_H__ */
Signature · 1 line
2.34.1
PATCH v10 5/7 arch: arm: dts: remove Lemans EVK override DTS
In reply to Balaji SelvanathanRemove Lemans EVK override dtsi: arch/arm/dts/lemans-evk-u-boot.dtsi
Memory node is not required as we can read the memory info from SMEM.
---
Changes in v10:
- Drop the SMEM series dependency, it is now merged
Changes in v7:
- No changes
Changes in v5:
- No changes
Changes in v4:
- Newly added in v4
--- arch/arm/dts/lemans-evk-u-boot.dtsi | 19 ------------------- 1 file changed, 19 deletions(-)
arch/arm/dts/lemans-evk-u-boot.dtsi deleted +0 -19
@@ -1,19 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -/* - * Copyright (c) 2026, Qualcomm Innovation Center, Inc. All rights reserved. - */ - -/ { - /* Will be removed when bootloader updates later */ - memory@80000000 { - device_type = "memory"; - reg = <0x0 0x80000000 0x0 0x3ee00000>, - <0x0 0xc0000000 0x0 0x0fd00000>, - <0xD 0x00000000 0x2 0x54100000>, - <0xA 0x80000000 0x1 0x80000000>, - <0x9 0x00000000 0x1 0x80000000>, - <0x1 0x00000000 0x3 0x00000000>, - <0x0 0xd0000000 0x0 0x01900000>, - <0x0 0xd3500000 0x0 0x2cb00000>; - }; -};
Signature · 1 line
2.34.1
PATCH v10 6/7 configs: add qcom_lemans_snagboot_defconfig for Lemans-EVK
In reply to Balaji SelvanathanAdd defconfig for booting U-Boot in Snagboot mode on Lemans-EVK. In this mode, XBL loads U-Boot and directly jumps to it. U-Boot then enters fastboot over USB for device provisioning.
Create a reusable config fragment at configs/qcom-snagboot.config with common snagboot settings. Platform-specific defconfigs should include this fragment along with their own settings.
---
Changes in v10:
- Drop CONFIG_ENV_IS_NOWHERE, now provided by ENV_IS_DEFAULT
- Disable CONFIG_QCOM_COMMAND_DB
Changes in v9:
- Do not disable CONFIG_IOMMU in qcom-snagboot.config
Changes in v7:
- No changes
Changes in v5:
- Disable I2C configs as its not required in Snagboot mode
Changes in v4:
- Use CONFIG_ENV_IS_NOWHERE
- Place Snagboot related configs in seperate config fragment called configs/qcom-snagboot.config
- Include above config fragment in configs/qcom_lemans_snagboot_defconfig
Changes in v3:
- Removed enabling QCOM_COMMAND_DB_OPTIONAL, ENABLE_ARM_SOC_BOOT0_HOOK and SKIP_RELOCATE as they are now automatically enabled by QCOM_SNAGBOOT_SUPPORT selection
Changes in v2:
- Newly introduced in v2
--- configs/qcom-snagboot.config | 25 +++++++++++++++++++++++++ configs/qcom_lemans_snagboot_defconfig | 8 ++++++++ 2 files changed, 33 insertions(+)
configs/qcom-snagboot.config new file +25 -0
@@ -0,0 +1,25 @@ +CONFIG_QCOM_SNAGBOOT_MODE=y +# CONFIG_PSCI_RESET is not set +# CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR is not set +# CONFIG_QCOM_COMMAND_DB is not set +# CONFIG_REBOOT_MODE_ENV_UPDATE is not set +# CONFIG_CMD_POWEROFF is not set +# CONFIG_DM_I2C is not set +# CONFIG_CMD_I2C is not set +# CONFIG_SYS_I2C_QUP is not set +# CONFIG_SYS_I2C_GENI is not set +# CONFIG_I2C_MUX is not set +# CONFIG_I2C_EEPROM is not set +# CONFIG_ENV_IS_IN_SCSI is not set +# CONFIG_ENV_IS_IN_MMC is not set +# CONFIG_ENV_IS_IN_FLASH is not set +# CONFIG_ENV_IS_IN_NAND is not set +# CONFIG_ENV_USE_DEFAULT_ENV_TEXT_FILE is not set +CONFIG_USE_BOOTCOMMAND=y +CONFIG_BOOTCOMMAND="fastboot -l $fastboot_addr_r usb 0" +CONFIG_BOOTDELAY=0 +CONFIG_FASTBOOT_FLASH_BLOCK=y +CONFIG_FASTBOOT_FLASH_BLOCK_INTERFACE_NAME="scsi" +CONFIG_FASTBOOT_FLASH_BLOCK_DEVICE_ID=4 +CONFIG_FASTBOOT_GPT_NAME="gpt" +CONFIG_FASTBOOT_MBR_NAME="mbr"
configs/qcom_lemans_snagboot_defconfig new file +8 -0
@@ -0,0 +1,8 @@ +#include "qcom_defconfig" +#include "qcom-snagboot.config" + +CONFIG_TEXT_BASE=0x1c100000 +CONFIG_REMAKE_ELF=y +CONFIG_FASTBOOT_BUF_ADDR=0xdb300000 +CONFIG_DEFAULT_DEVICE_TREE="qcom/lemans-evk" +CONFIG_COUNTER_FREQUENCY=19200000
Signature · 1 line
2.34.1
PATCH v10 7/7 doc: qualcomm: Add snagboot mode documentation
In reply to Balaji SelvanathanDocument how to build and sign U-Boot for snagboot mode on Qualcomm platforms, using Lemans-EVK (also known as IQ9075) as the example, and how to add a snagboot defconfig for another board using the qcom-snagboot.config fragment.
---
Changes in v10:
- Fix the title underline length
- Mention the IQ9075 name and point to the snagrecover documentation
Changes in v8:
- Point to the upstream Snagboot docs instead of describing the tool
- Drop the "Why Snagboot?", architecture and EDL+Firehose comparison sections
- Move the build and signing steps ahead of board enablement
- Drop the list of Kconfig options selected/forbidden by QCOM_SNAGBOOT_MODE and the Lemans-EVK example section
- Replace the signing prerequisites list with commands to fetch swiv_build_utility.py and qtestsign
- Drop the "Expected result" and "Output" blocks
Changes in v7:
- Rebased on top of latest file
Changes in v5:
- Added build steps for U-Boot in Snagboot mode
Changes in v4:
- Newly added in v4
--- doc/board/qualcomm/index.rst | 1 + doc/board/qualcomm/snagboot.rst | 84 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+)
doc/board/qualcomm/index.rst +1 -0
@@ -17,3 +17,4 @@ Qualcomm rdp signing spl + snagboot
doc/board/qualcomm/snagboot.rst new file +84 -0
84 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 13 lines · Balaji Selvanathan
This series adds support for running U-Boot in snagboot mode on Qualcomm Snapdragon platforms, targeting the Lemans-EVK board.
Snagboot (https://github.com/bootlin/snagboot) is a recovery and reflashing tool that works through the SoC boot ROM. On Qualcomm SoCs, snagrecover loads XBL over Sahara in EDL mode to initialise DDR and then loads U-Boot into DDR, where it enters fastboot so that snagflash can write the images. Support for the Lemans-EVK (IQ9075) is in the snagboot tree, see the Qualcomm IQ9075 sections of
https://github.com/bootlin/snagboot/blob/main/docs/snagrecover.md
See also thedoc/board/qualcomm/snagboot.rstadded in patch 7 for usage and build steps.
Quoted 6 lines
XBL leaves the MMU enabled and does not set up PSCI firmware or Command DB in this flow, so the series adds a
QCOM_SNAGBOOT_MODEoption, an early MMU disable, and a defconfig and config fragment for Lemans-EVK.Tested on Lemans-EVK board.
This all seems fine and I'll leave the Qualcomm-specific reviews to someone else now, thanks for reworking it.
Signature · 1 line
Tom
Hi Tom,
Quoted 15 lines · Tom Rini
Quoted 13 lines · Balaji Selvanathan
This series adds support for running U-Boot in snagboot mode on Qualcomm Snapdragon platforms, targeting the Lemans-EVK board.
Snagboot (https://github.com/bootlin/snagboot) is a recovery and reflashing tool that works through the SoC boot ROM. On Qualcomm SoCs, snagrecover loads XBL over Sahara in EDL mode to initialise DDR and then loads U-Boot into DDR, where it enters fastboot so that snagflash can write the images. Support for the Lemans-EVK (IQ9075) is in the snagboot tree, see the Qualcomm IQ9075 sections of
https://github.com/bootlin/snagboot/blob/main/docs/snagrecover.md
See also thedoc/board/qualcomm/snagboot.rstadded in patch 7 for usage and build steps.
Quoted 8 lines
Quoted 6 lines
XBL leaves the MMU enabled and does not set up PSCI firmware or Command DB in this flow, so the series adds a
QCOM_SNAGBOOT_MODEoption, an early MMU disable, and a defconfig and config fragment for Lemans-EVK.Tested on Lemans-EVK board.
This all seems fine and I'll leave the Qualcomm-specific reviews to someone else now, thanks for reworking it.
Thanks for the feedbacks.