diff options
| author | Miika Pekkarinen <miipekk@ihme.org> | 2007-01-12 18:34:00 +0000 |
|---|---|---|
| committer | Miika Pekkarinen <miipekk@ihme.org> | 2007-01-12 18:34:00 +0000 |
| commit | 0ea4d3197ed7e56f39c630741cb69152ac9e41de (patch) | |
| tree | bc29ccef30da139df3e928fd3b8ff3801407b58c /firmware | |
| parent | 12ef310466937551dbedb2165769d7832b11156c (diff) | |
| download | rockbox-0ea4d3197ed7e56f39c630741cb69152ac9e41de.zip rockbox-0ea4d3197ed7e56f39c630741cb69152ac9e41de.tar.gz rockbox-0ea4d3197ed7e56f39c630741cb69152ac9e41de.tar.bz2 rockbox-0ea4d3197ed7e56f39c630741cb69152ac9e41de.tar.xz | |
Prepare core support for the iriver bootloader supporting ROM images
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11991 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
| -rw-r--r-- | firmware/eeprom_settings.c | 8 | ||||
| -rw-r--r-- | firmware/export/config-h120.h | 5 | ||||
| -rw-r--r-- | firmware/export/eeprom_settings.h | 13 | ||||
| -rw-r--r-- | firmware/export/system.h | 4 | ||||
| -rw-r--r-- | firmware/system.c | 35 | ||||
| -rw-r--r-- | firmware/target/coldfire/crt0.S | 58 |
6 files changed, 96 insertions, 27 deletions
diff --git a/firmware/eeprom_settings.c b/firmware/eeprom_settings.c index ad2c9c8..f3be2ec 100644 --- a/firmware/eeprom_settings.c +++ b/firmware/eeprom_settings.c @@ -36,7 +36,7 @@ static bool reset_config(void) #else firmware_settings.version = EEPROM_SETTINGS_VERSION; firmware_settings.initialized = true; - firmware_settings.boot_disk = false; + firmware_settings.bootmethod = BOOT_RECOVERY; firmware_settings.bl_version = 0; #endif @@ -51,7 +51,7 @@ bool eeprom_settings_init(void) eeprom_24cxx_init(); /* Check if player has been flashed. */ - if (!detect_flashed_rockbox()) + if (detect_original_firmware()) { memset(&firmware_settings, 0, sizeof(struct eeprom_settings)); firmware_settings.initialized = false; @@ -61,7 +61,7 @@ bool eeprom_settings_init(void) ret = eeprom_24cxx_read(0, &firmware_settings, sizeof(struct eeprom_settings)); - + if (ret < 0) { memset(&firmware_settings, 0, sizeof(struct eeprom_settings)); @@ -101,7 +101,7 @@ bool eeprom_settings_store(void) int ret; uint32_t sum; - if (!firmware_settings.initialized || !detect_flashed_rockbox()) + if (!firmware_settings.initialized || detect_original_firmware()) { logf("Rockbox in flash is required"); return false; diff --git a/firmware/export/config-h120.h b/firmware/export/config-h120.h index ee3d702..9bfb958 100644 --- a/firmware/export/config-h120.h +++ b/firmware/export/config-h120.h @@ -139,8 +139,9 @@ #define BOOTFILE "rockbox." BOOTFILE_EXT #define BOOTLOADER_ENTRYPOINT 0x001F0000 -#define FLASH_ENTRYPOINT 0x00001000 -#define FLASH_MAGIC 0xfbfbfbf1 +#define FLASH_RAMIMAGE_ENTRY 0x00001000 +#define FLASH_ROMIMAGE_ENTRY 0x00100000 +#define FLASH_MAGIC 0xfbfbfbf2 /* Define this if there is an EEPROM chip */ #define HAVE_EEPROM diff --git a/firmware/export/eeprom_settings.h b/firmware/export/eeprom_settings.h index 367e7b2..aade86b 100644 --- a/firmware/export/eeprom_settings.h +++ b/firmware/export/eeprom_settings.h @@ -23,17 +23,26 @@ #include <stdbool.h> #include "inttypes.h" -#define EEPROM_SETTINGS_VERSION 0x24c01001 +#define EEPROM_SETTINGS_VERSION 0x24c01002 #define EEPROM_SETTINGS_BL_MINVER 7 +enum boot_methods { + BOOT_DISK = 0, + BOOT_RAM, + BOOT_ROM, + BOOT_RECOVERY, +}; + struct eeprom_settings { long version; /* Settings version number */ bool initialized; /* Is eeprom_settings ready to be used */ bool disk_clean; /* Is disk intact from last reboot */ - bool boot_disk; /* Load firmware from disk (default=FLASH) */ + uint8_t bootmethod; /* The default boot method. */ uint8_t bl_version; /* Installed bootloader version */ + long reserved; /* A few reserved bits for the future. */ + /* This must be the last entry */ uint32_t checksum; /* Checksum of this structure */ }; diff --git a/firmware/export/system.h b/firmware/export/system.h index 9492287..86bbefb 100644 --- a/firmware/export/system.h +++ b/firmware/export/system.h @@ -52,7 +52,9 @@ struct flash_header { char version[32]; }; -bool detect_flashed_rockbox(void); +bool detect_flashed_romimage(void); +bool detect_flashed_ramimage(void); +bool detect_original_firmware(void); #ifdef HAVE_ADJUSTABLE_CPU_FREQ #define FREQ cpu_frequency diff --git a/firmware/system.c b/firmware/system.c index 4ab47fa..c9ce086 100644 --- a/firmware/system.c +++ b/firmware/system.c @@ -82,31 +82,44 @@ void cpu_idle_mode(bool on_off) #endif /* HAVE_ADJUSTABLE_CPU_FREQ */ -bool detect_flashed_rockbox(void) -{ #ifdef HAVE_FLASHED_ROCKBOX - struct flash_header hdr; - uint8_t *src = (uint8_t *)FLASH_ENTRYPOINT; - +static bool detect_flash_header(uint8_t *addr) +{ #ifndef BOOTLOADER int oldmode = system_memory_guard(MEMGUARD_NONE); #endif - - memcpy(&hdr, src, sizeof(struct flash_header)); - + struct flash_header hdr; + memcpy(&hdr, addr, sizeof(struct flash_header)); #ifndef BOOTLOADER system_memory_guard(oldmode); #endif + return hdr.magic == FLASH_MAGIC; +} +#endif - if (hdr.magic != FLASH_MAGIC) - return false; +bool detect_flashed_romimage(void) +{ +#ifdef HAVE_FLASHED_ROCKBOX + return detect_flash_header((uint8_t *)FLASH_ROMIMAGE_ENTRY); +#else + return false; +#endif /* HAVE_FLASHED_ROCKBOX */ +} - return true; +bool detect_flashed_ramimage(void) +{ +#ifdef HAVE_FLASHED_ROCKBOX + return detect_flash_header((uint8_t *)FLASH_RAMIMAGE_ENTRY); #else return false; #endif /* HAVE_FLASHED_ROCKBOX */ } +bool detect_original_firmware(void) +{ + return !(detect_flashed_ramimage() || detect_flashed_romimage()); +} + #if CONFIG_CPU == SH7034 #include "led.h" #include "system.h" diff --git a/firmware/target/coldfire/crt0.S b/firmware/target/coldfire/crt0.S index 7fc389c..c177cd4 100644 --- a/firmware/target/coldfire/crt0.S +++ b/firmware/target/coldfire/crt0.S @@ -89,28 +89,40 @@ start: #endif #ifdef BOOTLOADER - /* Check if original firmware is still present */ + /* Check if we have a Rockbox ROM image */ + lea 0x00100000,%a2 + move.l (%a2),%d0 + move.l #FLASH_MAGIC,%d1 + cmp.l %d0,%d1 + beq.b .imagefound + + /* Check for RAM image */ lea 0x00001000,%a2 move.l (%a2),%d0 - move.l #0xfbfbfbf1,%d1 + move.l #FLASH_MAGIC,%d1 cmp.l %d0,%d1 - beq.b .ignorecookie + beq.b .imagefound - /* The cookie is not reset. This must mean that the boot loader - has crashed. Let's start the original firmware immediately. */ + /* Not either ROM or RAM image was found, so original firmware + should be still present. */ + + /* Check if the cookie is present. */ lea 0x10017ffc,%a2 move.l (%a2),%d0 move.l #0xc0015a17,%d1 cmp.l %d0,%d1 bne.b .nocookie - /* Clear the cookie again */ + + /* The cookie is not reset. This must mean that the boot loader + has crashed. Let's start the original firmware immediately. */ + lea 0x10017ffc,%a2 clr.l (%a2) jmp 8 .nocookie: /* Set the cookie */ move.l %d1,(%a2) -.ignorecookie: +.imagefound: /* Set up the DRAM controller. The refresh is based on the 11.2896MHz clock (5.6448MHz bus frequency). We haven't yet started the PLL */ @@ -168,6 +180,38 @@ start: move.l %d0,0x31000800 /* A12=1 means CASL=1 (a0 is not connected) */ /* DACR0[IMRS] gets deactivated by the SDRAM controller */ + + /* Check if we have a Rockbox ROM image. For RAM image only cookie is + not set at all. But we could support also RAM images loading. */ + lea 0x00100000,%a2 + move.l (%a2),%d0 + move.l #FLASH_MAGIC,%d1 + cmp.l %d0,%d1 + bne.b .noromimage + + /* Check again if the cookie is present. */ + lea 0x10017ffc,%a2 + move.l (%a2),%d0 + move.l #0xc0015a17,%d1 + cmp.l %d0,%d1 + bne.b .nocookie2 + + /* We have found Rockbox in ROM! + Clear the cookie and load the ROM image */ + lea 0x10017ffc,%a2 + clr.l (%a2) + lea 0x00100028+4,%a2 + move.l (%a2),%sp + lea 0x00100028+8,%a2 + move.l (%a2),%d0 + move.l %d0,%a2 + jmp (%a2) + +.nocookie2: + /* Set the cookie */ + move.l %d1,(%a2) +.noromimage: + #endif /* BOOTLOADER */ /* Invalicate cache */ |