mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2024-11-22 23:45:20 +02:00
Implemented nload
This commit is contained in:
parent
8dbb1401fd
commit
f3d7b160a7
49
ingenic.c
49
ingenic.c
@ -391,7 +391,12 @@ int ingenic_load_sdram(void *hndl, void *data, uint32_t base, uint32_t size) {
|
|||||||
HANDLE;
|
HANDLE;
|
||||||
|
|
||||||
while(size) {
|
while(size) {
|
||||||
int block = size > 65535 ? 65535 : size;
|
int block = size > STAGE2_IOBUF ? STAGE2_IOBUF : size;
|
||||||
|
|
||||||
|
printf("Loading %d bytes from %p to 0x%08X\n", block, data, base);
|
||||||
|
|
||||||
|
if(usbdev_sendbulk(handle->usb, data, block) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if(ingenic_wordop(handle->usb, VR_SET_DATA_ADDRESS, base) == -1)
|
if(ingenic_wordop(handle->usb, VR_SET_DATA_ADDRESS, base) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
@ -400,25 +405,20 @@ int ingenic_load_sdram(void *hndl, void *data, uint32_t base, uint32_t size) {
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
if(usbdev_sendbulk(handle->usb, data, block) == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(usbdev_vendor(handle->usb, USBDEV_TODEV, VR_SDRAM_OPS, SDRAM_LOAD, 0, 0, 0) == -1)
|
if(usbdev_vendor(handle->usb, USBDEV_TODEV, VR_SDRAM_OPS, SDRAM_LOAD, 0, 0, 0) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
uint32_t result[8];
|
uint32_t result[8];
|
||||||
|
|
||||||
if(usbdev_recvbulk(handle->usb, result, sizeof(result)) == -1)
|
int ret = usbdev_recvbulk(handle->usb, result, sizeof(result));
|
||||||
|
if(ret == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
data += 65535;
|
hexdump(result, ret);
|
||||||
base += 65535;
|
|
||||||
if(size <= 65535)
|
|
||||||
break;
|
|
||||||
|
|
||||||
size -= 65535;
|
data += block;
|
||||||
|
base += block;
|
||||||
|
size -= block;
|
||||||
}
|
}
|
||||||
debug(LEVEL_DEBUG, "Load done\n");
|
debug(LEVEL_DEBUG, "Load done\n");
|
||||||
|
|
||||||
@ -452,6 +452,8 @@ int ingenic_load_sdram_file(void *hndl, uint32_t base, const char *file) {
|
|||||||
int ingenic_go(void *hndl, uint32_t address) {
|
int ingenic_go(void *hndl, uint32_t address) {
|
||||||
HANDLE;
|
HANDLE;
|
||||||
|
|
||||||
|
debug(LEVEL_DEBUG, "Go to 0x%08X\n", address);
|
||||||
|
|
||||||
return ingenic_wordop(handle->usb, VR_PROGRAM_START2, address);
|
return ingenic_wordop(handle->usb, VR_PROGRAM_START2, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -663,3 +665,26 @@ int ingenic_program_nand(void *hndl, int cs, int start, int type, const char *fi
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ingenic_load_nand(void *hndl, int cs, int start, int pages, uint32_t base) {
|
||||||
|
HANDLE;
|
||||||
|
|
||||||
|
if(ingenic_wordop(handle->usb, VR_PROGRAM_START1, base) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if(ingenic_wordop(handle->usb, VR_SET_DATA_ADDRESS, start) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if(ingenic_wordop(handle->usb, VR_SET_DATA_LENGTH, pages) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if(ingenic_nandop(handle->usb, cs, NAND_READ_TO_RAM, 0) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
uint16_t result[4];
|
||||||
|
|
||||||
|
if(usbdev_recvbulk(handle->usb, result, sizeof(result)) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -138,5 +138,6 @@ int ingenic_query_nand(void *hndl, int cs, nand_info_t *info);
|
|||||||
int ingenic_dump_nand(void *hndl, int cs, int start, int pages, int type, const char *filename);
|
int ingenic_dump_nand(void *hndl, int cs, int start, int pages, int type, const char *filename);
|
||||||
int ingenic_program_nand(void *hndl, int cs, int start, int type, const char *filename);
|
int ingenic_program_nand(void *hndl, int cs, int start, int type, const char *filename);
|
||||||
int ingenic_erase_nand(void *hndl, int cs, int start, int blocks);
|
int ingenic_erase_nand(void *hndl, int cs, int start, int blocks);
|
||||||
|
int ingenic_load_nand(void *hndl, int cs, int start, int pages, uint32_t base);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,6 +32,7 @@ static int usbboot_nquery(int argc, char *argv[]);
|
|||||||
static int usbboot_ndump(int argc, char *argv[]);
|
static int usbboot_ndump(int argc, char *argv[]);
|
||||||
static int usbboot_nerase(int argc, char *argv[]);
|
static int usbboot_nerase(int argc, char *argv[]);
|
||||||
static int usbboot_nprogram(int argc, char *argv[]);
|
static int usbboot_nprogram(int argc, char *argv[]);
|
||||||
|
static int usbboot_nload(int argc, char *argv[]);
|
||||||
|
|
||||||
const shell_command_t usbboot_cmdset[] = {
|
const shell_command_t usbboot_cmdset[] = {
|
||||||
|
|
||||||
@ -45,6 +46,7 @@ const shell_command_t usbboot_cmdset[] = {
|
|||||||
{ "nerase", "<DEVICE> <STARTBLOCK> <BLOCKS> - Erase NAND blocks", usbboot_nerase },
|
{ "nerase", "<DEVICE> <STARTBLOCK> <BLOCKS> - Erase NAND blocks", usbboot_nerase },
|
||||||
{ "nprogram", "<DEVICE> <STARTPAGE> <FILE> - Program NAND from file", usbboot_nprogram },
|
{ "nprogram", "<DEVICE> <STARTPAGE> <FILE> - Program NAND from file", usbboot_nprogram },
|
||||||
{ "nprogram_oob", "<DEVICE> <STARTPAGE> <FILE> - Program NAND with OOB from file", usbboot_nprogram },
|
{ "nprogram_oob", "<DEVICE> <STARTPAGE> <FILE> - Program NAND with OOB from file", usbboot_nprogram },
|
||||||
|
{ "nload", "<DEVICE> <STARTPAGE> <PAGES> <BASE> - Load NAND data to SDRAM", usbboot_nload },
|
||||||
|
|
||||||
{ NULL, NULL, NULL }
|
{ NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
@ -177,3 +179,18 @@ static int usbboot_nprogram(int argc, char *argv[]) {
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int usbboot_nload(int argc, char *argv[]) {
|
||||||
|
if(argc != 5) {
|
||||||
|
printf("Usage: %s <DEVICE> <STARTPAGE> <PAGES> <BASE>\n", argv[0]);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ret = ingenic_load_nand(shell_device(), atoi(argv[1]), atoi(argv[2]), atoi(argv[3]), strtoul(argv[4], NULL, 0));
|
||||||
|
|
||||||
|
if(ret == -1)
|
||||||
|
perror("ingenic_load_nand");
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user