forked from len0rd/rockbox
xduoox3: Bootloader improvements:
* Explicitly clear the caches prior to launching the binary * Ensure the function that launches the binary is in iram * Re-sequenced some of the subsystem initializations * Fixes for USB mode Change-Id: Ie020b18586b2599edeb88529dd3d7337e33a5a6f
This commit is contained in:
parent
247258b9d2
commit
e07c460eef
1 changed files with 27 additions and 19 deletions
|
|
@ -55,13 +55,18 @@ static void show_splash(int timeout, const char *msg)
|
||||||
sleep(timeout);
|
sleep(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int usb_inited = 0;
|
||||||
|
|
||||||
static void usb_mode(void)
|
static void usb_mode(void)
|
||||||
{
|
{
|
||||||
int button;
|
int button;
|
||||||
|
|
||||||
/* Init USB */
|
/* Init USB, but only once */
|
||||||
|
if (!usb_inited) {
|
||||||
usb_init();
|
usb_init();
|
||||||
usb_start_monitoring();
|
usb_start_monitoring();
|
||||||
|
usb_inited = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Wait for threads to connect */
|
/* Wait for threads to connect */
|
||||||
show_splash(HZ/2, "Waiting for USB");
|
show_splash(HZ/2, "Waiting for USB");
|
||||||
|
|
@ -91,10 +96,20 @@ static void usb_mode(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Jump to loaded binary */
|
||||||
|
void exec(void* addr) __attribute__((noinline, noreturn, section(".icode")));
|
||||||
|
|
||||||
|
void exec(void* addr)
|
||||||
|
{
|
||||||
|
commit_discard_idcache();
|
||||||
|
typedef void(*entry_fn)(void) __attribute__((noreturn));
|
||||||
|
entry_fn fn = (entry_fn)addr;
|
||||||
|
fn();
|
||||||
|
}
|
||||||
|
|
||||||
static int boot_rockbox(void)
|
static int boot_rockbox(void)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
void (*kernel_entry)(void);
|
|
||||||
|
|
||||||
printf("Mounting disk...\n");
|
printf("Mounting disk...\n");
|
||||||
|
|
||||||
|
|
@ -103,7 +118,6 @@ static int boot_rockbox(void)
|
||||||
verbose = true;
|
verbose = true;
|
||||||
#ifdef HAVE_BOOTLOADER_USB_MODE
|
#ifdef HAVE_BOOTLOADER_USB_MODE
|
||||||
error(EDISK, rc, false);
|
error(EDISK, rc, false);
|
||||||
usb_start_monitoring();
|
|
||||||
usb_mode();
|
usb_mode();
|
||||||
#else
|
#else
|
||||||
error(EDISK, rc, true);
|
error(EDISK, rc, true);
|
||||||
|
|
@ -118,11 +132,8 @@ static int boot_rockbox(void)
|
||||||
{
|
{
|
||||||
printf("Starting Rockbox...\n");
|
printf("Starting Rockbox...\n");
|
||||||
adc_close(); /* Disable SADC, seems to fix the re-init Rockbox does */
|
adc_close(); /* Disable SADC, seems to fix the re-init Rockbox does */
|
||||||
|
|
||||||
disable_interrupt();
|
disable_interrupt();
|
||||||
kernel_entry = (void*) CONFIG_SDRAM_START;
|
exec((void*) CONFIG_SDRAM_START);
|
||||||
kernel_entry();
|
|
||||||
|
|
||||||
return 0; /* Shouldn't happen */
|
return 0; /* Shouldn't happen */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -152,13 +163,13 @@ int main(void)
|
||||||
|
|
||||||
serial_puts("\n\nSPL Stage 2\n\n");
|
serial_puts("\n\nSPL Stage 2\n\n");
|
||||||
|
|
||||||
|
system_init();
|
||||||
kernel_init();
|
kernel_init();
|
||||||
|
|
||||||
lcd_init();
|
lcd_init();
|
||||||
font_init();
|
font_init();
|
||||||
lcd_setfont(FONT_SYSFIXED);
|
lcd_setfont(FONT_SYSFIXED);
|
||||||
button_init();
|
|
||||||
backlight_init();
|
backlight_init();
|
||||||
|
|
||||||
show_logo();
|
show_logo();
|
||||||
|
|
||||||
rc = storage_init();
|
rc = storage_init();
|
||||||
|
|
@ -170,23 +181,20 @@ int main(void)
|
||||||
|
|
||||||
filesystem_init();
|
filesystem_init();
|
||||||
|
|
||||||
#ifdef HAVE_BOOTLOADER_USB_MODE
|
/* Don't mount the disks yet, there could be file system/partition errors
|
||||||
button_init_device();
|
which are fixable in USB mode */
|
||||||
int btn = button_read_device();
|
|
||||||
|
|
||||||
usb_init();
|
#ifdef HAVE_BOOTLOADER_USB_MODE
|
||||||
|
button_init();
|
||||||
|
int btn = button_read_device();
|
||||||
|
|
||||||
/* Enter USB mode if USB is plugged and PLAY button is pressed */
|
/* Enter USB mode if USB is plugged and PLAY button is pressed */
|
||||||
if(btn & BUTTON_PLAY) {
|
if(btn & BUTTON_PLAY) {
|
||||||
usb_start_monitoring();
|
|
||||||
if(usb_detect() == USB_INSERTED)
|
if(usb_detect() == USB_INSERTED)
|
||||||
usb_mode();
|
usb_mode();
|
||||||
}
|
}
|
||||||
#endif /* HAVE_BOOTLOADER_USB_MODE */
|
#endif /* HAVE_BOOTLOADER_USB_MODE */
|
||||||
|
|
||||||
/* Don't mount the disks yet, there could be file system/partition errors
|
|
||||||
which are fixable in USB mode */
|
|
||||||
|
|
||||||
reset_screen();
|
reset_screen();
|
||||||
|
|
||||||
printf(MODEL_NAME" Rockbox Bootloader\n");
|
printf(MODEL_NAME" Rockbox Bootloader\n");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue