diff options
author | Dave Chapman <dave@dchapman.com> | 2009-10-11 01:37:12 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2009-10-11 01:37:12 +0000 |
commit | b04a7a86e1d903a37091486764d0dfe09372d663 (patch) | |
tree | 35c74cc921eb641858269c30c2add4e436d97ec8 /bootloader | |
parent | a27f2b8683204e337b142124979592ee1cd0d6f9 (diff) | |
download | rockbox-b04a7a86e1d903a37091486764d0dfe09372d663.tar.gz rockbox-b04a7a86e1d903a37091486764d0dfe09372d663.zip |
Make the Nano2G bootloader actually function as a bootloader. The resulting bootloader-ipodnano2g.ipod file needs to be encrypted on a target using the crypt_firmware plugin to create bootloader-ipodnano2g.ipodx, which can then be written to the firmware partition using the ipodpatcher patch at FS#10609. Dual-booting doesn't work yet - only Rockbox can be run.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23084 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'bootloader')
-rw-r--r-- | bootloader/SOURCES | 7 | ||||
-rw-r--r-- | bootloader/ipodnano2g.c | 137 |
2 files changed, 107 insertions, 37 deletions
diff --git a/bootloader/SOURCES b/bootloader/SOURCES index f297f18fba..a512064ffd 100644 --- a/bootloader/SOURCES +++ b/bootloader/SOURCES | |||
@@ -1,6 +1,8 @@ | |||
1 | common.c | 1 | common.c |
2 | 2 | ||
3 | #if defined(IPOD_ARCH) | 3 | #if defined(IPOD_NANO2G) |
4 | ipodnano2g.c | ||
5 | #elif defined(IPOD_ARCH) | ||
4 | ipod.c | 6 | ipod.c |
5 | #elif defined(GIGABEAT_F) | 7 | #elif defined(GIGABEAT_F) |
6 | gigabeat.c | 8 | gigabeat.c |
@@ -55,7 +57,4 @@ show_logo.c | |||
55 | #elif defined(LYRE_PROTO1) | 57 | #elif defined(LYRE_PROTO1) |
56 | lyre_proto1.c | 58 | lyre_proto1.c |
57 | show_logo.c | 59 | show_logo.c |
58 | #elif defined(IPOD_NANO2G) | ||
59 | ipodnano2g.c | ||
60 | show_logo.c | ||
61 | #endif | 60 | #endif |
diff --git a/bootloader/ipodnano2g.c b/bootloader/ipodnano2g.c index f6bfe148ac..f05829eb6d 100644 --- a/bootloader/ipodnano2g.c +++ b/bootloader/ipodnano2g.c | |||
@@ -45,56 +45,127 @@ | |||
45 | #include "file.h" | 45 | #include "file.h" |
46 | #include "common.h" | 46 | #include "common.h" |
47 | 47 | ||
48 | char version[] = APPSVERSION; | 48 | /* Safety measure - maximum allowed firmware image size. |
49 | The largest known current (October 2009) firmware is about 6.2MB so | ||
50 | we set this to 8MB. | ||
51 | */ | ||
52 | #define MAX_LOADSIZE (8*1024*1024) | ||
53 | |||
54 | /* The buffer to load the firmware into */ | ||
55 | unsigned char *loadbuffer = (unsigned char *)0x08000000; | ||
49 | 56 | ||
50 | /* Show the Rockbox logo - in show_logo.c */ | 57 | /* Bootloader version */ |
51 | extern int show_logo(void); | 58 | char version[] = APPSVERSION; |
52 | 59 | ||
53 | extern int line; | 60 | extern int line; |
54 | 61 | ||
62 | void fatal_error(void) | ||
63 | { | ||
64 | extern int line; | ||
65 | bool holdstatus=false; | ||
66 | |||
67 | /* System font is 6 pixels wide */ | ||
68 | printf("Hold MENU+SELECT to"); | ||
69 | printf("reboot then SELECT+PLAY"); | ||
70 | printf("for disk mode"); | ||
71 | lcd_update(); | ||
72 | |||
73 | while (1) { | ||
74 | if (button_hold() != holdstatus) { | ||
75 | if (button_hold()) { | ||
76 | holdstatus=true; | ||
77 | lcd_puts(0, line, "Hold switch on!"); | ||
78 | } else { | ||
79 | holdstatus=false; | ||
80 | lcd_puts(0, line, " "); | ||
81 | } | ||
82 | lcd_update(); | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | |||
55 | void main(void) | 87 | void main(void) |
56 | { | 88 | { |
57 | int i; | 89 | int i; |
90 | int btn; | ||
91 | int rc; | ||
92 | bool button_was_held; | ||
93 | |||
94 | /* Check the button hold status as soon as possible - to | ||
95 | give the user maximum chance to turn it on in order to | ||
96 | reset the settings in rockbox. */ | ||
97 | button_was_held = button_hold(); | ||
58 | 98 | ||
59 | system_init(); | 99 | system_init(); |
60 | i2c_init(); | ||
61 | kernel_init(); | 100 | kernel_init(); |
62 | 101 | ||
102 | i2c_init(); | ||
103 | |||
63 | enable_irq(); | 104 | enable_irq(); |
64 | 105 | ||
106 | backlight_init(); /* Turns on the backlight */ | ||
107 | |||
65 | lcd_init(); | 108 | lcd_init(); |
109 | font_init(); | ||
110 | |||
111 | lcd_set_foreground(LCD_WHITE); | ||
112 | lcd_set_background(LCD_BLACK); | ||
113 | lcd_clear_display(); | ||
114 | |||
115 | // button_init(); | ||
116 | |||
117 | btn=0; /* TODO */ | ||
66 | 118 | ||
67 | _backlight_init(); | 119 | /* Enable bootloader messages */ |
68 | 120 | if (btn==BUTTON_RIGHT) | |
69 | lcd_puts_scroll(0,0,"+++ this is a very very long line to test scrolling. ---"); | 121 | verbose = true; |
70 | verbose = 0; | 122 | |
71 | i = 0; | 123 | lcd_setfont(FONT_SYSFIXED); |
72 | while (!button_hold()) { | 124 | |
73 | line = 1; | 125 | printf("Rockbox boot loader"); |
74 | 126 | printf("Version: %s", version); | |
75 | printf("i=%d",i++); | 127 | |
76 | printf("TBCNT: %08x",TBCNT); | 128 | i = storage_init(); |
77 | printf("GPIO 0: %08x",PDAT0); | 129 | |
78 | printf("GPIO 1: %08x",PDAT1); | 130 | if (i != 0) { |
79 | printf("GPIO 2: %08x",PDAT2); | 131 | printf("ATA error: %d", i); |
80 | printf("GPIO 3: %08x",PDAT3); | 132 | fatal_error(); |
81 | printf("GPIO 4: %08x",PDAT4); | ||
82 | printf("GPIO 5: %08x",PDAT5); | ||
83 | printf("GPIO 6: %08x",PDAT6); | ||
84 | printf("GPIO 7: %08x",PDAT7); | ||
85 | printf("GPIO 10: %08x",PDAT10); | ||
86 | printf("GPIO 11: %08x",PDAT11); | ||
87 | printf("GPIO 13: %08x",PDAT13); | ||
88 | printf("GPIO 14: %08x",PDAT14); | ||
89 | |||
90 | lcd_update(); | ||
91 | } | 133 | } |
92 | 134 | ||
93 | disable_irq(); | 135 | disk_init(); |
136 | rc = disk_mount_all(); | ||
137 | if (rc<=0) | ||
138 | { | ||
139 | printf("No partition found"); | ||
140 | fatal_error(); | ||
141 | } | ||
142 | |||
143 | if (button_was_held || (btn==BUTTON_MENU)) { | ||
144 | /* If either the hold switch was on, or the Menu button was held, then | ||
145 | try the Apple firmware */ | ||
94 | 146 | ||
95 | /* Branch back to iBugger entry point */ | 147 | printf("Loading original firmware..."); |
96 | asm volatile("ldr pc, =0x08640568"); | 148 | |
149 | /* TODO */ | ||
150 | fatal_error(); | ||
151 | } else { | ||
152 | printf("Loading Rockbox..."); | ||
153 | rc=load_firmware(loadbuffer, BOOTFILE, MAX_LOADSIZE); | ||
154 | |||
155 | if (rc != EOK) { | ||
156 | printf("Error!"); | ||
157 | printf("Can't load " BOOTFILE ": "); | ||
158 | printf(strerror(rc)); | ||
159 | fatal_error(); | ||
160 | } | ||
161 | |||
162 | printf("Rockbox loaded."); | ||
163 | } | ||
164 | |||
165 | /* If we get here, we have a new firmware image at 0x08000000, run it */ | ||
166 | |||
167 | disable_irq(); | ||
97 | 168 | ||
98 | /* We never reach here */ | 169 | /* Branch to start of DRAM */ |
99 | while(1); | 170 | asm volatile("ldr pc, =0x08000000"); |
100 | } | 171 | } |