From 0be911338126001bd2c78f6779f3a30d9dea342a Mon Sep 17 00:00:00 2001 From: Olaf Rempel Date: Mon, 3 Mar 2008 23:50:40 +0100 Subject: [PATCH] moved to 0x13c000 --- at91_init0.s | 47 ++++++++++++++++++++++++++++------------------- ldscript.ld | 15 +++++++-------- src/dfu.c | 2 +- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/at91_init0.s b/at91_init0.s index 006acae..dd77955 100644 --- a/at91_init0.s +++ b/at91_init0.s @@ -31,7 +31,7 @@ .equ I_BIT, 0x80 .equ F_BIT, 0x40 - .section .init + .section .init_dummy, "x" .global _hwstart .func _hwstart _hwstart: @@ -44,15 +44,15 @@ _hwstart: ldr pc, [pc, #4] /* 0x18 IRQ */ ldr pc, [pc, #0] /* 0x1c FIQ */ - .word _blrelocate /* + 0x13c000 */ + .word _relocate + 0x13c000 .word 0x80000000 .endfunc - .section .init - .global _blrelocate - .func _blrelocate -_blrelocate: + .section .init, "x" + .global _relocate + .func _relocate +_relocate: msr CPSR_c, #ARM_MODE_SVC | I_BIT | F_BIT /* Remap RAM to 0x00000000 */ @@ -60,22 +60,14 @@ _blrelocate: mov r2, #0x01 str r2, [r1] - /* Relocate .data section */ - ldr r1, =__init_end__ + /* Relocate .text section */ + ldr r1, =__text_copy_start__ ldr r2, =__text_start__ - ldr r3, =__data_end__ -LoopRel: cmp r2, r3 + ldr r3, =__text_end__ +_relocate1: cmp r2, r3 ldrlo r0, [r1], #4 strlo r0, [r2], #4 - blo LoopRel - - /* Clear .bss section */ - mov r0, #0 - ldr r1, =__bss_start__ - ldr r2, =__bss_end__ -LoopZI: cmp r1, r2 - strlo r0, [r1], #4 - BLO LoopZI + blo _relocate1 ldr r0, =InitReset mov pc, r0 @@ -144,6 +136,23 @@ InitReset: msr CPSR_c, #ARM_MODE_SVC mov sp, r0 + /* Relocate .data section */ + ldr r1, =__data_copy_start__ + ldr r2, =__data_start__ + ldr r3, =__data_end__ +LoopRel: cmp r2, r3 + ldrlo r0, [r1], #4 + strlo r0, [r2], #4 + blo LoopRel + + /* Clear .bss section */ + mov r0, #0 + ldr r1, =__bss_start__ + ldr r2, =__bss_end__ +LoopZI: cmp r1, r2 + strlo r0, [r1], #4 + blo LoopZI + /* Start main() */ ldr lr, =exit ldr r0, =main diff --git a/ldscript.ld b/ldscript.ld index 9d97b20..2b73aa6 100644 --- a/ldscript.ld +++ b/ldscript.ld @@ -1,26 +1,23 @@ MEMORY { -/* FLASH(rx) : ORIGIN = 0x00100000, LENGTH = 256k -*/ - CODE (rx) : ORIGIN = 0x00100000, LENGTH = 16k + CODE (rx) : ORIGIN = 0x0013C000, LENGTH = 16k DATA (rwx) : ORIGIN = 0x00000000, LENGTH = 64k } SECTIONS { -/* . = ORIGIN(FLASH); - .text.dummy : { - *(.text.dummy) + .init_dummy : { + *(.init_dummy) } >FLASH =0 -*/ + . = ORIGIN(CODE); .init : { *(.init) - __init_end__ = .; + __text_copy_start__ = .; } >CODE =0 .text : AT (LOADADDR(.init) + SIZEOF(.init)) { @@ -43,6 +40,8 @@ SECTIONS . = ALIGN(4); *(.rodata) *(.rodata.*) + + __data_copy_start__ = (__text_copy_start__ + (__text_end__ - __text_start__)); } >DATA =0 __text_start__ = ADDR(.text); diff --git a/src/dfu.c b/src/dfu.c index e9250b4..289fad9 100644 --- a/src/dfu.c +++ b/src/dfu.c @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 01/2008 by Olaf Rempel * + * Copyright (C) 03/2008 by Olaf Rempel * * razzor@kopf-tisch.de * * * * This program is free software; you can redistribute it and/or modify *