Last commit for the flash bootloader. The bootloader build works properly either flashed or unflashed.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19098 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Karl Kurbjun 2008-11-12 05:11:18 +00:00
parent d922f31a09
commit f32336e4a5
2 changed files with 85 additions and 8 deletions

View file

@ -44,11 +44,29 @@
#include "rbunicode.h" #include "rbunicode.h"
#include "usb.h" #include "usb.h"
#include "mmu-arm.h" #include "mmu-arm.h"
#include "rtc.h"
#include <stdarg.h> #include <stdarg.h>
char version[] = APPSVERSION; char version[] = APPSVERSION;
void shutdown(void)
{
/* We need to gracefully spin down the disk to prevent clicks. */
if (ide_powered())
{
/* Make sure ATA has been initialized. */
ata_init();
/* And put the disk into sleep immediately. */
ata_sleepnow();
}
_backlight_off();
power_off();
}
void main(void) void main(void)
{ {
unsigned char* loadbuffer; unsigned char* loadbuffer;
@ -56,14 +74,72 @@ void main(void)
int rc; int rc;
int(*kernel_entry)(void); int(*kernel_entry)(void);
power_init();
system_init(); system_init();
lcd_init(); lcd_init();
backlight_init(); backlight_init();
button_init();
font_init(); font_init();
kernel_init(); /* Need the kernel to sleep */
adc_init();
lcd_setfont(FONT_SYSFIXED); lcd_setfont(FONT_SYSFIXED);
/* These checks should only run if the bootloader is flashed */
if(GSTATUS3&0x02)
{
GSTATUS3&=0xFFFFFFFD;
if(!(GPGDAT&BUTTON_POWER) && charger_inserted())
{
while(!(GPGDAT&BUTTON_POWER) && charger_inserted())
{
char msg[20];
if(charging_state())
{
snprintf(msg,sizeof(msg),"Charging");
}
else
{
snprintf(msg,sizeof(msg),"Charge Complete");
}
reset_screen();
lcd_putsxy( (LCD_WIDTH - (SYSFONT_WIDTH * strlen(msg))) / 2,
(LCD_HEIGHT - SYSFONT_HEIGHT) / 2, msg);
lcd_update();
#if defined(HAVE_RTC_ALARM)
/* Check if the alarm went off while charging */
if(rtc_check_alarm_flag())
{
GSTATUS3=1; /* Normally this is set in crt0.s */
break;
}
#endif
}
if(!(GPGDAT&BUTTON_POWER)
#if defined(HAVE_RTC_ALARM)
&& !GSTATUS3
#endif
)
{
shutdown();
}
}
if(button_hold())
{
const char msg[] = "HOLD is enabled";
reset_screen();
lcd_putsxy( (LCD_WIDTH - (SYSFONT_WIDTH * strlen(msg))) / 2,
(LCD_HEIGHT - SYSFONT_HEIGHT) / 2, msg);
lcd_update();
sleep(2*HZ);
shutdown();
}
}
power_init();
usb_init(); usb_init();
/* Enter USB mode without USB thread */ /* Enter USB mode without USB thread */
@ -88,9 +164,7 @@ void main(void)
lcd_update(); lcd_update();
} }
kernel_init(); reset_screen();
adc_init();
button_init();
/* Show debug messages if button is pressed */ /* Show debug messages if button is pressed */
if(button_read_device()) if(button_read_device())

View file

@ -105,10 +105,13 @@ start:
ldr r1, [r2] ldr r1, [r2]
ands r1, r1, #0x40000000 ands r1, r1, #0x40000000
/* Woke up with the alarm - store a flag in GSTATUS3 */ /* Store a flag in GSTATUS3 to indicate that the bootloader is flashed */
ldrne r2, =0x560000b8 ldr r2, =0x560000b8
movne r1, #0x01 mov r1, #0x02
strne r1, [r2]
/* Woke up with the alarm? - store a flag in GSTATUS3 */
orrne r1, r1, #0x01
str r1, [r2]
bne poweron bne poweron
/* Set GPG up to read power and menu status */ /* Set GPG up to read power and menu status */