forked from len0rd/rockbox
* Clean up Jz4740 USB tool a bit
* Make IHFSsplit compile under Windows * Change SDRAM base address + remove hack for Onda VX747 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18395 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3637513e30
commit
aefbd6301a
5 changed files with 61 additions and 31 deletions
|
@ -24,7 +24,7 @@
|
||||||
*/
|
*/
|
||||||
#define TARGET_TREE /* this target is using the target tree system */
|
#define TARGET_TREE /* this target is using the target tree system */
|
||||||
|
|
||||||
#define CONFIG_SDRAM_START 0x80E00000 /* HACK! */
|
#define CONFIG_SDRAM_START 0x80004000
|
||||||
|
|
||||||
#define ONDA_VX747 1
|
#define ONDA_VX747 1
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ STARTUP(target/mips/ingenic_jz47xx/crt0.o)
|
||||||
|
|
||||||
#define DRAMSIZE (MEMORYSIZE * 0x100000)
|
#define DRAMSIZE (MEMORYSIZE * 0x100000)
|
||||||
|
|
||||||
#define DRAMORIG 0x80E00000 /* HACK */
|
#define DRAMORIG 0x80004000
|
||||||
#define IRAMORIG 0x80000000
|
#define IRAMORIG 0x80000000
|
||||||
#define IRAMSIZE 16K
|
#define IRAMSIZE 16K
|
||||||
|
|
||||||
|
|
|
@ -49,11 +49,6 @@
|
||||||
.set noreorder
|
.set noreorder
|
||||||
.set noat
|
.set noat
|
||||||
|
|
||||||
#ifdef BOOTLOADER
|
|
||||||
.word 0 /* HACK */
|
|
||||||
.word 0 /* HACK */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_start:
|
_start:
|
||||||
la ra, _start
|
la ra, _start
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -105,7 +105,11 @@ void mkdir_p(const char *path)
|
||||||
if (strchr(dir, '/'))
|
if (strchr(dir, '/'))
|
||||||
mkdir_p(dir);
|
mkdir_p(dir);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
mkdir(dir);
|
||||||
|
#else
|
||||||
mkdir(dir, 0755);
|
mkdir(dir, 0755);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BUF_SIZE 4096
|
#define BUF_SIZE 4096
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define VERSION "0.3"
|
#define VERSION "0.4"
|
||||||
|
|
||||||
#define MAX_FIRMWARESIZE (64*1024*1024) /* Arbitrary limit (for safety) */
|
#define MAX_FIRMWARESIZE (64*1024*1024) /* Arbitrary limit (for safety) */
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* USB IDs for USB Boot Mode */
|
/* USB IDs for USB Boot Mode */
|
||||||
#define VID 0x601A
|
#define VID 0x601A
|
||||||
#define PID 0x4740
|
#define PID 0x4740
|
||||||
|
|
||||||
#define EP_BULK_TO 0x01
|
#define EP_BULK_TO 0x01
|
||||||
#define TOUT 5000
|
#define TOUT 5000
|
||||||
|
@ -102,12 +102,11 @@ enum NAND_OPS_TYPE
|
||||||
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
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -120,11 +119,11 @@ enum OPTION
|
||||||
|
|
||||||
int filesize(FILE* fd)
|
int filesize(FILE* fd)
|
||||||
{
|
{
|
||||||
int tmp;
|
int ret;
|
||||||
fseek(fd, 0, SEEK_END);
|
fseek(fd, 0, SEEK_END);
|
||||||
tmp = ftell(fd);
|
ret = ftell(fd);
|
||||||
fseek(fd, 0, SEEK_SET);
|
fseek(fd, 0, SEEK_SET);
|
||||||
return tmp;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SEND_COMMAND(cmd, arg) err = usb_control_msg(dh, USB_ENDPOINT_OUT | USB_TYPE_VENDOR, (cmd), (arg)>>16, (arg)&0xFFFF, NULL, 0, TOUT);\
|
#define SEND_COMMAND(cmd, arg) err = usb_control_msg(dh, USB_ENDPOINT_OUT | USB_TYPE_VENDOR, (cmd), (arg)>>16, (arg)&0xFFFF, NULL, 0, TOUT);\
|
||||||
|
@ -299,7 +298,6 @@ int test_device(usb_dev_handle* dh)
|
||||||
TEST(CPM_CLKGR, 4);
|
TEST(CPM_CLKGR, 4);
|
||||||
|
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
//or_reg(dh, SADC_ENA, SADC_ENA_TSEN, 1);
|
|
||||||
TEST(SADC_ENA, 1);
|
TEST(SADC_ENA, 1);
|
||||||
TEST(SADC_CTRL, 1);
|
TEST(SADC_CTRL, 1);
|
||||||
TEST(SADC_TSDAT, 4);
|
TEST(SADC_TSDAT, 4);
|
||||||
|
@ -326,7 +324,6 @@ int probe_device(usb_dev_handle* dh)
|
||||||
{
|
{
|
||||||
int tmp;
|
int tmp;
|
||||||
|
|
||||||
//or_reg(dh, SADC_ENA, SADC_ENA_TSEN, 1);
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
if(read_reg(dh, SADC_STATE, 1) & SADC_STATE_TSRDY)
|
if(read_reg(dh, SADC_STATE, 1) & SADC_STATE_TSRDY)
|
||||||
|
@ -493,9 +490,9 @@ int mimic_of(usb_dev_handle *dh, bool vx767)
|
||||||
_SLEEP(2);
|
_SLEEP(2);
|
||||||
_GET_CPU;
|
_GET_CPU;
|
||||||
_SET_ADDR(0x80E0 << 16);
|
_SET_ADDR(0x80E0 << 16);
|
||||||
_SEND_FILE("onda.bin");
|
_SEND_FILE("10.bin");
|
||||||
_GET_CPU;
|
_GET_CPU;
|
||||||
_VERIFY_DATA("onda.bin", 0x80E0 << 16);
|
_VERIFY_DATA("10.bin", 0x80E0 << 16);
|
||||||
_GET_CPU;
|
_GET_CPU;
|
||||||
_FLUSH;
|
_FLUSH;
|
||||||
_GET_CPU;
|
_GET_CPU;
|
||||||
|
@ -511,6 +508,33 @@ int mimic_of(usb_dev_handle *dh, bool vx767)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int send_rockbox(usb_dev_handle *dh)
|
||||||
|
{
|
||||||
|
int err, fsize;
|
||||||
|
unsigned char *buffer, *buffer2;
|
||||||
|
char cpu[8];
|
||||||
|
|
||||||
|
fprintf(stderr, "[INFO] Start!\n");
|
||||||
|
_GET_CPU;
|
||||||
|
_SET_ADDR(0x8000 << 16);
|
||||||
|
_SEND_FILE("1.bin");
|
||||||
|
_GET_CPU;
|
||||||
|
_VERIFY_DATA("1.bin", 0x8000 << 16);
|
||||||
|
_STAGE1(0x8000 << 16);
|
||||||
|
_SLEEP(3);
|
||||||
|
_GET_CPU;
|
||||||
|
_SET_ADDR(0x080004000);
|
||||||
|
_SEND_FILE("onda.bin");
|
||||||
|
_GET_CPU;
|
||||||
|
_VERIFY_DATA("onda.bin", 0x080004000);
|
||||||
|
_GET_CPU;
|
||||||
|
_FLUSH;
|
||||||
|
_GET_CPU;
|
||||||
|
_STAGE2(0x080004000);
|
||||||
|
fprintf(stderr, "[INFO] Done!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#define SEND_NAND_COMMAND(cs, cmd, option) SEND_COMMAND(VR_NAND_OPS, ((cmd&0xF)|((cs&0xFF)<<4)|((option&0xFF)<<12)) );
|
#define SEND_NAND_COMMAND(cs, cmd, option) SEND_COMMAND(VR_NAND_OPS, ((cmd&0xF)|((cs&0xFF)<<4)|((option&0xFF)<<12)) );
|
||||||
#define LENGTH 1024*1024*5
|
#define LENGTH 1024*1024*5
|
||||||
int nand_dump(usb_dev_handle *dh)
|
int nand_dump(usb_dev_handle *dh)
|
||||||
|
@ -721,6 +745,9 @@ found:
|
||||||
case 9:
|
case 9:
|
||||||
err = rom_dump(dh);
|
err = rom_dump(dh);
|
||||||
break;
|
break;
|
||||||
|
case 10:
|
||||||
|
err = send_rockbox(dh);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* release claimed interface */
|
/* release claimed interface */
|
||||||
|
@ -734,21 +761,24 @@ found:
|
||||||
void print_usage(void)
|
void print_usage(void)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
fprintf(stderr, "Usage: usbtool.exe [CMD] [FILE] [ADDRESS] [LEN]\n");
|
fprintf(stderr, "Usage: usbtool.exe <CMD> [FILE] [ADDRESS] [LEN]\n");
|
||||||
#else
|
#else
|
||||||
fprintf(stderr, "Usage: usbtool [CMD] [FILE] [ADDRESS] [LEN]\n");
|
fprintf(stderr, "Usage: usbtool <CMD> [FILE] [ADDRESS] [LEN]\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fprintf(stderr, "\t[ADDRESS] has to be in 0xHEXADECIMAL format\n");
|
fprintf(stderr, "\t[ADDRESS] has to be in 0xHEXADECIMAL format\n");
|
||||||
fprintf(stderr, "\t[CMD]:\n");
|
fprintf(stderr, "\tCMD:\n");
|
||||||
fprintf(stderr, "\t\t1 -> upload file to specified address and boot from it\n");
|
fprintf(stderr, "\t\t 1 -> upload file to specified address and boot from it\n");
|
||||||
fprintf(stderr, "\t\t2 -> read data from [ADDRESS] with length [LEN] to [FILE]\n");
|
fprintf(stderr, "\t\t 2 -> read data from [ADDRESS] with length [LEN] to [FILE]\n");
|
||||||
fprintf(stderr, "\t\t3 -> read device status\n");
|
fprintf(stderr, "\t\t 3 -> read device status\n");
|
||||||
fprintf(stderr, "\t\t4 -> probe keys (only Onda VX747)\n");
|
fprintf(stderr, "\t\t 4 -> probe keys (only Onda VX747)\n");
|
||||||
fprintf(stderr, "\t\t5 -> same as 1 but do a stage 2 boot\n");
|
fprintf(stderr, "\t\t 5 -> same as 1 but do a stage 2 boot\n");
|
||||||
fprintf(stderr, "\t\t6 -> mimic VX747 OF fw recovery\n");
|
fprintf(stderr, "\t\t 6 -> mimic VX747 OF fw recovery\n");
|
||||||
fprintf(stderr, "\t\t7 -> mimic VX767 OF fw recovery\n");
|
fprintf(stderr, "\t\t 7 -> mimic VX767 OF fw recovery\n");
|
||||||
fprintf(stderr, "\t\t8 -> do a NAND dump\n");
|
fprintf(stderr, "\t\t 8 -> do a NAND dump\n");
|
||||||
fprintf(stderr, "\t\t9 -> do a ROM dump\n");
|
fprintf(stderr, "\t\t 9 -> do a ROM dump\n");
|
||||||
|
fprintf(stderr, "\t\t10 -> send Rockbox bootloader to SDRAM\n");
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
fprintf(stderr, "\nExample:\n\t usbtool.exe 1 fw.bin 0x80000000\n");
|
fprintf(stderr, "\nExample:\n\t usbtool.exe 1 fw.bin 0x80000000\n");
|
||||||
fprintf(stderr, "\t usbtool.exe 2 save.bin 0x81000000 1024\n");
|
fprintf(stderr, "\t usbtool.exe 2 save.bin 0x81000000 1024\n");
|
||||||
|
@ -865,6 +895,7 @@ int main(int argc, char* argv[])
|
||||||
case 7:
|
case 7:
|
||||||
case 8:
|
case 8:
|
||||||
case 9:
|
case 9:
|
||||||
|
case 10:
|
||||||
return jzconnect(address, NULL, 0, cmd);
|
return jzconnect(address, NULL, 0, cmd);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue