summaryrefslogtreecommitdiff
path: root/bootloader/ondavx747.c
diff options
context:
space:
mode:
Diffstat (limited to 'bootloader/ondavx747.c')
-rwxr-xr-xbootloader/ondavx747.c73
1 files changed, 64 insertions, 9 deletions
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();