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 "pinctrl-imx233.h"
39 #include "system-target.h"
40 #include "ssp-imx233.h"
46 void main(void) NORETURN_ATTR
;
49 unsigned char* loadbuffer
;
51 void(*kernel_entry
)(void);
66 //button_debug_screen();
70 usb_start_monitoring();
71 extern int usb_status
;
72 usb_status
= USB_INSERTED
;
73 usb_status_event(USB_POWERED
);
75 printf("USB: Connecting");
79 int button
= button_get_w_tmo(HZ
/25);
81 if(button
== SYS_USB_CONNECTED
)
83 if(button_read_device() & BUTTON_POWER
)
88 printf("USB: Connected");
91 int button
= button_get_w_tmo(HZ
/25);
93 if(button_read_device() & BUTTON_POWER
)
101 error(EATA
, ret
, true);
103 while(!disk_init(IF_MV(0)))
104 panicf("disk_init failed!");
106 while((ret
= disk_mount_all()) <= 0)
108 error(EDISK
, ret
, true);
111 printf("Loading firmware");
113 loadbuffer
= (unsigned char*)DRAM_ORIG
; /* DRAM */
114 buffer_size
= (int)(loadbuffer
+ DRAM_SIZE
- TTB_SIZE
);
116 while((ret
= load_firmware(loadbuffer
, BOOTFILE
, buffer_size
)) < 0)
118 error(EBOOTFILE
, ret
, true);
121 kernel_entry
= (void*) loadbuffer
;
122 //cpucache_invalidate();
125 printf("ERR: Failed to boot");