| /******************************************************************************* |
| * Copyright (C) 2016, ZIXC Corporation. |
| * |
| * File Name:cmd_compat_write.c |
| * File Mark: |
| * Description: |
| * Others: |
| * Version: 1.0 |
| * Author: zangxiaofeng |
| * Date: 2013-3-13 |
| * History 1: |
| * Date: |
| * Version: |
| * Author: |
| * Modification: |
| * History 2: |
| ********************************************************************************/ |
| |
| |
| /**************************************************************************** |
| * Include files |
| ****************************************************************************/ |
| #include <common.h> |
| #include <command.h> |
| #include <net.h> |
| #include <jffs2/load_kernel.h> |
| #include "downloader_config.h" |
| #include "downloader_nand.h" |
| #include "downloader_serial.h" |
| #include "errno.h" |
| #include <boot_mode.h> |
| /**************************************************************************** |
| * Global Function Prototypes |
| ****************************************************************************/ |
| |
| /******************************************************************************* |
| * Function:do_compat_write |
| * Description: |
| * Parameters: |
| * Input: |
| * |
| * Output: |
| * |
| * Returns: |
| * |
| * |
| * Others: |
| ********************************************************************************/ |
| int do_compat_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| { |
| partition_entry_t *part = NULL; |
| char *par = NULL; |
| char ack[64]={0}; |
| unsigned int offset = 0; |
| unsigned int size = 0; |
| unsigned int ret = 0; |
| |
| if(argc<4) |
| { |
| return cmd_usage(cmdtp); |
| } |
| |
| par = argv[1]; |
| offset = (unsigned int)simple_strtoul (argv[2], NULL, 16); |
| size = (unsigned int)simple_strtoul (argv[3], NULL, 16); |
| part = downloader_get_part_dl(par); |
| if(part == NULL) |
| { |
| sprintf(ack,"FAIL INVALID PARTITION TYPE"); |
| downloader_serial_write(ack, strlen(ack)+1); |
| return -1; |
| } |
| |
| if((read_boot_flashtype() == IF_TYPE_NOR) |
| && (strcmp((const char *)part->part_type,"nand") == 0)) |
| { |
| ret = do_nor_write(part, par, offset,size); |
| return ret; |
| } |
| |
| if(strcmp((const char *)part->part_type,"nand") == 0) |
| { |
| ret = do_nand_write(part, par, offset, size); |
| return ret; |
| } |
| else if (strcmp((const char *)part->part_type,"fs") == 0) |
| { |
| ret = do_yaffs_write(part, par, offset, size); |
| return ret; |
| } |
| else if (strcmp((const char *)part->part_type,"ddr") == 0) |
| { |
| ret = do_ram_write(offset, size); |
| return ret; |
| } |
| else if (strcmp((const char *)part->part_type,"raw") == 0) |
| { |
| ret = do_raw_write(offset, size); |
| return ret; |
| } |
| else |
| { |
| sprintf(ack,"FAIL INVALID PARTITION TYPE"); |
| downloader_serial_write(ack, strlen(ack)+1); |
| return -1; |
| } |
| } |
| U_BOOT_CMD( |
| compat_write, CONFIG_SYS_MAXARGS, 0, do_compat_write, |
| "download: compat_write [partition][offset][size]", |
| "" |
| ); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |