1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 by Dave Chapman
12 * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
14 * All files in this archive are subject to the GNU General Public License.
15 * See the file COPYING in the source tree root for full license agreement.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
37 #include "adc-target.h"
38 #include "backlight.h"
39 #include "backlight-target.h"
47 #define LOAD_ADDRESS 0x20000000 /* DRAM_START */
50 char version
[] = APPSVERSION
;
54 #define MAX_LOAD_SIZE (8*1024*1024) /* Arbitrary, but plenty. */
56 /* The following function is just test/development code */
58 void show_debug_screen(void)
63 bool do_power_off
= false;
65 /*lcd_puts_scroll(0,0,"this is a very long line to test scrolling");*/
66 while(!do_power_off
) {
69 button
= button_get(false);
71 /* Power-off if POWER button has been held for a long time
72 This loop is currently running at about 100 iterations/second
74 if (button
& POWEROFF_BUTTON
) {
76 if (power_count
> 200)
82 if (button
& BUTTON_SELECT
){
89 /*printf("Btn: 0x%08x",button);
90 printf("Tick: %d",current_tick);
91 printf("GPIOA: 0x%08x",GPIOA);
92 printf("GPIOB: 0x%08x",GPIOB);
93 printf("GPIOC: 0x%08x",GPIOC);
94 printf("GPIOD: 0x%08x",GPIOD);
95 printf("GPIOE: 0x%08x",GPIOE);*/
101 printf("ADC%d: 0x%04x",i
,adc_read(i
));
105 printf("Count: %d",count
);
117 printf("(NOT) POWERED OFF");
121 #else /* !CPU_TCC77X */
122 void show_debug_screen(void)
127 bool do_power_off
= false;
128 #ifdef HAVE_BUTTON_DATA
132 while(!do_power_off
) {
134 printf("Hello World!");
136 #ifdef HAVE_BUTTON_DATA
137 button
= button_read_device(&data
);
139 button
= button_read_device();
142 /* Power-off if POWER button has been held for a long time
143 This loop is currently running at about 100 iterations/second
145 if (button
& POWEROFF_BUTTON
) {
147 if (power_count
> 200)
153 printf("Btn: 0x%08x",button
);
156 printf("Count: %d",count
);
166 printf("(NOT) POWERED OFF");
173 #if defined(COWON_D2) && defined(TCCBOOT)
175 unsigned char* loadbuffer
= (unsigned char*)LOAD_ADDRESS
;
181 /* The D2 doesn't enable threading or interrupts */
192 lcd_setfont(FONT_SYSFIXED
);
196 /* Only load the firmware if TCCBOOT is defined - this ensures SDRAM_START is
197 available for loading the firmware. Otherwise display the debug screen. */
198 #if defined(COWON_D2) && defined(TCCBOOT)
199 printf("Rockbox boot loader");
200 printf("Version %s", version
);
211 rc
= disk_mount_all();
217 rc
= load_firmware(loadbuffer
, BOOTFILE
, MAX_LOAD_SIZE
);
225 int(*kernel_entry
)(void);
227 kernel_entry
= (void*) loadbuffer
;
237 /* These functions are present in the firmware library, but we reimplement
238 them here because the originals do a lot more than we want */
239 void usb_acknowledge(void)
243 void usb_wait_for_disconnect(void)