Add support for split heap in ST devices

pull/9944/head
Deepika 2019-03-06 15:43:34 -06:00
parent 1a52587c2d
commit 1576fb0aaa
5 changed files with 186 additions and 101 deletions

View File

@ -14,7 +14,7 @@ STACK_SIZE = MBED_BOOT_STACK_SIZE;
/* Linker script to configure memory regions. */
MEMORY
{
{
FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE
SRAM2 (rwx) : ORIGIN = 0x10000188, LENGTH = 32k - 0x188
SRAM1 (rwx) : ORIGIN = 0x20000000, LENGTH = 96k
@ -24,7 +24,7 @@ MEMORY
* with other linker script that defines memory regions FLASH and RAM.
* It references following symbols, which must be defined in code:
* Reset_Handler : Entry of reset handler
*
*
* It defines following symbols, which code can use without definition:
* __exidx_start
* __exidx_end
@ -92,6 +92,35 @@ SECTIONS
__etext = .;
_sidata = .;
/* .stack section doesn't contains any symbols. It is only
* used for linker to reserve space for the isr stack section
* WARNING: .stack should come immediately after the last secure memory
* section. This provides stack overflow detection. */
.stack (NOLOAD):
{
__StackLimit = .;
*(.stack*);
. += STACK_SIZE - (. - __StackLimit);
} > SRAM2
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ADDR(.stack) + SIZEOF(.stack);
_estack = __StackTop;
__StackLimit = ADDR(.stack);
PROVIDE(__stack = __StackTop);
/* Place holder for additional heap */
.heap_0 (COPY):
{
__mbed_sbrk_start_0 = .;
. += (ORIGIN(SRAM2) + LENGTH(SRAM2) - .);
__mbed_krbs_start_0 = .;
} > SRAM2
/* Check if heap exceeds SRAM2 */
ASSERT(__mbed_krbs_start_0 <= (ORIGIN(SRAM2)+LENGTH(SRAM2)), "Heap is too big for SRAM2")
.data : AT (__etext)
{
__data_start__ = .;
@ -99,21 +128,20 @@ SECTIONS
*(vtable)
*(.data*)
. = ALIGN(4);
. = ALIGN(8);
/* preinit data */
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP(*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
. = ALIGN(8);
/* init data */
PROVIDE_HIDDEN (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
. = ALIGN(8);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
@ -121,52 +149,43 @@ SECTIONS
PROVIDE_HIDDEN (__fini_array_end = .);
KEEP(*(.jcr*))
. = ALIGN(4);
. = ALIGN(8);
/* All data end */
__data_end__ = .;
_edata = .;
} > SRAM1
/* Check if bss exceeds SRAM1 */
ASSERT(__data_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), ".data is too big for SRAM1")
.bss :
{
. = ALIGN(4);
. = ALIGN(8);
__bss_start__ = .;
_sbss = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
. = ALIGN(8);
__bss_end__ = .;
_ebss = .;
} > SRAM1
/* Check if bss exceeds SRAM1 */
ASSERT(__bss_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "BSS is too big for SRAM1")
/* Placeholder for default single heap */
.heap (COPY):
{
__end__ = .;
end = __end__;
__mbed_sbrk_start = .;
*(.heap*)
. += (ORIGIN(SRAM1) + LENGTH(SRAM1) - .);
__mbed_krbs_start = .;
__HeapLimit = .;
} > SRAM1
PROVIDE(__heap_size = SIZEOF(.heap));
PROVIDE(__mbed_sbrk_start = ADDR(.heap));
PROVIDE(__mbed_krbs_start = ADDR(.heap) + SIZEOF(.heap));
/* Check if data + heap exceeds RAM1 limit */
ASSERT((ORIGIN(SRAM1)+LENGTH(SRAM1)) >= __HeapLimit, "SRAM1 overflow")
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
*(.stack*)
} > SRAM2
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(SRAM2) + LENGTH(SRAM2);
_estack = __StackTop;
__StackLimit = __StackTop - STACK_SIZE;
PROVIDE(__stack = __StackTop);
/* Check if stack exceeds RAM2 limit */
ASSERT((ORIGIN(SRAM2)+LENGTH(SRAM2)) >= __StackLimit, "SRAM2 overflow")
}
/* Check if heap exceeds SRAM1 */
ASSERT(__HeapLimit <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "Heap is too big for SRAM1")
}

