Nano2G bootloader - fix dual-booting the Apple firmware.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23139 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dave Chapman 2009-10-12 19:46:45 +00:00
parent 48658eec41
commit a70c7bf862
3 changed files with 15 additions and 11 deletions

View file

@ -51,8 +51,8 @@
*/ */
#define MAX_LOADSIZE (8*1024*1024) #define MAX_LOADSIZE (8*1024*1024)
/* The buffer to load the firmware into */ /* The buffer to load the firmware into - use an uncached alias of 0x08000000 */
unsigned char *loadbuffer = (unsigned char *)0x08000000; unsigned char *loadbuffer = (unsigned char *)0x48000000;
/* Bootloader version */ /* Bootloader version */
char version[] = APPSVERSION; char version[] = APPSVERSION;
@ -229,11 +229,9 @@ void main(void)
if (button_was_held || (btn==BUTTON_MENU)) { if (button_was_held || (btn==BUTTON_MENU)) {
/* If either the hold switch was on, or the Menu button was held, then /* If either the hold switch was on, or the Menu button was held, then
try the Apple firmware */ try the Apple firmware */
verbose = true;
printf("Loading original firmware..."); printf("Loading original firmware...");
if ((rc = readfw("DNANkbso", (void*)0x08000000, &size)) < 0) { if ((rc = readfw("DNANkbso", loadbuffer, &size)) < 0) {
printf("readfw error %d",rc); printf("readfw error %d",rc);
fatal_error(); fatal_error();
} }
@ -241,7 +239,7 @@ void main(void)
/* Now we need to decrypt it */ /* Now we need to decrypt it */
printf("Decrypting %d bytes...",size); printf("Decrypting %d bytes...",size);
aes_decrypt((void*)0x08000000, size); aes_decrypt(loadbuffer, size);
} else { } else {
printf("Loading Rockbox..."); printf("Loading Rockbox...");
rc=load_firmware(loadbuffer, BOOTFILE, MAX_LOADSIZE); rc=load_firmware(loadbuffer, BOOTFILE, MAX_LOADSIZE);
@ -265,8 +263,15 @@ void main(void)
/* Remap the bootrom back to zero - that's how the NOR bootloader leaves /* Remap the bootrom back to zero - that's how the NOR bootloader leaves
it. it.
*/ */
// This won't work, as we are running from IRAM mapped to 0x0... MIUCON &= ~1;
//MIUCON &= ~1;
/* Disable caches and protection unit */
asm volatile(
"mrc 15, 0, r0, c1, c0, 0 \n"
"bic r0, r0, #0x1000 \n"
"bic r0, r0, #0x5 \n"
"mcr 15, 0, r0, c1, c0, 0 \n"
);
/* Branch to start of DRAM */ /* Branch to start of DRAM */
asm volatile("ldr pc, =0x08000000"); asm volatile("ldr pc, =0x08000000");

View file

@ -12,11 +12,10 @@ STARTUP(target/arm/s5l8700/crt0.o)
#define DRAMORIG 0x08000000 #define DRAMORIG 0x08000000
#define DRAMSIZE (MEMORYSIZE * 0x100000) #define DRAMSIZE (MEMORYSIZE * 0x100000)
#define IRAMORIG 0x22000000
#if CONFIG_CPU==S5L8701 #if CONFIG_CPU==S5L8701
#define IRAMORIG 0x0
#define IRAMSIZE 176K #define IRAMSIZE 176K
#else #else
#define IRAMORIG 0x22000000
#define IRAMSIZE 256K #define IRAMSIZE 256K
#endif #endif

View file

@ -91,7 +91,7 @@ newstart2:
#ifdef BOOTLOADER #ifdef BOOTLOADER
/* Relocate ourself to IRAM - we have been loaded to DRAM */ /* Relocate ourself to IRAM - we have been loaded to DRAM */
mov r0, #0x08000000 /* source (DRAM) */ mov r0, #0x08000000 /* source (DRAM) */
mov r1, #0x00000000 /* dest (IRAM) */ mov r1, #0x22000000 /* dest (IRAM) */
ldr r2, =_dataend ldr r2, =_dataend
1: 1:
cmp r2, r1 cmp r2, r1