1
0
Fork 0
forked from len0rd/rockbox

Add Rockbox bootloader for H10

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10781 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Barry Wardell 2006-08-28 08:11:32 +00:00
parent 93083e15c6
commit 1920df36d8
7 changed files with 165 additions and 168 deletions

View file

@ -43,33 +43,19 @@
/* Size of the buffer to store the loaded Rockbox/iriver image */ /* Size of the buffer to store the loaded Rockbox/iriver image */
#define MAX_LOADSIZE (5*1024*1024) #define MAX_LOADSIZE (5*1024*1024)
/* This is identical to the function used in the iPod bootloader */ /* A buffer to load the iriver firmware or Rockbox into */
static void memmove16(void *dest, const void *src, unsigned count) unsigned char loadbuffer[MAX_LOADSIZE];
{
struct bufstr {
unsigned _buf[4];
} *d, *s;
if (src >= dest) { char version[] = APPSVERSION;
count = (count + 15) >> 4;
d = (struct bufstr *) dest;
s = (struct bufstr *) src;
while (count--)
*d++ = *s++;
} else {
count = (count + 15) >> 4;
d = (struct bufstr *)(dest + (count <<4));
s = (struct bufstr *)(src + (count <<4));
while (count--)
*--d = *--s;
}
}
#define DRAM_START 0x10000000
int line=0;
/* Load original iriver firmware. This function expects a file called /* Load original iriver firmware. This function expects a file called
"H10_20GC.mi4" in the root directory of the player. It should be decrypted "/System/Original.mi4" on the player. It should be decrypted
and have the header stripped using mi4code. It reads the file in to a memory and have the header stripped using mi4code. It reads the file in to a memory
buffer called buf. The rest of the loading is done in main() buffer called buf. The rest of the loading is done in main() and crt0.S
*/ */
int load_iriver(unsigned char* buf) int load_iriver(unsigned char* buf)
{ {
@ -77,9 +63,13 @@ int load_iriver(unsigned char* buf)
int rc; int rc;
int len; int len;
fd = open("/H10_20GC.mi4", O_RDONLY); fd = open("/System/Original.mi4", O_RDONLY);
len = filesize(fd); len = filesize(fd);
if (len > MAX_LOADSIZE)
return -6;
rc = read(fd, buf, len); rc = read(fd, buf, len);
if(rc < len) if(rc < len)
return -4; return -4;
@ -88,155 +78,158 @@ int load_iriver(unsigned char* buf)
return len; return len;
} }
/* A buffer to load the iriver firmware or Rockbox into */ /* Load Rockbox firmware (rockbox.h10) */
unsigned char loadbuffer[MAX_LOADSIZE]; int load_rockbox(unsigned char* buf)
void main(void)
{ {
/* Attempt to load original iriver firmware. Successfully starts loading the int fd;
iriver firmware but then locks up once the "System Initialising" screen
is displayed.
The iriver firmware was decrypted and the header removed. It was then
appended to the end of bootloader.bin and an mi4 file was created from
the resulting file.
The original firmware starts at 0xd800 in the file and is of length
0x47da00.
The whole file (bootloader.bin + decrypted mi4) are loaded to memory by
the original iriver bootloader on startup. This copies the mi4 part to
the start of DRAM and passes execution to there.
memmove16((void*)DRAMORIG, (void*)(DRAMORIG + 0xd800), 0x47da00);
asm volatile(
"mov r0, #" SC(DRAMORIG) "\n"
"mov pc, r0 \n"
);
*/
/*int i;
int rc; int rc;
int btn; int len;
int fd;*/ unsigned long chksum;
char buffer[24]; char model[5];
unsigned long sum;
int i;
char str[80];
snprintf(buffer, 24, "Hello World"); fd = open("/.rockbox/" BOOTFILE, O_RDONLY);
lcd_puts(0, 0, buffer); if(fd < 0)
{
fd = open("/" BOOTFILE, O_RDONLY);
if(fd < 0)
return -1;
}
len = filesize(fd) - 8;
snprintf(str, sizeof(str), "Length: %x", len);
lcd_puts(0, line++ ,str);
lcd_update(); lcd_update();
/*i=ata_init(); if (len > MAX_LOADSIZE)
return -6;
lseek(fd, FIRMWARE_OFFSET_FILE_CRC, SEEK_SET);
rc = read(fd, &chksum, 4);
chksum=betoh32(chksum); /* Rockbox checksums are big-endian */
if(rc < 4)
return -2;
snprintf(str, sizeof(str), "Checksum: %x", chksum);
lcd_puts(0, line++ ,str);
lcd_update();
rc = read(fd, model, 4);
if(rc < 4)
return -3;
model[4] = 0;
snprintf(str, sizeof(str), "Model name: %s", model);
lcd_puts(0, line++ ,str);
lcd_update();
lseek(fd, FIRMWARE_OFFSET_FILE_DATA, SEEK_SET);
rc = read(fd, buf, len);
if(rc < len)
return -4;
close(fd);
sum = MODEL_NUMBER;
for(i = 0;i < len;i++) {
sum += buf[i];
}
snprintf(str, sizeof(str), "Sum: %x", sum);
lcd_puts(0, line++ ,str);
lcd_update();
if(sum != chksum)
return -5;
return len;
}
void* main(void)
{
char buf[256];
int i;
int rc;
unsigned short* identify_info;
struct partinfo* pinfo;
system_init();
kernel_init();
lcd_init();
font_init();
line=0;
lcd_setfont(FONT_SYSFIXED);
lcd_puts(0, line++, "Rockbox boot loader");
snprintf(buf, sizeof(buf), "Version: 20%s", version);
lcd_puts(0, line++, buf);
snprintf(buf, sizeof(buf), "iriver H10");
lcd_puts(0, line++, buf);
lcd_update();
i=ata_init();
if (i==0) {
identify_info=ata_get_identify();
/* Show model */
for (i=0; i < 20; i++) {
((unsigned short*)buf)[i]=htobe16(identify_info[i+27]);
}
buf[40]=0;
for (i=39; i && buf[i]==' '; i--) {
buf[i]=0;
}
lcd_puts(0, line++, buf);
lcd_update();
} else {
snprintf(buf, sizeof(buf), "ATA: %d", i);
lcd_puts(0, line++, buf);
lcd_update();
}
disk_init(); disk_init();
rc = disk_mount_all();*/ rc = disk_mount_all();
if (rc<=0)
{
lcd_puts(0, line++, "No partition found");
lcd_update();
}
/* Load original iriver firmware. Uses load_iriver(buf) to load the pinfo = disk_partinfo(0);
decrypted mi4 file from disk to DRAM. This then copies that part of DRAM snprintf(buf, sizeof(buf), "Partition 0: 0x%02x %ld MB",
to the start of DRAM and passes pinfo->type, pinfo->size / 2048);
execution to there. lcd_puts(0, line++, buf);
lcd_update();
i=button_read_device();
if(i==BUTTON_LEFT)
{
lcd_puts(0, line, "Loading iriver firmware...");
lcd_update();
rc=load_iriver(loadbuffer); rc=load_iriver(loadbuffer);
memcpy((void*)DRAMORIG,loadbuffer,rc); } else {
asm volatile( lcd_puts(0, line, "Loading Rockbox...");
"mov r0, #" SC(DRAMORIG) "\n" lcd_update();
"mov pc, r0 \n" rc=load_rockbox(loadbuffer);
);*/
/* This assumes that /test.txt exists */
/*fd=open("/test.txt",O_RDWR);*/
/*
for(i=0;i<100;i++){
btn = button_read_device();
switch(btn){
case BUTTON_LEFT:
snprintf(buffer, sizeof(buffer), "Left");
write(fd,buffer,sizeof(buffer));
break;
case BUTTON_RIGHT:
break;
case BUTTON_REW:
break;
case BUTTON_FF:
break;
case BUTTON_PLAY:
break;
default:
break;
} }
if (rc < 0) {
snprintf(buf, sizeof(buf), "Rockbox error: %d",rc);
lcd_puts(0, line++, buf);
lcd_update();
} }
*/
memcpy((void*)DRAM_START,loadbuffer,rc);
return (void*)DRAM_START;
/* Investigate gpio
unsigned int gpio_a, gpio_b, gpio_c, gpio_d;
unsigned int gpio_e, gpio_f, gpio_g, gpio_h;
unsigned int gpio_i, gpio_j, gpio_k, gpio_l;
gpio_a = GPIOA_INPUT_VAL;
gpio_b = GPIOB_INPUT_VAL;
gpio_c = GPIOC_INPUT_VAL;
gpio_g = GPIOG_INPUT_VAL;
gpio_h = GPIOH_INPUT_VAL;
gpio_i = GPIOI_INPUT_VAL;
snprintf(buffer,sizeof(buffer),"GPIO_A: %02x GPIO_G: %02x\n",gpio_a,gpio_g);
write(fd,buffer,sizeof(buffer));
snprintf(buffer,sizeof(buffer),"GPIO_B: %02x GPIO_H: %02x\n",gpio_b,gpio_h);
write(fd,buffer,sizeof(buffer));
snprintf(buffer,sizeof(buffer),"GPIO_C: %02x GPIO_I: %02x\n",gpio_c,gpio_i);
write(fd,buffer,sizeof(buffer));
gpio_d = GPIOD_INPUT_VAL;
gpio_e = GPIOE_INPUT_VAL;
gpio_f = GPIOF_INPUT_VAL;
gpio_j = GPIOJ_INPUT_VAL;
gpio_k = GPIOK_INPUT_VAL;
gpio_l = GPIOL_INPUT_VAL;
snprintf(buffer,sizeof(buffer),"GPIO_D: %02x GPIO_J: %02x\n",gpio_d,gpio_j);
write(fd,buffer,sizeof(buffer));
snprintf(buffer,sizeof(buffer),"GPIO_E: %02x GPIO_K: %02x\n",gpio_e,gpio_k);
write(fd,buffer,sizeof(buffer));
snprintf(buffer,sizeof(buffer),"GPIO_F: %02x GPIO_L: %02x\n",gpio_f,gpio_l);
write(fd,buffer,sizeof(buffer));
*/
/* Detect the scroller being touched
int j = 0;
for(j=0;j<1000;j++){
if(gpio_c!=0xF7){
snprintf(buffer, sizeof(buffer), "GPIO_C: %02x\n", gpio_c);
write(fd,buffer,sizeof(buffer));
}
if(gpio_d!=0xDD){
snprintf(buffer, sizeof(buffer), "GPIO_D: %02x\n", gpio_d);
write(fd,buffer,sizeof(buffer));
}
}*/
/* Apparently necessary for the data to be actually written to file */
/*fsync(fd);
udelay(1000000);*/
/* This causes the device to shut off instantly
GPIOF_OUTPUT_VAL = 0;
*/
/*close(fd);*/
udelay(100000000);
} }
/* These functions are present in the firmware library, but we reimplement /* These functions are present in the firmware library, but we reimplement

View file

@ -5,7 +5,7 @@
#define TARGET_TREE /* this target is using the target tree system */ #define TARGET_TREE /* this target is using the target tree system */
/* For Rolo and boot loader */ /* For Rolo and boot loader */
#define MODEL_NUMBER 11 #define MODEL_NUMBER 13
/* define this if you have recording possibility */ /* define this if you have recording possibility */
/*#define HAVE_RECORDING 1*/ /* TODO: add support for this */ /*#define HAVE_RECORDING 1*/ /* TODO: add support for this */

