Skip to content

Commit e2f1ece

Browse files
committed
LPC1114 - linker script & startup code improvement
1 parent e5e819b commit e2f1ece

File tree

3 files changed

+45
-49
lines changed

3 files changed

+45
-49
lines changed
Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,48 @@
11
#! armcc -E
22

3+
#if !defined(MBED_APP_START)
4+
#define MBED_APP_START 0x00000000
5+
#endif
6+
7+
; 32K flash
8+
#if !defined(MBED_APP_SIZE)
9+
#define MBED_APP_SIZE 0x8000
10+
#endif
11+
12+
; 4KB
13+
#if !defined(MBED_RAM_START)
14+
#define MBED_RAM_START 0x10000000
15+
#endif
16+
17+
#if !defined(MBED_RAM_SIZE)
18+
#define MBED_RAM_SIZE 0x00001000
19+
#endif
20+
21+
322
#if !defined(MBED_BOOT_STACK_SIZE)
4-
#define MBED_BOOT_STACK_SIZE 0x400
23+
#define MBED_BOOT_STACK_SIZE 0x400
524
#endif
625

7-
#define Stack_Size MBED_BOOT_STACK_SIZE
26+
; 8_byte_aligned(48 vect * 4 bytes) = 8_byte_aligned(0xC0) = 0xC0
27+
#define VECTOR_SIZE 0xC0
28+
29+
#define RAM_FIXED_SIZE (MBED_BOOT_STACK_SIZE+VECTOR_SIZE)
830

9-
LR_IROM1 0x00000000 0x8000 { ; load region size_region (32k)
10-
ER_IROM1 0x00000000 0x8000 { ; load address = execution address
31+
LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
32+
33+
ER_IROM1 MBED_APP_START MBED_APP_SIZE { ; load address = execution address
1134
*.o (RESET, +First)
1235
*(InRoot$$Sections)
1336
.ANY (+RO)
1437
}
15-
; 8_byte_aligned(48 vect * 4 bytes) = 8_byte_aligned(0xC0) = 0xC0
16-
; 8KB - 0xC0 = 0xF40
17-
RW_IRAM1 0x100000C0 0xF40-Stack_Size {
38+
39+
RW_IRAM1 (MBED_RAM_START+VECTOR_SIZE) (MBED_RAM_SIZE-VECTOR_SIZE) { ; RW data
1840
.ANY (+RW +ZI)
1941
}
20-
ARM_LIB_STACK (0x100000C0+0xF40) EMPTY -Stack_Size { ; stack
42+
43+
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_SIZE-RAM_FIXED_SIZE+MBED_RAM_START-AlignExpr(ImageLimit(RW_IRAM1), 16)) {
44+
}
45+
46+
ARM_LIB_STACK (MBED_RAM_START+MBED_RAM_SIZE) EMPTY -MBED_BOOT_STACK_SIZE { ; stack
2147
}
2248
}

targets/TARGET_NXP/TARGET_LPC11XX_11CXX/device/TOOLCHAIN_GCC_ARM/TARGET_LPC11XX/LPC1114.ld

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ SECTIONS
4646
.text :
4747
{
4848
KEEP(*(.isr_vector))
49-
*(.text.Reset_Handler)
49+
*(.text.Reset_Handler)
5050
*(.text.SystemInit)
51-
. = 0x200;
51+
. = 0x200;
5252
*(.text*)
5353

5454
KEEP(*(.init))
@@ -95,24 +95,24 @@ SECTIONS
9595

9696
. = ALIGN(8);
9797
/* preinit data */
98-
PROVIDE (__preinit_array_start = .);
98+
PROVIDE_HIDDEN (__preinit_array_start = .);
9999
KEEP(*(.preinit_array))
100-
PROVIDE (__preinit_array_end = .);
100+
PROVIDE_HIDDEN (__preinit_array_end = .);
101101

102102
. = ALIGN(8);
103103
/* init data */
104-
PROVIDE (__init_array_start = .);
104+
PROVIDE_HIDDEN (__init_array_start = .);
105105
KEEP(*(SORT(.init_array.*)))
106106
KEEP(*(.init_array))
107-
PROVIDE (__init_array_end = .);
107+
PROVIDE_HIDDEN (__init_array_end = .);
108108

109109

110110
. = ALIGN(8);
111111
/* finit data */
112-
PROVIDE (__fini_array_start = .);
112+
PROVIDE_HIDDEN (__fini_array_start = .);
113113
KEEP(*(SORT(.fini_array.*)))
114114
KEEP(*(.fini_array))
115-
PROVIDE (__fini_array_end = .);
115+
PROVIDE_HIDDEN (__fini_array_end = .);
116116

117117
. = ALIGN(8);
118118
/* All data end */
@@ -128,7 +128,7 @@ SECTIONS
128128
__bss_end__ = .;
129129
} > RAM
130130

131-
.heap :
131+
.heap (COPY):
132132
{
133133
__end__ = .;
134134
end = __end__;
@@ -140,7 +140,7 @@ SECTIONS
140140
/* .stack_dummy section doesn't contains any symbols. It is only
141141
* used for linker to calculate size of stack sections, and assign
142142
* values to stack symbols later */
143-
.stack_dummy :
143+
.stack_dummy (COPY):
144144
{
145145
*(.stack)
146146
} > RAM
@@ -153,4 +153,4 @@ SECTIONS
153153

154154
/* Check if data + heap + stack exceeds RAM limit */
155155
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
156-
}
156+
}

targets/TARGET_NXP/TARGET_LPC11XX_11CXX/device/TOOLCHAIN_GCC_ARM/startup_LPC11xx.S

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -44,36 +44,7 @@
4444
aborting compilation, it is not the run time limit:
4545
Heap_Size + Stack_Size = 0x80 + 0x80 = 0x100
4646
*/
47-
.section .stack
48-
.align 3
49-
#ifdef __STACK_SIZE
50-
.equ Stack_Size, __STACK_SIZE
51-
#else
52-
.equ Stack_Size, 0x80
53-
#endif
54-
.globl __StackTop
55-
.globl __StackLimit
56-
__StackLimit:
57-
.space Stack_Size
58-
.size __StackLimit, . - __StackLimit
59-
__StackTop:
60-
.size __StackTop, . - __StackTop
6147

62-
.section .heap
63-
.align 3
64-
#ifdef __HEAP_SIZE
65-
.equ Heap_Size, __HEAP_SIZE
66-
#else
67-
.equ Heap_Size, 0x80
68-
#endif
69-
.globl __HeapBase
70-
.globl __HeapLimit
71-
__HeapBase:
72-
.space Heap_Size
73-
.size __HeapBase, . - __HeapBase
74-
__HeapLimit:
75-
.size __HeapLimit, . - __HeapLimit
76-
7748
.section .isr_vector
7849
.align 2
7950
.globl __isr_vector
@@ -210,6 +181,5 @@ Reset_Handler:
210181
def_irq_default_handler PIOINT2_IRQHandler
211182
def_irq_default_handler PIOINT1_IRQHandler
212183
def_irq_default_handler PIOINT0_IRQHandler
213-
def_irq_default_handler DEF_IRQHandler
214184

215185
.end

0 commit comments

Comments
 (0)