mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2024-11-01 16:25:20 +02:00
add usb_send_data_address_to_ingenic,
usb_send_data_to_ingenic function.
This commit is contained in:
parent
b22c1f680e
commit
acc365174f
@ -163,7 +163,6 @@ cleanup:
|
||||
if (ingenic_dev.file_buff)
|
||||
free(ingenic_dev.file_buff);
|
||||
out:
|
||||
usb_ingenic_cleanup(&ingenic_dev);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -177,7 +176,6 @@ int nand_program_check(struct nand_in_t *nand_in,
|
||||
|
||||
int nand_erase(struct nand_in_t *nand_in)
|
||||
{
|
||||
#if 0
|
||||
unsigned int start_blk, blk_num, end_block;
|
||||
int i;
|
||||
|
||||
@ -197,6 +195,7 @@ int nand_erase(struct nand_in_t *nand_in)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
for (i = 0; i < nand_in->max_chip; i++) {
|
||||
if ((nand_in->cs_map)[i]==0)
|
||||
continue;
|
||||
@ -211,14 +210,14 @@ int nand_erase(struct nand_in_t *nand_in)
|
||||
printf(" Finish!");
|
||||
}
|
||||
Handle_Close();
|
||||
end_block = ((ret[3]<<24)|(ret[2]<<16)|(ret[1]<<8)|(ret[0]<<0)) / Hand.nand_ppb;
|
||||
end_block = ((ret[3] << 24) |
|
||||
(ret[2] << 16) |
|
||||
(ret[1] << 8) |
|
||||
(ret[0] << 0)) / Hand.nand_ppb;
|
||||
printf("\n Operation end position : %d ",end_block);
|
||||
if ( !Hand.nand_force_erase ) //not force erase ,show bad block infomation
|
||||
{
|
||||
if (!hand.nand_force_erase) { /* not force erase, show bad block infomation */
|
||||
printf("\n There are marked bad blocks :%d ",end_block - start_blk - blk_num );
|
||||
}
|
||||
else //force erase ,no bad block infomation can show
|
||||
{
|
||||
} else { /* force erase, no bad block infomation can show */
|
||||
printf("\n Force erase ,no bad block infomation !" );
|
||||
}
|
||||
#endif
|
||||
|
@ -141,6 +141,9 @@ int usb_get_ingenic_cpu(struct ingenic_dev *ingenic_dev)
|
||||
{
|
||||
int status;
|
||||
|
||||
memset(&ingenic_dev->cpu_info_buff, 0,
|
||||
ARRAY_SIZE(ingenic_dev->cpu_info_buff));
|
||||
|
||||
status = usb_control_msg(ingenic_dev->usb_handle,
|
||||
/* bmRequestType */ USB_ENDPOINT_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
|
||||
/* bRequest */ VR_GET_CPU_INFO,
|
||||
@ -192,31 +195,9 @@ int usb_ingenic_flush_cache(struct ingenic_dev *ingenic_dev)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int usb_ingenic_upload(struct ingenic_dev *ingenic_dev, int stage)
|
||||
int usb_send_data_length_to_ingenic(struct ingenic_dev *ingenic_dev)
|
||||
{
|
||||
int status;
|
||||
|
||||
unsigned int stage2_addr;
|
||||
stage2_addr = total_size + 0x80000000;
|
||||
stage2_addr -= CODE_SIZE;
|
||||
int stage_addr = (stage == 1 ? 0x80002000 : stage2_addr);
|
||||
|
||||
/* tell the device the RAM address to store the file */
|
||||
status = usb_control_msg(ingenic_dev->usb_handle,
|
||||
/* bmRequestType */ USB_ENDPOINT_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
|
||||
/* bRequest */ VR_SET_DATA_ADDRESS,
|
||||
/* wValue */ STAGE_ADDR_MSB(stage_addr),
|
||||
/* wIndex */ STAGE_ADDR_LSB(stage_addr),
|
||||
/* Data */ 0,
|
||||
/* wLength */ 0,
|
||||
USB_TIMEOUT);
|
||||
|
||||
if (status != 0) {
|
||||
fprintf(stderr, "Error - can't set the address on Ingenic device: %i\n", status);
|
||||
goto out;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* tell the device the length of the file to be uploaded */
|
||||
status = usb_control_msg(ingenic_dev->usb_handle,
|
||||
/* bmRequestType */ USB_ENDPOINT_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
|
||||
@ -229,20 +210,58 @@ int usb_ingenic_upload(struct ingenic_dev *ingenic_dev, int stage)
|
||||
|
||||
if (status != 0)
|
||||
fprintf(stderr, "Error - can't set data length on Ingenic device: %i\n", status);
|
||||
#endif
|
||||
|
||||
printf("\n Download stage %d program and execute at 0x%08x ", stage, (stage_addr));
|
||||
/* upload the file */
|
||||
return status;
|
||||
}
|
||||
|
||||
int usb_send_data_address_to_ingenic(struct ingenic_dev *ingenic_dev, unsigned int stage_addr)
|
||||
{
|
||||
int status;
|
||||
/* tell the device the RAM address to store the file */
|
||||
status = usb_control_msg(ingenic_dev->usb_handle,
|
||||
/* bmRequestType */ USB_ENDPOINT_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
|
||||
/* bRequest */ VR_SET_DATA_ADDRESS,
|
||||
/* wValue */ STAGE_ADDR_MSB(stage_addr),
|
||||
/* wIndex */ STAGE_ADDR_LSB(stage_addr),
|
||||
/* Data */ 0,
|
||||
/* wLength */ 0,
|
||||
USB_TIMEOUT);
|
||||
|
||||
if (status != 0) {
|
||||
fprintf(stderr, "Error - can't set the address on Ingenic device: %i\n", status);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int usb_send_data_to_ingenic(struct ingenic_dev *ingenic_dev)
|
||||
{
|
||||
int status;
|
||||
status = usb_bulk_write(ingenic_dev->usb_handle,
|
||||
/* endpoint */ INGENIC_OUT_ENDPOINT,
|
||||
/* bulk data */ ingenic_dev->file_buff,
|
||||
/* bulk data length */ ingenic_dev->file_len,
|
||||
USB_TIMEOUT);
|
||||
|
||||
if (status < ingenic_dev->file_len) {
|
||||
fprintf(stderr, "Error - can't send bulk data to Ingenic CPU: %i\nfile length: %d\n", status, ingenic_dev->file_len);
|
||||
fprintf(stderr, "Error - can't send bulk data to Ingenic CPU: %i\n", status);
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int usb_ingenic_upload(struct ingenic_dev *ingenic_dev, int stage)
|
||||
{
|
||||
int status;
|
||||
|
||||
unsigned int stage2_addr;
|
||||
stage2_addr = total_size + 0x80000000;
|
||||
stage2_addr -= CODE_SIZE;
|
||||
int stage_addr = (stage == 1 ? 0x80002000 : stage2_addr);
|
||||
|
||||
usb_send_data_address_to_ingenic(ingenic_dev, stage_addr);
|
||||
printf("\n Download stage %d program and execute at 0x%08x ", stage, (stage_addr));
|
||||
usb_send_data_to_ingenic(ingenic_dev);
|
||||
|
||||
if (stage == 2) {
|
||||
sleep(1);
|
||||
|
@ -102,6 +102,7 @@ int main(int argc, char **argv)
|
||||
command_handle(com_buf);
|
||||
}
|
||||
|
||||
usb_ingenic_cleanup(&ingenic_dev);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user