View file

@ -5,7 +5,7 @@
#define TARGET_TREE /* this target is using the target tree system */ #define TARGET_TREE /* this target is using the target tree system */
/* For Rolo and boot loader */ /* For Rolo and boot loader */
#define MODEL_NUMBER 13 #define MODEL_NUMBER 14
/* define this if you have recording possibility */ /* define this if you have recording possibility */
/*#define HAVE_RECORDING 1*/ /* TODO: add support for this */ /*#define HAVE_RECORDING 1*/ /* TODO: add support for this */

View file

@ -31,8 +31,8 @@
#include "buffer.h" #include "buffer.h"
#if (CONFIG_CPU != TCC730) && !defined(IRIVER_IFP7XX_SERIES) && \ #if (CONFIG_CPU != TCC730) && !defined(IRIVER_IFP7XX_SERIES) && \
(CONFIG_CPU != PP5002) (CONFIG_CPU != PP5002) && !defined(IRIVER_H10) && !defined(IRIVER_H10_5GB)
/* FIX: this doesn't work on Gmini, iFP or 3rd Gen ipods yet */ /* FIX: this doesn't work on Gmini, iFP, 3rd Gen ipods, or H10 yet */
#define IRQ0_EDGE_TRIGGER 0x80 #define IRQ0_EDGE_TRIGGER 0x80

