summaryrefslogtreecommitdiffstats
path: root/bootloader/iriver_h1x0.c
diff options
context:
space:
mode:
authorJames Buren <braewoods+rb@braewoods.net>2020-11-14 14:57:47 +0000
committerWilliam Wilgus <me.theuser@yahoo.com>2020-11-14 23:20:43 +0000
commit7d9ac021b5bac5078778c4b2489d31c9f2892404 (patch)
tree34dbebfaf91d3b57a2fdc582cf727777e9e250d8 /bootloader/iriver_h1x0.c
parent33d42c20de9a66cbfec8b213d19b454794d63900 (diff)
downloadrockbox-7d9ac021b5bac5078778c4b2489d31c9f2892404.tar.gz
rockbox-7d9ac021b5bac5078778c4b2489d31c9f2892404.zip
h1x0/h300: bring the two bootloaders more in sync
The most major change here is the porting of the failsafe boot menu and eeprom settings support from the h1x0 bootloader to the h300 bootloader. This has been successfully tested already and indeed works about the same as it does on the h1x0 bootloader. The other major change is the addition of new code to both bootloaders that will retry the flash boot function after exitting disk mode. It still falls back to booting from disk if this either fails or is not configured to boot from flash. There were also various other modifications to bring the two closer in sync so there are fewer differences. Change-Id: I17a5724e03225b57e9d0071387294aa6cd025178
Diffstat (limited to 'bootloader/iriver_h1x0.c')
-rw-r--r--bootloader/iriver_h1x0.c59
1 files changed, 20 insertions, 39 deletions
diff --git a/bootloader/iriver_h1x0.c b/bootloader/iriver_h1x0.c
index 168bd29b67..d5a3b887a2 100644
--- a/bootloader/iriver_h1x0.c
+++ b/bootloader/iriver_h1x0.c
@@ -61,9 +61,7 @@
extern int line;
extern int remote_line;
-#ifdef HAVE_EEPROM_SETTINGS
static bool recovery_mode = false;
-#endif
/* Reset the cookie for the crt0 crash check */
inline void __reset_cookie(void)
@@ -96,12 +94,12 @@ void start_firmware(void)
void start_flashed_romimage(void)
{
uint8_t *src = (uint8_t *)FLASH_ROMIMAGE_ENTRY;
- int *reset_vector;
+ uint32_t *reset_vector;
if (!detect_flashed_romimage())
return ;
- reset_vector = (int *)(&src[sizeof(struct flash_header)+4]);
+ reset_vector = (uint32_t *)(&src[sizeof(struct flash_header)+sizeof(uint32_t)]);
asm(" move.w #0x2700,%sr");
__reset_cookie();
@@ -119,7 +117,7 @@ void start_flashed_romimage(void)
void start_flashed_ramimage(void)
{
struct flash_header hdr;
- unsigned char *buf = (unsigned char *)DRAM_START;
+ uint8_t *buf = (uint8_t *)DRAM_START;
uint8_t *src = (uint8_t *)FLASH_RAMIMAGE_ENTRY;
if (!detect_flashed_ramimage())
@@ -141,11 +139,9 @@ void start_flashed_ramimage(void)
void shutdown(void)
{
printf("Shutting down...");
-#ifdef HAVE_EEPROM_SETTINGS
/* Reset the rockbox crash check. */
firmware_settings.bl_version = 0;
eeprom_settings_store();
-#endif
/* We need to gracefully spin down the disk to prevent clicks. */
if (ide_powered())
@@ -185,7 +181,6 @@ void check_battery(void)
}
}
-#ifdef HAVE_EEPROM_SETTINGS
void initialize_eeprom(void)
{
if (detect_original_firmware())
@@ -235,17 +230,17 @@ void try_flashboot(void)
}
}
-static const char *options[] = {
- "Boot from disk",
- "Boot RAM image",
- "Boot ROM image",
- "Shutdown"
-};
-
-#define FAILSAFE_OPTIONS 4
-#define TIMEOUT (15*HZ)
void failsafe_menu(void)
{
+ static const char *options[] =
+ {
+ "Boot from disk",
+ "Boot RAM image",
+ "Boot ROM image",
+ "Shutdown"
+ };
+ const int FAILSAFE_OPTIONS = sizeof(options) / sizeof(*options);
+ const long TIMEOUT = 15 * HZ;
long start_tick = current_tick;
int option = 3;
int button;
@@ -355,7 +350,6 @@ void failsafe_menu(void)
shutdown();
}
-#endif
/* get rid of a nasty humming sound during boot
-> RESET signal */
@@ -427,9 +421,7 @@ void main(void)
coldfire_set_pllcr_audio_bits(DEFAULT_PLLCR_AUDIO_BITS);
enable_irq();
-#ifdef HAVE_EEPROM_SETTINGS
initialize_eeprom();
-#endif
usb_init();
/* A small delay after usb_init is necessary to read the I/O port correctly
@@ -458,19 +450,11 @@ void main(void)
}
/* Power on the hard drive early, to speed up the loading. */
- if (!hold_status
-# ifdef HAVE_EEPROM_SETTINGS
- && !recovery_mode
-# endif
- )
- {
+ if (!hold_status && !recovery_mode)
ide_power_enable(true);
- }
-# ifdef HAVE_EEPROM_SETTINGS
if (!hold_status && (usb_detect() != USB_INSERTED) && !recovery_mode)
try_flashboot();
-# endif
lcd_init();
@@ -500,11 +484,7 @@ void main(void)
/* Don't start if the Hold button is active on the device you
are starting with */
- if ((usb_detect() != USB_INSERTED) && (hold_status
-#ifdef HAVE_EEPROM_SETTINGS
- || recovery_mode
-#endif
- ))
+ if ((usb_detect() != USB_INSERTED) && (hold_status || recovery_mode))
{
if (detect_original_firmware())
{
@@ -512,9 +492,7 @@ void main(void)
shutdown();
}
-#ifdef HAVE_EEPROM_SETTINGS
failsafe_menu();
-#endif
}
/* Holding REC while starting runs the original firmware */
@@ -537,13 +515,12 @@ void main(void)
lcd_remote_puts(0, 3, msg);
lcd_remote_update();
-#ifdef HAVE_EEPROM_SETTINGS
if (firmware_settings.initialized)
{
firmware_settings.disk_clean = false;
eeprom_settings_store();
}
-#endif
+
ide_power_enable(true);
storage_enable(false);
sleep(HZ/20);
@@ -570,6 +547,11 @@ void main(void)
lcd_update();
}
+ /* boot from flash if that is the default */
+ try_flashboot();
+ if (recovery_mode)
+ printf("Falling back to boot from disk");
+
rc = storage_init();
if(rc)
{
@@ -580,7 +562,6 @@ void main(void)
while(!(button_get(true) & BUTTON_REL));
}
-
filesystem_init();
rc = disk_mount_all();