From b04a7a86e1d903a37091486764d0dfe09372d663 Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Sun, 11 Oct 2009 01:37:12 +0000 Subject: Make the Nano2G bootloader actually function as a bootloader. The resulting bootloader-ipodnano2g.ipod file needs to be encrypted on a target using the crypt_firmware plugin to create bootloader-ipodnano2g.ipodx, which can then be written to the firmware partition using the ipodpatcher patch at FS#10609. Dual-booting doesn't work yet - only Rockbox can be run. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23084 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/s5l8700/boot.lds | 12 ++++++++---- firmware/target/arm/s5l8700/crt0.S | 21 ++++++++++++++++++++- firmware/target/arm/s5l8700/ipodnano2g/ftl-target.h | 5 +++++ 3 files changed, 33 insertions(+), 5 deletions(-) (limited to 'firmware/target/arm') diff --git a/firmware/target/arm/s5l8700/boot.lds b/firmware/target/arm/s5l8700/boot.lds index 2dea0ee4ea..637a3a29c1 100644 --- a/firmware/target/arm/s5l8700/boot.lds +++ b/firmware/target/arm/s5l8700/boot.lds @@ -9,14 +9,14 @@ OUTPUT_FORMAT(elf32-bigarm) OUTPUT_ARCH(arm) STARTUP(target/arm/s5l8700/crt0.o) -/* DRAMORIG is in fact 0x08000000 but remapped to 0x0 */ #define DRAMORIG 0x08000000 #define DRAMSIZE (MEMORYSIZE * 0x100000) -#define IRAMORIG 0x22000000 #if CONFIG_CPU==S5L8701 +#define IRAMORIG 0x0 #define IRAMSIZE 176K #else +#define IRAMORIG 0x22000000 #define IRAMSIZE 256K #endif @@ -91,7 +91,11 @@ SECTIONS _fiqstackend = .; } > IRAM - .bss : { + /* The bss section is too large for IRAM - we just move it 12MB into the + DRAM */ + + . = DRAMORIG; + .bss . + (12*1024*1024): { _edata = .; *(.bss*); *(.ibss); @@ -99,5 +103,5 @@ SECTIONS *(COMMON); . = ALIGN(0x4); _end = .; - } > IRAM + } > DRAM } diff --git a/firmware/target/arm/s5l8700/crt0.S b/firmware/target/arm/s5l8700/crt0.S index 4a89f3da39..aa2923cb29 100644 --- a/firmware/target/arm/s5l8700/crt0.S +++ b/firmware/target/arm/s5l8700/crt0.S @@ -27,7 +27,11 @@ .global _newstart /* Exception vectors */ start: +#if CONFIG_CPU==S5L8701 && defined(BOOTLOADER) + b newstart2 +#else b _newstart +#endif ldr pc, =undef_instr_handler ldr pc, =software_int_handler ldr pc, =prefetch_abort_handler @@ -88,7 +92,22 @@ newstart2: orr r2, r2, #1 bic r2, r2, #0x10000 str r2, [r1] // remap iram to address 0x0 -#endif + +#ifdef BOOTLOADER + /* Relocate ourself to IRAM - we have been loaded to DRAM */ + mov r0, #0x08000000 /* source (DRAM) */ + mov r1, #0x00000000 /* dest (IRAM) */ + ldr r2, =_dataend +1: + cmp r2, r1 + ldrhi r3, [r0], #4 + strhi r3, [r1], #4 + bhi 1b + + ldr pc, =start_loc /* jump to the relocated start_loc: */ +start_loc: +#endif /* BOOTLOADER */ +#endif /* CONFIG_CPU==S5L8701 */ ldr r1, =0x3c500000 // CLKCON ldr r0, =0x00800080 diff --git a/firmware/target/arm/s5l8700/ipodnano2g/ftl-target.h b/firmware/target/arm/s5l8700/ipodnano2g/ftl-target.h index f214964551..0c36db9799 100644 --- a/firmware/target/arm/s5l8700/ipodnano2g/ftl-target.h +++ b/firmware/target/arm/s5l8700/ipodnano2g/ftl-target.h @@ -25,6 +25,11 @@ #include "config.h" #include "inttypes.h" +#ifdef BOOTLOADER +/* Bootloaders don't need write access */ +#define FTL_READONLY +#endif + uint32_t ftl_init(void); uint32_t ftl_read(uint32_t sector, uint32_t count, void* buffer); uint32_t ftl_write(uint32_t sector, uint32_t count, const void* buffer); -- cgit v1.2.3