1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-11-22 22:00:36 +02:00

add nand erase (nerase) command

This commit is contained in:
xiangfu 2009-06-08 08:52:39 +00:00
parent b93c934c64
commit 664f9a743f
3 changed files with 44 additions and 9 deletions

View File

@ -40,7 +40,7 @@ extern char com_argv[MAX_ARGC][MAX_COMMAND_LENGTH];
struct ingenic_dev ingenic_dev; struct ingenic_dev ingenic_dev;
struct hand hand; struct hand hand;
static struct nand_in nand_in; struct nand_in nand_in;
static struct nand_out nand_out; static struct nand_out nand_out;
unsigned int total_size; unsigned int total_size;
unsigned char code_buf[4 * 512 * 1024]; unsigned char code_buf[4 * 512 * 1024];
@ -544,6 +544,8 @@ int init_nand_in(void)
nand_in.check = error_check; nand_in.check = error_check;
nand_in.dev = 0; nand_in.dev = 0;
nand_in.cs_map = cs; nand_in.cs_map = cs;
memset(nand_in.cs_map, 0, MAX_DEV_NUM);
nand_in.max_chip = 16; nand_in.max_chip = 16;
return 0; return 0;
} }
@ -561,7 +563,6 @@ int nand_prog(void)
"\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";
init_nand_in();
if (com_argc != 6) { if (com_argc != 6) {
printf("\n not enough argument."); printf("\n not enough argument.");
@ -569,8 +570,7 @@ int nand_prog(void)
return 0; return 0;
} }
for (i = 0; i < MAX_DEV_NUM; i++) init_nand_in();
(nand_in.cs_map)[i] = 0;
nand_in.start = atoi(com_argv[1]); nand_in.start = atoi(com_argv[1]);
image_file = com_argv[2]; image_file = com_argv[2];
@ -613,9 +613,6 @@ int nand_query(void)
} }
init_nand_in(); init_nand_in();
for (i = 0; i < MAX_DEV_NUM; i++)
(nand_in.cs_map)[i] = 0;
nand_in.dev = atoi(com_argv[1]); nand_in.dev = atoi(com_argv[1]);
(nand_in.cs_map)[atoi(com_argv[2])] = 1; (nand_in.cs_map)[atoi(com_argv[2])] = 1;

View File

@ -22,6 +22,8 @@
#ifndef __CMD_H__ #ifndef __CMD_H__
#define __CMD_H__ #define __CMD_H__
#include "usb_boot_defines.h"
#define COMMAND_NUM 31 #define COMMAND_NUM 31
#define MAX_ARGC 10 #define MAX_ARGC 10
#define MAX_COMMAND_LENGTH 100 #define MAX_COMMAND_LENGTH 100
@ -29,5 +31,6 @@
int boot(char *stage1_path, char *stage2_path); int boot(char *stage1_path, char *stage2_path);
int nand_prog(void); int nand_prog(void);
int nand_query(void); int nand_query(void);
int nand_erase(struct nand_in *nand_in);
#endif /* __CMD_H__ */ #endif /* __CMD_H__ */

View File

@ -27,6 +27,7 @@
#include "cmd.h" #include "cmd.h"
#include "config.h" #include "config.h"
extern struct nand_in nand_in;
int com_argc; int com_argc;
char com_argv[MAX_ARGC][MAX_COMMAND_LENGTH]; char com_argv[MAX_ARGC][MAX_COMMAND_LENGTH];
@ -42,7 +43,7 @@ static const char COMMAND[][30]=
"nerase", "nerase",
"nread", "nread",
"nreadraw", "nreadraw",
"nreadoob", "nreadoob", /* index 10 */
"nprog", "nprog",
"help", "help",
"version", "version",
@ -52,7 +53,7 @@ static const char COMMAND[][30]=
"readnand", "readnand",
"gpios", "gpios",
"gpioc", "gpioc",
"boot", "boot", /* index 20 */
"list", "list",
"select", "select",
"unselect", "unselect",
@ -110,6 +111,37 @@ static int handle_fconfig(void)
return 1; return 1;
} }
/* need transfer two para :blk_num ,start_blk */
int handle_nerase(void)
{
int i;
if (com_argc < 5) {
printf("\n Usage:");
printf(" nerase (1) (2) (3) (4) ");
printf("\n 1:start block number"
"\n 2:block length"
"\n 3:device index number"
"\n 4:flash chip index number");
return -1;
}
init_nand_in();
nand_in.start = atoi(com_argv[1]);
nand_in.length = atoi(com_argv[2]);
nand_in.dev = atoi(com_argv[3]);
if (atoi(com_argv[4]) >= MAX_DEV_NUM) {
printf("\n Flash index number overflow!");
return -1;
}
(nand_in.cs_map)[atoi(com_argv[4])] = 1;
if (nand_erase(&nand_in) < 1)
return -1;
return 1;
}
int command_interpret(char * com_buf) int command_interpret(char * com_buf)
{ {
char *buf = com_buf; char *buf = com_buf;
@ -158,6 +190,9 @@ int command_handle(char *buf)
case 6: case 6:
nand_query(); nand_query();
break; break;
case 7:
handle_nerase();
break;
case 11: case 11:
nand_prog(); nand_prog();
break; break;