12
tools/configure vendored
View file

@ -893,10 +893,10 @@ toolsdir='\$(ROOTDIR)/tools'
target="-DIRIVER_H10" target="-DIRIVER_H10"
memory=32 # always memory=32 # always
arm7tdmicc arm7tdmicc
tool="$rootdir/tools/mkmi4.sh h10" tool="$rootdir/tools/scramble -add=h10"
bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
bmp2rb_native="$rootdir/tools/bmp2rb -f 5" bmp2rb_native="$rootdir/tools/bmp2rb -f 5"
output="H10_20GC.mi4" output="rockbox.h10"
appextra="recorder:gui" appextra="recorder:gui"
archosrom="" archosrom=""
flash="" flash=""
@ -904,7 +904,7 @@ toolsdir='\$(ROOTDIR)/tools'
codecs="libmad liba52 libffmpegFLAC libTremor libwavpack dumb libmusepack libalac libfaad libm4a" codecs="libmad liba52 libffmpegFLAC libTremor libwavpack dumb libmusepack libalac libfaad libm4a"
# toolset is the tools within the tools directory that we build for # toolset is the tools within the tools directory that we build for
# this particular target. # this particular target.
toolset=$genericbitmaptools toolset="$genericbitmaptools scramble"
# architecture, manufacturer and model for the target-tree build # architecture, manufacturer and model for the target-tree build
t_cpu="arm" t_cpu="arm"
t_manufacturer="iriver" t_manufacturer="iriver"
@ -939,10 +939,10 @@ toolsdir='\$(ROOTDIR)/tools'
target="-DIRIVER_H10_5GB" target="-DIRIVER_H10_5GB"
memory=32 # always memory=32 # always
arm7tdmicc arm7tdmicc
tool="$rootdir/tools/mkmi4.sh h10_5gb" tool="$rootdir/tools/scramble -add=h10_5gb"
bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
bmp2rb_native="$rootdir/tools/bmp2rb -f 5" bmp2rb_native="$rootdir/tools/bmp2rb -f 5"
output="H10.mi4" output="rockbox.h10"
appextra="recorder:gui" appextra="recorder:gui"
archosrom="" archosrom=""
flash="" flash=""
@ -950,7 +950,7 @@ toolsdir='\$(ROOTDIR)/tools'
codecs="libmad liba52 libffmpegFLAC libTremor libwavpack dumb libmusepack libalac libfaad libm4a" codecs="libmad liba52 libffmpegFLAC libTremor libwavpack dumb libmusepack libalac libfaad libm4a"
# toolset is the tools within the tools directory that we build for # toolset is the tools within the tools directory that we build for
# this particular target. # this particular target.
toolset=$genericbitmaptools toolset="$genericbitmaptools scramble"
# architecture, manufacturer and model for the target-tree build # architecture, manufacturer and model for the target-tree build
t_cpu="arm" t_cpu="arm"
t_manufacturer="iriver" t_manufacturer="iriver"

