diff options
Diffstat (limited to 'bootloader')
-rw-r--r-- | bootloader/ondavx747.c | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/bootloader/ondavx747.c b/bootloader/ondavx747.c index 496363c4b1..0cae73c174 100644 --- a/bootloader/ondavx747.c +++ b/bootloader/ondavx747.c | |||
@@ -83,8 +83,6 @@ static void usb_mode(void) | |||
83 | } | 83 | } |
84 | } | 84 | } |
85 | } | 85 | } |
86 | |||
87 | reset_screen(); | ||
88 | } | 86 | } |
89 | 87 | ||
90 | static int boot_of(void) | 88 | static int boot_of(void) |
@@ -92,6 +90,11 @@ static int boot_of(void) | |||
92 | int fd, rc, len, i, checksum = 0; | 90 | int fd, rc, len, i, checksum = 0; |
93 | void (*kernel_entry)(int, void*, void*); | 91 | void (*kernel_entry)(int, void*, void*); |
94 | 92 | ||
93 | printf("Mounting disk..."); | ||
94 | rc = disk_mount_all(); | ||
95 | if (rc <= 0) | ||
96 | error(EDISK,rc); | ||
97 | |||
95 | /* TODO: get this from the NAND flash instead of SD */ | 98 | /* TODO: get this from the NAND flash instead of SD */ |
96 | fd = open("/ccpmp.bin", O_RDONLY); | 99 | fd = open("/ccpmp.bin", O_RDONLY); |
97 | if(fd < 0) | 100 | if(fd < 0) |
@@ -140,7 +143,12 @@ static int boot_rockbox(void) | |||
140 | int rc; | 143 | int rc; |
141 | void (*kernel_entry)(void); | 144 | void (*kernel_entry)(void); |
142 | 145 | ||
143 | printf("Loading firmware"); | 146 | printf("Mounting disk..."); |
147 | rc = disk_mount_all(); | ||
148 | if (rc <= 0) | ||
149 | error(EDISK,rc); | ||
150 | |||
151 | printf("Loading firmware..."); | ||
144 | rc = load_firmware((unsigned char *)CONFIG_SDRAM_START, BOOTFILE, 0x400000); | 152 | rc = load_firmware((unsigned char *)CONFIG_SDRAM_START, BOOTFILE, 0x400000); |
145 | if(rc < 0) | 153 | if(rc < 0) |
146 | return rc; | 154 | return rc; |
@@ -157,6 +165,20 @@ static int boot_rockbox(void) | |||
157 | } | 165 | } |
158 | } | 166 | } |
159 | 167 | ||
168 | static void reset_configuration(void) | ||
169 | { | ||
170 | int rc; | ||
171 | |||
172 | rc = disk_mount_all(); | ||
173 | if (rc <= 0) | ||
174 | error(EDISK,rc); | ||
175 | |||
176 | if(rename(ROCKBOX_DIR "/config.cfg", ROCKBOX_DIR "/config.old") == 0) | ||
177 | show_splash(HZ/2, "Configuration reset successfully!"); | ||
178 | else | ||
179 | show_splash(HZ/2, "Couldn't reset configuration!"); | ||
180 | } | ||
181 | |||
160 | #define RECT_X (LCD_WIDTH/8) | 182 | #define RECT_X (LCD_WIDTH/8) |
161 | #define RECT_Y(i) (LCD_HEIGHT/20 + LCD_HEIGHT/10*i + RECT_HEIGHT*i) | 183 | #define RECT_Y(i) (LCD_HEIGHT/20 + LCD_HEIGHT/10*i + RECT_HEIGHT*i) |
162 | #define RECT_WIDTH (LCD_WIDTH*3/4) | 184 | #define RECT_WIDTH (LCD_WIDTH*3/4) |
@@ -165,10 +187,11 @@ static int boot_rockbox(void) | |||
165 | #define TEXT_Y(i) (RECT_Y(i) + RECT_HEIGHT/2 - SYSFONT_HEIGHT/2) | 187 | #define TEXT_Y(i) (RECT_Y(i) + RECT_HEIGHT/2 - SYSFONT_HEIGHT/2) |
166 | static int boot_menu(void) | 188 | static int boot_menu(void) |
167 | { | 189 | { |
168 | const char* strings[] = {"Boot Rockbox", "Boot OF", "USB mode"}; | 190 | const char* strings[] = {"Boot Rockbox", "Boot OF", "USB mode", "Reset Rockbox configuration"}; |
169 | int button, touch; | 191 | int button, touch; |
170 | unsigned int i; | 192 | unsigned int i; |
171 | 193 | ||
194 | verbose = true; | ||
172 | adc_init(); | 195 | adc_init(); |
173 | 196 | ||
174 | redraw: | 197 | redraw: |
@@ -201,12 +224,19 @@ redraw: | |||
201 | switch(found) | 224 | switch(found) |
202 | { | 225 | { |
203 | case 0: | 226 | case 0: |
204 | return boot_rockbox(); | 227 | reset_screen(); |
228 | boot_rockbox(); | ||
229 | break; | ||
205 | case 1: | 230 | case 1: |
206 | return boot_of(); | 231 | reset_screen(); |
232 | boot_of(); | ||
233 | break; | ||
207 | case 2: | 234 | case 2: |
208 | usb_mode(); | 235 | usb_mode(); |
209 | break; | 236 | break; |
237 | case 3: | ||
238 | reset_configuration(); | ||
239 | break; | ||
210 | } | 240 | } |
211 | 241 | ||
212 | if(found != -1) | 242 | if(found != -1) |
@@ -237,6 +267,9 @@ int main(void) | |||
237 | if(rc) | 267 | if(rc) |
238 | error(EATA, rc); | 268 | error(EATA, rc); |
239 | 269 | ||
270 | /* Don't mount the disks yet, there could be file system/partition errors | ||
271 | which are fixable in USB mode */ | ||
272 | |||
240 | #ifdef HAVE_TOUCHSCREEN | 273 | #ifdef HAVE_TOUCHSCREEN |
241 | rc = button_read_device(&dummy); | 274 | rc = button_read_device(&dummy); |
242 | #else | 275 | #else |
@@ -249,6 +282,9 @@ int main(void) | |||
249 | #ifdef BUTTON_VOL_UP | 282 | #ifdef BUTTON_VOL_UP |
250 | if(rc & BUTTON_VOL_UP || | 283 | if(rc & BUTTON_VOL_UP || |
251 | #endif | 284 | #endif |
285 | #ifdef BUTTON_POWER | ||
286 | rc & BUTTON_POWER || | ||
287 | #endif | ||
252 | 0) | 288 | 0) |
253 | rc = boot_menu(); | 289 | rc = boot_menu(); |
254 | 290 | ||
@@ -257,10 +293,6 @@ int main(void) | |||
257 | printf(MODEL_NAME" Rockbox Bootloader"); | 293 | printf(MODEL_NAME" Rockbox Bootloader"); |
258 | printf("Version "APPSVERSION); | 294 | printf("Version "APPSVERSION); |
259 | 295 | ||
260 | rc = disk_mount_all(); | ||
261 | if (rc <= 0) | ||
262 | error(EDISK,rc); | ||
263 | |||
264 | #ifdef HAS_BUTTON_HOLD | 296 | #ifdef HAS_BUTTON_HOLD |
265 | if(button_hold()) | 297 | if(button_hold()) |
266 | rc = boot_of(); | 298 | rc = boot_of(); |