summaryrefslogtreecommitdiff
path: root/bootloader/ipodnano2g.c
diff options
context:
space:
mode:
Diffstat (limited to 'bootloader/ipodnano2g.c')
-rw-r--r--bootloader/ipodnano2g.c137
1 files changed, 104 insertions, 33 deletions
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
48char 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 */
55unsigned char *loadbuffer = (unsigned char *)0x08000000;
49 56
50/* Show the Rockbox logo - in show_logo.c */ 57/* Bootloader version */
51extern int show_logo(void); 58char version[] = APPSVERSION;
52 59
53extern int line; 60extern int line;
54 61
62void 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
55void main(void) 87void 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}