Skip to content

Commit 1a52587

Browse files
author
Deepika
committed
Update the linker file to support single and multiple heap banks
1 parent 3593444 commit 1a52587

File tree

1 file changed

+23
-9
lines changed
  • targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/device/TOOLCHAIN_GCC_ARM

1 file changed

+23
-9
lines changed

targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/device/TOOLCHAIN_GCC_ARM/STM32L475XX.ld

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
#define MBED_APP_SIZE 1024k
77
#endif
88

9+
M_CRASH_DATA_RAM_SIZE = 0x100;
10+
911
#if !defined(MBED_BOOT_STACK_SIZE)
1012
#define MBED_BOOT_STACK_SIZE 0x400
1113
#endif
1214

1315
STACK_SIZE = MBED_BOOT_STACK_SIZE;
1416

15-
M_CRASH_DATA_RAM_SIZE = 0x100;
16-
1717
/* Linker script to configure memory regions. */
1818
MEMORY
1919
{
@@ -106,7 +106,7 @@ SECTIONS
106106
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
107107
} > SRAM2
108108

109-
/* .stack section doesn't contains any symbols. It is only
109+
/* .stack section doesn't contains any symbols. It is only
110110
* used for linker to reserve space for the isr stack section
111111
* WARNING: .stack should come immediately after the last secure memory
112112
* section. This provides stack overflow detection. */
@@ -124,6 +124,17 @@ SECTIONS
124124
__StackLimit = ADDR(.stack);
125125
PROVIDE(__stack = __StackTop);
126126

127+
/* Place holder for additional heap */
128+
.heap_0 (COPY):
129+
{
130+
__mbed_sbrk_start_0 = .;
131+
. += (ORIGIN(SRAM2) + LENGTH(SRAM2) - .);
132+
__mbed_krbs_start_0 = .;
133+
} > SRAM2
134+
135+
/* Check if heap exceeds SRAM2 */
136+
ASSERT(__mbed_krbs_start_0 <= (ORIGIN(SRAM2)+LENGTH(SRAM2)), "Heap is too big for SRAM2")
137+
127138
.data : AT (__etext)
128139
{
129140
__data_start__ = .;
@@ -144,6 +155,7 @@ SECTIONS
144155
KEEP(*(.init_array))
145156
PROVIDE_HIDDEN (__init_array_end = .);
146157

158+
147159
. = ALIGN(8);
148160
/* finit data */
149161
PROVIDE_HIDDEN (__fini_array_start = .);
@@ -156,6 +168,7 @@ SECTIONS
156168
/* All data end */
157169
__data_end__ = .;
158170
_edata = .;
171+
159172
} > SRAM1
160173

161174
/* Check if bss exceeds SRAM1 */
@@ -176,17 +189,18 @@ SECTIONS
176189
/* Check if bss exceeds SRAM1 */
177190
ASSERT(__bss_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "BSS is too big for SRAM1")
178191

192+
/* Placeholder for default single heap */
179193
.heap (COPY):
180194
{
181195
__end__ = .;
182-
__mbed_sbrk_start_0 = .;
183196
end = __end__;
197+
__mbed_sbrk_start = .;
184198
*(.heap*)
185-
. = (ORIGIN(SRAM2) + LENGTH(SRAM2));
186-
__mbed_krbs_start_0 = .;
187-
__mbed_sbrk_start = __bss_end__;
188-
. = (ORIGIN(SRAM1) + LENGTH(SRAM1));
199+
. += (ORIGIN(SRAM1) + LENGTH(SRAM1) - .);
189200
__mbed_krbs_start = .;
190201
__HeapLimit = .;
191-
} > SRAM2
202+
} > SRAM1
203+
204+
/* Check if heap exceeds SRAM1 */
205+
ASSERT(__HeapLimit <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "Heap is too big for SRAM1")
192206
}

0 commit comments

Comments
 (0)