View file

@ -48,7 +48,7 @@ findtool(){
} }
help () { help () {
echo "Usage: mi4fix.sh <e200/h10> <input> <output>" echo "Usage: mi4fix.sh <e200/h10/h10_5gb> <input> <output>"
exit exit
} }

View file

@ -84,7 +84,7 @@ void usage(void)
"\t-ipod5g ipod firmware partition format (5th Gen - aka Video)\n" "\t-ipod5g ipod firmware partition format (5th Gen - aka Video)\n"
"\t-add=X Rockbox generic \"add-up\" checksum format\n" "\t-add=X Rockbox generic \"add-up\" checksum format\n"
"\t (X values: h100, h120, h140, h300, ipco, nano, ipvd\n" "\t (X values: h100, h120, h140, h300, ipco, nano, ipvd\n"
"\t ip3g, ip4g, mini, x5)\n" "\t ip3g, ip4g, mini, x5, h10, h10_5gb)\n"
"\nNo option results in Archos standard player/recorder format.\n"); "\nNo option results in Archos standard player/recorder format.\n");
exit(1); exit(1);
@ -196,6 +196,10 @@ int main (int argc, char** argv)
modelnum = 10; modelnum = 10;
else if(!strcmp(&argv[1][5], "mn2g")) else if(!strcmp(&argv[1][5], "mn2g"))
modelnum = 11; modelnum = 11;
else if(!strcmp(&argv[1][5], "h10"))
modelnum = 13;
else if(!strcmp(&argv[1][5], "h10_5gb"))
modelnum = 14;
else { else {
fprintf(stderr, "unsupported model: %s\n", &argv[1][5]); fprintf(stderr, "unsupported model: %s\n", &argv[1][5]);
return 2; return 2;