View File

@ -93,6 +93,35 @@ SECTIONS
__etext = .;
_sidata = .;
/* .stack section doesn't contains any symbols. It is only
* used for linker to reserve space for the isr stack section
* WARNING: .stack should come immediately after the last secure memory
* section. This provides stack overflow detection. */
.stack (NOLOAD):
{
__StackLimit = .;
*(.stack*);
. += STACK_SIZE - (. - __StackLimit);
} > SRAM2
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ADDR(.stack) + SIZEOF(.stack);
_estack = __StackTop;
__StackLimit = ADDR(.stack);
PROVIDE(__stack = __StackTop);
/* Place holder for additional heap */
.heap_0 (COPY):
{
__mbed_sbrk_start_0 = .;
. += (ORIGIN(SRAM2) + LENGTH(SRAM2) - .);
__mbed_krbs_start_0 = .;
} > SRAM2
/* Check if heap exceeds SRAM2 */
ASSERT(__mbed_krbs_start_0 <= (ORIGIN(SRAM2)+LENGTH(SRAM2)), "Heap is too big for SRAM2")
.data : AT (__etext)
{
__data_start__ = .;
@ -129,6 +158,9 @@ SECTIONS
} > SRAM1
/* Check if bss exceeds SRAM1 */
ASSERT(__data_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), ".data is too big for SRAM1")
.bss :
{
. = ALIGN(8);
@ -141,30 +173,21 @@ SECTIONS
_ebss = .;
} > SRAM1
/* Check if bss exceeds SRAM1 */
ASSERT(__bss_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "BSS is too big for SRAM1")
/* Placeholder for default single heap */
.heap (COPY):
{
__end__ = .;
end = __end__;
__mbed_sbrk_start = .;
*(.heap*)
. = ORIGIN(SRAM1) + LENGTH(SRAM1) - STACK_SIZE;
. += (ORIGIN(SRAM1) + LENGTH(SRAM1) - .);
__mbed_krbs_start = .;
__HeapLimit = .;
} > SRAM1
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
*(.stack*)
} > SRAM1
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(SRAM1) + LENGTH(SRAM1);
_estack = __StackTop;
__StackLimit = __StackTop - STACK_SIZE;
PROVIDE(__stack = __StackTop);
/* Check if data + heap + stack exceeds RAM limit */
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
/* Check if heap exceeds SRAM1 */
ASSERT(__HeapLimit <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "Heap is too big for SRAM1")
}

View File

