diff options
-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; |