1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-12-23 21:56:46 +02:00

change cmd_boot.c to cmd.c, put all the command in this file.

add some struct nprog needs.
remove handle_help handle_exit function.
This commit is contained in:
xiangfu 2009-04-29 07:25:12 +00:00
parent f93b8a829b
commit 6e4e15eb31
5 changed files with 115 additions and 47 deletions

View File

@ -34,7 +34,7 @@ CFLAGS += -pedantic -Wall -W -O1 -g3 -std=gnu99
LDFLAGS += -lusb -lconfuse LDFLAGS += -lusb -lconfuse
BINARY_NAME = inflash BINARY_NAME = inflash
SRC_C= main.c usb.c cmd_boot.c command_line.c SRC_C= main.c usb.c cmd.c command_line.c
SRC_H= ingenic_usb.h usb_boot_defines.h command_line.h cmd.h config.h SRC_H= ingenic_usb.h usb_boot_defines.h command_line.h cmd.h config.h
SRC_O= $(SRC_C:.c=.o) SRC_O= $(SRC_C:.c=.o)

View File

@ -32,8 +32,10 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <confuse.h> #include <confuse.h>
struct nand_in nand_in;
struct nand_out nand_out;
struct fw_args_t fw_args;
unsigned int total_size; unsigned int total_size;
fw_args_t fw_args;
static int parse_configure(char * file_path) static int parse_configure(char * file_path)
{ {
@ -199,7 +201,7 @@ static int load_file(struct ingenic_dev *ingenic_dev, const char *file_path)
goto close; goto close;
} }
memcpy(ingenic_dev->file_buff + 8, &fw_args, sizeof(fw_args_t)); memcpy(ingenic_dev->file_buff + 8, &fw_args, sizeof(struct fw_args_t));
res = 1; res = 1;
@ -216,7 +218,7 @@ int boot(char *stage1_path, char *stage2_path, char *config_path ){
int status; int status;
memset(&ingenic_dev, 0, sizeof(struct ingenic_dev)); memset(&ingenic_dev, 0, sizeof(struct ingenic_dev));
memset(&fw_args, 0, sizeof(fw_args_t)); memset(&fw_args, 0, sizeof(struct fw_args_t));
if (parse_configure(config_path) < 1) if (parse_configure(config_path) < 1)
goto out; goto out;
@ -281,3 +283,49 @@ out:
usb_ingenic_cleanup(&ingenic_dev); usb_ingenic_cleanup(&ingenic_dev);
return res; return res;
} }
int nprog(int com_argc, char **com_argv)
{
#if 0
unsigned int i;
if (com_argc < 6)
{
printf("\n Usage:"
" nprog (1) (2) (3) (4) (5) "
"\n 1:start page number"
"\n 2:image file name"
"\n 3:device index number"
"\n 4:flash index number"
"\n 5:image type -n:no oob,-o:with oob no ecc,-e:with oob and ecc");
return 0;
}
for (i = 0; i < MAX_DEV_NUM; i++)
(nand_in.cs_map)[i] = 0;
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;
nand_in.start = atoi(com_argv[1]);
nand_in.dev = atoi(com_argv[3]);
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
nand_in.option = NO_OOB;
if (Hand.nand_plane > 1)
/* API_Nand_Program_File_Planes(&nand_in,&nand_out,com_argv[2]); */
else
/* API_Nand_Program_File(&nand_in,&nand_out,com_argv[2]); */
#if 0
printf("\n Flash check result:");
for (i = 0; i < 16; i++)
printf(" %d", (nand_out.status)[i]);
#endif
#endif
printf("\n not implement yet!!");
return 1;
}

View File

@ -23,5 +23,6 @@
#define __CMD_H__ #define __CMD_H__
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);
#endif /* __CMD_H__ */ #endif /* __CMD_H__ */

View File

