diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2007-02-22 15:09:49 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2007-02-22 15:09:49 +0000 |
commit | 46597c953963eb8333e5122896fdcb4d0ec9f93f (patch) | |
tree | 434605a340de75938beb7cb996f57c333649f88e | |
parent | 9744433752b59a5da45c8076c4be6d2980d8cbbb (diff) | |
download | rockbox-46597c953963eb8333e5122896fdcb4d0ec9f93f.tar.gz rockbox-46597c953963eb8333e5122896fdcb4d0ec9f93f.zip |
FS#6554 - Move bootloader code into a common file
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12453 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | bootloader/SOURCES | 4 | ||||
-rw-r--r-- | bootloader/common.c | 2 | ||||
-rw-r--r-- | bootloader/gigabeat.c | 148 | ||||
-rw-r--r-- | bootloader/main.c | 150 | ||||
-rw-r--r-- | bootloader/tpj1022.c | 24 |
5 files changed, 68 insertions, 260 deletions
diff --git a/bootloader/SOURCES b/bootloader/SOURCES index 76cb6931ef..68002caf0b 100644 --- a/bootloader/SOURCES +++ b/bootloader/SOURCES | |||
@@ -1,10 +1,10 @@ | |||
1 | #if defined(IPOD_ARCH) | ||
2 | common.c | 1 | common.c |
2 | |||
3 | #if defined(IPOD_ARCH) | ||
3 | ipod.c | 4 | ipod.c |
4 | #elif defined(GIGABEAT_F) | 5 | #elif defined(GIGABEAT_F) |
5 | gigabeat.c | 6 | gigabeat.c |
6 | #elif defined(IRIVER_H10) || defined(IRIVER_H10_5GB) || defined(SANSA_E200) | 7 | #elif defined(IRIVER_H10) || defined(IRIVER_H10_5GB) || defined(SANSA_E200) |
7 | common.c | ||
8 | main-pp.c | 8 | main-pp.c |
9 | #elif defined(ELIO_TPJ1022) | 9 | #elif defined(ELIO_TPJ1022) |
10 | tpj1022.c | 10 | tpj1022.c |
diff --git a/bootloader/common.c b/bootloader/common.c index 410fd42cd8..1d0ad360be 100644 --- a/bootloader/common.c +++ b/bootloader/common.c | |||
@@ -154,7 +154,7 @@ int load_firmware(unsigned char* buf, char* firmware, int buffer_size) | |||
154 | if(sum != chksum) | 154 | if(sum != chksum) |
155 | return EBAD_CHKSUM; | 155 | return EBAD_CHKSUM; |
156 | 156 | ||
157 | return len; | 157 | return EOK; |
158 | } | 158 | } |
159 | 159 | ||
160 | /* Load raw binary image. */ | 160 | /* Load raw binary image. */ |
diff --git a/bootloader/gigabeat.c b/bootloader/gigabeat.c index a466f9498f..f9073028fb 100644 --- a/bootloader/gigabeat.c +++ b/bootloader/gigabeat.c | |||
@@ -18,11 +18,10 @@ | |||
18 | #include "power.h" | 18 | #include "power.h" |
19 | #include "file.h" | 19 | #include "file.h" |
20 | #include "button-target.h" | 20 | #include "button-target.h" |
21 | #include "common.h" | ||
21 | 22 | ||
22 | extern void map_memory(void); | 23 | extern void map_memory(void); |
23 | 24 | ||
24 | int line = 0; | ||
25 | |||
26 | char version[] = APPSVERSION; | 25 | char version[] = APPSVERSION; |
27 | 26 | ||
28 | static void go_usb_mode(void) | 27 | static void go_usb_mode(void) |
@@ -55,30 +54,25 @@ int restore_fwimg01dat(void) | |||
55 | int orig_file = 0, dest_file = 0; | 54 | int orig_file = 0, dest_file = 0; |
56 | int size = 0, size_read; | 55 | int size = 0, size_read; |
57 | static char buf[4096]; | 56 | static char buf[4096]; |
58 | char lcd_buf[64]; | 57 | |
59 | |||
60 | orig_file = open("/GBSYSTEM/FWIMG/FWIMG01.DAT.ORIG", O_RDONLY); | 58 | orig_file = open("/GBSYSTEM/FWIMG/FWIMG01.DAT.ORIG", O_RDONLY); |
61 | if(orig_file < 0) { | 59 | if(orig_file < 0) { |
62 | /* Couldn't open source file */ | 60 | /* Couldn't open source file */ |
63 | lcd_puts(0, line++, "Couldn't open FWIMG01.DAT.ORIG for reading"); | 61 | printf("Couldn't open FWIMG01.DAT.ORIG for reading"); |
64 | lcd_update(); | ||
65 | return(1); | 62 | return(1); |
66 | } | 63 | } |
67 | 64 | ||
68 | lcd_puts(0, line++, "FWIMG01.DAT.ORIG opened for reading"); | 65 | printf("FWIMG01.DAT.ORIG opened for reading"); |
69 | lcd_update(); | ||
70 | 66 | ||
71 | dest_file = open("/GBSYSTEM/FWIMG/FWIMG01.DAT", O_RDWR); | 67 | dest_file = open("/GBSYSTEM/FWIMG/FWIMG01.DAT", O_RDWR); |
72 | if(dest_file < 0) { | 68 | if(dest_file < 0) { |
73 | /* Couldn't open destination file */ | 69 | /* Couldn't open destination file */ |
74 | lcd_puts(0, line++, "Couldn't open FWIMG01.DAT.ORIG for writing"); | 70 | printf("Couldn't open FWIMG01.DAT.ORIG for writing"); |
75 | lcd_update(); | ||
76 | close(orig_file); | 71 | close(orig_file); |
77 | return(2); | 72 | return(2); |
78 | } | 73 | } |
79 | 74 | ||
80 | lcd_puts(0, line++, "FWIMG01.DAT opened for writing"); | 75 | printf("FWIMG01.DAT opened for writing"); |
81 | lcd_update(); | ||
82 | 76 | ||
83 | do { | 77 | do { |
84 | /* Copy in chunks */ | 78 | /* Copy in chunks */ |
@@ -95,65 +89,22 @@ int restore_fwimg01dat(void) | |||
95 | close(orig_file); | 89 | close(orig_file); |
96 | close(dest_file); | 90 | close(dest_file); |
97 | 91 | ||
98 | snprintf(lcd_buf, sizeof(lcd_buf), "Finished copying %ld bytes from", size); | 92 | printf("Finished copying %ld bytes from", size); |
99 | lcd_puts(0, line++, lcd_buf); | 93 | printf("FWIMG01.DAT.ORIG to FWIMG01.DAT"); |
100 | lcd_puts(0, line++, "FWIMG01.DAT.ORIG to FWIMG01.DAT"); | ||
101 | 94 | ||
102 | return(0); | 95 | return(0); |
103 | } | 96 | } |
104 | 97 | ||
105 | |||
106 | int load_rockbox(const char* file_name, unsigned char* buf, int buffer_size) | ||
107 | { | ||
108 | int fd; | ||
109 | int rc; | ||
110 | int len; | ||
111 | char str[256]; | ||
112 | |||
113 | fd = open("/.rockbox/" BOOTFILE, O_RDONLY); | ||
114 | if(fd < 0) { | ||
115 | fd = open("/" BOOTFILE, O_RDONLY); | ||
116 | if(fd < 0) | ||
117 | return -1; | ||
118 | } | ||
119 | fd = open(file_name, O_RDONLY); | ||
120 | if(fd < 0) | ||
121 | return -2; | ||
122 | |||
123 | len = filesize(fd); | ||
124 | |||
125 | if(len > buffer_size) { | ||
126 | snprintf(str, sizeof(str), "len: %d buf: %d", len, buffer_size); | ||
127 | lcd_puts(0, line++, str); | ||
128 | lcd_update(); | ||
129 | return -6; | ||
130 | } | ||
131 | |||
132 | rc = read(fd, buf, len); | ||
133 | if(rc < len) { | ||
134 | snprintf(str, sizeof(str), "len: %d rc: %d", len, rc); | ||
135 | lcd_puts(0, line++, str); | ||
136 | lcd_update(); | ||
137 | return -4; | ||
138 | } | ||
139 | |||
140 | close(fd); | ||
141 | |||
142 | return len; | ||
143 | } | ||
144 | |||
145 | char buf[256]; | 98 | char buf[256]; |
146 | 99 | ||
147 | void display_instructions(void) | 100 | void display_instructions(void) |
148 | { | 101 | { |
149 | lcd_setfont(FONT_SYSFIXED); | 102 | lcd_setfont(FONT_SYSFIXED); |
150 | lcd_puts(0, line++, "Hold MENU when booting for rescue mode."); | 103 | printf("Hold MENU when booting for rescue mode."); |
151 | lcd_puts(0, line++, " \"VOL+\" button to restore original kernel"); | 104 | printf(" \"VOL+\" button to restore original kernel"); |
152 | lcd_puts(0, line++, " \"A\" button to load original firmware"); | 105 | printf(" \"A\" button to load original firmware"); |
153 | line++; | 106 | printf(""); |
154 | snprintf(buf, sizeof(buf), "FRAME %x TTB %x", FRAME, TTB_BASE); | 107 | printf("FRAME %x TTB %x", FRAME, TTB_BASE); |
155 | lcd_puts(0, line++, buf); | ||
156 | lcd_update(); | ||
157 | } | 108 | } |
158 | 109 | ||
159 | void * main(void) | 110 | void * main(void) |
@@ -179,23 +130,20 @@ void * main(void) | |||
179 | } | 130 | } |
180 | if(GPGDAT & 2) { | 131 | if(GPGDAT & 2) { |
181 | lcd_init(); | 132 | lcd_init(); |
182 | lcd_puts(0, line++, "Entering rescue mode.."); | 133 | printf("Entering rescue mode.."); |
183 | lcd_update(); | ||
184 | go_usb_mode(); | 134 | go_usb_mode(); |
185 | while(1); | 135 | while(1); |
186 | } | 136 | } |
187 | if(GPGDAT & 0x10) { | 137 | if(GPGDAT & 0x10) { |
188 | lcd_init(); | 138 | lcd_init(); |
189 | load_original = true; | 139 | load_original = true; |
190 | lcd_puts(0, line++, "Loading original firmware..."); | 140 | printf("Loading original firmware..."); |
191 | lcd_update(); | ||
192 | } | 141 | } |
193 | 142 | ||
194 | i = ata_init(); | 143 | i = ata_init(); |
195 | i = disk_mount_all(); | 144 | i = disk_mount_all(); |
196 | if(!show_bootsplash) { | 145 | if(!show_bootsplash) { |
197 | snprintf(buf, sizeof(buf), "disk_mount_all: %d", i); | 146 | printf("disk_mount_all: %d", i); |
198 | lcd_puts(0, line++, buf); | ||
199 | } | 147 | } |
200 | if(show_bootsplash) { | 148 | if(show_bootsplash) { |
201 | int fd = open("/bootsplash.raw", O_RDONLY); | 149 | int fd = open("/bootsplash.raw", O_RDONLY); |
@@ -216,17 +164,15 @@ void * main(void) | |||
216 | if(GPGDAT & 4) { | 164 | if(GPGDAT & 4) { |
217 | 165 | ||
218 | /* Try to restore the original kernel/bootloader if a copy is found */ | 166 | /* Try to restore the original kernel/bootloader if a copy is found */ |
219 | lcd_puts(0, line++, "Restoring FWIMG01.DAT..."); | 167 | printf("Restoring FWIMG01.DAT..."); |
220 | lcd_update(); | ||
221 | 168 | ||
222 | if(!restore_fwimg01dat()) { | 169 | if(!restore_fwimg01dat()) { |
223 | lcd_puts(0, line++, "Restoring FWIMG01.DAT successful."); | 170 | printf("Restoring FWIMG01.DAT successful."); |
224 | } else { | 171 | } else { |
225 | lcd_puts(0, line++, "Restoring FWIMG01.DAT failed."); | 172 | printf("Restoring FWIMG01.DAT failed."); |
226 | } | 173 | } |
227 | 174 | ||
228 | lcd_puts(0, line++, "Now power cycle to boot original"); | 175 | printf("Now power cycle to boot original"); |
229 | lcd_update(); | ||
230 | while(1); | 176 | while(1); |
231 | } | 177 | } |
232 | 178 | ||
@@ -242,76 +188,66 @@ void * main(void) | |||
242 | for(i=39; i && buf[i]==' '; i--) | 188 | for(i=39; i && buf[i]==' '; i--) |
243 | buf[i] = 0; | 189 | buf[i] = 0; |
244 | 190 | ||
245 | lcd_puts(0, line++, "Model"); | 191 | printf("Model"); |
246 | lcd_puts(0, line++, buf); | 192 | printf(buf); |
247 | 193 | ||
248 | for(i=0; i < 4; i++) | 194 | for(i=0; i < 4; i++) |
249 | ((unsigned short*)buf)[i]=htobe16(identify_info[i+23]); | 195 | ((unsigned short*)buf)[i]=htobe16(identify_info[i+23]); |
250 | 196 | ||
251 | buf[8]=0; | 197 | buf[8]=0; |
252 | 198 | ||
253 | lcd_puts(0, line++, "Firmware"); | 199 | printf("Firmware"); |
254 | lcd_puts(0, line++, buf); | 200 | printf(buf); |
255 | 201 | ||
256 | pinfo = disk_partinfo(0); | 202 | pinfo = disk_partinfo(0); |
257 | snprintf(buf, sizeof(buf), "Partition 0: 0x%02x %ld MB", | 203 | printf("Partition 0: 0x%02x %ld MB", pinfo->type, pinfo->size / 2048); |
258 | pinfo->type, pinfo->size / 2048); | ||
259 | lcd_puts(0, line++, buf); | ||
260 | lcd_update(); | ||
261 | } | 204 | } |
262 | /* Load original firmware */ | 205 | /* Load original firmware */ |
263 | if(load_original) { | 206 | if(load_original) { |
264 | loadbuffer = (unsigned char*)0x30008000; | 207 | loadbuffer = (unsigned char*)0x30008000; |
265 | buffer_size =(unsigned char*)0x31000000 - loadbuffer; | 208 | buffer_size =(unsigned char*)0x31000000 - loadbuffer; |
266 | rc = load_rockbox("/rockbox.gigabeat", loadbuffer, buffer_size); | 209 | rc = load_firmware("rockbox.gigabeat", loadbuffer, buffer_size); |
267 | if(rc < 0) { | 210 | if(rc < EOK) { |
268 | lcd_puts(0, line++, "failed to load original firmware. Loading rockbox"); | 211 | printf("Error!"); |
269 | lcd_update(); | 212 | printf("Failed to load original firmware:"); |
213 | printf(strerror(rc)); | ||
214 | printf("Loading rockbox"); | ||
270 | sleep(2*HZ); | 215 | sleep(2*HZ); |
271 | goto load_rockbox; | 216 | goto load_rockbox; |
272 | } | 217 | } |
273 | 218 | ||
274 | snprintf(buf, sizeof(buf), "Loaded: %d", rc); | 219 | printf("Loaded: %d", rc); |
275 | lcd_puts(0, line++, buf); | ||
276 | lcd_update(); | ||
277 | sleep(2*HZ); | 220 | sleep(2*HZ); |
278 | 221 | ||
279 | (*((int*)0x7000000)) = 333; | 222 | (*((int*)0x7000000)) = 333; |
280 | rc = *((int*)0x7000000+0x8000000); | 223 | rc = *((int*)0x7000000+0x8000000); |
281 | snprintf(buf, sizeof(buf), "Bank0 mem test: %d", rc); | 224 | printf("Bank0 mem test: %d", rc); |
282 | lcd_puts(0, line++, buf); | ||
283 | lcd_update(); | ||
284 | sleep(3*HZ); | 225 | sleep(3*HZ); |
285 | 226 | ||
286 | lcd_puts(0, line++, "Woops, should not return from firmware!"); | 227 | printf("Woops, should not return from firmware!"); |
287 | lcd_update(); | ||
288 | goto usb; | 228 | goto usb; |
289 | } | 229 | } |
290 | 230 | ||
291 | load_rockbox: | 231 | load_rockbox: |
292 | map_memory(); | 232 | map_memory(); |
293 | if(!show_bootsplash) { | 233 | if(!show_bootsplash) { |
294 | lcd_puts(0, line, "Loading Rockbox..."); | 234 | printf("Loading Rockbox..."); |
295 | lcd_update(); | ||
296 | } | 235 | } |
297 | 236 | ||
298 | loadbuffer = (unsigned char*) 0x100; | 237 | loadbuffer = (unsigned char*) 0x100; |
299 | buffer_size = (unsigned char*)0x400000 - loadbuffer; | 238 | buffer_size = (unsigned char*)0x400000 - loadbuffer; |
300 | rc=load_rockbox("/rockbox.gigabeat", loadbuffer, buffer_size); | 239 | rc=load_firmware("rockbox.gigabeat", loadbuffer, buffer_size); |
301 | if(rc < 0) { | 240 | if(rc < EOK) { |
302 | snprintf(buf, sizeof(buf), "Rockbox error: %d",rc); | 241 | printf("Error!"); |
303 | lcd_puts(0, line++, buf); | 242 | printf("Can't load rockbox.gigabeat:"); |
304 | lcd_update(); | 243 | printf(strerror(rc)); |
305 | } else { | 244 | } else { |
306 | if(!show_bootsplash) { | 245 | if(!show_bootsplash) { |
307 | lcd_puts(0, line++, "Rockbox loaded."); | 246 | printf("Rockbox loaded."); |
308 | lcd_update(); | ||
309 | } | 247 | } |
310 | kernel_entry = (void*) loadbuffer; | 248 | kernel_entry = (void*) loadbuffer; |
311 | rc = kernel_entry(); | 249 | rc = kernel_entry(); |
312 | snprintf(buf, sizeof(buf), "Woops, should not return from firmware: %d", rc); | 250 | printf("Woops, should not return from firmware: %d", rc); |
313 | lcd_puts(0, line++, buf); | ||
314 | lcd_update(); | ||
315 | goto usb; | 251 | goto usb; |
316 | } | 252 | } |
317 | usb: | 253 | usb: |
diff --git a/bootloader/main.c b/bootloader/main.c index fd878ac5f6..c2e3cce302 100644 --- a/bootloader/main.c +++ b/bootloader/main.c | |||
@@ -43,20 +43,19 @@ | |||
43 | #include "eeprom_settings.h" | 43 | #include "eeprom_settings.h" |
44 | 44 | ||
45 | #include "pcf50606.h" | 45 | #include "pcf50606.h" |
46 | #include "common.h" | ||
46 | 47 | ||
47 | #include <stdarg.h> | 48 | #include <stdarg.h> |
48 | 49 | ||
50 | /* Maximum allowed firmware image size. 10MB is more than enough */ | ||
51 | #define MAX_LOADSIZE (10*1024*1024) | ||
52 | |||
49 | #define DRAM_START 0x31000000 | 53 | #define DRAM_START 0x31000000 |
50 | 54 | ||
51 | #ifdef HAVE_EEPROM_SETTINGS | 55 | #ifdef HAVE_EEPROM_SETTINGS |
52 | static bool recovery_mode = false; | 56 | static bool recovery_mode = false; |
53 | #endif | 57 | #endif |
54 | 58 | ||
55 | int line = 0; | ||
56 | #ifdef HAVE_REMOTE_LCD | ||
57 | int remote_line = 0; | ||
58 | #endif | ||
59 | |||
60 | int usb_screen(void) | 59 | int usb_screen(void) |
61 | { | 60 | { |
62 | return 0; | 61 | return 0; |
@@ -64,41 +63,6 @@ int usb_screen(void) | |||
64 | 63 | ||
65 | char version[] = APPSVERSION; | 64 | char version[] = APPSVERSION; |
66 | 65 | ||
67 | char printfbuf[256]; | ||
68 | |||
69 | void reset_screen(void) | ||
70 | { | ||
71 | lcd_clear_display(); | ||
72 | line = 0; | ||
73 | #ifdef HAVE_REMOTE_LCD | ||
74 | lcd_remote_clear_display(); | ||
75 | remote_line = 0; | ||
76 | #endif | ||
77 | } | ||
78 | |||
79 | void printf(const char *format, ...) | ||
80 | { | ||
81 | int len; | ||
82 | unsigned char *ptr; | ||
83 | va_list ap; | ||
84 | va_start(ap, format); | ||
85 | |||
86 | ptr = printfbuf; | ||
87 | len = vsnprintf(ptr, sizeof(printfbuf), format, ap); | ||
88 | va_end(ap); | ||
89 | |||
90 | lcd_puts(0, line++, ptr); | ||
91 | lcd_update(); | ||
92 | if(line >= 16) | ||
93 | line = 0; | ||
94 | #ifdef HAVE_REMOTE_LCD | ||
95 | lcd_remote_puts(0, remote_line++, ptr); | ||
96 | lcd_remote_update(); | ||
97 | if(remote_line >= 8) | ||
98 | remote_line = 0; | ||
99 | #endif | ||
100 | } | ||
101 | |||
102 | /* Reset the cookie for the crt0 crash check */ | 66 | /* Reset the cookie for the crt0 crash check */ |
103 | inline void __reset_cookie(void) | 67 | inline void __reset_cookie(void) |
104 | { | 68 | { |
@@ -116,68 +80,6 @@ void start_iriver_fw(void) | |||
116 | asm(" jmp (%a0)"); | 80 | asm(" jmp (%a0)"); |
117 | } | 81 | } |
118 | 82 | ||
119 | int load_firmware(void) | ||
120 | { | ||
121 | int fd; | ||
122 | int rc; | ||
123 | int len; | ||
124 | unsigned long chksum; | ||
125 | char model[5]; | ||
126 | unsigned long sum; | ||
127 | int i; | ||
128 | unsigned char *buf = (unsigned char *)DRAM_START; | ||
129 | |||
130 | fd = open("/.rockbox/" BOOTFILE, O_RDONLY); | ||
131 | if(fd < 0) | ||
132 | { | ||
133 | fd = open("/" BOOTFILE, O_RDONLY); | ||
134 | if(fd < 0) | ||
135 | return -1; | ||
136 | } | ||
137 | |||
138 | len = filesize(fd) - 8; | ||
139 | |||
140 | printf("Length: %x", len); | ||
141 | |||
142 | lseek(fd, FIRMWARE_OFFSET_FILE_CRC, SEEK_SET); | ||
143 | |||
144 | rc = read(fd, &chksum, 4); | ||
145 | if(rc < 4) | ||
146 | return -2; | ||
147 | |||
148 | printf("Checksum: %x", chksum); | ||
149 | |||
150 | rc = read(fd, model, 4); | ||
151 | if(rc < 4) | ||
152 | return -3; | ||
153 | |||
154 | model[4] = 0; | ||
155 | |||
156 | printf("Model name: %s", model); | ||
157 | lcd_update(); | ||
158 | |||
159 | lseek(fd, FIRMWARE_OFFSET_FILE_DATA, SEEK_SET); | ||
160 | |||
161 | rc = read(fd, buf, len); | ||
162 | if(rc < len) | ||
163 | return -4; | ||
164 | |||
165 | close(fd); | ||
166 | |||
167 | sum = MODEL_NUMBER; | ||
168 | |||
169 | for(i = 0;i < len;i++) { | ||
170 | sum += buf[i]; | ||
171 | } | ||
172 | |||
173 | printf("Sum: %x", sum); | ||
174 | |||
175 | if(sum != chksum) | ||
176 | return -5; | ||
177 | |||
178 | return 0; | ||
179 | } | ||
180 | |||
181 | void start_firmware(void) | 83 | void start_firmware(void) |
182 | { | 84 | { |
183 | asm(" move.w #0x2700,%sr"); | 85 | asm(" move.w #0x2700,%sr"); |
@@ -353,6 +255,7 @@ void failsafe_menu(void) | |||
353 | int defopt = -1; | 255 | int defopt = -1; |
354 | char buf[32]; | 256 | char buf[32]; |
355 | int i; | 257 | int i; |
258 | extern int line; | ||
356 | 259 | ||
357 | reset_screen(); | 260 | reset_screen(); |
358 | printf("Bootloader %s", version); | 261 | printf("Bootloader %s", version); |
@@ -516,15 +419,21 @@ void main(void) | |||
516 | } | 419 | } |
517 | 420 | ||
518 | printf("Loading firmware"); | 421 | printf("Loading firmware"); |
519 | i = load_firmware(); | 422 | i = load_firmware((unsigned char *)DRAM_START, BOOTFILE, MAX_LOADSIZE); |
520 | printf("Result: %d", i); | 423 | printf("Result: %s", strerror(i)); |
521 | 424 | ||
522 | if(i == 0) | 425 | if (i < EOK) { |
426 | printf("Error!"); | ||
427 | printf("Can't load rockbox.ipod:"); | ||
428 | printf(strerror(rc)); | ||
429 | sleep(HZ*3); | ||
430 | power_off(); | ||
431 | } else { | ||
523 | start_firmware(); | 432 | start_firmware(); |
524 | 433 | } | |
525 | power_off(); | ||
526 | 434 | ||
527 | #else | 435 | #else |
436 | extern int line; | ||
528 | /* We want to read the buttons as early as possible, before the user | 437 | /* We want to read the buttons as early as possible, before the user |
529 | releases the ON button */ | 438 | releases the ON button */ |
530 | 439 | ||
@@ -721,15 +630,16 @@ void main(void) | |||
721 | } | 630 | } |
722 | 631 | ||
723 | printf("Loading firmware"); | 632 | printf("Loading firmware"); |
724 | i = load_firmware(); | 633 | i = load_firmware((unsigned char *)DRAM_START, BOOTFILE, MAX_LOADSIZE); |
725 | printf("Result: %d", i); | 634 | printf("Result: %d", strerror(i)); |
726 | 635 | ||
727 | if (i == 0) | 636 | if (i == EOK) |
728 | start_firmware(); | 637 | start_firmware(); |
729 | 638 | ||
730 | if (!detect_original_firmware()) | 639 | if (!detect_original_firmware()) |
731 | { | 640 | { |
732 | printf("No firmware found on disk"); | 641 | printf("No firmware found on disk"); |
642 | sleep(HZ*2); | ||
733 | shutdown(); | 643 | shutdown(); |
734 | } | 644 | } |
735 | else | 645 | else |
@@ -739,24 +649,6 @@ void main(void) | |||
739 | 649 | ||
740 | /* These functions are present in the firmware library, but we reimplement | 650 | /* These functions are present in the firmware library, but we reimplement |
741 | them here because the originals do a lot more than we want */ | 651 | them here because the originals do a lot more than we want */ |
742 | |||
743 | void reset_poweroff_timer(void) | ||
744 | { | ||
745 | } | ||
746 | |||
747 | void screen_dump(void) | 652 | void screen_dump(void) |
748 | { | 653 | { |
749 | } | 654 | } |
750 | |||
751 | int dbg_ports(void) | ||
752 | { | ||
753 | return 0; | ||
754 | } | ||
755 | |||
756 | void mpeg_stop(void) | ||
757 | { | ||
758 | } | ||
759 | |||
760 | void sys_poweroff(void) | ||
761 | { | ||
762 | } | ||
diff --git a/bootloader/tpj1022.c b/bootloader/tpj1022.c index 0088f73690..5d70adf5fe 100644 --- a/bootloader/tpj1022.c +++ b/bootloader/tpj1022.c | |||
@@ -37,11 +37,10 @@ | |||
37 | #include "panic.h" | 37 | #include "panic.h" |
38 | #include "power.h" | 38 | #include "power.h" |
39 | #include "file.h" | 39 | #include "file.h" |
40 | #include "common.h" | ||
40 | 41 | ||
41 | char version[] = APPSVERSION; | 42 | char version[] = APPSVERSION; |
42 | 43 | ||
43 | int line=0; | ||
44 | |||
45 | void* main(void) | 44 | void* main(void) |
46 | { | 45 | { |
47 | int i; | 46 | int i; |
@@ -54,8 +53,7 @@ void* main(void) | |||
54 | lcd_init(); | 53 | lcd_init(); |
55 | font_init(); | 54 | font_init(); |
56 | 55 | ||
57 | lcd_puts(0, line++ ,"Hello World!"); | 56 | printf("Hello World!"); |
58 | lcd_update(); | ||
59 | #endif | 57 | #endif |
60 | 58 | ||
61 | i=ata_init(); | 59 | i=ata_init(); |
@@ -108,20 +106,6 @@ void* main(void) | |||
108 | 106 | ||
109 | /* These functions are present in the firmware library, but we reimplement | 107 | /* These functions are present in the firmware library, but we reimplement |
110 | them here because the originals do a lot more than we want */ | 108 | them here because the originals do a lot more than we want */ |
111 | |||
112 | void reset_poweroff_timer(void) | ||
113 | { | ||
114 | } | ||
115 | |||
116 | int dbg_ports(void) | ||
117 | { | ||
118 | return 0; | ||
119 | } | ||
120 | |||
121 | void mpeg_stop(void) | ||
122 | { | ||
123 | } | ||
124 | |||
125 | void usb_acknowledge(void) | 109 | void usb_acknowledge(void) |
126 | { | 110 | { |
127 | } | 111 | } |
@@ -129,7 +113,3 @@ void usb_acknowledge(void) | |||
129 | void usb_wait_for_disconnect(void) | 113 | void usb_wait_for_disconnect(void) |
130 | { | 114 | { |
131 | } | 115 | } |
132 | |||
133 | void sys_poweroff(void) | ||
134 | { | ||
135 | } | ||