Skip to content

Commit e03455a

Browse files
author
Deepika
committed
Target_Freescale: Set the heap size and limit
1 parent 5e4dcab commit e03455a

File tree

17 files changed

+175
-36
lines changed

17 files changed

+175
-36
lines changed

targets/TARGET_Freescale/TARGET_K20XX/TARGET_K20D50M/device/TOOLCHAIN_GCC_ARM/MK20D5.ld

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ SECTIONS
147147
__end__ = .;
148148
end = __end__;
149149
*(.heap*)
150+
. = ORIGIN(RAM) + LENGTH(RAM) - STACK_SIZE;
150151
__HeapLimit = .;
151152
} > RAM
152153

targets/TARGET_Freescale/TARGET_K20XX/TARGET_TEENSY3_1/device/TOOLCHAIN_GCC_ARM/MK20DX256.ld

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ SECTIONS
148148
__end__ = .;
149149
end = __end__;
150150
*(.heap*)
151+
. = ORIGIN(RAM) + LENGTH(RAM) - STACK_SIZE;
151152
__HeapLimit = .;
152153
} > RAM
153154

targets/TARGET_Freescale/TARGET_KLXX/TARGET_KL05Z/device/TOOLCHAIN_GCC_ARM/MKL05Z4.ld

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ SECTIONS
138138
__end__ = .;
139139
end = __end__;
140140
*(.heap*)
141+
.= ORIGIN(RAM) + LENGTH(RAM) - STACK_SIZE;
141142
__HeapLimit = .;
142143
} > RAM
143144

targets/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/device/TOOLCHAIN_GCC_ARM/MKL25Z4.ld

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ SECTIONS
147147
__end__ = .;
148148
end = __end__;
149149
*(.heap*)
150+
.= ORIGIN(RAM) + LENGTH(RAM) - STACK_SIZE;
150151
__HeapLimit = .;
151152
} > RAM
152153

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

targets/TARGET_Freescale/TARGET_KLXX/TARGET_KL26Z/device/TOOLCHAIN_GCC_ARM/MKL26Z4.ld

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ SECTIONS
147147
__end__ = .;
148148
end = __end__;
149149
*(.heap*)
150+
. = ORIGIN(RAM) + LENGTH(RAM) - STACK_SIZE;
150151
__HeapLimit = .;
151152
} > RAM
152153

targets/TARGET_Freescale/TARGET_KLXX/TARGET_KL46Z/device/TOOLCHAIN_GCC_ARM/MKL46Z4.ld

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ SECTIONS
147147
__end__ = .;
148148
end = __end__;
149149
*(.heap*)
150+
. = ORIGIN(RAM) + LENGTH(RAM) - STACK_SIZE;
150151
__HeapLimit = .;
151152
} > RAM
152153

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K66F/device/TOOLCHAIN_GCC_ARM/MK66FN2M0xxx18.ld

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ __heap_size__ = 0x6000;
6767
#define MBED_APP_SIZE 0x200000
6868
#endif
6969

70-
HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0400;
7170
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
7271
M_VECTOR_RAM_SIZE = DEFINED(__ram_vector_table__) ? 0x0400 : 0x0;
7372
M_CRASH_DATA_RAM_SIZE = 0x100;
@@ -253,7 +252,7 @@ SECTIONS
253252
__end__ = .;
254253
PROVIDE(end = .);
255254
__HeapBase = .;
256-
. += HEAP_SIZE;
255+
. = ORIGIN(m_data_2) + LENGTH(m_data_2) - STACK_SIZE;
257256
__HeapLimit = .;
258257
__heap_limit = .; /* Add for _sbrk */
259258
} > m_data_2

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K82F/device/TOOLCHAIN_GCC_ARM/MK82FN256xxx15.ld

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ __ram_vector_table__ = 1;
6060
* the stack where main runs is determined via the RTOS. */
6161
__stack_size__ = MBED_BOOT_STACK_SIZE;
6262

63-
__heap_size__ = 0x6000;
64-
65-
HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0400;
6663
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
6764
M_VECTOR_RAM_SIZE = DEFINED(__ram_vector_table__) ? 0x03C0 : 0x0;
6865

@@ -247,7 +244,7 @@ SECTIONS
247244
__end__ = .;
248245
PROVIDE(end = .);
249246
__HeapBase = .;
250-
. += HEAP_SIZE;
247+
. = ORIGIN(m_data_2) + LENGTH(m_data_2) - STACK_SIZE;
251248
__HeapLimit = .;
252249
__heap_limit = .; /* Add for _sbrk */
253250
} > m_data_2

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL27Z/device/TOOLCHAIN_GCC_ARM/MKL27Z64xxx4.ld

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,8 @@ __ram_vector_table__ = 1;
5757
#define MBED_BOOT_STACK_SIZE 0x400
5858
#endif
5959

60-
/* With the RTOS in use, this does not affect the main stack size. The size of
61-
* the stack where main runs is determined via the RTOS. */
6260
__stack_size__ = MBED_BOOT_STACK_SIZE;
63-
/* With the RTOS in use, this does not affect the main heap size. */
64-
__heap_size__ = 0x0;
6561

66-
HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0400;
6762
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
6863
M_VECTOR_RAM_SIZE = DEFINED(__ram_vector_table__) ? 0x0200 : 0x0;
6964

@@ -249,7 +244,7 @@ SECTIONS
249244
__end__ = .;
250245
PROVIDE(end = .);
251246
__HeapBase = .;
252-
. += HEAP_SIZE;
247+
. = ORIGIN(m_data) + LENGTH(m_data) - STACK_SIZE;
253248
__HeapLimit = .;
254249
__heap_limit = .; /* Add for _sbrk */
255250
} > m_data

0 commit comments

Comments
 (0)