aboutsummaryrefslogtreecommitdiff
path: root/lib/lpc17xx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lpc17xx')
-rw-r--r--lib/lpc17xx/Makefile4
-rw-r--r--lib/lpc17xx/libopencm3_lpc17xx.ld34
-rw-r--r--lib/lpc17xx/vector.c7
3 files changed, 28 insertions, 17 deletions
diff --git a/lib/lpc17xx/Makefile b/lib/lpc17xx/Makefile
index f688716..d1da64a 100644
--- a/lib/lpc17xx/Makefile
+++ b/lib/lpc17xx/Makefile
@@ -28,8 +28,8 @@ CFLAGS = -O0 -g -Wall -Wextra -I../../include -fno-common \
-ffunction-sections -fdata-sections -MD
# ARFLAGS = rcsv
ARFLAGS = rcs
-OBJS = gpio.o vector.o
+OBJS = gpio.o vector.o assert.o
-# VPATH += ../usb
+VPATH += ../cm3
include ../Makefile.include
diff --git a/lib/lpc17xx/libopencm3_lpc17xx.ld b/lib/lpc17xx/libopencm3_lpc17xx.ld
index 30a2c0f..4e0f1df 100644
--- a/lib/lpc17xx/libopencm3_lpc17xx.ld
+++ b/lib/lpc17xx/libopencm3_lpc17xx.ld
@@ -1,4 +1,3 @@
-
/*
* This file is part of the libopencm3 project.
*
@@ -31,28 +30,44 @@ ENTRY(reset_handler)
/* Define sections. */
SECTIONS
{
- . = ORIGIN(rom);
-
.text : {
*(.vectors) /* Vector table */
*(.text*) /* Program code */
+ . = ALIGN(4);
*(.rodata*) /* Read-only data */
- _etext = .;
+ . = ALIGN(4);
} >rom
- . = ORIGIN(ram);
+ /*
+ * Another section used by C++ stuff, appears when using newlib with
+ * 64bit (long long) printf support
+ */
+ .ARM.extab : {
+ *(.ARM.extab*)
+ } >rom
+ .ARM.exidx : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >rom
+
+ . = ALIGN(4);
+ _etext = .;
.data : {
_data = .;
*(.data*) /* Read-write initialized data */
+ . = ALIGN(4);
_edata = .;
} >ram AT >rom
+ _data_loadaddr = LOADADDR(.data);
.bss : {
*(.bss*) /* Read-write zero initialized data */
*(COMMON)
+ . = ALIGN(4);
_ebss = .;
- } >ram AT >rom
+ } >ram
/*
* The .eh_frame section appears to be used for C++ exception handling.
@@ -60,12 +75,7 @@ SECTIONS
*/
/DISCARD/ : { *(.eh_frame) }
- /*
- * Another section used by C++ stuff, appears when using newlib with
- * 64bit (long long) printf support - discard it for now.
- */
- /DISCARD/ : { *(.ARM.exidx) }
-
+ . = ALIGN(4);
end = .;
}
diff --git a/lib/lpc17xx/vector.c b/lib/lpc17xx/vector.c
index 016db7a..518f562 100644
--- a/lib/lpc17xx/vector.c
+++ b/lib/lpc17xx/vector.c
@@ -19,8 +19,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;
void main(void);
void reset_handler(void);
@@ -60,9 +60,10 @@ void (*const vector_table[]) (void) = {
void reset_handler(void)
{
volatile unsigned *src, *dest;
+
__asm__("MSR msp, %0" : : "r"(&_stack));
- for (src = &_etext, dest = &_data; dest < &_edata; src++, dest++)
+ for (src = &_data_loadaddr, dest = &_data; dest < &_edata; src++, dest++)
*dest = *src;
while (dest < &_ebss)