diff options
author | Jiho Chu <jiho.chu@samsung.com> | 2017-05-25 19:36:06 +0900 |
---|---|---|
committer | Jiho Chu <jiho.chu@samsung.com> | 2017-06-01 18:02:34 +0900 |
commit | 8ac40bce02e2d556581ef6e4ad13e026449518ac (patch) | |
tree | 335ab07d6afa3efbcf935aa42786c0e5d915d7d5 | |
parent | 6df73267e54e0063baeafa307bda45cc3208cf32 (diff) | |
download | u-boot-submit/tizen/20170602.011955.tar.gz u-boot-submit/tizen/20170602.011955.tar.bz2 u-boot-submit/tizen/20170602.011955.zip |
cmd: nfsdown: support FAT type imagesubmit/tizen/20170602.011955accepted/tizen/unified/20170602.154735
Add function to support FAT type image update, especially
for ramdisk.img. It will download image from nfs server,
and update using fatwrite command.
Change-Id: I8d65a266137f1e6b15899662bb907998ae084879
Signed-off-by: Jiho Chu <jiho.chu@samsung.com>
-rw-r--r-- | cmd/nfsdown.c | 61 |
1 files changed, 48 insertions, 13 deletions
diff --git a/cmd/nfsdown.c b/cmd/nfsdown.c index eced7c3195..bd31a7a230 100644 --- a/cmd/nfsdown.c +++ b/cmd/nfsdown.c @@ -26,14 +26,14 @@ #define NFS_DOWNLOAD_ADDR "0x40000000" #endif -enum img_type { - IMG_TYPE_RAW, - IMG_TYPE_PART, +enum img_layout { + RAW_ADDR, + FS_FAT, }; struct img_info { char name[LEN_NAME]; - enum img_type type; + enum img_layout layout; /* mmc info */ uint hwpart; @@ -64,7 +64,8 @@ static char *g_update_image_names[] = { "rootfs.img", "system-data.img", "user.img", - "modules.img" + "modules.img", + "ramdisk.img" }; #if defined(CONFIG_CMD_USB) && defined(CONFIG_USB_HOST_ETHER) @@ -186,7 +187,7 @@ static struct img_info *create_img_info(struct mmc *mmc, char *str_info) goto create_img_err; if (!strncmp(tok[1], "raw", 3)) { - info->type = IMG_TYPE_RAW; + info->layout = RAW_ADDR; info->lba_start = simple_strtoul(tok[2], NULL, 0); info->lba_size = simple_strtoul(tok[3], NULL, 0); info->lba_blk_size = 512; @@ -199,7 +200,7 @@ static struct img_info *create_img_info(struct mmc *mmc, char *str_info) disk_partition_t partinfo; uint offset = 0; - info->type = IMG_TYPE_PART; + info->layout = RAW_ADDR; info->hwpart = simple_strtoul(tok[2], NULL, 0); info->part = simple_strtoul(tok[3], NULL, 0); @@ -217,10 +218,11 @@ static struct img_info *create_img_info(struct mmc *mmc, char *str_info) info->lba_size = partinfo.size - offset; info->lba_blk_size = partinfo.blksz; } else if (!strncmp(tok[1], "fat", 3)) { - error("nfsdown does not support fat update"); - goto create_img_err; + info->layout = FS_FAT; + info->hwpart = simple_strtoul(tok[2], NULL, 0); + info->part = simple_strtoul(tok[3], NULL, 0); } else { - error("Unrecognized img type: %s", tok[0]); + error("Unrecognized img layout: %s", tok[0]); goto create_img_err; } @@ -302,6 +304,33 @@ static int do_nfs_to_mmc(struct mmc *mmc, char *buf_addr, char *file_path, return (int)net_boot_file_size; } +static int do_nfs_to_fat(char *buf_addr, char *file_path, char *file_name, + uint dev, uint part) +{ + char *_argv[3]; + uint _size; + int ret; + int repeatable; + char buf[256]; + + _argv[0] = "nfs"; + _argv[1] = buf_addr; + _argv[2] = file_path; + + ret = cmd_process(0, 3, _argv, &repeatable, NULL); + if (ret != CMD_RET_SUCCESS) { + puts("nfs download failed!!\n"); + return -1; + } + + _size = net_boot_file_size; + snprintf(buf, 256, "fatwrite mmc %d:%d %s %s %x", dev, part, buf_addr, + file_name, _size); + run_command(buf, 0); + + return _size; +} + int do_nfs_down(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { char *nfs_path; @@ -366,9 +395,15 @@ int do_nfs_down(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) list_for_each_entry(info, &img_info_list, list) { snprintf(src_path, LEN_BUF, "%s/%s", nfs_path, info->name); - size = do_nfs_to_mmc(mmc, NFS_DOWNLOAD_ADDR, src_path, - info->hwpart, info->lba_start, - info->lba_size, info->lba_blk_size); + if (info->layout == FS_FAT) + size = do_nfs_to_fat(NFS_DOWNLOAD_ADDR, src_path, + info->name, info->hwpart, + info->part); + else + size = do_nfs_to_mmc(mmc, NFS_DOWNLOAD_ADDR, src_path, + info->hwpart, info->lba_start, + info->lba_size, + info->lba_blk_size); if (size > 0) { struct img_comp *new_comp; |