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 #include "backlight.h"
31 #include "button-target.h"
40 void main(void) __attribute__((naked
, noreturn
));
43 unsigned char* loadbuffer
;
45 void(*kernel_entry
)(void);
59 int btn
= button_read_device();
61 #if !defined(SANSA_FUZE) && !defined(SANSA_CLIP)
66 printf("Hold switch on");
67 printf("Shutting down...");
73 /* Enable bootloader messages if any button is pressed */
84 if(!disk_init(IF_MV(0)))
85 panicf("disk_init failed!");
87 ret
= disk_mount_all();
92 printf("Loading firmware");
94 loadbuffer
= (unsigned char*)DRAM_ORIG
; /* DRAM */
95 buffer_size
= (int)(loadbuffer
+ (DRAM_SIZE
) - TTB_SIZE
);
97 ret
= load_firmware(loadbuffer
, BOOTFILE
, buffer_size
);
99 error(EBOOTFILE
, ret
);
101 disable_irq(); /* disable irq until we have copied the new vectors */
105 kernel_entry
= (void*) loadbuffer
;
108 printf("ERR: Failed to boot");