Skip to contentSkip to conversation

Remove usage of CMD_BOOTx from SPL code

PATCH Superseded Anshul Dalal 2 participants 4 messages Oct 24, 2025

Subsystems (3)

v8 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v8 cover Remove usage of CMD_BOOTx from SPL code

Hi all,

We currently make use of CMD_BOOTI and CMD_BOOTZ in the SPL boot flow in falcon mode, this isn't correct since all CMD_* configs are only meant for U-Boot proper and not the SPL.

Therefore this patch set adds new LIB_BOOT[IMZ] configs that allow for more granular selection of their respective compilation targets.

Additionally, this also allows us to more easily disable support for raw images from secure falcon mode (SPL_OS_BOOT_SECURE) by doing the following:

  config LIB_SPL_BOOTI
    ...
    depends on SPL_OS_BOOT && !SPL_OS_BOOT_SECURE
    ...

Regards,
Anshul

---
Changes in v8:
- Use LIB_$(PHASE_)LIB_BOOT[IMZ] instead
- Drop the patch migrating falcon configs
- Drop the patch for colibri_vf
- Link to v7: https://lore.kernel.org/u-boot/[email protected]/

Changes in v7:
- Change SPL configs from SPL_HAS_* to SPL_*
- Change library symbol names from LIB_BOOTx to just BOOTx
- Add BOOTM for compiling boot.c
- Link to v6: https://lore.kernel.org/u-boot/[email protected]/

Changes in v6:
- Add LIB_BOOTx library symbols
- Update existing configs ensuring no change in size or build failure
- Link to v5: https://lore.kernel.org/all/[email protected]/

Changes in v5:
- Remove imply clause for CMD_BOOTZ instead add default y for SPL_HAS_BOOTZ
- Update commit message to reflect the changes
- Remove 'More info' link
- Link to v4: https://lore.kernel.org/u-boot/[email protected]/

Changes in v4:
- Don't set SPL_HAS_BOOTI for sandbox by default
- Updated prompts for SPL_HAS_BOOT[IZ]
- Removed check for SPL_HAS_FRAMEWORK from Makefile
- Link to v3: https://lore.kernel.org/u-boot/[email protected]/

Changes in v3:
- Add imply clause for CMD_BOOTZ to enable SPL_HAS_BOOTZ
- Fix broken check for bootz_setup
- Link to v2: https://lore.kernel.org/u-boot/[email protected]/

Changes in v2:
- Add SPL_HAS_BOOT[IZ] configs
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/

GitHub CI: https://github.com/u-boot/u-boot/pull/757

---
Anshul Dalal (2):
spl: remove usage of CMD_BOOTx from image parsing
configs: disable SPL_BOOTZ to preserve spl size

 arch/arm/lib/Makefile                | 13 +++++++------
 arch/riscv/lib/Makefile              |  4 ++--
 boot/Kconfig                         | 18 ++++++++++++++++++
 cmd/Kconfig                          |  5 +++++
 common/spl/Kconfig                   | 16 ++++++++++++++++
 common/spl/spl.c                     |  5 +++--
 configs/imx28_xea_defconfig          |  1 +
 configs/imx6qdl_icore_mipi_defconfig |  1 +
 configs/imx6qdl_icore_mmc_defconfig  |  1 +
 configs/imx6qdl_icore_rqs_defconfig  |  1 +
 10 files changed, 55 insertions(+), 10 deletions(-)

---
base-commit: b10c055d4e1b5153a331a61ef82a5b01b5bb4c45
change-id: 20251023-fix_cmd_bootx-9ea1d69f08e3

Best regards,

Signature · 1 line
Anshul Dalal <[email protected]>
#1 lore raw

PATCH v8 1/2 spl: remove usage of CMD_BOOTx from image parsing

Using CMD_* configs from spl doesn't make logical sense. Therefore this patch replaces the checks for CMD_BOOTx with newly added library symbols BOOTI, BOOTM and BOOTZ which are enabled by their respective CMD_* or SPL_* counterparts.

