From bd42d31e5eb1eed61da6c25064de1eed23c7163e Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Thu, 31 Mar 2005 08:47:02 +0000 Subject: RoLo now works on the iRiver git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6238 a1c6a512-1295-4272-9138-f99709370657 --- firmware/app.lds | 2 + firmware/export/config-fmrecorder.h | 3 ++ firmware/export/config-h100.h | 3 ++ firmware/export/config-ondiofm.h | 3 ++ firmware/export/config-ondiosp.h | 3 ++ firmware/export/config-player.h | 3 ++ firmware/export/config-recorder.h | 3 ++ firmware/export/config-recorderv2.h | 3 ++ firmware/rolo.c | 91 ++++++++++++++++++++++++++++++------- firmware/rom.lds | 2 + 10 files changed, 100 insertions(+), 16 deletions(-) (limited to 'firmware') diff --git a/firmware/app.lds b/firmware/app.lds index b79a11094e..a7ca57e54e 100644 --- a/firmware/app.lds +++ b/firmware/app.lds @@ -139,6 +139,8 @@ SECTIONS { .vectors : { + loadaddress = .; + _loadaddress = .; *(.resetvectors); *(.vectors); } > DRAM diff --git a/firmware/export/config-fmrecorder.h b/firmware/export/config-fmrecorder.h index f5e82bbd12..ec410cb02a 100644 --- a/firmware/export/config-fmrecorder.h +++ b/firmware/export/config-fmrecorder.h @@ -78,4 +78,7 @@ #define CONFIG_LCD LCD_SSD1815 +#define BOOTFILE_EXT ".ajz" +#define BOOTFILE "ajbrec" BOOTFILE_EXT + #endif /* SIMULATOR */ diff --git a/firmware/export/config-h100.h b/firmware/export/config-h100.h index 9c7ba6c1d3..d8453a96d1 100644 --- a/firmware/export/config-h100.h +++ b/firmware/export/config-h100.h @@ -56,4 +56,7 @@ /* Define this if you have adjustable CPU frequency */ #define HAVE_ADJUSTABLE_CPU_FREQ +#define BOOTFILE_EXT ".iriver" +#define BOOTFILE "rockbox" BOOTFILE_EXT + #endif diff --git a/firmware/export/config-ondiofm.h b/firmware/export/config-ondiofm.h index 79e7adbe58..cce88e591b 100644 --- a/firmware/export/config-ondiofm.h +++ b/firmware/export/config-ondiofm.h @@ -87,4 +87,7 @@ #define CONFIG_LCD LCD_SSD1815 +#define BOOTFILE_EXT ".ajz" +#define BOOTFILE "ajbrec" BOOTFILE_EXT + #endif /* SIMULATOR */ diff --git a/firmware/export/config-ondiosp.h b/firmware/export/config-ondiosp.h index bda078a792..58cb4085ae 100644 --- a/firmware/export/config-ondiosp.h +++ b/firmware/export/config-ondiosp.h @@ -75,4 +75,7 @@ #define CONFIG_LCD LCD_SSD1815 +#define BOOTFILE_EXT ".ajz" +#define BOOTFILE "ajbrec" BOOTFILE_EXT + #endif /* SIMULATOR */ diff --git a/firmware/export/config-player.h b/firmware/export/config-player.h index 6ca5663563..8b85bfdfae 100644 --- a/firmware/export/config-player.h +++ b/firmware/export/config-player.h @@ -68,4 +68,7 @@ #define CONFIG_LCD LCD_SSD1801 +#define BOOTFILE_EXT ".mod" +#define BOOTFILE "archos" BOOTFILE_EXT + #endif /* SIMULATOR */ diff --git a/firmware/export/config-recorder.h b/firmware/export/config-recorder.h index 4d29b66fa0..a3a354feea 100644 --- a/firmware/export/config-recorder.h +++ b/firmware/export/config-recorder.h @@ -72,4 +72,7 @@ #define CONFIG_LCD LCD_SSD1815 +#define BOOTFILE_EXT ".ajz" +#define BOOTFILE "ajbrec" BOOTFILE_EXT + #endif /* SIMULATOR */ diff --git a/firmware/export/config-recorderv2.h b/firmware/export/config-recorderv2.h index 941946ace0..b9a011802c 100644 --- a/firmware/export/config-recorderv2.h +++ b/firmware/export/config-recorderv2.h @@ -78,4 +78,7 @@ #define CONFIG_LCD LCD_SSD1815 +#define BOOTFILE_EXT ".ajz" +#define BOOTFILE "ajbrec" BOOTFILE_EXT + #endif /* SIMULATOR */ diff --git a/firmware/rolo.c b/firmware/rolo.c index fccc9f38da..ceb70791cf 100644 --- a/firmware/rolo.c +++ b/firmware/rolo.c @@ -29,8 +29,8 @@ #include "string.h" #include "buffer.h" -#if (CONFIG_CPU != MCF5249) && (CONFIG_CPU != TCC730) -/* FIX: this doesn't work on iRiver or Gmini yet */ +#if CONFIG_CPU != TCC730 +/* FIX: this doesn't work on Gmini yet */ #define IRQ0_EDGE_TRIGGER 0x80 @@ -46,11 +46,36 @@ static void rolo_error(const char *text) lcd_stop_scroll(); } +#if CONFIG_CPU == SH7034 /* these are in assembler file "descramble.S" */ extern unsigned short descramble(const unsigned char* source, unsigned char* dest, int length); extern void rolo_restart(const unsigned char* source, unsigned char* dest, int length); +#else +void rolo_restart(const unsigned char* source, unsigned char* dest, + long length) __attribute__ ((section (".icode"))); +void rolo_restart(const unsigned char* source, unsigned char* dest, + long length) +{ + long i; + + for(i = 0;i < length;i++) + *dest++ = *source++; + +#if CONFIG_CPU == MCF5249 + asm volatile (" move.l #0,%d0"); + asm volatile (" move.l #0x30000000,%d0"); + asm volatile (" movec.l %d0,%vbr"); + asm volatile (" move.l 0x30000000,%sp"); + asm volatile (" move.l 0x30000004,%a0"); + asm volatile (" jmp (%a0)"); +#endif +} +#endif + +/* This is assigned in the linker control file */ +extern unsigned long loadaddress; /*************************************************************************** * @@ -61,10 +86,15 @@ extern void rolo_restart(const unsigned char* source, unsigned char* dest, int rolo_load(const char* filename) { int fd; - unsigned long length; - unsigned long file_length; + long length; +#ifdef IRIVER_H100 + int i; + unsigned long checksum,file_checksum; +#else + long file_length; unsigned short checksum,file_checksum; - unsigned char* ramstart = (void*)0x09000000; +#endif + unsigned char* ramstart = (void*)&loadaddress; lcd_clear_display(); lcd_puts(0, 0, "ROLO..."); @@ -79,8 +109,40 @@ int rolo_load(const char* filename) return -1; } + length = filesize(fd) - FIRMWARE_OFFSET_FILE_DATA; + +#if CONFIG_CPU == MCF5249 + /* Read and save checksum */ + lseek(fd, FIRMWARE_OFFSET_FILE_CRC, SEEK_SET); + if (read(fd, &file_checksum, 4) != 4) { + rolo_error("Error Reading checksum"); + return -1; + } + lseek(fd, FIRMWARE_OFFSET_FILE_DATA, SEEK_SET); + + if (read(fd, mp3buf, length) != length) { + rolo_error("Error Reading File"); + return -1; + } + + checksum = 0; + + for(i = 0;i < length;i++) { + checksum += mp3buf[i]; + } + + /* Verify checksum against file header */ + if (checksum != file_checksum) { + rolo_error("Checksum Error"); + return -1; + } + + lcd_puts(0, 1, "Executing "); + lcd_update(); + + set_irq_level(HIGHEST_IRQ_LEVEL); +#else /* Read file length from header and compare to real file length */ - length=lseek(fd,0,SEEK_END)-FIRMWARE_OFFSET_FILE_DATA; lseek(fd, FIRMWARE_OFFSET_FILE_LENGTH, SEEK_SET); if(read(fd, &file_length, 4) != 4) { rolo_error("Error Reading File Length"); @@ -90,7 +152,7 @@ int rolo_load(const char* filename) rolo_error("File length mismatch"); return -1; } - + /* Read and save checksum */ lseek(fd, FIRMWARE_OFFSET_FILE_CRC, SEEK_SET); if (read(fd, &file_checksum, 2) != 2) { @@ -114,9 +176,8 @@ int rolo_load(const char* filename) lcd_update(); checksum = descramble(mp3buf + length, mp3buf, length); - + /* Verify checksum against file header */ - if (checksum != file_checksum) { rolo_error("Checksum Error"); return -1; @@ -125,10 +186,8 @@ int rolo_load(const char* filename) lcd_puts(0, 1, "Executing "); lcd_update(); - /* Disable interrupts */ - asm("mov #15<<4,r6\n" - "ldc r6,sr"); - + set_irq_level(HIGHEST_IRQ_LEVEL); + /* Calling these 2 initialization routines was necessary to get the the origional Archos version of the firmware to load and execute. */ system_init(); /* Initialize system for restart */ @@ -141,12 +200,12 @@ int rolo_load(const char* filename) defined(ARCHOS_FMRECORDER) PAIOR = 0x0FA0; #endif - +#endif rolo_restart(mp3buf, ramstart, length); return 0; /* this is never reached */ } -#else /* (CONFIG_CPU != MCF5249) && (CONFIG_CPU != TCC730) */ +#else /* CONFIG_CPU != TCC730 */ int rolo_load(const char* filename) { /* dummy */ @@ -154,4 +213,4 @@ int rolo_load(const char* filename) return 0; } -#endif /* ! (CONFIG_CPU != MCF5249) && (CONFIG_CPU != TCC730) */ +#endif /* ! CONFIG_CPU != TCC730 */ diff --git a/firmware/rom.lds b/firmware/rom.lds index 749998b637..55346dc122 100644 --- a/firmware/rom.lds +++ b/firmware/rom.lds @@ -47,6 +47,8 @@ SECTIONS .data : AT ( _datacopy ) { + loadaddress = .; + _loadaddress = .; _datastart = .; *(.resetvectors); *(.vectors); -- cgit v1.2.3