From 3f17eac1f206c33084d83d6cb9535f7aa474fbc1 Mon Sep 17 00:00:00 2001 From: Chanho Park Date: Wed, 2 Sep 2015 11:48:06 +0900 Subject: [PATCH] common: fastboot: support fatfs for sdfuse This patch allows fat file system for sd_fuse. When ext4 is not available of the partition, sdfuse will fall back to fat file system. For example, fatfs is in the first partition: sdfuse flash 1 kernel zImage sdfuse flash 1 dtb exynos5422-artik10.dtb Change-Id: If66e64ab3b7529469dc2902b90470a6a575ececb Signed-off-by: Chanho Park --- common/cmd_fastboot.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c index 5fd7e52eb..23629b9d7 100644 --- a/common/cmd_fastboot.c +++ b/common/cmd_fastboot.c @@ -2113,7 +2113,7 @@ U_BOOT_CMD( extern struct ext2fs_node *ext4fs_file; static int update_from_sd(int part_num, const char *part, const char *file) { - int ret = 1; + int ret = 1, is_fat = 0; long size; unsigned long addr; unsigned long offset = 0; @@ -2138,8 +2138,12 @@ static int update_from_sd(int part_num, const char *part, const char *file) ret = ext4fs_probe(dev_desc, &part_info); if (ret) { - printf("Cannot probe ext4 partition\n"); - return -1; + /* Fall back to fat file system */ + if (fat_set_blk_dev(dev_desc, &part_info) != 0) { + printf("Cannot probe ext4 or fat partition\n"); + return -1; + } + is_fat = 1; } reset_handler(); @@ -2147,7 +2151,11 @@ static int update_from_sd(int part_num, const char *part, const char *file) addr = CFG_FASTBOOT_TRANSFER_BUFFER; - file_len = ext4fs_open(file); + if (is_fat) + file_len = fat_size(file); + else + file_len = ext4fs_open(file); + if (file_len < 0) { printf("File not found %s\n", file); return -1; @@ -2165,7 +2173,11 @@ static int update_from_sd(int part_num, const char *part, const char *file) if (count > CHUNK_SIZE) count = CHUNK_SIZE; - size = ext4fs_read_file(ext4fs_file, offset, count, addr); + if (is_fat) + size = file_fat_read_at(file, offset, addr, count); + else + size = ext4fs_read_file(ext4fs_file, offset, count, + addr); if (size == -1) { printf("Failed to read %s\n", file); ret = -1; @@ -2191,7 +2203,8 @@ static int update_from_sd(int part_num, const char *part, const char *file) } err_out: - ext4fs_close(); + if (!is_fat) + ext4fs_close(); reset_handler(); return ret; } -- 2.34.1