SPL_BOOTZ is enabled by default for 32-bit ARM systems and SPL_BOOTI is enabled by default for 64-bit ARM and RISCV.

The respective C files (image.c/zimage.c) are compiled based on library symbols BOOTx instead which are in turn selected by both CMD_BOOTx and SPL_BOOTx as required.

---
 arch/arm/lib/Makefile   | 13 +++++++------
 arch/riscv/lib/Makefile |  4 ++--
 boot/Kconfig            | 18 ++++++++++++++++++
 cmd/Kconfig             |  5 +++++
 common/spl/Kconfig      | 16 ++++++++++++++++
 common/spl/spl.c        |  5 +++--
 6 files changed, 51 insertions(+), 10 deletions(-)
arch/arm/lib/Makefile +7 -6
index ade42d0ca4370b7df3aec59615f12e28a96874cd..9f3c30156d22330515e408ec030a3ced3b81ab38 100644
@@ -7,6 +7,13 @@ lib-$(CONFIG_USE_PRIVATE_LIBGCC) += ashldi3.o ashrdi3.o lshrdi3.o \
 				    lib1funcs.o uldivmod.o div0.o \
 				    div64.o muldi3.o
 
+obj-$(CONFIG_$(PHASE_)LIB_BOOTI) += image.o
+obj-$(CONFIG_$(PHASE_)LIB_BOOTZ) += zimage.o
+
+ifndef CONFIG_XPL_BUILD
+obj-$(CONFIG_LIB_BOOTM) += bootm.o
+endif
+
 ifdef CONFIG_CPU_V7M
 obj-y	+= vectors_m.o crt0.o
 else ifdef CONFIG_ARM64
@@ -30,15 +37,9 @@ endif
 
 obj-$(CONFIG_CPU_V7M) += cmd_boot.o
 obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
-obj-$(CONFIG_CMD_BOOTI) += bootm.o image.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
-obj-$(CONFIG_CMD_BOOTZ) += bootm.o zimage.o
 else
 obj-$(CONFIG_$(PHASE_)FRAMEWORK) += spl.o
-ifdef CONFIG_SPL_FRAMEWORK
-obj-$(CONFIG_CMD_BOOTI) += image.o
-obj-$(CONFIG_CMD_BOOTZ) += zimage.o
-endif
 obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
 endif
 ifdef CONFIG_ARM64
arch/riscv/lib/Makefile +2 -2
index db8d235c6993a8fd78b09acf50f14776615d5269..f1f50918effb45f8281d0d1b315523e42919f706 100644
@@ -6,8 +6,8 @@
 # Copyright (C) 2017 Andes Technology Corporation
 # Rick Chen, Andes Technology Corporation <[email protected]>
 
-obj-$(CONFIG_CMD_BOOTM) += bootm.o
-obj-$(CONFIG_CMD_BOOTI) += bootm.o image.o
+obj-$(CONFIG_$(PHASE_)LIB_BOOTM) += bootm.o
+obj-$(CONFIG_$(PHASE_)LIB_BOOTI) += image.o
 obj-$(CONFIG_CMD_GO) += boot.o
 obj-y	+= cache.o
 obj-$(CONFIG_SIFIVE_CACHE) += sifive_cache.o
boot/Kconfig +18 -0
index 022ec05de0a007677ca8b3111559a5601d36be05..d625d41bd8521ecb8e57901eae0384b5a2d44307 100644
@@ -33,6 +33,24 @@ config TIMESTAMP
 	  loaded that does not, the message 'Wrong FIT format: no timestamp'
 	  is shown.
 
+config LIB_BOOTI
+	bool
+
+config LIB_BOOTM
+	bool
+
+config LIB_BOOTZ
+	bool
+
+config SPL_LIB_BOOTI
+	bool
+
+config SPL_LIB_BOOTM
+	bool
+
+config SPL_LIB_BOOTZ
+	bool
+
 config BUTTON_CMD
 	bool "Support for running a command if a button is held during boot"
 	depends on CMDLINE
