Skip to content

Commit 4161688

Browse files
felseradbridge
authored andcommitted
Decrease heap size in IAR linker so tests compile and use SRAM2 for IAR and GCC
1 parent fcdac9e commit 4161688

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

targets/TARGET_STM/TARGET_STM32L4/TARGET_MTS_DRAGONFLY_L471QG/device/TOOLCHAIN_GCC_ARM/STM32L471XX.ld

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,24 +139,28 @@ SECTIONS
139139
__end__ = .;
140140
end = __end__;
141141
*(.heap*)
142+
. += (ORIGIN(SRAM1) + LENGTH(SRAM1) - .);
142143
__HeapLimit = .;
143144
} > SRAM1
144-
145+
PROVIDE(__heap_size = SIZEOF(.heap));
146+
PROVIDE(__mbed_sbrk_start = ADDR(.heap));
147+
PROVIDE(__mbed_krbs_start = ADDR(.heap) + SIZEOF(.heap));
148+
/* Check if data + heap exceeds RAM1 limit */
149+
ASSERT((ORIGIN(SRAM1)+LENGTH(SRAM1)) >= __HeapLimit, "SRAM1 overflow")
145150
/* .stack_dummy section doesn't contains any symbols. It is only
146151
* used for linker to calculate size of stack sections, and assign
147152
* values to stack symbols later */
148153
.stack_dummy (COPY):
149154
{
150155
*(.stack*)
151-
} > SRAM1
156+
} > SRAM2
152157

153158
/* Set stack top to end of RAM, and stack limit move down by
154159
* size of stack_dummy section */
155-
__StackTop = ORIGIN(SRAM1) + LENGTH(SRAM1);
160+
__StackTop = ORIGIN(SRAM2) + LENGTH(SRAM2);
156161
_estack = __StackTop;
157162
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
158163
PROVIDE(__stack = __StackTop);
159-
160-
/* Check if data + heap + stack exceeds RAM limit */
161-
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
164+
/* Check if stack exceeds RAM2 limit */
165+
ASSERT((ORIGIN(SRAM2)+LENGTH(SRAM2)) >= __StackLimit, "SRAM2 overflow")
162166
}

targets/TARGET_STM/TARGET_STM32L4/TARGET_MTS_DRAGONFLY_L471QG/device/TOOLCHAIN_IAR/stm32l471xx.icf

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,17 @@ define region ROM_region = mem:[from __region_ROM_start__ to __region_ROM_end__]
2121
define region SRAM2_region = mem:[from __region_SRAM2_start__ to __region_SRAM2_end__];
2222
define region SRAM1_region = mem:[from __region_SRAM1_start__ to __region_SRAM1_end__];
2323

24-
/* Stack 1/8 and Heap 1/4 of RAM */
25-
define symbol __size_cstack__ = 0x8000;
26-
define symbol __size_heap__ = 0xa000;
24+
/* Stack complete SRAM2 and Heap 1/3 of SRAM1 */
25+
define symbol __size_cstack__ = 0x7e00;
26+
define symbol __size_heap__ = 0x8000;
2727
define block CSTACK with alignment = 8, size = __size_cstack__ { };
2828
define block HEAP with alignment = 8, size = __size_heap__ { };
29-
define block STACKHEAP with fixed order { block HEAP, block CSTACK };
3029

3130
initialize by copy with packing = zeros { readwrite };
3231
do not initialize { section .noinit };
3332

3433
place at address mem:__intvec_start__ { readonly section .intvec };
3534

3635
place in ROM_region { readonly };
37-
place in SRAM1_region { readwrite, block STACKHEAP };
38-
place in SRAM2_region { };
36+
place in SRAM1_region { readwrite, block HEAP };
37+
place in SRAM2_region { block CSTACK };

targets/targets.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,6 +2181,7 @@
21812181
"macro_name": "MODEM_ON_BOARD_UART"
21822182
}
21832183
},
2184+
"macros_add": ["TWO_RAM_REGIONS"],
21842185
"detect_code": ["0312"],
21852186
"device_has_add": ["ANALOGOUT", "CAN", "LOWPOWERTIMER", "SERIAL_ASYNCH", "SERIAL_FC", "TRNG", "FLASH"],
21862187
"release_versions": ["2", "5"],

0 commit comments

Comments
 (0)