Skip to content

Commit 139c051

Browse files
committed
uVisor: Standardize available legacy heap and stack
With the RTOS, the STACK_SIZE specified here is unrelated to the stack size available for the main thread (that runs pre_main). Save memory by reducing the stack size to a more reasonable amount. On uVisor, HEAP_SIZE is both a minimum available and maximum available heap size. The heap can't grow beyond the end of the heap into the neighboring stack. On all uVisor-supported platforms, guarantee at least 0x6000 bytes of heap space. This increases the portability of uVisor applications as the memory available for legacy heap allocations is guaranteed. This helps to avoid out of memory errors on platforms that were previously guaranteeing less memory.
1 parent 65956d1 commit 139c051

File tree

3 files changed

+26
-7
lines changed
  • targets
    • TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_GCC_ARM
    • TARGET_STM/TARGET_STM32F4/TARGET_DISCO_F429ZI/device/TOOLCHAIN_GCC_ARM
    • TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32GG/device/TARGET_1024K/TOOLCHAIN_GCC_ARM

3 files changed

+26
-7
lines changed

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_GCC_ARM/MK64FN1M0xxx12.ld

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,15 @@ ENTRY(Reset_Handler)
5353

5454
__ram_vector_table__ = 1;
5555

56-
/* Heap 1/4 of ram and stack 1/8 */
57-
__stack_size__ = 0x8000;
58-
__heap_size__ = 0x10000;
56+
/* With the RTOS in use, this does not affect the main stack size. The size of
57+
* the stack where main runs is determined via the RTOS. */
58+
__stack_size__ = 0x400;
59+
60+
/* This is the guaranteed minimum available heap size for an application. When
61+
* uVisor is enabled, this is also the maximum available heap size. The
62+
* HEAP_SIZE value is set by uVisor porters to balance the size of the legacy
63+
* heap and the page heap in uVisor applications. */
64+
__heap_size__ = 0x6000;
5965

6066
HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0400;
6167
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;

targets/TARGET_STM/TARGET_STM32F4/TARGET_DISCO_F429ZI/device/TOOLCHAIN_GCC_ARM/STM32F429ZI.ld

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
M_VECTOR_RAM_SIZE = 0x400;
22

3-
/* Heap: 1/4 of RAM. Stack: 1/8 of RAM. */
4-
STACK_SIZE = 0x6000;
5-
HEAP_SIZE = 0xC000;
3+
/* With the RTOS in use, this does not affect the main stack size. The size of
4+
* the stack where main runs is determined via the RTOS. */
5+
STACK_SIZE = 0x400;
6+
7+
/* This is the guaranteed minimum available heap size for an application. When
8+
* uVisor is enabled, this is also the maximum available heap size. The
9+
* HEAP_SIZE value is set by uVisor porters to balance the size of the legacy
10+
* heap and the page heap in uVisor applications. */
11+
HEAP_SIZE = 0x6000;
612

713
/* Specify the memory areas */
814
MEMORY

targets/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32GG/device/TARGET_1024K/TOOLCHAIN_GCC_ARM/efm32gg.ld

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@
99
/* Version 4.2.0 */
1010
/* */
1111

12+
/* With the RTOS in use, this does not affect the main stack size. The size of
13+
* the stack where main runs is determined via the RTOS. */
1214
STACK_SIZE = 0x400;
13-
HEAP_SIZE = 0xC00;
15+
16+
/* This is the guaranteed minimum available heap size for an application. When
17+
* uVisor is enabled, this is also the maximum available heap size. The
18+
* HEAP_SIZE value is set by uVisor porters to balance the size of the legacy
19+
* heap and the page heap in uVisor applications. */
20+
HEAP_SIZE = 0x6000;
1421

1522
MEMORY
1623
{

0 commit comments

Comments
 (0)