[PATCH] spl: add linux initrd ramdisk properties to dtb

Anatolij Gustschin agust at denx.de
Wed Jun 25 23:01:32 CEST 2025


Currently when SPL is booting FIT images with ramdisk
the kernel fails to find the ramdisk and panics.

This is due to missing "linux,initrd-start/end"
properties in the device tree. Add fixup to insert
these properties if a ramdisk is detected in the
FIT image.

Signed-off-by: Anatolij Gustschin <agust at denx.de>
---
 common/spl/spl_fit.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index b3824af475f..29f06778507 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -567,6 +567,17 @@ static int spl_fit_image_get_os(const void *fit, int noffset, uint8_t *os)
 	return 0;
 }
 
+static int spl_fit_image_is_ramdisk(const void *fit, int node)
+{
+	const char *type;
+
+	type = fdt_getprop(fit, node, FIT_TYPE_PROP, NULL);
+	if (!type)
+		return 0;
+
+	return !strcmp(type, FIT_RAMDISK_PROP);
+}
+
 /*
  * The purpose of the FIT load buffer is to provide a memory location that is
  * independent of the load address of any FIT component.
@@ -890,6 +901,18 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 			spl_image->fdt_addr = image_info.fdt_addr;
 		}
 
+		if (spl_fit_image_is_ramdisk(ctx.fit, node)) {
+			/*
+			 * Insert initrd properties into dtb for
+			 * ramdisk detection in kernel
+			 */
+			if (spl_image->fdt_addr) {
+				fdt_initrd(spl_image->fdt_addr,
+					   image_info.load_addr,
+					   image_info.load_addr + image_info.size);
+			}
+		}
+
 		/*
 		 * If the "firmware" image did not provide an entry point,
 		 * use the first valid entry point from the loadables.
-- 
2.25.1



More information about the U-Boot mailing list