1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2011 by amaury Pouly
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 ****************************************************************************/
29 #include "gcc_extensions.h"
31 #include "backlight.h"
32 #include "button-target.h"
38 #include "system-target.h"
39 #include "fmradio_i2c.h"
43 void main(uint32_t arg
) NORETURN_ATTR
;
44 void main(uint32_t arg
)
46 unsigned char* loadbuffer
;
48 void(*kernel_entry
)(void);
64 //button_debug_screen();
65 printf("arg=%c%c%c%c", arg
>> 24,
66 (arg
>> 16) & 0xff, (arg
>> 8) & 0xff, (arg
& 0xff));
70 error(EATA
, ret
, true);
72 #ifdef HAVE_BOOTLOADER_USB_MODE
74 usb_core_enable_driver(USB_DRIVER_SERIAL
, true);
76 while(!(button_read_device() & BUTTON_POWER
))
79 #endif /* HAVE_BOOTLOADER_USB_MODE */
81 while(!disk_init(IF_MV(0)))
82 panicf("disk_init failed!");
84 while((ret
= disk_mount_all()) <= 0)
86 error(EDISK
, ret
, true);
89 if(button_read_device() & BUTTON_VOL_UP
)
90 printf("Booting from SD card required.");
92 printf("Loading firmware");
94 loadbuffer
= (unsigned char*)DRAM_ORIG
; /* DRAM */
95 buffer_size
= (int)(loadbuffer
+ DRAM_SIZE
- TTB_SIZE
);
97 while((ret
= load_firmware(loadbuffer
, BOOTFILE
, buffer_size
)) < 0)
99 error(EBOOTFILE
, ret
, true);
102 kernel_entry
= (void*) loadbuffer
;
103 //cpucache_invalidate();
106 printf("ERR: Failed to boot");