@ -64,18 +64,6 @@ static const char COMMAND[][30]=
"run" "run"
}; };
void handle_exit(int res)
{
printf("\n exiting inflash software\n");
exit(res);
}
int handle_nprog(void)
{
printf("\n not implement");
return 1;
}
int handle_help(void) int handle_help(void)
{ {
printf("\n Command support in current version:" printf("\n Command support in current version:"
@ -122,11 +110,6 @@ int handle_fconfig(void)
return 1; return 1;
} }
int handle_boot(void)
{
return boot(STAGE1_FILE_PATH, STAGE2_FILE_PATH, CONFIG_FILE_PATH);
}
int command_input(char *buf) int command_input(char *buf)
{ {
char *cptr; char *cptr;
@ -181,20 +164,18 @@ int command_handle(char *buf)
if (!cmd) return -1; if (!cmd) return -1;
switch (cmd) { switch (cmd) {
case 11: case 11:
handle_nprog(); return nprog(com_argc, com_argv);
break;
case 12: case 12:
handle_help(); handle_help();
break; break;
case 13: case 13:
handle_version(); handle_version();
break; break;
case 16: case 16: /* exit */
handle_exit(0); printf("\n exiting inflash software\n");
break; exit(EXIT_SUCCESS);
case 20: case 20:
handle_boot(); return boot(STAGE1_FILE_PATH, STAGE2_FILE_PATH, CONFIG_FILE_PATH);
break;
default: default:
printf("\n Command not support!"); printf("\n Command not support!");
return -1; return -1;

View File

@ -1,3 +1,24 @@
/*
* "Ingenic flash tool" - flash the Ingenic CPU via USB
*
* (C) Copyright 2009
* Author: Marek Lindner <lindner_marek@yahoo.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 3 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA
*/
#ifndef __JZ4740_USBDEFINES__H_ #ifndef __JZ4740_USBDEFINES__H_
#define __JZ4740_USBDEFINES__H_ #define __JZ4740_USBDEFINES__H_
@ -18,29 +39,25 @@
#define IOCTL_OUTBUF_SIZE 512 #define IOCTL_OUTBUF_SIZE 512
#define MAX_DEV_NUM 16 #define MAX_DEV_NUM 16
enum CPUTYPE enum CPUTYPE {
{
JZ4740, JZ4740,
JZ4750, JZ4750,
}; };
enum USB_Boot_State enum USB_Boot_State {
{
DISCONNECT, DISCONNECT,
CONNECT, CONNECT,
BOOT, BOOT,
UNBOOT UNBOOT
}; };
enum OPTION enum OPTION {
{
OOB_ECC, OOB_ECC,
OOB_NO_ECC, OOB_NO_ECC,
NO_OOB, NO_OOB,
}; };
enum NOR_OPS_TYPE enum NOR_OPS_TYPE {
{
NOR_INIT = 0, NOR_INIT = 0,
NOR_QUERY, NOR_QUERY,
NOR_WRITE, NOR_WRITE,
@ -56,8 +73,7 @@ enum NOR_FLASH_TYPE
NOR_SST39x8 NOR_SST39x8
}; };
enum NAND_OPS_TYPE enum NAND_OPS_TYPE {
{
NAND_QUERY = 0, NAND_QUERY = 0,
NAND_INIT, NAND_INIT,
NAND_MARK_BAD, NAND_MARK_BAD,
@ -69,20 +85,19 @@ enum NAND_OPS_TYPE
NAND_READ_TO_RAM NAND_READ_TO_RAM
}; };
enum SDRAM_OPS_TYPE enum SDRAM_OPS_TYPE {
{
SDRAM_LOAD, SDRAM_LOAD,
}; };
enum DATA_STRUCTURE_OB enum DATA_STRUCTURE_OB {
{
DS_flash_info , DS_flash_info ,
DS_hand DS_hand
}; };
typedef struct { struct fw_args_t {
/* CPU ID */ /* CPU ID */
unsigned int cpu_id; unsigned int cpu_id;
/* PLL args */ /* PLL args */
unsigned char ext_clk; unsigned char ext_clk;
unsigned char cpu_speed; unsigned char cpu_speed;
@ -107,9 +122,9 @@ typedef struct {
/* for align */ /* for align */
/* unsigned char align1; */ /* unsigned char align1; */
/* unsigned char align2; */ /* unsigned char align2; */
} __attribute__((packed)) fw_args_t; } __attribute__((packed));
typedef struct { struct hand_t {
/* nand flash info */ /* nand flash info */
int pt; /* cpu type */ int pt; /* cpu type */
@ -128,8 +143,31 @@ typedef struct {
int nand_wppin; int nand_wppin;
int nand_bpc; /* block number per chip */ int nand_bpc; /* block number per chip */
fw_args_t fw_args; struct fw_args_t fw_args;
} __attribute__((packed));
} __attribute__((packed)) hand_t; struct nand_in {
unsigned char dev;
unsigned char max_chip;
unsigned char *buf;
unsigned char *cs_map;
unsigned int start;
unsigned int length;
unsigned int option;
int (* check) (unsigned char *,unsigned char *,unsigned int);
};
struct nand_out {
unsigned char *status;
};
struct sdram_in {
unsigned char dev;
unsigned char *buf;
unsigned int start;
unsigned int length;
unsigned int option;
};
#endif /* __JZ4740_USBDEFINES__H_ */ #endif /* __JZ4740_USBDEFINES__H_ */