@ -104,7 +104,36 @@ SECTIONS
. += M_CRASH_DATA_RAM_SIZE;
. = ALIGN(8);
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
} > SRAM1
} > SRAM2
/* .stack section doesn't contains any symbols. It is only
* used for linker to reserve space for the isr stack section
* WARNING: .stack should come immediately after the last secure memory
* section. This provides stack overflow detection. */
.stack (NOLOAD):
{
__StackLimit = .;
*(.stack*);
. += STACK_SIZE - (. - __StackLimit);
} > SRAM2
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ADDR(.stack) + SIZEOF(.stack);
_estack = __StackTop;
__StackLimit = ADDR(.stack);
PROVIDE(__stack = __StackTop);
/* Place holder for additional heap */
.heap_0 (COPY):
{
__mbed_sbrk_start_0 = .;
. += (ORIGIN(SRAM2) + LENGTH(SRAM2) - .);
__mbed_krbs_start_0 = .;
} > SRAM2
/* Check if heap exceeds SRAM2 */
ASSERT(__mbed_krbs_start_0 <= (ORIGIN(SRAM2)+LENGTH(SRAM2)), "Heap is too big for SRAM2")
.data : AT (__etext)
{
@ -126,7 +155,6 @@ SECTIONS
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(8);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
@ -142,6 +170,9 @@ SECTIONS
} > SRAM1
/* Check if bss exceeds SRAM1 */
ASSERT(__data_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), ".data is too big for SRAM1")
.bss :
{
. = ALIGN(8);
@ -154,34 +185,21 @@ SECTIONS
_ebss = .;
} > SRAM1
/* Check if bss exceeds SRAM1 */
ASSERT(__bss_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "BSS is too big for SRAM1")
/* Placeholder for default single heap */
.heap (COPY):
{
__end__ = .;
end = __end__;
__mbed_sbrk_start = .;
*(.heap*)
. += (ORIGIN(SRAM1) + LENGTH(SRAM1) - .);
__mbed_krbs_start = .;
__HeapLimit = .;
} > SRAM1
PROVIDE(__heap_size = SIZEOF(.heap));
PROVIDE(__mbed_sbrk_start = ADDR(.heap));
PROVIDE(__mbed_krbs_start = ADDR(.heap) + SIZEOF(.heap));
/* Check if data + heap exceeds RAM1 limit */
ASSERT((ORIGIN(SRAM1)+LENGTH(SRAM1)) >= __HeapLimit, "SRAM1 overflow")
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
*(.stack*)
} > SRAM2
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(SRAM2) + LENGTH(SRAM2);
_estack = __StackTop;
__StackLimit = __StackTop - STACK_SIZE;
PROVIDE(__stack = __StackTop);
/* Check if stack exceeds RAM2 limit */
ASSERT((ORIGIN(SRAM2)+LENGTH(SRAM2)) >= __StackLimit, "SRAM2 overflow")
/* Check if heap exceeds SRAM1 */
ASSERT(__HeapLimit <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "Heap is too big for SRAM1")
}

View File

@ -104,7 +104,36 @@ SECTIONS
. += M_CRASH_DATA_RAM_SIZE;
. = ALIGN(8);
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
} > SRAM1
} > SRAM2
/* .stack section doesn't contains any symbols. It is only
* used for linker to reserve space for the isr stack section
* WARNING: .stack should come immediately after the last secure memory
* section. This provides stack overflow detection. */
.stack (NOLOAD):
{
__StackLimit = .;
*(.stack*);
. += STACK_SIZE - (. - __StackLimit);
} > SRAM2
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ADDR(.stack) + SIZEOF(.stack);
_estack = __StackTop;
__StackLimit = ADDR(.stack);
PROVIDE(__stack = __StackTop);
/* Place holder for additional heap */
.heap_0 (COPY):
{
__mbed_sbrk_start_0 = .;
. += (ORIGIN(SRAM2) + LENGTH(SRAM2) - .);
__mbed_krbs_start_0 = .;
} > SRAM2
/* Check if heap exceeds SRAM2 */
ASSERT(__mbed_krbs_start_0 <= (ORIGIN(SRAM2)+LENGTH(SRAM2)), "Heap is too big for SRAM2")
.data : AT (__etext)
{
@ -126,7 +155,6 @@ SECTIONS
KEEP(*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(8);
/* finit data */
PROVIDE_HIDDEN (__fini_array_start = .);
@ -142,6 +170,9 @@ SECTIONS
} > SRAM1
/* Check if bss exceeds SRAM1 */
ASSERT(__data_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), ".data is too big for SRAM1")
.bss :
{
. = ALIGN(8);
@ -154,34 +185,21 @@ SECTIONS
_ebss = .;
} > SRAM1
/* Check if bss exceeds SRAM1 */
ASSERT(__bss_end__ <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "BSS is too big for SRAM1")
/* Placeholder for default single heap */
.heap (COPY):
{
__end__ = .;
end = __end__;
__mbed_sbrk_start = .;
*(.heap*)
. += (ORIGIN(SRAM1) + LENGTH(SRAM1) - .);
__mbed_krbs_start = .;
__HeapLimit = .;
} > SRAM1
PROVIDE(__heap_size = SIZEOF(.heap));
PROVIDE(__mbed_sbrk_start = ADDR(.heap));
PROVIDE(__mbed_krbs_start = ADDR(.heap) + SIZEOF(.heap));
/* Check if data + heap exceeds RAM1 limit */
ASSERT((ORIGIN(SRAM1)+LENGTH(SRAM1)) >= __HeapLimit, "SRAM1 overflow")
/* .stack_dummy section doesn't contains any symbols. It is only
* used for linker to calculate size of stack sections, and assign
* values to stack symbols later */
.stack_dummy (COPY):
{
*(.stack*)
} > SRAM2
/* Set stack top to end of RAM, and stack limit move down by
* size of stack_dummy section */
__StackTop = ORIGIN(SRAM2) + LENGTH(SRAM2);
_estack = __StackTop;
__StackLimit = __StackTop - STACK_SIZE;
PROVIDE(__stack = __StackTop);
/* Check if stack exceeds RAM2 limit */
ASSERT((ORIGIN(SRAM2)+LENGTH(SRAM2)) >= __StackLimit, "SRAM2 overflow")
/* Check if heap exceeds SRAM1 */
ASSERT(__HeapLimit <= (ORIGIN(SRAM1)+LENGTH(SRAM1)), "Heap is too big for SRAM1")
}

