summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2009-07-17 14:30:42 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2009-07-17 14:30:42 +0000
commitcf9935d6362dd52e4b2f33dd19fff0a0860814d7 (patch)
tree1530a9450d78768077798bd756fbfa67ea1efb12
parent1dc0c46d930d8e59902e9b3ce92aab21a5311d78 (diff)
downloadrockbox-cf9935d6362dd52e4b2f33dd19fff0a0860814d7.tar.gz
rockbox-cf9935d6362dd52e4b2f33dd19fff0a0860814d7.zip
Onda VX747: add dual-boot capability + make it possible to permanently 'stick' Rockbox to your DAP
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21919 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--bootloader/SOURCES1
-rw-r--r--bootloader/common.c3
-rwxr-xr-xbootloader/ondavx747.c73
-rw-r--r--firmware/export/config-ondavx747.h5
-rw-r--r--firmware/target/mips/ingenic_jz47xx/boot.lds2
-rw-r--r--firmware/target/mips/ingenic_jz47xx/crt0.S6
-rwxr-xr-xtools/configure16
-rw-r--r--tools/scramble.c64
8 files changed, 146 insertions, 24 deletions
diff --git a/bootloader/SOURCES b/bootloader/SOURCES
index d36479c4ee..42f3f577cf 100644
--- a/bootloader/SOURCES
+++ b/bootloader/SOURCES
@@ -44,6 +44,7 @@ meizu_m6sp.c
44meizu_m3.c 44meizu_m3.c
45#elif defined(ONDA_VX747) || defined(ONDA_VX747P) || defined(ONDA_VX767) || defined(ONDA_VX777) 45#elif defined(ONDA_VX747) || defined(ONDA_VX747P) || defined(ONDA_VX767) || defined(ONDA_VX777)
46ondavx747.c 46ondavx747.c
47show_logo.c
47#elif defined(CREATIVE_ZVx) 48#elif defined(CREATIVE_ZVx)
48creativezvm.c 49creativezvm.c
49#elif CONFIG_CPU==AS3525 50#elif CONFIG_CPU==AS3525
diff --git a/bootloader/common.c b/bootloader/common.c
index 4ac421d872..f7ab661ca2 100644
--- a/bootloader/common.c
+++ b/bootloader/common.c
@@ -40,7 +40,8 @@
40#if defined(IPOD_ARCH) || defined(IRIVER_H10) || defined(IRIVER_H10_5GB) \ 40#if defined(IPOD_ARCH) || defined(IRIVER_H10) || defined(IRIVER_H10_5GB) \
41 || defined(SANSA_E200) || defined(SANSA_C200) || defined(GIGABEAT_F) \ 41 || defined(SANSA_E200) || defined(SANSA_C200) || defined(GIGABEAT_F) \
42 || defined(PHILIPS_SA9200) || (CONFIG_CPU == AS3525) || defined(COWON_D2) \ 42 || defined(PHILIPS_SA9200) || (CONFIG_CPU == AS3525) || defined(COWON_D2) \
43 || defined(MROBE_100) || defined(PHILIPS_HDD1630) || defined(MROBE_500) 43 || defined(MROBE_100) || defined(PHILIPS_HDD1630) || defined(MROBE_500) \
44 || defined(ONDA_VX747)
44bool verbose = false; 45bool verbose = false;
45#else 46#else
46bool verbose = true; 47bool verbose = true;
diff --git a/bootloader/ondavx747.c b/bootloader/ondavx747.c
index 6a04c1ba85..3767005ebe 100755
--- a/bootloader/ondavx747.c
+++ b/bootloader/ondavx747.c
@@ -34,6 +34,8 @@
34#include "string.h" 34#include "string.h"
35#include "adc.h" 35#include "adc.h"
36 36
37extern int show_logo(void);
38
37static void show_splash(int timeout, const char *msg) 39static void show_splash(int timeout, const char *msg)
38{ 40{
39 reset_screen(); 41 reset_screen();
@@ -84,9 +86,52 @@ static void usb_mode(void)
84 reset_screen(); 86 reset_screen();
85} 87}
86 88
87static void boot_of(void) 89static int boot_of(void)
88{ 90{
89 /* Do nothing atm */ 91 int fd, rc, len, i, checksum = 0;
92 void (*kernel_entry)(int, void*, void*);
93
94 /* TODO: get this from the NAND flash instead of SD */
95 fd = open("/ccpmp.bin", O_RDONLY);
96 if(fd < 0)
97 return EFILE_NOT_FOUND;
98
99 lseek(fd, 4, SEEK_SET);
100 rc = read(fd, (char*)&len, 4); /* CPU is LE */
101 if(rc < 4)
102 return EREAD_IMAGE_FAILED;
103
104 len += 8;
105 printf("Reading %d bytes...", len);
106
107 lseek(fd, 0, SEEK_SET);
108 rc = read(fd, (void*)0x80004000, len);
109 if(rc < len)
110 return EREAD_IMAGE_FAILED;
111
112 close(fd);
113
114 for(i=0; i<len; i++)
115 checksum += ((unsigned char*)0x80004000)[i];
116
117 *((unsigned int*)0x80004000) = checksum;
118
119 printf("Starting the OF...");
120
121 /* OF requires all clocks on */
122 __cpm_start_all();
123
124 disable_interrupt();
125 __dcache_writeback_all();
126 __icache_invalidate_all();
127
128 for(i=8000; i>0; i--)
129 asm volatile("nop\n");
130
131 kernel_entry = (void*) 0x80004008;
132 kernel_entry(0, "Jan 10 2008", "15:34:42"); /* Reversed from the SPL */
133
134 return 0;
90} 135}
91 136
92int main(void) 137int main(void)
@@ -102,12 +147,9 @@ int main(void)
102 font_init(); 147 font_init();
103 lcd_setfont(FONT_SYSFIXED); 148 lcd_setfont(FONT_SYSFIXED);
104 button_init(); 149 button_init();
105 adc_init();
106 backlight_init(); 150 backlight_init();
107 151
108 reset_screen(); 152 show_logo();
109 printf(MODEL_NAME" Rockbox Bootloader");
110 printf("Version "APPSVERSION);
111 153
112 rc = storage_init(); 154 rc = storage_init();
113 if(rc) 155 if(rc)
@@ -119,15 +161,28 @@ int main(void)
119 rc = button_read_device(); 161 rc = button_read_device();
120#endif 162#endif
121 163
164 if(rc)
165 verbose = true;
166
122 if(rc & BUTTON_VOL_UP) 167 if(rc & BUTTON_VOL_UP)
123 usb_mode(); 168 usb_mode();
124 else if(button_hold()) 169
125 boot_of(); 170 if(verbose)
171 reset_screen();
172 printf(MODEL_NAME" Rockbox Bootloader");
173 printf("Version "APPSVERSION);
126 174
127 rc = disk_mount_all(); 175 rc = disk_mount_all();
128 if (rc <= 0) 176 if (rc <= 0)
129 error(EDISK,rc); 177 error(EDISK,rc);
130 178
179 if(button_hold())
180 {
181 rc = boot_of();
182 if(rc < 0)
183 printf("Error: %s", strerror(rc));
184 }
185
131 printf("Loading firmware"); 186 printf("Loading firmware");
132 rc = load_firmware((unsigned char *)CONFIG_SDRAM_START, BOOTFILE, 0x400000); 187 rc = load_firmware((unsigned char *)CONFIG_SDRAM_START, BOOTFILE, 0x400000);
133 if(rc < 0) 188 if(rc < 0)
@@ -136,7 +191,7 @@ int main(void)
136 if (rc == EOK) 191 if (rc == EOK)
137 { 192 {
138 printf("Starting Rockbox..."); 193 printf("Starting Rockbox...");
139 adc_close(); /* Disable SADC */ 194 adc_close(); /* Disable SADC */
140 _backlight_off(); /* Force backlight off to prevent LCD 'flicker' */ 195 _backlight_off(); /* Force backlight off to prevent LCD 'flicker' */
141 196
142 disable_interrupt(); 197 disable_interrupt();
diff --git a/firmware/export/config-ondavx747.h b/firmware/export/config-ondavx747.h
index 22108fff49..1d9a7a8883 100644
--- a/firmware/export/config-ondavx747.h
+++ b/firmware/export/config-ondavx747.h
@@ -81,8 +81,13 @@
81/* LCD dimensions */ 81/* LCD dimensions */
82#define CONFIG_LCD LCD_ONDAVX747 82#define CONFIG_LCD LCD_ONDAVX747
83 83
84#ifdef BOOTLOADER /* OF requires landscape */
85#define LCD_WIDTH 400
86#define LCD_HEIGHT 240
87#else
84#define LCD_WIDTH 240 88#define LCD_WIDTH 240
85#define LCD_HEIGHT 400 89#define LCD_HEIGHT 400
90#endif
86 91
87#define LCD_DEPTH 16 /* 16bit colours */ 92#define LCD_DEPTH 16 /* 16bit colours */
88#define LCD_PIXELFORMAT RGB565 /* rgb565 */ 93#define LCD_PIXELFORMAT RGB565 /* rgb565 */
diff --git a/firmware/target/mips/ingenic_jz47xx/boot.lds b/firmware/target/mips/ingenic_jz47xx/boot.lds
index fb30fa240f..15d3e3dd47 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-4) * 0x100000) 9#define DRAMSIZE ((MEMORYSIZE-4) * 0x100000)
10 10
11#define DRAMORIG 0x80404000 11#define DRAMORIG 0x80E04000
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 111244b173..7035c5ab0b 100644
--- a/firmware/target/mips/ingenic_jz47xx/crt0.S
+++ b/firmware/target/mips/ingenic_jz47xx/crt0.S
@@ -50,12 +50,12 @@
50 .set noat 50 .set noat
51 51
52#ifdef BOOTLOADER 52#ifdef BOOTLOADER
53 /* These will get filled in scramble */ 53 /* These will get filled in by scramble */
54 .word 0 /* Unknown */ 54 .word 0 /* Empty */
55 .word 0 /* Filesize */ 55 .word 0 /* Filesize */
56 56
57 /* Relocate bootloader */ 57 /* Relocate bootloader */
58 la t0, (_loadaddress-0x400000) 58 la t0, (_loadaddress-0xE00000)
59 la t1, _loadaddress 59 la t1, _loadaddress
60 la t2, _bootend 60 la t2, _bootend
61_relocate_loop: 61_relocate_loop:
diff --git a/tools/configure b/tools/configure
index f5aeceaf58..802173f1b6 100755
--- a/tools/configure
+++ b/tools/configure
@@ -2105,8 +2105,8 @@ fi
2105 plugins="yes" 2105 plugins="yes"
2106 swcodec="yes" 2106 swcodec="yes"
2107 toolset=$genericbitmaptools 2107 toolset=$genericbitmaptools
2108 boottool="cp" 2108 boottool="$rootdir/tools/scramble -ccpmp"
2109 bootoutput="rockboot.vx747" 2109 bootoutput="ccpmp.bin"
2110 # architecture, manufacturer and model for the target-tree build 2110 # architecture, manufacturer and model for the target-tree build
2111 t_cpu="mips" 2111 t_cpu="mips"
2112 t_manufacturer="ingenic_jz47xx" 2112 t_manufacturer="ingenic_jz47xx"
@@ -2127,8 +2127,8 @@ fi
2127 plugins="" #FIXME 2127 plugins="" #FIXME
2128 swcodec="yes" 2128 swcodec="yes"
2129 toolset=$genericbitmaptools 2129 toolset=$genericbitmaptools
2130 boottool="cp" 2130 boottool="$rootdir/tools/scramble -ccpmp"
2131 bootoutput="rockboot.vx767" 2131 bootoutput="ccpmp.bin"
2132 # architecture, manufacturer and model for the target-tree build 2132 # architecture, manufacturer and model for the target-tree build
2133 t_cpu="mips" 2133 t_cpu="mips"
2134 t_manufacturer="ingenic_jz47xx" 2134 t_manufacturer="ingenic_jz47xx"
@@ -2149,8 +2149,8 @@ fi
2149 plugins="yes" 2149 plugins="yes"
2150 swcodec="yes" 2150 swcodec="yes"
2151 toolset=$genericbitmaptools 2151 toolset=$genericbitmaptools
2152 boottool="cp" 2152 boottool="$rootdir/tools/scramble -ccpmp"
2153 bootoutput="rockboot.vx747p" 2153 bootoutput="ccpmp.bin"
2154 # architecture, manufacturer and model for the target-tree build 2154 # architecture, manufacturer and model for the target-tree build
2155 t_cpu="mips" 2155 t_cpu="mips"
2156 t_manufacturer="ingenic_jz47xx" 2156 t_manufacturer="ingenic_jz47xx"
@@ -2171,8 +2171,8 @@ fi
2171 plugins="" #TODO 2171 plugins="" #TODO
2172 swcodec="yes" 2172 swcodec="yes"
2173 toolset=$genericbitmaptools 2173 toolset=$genericbitmaptools
2174 boottool="cp" 2174 boottool="$rootdir/tools/scramble -ccpmp"
2175 bootoutput="rockboot.vx777" 2175 bootoutput="ccpmp.bin"
2176 # architecture, manufacturer and model for the target-tree build 2176 # architecture, manufacturer and model for the target-tree build
2177 t_cpu="mips" 2177 t_cpu="mips"
2178 t_manufacturer="ingenic_jz47xx" 2178 t_manufacturer="ingenic_jz47xx"
diff --git a/tools/scramble.c b/tools/scramble.c
index cabe15f48d..5d2b12fb84 100644
--- a/tools/scramble.c
+++ b/tools/scramble.c
@@ -33,6 +33,7 @@
33 33
34int iaudio_encode(char *iname, char *oname, char *idstring); 34int iaudio_encode(char *iname, char *oname, char *idstring);
35int ipod_encode(char *iname, char *oname, int fw_ver, bool fake_rsrc); 35int ipod_encode(char *iname, char *oname, int fw_ver, bool fake_rsrc);
36int ccpmp_encode(char *iname, char *oname);
36 37
37enum 38enum
38{ 39{
@@ -375,8 +376,7 @@ int main (int argc, char** argv)
375 oname = argv[3]; 376 oname = argv[3];
376 return ipod_encode(iname, oname, 3, true); /* Firmware image v3 */ 377 return ipod_encode(iname, oname, 3, true); /* Firmware image v3 */
377 } 378 }
378 else if(!strncmp(argv[1], "-creative=", 10)) 379 else if(!strncmp(argv[1], "-creative=", 10)) {
379 {
380 if(!strcmp(argv[2], "-no-ciff")) 380 if(!strcmp(argv[2], "-no-ciff"))
381 { 381 {
382 creative_enable_ciff = false; 382 creative_enable_ciff = false;
@@ -405,6 +405,11 @@ int main (int argc, char** argv)
405 return 2; 405 return 2;
406 } 406 }
407 } 407 }
408 else if(!strcmp(argv[1], "-ccpmp")) {
409 iname = argv[2];
410 oname = argv[3];
411 return ccpmp_encode(iname, oname);
412 }
408 else if(!strncmp(argv[1], "-mi4", 4)) { 413 else if(!strncmp(argv[1], "-mi4", 4)) {
409 int mi4magic; 414 int mi4magic;
410 char model[4] = ""; 415 char model[4] = "";
@@ -824,3 +829,58 @@ int ipod_encode(char *iname, char *oname, int fw_ver, bool fake_rsrc)
824 return 0; 829 return 0;
825} 830}
826 831
832#define CCPMP_SIZE 0x500000
833int ccpmp_encode(char *iname, char *oname)
834{
835 size_t len;
836 int length;
837 FILE *file;
838 unsigned char *outbuf;
839
840 file = fopen(iname, "rb");
841 if (!file) {
842 perror(iname);
843 return -1;
844 }
845 fseek(file,0,SEEK_END);
846 length = ftell(file);
847
848 fseek(file,0,SEEK_SET);
849
850 outbuf = malloc(CCPMP_SIZE);
851
852 if ( !outbuf ) {
853 printf("out of memory!\n");
854 return -1;
855 }
856
857 len = fread(outbuf, 1, length, file);
858 if(len < (size_t)length) {
859 perror(iname);
860 return -2;
861 }
862 fclose(file);
863
864 /* Clear the tail area to 0xFF */
865 memset(&outbuf[length], 0xFF, CCPMP_SIZE - length);
866
867 /* Header */
868 int2le(length, &outbuf[0x4]);
869
870 file = fopen(oname, "wb");
871 if (!file) {
872 perror(oname);
873 return -3;
874 }
875
876 len = fwrite(outbuf, 1, CCPMP_SIZE, file);
877 if(len < (size_t)length) {
878 perror(oname);
879 return -4;
880 }
881
882 fclose(file);
883
884 return 0;
885}
886