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

Lokesh Vutla lokeshvutla at ti.com
Thu Apr 14 07:15:58 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>
Reviewed-by: Mugunthan V N <mugunthanvnm at ti.com>
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