1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2008 by Rafaël Carré
12 * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
13 * and the ipodlinux bootloader by Daniel Palffy and Bernard Leach
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ****************************************************************************/
30 #ifdef USE_ROCKBOX_USB
33 #endif /* USE_ROCKBOX_USB */
34 #include "backlight.h"
35 #include "button-target.h"
44 void main(void) __attribute__((noreturn
));
47 unsigned char* loadbuffer
;
49 void(*kernel_entry
)(void);
63 int btn
= button_read_device();
65 #if !defined(SANSA_FUZE) && !defined(SANSA_CLIP) && !defined(SANSA_CLIPV2) \
66 && !defined(SANSA_CLIPPLUS)
71 printf("Hold switch on");
72 printf("Shutting down...");
78 /* Enable bootloader messages if any button is pressed */
89 #ifdef USE_ROCKBOX_USB
91 usb_start_monitoring();
92 if(usb_detect() == USB_INSERTED
)
94 const char msg
[] = "Bootloader USB mode";
96 lcd_putsxy( (LCD_WIDTH
- (SYSFONT_WIDTH
* sizeof(msg
))) / 2,
97 (LCD_HEIGHT
- SYSFONT_HEIGHT
) / 2, msg
);
100 while(usb_detect() == USB_INSERTED
)
106 #endif /* USE_ROCKBOX_USB */
108 if(!disk_init(IF_MV(0)))
109 panicf("disk_init failed!");
111 ret
= disk_mount_all();
116 printf("Loading firmware");
118 loadbuffer
= (unsigned char*)DRAM_ORIG
; /* DRAM */
119 buffer_size
= (int)(loadbuffer
+ (DRAM_SIZE
) - TTB_SIZE
);
121 ret
= load_firmware(loadbuffer
, BOOTFILE
, buffer_size
);
123 error(EBOOTFILE
, ret
);
127 kernel_entry
= (void*) loadbuffer
;
128 cpucache_invalidate();
131 printf("ERR: Failed to boot");