summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-09-03 12:42:14 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-09-03 12:42:14 +0000
commitaefbd6301a11367727b7dc265f5aaccbbaac2a3f (patch)
treec624a59673ae5b5143aa95e2775aa64eeebd9181
parent3637513e30c70f47425b2d79753639dff6a794c8 (diff)
downloadrockbox-aefbd6301a11367727b7dc265f5aaccbbaac2a3f.tar.gz
rockbox-aefbd6301a11367727b7dc265f5aaccbbaac2a3f.zip
* 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
-rw-r--r--firmware/export/config-ondavx747.h2
-rw-r--r--firmware/target/mips/ingenic_jz47xx/boot.lds2
-rw-r--r--firmware/target/mips/ingenic_jz47xx/crt0.S5
-rw-r--r--utils/jz4740_tools/IHFSsplit.c4
-rw-r--r--utils/jz4740_tools/jz4740_usbtool.c79
5 files changed, 61 insertions, 31 deletions
diff --git a/firmware/export/config-ondavx747.h b/firmware/export/config-ondavx747.h
index ffb5e90a75..9f5c800d3c 100644
--- a/firmware/export/config-ondavx747.h
+++ b/firmware/export/config-ondavx747.h
@@ -24,7 +24,7 @@
24 */ 24 */
25#define TARGET_TREE /* this target is using the target tree system */ 25#define TARGET_TREE /* this target is using the target tree system */
26 26
27#define CONFIG_SDRAM_START 0x80E00000 /* HACK! */ 27#define CONFIG_SDRAM_START 0x80004000
28 28
29#define ONDA_VX747 1 29#define ONDA_VX747 1
30 30
diff --git a/firmware/target/mips/ingenic_jz47xx/boot.lds b/firmware/target/mips/ingenic_jz47xx/boot.lds
index 0ea8877714..b6f3e169fb 100644
--- a/firmware/target/mips/ingenic_jz47xx/boot.lds
+++ b/firmware/target/mips/ingenic_jz47xx/boot.lds
@@ -8,7 +8,7 @@ STARTUP(target/mips/ingenic_jz47xx/crt0.o)
8 8
9#define DRAMSIZE (MEMORYSIZE * 0x100000) 9#define DRAMSIZE (MEMORYSIZE * 0x100000)
10 10
11#define DRAMORIG 0x80E00000 /* HACK */ 11#define DRAMORIG 0x80004000
12#define IRAMORIG 0x80000000 12#define IRAMORIG 0x80000000
13#define IRAMSIZE 16K 13#define IRAMSIZE 16K
14 14
diff --git a/firmware/target/mips/ingenic_jz47xx/crt0.S b/firmware/target/mips/ingenic_jz47xx/crt0.S
index f079b940a1..baef085845 100644
--- a/firmware/target/mips/ingenic_jz47xx/crt0.S
+++ b/firmware/target/mips/ingenic_jz47xx/crt0.S
@@ -49,11 +49,6 @@
49 .set noreorder 49 .set noreorder
50 .set noat 50 .set noat
51 51
52#ifdef BOOTLOADER
53 .word 0 /* HACK */
54 .word 0 /* HACK */
55#endif
56
57_start: 52_start:
58 la ra, _start 53 la ra, _start
59 /* 54 /*
diff --git a/utils/jz4740_tools/IHFSsplit.c b/utils/jz4740_tools/IHFSsplit.c
index 84ba9a790d..ad62d81daf 100644
--- a/utils/jz4740_tools/IHFSsplit.c
+++ b/utils/jz4740_tools/IHFSsplit.c
@@ -105,7 +105,11 @@ void mkdir_p(const char *path)
105 if (strchr(dir, '/')) 105 if (strchr(dir, '/'))
106 mkdir_p(dir); 106 mkdir_p(dir);
107 107
108#ifdef _WIN32
109 mkdir(dir);
110#else
108 mkdir(dir, 0755); 111 mkdir(dir, 0755);
112#endif
109} 113}
110 114
111#define BUF_SIZE 4096 115#define BUF_SIZE 4096
diff --git a/utils/jz4740_tools/jz4740_usbtool.c b/utils/jz4740_tools/jz4740_usbtool.c
index b1aa198d23..da60c803c1 100644
--- a/utils/jz4740_tools/jz4740_usbtool.c
+++ b/utils/jz4740_tools/jz4740_usbtool.c
@@ -39,7 +39,7 @@
39#include <stdbool.h> 39#include <stdbool.h>
40#include <unistd.h> 40#include <unistd.h>
41 41
42#define VERSION "0.3" 42#define VERSION "0.4"
43 43
44#define MAX_FIRMWARESIZE (64*1024*1024) /* Arbitrary limit (for safety) */ 44#define MAX_FIRMWARESIZE (64*1024*1024) /* Arbitrary limit (for safety) */
45 45
@@ -49,8 +49,8 @@
49#endif 49#endif
50 50
51/* USB IDs for USB Boot Mode */ 51/* USB IDs for USB Boot Mode */
52#define VID 0x601A 52#define VID 0x601A
53#define PID 0x4740 53#define PID 0x4740
54 54
55#define EP_BULK_TO 0x01 55#define EP_BULK_TO 0x01
56#define TOUT 5000 56#define TOUT 5000
@@ -102,12 +102,11 @@ enum NAND_OPS_TYPE
102enum SDRAM_OPS_TYPE 102enum SDRAM_OPS_TYPE
103{ 103{
104 SDRAM_LOAD, 104 SDRAM_LOAD,
105
106}; 105};
107 106
108enum DATA_STRUCTURE_OB 107enum DATA_STRUCTURE_OB
109{ 108{
110 DS_flash_info , 109 DS_flash_info,
111 DS_hand 110 DS_hand
112}; 111};
113 112
@@ -120,11 +119,11 @@ enum OPTION
120 119
121int filesize(FILE* fd) 120int filesize(FILE* fd)
122{ 121{
123 int tmp; 122 int ret;
124 fseek(fd, 0, SEEK_END); 123 fseek(fd, 0, SEEK_END);
125 tmp = ftell(fd); 124 ret = ftell(fd);
126 fseek(fd, 0, SEEK_SET); 125 fseek(fd, 0, SEEK_SET);
127 return tmp; 126 return ret;
128} 127}
129 128
130#define SEND_COMMAND(cmd, arg) err = usb_control_msg(dh, USB_ENDPOINT_OUT | USB_TYPE_VENDOR, (cmd), (arg)>>16, (arg)&0xFFFF, NULL, 0, TOUT);\ 129#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)
299 TEST(CPM_CLKGR, 4); 298 TEST(CPM_CLKGR, 4);
300 299
301 fprintf(stderr, "\n"); 300 fprintf(stderr, "\n");
302 //or_reg(dh, SADC_ENA, SADC_ENA_TSEN, 1);
303 TEST(SADC_ENA, 1); 301 TEST(SADC_ENA, 1);
304 TEST(SADC_CTRL, 1); 302 TEST(SADC_CTRL, 1);
305 TEST(SADC_TSDAT, 4); 303 TEST(SADC_TSDAT, 4);
@@ -326,7 +324,6 @@ int probe_device(usb_dev_handle* dh)
326{ 324{
327 int tmp; 325 int tmp;
328 326
329 //or_reg(dh, SADC_ENA, SADC_ENA_TSEN, 1);
330 while(1) 327 while(1)
331 { 328 {
332 if(read_reg(dh, SADC_STATE, 1) & SADC_STATE_TSRDY) 329 if(read_reg(dh, SADC_STATE, 1) & SADC_STATE_TSRDY)
@@ -493,9 +490,9 @@ int mimic_of(usb_dev_handle *dh, bool vx767)
493 _SLEEP(2); 490 _SLEEP(2);
494 _GET_CPU; 491 _GET_CPU;
495 _SET_ADDR(0x80E0 << 16); 492 _SET_ADDR(0x80E0 << 16);
496 _SEND_FILE("onda.bin"); 493 _SEND_FILE("10.bin");
497 _GET_CPU; 494 _GET_CPU;
498 _VERIFY_DATA("onda.bin", 0x80E0 << 16); 495 _VERIFY_DATA("10.bin", 0x80E0 << 16);
499 _GET_CPU; 496 _GET_CPU;
500 _FLUSH; 497 _FLUSH;
501 _GET_CPU; 498 _GET_CPU;
@@ -511,6 +508,33 @@ int mimic_of(usb_dev_handle *dh, bool vx767)
511 return 0; 508 return 0;
512} 509}
513 510
511int send_rockbox(usb_dev_handle *dh)
512{
513 int err, fsize;
514 unsigned char *buffer, *buffer2;
515 char cpu[8];
516
517 fprintf(stderr, "[INFO] Start!\n");
518 _GET_CPU;
519 _SET_ADDR(0x8000 << 16);
520 _SEND_FILE("1.bin");
521 _GET_CPU;
522 _VERIFY_DATA("1.bin", 0x8000 << 16);
523 _STAGE1(0x8000 << 16);
524 _SLEEP(3);
525 _GET_CPU;
526 _SET_ADDR(0x080004000);
527 _SEND_FILE("onda.bin");
528 _GET_CPU;
529 _VERIFY_DATA("onda.bin", 0x080004000);
530 _GET_CPU;
531 _FLUSH;
532 _GET_CPU;
533 _STAGE2(0x080004000);
534 fprintf(stderr, "[INFO] Done!\n");
535 return 0;
536}
537
514#define SEND_NAND_COMMAND(cs, cmd, option) SEND_COMMAND(VR_NAND_OPS, ((cmd&0xF)|((cs&0xFF)<<4)|((option&0xFF)<<12)) ); 538#define SEND_NAND_COMMAND(cs, cmd, option) SEND_COMMAND(VR_NAND_OPS, ((cmd&0xF)|((cs&0xFF)<<4)|((option&0xFF)<<12)) );
515#define LENGTH 1024*1024*5 539#define LENGTH 1024*1024*5
516int nand_dump(usb_dev_handle *dh) 540int nand_dump(usb_dev_handle *dh)
@@ -721,6 +745,9 @@ found:
721 case 9: 745 case 9:
722 err = rom_dump(dh); 746 err = rom_dump(dh);
723 break; 747 break;
748 case 10:
749 err = send_rockbox(dh);
750 break;
724 } 751 }
725 752
726 /* release claimed interface */ 753 /* release claimed interface */
@@ -734,21 +761,24 @@ found:
734void print_usage(void) 761void print_usage(void)
735{ 762{
736#ifdef _WIN32 763#ifdef _WIN32
737 fprintf(stderr, "Usage: usbtool.exe [CMD] [FILE] [ADDRESS] [LEN]\n"); 764 fprintf(stderr, "Usage: usbtool.exe <CMD> [FILE] [ADDRESS] [LEN]\n");
738#else 765#else
739 fprintf(stderr, "Usage: usbtool [CMD] [FILE] [ADDRESS] [LEN]\n"); 766 fprintf(stderr, "Usage: usbtool <CMD> [FILE] [ADDRESS] [LEN]\n");
740#endif 767#endif
768
741 fprintf(stderr, "\t[ADDRESS] has to be in 0xHEXADECIMAL format\n"); 769 fprintf(stderr, "\t[ADDRESS] has to be in 0xHEXADECIMAL format\n");
742 fprintf(stderr, "\t[CMD]:\n"); 770 fprintf(stderr, "\tCMD:\n");
743 fprintf(stderr, "\t\t1 -> upload file to specified address and boot from it\n"); 771 fprintf(stderr, "\t\t 1 -> upload file to specified address and boot from it\n");
744 fprintf(stderr, "\t\t2 -> read data from [ADDRESS] with length [LEN] to [FILE]\n"); 772 fprintf(stderr, "\t\t 2 -> read data from [ADDRESS] with length [LEN] to [FILE]\n");
745 fprintf(stderr, "\t\t3 -> read device status\n"); 773 fprintf(stderr, "\t\t 3 -> read device status\n");
746 fprintf(stderr, "\t\t4 -> probe keys (only Onda VX747)\n"); 774 fprintf(stderr, "\t\t 4 -> probe keys (only Onda VX747)\n");
747 fprintf(stderr, "\t\t5 -> same as 1 but do a stage 2 boot\n"); 775 fprintf(stderr, "\t\t 5 -> same as 1 but do a stage 2 boot\n");
748 fprintf(stderr, "\t\t6 -> mimic VX747 OF fw recovery\n"); 776 fprintf(stderr, "\t\t 6 -> mimic VX747 OF fw recovery\n");
749 fprintf(stderr, "\t\t7 -> mimic VX767 OF fw recovery\n"); 777 fprintf(stderr, "\t\t 7 -> mimic VX767 OF fw recovery\n");
750 fprintf(stderr, "\t\t8 -> do a NAND dump\n"); 778 fprintf(stderr, "\t\t 8 -> do a NAND dump\n");
751 fprintf(stderr, "\t\t9 -> do a ROM dump\n"); 779 fprintf(stderr, "\t\t 9 -> do a ROM dump\n");
780 fprintf(stderr, "\t\t10 -> send Rockbox bootloader to SDRAM\n");
781
752#ifdef _WIN32 782#ifdef _WIN32
753 fprintf(stderr, "\nExample:\n\t usbtool.exe 1 fw.bin 0x80000000\n"); 783 fprintf(stderr, "\nExample:\n\t usbtool.exe 1 fw.bin 0x80000000\n");
754 fprintf(stderr, "\t usbtool.exe 2 save.bin 0x81000000 1024\n"); 784 fprintf(stderr, "\t usbtool.exe 2 save.bin 0x81000000 1024\n");
@@ -865,6 +895,7 @@ int main(int argc, char* argv[])
865 case 7: 895 case 7:
866 case 8: 896 case 8:
867 case 9: 897 case 9:
898 case 10:
868 return jzconnect(address, NULL, 0, cmd); 899 return jzconnect(address, NULL, 0, cmd);
869 break; 900 break;
870 default: 901 default: