mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2024-11-26 04:26:16 +02:00
now the nprog function can read the argument
This commit is contained in:
parent
5db3e003da
commit
6082b4557d
@ -32,11 +32,17 @@
|
||||
#include <sys/stat.h>
|
||||
#include <confuse.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_out_t nand_out;
|
||||
static struct fw_args_t fw_args;
|
||||
unsigned int total_size;
|
||||
unsigned char code_buf[4 * 512 * 1024];
|
||||
unsigned char cs[16];
|
||||
|
||||
static int parse_configure(char * file_path)
|
||||
{
|
||||
@ -284,24 +290,26 @@ out:
|
||||
usb_ingenic_cleanup(&ingenic_dev);
|
||||
return res;
|
||||
}
|
||||
int nprog(int com_argc, char **com_argv)
|
||||
int nprog(void)
|
||||
{
|
||||
#if 0
|
||||
unsigned int i;
|
||||
int index;
|
||||
int c;
|
||||
char *image_file;
|
||||
char *help = "\n Usage: nprog [options] ..."
|
||||
"\n -s\tstart page number"
|
||||
"\n -i\timage file name"
|
||||
"\n -d\tdevice index number"
|
||||
"\n -f\tflash index number"
|
||||
"\n image type:"
|
||||
char *help = "\n Usage: nprog (1) (2) (3) (4) (5)"
|
||||
"\n (1)\tstart page number"
|
||||
"\n (2)\timage file name"
|
||||
"\n (3)\tdevice index number"
|
||||
"\n (4)\tflash index number"
|
||||
"\n (5) image type must be:"
|
||||
"\n \t-n:\tno oob"
|
||||
"\n \t-o:\twith oob no ecc"
|
||||
"\n \t-e:\twith oob and ecc";
|
||||
opterr = 0;
|
||||
if (com_argc != 10) {
|
||||
nand_in.buf = code_buf;
|
||||
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("%s", help);
|
||||
return 0;
|
||||
@ -309,52 +317,19 @@ int nprog(int com_argc, char **com_argv)
|
||||
for (i = 0; i < MAX_DEV_NUM; i++)
|
||||
(nand_in.cs_map)[i] = 0;
|
||||
|
||||
while ((c = getopt (com_argc, com_argv, "s:i:d:f:noe")) != -1)
|
||||
switch (c)
|
||||
{
|
||||
|
||||
case 's':
|
||||
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;
|
||||
break;
|
||||
case '?':
|
||||
if (optopt == 's' ||
|
||||
optopt == 'i' ||
|
||||
optopt == 'd' ||
|
||||
optopt == 'f')
|
||||
printf ("Option -%c requires an argument.\n", optopt);
|
||||
else if (isprint (optopt))
|
||||
printf ("Unknown option `-%c'.\n", optopt);
|
||||
else
|
||||
printf ("Unknown option character `\\x%x'.\n", optopt);
|
||||
printf("%s", help);
|
||||
return -1;
|
||||
default:
|
||||
printf("%s", help);
|
||||
return -1;
|
||||
}
|
||||
|
||||
nand_in.start = atoi(com_argv[1]);
|
||||
image_file = com_argv[2];
|
||||
nand_in.dev = atoi(com_argv[3]);
|
||||
(nand_in.cs_map)[atoi(com_argv[4])] = 1;
|
||||
if (!strcmp(com_argv[5],"-e"))
|
||||
nand_in.option = OOB_ECC;
|
||||
else if (!strcmp(com_argv[5],"-o"))
|
||||
nand_in.option = OOB_NO_ECC;
|
||||
else if (!strcmp(com_argv[5],"-n"))
|
||||
nand_in.option = NO_OOB;
|
||||
else
|
||||
printf("%s", help);
|
||||
#if 0
|
||||
if (Hand.nand_plane > 1)
|
||||
/* API_Nand_Program_File_Planes(&nand_in,&nand_out,com_argv[2]); */
|
||||
else
|
||||
@ -363,12 +338,12 @@ int nprog(int com_argc, char **com_argv)
|
||||
printf("\n Flash check result:");
|
||||
for (i = 0; i < 16; 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,
|
||||
nand_in.dev,
|
||||
(nand_in.cs_map)[atoi(optarg)],
|
||||
(nand_in.cs_map)[atoi(com_argv[4])],
|
||||
nand_in.option);
|
||||
#endif
|
||||
printf("\n not implement yet!! ");
|
||||
|
||||
return 1;
|
||||
|
@ -22,7 +22,11 @@
|
||||
#ifndef __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 nprog(int com_argc, char **com_argv);
|
||||
int nprog(void);
|
||||
|
||||
#endif /* __CMD_H__ */
|
||||
|
@ -27,11 +27,8 @@
|
||||
#include "cmd.h"
|
||||
#include "config.h"
|
||||
|
||||
#define COMMAND_NUM 31
|
||||
#define MAX_ARGC 10
|
||||
#define MAX_COMMAND_LENGTH 100
|
||||
static int com_argc;
|
||||
static char com_argv[MAX_ARGC][MAX_COMMAND_LENGTH];
|
||||
int com_argc;
|
||||
char com_argv[MAX_ARGC][MAX_COMMAND_LENGTH];
|
||||
|
||||
static const char COMMAND[][30]=
|
||||
{
|
||||
@ -167,7 +164,7 @@ int command_handle(char *buf)
|
||||
if (!cmd) return -1;
|
||||
switch (cmd) {
|
||||
case 11:
|
||||
return nprog(com_argc, com_argv);
|
||||
return nprog();
|
||||
case 12:
|
||||
handle_help();
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user