View File

@ -3465,7 +3465,7 @@
"MPU"
],
"device_has_remove": ["LPTICKER"],
"macros_add": ["MBEDTLS_CONFIG_HW_SUPPORT"],
"macros_add": ["MBEDTLS_CONFIG_HW_SUPPORT", "MBED_SPLIT_HEAP"],
"device_name": "STM32L443RC",
"detect_code": ["0458"],
"bootloader_supported": true
@ -3490,7 +3490,8 @@
"detect_code": ["0765"],
"macros_add": [
"MBED_TICKLESS",
"USBHOST_OTHER"
"USBHOST_OTHER",
"MBED_SPLIT_HEAP"
],
"device_has_add": [
"ANALOGOUT",
@ -3552,7 +3553,8 @@
"macros_add": [
"MBED_TICKLESS",
"USBHOST_OTHER",
"MBEDTLS_CONFIG_HW_SUPPORT"
"MBEDTLS_CONFIG_HW_SUPPORT",
"MBED_SPLIT_HEAP"
],
"device_has_add": [
"ANALOGOUT",
@ -3587,7 +3589,8 @@
"detect_code": ["0460"],
"macros_add": [
"MBEDTLS_CONFIG_HW_SUPPORT",
"WISE_1570"
"WISE_1570",
"MBED_SPLIT_HEAP"
],
"device_has_add": [
"ANALOGOUT",
@ -4212,7 +4215,8 @@
"detect_code": ["0820"],
"macros_add": [
"MBED_TICKLESS",
"USBHOST_OTHER"
"USBHOST_OTHER",
"MBED_SPLIT_HEAP"
],
"device_has_add": [
"ANALOGOUT",
@ -4227,7 +4231,7 @@
"device_name": "STM32L476VG",
"bootloader_supported": true
},
"RHOMBIO_L476DMW1K": {
"RHOMBIO_L476DMW1K": {
"components_add": ["FLASHIAP"],
"inherits": ["FAMILY_STM32"],
"core": "Cortex-M4F",
@ -4248,7 +4252,7 @@
"macros_add": [
"MBED_TICKLESS",
"USBHOST_OTHER",
"TWO_RAM_REGIONS"
"MBED_SPLIT_HEAP"
],
"device_has_add": [
"ANALOGOUT",
@ -4357,6 +4361,9 @@
"FLASH",
"MPU"
],
"macros_add": [
"MBED_SPLIT_HEAP"
],
"release_versions": ["2", "5"],
"device_name": "STM32L471QG",
"bootloader_supported": true