cmd/Kconfig +5 -0
index 9929087a8bb8b525ea43a1d9d35dc49d4223e13a..f8d60161152b5a97f5995b6c499d3efb1872acf1 100644
@@ -284,6 +284,7 @@ config CMD_BOOTD
 config CMD_BOOTM
 	bool "bootm"
 	default y
+	select LIB_BOOTM
 	help
 	  Boot an application image from the memory.
 
@@ -360,6 +361,8 @@ config BOOTM_ELF
 
 config CMD_BOOTZ
 	bool "bootz"
+	select LIB_BOOTZ
+	select LIB_BOOTM
 	help
 	  Boot the Linux zImage
 
@@ -367,6 +370,8 @@ config CMD_BOOTI
 	bool "booti"
 	depends on ARM64 || RISCV || SANDBOX
 	default y
+	select LIB_BOOTI
+	select LIB_BOOTM
 	help
 	  Boot an AArch64 Linux Kernel image from memory.
 
common/spl/Kconfig +16 -0
index 24d6ce5d7399b06799a930911f93665a10531469..6027f24b1fee2dcf9806e5bb07083f9bf9dc01fe 100644
@@ -1216,6 +1216,22 @@ config SPL_OS_BOOT_SECURE
 	  to use falcon mode by disabling certain inherently non-securable options
 	  in the SPL boot flow.
 
+config SPL_BOOTZ
+	bool "Allow booting a zImage style Linux kernel from SPL"
+	depends on SPL_OS_BOOT && !SPL_OS_BOOT_SECURE
+	default y if ARM && !ARM64
+	select SPL_LIB_BOOTZ
+	help
+	  Boot a linux zimage from memory in falcon boot.
+
+config SPL_BOOTI
+	bool "Allow booting an Image style Linux kernel from SPL"
+	depends on SPL_OS_BOOT && !SPL_OS_BOOT_SECURE
+	default y if ARM64 || RISCV
+	select SPL_LIB_BOOTI
+	help
+	  Boot an uncompressed linux kernel image from memory in falcon boot.
+
 config SPL_OS_BOOT_ARGS
 	bool "Allow SPL to load args for kernel in falcon mode"
 	depends on (SPL_OS_BOOT || SPL_LOAD_FIT_OPENSBI_OS_BOOT) && !SPL_OS_BOOT_SECURE
common/spl/spl.c +3 -2
index 64313cb8dfe1a401078882564b69890480c9894d..4dae3d0940d02b59e97f89bea6f803e0ade94332 100644
@@ -340,7 +340,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
 		panic("** no mkimage signature but raw image not supported");
 	}
 
-	if (CONFIG_IS_ENABLED(OS_BOOT) && IS_ENABLED(CONFIG_CMD_BOOTI)) {
+	if (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_BOOTI)) {
 		ulong start, size;
 
 		if (!booti_setup((ulong)header, &start, &size, 0)) {
@@ -354,7 +354,8 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
 			      spl_image->load_addr, spl_image->size);
 			return 0;
 		}
