[PATCH v2 8/9] mach-snapdragon: Add commands to create wrapper ELF
Varadarajan Narayanan
varadarajan.narayanan at oss.qualcomm.com
Fri Apr 10 11:11:53 CEST 2026
The IPQ5210 boot ROM expects the SPL binary image to be embedded within
an ELF along with additional binaries. Hence add the relevant commands
and linker script needed to convert u-boot-spl.bin to the expected
format.
Signed-off-by: Varadarajan Narayanan <varadarajan.narayanan at oss.qualcomm.com>
---
arch/arm/mach-snapdragon/Kconfig | 6 ++++++
.../mach-snapdragon/ipq5210-spl-wrap-elf.lds | 14 +++++++++++++
scripts/Makefile.xpl | 21 +++++++++++++++++++
3 files changed, 41 insertions(+)
create mode 100644 arch/arm/mach-snapdragon/ipq5210-spl-wrap-elf.lds
diff --git a/arch/arm/mach-snapdragon/Kconfig b/arch/arm/mach-snapdragon/Kconfig
index d3de8693b5a..378f891a6ac 100644
--- a/arch/arm/mach-snapdragon/Kconfig
+++ b/arch/arm/mach-snapdragon/Kconfig
@@ -42,4 +42,10 @@ config SYS_CONFIG_NAME
Based on this option include/configs/<CONFIG_SYS_CONFIG_NAME>.h header
will be used for board configuration.
+config SPL_WRAPPER_ELF
+ bool "Create wrapper ELF for applicable platforms"
+ help
+ Some platforms embed the U-Boot SPL binary within an ELF as a
+ segment. Additional tools are used to convert this ELF into a
+ image that is usable for the boot ROM.
endif
diff --git a/arch/arm/mach-snapdragon/ipq5210-spl-wrap-elf.lds b/arch/arm/mach-snapdragon/ipq5210-spl-wrap-elf.lds
new file mode 100644
index 00000000000..d13a7e41c29
--- /dev/null
+++ b/arch/arm/mach-snapdragon/ipq5210-spl-wrap-elf.lds
@@ -0,0 +1,14 @@
+PHDRS {
+ ptype PT_LOAD FLAGS(0x7);
+}
+
+ENTRY(_entry)
+
+SECTIONS {
+ . = 0x8c24000;
+ _entry = . ;
+ data : {
+ *(.data)
+ . = ALIGN(4);
+ } :ptype
+}
diff --git a/scripts/Makefile.xpl b/scripts/Makefile.xpl
index c5ddf64c73f..15dee45053e 100644
--- a/scripts/Makefile.xpl
+++ b/scripts/Makefile.xpl
@@ -255,6 +255,23 @@ MKIMAGEFLAGS_boot.bin = -T zynqmpimage -R $(srctree)/$(CONFIG_BOOT_INIT_FILE) \
-n "$(shell cd $(srctree); readlink -f $(CONFIG_PMUFW_INIT_FILE))"
endif
+ifeq ($(CONFIG_SPL_WRAPPER_ELF),y)
+# Convert ELF to object file
+OBJCOPYFLAGS_$(SPL_BIN).bin.o = -I binary -O elf64-littleaarch64
+
+$(obj)/$(SPL_BIN).bin.o: $(obj)/$(SPL_BIN).bin FORCE
+ $(call if_changed,objcopy)
+
+# Wrap the object file inside a ELF
+QCOM_SPL_SOC = $(shell echo $(notdir "$(CONFIG_DEFAULT_DEVICE_TREE)") | cut -f1 -d-)
+QCOM_SPL_WRAP_LDS = $(srctree)/arch/arm/mach-snapdragon/$(QCOM_SPL_SOC)-spl-wrap-elf.lds
+LDFLAGS_$(SPL_BIN).wrap-elf = -T $(QCOM_SPL_WRAP_LDS)
+
+$(obj)/$(SPL_BIN).wrap-elf: $(obj)/$(SPL_BIN).bin.o FORCE
+ $(call if_changed,ld)
+
+endif
+
$(obj)/$(SPL_BIN)-align.bin: $(obj)/$(SPL_BIN).bin
@dd if=$< of=$@ conv=block,sync bs=4 2>/dev/null;
@@ -301,6 +318,10 @@ INPUTS-$(CONFIG_ARCH_ZYNQMP) += $(obj)/boot.bin
INPUTS-$(CONFIG_ARCH_MEDIATEK) += $(obj)/u-boot-spl-mtk.bin
+ifeq ($(CONFIG_ARCH_SNAPDRAGON),y)
+INPUTS-$(CONFIG_SPL_WRAPPER_ELF) += spl/u-boot-spl.wrap-elf
+endif
+
all: $(INPUTS-y)
quiet_cmd_cat = CAT $@
--
2.34.1
More information about the U-Boot
mailing list