mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2024-11-01 16:25:20 +02:00
add nand_ops function
This commit is contained in:
parent
acc365174f
commit
fac0cd77ea
@ -19,9 +19,6 @@
|
|||||||
* Boston, MA 02110-1301, USA
|
* Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ingenic_usb.h"
|
|
||||||
#include "usb_boot_defines.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -33,6 +30,8 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "ingenic_cfg.h"
|
#include "ingenic_cfg.h"
|
||||||
|
#include "ingenic_usb.h"
|
||||||
|
#include "usb_boot_defines.h"
|
||||||
|
|
||||||
extern int com_argc;
|
extern int com_argc;
|
||||||
extern char com_argv[MAX_ARGC][MAX_COMMAND_LENGTH];
|
extern char com_argv[MAX_ARGC][MAX_COMMAND_LENGTH];
|
||||||
@ -202,9 +201,10 @@ int nand_erase(struct nand_in_t *nand_in)
|
|||||||
printf("\n Erasing No.%d device No.%d flash......",
|
printf("\n Erasing No.%d device No.%d flash......",
|
||||||
nand_in->dev, i);
|
nand_in->dev, i);
|
||||||
|
|
||||||
JZ4740_USB_SET_DATA_ADDRESS(start_blk, hDevice);
|
usb_send_data_address_to_ingenic(&ingenic_dev, start_blk);
|
||||||
JZ4740_USB_SET_DATA_LENGTH(blk_num, hDevice);
|
ingenic_dev->file_len = blk_num;
|
||||||
unsigned short temp = ((i<<4) & 0xff0) + NAND_ERASE;
|
usb_send_data_to_ingenic(&ingenic_dev);
|
||||||
|
unsigned short temp = ((i << 4) & 0xff0) + NAND_ERASE;
|
||||||
JZ4740_USB_NAND_OPS(temp,hDevice);
|
JZ4740_USB_NAND_OPS(temp,hDevice);
|
||||||
ReadFile(hDevice, ret, 8, &nRead, NULL);
|
ReadFile(hDevice, ret, 8, &nRead, NULL);
|
||||||
printf(" Finish!");
|
printf(" Finish!");
|
||||||
@ -239,7 +239,7 @@ int nand_program_file(struct nand_in_t *nand_in,
|
|||||||
#if 0
|
#if 0
|
||||||
/* nand_out->status = (unsigned char *)malloc(nand_in->max_chip * sizeof(unsigned char)); */
|
/* nand_out->status = (unsigned char *)malloc(nand_in->max_chip * sizeof(unsigned char)); */
|
||||||
nand_out->status = status_buf;
|
nand_out->status = status_buf;
|
||||||
for (i=0;i<nand_in->max_chip;i++)
|
for (i=0; i<nand_in->max_chip; i++)
|
||||||
(nand_out->status)[i] = 0; /* set all status to fail */
|
(nand_out->status)[i] = 0; /* set all status to fail */
|
||||||
#endif
|
#endif
|
||||||
fp = fopen(fname,"rb");
|
fp = fopen(fname,"rb");
|
||||||
@ -267,7 +267,7 @@ int nand_program_file(struct nand_in_t *nand_in,
|
|||||||
n_in.cs_map = nand_in->cs_map;
|
n_in.cs_map = nand_in->cs_map;
|
||||||
n_in.dev = nand_in->dev;
|
n_in.dev = nand_in->dev;
|
||||||
n_in.max_chip = nand_in->max_chip;
|
n_in.max_chip = nand_in->max_chip;
|
||||||
if (nand_erase(&n_in)!=1)
|
if (nand_erase(&n_in) != 1)
|
||||||
return -1;
|
return -1;
|
||||||
if (nand_in->option == NO_OOB)
|
if (nand_in->option == NO_OOB)
|
||||||
transfer_size = (hand.nand_ppb * hand.nand_ps);
|
transfer_size = (hand.nand_ppb * hand.nand_ps);
|
||||||
@ -295,7 +295,7 @@ int nand_program_file(struct nand_in_t *nand_in,
|
|||||||
printf("\n No.%d Programming...",k+1);
|
printf("\n No.%d Programming...",k+1);
|
||||||
nand_in->length = code_len; /* code length,not page number! */
|
nand_in->length = code_len; /* code length,not page number! */
|
||||||
nand_in->buf = code_buf;
|
nand_in->buf = code_buf;
|
||||||
start_page = nand_program_check(nand_in,&n_out);
|
start_page = nand_program_check(nand_in, &n_out);
|
||||||
if ( start_page - nand_in->start > hand.nand_ppb )
|
if ( start_page - nand_in->start > hand.nand_ppb )
|
||||||
printf("\n Skip a old bad block !");
|
printf("\n Skip a old bad block !");
|
||||||
nand_in->start = start_page;
|
nand_in->start = start_page;
|
||||||
@ -313,16 +313,16 @@ int nand_program_file(struct nand_in_t *nand_in,
|
|||||||
|
|
||||||
if (j) {
|
if (j) {
|
||||||
j += hand.nand_ps - (j % hand.nand_ps);
|
j += hand.nand_ps - (j % hand.nand_ps);
|
||||||
memset(code_buf,0,j); /* set all to null */
|
memset(code_buf, 0, j); /* set all to null */
|
||||||
fread(code_buf,1,j,fp); /* read code from file to buffer */
|
fread(code_buf, 1, j, fp); /* read code from file to buffer */
|
||||||
nand_in->length = j;
|
nand_in->length = j;
|
||||||
nand_in->buf = code_buf;
|
nand_in->buf = code_buf;
|
||||||
printf("\n No.%d Programming...",k+1);
|
printf("\n No.%d Programming...",k+1);
|
||||||
start_page = nand_program_check(nand_in,&n_out);
|
start_page = nand_program_check(nand_in, &n_out);
|
||||||
if ( start_page - nand_in->start > hand.nand_ppb )
|
if ( start_page - nand_in->start > hand.nand_ppb )
|
||||||
printf(" Skip a old bad block !");
|
printf(" Skip a old bad block !");
|
||||||
#if 0
|
#if 0
|
||||||
for (i=0;i<nand_in->max_chip;i++) {
|
for (i=0; i < nand_in->max_chip; i++) {
|
||||||
(nand_out->status)[i] = (nand_out->status)[i] * (n_out.status)[i];
|
(nand_out->status)[i] = (nand_out->status)[i] * (n_out.status)[i];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -300,3 +300,23 @@ void usb_ingenic_cleanup(struct ingenic_dev *ingenic_dev)
|
|||||||
if (ingenic_dev->usb_handle)
|
if (ingenic_dev->usb_handle)
|
||||||
usb_close(ingenic_dev->usb_handle);
|
usb_close(ingenic_dev->usb_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int usb_ingenic_nand_ops(struct ingenic_dev *ingenic_dev, int ops)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
status = usb_control_msg(ingenic_dev->usb_handle,
|
||||||
|
/* bmRequestType */ USB_ENDPOINT_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
|
||||||
|
/* bRequest */ VR_NAND_OPS,
|
||||||
|
/* wValue */ ops & 0xffff,
|
||||||
|
/* wIndex */ 0,
|
||||||
|
/* Data */ 0,
|
||||||
|
/* wLength */ 0,
|
||||||
|
USB_TIMEOUT);
|
||||||
|
|
||||||
|
if (status != 0) {
|
||||||
|
fprintf(stderr, "Error - can't set Ingenic device nand ops: %i\n", status);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
@ -64,5 +64,9 @@ int usb_ingenic_init(struct ingenic_dev *ingenic_dev);
|
|||||||
int usb_get_ingenic_cpu(struct ingenic_dev *ingenic_dev);
|
int usb_get_ingenic_cpu(struct ingenic_dev *ingenic_dev);
|
||||||
int usb_ingenic_upload(struct ingenic_dev *ingenic_dev, int stage);
|
int usb_ingenic_upload(struct ingenic_dev *ingenic_dev, int stage);
|
||||||
void usb_ingenic_cleanup(struct ingenic_dev *ingenic_dev);
|
void usb_ingenic_cleanup(struct ingenic_dev *ingenic_dev);
|
||||||
|
int usb_send_data_address_to_ingenic(struct ingenic_dev *ingenic_dev,
|
||||||
|
unsigned int stage_addr);
|
||||||
|
int usb_send_data_to_ingenic(struct ingenic_dev *ingenic_dev);
|
||||||
|
|
||||||
#endif /* __INGENIC_USB_H__ */
|
#endif /* __INGENIC_USB_H__ */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user