[U-Boot] [PATCH v2 2/2] spl: Support loading a FIT from FAT FS

Lokesh Vutla lokeshvutla at ti.com
Mon Apr 11 06:51:54 CEST 2016


Detect a FIT when loading from a FAT File system and handle it using the
new FIT SPL support.

Reviewed-by: Tom Rini <trini at konsulko.com>
Reviewed-by: Simon Glass <sjg at chromium.org>
Signed-off-by: Lokesh Vutla <lokeshvutla at ti.com>
---
 common/spl/spl_fat.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c
index d761b26..3784f1b 100644
--- a/common/spl/spl_fat.c
+++ b/common/spl/spl_fat.c
@@ -39,6 +39,19 @@ static int spl_register_fat_device(struct blk_desc *block_dev, int partition)
 	return err;
 }
 
+static int h_spl_fit_read(struct spl_load_info *load, const char *filename,
+			  void *buf, ulong file_offset, ulong size)
+{
+	loff_t actread;
+	int ret;
+
+	ret = fat_read_file(filename, buf, file_offset, size, &actread);
+	if (ret)
+		return ret;
+	else
+		return actread;
+}
+
 int spl_load_image_fat(struct blk_desc *block_dev,
 						int partition,
 						const char *filename)
@@ -57,9 +70,19 @@ int spl_load_image_fat(struct blk_desc *block_dev,
 	if (err <= 0)
 		goto end;
 
-	spl_parse_image_header(header);
+	if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) {
+		struct spl_load_info load;
 
-	err = file_fat_read(filename, (u8 *)spl_image.load_addr, 0);
+		debug("Found FIT\n");
+		load.priv = NULL;
+		load.fs_read = h_spl_fit_read;
+
+		err = spl_fs_load_simple_fit(&load, filename, header);
+	} else {
+		spl_parse_image_header(header);
+
+		err = file_fat_read(filename, (u8 *)spl_image.load_addr, 0);
+	}
 
 end:
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
-- 
2.1.4



More information about the U-Boot mailing list