diff --git a/apps/filetree.c b/apps/filetree.c index c828f176ba..a3754ea190 100644 --- a/apps/filetree.c +++ b/apps/filetree.c @@ -39,8 +39,10 @@ #include "rolo.h" #include "sprintf.h" +#ifndef SIMULATOR static int boot_size = 0; static int boot_cluster; +#endif extern bool boot_changed; int ft_build_playlist(struct tree_context* c, int start_index) @@ -241,6 +243,7 @@ int ft_load(struct tree_context* c, const char* tempdir) if ( !(dptr->attr & ATTR_DIRECTORY) && (len > 4) ) dptr->attr |= filetype_get_attr(entry->d_name); +#ifndef SIMULATOR /* memorize/compare details about the boot file */ if ((c->currdir[1] == 0) && !strcasecmp(entry->d_name, BOOTFILE)) { if (boot_size) { @@ -251,7 +254,8 @@ int ft_load(struct tree_context* c, const char* tempdir) boot_size = entry->size; boot_cluster = entry->startcluster; } - +#endif + /* filter out non-visible files */ if (!(dptr->attr & ATTR_DIRECTORY) && ( (*c->dirfilter == SHOW_PLAYLIST && diff --git a/apps/tree.c b/apps/tree.c index b7ad02a4aa..69bc8bc244 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -81,11 +81,7 @@ const struct filetype filetypes[] = { #endif { ".bmark",TREE_ATTR_BMARK, Bookmark, VOICE_EXT_BMARK }, #ifndef SIMULATOR -#ifdef HAVE_LCD_BITMAP - { ".ajz", TREE_ATTR_MOD, Mod_Ajz, VOICE_EXT_AJZ }, -#else - { ".mod", TREE_ATTR_MOD, Mod_Ajz, VOICE_EXT_AJZ }, -#endif + { BOOTFILE_EXT, TREE_ATTR_MOD, Mod_Ajz, VOICE_EXT_AJZ }, #endif /* #ifndef SIMULATOR */ }; diff --git a/apps/tree.h b/apps/tree.h index 239d0042f7..c3ab60c243 100644 --- a/apps/tree.h +++ b/apps/tree.h @@ -113,12 +113,6 @@ #endif -#ifdef HAVE_LCD_BITMAP -#define BOOTFILE "ajbrec.ajz" -#else -#define BOOTFILE "archos.mod" -#endif - struct entry { short attr; /* FAT attributes + file type flags */ unsigned long time_write; /* Last write time */ 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);