aboutsummaryrefslogtreecommitdiff
path: root/lib/lpc43xx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lpc43xx')
-rw-r--r--lib/lpc43xx/libopencm3_lpc43xx.ld1
-rw-r--r--lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld1
-rw-r--r--lib/lpc43xx/vector.c7
3 files changed, 6 insertions, 3 deletions
diff --git a/lib/lpc43xx/libopencm3_lpc43xx.ld b/lib/lpc43xx/libopencm3_lpc43xx.ld
index 2fedf09..b7f1d14 100644
--- a/lib/lpc43xx/libopencm3_lpc43xx.ld
+++ b/lib/lpc43xx/libopencm3_lpc43xx.ld
@@ -60,6 +60,7 @@ SECTIONS
. = ALIGN(4);
_edata = .;
} >ram AT >rom
+ _data_loadaddr = LOADADDR(.data);
.bss : {
*(.bss*) /* Read-write zero initialized data */
diff --git a/lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld b/lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld
index e39f662..4037ddc 100644
--- a/lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld
+++ b/lib/lpc43xx/libopencm3_lpc43xx_rom_to_ram.ld
@@ -61,6 +61,7 @@ SECTIONS
. = ALIGN(4);
_edata = .;
} >ram_data AT >rom
+ _data_loadaddr = LOADADDR(.data);
.bss : {
*(.bss*) /* Read-write zero initialized data */
diff --git a/lib/lpc43xx/vector.c b/lib/lpc43xx/vector.c
index daef5a9..23008bc 100644
--- a/lib/lpc43xx/vector.c
+++ b/lib/lpc43xx/vector.c
@@ -20,8 +20,8 @@
#define WEAK __attribute__ ((weak))
-/* Symbols exported by the linker script(s). */
-extern unsigned _etext, _data, _edata, _ebss, _stack;
+/* Symbols exported by the linker script(s): */
+extern unsigned _data_loadaddr, _data, _edata, _ebss, _stack;
extern unsigned _etext_ram, _text_ram, _etext_rom;
void main(void);
@@ -165,6 +165,7 @@ void (*const vector_table[]) (void) = {
void reset_handler(void)
{
volatile unsigned *src, *dest;
+
__asm__("MSR msp, %0" : : "r"(&_stack));
/* Copy the code from ROM to Real RAM (if enabled) */
@@ -185,7 +186,7 @@ void reset_handler(void)
/* Continue Execution in RAM */
}
- for (src = &_etext, dest = &_data; dest < &_edata; src++, dest++)
+ for (src = &_data_loadaddr, dest = &_data; dest < &_edata; src++, dest++)
*dest = *src;
while (dest < &_ebss)