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)
51 /* Address to load main Rockbox image to */
52 #define LOAD_ADDRESS 0x20000000 /* DRAM_START */
54 char version
[] = APPSVERSION
;
58 #define MAX_LOAD_SIZE (8*1024*1024) /* Arbitrary, but plenty. */
60 /* The following function is just test/development code */
62 void show_debug_screen(void)
67 bool do_power_off
= false;
69 lcd_puts_scroll(0,0,"this is a very long line to test scrolling");
70 while (!do_power_off
) {
72 button
= button_get(false);
74 /* Power-off if POWER button has been held for a time
75 This loop is currently running at about 100 iterations/second
77 if (button
& POWEROFF_BUTTON
) {
79 if (power_count
> 100)
85 if (button
& BUTTON_SELECT
){
92 printf("Btn: 0x%08x",button
);
94 printf("Tick: %d",current_tick
);
95 printf("GPIOA: 0x%08x",GPIOA
);
96 printf("GPIOB: 0x%08x",GPIOB
);
97 printf("GPIOC: 0x%08x",GPIOC
);
98 printf("GPIOD: 0x%08x",GPIOD
);
99 printf("GPIOE: 0x%08x",GPIOE
);
104 for (i
= 0; i
<4; i
++)
106 printf("ADC%d: 0x%04x",i
,adc_read(i
));
110 printf("Count: %d",count
);
122 printf("(NOT) POWERED OFF");
126 #else /* !CPU_TCC77X */
128 void show_debug_screen(void)
133 bool do_power_off
= false;
134 #ifdef HAVE_BUTTON_DATA
138 while(!do_power_off
) {
140 printf("Hello World!");
142 #ifdef HAVE_BUTTON_DATA
143 button
= button_read_device(&data
);
145 button
= button_read_device();
148 /* Power-off if POWER button has been held for a long time
149 This loop is currently running at about 100 iterations/second
151 if (button
& POWEROFF_BUTTON
) {
153 if (power_count
> 200)
159 printf("Btn: 0x%08x",button
);
162 printf("Count: %d",count
);
172 printf("(NOT) POWERED OFF");
181 unsigned char* loadbuffer
= (unsigned char*)LOAD_ADDRESS
;
187 /* The D2 doesn't enable threading or interrupts */
198 lcd_setfont(FONT_SYSFIXED
);
202 /* Only load the firmware if TCCBOOT is defined - this ensures SDRAM_START is
203 available for loading the firmware. Otherwise display the debug screen. */
205 printf("Rockbox boot loader");
206 printf("Version %s", version
);
217 rc
= disk_mount_all();
223 rc
= load_firmware(loadbuffer
, BOOTFILE
, MAX_LOAD_SIZE
);
231 int(*kernel_entry
)(void);
233 kernel_entry
= (void*) loadbuffer
;
243 #ifndef HAVE_USBSTACK
244 /* These functions are present in the firmware library, but we reimplement
245 them here because the originals do a lot more than we want */
246 void usb_acknowledge(void)
250 void usb_wait_for_disconnect(void)