-	} else if (CONFIG_IS_ENABLED(OS_BOOT) && IS_ENABLED(CONFIG_CMD_BOOTZ)) {
+	} else if (IS_ENABLED(CONFIG_SPL_OS_BOOT) &&
+		   IS_ENABLED(CONFIG_SPL_BOOTZ)) {
 		ulong start, end;
 
 		if (!bootz_setup((ulong)header, &start, &end)) {
Signature · 1 line
2.51.0
#2 lore raw

Re: [PATCH v8 1/2] spl: remove usage of CMD_BOOTx from image parsing

Quoted 4 lines · Anshul Dalal

Using CMD_* configs from spl doesn't make logical sense. Therefore this patch replaces the checks for CMD_BOOTx with newly added library symbols BOOTI, BOOTM and BOOTZ which are enabled by their respective CMD_* or SPL_* counterparts.

You didn't update the commit message here to reflect the new symbol names.

Quoted 5 lines
arch/arm/lib/Makefile +0 -0
index ade42d0ca4370b7df3aec59615f12e28a96874cd..9f3c30156d22330515e408ec030a3ced3b81ab38 100644

arch/arm/lib/Makefile lib-$(CONFIG_USE_PRIVATE_LIBGCC) += ashldi3.o ashrdi3.o lshrdi3.o \ · line 15

Quoted 9 lines
arch/arm/lib/Makefile +6 -0
@@ -7,6 +7,13 @@ lib-$(CONFIG_USE_PRIVATE_LIBGCC) += ashldi3.o ashrdi3.o lshrdi3.o \
 				    lib1funcs.o uldivmod.o div0.o \
 				    div64.o muldi3.o
 
+obj-$(CONFIG_$(PHASE_)LIB_BOOTI) += image.o
+obj-$(CONFIG_$(PHASE_)LIB_BOOTZ) += zimage.o
+
+ifndef CONFIG_XPL_BUILD
+obj-$(CONFIG_LIB_BOOTM) += bootm.o
+endif

Since we have $(PHASE_) now for LIB_BOOTM this too should be like the other two.

Signature · 1 line
Tom
#3 lore raw

PATCH v8 2/2 configs: disable SPL_BOOTZ to preserve spl size

In reply to Anshul Dalal

In the existing behaviour, CMD_BOOTZ is not enabled by default which means zimage.o is not compiled in the SPL in falcon mode unless explicitly enabled. This changes now as SPL_BOOTZ is default y for falcon users which leads to larger SPL size with zimage.o being present.

This patch modifies the defconfigs that used falcon mode but don't require zimage support.

---
 configs/imx28_xea_defconfig          | 1 +
 configs/imx6qdl_icore_mipi_defconfig | 1 +
 configs/imx6qdl_icore_mmc_defconfig  | 1 +
 configs/imx6qdl_icore_rqs_defconfig  | 1 +
 4 files changed, 4 insertions(+)
configs/imx28_xea_defconfig +1 -0
index 8715893bbcc0ad565ffc923ab5cc980e0f5bf0b3..0bb2e4472500b7ee1d31d29b35e78b82e912f4d2 100644
@@ -132,3 +132,4 @@ CONFIG_DM_SPI=y
 CONFIG_MXS_SPI=y
 CONFIG_SPL_CRC8=y
 # CONFIG_SPL_OF_LIBFDT is not set
+# CONFIG_SPL_BOOTZ is not set
configs/imx6qdl_icore_mipi_defconfig +1 -0
index c322fd3eff14058c2d3d3cb8cb64103554114e1c..cc05ecf587f56bfe82ac7706b630653fcbd13458 100644
@@ -74,3 +74,4 @@ CONFIG_PINCTRL_IMX6=y
 CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_IMX_THERMAL=y
+# CONFIG_SPL_BOOTZ is not set
configs/imx6qdl_icore_mmc_defconfig +1 -0
index 0b82fbecbee373371e87bff5baac2d0de75bed09..169903266cd5c7420ae9bab4045e1fe0b56fac6c 100644
@@ -102,3 +102,4 @@ CONFIG_SPLASH_SCREEN=y
 CONFIG_SPLASH_SCREEN_ALIGN=y
 CONFIG_BMP_16BPP=y
 CONFIG_IMX_WATCHDOG=y
+# CONFIG_SPL_BOOTZ is not set
configs/imx6qdl_icore_rqs_defconfig +1 -0
index 8520f90c867aee27894baeac6994576589fe2c5f..34d834ec8e1556612c7e692a540eababaa84230f 100644
@@ -71,3 +71,4 @@ CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
 CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
+# CONFIG_SPL_BOOTZ is not set
Signature · 1 line
2.51.0