1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-11-29 20:14:03 +02:00

now the nprog function can read the argument

This commit is contained in:
xiangfu 2009-04-30 06:41:49 +00:00
parent 5db3e003da
commit 6082b4557d
3 changed files with 44 additions and 68 deletions

View File

@ -32,11 +32,17 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <confuse.h> #include <confuse.h>
#include <ctype.h> #include <ctype.h>
#include "cmd.h"
extern int com_argc;
extern char com_argv[MAX_ARGC][MAX_COMMAND_LENGTH];
static struct nand_in_t nand_in; static struct nand_in_t nand_in;
static struct nand_out_t nand_out; static struct nand_out_t nand_out;
static struct fw_args_t fw_args; static struct fw_args_t fw_args;
unsigned int total_size; unsigned int total_size;
unsigned char code_buf[4 * 512 * 1024];
unsigned char cs[16];
static int parse_configure(char * file_path) static int parse_configure(char * file_path)
{ {
@ -284,24 +290,26 @@ out:
usb_ingenic_cleanup(&ingenic_dev); usb_ingenic_cleanup(&ingenic_dev);
return res; return res;
} }
int nprog(int com_argc, char **com_argv) int nprog(void)
{ {
#if 0
unsigned int i; unsigned int i;
int index;
int c;
char *image_file; char *image_file;
char *help = "\n Usage: nprog [options] ..." char *help = "\n Usage: nprog (1) (2) (3) (4) (5)"
"\n -s\tstart page number" "\n (1)\tstart page number"
"\n -i\timage file name" "\n (2)\timage file name"
"\n -d\tdevice index number" "\n (3)\tdevice index number"
"\n -f\tflash index number" "\n (4)\tflash index number"
"\n image type:" "\n (5) image type must be:"
"\n \t-n:\tno oob" "\n \t-n:\tno oob"
"\n \t-o:\twith oob no ecc" "\n \t-o:\twith oob no ecc"
"\n \t-e:\twith oob and ecc"; "\n \t-e:\twith oob and ecc";
opterr = 0; nand_in.buf = code_buf;
if (com_argc != 10) { nand_in.check = NULL;
nand_in.dev = 0;
nand_in.cs_map = cs;
nand_in.max_chip =16;
if (com_argc != 6) {
printf("\n not enough argument."); printf("\n not enough argument.");
printf("%s", help); printf("%s", help);
return 0; return 0;
@ -309,52 +317,19 @@ int nprog(int com_argc, char **com_argv)
for (i = 0; i < MAX_DEV_NUM; i++) for (i = 0; i < MAX_DEV_NUM; i++)
(nand_in.cs_map)[i] = 0; (nand_in.cs_map)[i] = 0;
while ((c = getopt (com_argc, com_argv, "s:i:d:f:noe")) != -1) nand_in.start = atoi(com_argv[1]);
switch (c) image_file = com_argv[2];
{ nand_in.dev = atoi(com_argv[3]);
(nand_in.cs_map)[atoi(com_argv[4])] = 1;
case 's': if (!strcmp(com_argv[5],"-e"))
nand_in.start = atoi(optarg);
break;
case 'i':
image_file = optarg;
break;
case 'd':
nand_in.dev = atoi(optarg);
break;
case 'f':
(nand_in.cs_map)[atoi(optarg)] = 1;
if (atoi(optarg) >= MAX_DEV_NUM) {
printf("\n Flash index number overflow!");
return -1;
}
break;
case 'n':
nand_in.option = NO_OOB;
break;
case 'o':
nand_in.option = OOB_NO_ECC;
break;
case 'e':
nand_in.option = OOB_ECC; nand_in.option = OOB_ECC;
break; else if (!strcmp(com_argv[5],"-o"))
case '?': nand_in.option = OOB_NO_ECC;
if (optopt == 's' || else if (!strcmp(com_argv[5],"-n"))
optopt == 'i' || nand_in.option = NO_OOB;
optopt == 'd' ||
optopt == 'f')
printf ("Option -%c requires an argument.\n", optopt);
else if (isprint (optopt))
printf ("Unknown option `-%c'.\n", optopt);
else else
printf ("Unknown option character `\\x%x'.\n", optopt);
printf("%s", help); printf("%s", help);
return -1; #if 0
default:
printf("%s", help);
return -1;
}
if (Hand.nand_plane > 1) if (Hand.nand_plane > 1)
/* API_Nand_Program_File_Planes(&nand_in,&nand_out,com_argv[2]); */ /* API_Nand_Program_File_Planes(&nand_in,&nand_out,com_argv[2]); */
else else
@ -363,12 +338,12 @@ int nprog(int com_argc, char **com_argv)
printf("\n Flash check result:"); printf("\n Flash check result:");
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
printf(" %d", (nand_out.status)[i]); printf(" %d", (nand_out.status)[i]);
printf("nprog %d %s %d %d %d", nand_in.start, #endif
printf("\n nprog %d %s %d %d %d", nand_in.start,
image_file, image_file,
nand_in.dev, nand_in.dev,
(nand_in.cs_map)[atoi(optarg)], (nand_in.cs_map)[atoi(com_argv[4])],
nand_in.option); nand_in.option);
#endif
printf("\n not implement yet!! "); printf("\n not implement yet!! ");
return 1; return 1;

View File

@ -22,7 +22,11 @@
#ifndef __CMD_H__ #ifndef __CMD_H__
#define __CMD_H__ #define __CMD_H__
#define COMMAND_NUM 31
#define MAX_ARGC 10
#define MAX_COMMAND_LENGTH 100
int boot(char *stage1_path, char *stage2_path, char *config_path); int boot(char *stage1_path, char *stage2_path, char *config_path);
int nprog(int com_argc, char **com_argv); int nprog(void);
#endif /* __CMD_H__ */ #endif /* __CMD_H__ */

View File

@ -27,11 +27,8 @@
#include "cmd.h" #include "cmd.h"
#include "config.h" #include "config.h"
#define COMMAND_NUM 31 int com_argc;
#define MAX_ARGC 10 char com_argv[MAX_ARGC][MAX_COMMAND_LENGTH];
#define MAX_COMMAND_LENGTH 100
static int com_argc;
static char com_argv[MAX_ARGC][MAX_COMMAND_LENGTH];
static const char COMMAND[][30]= static const char COMMAND[][30]=
{ {
@ -167,7 +164,7 @@ int command_handle(char *buf)
if (!cmd) return -1; if (!cmd) return -1;
switch (cmd) { switch (cmd) {
case 11: case 11:
return nprog(com_argc, com_argv); return nprog();
case 12: case 12:
handle_help(); handle_help();
break; break;