diff options
author | Benoît Thébaudeau <benoit.thebaudeau@advansee.com> | 2012-09-18 08:14:56 +0000 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2012-09-26 11:11:32 -0700 |
commit | 1170e634dd2a6fdd541ae2153fd3fd73919da8fc (patch) | |
tree | dd1cdb0854199fad95296c84e54eeb319818b71b /common | |
parent | 9aa90c1df09d6c0a43a5e000ba9d66d6f13b29cb (diff) | |
download | u-boot-1170e634dd2a6fdd541ae2153fd3fd73919da8fc.tar.gz u-boot-1170e634dd2a6fdd541ae2153fd3fd73919da8fc.tar.xz u-boot-1170e634dd2a6fdd541ae2153fd3fd73919da8fc.zip |
FAT: Make it possible to read from any file position
When storage devices contain files larger than the embedded RAM, it is
useful to be able to read these files by chunks, e.g. for a software
update to the embedded NAND Flash from an external storage device (USB
stick, SD card, etc.).
Hence, this patch makes it possible by adding a new FAT API to read
files from a given position. This patch also adds this feature to the
fatload command.
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Cc: Wolfgang Denk <wd@denx.de>
Signed-off-by: Tom Rini <trini@ti.com>
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_fat.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/common/cmd_fat.c b/common/cmd_fat.c index 01e02f5b2b..55585c6cf4 100644 --- a/common/cmd_fat.c +++ b/common/cmd_fat.c @@ -37,7 +37,8 @@ int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { long size; unsigned long offset; - unsigned long count; + unsigned long count = 0; + unsigned long pos = 0; char buf [12]; block_dev_desc_t *dev_desc=NULL; disk_partition_t info; @@ -45,7 +46,7 @@ int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (argc < 5) { printf("usage: fatload <interface> [<dev[:part]>] " - "<addr> <filename> [bytes]\n"); + "<addr> <filename> [bytes [pos]]\n"); return 1; } @@ -60,11 +61,11 @@ int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 1; } offset = simple_strtoul(argv[3], NULL, 16); - if (argc == 6) + if (argc >= 6) count = simple_strtoul(argv[5], NULL, 16); - else - count = 0; - size = file_fat_read(argv[4], (unsigned char *)offset, count); + if (argc >= 7) + pos = simple_strtoul(argv[6], NULL, 16); + size = file_fat_read_at(argv[4], pos, (unsigned char *)offset, count); if(size==-1) { printf("\n** Unable to read \"%s\" from %s %d:%d **\n", @@ -82,11 +83,15 @@ int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) U_BOOT_CMD( - fatload, 6, 0, do_fat_fsload, + fatload, 7, 0, do_fat_fsload, "load binary file from a dos filesystem", - "<interface> [<dev[:part]>] <addr> <filename> [bytes]\n" - " - load binary file 'filename' from 'dev' on 'interface'\n" - " to address 'addr' from dos filesystem" + "<interface> [<dev[:part]>] <addr> <filename> [bytes [pos]]\n" + " - Load binary file 'filename' from 'dev' on 'interface'\n" + " to address 'addr' from dos filesystem.\n" + " 'pos' gives the file position to start loading from.\n" + " If 'pos' is omitted, 0 is used. 'pos' requires 'bytes'.\n" + " 'bytes' gives the size to load. If 'bytes' is 0 or omitted,\n" + " the load stops on end of file." ); int do_fat_ls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |