Skip to content

Commit 65fa7b6

Browse files
committed
LPC81X: reduce code size and add ARM_GCC support
LPC810 has only 4KB of flash, thus avoiding dead code is really nice. Here the NVIC interrupt setup was pulled from the us_ticker code even if no code is using timer events. This also adds ARM_GCC support for TARGET_LPC81X. LPC81X and LPC82X support Cortex M0+ VTOR register, so it is not necessary to put non-init text at 0x200.
1 parent 0209751 commit 65fa7b6

File tree

11 files changed

+570
-5
lines changed

11 files changed

+570
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,5 @@ cscope.*
7272

7373
# vim swap files
7474
*.swp
75+
*~
7576

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
/* Linker script for mbed LPC810-GCC-ARM based on LPC824.ld */
2+
3+
/* Linker script to configure memory regions. */
4+
MEMORY
5+
{
6+
/* Define each memory region */
7+
FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x1000 /* 4K bytes */
8+
RAM (rwx) : ORIGIN = 0x10000000+0xC0, LENGTH = 0x400-0xC0 /* 1K bytes */
9+
10+
11+
}
12+
13+
/* Linker script to place sections and symbol values. Should be used together
14+
* with other linker script that defines memory regions FLASH and RAM.
15+
* It references following symbols, which must be defined in code:
16+
* Reset_Handler : Entry of reset handler
17+
*
18+
* It defines following symbols, which code can use without definition:
19+
* __exidx_start
20+
* __exidx_end
21+
* __etext
22+
* __data_start__
23+
* __preinit_array_start
24+
* __preinit_array_end
25+
* __init_array_start
26+
* __init_array_end
27+
* __fini_array_start
28+
* __fini_array_end
29+
* __data_end__
30+
* __bss_start__
31+
* __bss_end__
32+
* __end__
33+
* end
34+
* __HeapLimit
35+
* __StackLimit
36+
* __StackTop
37+
* __stack
38+
*/
39+
ENTRY(Reset_Handler)
40+
41+
SECTIONS
42+
{
43+
.text :
44+
{
45+
KEEP(*(.isr_vector))
46+
*(.text.Reset_Handler)
47+
*(.text.SystemInit)
48+
*(.text*)
49+
50+
KEEP(*(.init))
51+
KEEP(*(.fini))
52+
53+
/* .ctors */
54+
*crtbegin.o(.ctors)
55+
*crtbegin?.o(.ctors)
56+
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
57+
*(SORT(.ctors.*))
58+
*(.ctors)
59+
60+
/* .dtors */
61+
*crtbegin.o(.dtors)
62+
*crtbegin?.o(.dtors)
63+
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
64+
*(SORT(.dtors.*))
65+
*(.dtors)
66+
67+
*(.rodata*)
68+
69+
KEEP(*(.eh_frame*))
70+
} > FLASH
71+
72+
.ARM.extab :
73+
{
74+
*(.ARM.extab* .gnu.linkonce.armextab.*)
75+
} > FLASH
76+
77+
__exidx_start = .;
78+
.ARM.exidx :
79+
{
80+
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
81+
} > FLASH
82+
__exidx_end = .;
83+
84+
__etext = .;
85+
86+
.data : AT (__etext)
87+
{
88+
__data_start__ = .;
89+
*(vtable)
90+
*(.data*)
91+
92+
. = ALIGN(4);
93+
/* preinit data */
94+
PROVIDE (__preinit_array_start = .);
95+
KEEP(*(.preinit_array))
96+
PROVIDE (__preinit_array_end = .);
97+
98+
. = ALIGN(4);
99+
/* init data */
100+
PROVIDE (__init_array_start = .);
101+
KEEP(*(SORT(.init_array.*)))
102+
KEEP(*(.init_array))
103+
PROVIDE (__init_array_end = .);
104+
105+
106+
. = ALIGN(4);
107+
/* finit data */
108+
PROVIDE (__fini_array_start = .);
109+
KEEP(*(SORT(.fini_array.*)))
110+
KEEP(*(.fini_array))
111+
PROVIDE (__fini_array_end = .);
112+
113+
. = ALIGN(4);
114+
/* All data end */
115+
__data_end__ = .;
116+
117+
} > RAM
118+
119+
.bss :
120+
{
121+
__bss_start__ = .;
122+
*(.bss*)
123+
*(COMMON)
124+
__bss_end__ = .;
125+
} > RAM
126+
127+
.heap :
128+
{
129+
__end__ = .;
130+
end = __end__;
131+
*(.heap*)
132+
__HeapLimit = .;
133+
} > RAM
134+
135+
/* .stack_dummy section doesn't contains any symbols. It is only
136+
* used for linker to calculate size of stack sections, and assign
137+
* values to stack symbols later */
138+
.stack_dummy :
139+
{
140+
*(.stack)
141+
} > RAM
142+
143+
/* Set stack top to end of RAM, and stack limit move down by
144+
* size of stack_dummy section */
145+
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
146+
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
147+
PROVIDE(__stack = __StackTop);
148+
149+
/* Check if data + heap + stack exceeds RAM limit */
150+
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
151+
}
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
/* Linker script for mbed LPC812-GCC-ARM based on LPC824.ld */
2+
3+
/* Linker script to configure memory regions. */
4+
MEMORY
5+
{
6+
/* Define each memory region */
7+
FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x4000 /* 16K bytes */
8+
RAM (rwx) : ORIGIN = 0x10000000+0xC0, LENGTH = 0x1000-0xC0 /* 4K bytes */
9+
10+
11+
}
12+
13+
/* Linker script to place sections and symbol values. Should be used together
14+
* with other linker script that defines memory regions FLASH and RAM.
15+
* It references following symbols, which must be defined in code:
16+
* Reset_Handler : Entry of reset handler
17+
*
18+
* It defines following symbols, which code can use without definition:
19+
* __exidx_start
20+
* __exidx_end
21+
* __etext
22+
* __data_start__
23+
* __preinit_array_start
24+
* __preinit_array_end
25+
* __init_array_start
26+
* __init_array_end
27+
* __fini_array_start
28+
* __fini_array_end
29+
* __data_end__
30+
* __bss_start__
31+
* __bss_end__
32+
* __end__
33+
* end
34+
* __HeapLimit
35+
* __StackLimit
36+
* __StackTop
37+
* __stack
38+
*/
39+
ENTRY(Reset_Handler)
40+
41+
SECTIONS
42+
{
43+
.text :
44+
{
45+
KEEP(*(.isr_vector))
46+
*(.text.Reset_Handler)
47+
*(.text.SystemInit)
48+
*(.text*)
49+
50+
KEEP(*(.init))
51+
KEEP(*(.fini))
52+
53+
/* .ctors */
54+
*crtbegin.o(.ctors)
55+
*crtbegin?.o(.ctors)
56+
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
57+
*(SORT(.ctors.*))
58+
*(.ctors)
59+
60+
/* .dtors */
61+
*crtbegin.o(.dtors)
62+
*crtbegin?.o(.dtors)
63+
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
64+
*(SORT(.dtors.*))
65+
*(.dtors)
66+
67+
*(.rodata*)
68+
69+
KEEP(*(.eh_frame*))
70+
} > FLASH
71+
72+
.ARM.extab :
73+
{
74+
*(.ARM.extab* .gnu.linkonce.armextab.*)
75+
} > FLASH
76+
77+
__exidx_start = .;
78+
.ARM.exidx :
79+
{
80+
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
81+
} > FLASH
82+
__exidx_end = .;
83+
84+
__etext = .;
85+
86+
.data : AT (__etext)
87+
{
88+
__data_start__ = .;
89+
*(vtable)
90+
*(.data*)
91+
92+
. = ALIGN(4);
93+
/* preinit data */
94+
PROVIDE (__preinit_array_start = .);
95+
KEEP(*(.preinit_array))
96+
PROVIDE (__preinit_array_end = .);
97+
98+
. = ALIGN(4);
99+
/* init data */
100+
PROVIDE (__init_array_start = .);
101+
KEEP(*(SORT(.init_array.*)))
102+
KEEP(*(.init_array))
103+
PROVIDE (__init_array_end = .);
104+
105+
106+
. = ALIGN(4);
107+
/* finit data */
108+
PROVIDE (__fini_array_start = .);
109+
KEEP(*(SORT(.fini_array.*)))
110+
KEEP(*(.fini_array))
111+
PROVIDE (__fini_array_end = .);
112+
113+
. = ALIGN(4);
114+
/* All data end */
115+
__data_end__ = .;
116+
117+
} > RAM
118+
119+
.bss :
120+
{
121+
__bss_start__ = .;
122+
*(.bss*)
123+
*(COMMON)
124+
__bss_end__ = .;
125+
} > RAM
126+
127+
.heap :
128+
{
129+
__end__ = .;
130+
end = __end__;
131+
*(.heap*)
132+
__HeapLimit = .;
133+
} > RAM
134+
135+
/* .stack_dummy section doesn't contains any symbols. It is only
136+
* used for linker to calculate size of stack sections, and assign
137+
* values to stack symbols later */
138+
.stack_dummy :
139+
{
140+
*(.stack)
141+
} > RAM
142+
143+
/* Set stack top to end of RAM, and stack limit move down by
144+
* size of stack_dummy section */
145+
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
146+
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
147+
PROVIDE(__stack = __StackTop);
148+
149+
/* Check if data + heap + stack exceeds RAM limit */
150+
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
151+
}

0 commit comments

Comments
 (0)