summaryrefslogtreecommitdiff
path: root/bootloader
diff options
context:
space:
mode:
authorBarry Wardell <rockbox@barrywardell.net>2006-12-19 11:33:53 +0000
committerBarry Wardell <rockbox@barrywardell.net>2006-12-19 11:33:53 +0000
commit2f16d4f1b3e52f0a268fa9679a72694f5a89dedf (patch)
tree332b7b5390bcd95fea7b291ca840e709c7aa1f83 /bootloader
parent6f4f58916417bdd11f2faf8339a0e94a039ca7a8 (diff)
downloadrockbox-2f16d4f1b3e52f0a268fa9679a72694f5a89dedf.tar.gz
rockbox-2f16d4f1b3e52f0a268fa9679a72694f5a89dedf.zip
Add working dual-boot bootloaders for H10 and Sansa, which allow booting the OF and Rockbox. Rolo also works.
Changes made: Combine bootloader/h10.c and bootloader/e200.c into a common bootloader file (bootloader/main-pp.c) to be used by all mi4 based PortalPlayer targets. The file bootloader/main-pp.c is based off the old bootloader/h10.c with some minor changes to allow it to work on the Sansa too. This effectively adds a Sansa bootloader. Define MODEL_NAME string in config-*.h for use in bootloader. Split crt0-pp.S into separate files for bootloader and normal builds. Bootloader code is now in crt0-pp-bl.S while normal build code stays in crt0-pp.S. Improvements to crt0-pp.S and crt0-pp-bl.S (mostly to make it more multiprocessor safe): * Leave space in bootloader at 0xe0-0xeb since scramble writes over there when it creates the mi4 file (don't leave space for iPods since it's not needed and all code in crt0-pp-bl.S needs to fit before the boot_table at 0x100). * Remove unused DEBUG and STUB code from crt0-pp.S. * Make CPU wait for COP to be sleeping when we put the COP to sleep. * Invalidate COP cache when COP wakes * Flush CPU cache before waking COP * Make sure only the CPU clears the BSS (not the COP) * Make sure only the CPU sets up its own stack (not the COP) Rolo works on H10, so enable it. Make Sansa e200 use rockbox.e200 rather than PP5022.mi4 for 'Normal' builds. This makes updating rockbox simpler as we don't need to go through the firmware update procedure, but rather just put a new rockbox.e200 on the device. rockbox.e200 uses a simple 'add' checksum. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11815 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'bootloader')
-rw-r--r--bootloader/SOURCES6
-rw-r--r--bootloader/e200.c190
-rw-r--r--bootloader/main-pp.c (renamed from bootloader/h10.c)26
3 files changed, 16 insertions, 206 deletions
diff --git a/bootloader/SOURCES b/bootloader/SOURCES
index 94f5a60e6b..b86365b429 100644
--- a/bootloader/SOURCES
+++ b/bootloader/SOURCES
@@ -2,10 +2,8 @@
2ipod.c 2ipod.c
3#elif defined(GIGABEAT_F) 3#elif defined(GIGABEAT_F)
4gigabeat.c 4gigabeat.c
5#elif defined(SANSA_E200) 5#elif defined(IRIVER_H10) || defined(IRIVER_H10_5GB) || defined(SANSA_E200)
6e200.c 6main-pp.c
7#elif defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
8h10.c
9#elif defined(ELIO_TPJ1022) 7#elif defined(ELIO_TPJ1022)
10tpj1022.c 8tpj1022.c
11#else 9#else
diff --git a/bootloader/e200.c b/bootloader/e200.c
deleted file mode 100644
index 27b1118a1c..0000000000
--- a/bootloader/e200.c
+++ /dev/null
@@ -1,190 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 Daniel Stenberg
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "config.h"
20
21#include <stdlib.h>
22#include <stdio.h>
23#include <string.h>
24#include "cpu.h"
25#include "system.h"
26#include "lcd.h"
27#include "kernel.h"
28#include "thread.h"
29#include "ata.h"
30#include "fat.h"
31#include "disk.h"
32#include "font.h"
33#include "adc.h"
34#include "backlight.h"
35#include "panic.h"
36#include "power.h"
37#include "file.h"
38
39static inline void blink(void)
40{
41 volatile unsigned int* ptr;
42 int i;
43 ptr = (volatile unsigned int*)0x70000020;
44
45 *ptr &= ~(1 << 13);
46 for(i = 0; i < 0xfffff; i++)
47 {
48 }
49 *ptr |= (1 << 13);
50 for(i = 0; i < 0xfffff; i++)
51 {
52 }
53}
54
55static inline void slow_blink(void)
56{
57 volatile unsigned int* ptr;
58 int i;
59 ptr = (volatile unsigned int*)0x70000020;
60
61 *ptr &= ~(1 << 13);
62 for(i = 0; i < (0xfffff); i++)
63 {
64 }
65 for(i = 0; i < (0xfffff); i++)
66 {
67 }
68 for(i = 0; i < (0xfffff); i++)
69 {
70 }
71
72 *ptr |= (1 << 13);
73 for(i = 0; i < (0xfffff); i++)
74 {
75 }
76 for(i = 0; i < (0xfffff); i++)
77 {
78 }
79 for(i = 0; i < (0xfffff); i++)
80 {
81 }
82}
83
84static inline unsigned long get_pc(void)
85{
86 unsigned long pc;
87 asm volatile (
88 "mov %0, pc\n"
89 : "=r"(pc)
90 );
91 return pc;
92}
93
94/* These functions are present in the firmware library, but we reimplement
95 them here because the originals do a lot more than we want */
96
97void reset_poweroff_timer(void)
98{
99}
100
101int dbg_ports(void)
102{
103 unsigned int gpio_a, gpio_b, gpio_c, gpio_d;
104 unsigned int gpio_e, gpio_f, gpio_g, gpio_h;
105 unsigned int gpio_i, gpio_j, gpio_k, gpio_l;
106
107 char buf[128];
108 int line;
109
110 lcd_setmargins(0, 0);
111 lcd_clear_display();
112 lcd_setfont(FONT_SYSFIXED);
113
114 while(1)
115 {
116 gpio_a = GPIOA_INPUT_VAL;
117 gpio_b = GPIOB_INPUT_VAL;
118 gpio_c = GPIOC_INPUT_VAL;
119
120 gpio_g = GPIOG_INPUT_VAL;
121 gpio_h = GPIOH_INPUT_VAL;
122 gpio_i = GPIOI_INPUT_VAL;
123
124 line = 0;
125 snprintf(buf, sizeof(buf), "GPIO_A: %02x GPIO_G: %02x", gpio_a, gpio_g);
126 lcd_puts(0, line++, buf);
127 snprintf(buf, sizeof(buf), "GPIO_B: %02x GPIO_H: %02x", gpio_b, gpio_h);
128 lcd_puts(0, line++, buf);
129 snprintf(buf, sizeof(buf), "GPIO_C: %02x GPIO_I: %02x", gpio_c, gpio_i);
130 lcd_puts(0, line++, buf);
131 line++;
132
133 gpio_d = GPIOD_INPUT_VAL;
134 gpio_e = GPIOE_INPUT_VAL;
135 gpio_f = GPIOF_INPUT_VAL;
136
137 gpio_j = GPIOJ_INPUT_VAL;
138 gpio_k = GPIOK_INPUT_VAL;
139 gpio_l = GPIOL_INPUT_VAL;
140
141 snprintf(buf, sizeof(buf), "GPIO_D: %02x GPIO_J: %02x", gpio_d, gpio_j);
142 lcd_puts(0, line++, buf);
143 snprintf(buf, sizeof(buf), "GPIO_E: %02x GPIO_K: %02x", gpio_e, gpio_k);
144 lcd_puts(0, line++, buf);
145 snprintf(buf, sizeof(buf), "GPIO_F: %02x GPIO_L: %02x", gpio_f, gpio_l);
146 lcd_puts(0, line++, buf);
147 line++;
148 snprintf(buf, sizeof(buf), "ADC_1: %02x", adc_read(ADC_0));
149 lcd_puts(0, line++, buf);
150 snprintf(buf, sizeof(buf), "ADC_2: %02x", adc_read(ADC_1));
151 lcd_puts(0, line++, buf);
152 snprintf(buf, sizeof(buf), "ADC_3: %02x", adc_read(ADC_2));
153 lcd_puts(0, line++, buf);
154 snprintf(buf, sizeof(buf), "ADC_4: %02x", adc_read(ADC_3));
155 lcd_puts(0, line++, buf);
156 lcd_update();
157 }
158 return 0;
159}
160
161void mpeg_stop(void)
162{
163}
164
165void usb_acknowledge(void)
166{
167}
168
169void usb_wait_for_disconnect(void)
170{
171}
172
173void sys_poweroff(void)
174{
175}
176
177void system_reboot(void)
178{
179
180}
181
182void main(void)
183{
184 kernel_init();
185 adc_init();
186 lcd_init_device();
187
188 dbg_ports();
189}
190
diff --git a/bootloader/h10.c b/bootloader/main-pp.c
index 0cfd64a96e..a533cc7044 100644
--- a/bootloader/h10.c
+++ b/bootloader/main-pp.c
@@ -40,8 +40,8 @@
40#include "power.h" 40#include "power.h"
41#include "file.h" 41#include "file.h"
42 42
43/* Size of the buffer to store the loaded Rockbox/iriver image */ 43/* Size of the buffer to store the loaded firmware image */
44#define MAX_LOADSIZE (5*1024*1024) 44#define MAX_LOADSIZE (10*1024*1024)
45 45
46/* A buffer to load the iriver firmware or Rockbox into */ 46/* A buffer to load the iriver firmware or Rockbox into */
47unsigned char loadbuffer[MAX_LOADSIZE]; 47unsigned char loadbuffer[MAX_LOADSIZE];
@@ -52,18 +52,18 @@ char version[] = APPSVERSION;
52 52
53int line=0; 53int line=0;
54 54
55/* Load original iriver firmware. This function expects a file called 55/* Load original mi4 firmware. This function expects a file called
56 "/System/Original.mi4" on the player. It should be decrypted 56 "/System/OF.bin" on the player. It should be a mi4 firmware decrypted
57 and have the header stripped using mi4code. It reads the file in to a memory 57 and header stripped using mi4code. It reads the file in to a memory
58 buffer called buf. The rest of the loading is done in main() and crt0.S 58 buffer called buf. The rest of the loading is done in main() and crt0.S
59*/ 59*/
60int load_iriver(unsigned char* buf) 60int load_original_firmware(unsigned char* buf)
61{ 61{
62 int fd; 62 int fd;
63 int rc; 63 int rc;
64 int len; 64 int len;
65 65
66 fd = open("/System/Original.mi4", O_RDONLY); 66 fd = open("/System/OF.bin", O_RDONLY);
67 67
68 len = filesize(fd); 68 len = filesize(fd);
69 69
@@ -78,7 +78,7 @@ int load_iriver(unsigned char* buf)
78 return len; 78 return len;
79} 79}
80 80
81/* Load Rockbox firmware (rockbox.h10) */ 81/* Load Rockbox firmware (rockbox.*) */
82int load_rockbox(unsigned char* buf) 82int load_rockbox(unsigned char* buf)
83{ 83{
84 int fd; 84 int fd;
@@ -164,6 +164,7 @@ void* main(void)
164 kernel_init(); 164 kernel_init();
165 lcd_init(); 165 lcd_init();
166 font_init(); 166 font_init();
167 button_init();
167 168
168 line=0; 169 line=0;
169 170
@@ -172,7 +173,7 @@ void* main(void)
172 lcd_puts(0, line++, "Rockbox boot loader"); 173 lcd_puts(0, line++, "Rockbox boot loader");
173 snprintf(buf, sizeof(buf), "Version: 20%s", version); 174 snprintf(buf, sizeof(buf), "Version: 20%s", version);
174 lcd_puts(0, line++, buf); 175 lcd_puts(0, line++, buf);
175 snprintf(buf, sizeof(buf), "iriver H10"); 176 snprintf(buf, sizeof(buf), MODEL_NAME);
176 lcd_puts(0, line++, buf); 177 lcd_puts(0, line++, buf);
177 lcd_update(); 178 lcd_update();
178 179
@@ -212,11 +213,11 @@ void* main(void)
212 i=button_read_device(); 213 i=button_read_device();
213 if(i==BUTTON_LEFT) 214 if(i==BUTTON_LEFT)
214 { 215 {
215 lcd_puts(0, line, "Loading iriver firmware..."); 216 lcd_puts(0, line++, "Loading original firmware...");
216 lcd_update(); 217 lcd_update();
217 rc=load_iriver(loadbuffer); 218 rc=load_original_firmware(loadbuffer);
218 } else { 219 } else {
219 lcd_puts(0, line, "Loading Rockbox..."); 220 lcd_puts(0, line++, "Loading Rockbox...");
220 lcd_update(); 221 lcd_update();
221 rc=load_rockbox(loadbuffer); 222 rc=load_rockbox(loadbuffer);
222 } 223 }
@@ -225,6 +226,7 @@ void* main(void)
225 snprintf(buf, sizeof(buf), "Rockbox error: %d",rc); 226 snprintf(buf, sizeof(buf), "Rockbox error: %d",rc);
226 lcd_puts(0, line++, buf); 227 lcd_puts(0, line++, buf);
227 lcd_update(); 228 lcd_update();
229 while(1) {}
228 } 230 }
229 231
230 memcpy((void*)DRAM_START,loadbuffer,rc); 232 memcpy((void*)DRAM_START,loadbuffer,rc);