| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /******************************************************************************* | 
 | 2 |  * Copyright (C) 2016, ZIXC Corporation. | 
 | 3 |  * | 
 | 4 |  * File Name:cmd_testusb.c | 
 | 5 |  * File Mark: | 
 | 6 |  * Description: | 
 | 7 |  * Others: | 
 | 8 |  * Version:       1.0 | 
 | 9 |  * Author:        zangxiaofeng | 
 | 10 |  * Date:          2013-4-22 | 
 | 11 |  * History 1: | 
 | 12 |  *     Date: | 
 | 13 |  *     Version: | 
 | 14 |  *     Author: | 
 | 15 |  *     Modification: | 
 | 16 |  * History 2: | 
 | 17 |   ********************************************************************************/ | 
 | 18 |  | 
 | 19 |  | 
 | 20 | /**************************************************************************** | 
 | 21 | * 	                                     Include files | 
 | 22 | ****************************************************************************/ | 
 | 23 | #include <common.h> | 
 | 24 | #include <command.h> | 
 | 25 | #include <net.h> | 
 | 26 | #include <jffs2/load_kernel.h> | 
 | 27 | #include "downloader_nand.h" | 
 | 28 | #include "downloader_config.h" | 
 | 29 | #include "errno.h" | 
 | 30 | /**************************************************************************** | 
 | 31 | *							Global Function Prototypes | 
 | 32 | ****************************************************************************/ | 
 | 33 | extern int downloader_serial_write(const char * buffer,unsigned int len); | 
 | 34 | extern int downloader_serial_read_actuallen(char * buffer,unsigned int len); | 
 | 35 |  | 
 | 36 | /******************************************************************************* | 
 | 37 |  * Function:do_reboot | 
 | 38 |  * Description: | 
 | 39 |  * Parameters: | 
 | 40 |  *	 Input: | 
 | 41 |  * | 
 | 42 |  *	 Output: | 
 | 43 |  * | 
 | 44 |  * Returns: | 
 | 45 |  * | 
 | 46 |  * | 
 | 47 |  * Others: | 
 | 48 |  ********************************************************************************/ | 
 | 49 | int do_testusb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) | 
 | 50 | { | 
 | 51 |     unsigned int size = 0; | 
 | 52 |     char ack[64] = {0}; | 
 | 53 |      | 
 | 54 |     if(argc < 2) | 
 | 55 |     { | 
 | 56 |         return cmd_usage(cmdtp); | 
 | 57 |     } | 
 | 58 |     size = (unsigned int)simple_strtoul (argv[1], NULL, 16); | 
 | 59 |  | 
 | 60 |     sprintf(ack,"DATA %x",size); | 
 | 61 |     downloader_serial_write(ack, strlen(ack)+1); | 
 | 62 |     downloader_serial_read_actuallen((char *)DOWNLOADER_BUFFER_BASE, size);  | 
 | 63 |     sprintf(ack,"OKAY"); | 
 | 64 |     downloader_serial_write(ack, strlen(ack)+1); | 
 | 65 |     return 0; | 
 | 66 | } | 
 | 67 |  | 
 | 68 | U_BOOT_CMD( | 
 | 69 | 	testusb, CONFIG_SYS_MAXARGS, 0, do_testusb, | 
 | 70 | 	"testusb: testusb [size]", | 
 | 71 | 	"" | 
 | 72 | ); | 
 | 73 |  |