[PATCH 5/5] spl: fit: add ramdisk load

Francesco Valla francesco at valla.it
Tue Apr 28 22:24:46 CEST 2026


Add ramdisk loading logic to the "full" SPL FIT loader, as well as the
corresponding FDT fixup. This is required for proper support of falcon
boot using FIT images, but is useless for a U-Boot launch, so make it
depend on SPL_OS_BOOT.

Signed-off-by: Francesco Valla <francesco at valla.it>
---
 common/spl/spl.c     | 17 ++++++++++++++---
 common/spl/spl_fit.c | 18 ++++++++++++++++--
 include/spl.h        | 20 ++++++++++++++++++++
 3 files changed, 50 insertions(+), 5 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index a09ebac62c2a..b4890ba9ae83 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -130,7 +130,7 @@ void __weak spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
 }
 
-void spl_fixup_fdt(void *fdt_blob)
+void spl_fixup_fdt(void *fdt_blob, ulong initrd_start, ulong initrd_end)
 {
 #if defined(CONFIG_SPL_OF_LIBFDT)
 	int err;
@@ -172,6 +172,14 @@ void spl_fixup_fdt(void *fdt_blob)
 			return;
 		}
 	}
+
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT)
+	err = fdt_initrd(fdt_blob, initrd_start, initrd_end);
+	if (err) {
+		printf(PHASE_PROMPT "fdt_initrd err - %d\n", err);
+		return;
+	}
+#endif
 #endif
 }
 
@@ -789,7 +797,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 		debug("Jumping to %s...\n", xpl_name(xpl_next_phase()));
 	} else if (CONFIG_IS_ENABLED(ATF) && os == IH_OS_ARM_TRUSTED_FIRMWARE) {
 		debug("Jumping to U-Boot via ARM Trusted Firmware\n");
-		spl_fixup_fdt(spl_image_fdt_addr(&spl_image));
+		spl_fixup_fdt(spl_image_fdt_addr(&spl_image),
+			      spl_image_ramdisk_start(&spl_image),
+			      spl_image_ramdisk_end(&spl_image));
 		jumper = &spl_invoke_atf;
 	} else if (CONFIG_IS_ENABLED(OPTEE_IMAGE) && os == IH_OS_TEE) {
 		debug("Jumping to U-Boot via OP-TEE\n");
@@ -804,7 +814,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 			fdt = (void *)SPL_PAYLOAD_ARGS_ADDR;
 		else
 			fdt = spl_image_fdt_addr(&spl_image);
-		spl_fixup_fdt(fdt);
+		spl_fixup_fdt(fdt, spl_image_ramdisk_start(&spl_image),
+			      spl_image_ramdisk_end(&spl_image));
 		spl_board_prepare_for_linux();
 		spl_image.arg = fdt;
 		jumper = &jump_to_image_linux;
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 46ebcabe56a1..51933ba7bebf 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -950,8 +950,8 @@ int spl_load_fit_image(struct spl_image_info *spl_image,
 	const char *fit_uname_config = NULL;
 	ulong fdt_hack;
 	const char *uname;
-	ulong fw_data = 0, dt_data = 0, img_data = 0;
-	ulong fw_len = 0, dt_len = 0, img_len = 0;
+	ulong fw_data = 0, dt_data = 0, img_data = 0, rd_data = 0;
+	ulong fw_len = 0, dt_len = 0, img_len = 0, rd_len = 0;
 	int idx, conf_noffset;
 	int ret;
 
@@ -1011,6 +1011,20 @@ int spl_load_fit_image(struct spl_image_info *spl_image,
 		}
 	}
 
+	if (spl_image->os != IH_OS_U_BOOT) {
+#ifdef CONFIG_SPL_FIT_SIGNATURE
+		images.verify = 1;
+#endif
+		ret = fit_image_load(&images, virt_to_phys((void *)header), NULL,
+				     &fit_uname_config, IH_ARCH_DEFAULT,
+				     IH_TYPE_RAMDISK, -1, FIT_LOAD_OPTIONAL,
+				     &rd_data, &rd_len);
+		if (ret >= 0) {
+			spl_image->ramdisk_addr = rd_data;
+			spl_image->ramdisk_size = rd_len;
+		}
+	}
+
 	conf_noffset = fit_conf_get_node((const void *)header,
 					 fit_uname_config);
 	if (conf_noffset < 0)
diff --git a/include/spl.h b/include/spl.h
index 5078d7525abb..a390cdd841b9 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -288,6 +288,8 @@ struct spl_image_info {
 	ulong entry_point;
 #if CONFIG_IS_ENABLED(LOAD_FIT) || CONFIG_IS_ENABLED(LOAD_FIT_FULL)
 	void *fdt_addr;
+	ulong ramdisk_addr;
+	ulong ramdisk_size;
 #endif
 #if defined(CONFIG_BOOTM_OPTEE) && defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
 	ulong optee_addr;
@@ -325,6 +327,24 @@ static inline void *spl_image_fdt_addr(struct spl_image_info *info)
 #endif
 }
 
+static inline ulong spl_image_ramdisk_start(struct spl_image_info *info)
+{
+#if CONFIG_IS_ENABLED(LOAD_FIT) || CONFIG_IS_ENABLED(LOAD_FIT_FULL)
+	return info->ramdisk_addr;
+#else
+	return 0;
+#endif
+}
+
+static inline ulong spl_image_ramdisk_end(struct spl_image_info *info)
+{
+#if CONFIG_IS_ENABLED(LOAD_FIT) || CONFIG_IS_ENABLED(LOAD_FIT_FULL)
+	return info->ramdisk_addr + info->ramdisk_size;
+#else
+	return 0;
+#endif
+}
+
 struct spl_load_info;
 
 /**

-- 
2.54.0



More information about the U-Boot mailing list