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

change the file_buf use the code_buf not malloc

This commit is contained in:
xiangfu 2009-05-26 17:05:54 +00:00
parent 132b7afd9c
commit b47ed72723
3 changed files with 10 additions and 33 deletions

View File

@ -59,11 +59,6 @@ static int load_file(struct ingenic_dev *ingenic_dev, const char *file_path)
struct stat fstat; struct stat fstat;
int fd, status, res = -1; int fd, status, res = -1;
if (ingenic_dev->file_buff)
free(ingenic_dev->file_buff);
ingenic_dev->file_buff = NULL;
status = stat(file_path, &fstat); status = stat(file_path, &fstat);
if (status < 0) { if (status < 0) {
@ -73,14 +68,7 @@ static int load_file(struct ingenic_dev *ingenic_dev, const char *file_path)
} }
ingenic_dev->file_len = fstat.st_size; ingenic_dev->file_len = fstat.st_size;
ingenic_dev->file_buff = malloc(ingenic_dev->file_len); ingenic_dev->file_buff = code_buf;
if (!ingenic_dev->file_buff) {
fprintf(stderr, "Error - "
"can't allocate memory to read file '%s': %s\n",
file_path, strerror(errno));
return -1;
}
fd = open(file_path, O_RDONLY); fd = open(file_path, O_RDONLY);
@ -169,26 +157,18 @@ int boot(char *stage1_path, char *stage2_path){
if (load_file(&ingenic_dev, stage1_path) < 1) if (load_file(&ingenic_dev, stage1_path) < 1)
return -1; return -1;
if (usb_ingenic_upload(&ingenic_dev, 1) < 1) { if (usb_ingenic_upload(&ingenic_dev, 1) < 1)
if (ingenic_dev.file_buff)
free(ingenic_dev.file_buff);
return -1; return -1;
}
/* now we upload the usb boot stage2 */ /* now we upload the usb boot stage2 */
sleep(1); sleep(1);
printf("\n Upload usb boot stage2"); printf("\n Upload usb boot stage2");
if (load_file(&ingenic_dev, stage2_path) < 1) { if (load_file(&ingenic_dev, stage2_path) < 1)
if (ingenic_dev.file_buff)
free(ingenic_dev.file_buff);
return -1; return -1;
}
if (usb_ingenic_upload(&ingenic_dev, 2) < 1) { if (usb_ingenic_upload(&ingenic_dev, 2) < 1)
if (ingenic_dev.file_buff)
free(ingenic_dev.file_buff);
return -1; return -1;
}
printf("\n Boot success!"); printf("\n Boot success!");
} }
sleep(1); sleep(1);

View File

@ -300,7 +300,8 @@ int usb_ingenic_upload(struct ingenic_dev *ingenic_dev, int stage)
usb_send_data_to_ingenic(ingenic_dev); usb_send_data_to_ingenic(ingenic_dev);
if (stage == 2) { if (stage == 2) {
usb_get_ingenic_cpu(ingenic_dev); if (usb_get_ingenic_cpu(ingenic_dev) < 1)
return -1;
usb_ingenic_flush_cache(ingenic_dev); usb_ingenic_flush_cache(ingenic_dev);
} }
@ -320,7 +321,8 @@ int usb_ingenic_upload(struct ingenic_dev *ingenic_dev, int stage)
return status; return status;
} }
usb_get_ingenic_cpu(ingenic_dev); if (usb_get_ingenic_cpu(ingenic_dev) < 1)
return -1;
return 1; return 1;
} }

View File

@ -116,16 +116,11 @@ struct fw_args {
unsigned char pin_num; unsigned char pin_num;
unsigned int start; unsigned int start;
unsigned int size; unsigned int size;
/* for align */
/* unsigned char align1; */
/* unsigned char align2; */
} __attribute__((packed)); } __attribute__((packed));
struct hand { struct hand {
/* nand flash info */ /* nand flash info */
int pt; /* cpu type */ int pt; /* cpu type */
unsigned int nand_bw; /* bus width */ unsigned int nand_bw; /* bus width */
unsigned int nand_rc; /* row cycle */ unsigned int nand_rc; /* row cycle */
unsigned int nand_ps; /* page size */ unsigned int nand_ps; /* page size */