[U-Boot] [PATCH 2/3] spl: ubi: Add support for loading simple fitImage

Marek Vasut marex at denx.de
Tue May 28 01:49:14 UTC 2019


Add code to load simple fitImage from the kernel volume, the args
volume is unnecessary.

Signed-off-by: Marek Vasut <marex at denx.de>
Cc: Ladislav Michl <ladis at linux-mips.org>
Cc: Tom Rini <trini at konsulko.com>
---
 common/spl/spl_ubi.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c
index 67e5fadd7c..6addd46ece 100644
--- a/common/spl/spl_ubi.c
+++ b/common/spl/spl_ubi.c
@@ -11,6 +11,14 @@
 #include <ubispl.h>
 #include <spl.h>
 
+static ulong spl_ubi_load_read(struct spl_load_info *load, ulong sector,
+			       ulong count, void *buf)
+{
+	if (buf != (void *)CONFIG_SPL_LOAD_FIT_ADDRESS + sector)
+		memcpy(buf, (void *)(CONFIG_SYS_LOAD_ADDR + sector), count);
+	return count;
+}
+
 int spl_ubi_load_image(struct spl_image_info *spl_image,
 		       struct spl_boot_device *bootdev)
 {
@@ -54,7 +62,19 @@ int spl_ubi_load_image(struct spl_image_info *spl_image,
 		ret = ubispl_load_volumes(&info, volumes, 2);
 		if (!ret) {
 			header = (struct image_header *)volumes[0].load_addr;
-			spl_parse_image_header(spl_image, header);
+
+			if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
+			    image_get_magic(header) == FDT_MAGIC) {
+				struct spl_load_info load;
+
+				debug("Found FIT\n");
+				load.bl_len = 1;
+				load.read = spl_ubi_load_read;
+				spl_load_simple_fit(spl_image, &load, 0, header);
+			} else {
+				spl_parse_image_header(spl_image, header);
+			}
+
 			puts("Linux loaded.\n");
 			goto out;
 		}
-- 
2.20.1



More information about the U-Boot mailing list