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 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
39 #include "adc-target.h"
40 #include "backlight.h"
41 #include "backlight-target.h"
47 #if defined(COWON_D2) || defined(IAUDIO_7) && defined(TCCBOOT)
52 # if defined(COWON_D2) || defined(IAUDIO_7)
53 # include "pcf50606.h"
55 # define LOAD_ADDRESS 0x20000000 /* DRAM_START */
58 char version
[] = APPSVERSION
;
62 #define MAX_LOAD_SIZE (8*1024*1024) /* Arbitrary, but plenty. */
64 /* The following function is just test/development code */
66 void show_debug_screen(void)
71 bool do_power_off
= false;
73 /*lcd_puts_scroll(0,0,"this is a very long line to test scrolling");*/
74 while(!do_power_off
) {
77 button
= button_get(false);
79 /* Power-off if POWER button has been held for a time
80 This loop is currently running at about 100 iterations/second
82 if (button
& POWEROFF_BUTTON
) {
84 if (power_count
> 100)
90 if (button
& BUTTON_SELECT
){
97 /*printf("Btn: 0x%08x",button);
98 printf("Tick: %d",current_tick);
99 printf("GPIOA: 0x%08x",GPIOA);
100 printf("GPIOB: 0x%08x",GPIOB);
101 printf("GPIOC: 0x%08x",GPIOC);
102 printf("GPIOD: 0x%08x",GPIOD);
103 printf("GPIOE: 0x%08x",GPIOE);*/
107 for (i
= 1; i
<4; i
++)
109 printf("ADC%d: 0x%04x",i
,adc_read(i
));
113 printf("Count: %d",count
);
125 printf("(NOT) POWERED OFF");
129 #else /* !CPU_TCC77X */
130 void show_debug_screen(void)
135 bool do_power_off
= false;
136 #ifdef HAVE_BUTTON_DATA
140 while(!do_power_off
) {
142 printf("Hello World!");
144 #ifdef HAVE_BUTTON_DATA
145 button
= button_read_device(&data
);
147 button
= button_read_device();
150 /* Power-off if POWER button has been held for a long time
151 This loop is currently running at about 100 iterations/second
153 if (button
& POWEROFF_BUTTON
) {
155 if (power_count
> 200)
161 printf("Btn: 0x%08x",button
);
164 printf("Count: %d",count
);
174 printf("(NOT) POWERED OFF");
183 unsigned char* loadbuffer
= (unsigned char*)LOAD_ADDRESS
;
189 /* The D2 doesn't enable threading or interrupts */
200 lcd_setfont(FONT_SYSFIXED
);
204 /* Only load the firmware if TCCBOOT is defined - this ensures SDRAM_START is
205 available for loading the firmware. Otherwise display the debug screen. */
207 printf("Rockbox boot loader");
208 printf("Version %s", version
);
219 rc
= disk_mount_all();
225 rc
= load_firmware(loadbuffer
, BOOTFILE
, MAX_LOAD_SIZE
);
233 int(*kernel_entry
)(void);
235 kernel_entry
= (void*) loadbuffer
;
245 /* These functions are present in the firmware library, but we reimplement
246 them here because the originals do a lot more than we want */
247 void usb_acknowledge(void)
251 void usb_wait_for_disconnect(void)