From 0d24df8b952c105cf8e532ff48b636bc81945938 Mon Sep 17 00:00:00 2001 From: Torne Wuff Date: Tue, 13 Apr 2010 22:17:42 +0000 Subject: [PATCH] FS#11199: ipod bootloader: reboot to disk mode on cable insert, following a fatal error If the ipod bootloader dies with a fatal error it prompts you to press buttons to reset and enter disk mode. With this change it now also polls for USB/firewire insertion and if the cable is detected, it reboots to disk mode directly for you, avoiding user problems with rebooting correctly by hand. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25643 a1c6a512-1295-4272-9138-f99709370657 --- bootloader/ipod.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/bootloader/ipod.c b/bootloader/ipod.c index e5538b280c..ee555793d0 100644 --- a/bootloader/ipod.c +++ b/bootloader/ipod.c @@ -43,6 +43,7 @@ #include "file.h" #include "common.h" #include "hwcompat.h" +#include "usb.h" #define XSC(X) #X #define SC(X) XSC(X) @@ -58,12 +59,6 @@ unsigned char *loadbuffer = (unsigned char *)DRAM_START; /* Bootloader version */ char version[] = APPSVERSION; -#define BUTTON_LEFT 1 -#define BUTTON_MENU 2 -#define BUTTON_RIGHT 3 -#define BUTTON_PLAY 4 -#define BUTTON_HOLD 5 - #if CONFIG_KEYPAD == IPOD_4G_PAD && !defined(IPOD_MINI) /* check if number of seconds has past */ int timer_check(int clock_start, unsigned int usecs) @@ -193,19 +188,22 @@ void fatal_error(void) /* System font is 6 pixels wide */ #if defined(IPOD_1G2G) || defined(IPOD_3G) - printf("Hold MENU+PLAY to"); - printf("reboot then REW+FF"); - printf("for disk mode"); + printf("Insert Firewire cable, or"); + printf("hold MENU+PLAY to reboot"); + printf("then REW+FF for disk mode"); #elif LCD_WIDTH >= (30*6) - printf("Hold MENU+SELECT to reboot"); + printf("Insert USB cable, or"); + printf("hold MENU+SELECT to reboot"); printf("then SELECT+PLAY for disk mode"); #else - printf("Hold MENU+SELECT to"); + printf("Insert USB cable, or"); + printf("hold MENU+SELECT to"); printf("reboot then SELECT+PLAY"); printf("for disk mode"); #endif lcd_update(); + usb_init(); while (1) { if (button_hold() != holdstatus) { if (button_hold()) { @@ -217,6 +215,18 @@ void fatal_error(void) } lcd_update(); } + if (usb_detect() == USB_INSERTED) { + ata_sleepnow(); /* Immediately spindown the disk. */ + sleep(HZ*2); +#if CONFIG_CPU == PP5020 + memcpy((void *)0x40017f00, "diskmode\0\0hotstuff\0\0\1", 21); +#elif CONFIG_CPU == PP5022 + memcpy((void *)0x4001ff00, "diskmode\0\0hotstuff\0\0\1", 21); +#elif CONFIG_CPU == PP5002 + memcpy((void *)0x40017f00, "diskmodehotstuff\1", 17); +#endif /* CONFIG_CPU */ + system_reboot(); /* Reboot */ + } udelay(100000); /* 100ms */ }