Skip to content

Commit 1af4d8b

Browse files
committed
TARGET_Arm_SSG: ISR stack size unification
Unify ISR stack size for targets which support MBED 5 (or MBED 2 and MBED 5). MBED 5 : 0 boards ---------------- MBED 2, 5 : 2 boards ---------------- ARM_CM3DS_MPS2 ARM_BEETLE_SOC MBED 2 : 6 boards (skipped) ---------------- ARM_MPS2_M0 ARM_MPS2_M3 ARM_MPS2_M4 ARM_MPS2_M7 ARM_MPS2_M0P ARM_IOTSS_BEID
1 parent af20945 commit 1af4d8b

File tree

8 files changed

+74
-14
lines changed

8 files changed

+74
-14
lines changed

targets/TARGET_ARM_SSG/TARGET_BEETLE/device/TOOLCHAIN_ARM_STD/BEETLE.sct

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#! armcc -E
2+
#include "mbed_config.h"
3+
14
;/*
25
; * BEETLE CMSIS Library
36
; */
@@ -22,6 +25,16 @@
2225
; *** Scatter-Loading Description File ***
2326
; *************************************************************
2427

28+
#if (defined(__stack_size__))
29+
#define Stack_Size __stack_size__
30+
#else
31+
#if (defined(MBED_CONF_RTOS_PRESENT))
32+
#define Stack_Size 0x0400
33+
#else
34+
#define Stack_Size 0x1000
35+
#endif
36+
#endif
37+
2538
LR_IROM1 0x00000000 0x00040000 { ; load region size_region
2639
ER_IROM1 0x00000000 0x00040000 { ; load address = execution address
2740
*.o (RESET, +FIRST)
@@ -30,7 +43,10 @@ LR_IROM1 0x00000000 0x00040000 { ; load region size_region
3043
CORDIO_RO_2.1.o (*)
3144
}
3245
; Total: 80 vectors = 320 bytes (0x140) to be reserved in RAM
33-
RW_IRAM1 (0x20000000+0x140) (0x20000-0x140) { ; RW data
46+
RW_IRAM1 (0x20000000+0x140) (0x20000-0x140-Stack_Size) { ; RW data
3447
.ANY (+RW +ZI)
3548
}
49+
50+
ARM_LIB_STACK (0x20000000 + 0x20000) EMPTY -Stack_Size { ; Stack region growing down
51+
}
3652
}

targets/TARGET_ARM_SSG/TARGET_BEETLE/device/TOOLCHAIN_GCC_ARM/BEETLE.ld

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ MEMORY
5959
*/
6060
ENTRY(Reset_Handler)
6161

62-
/* Heap 1/4 of ram and stack 1/8 */
63-
__stack_size__ = 0x4000;
64-
__heap_size__ = 0x8000;
65-
6662
HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0400;
6763
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
6864

@@ -202,11 +198,17 @@ SECTIONS
202198
__end__ = .;
203199
PROVIDE(end = .);
204200
__HeapBase = .;
205-
. += HEAP_SIZE;
201+
. = ORIGIN(RAM) + LENGTH(RAM) - Stack_Size;
206202
__HeapLimit = .;
207203
__heap_limit = .; /* Add for _sbrk */
208204
} > RAM
209205

206+
.stack_dummy :
207+
{
208+
*(.stack)
209+
. += Stack_Size;
210+
} > RAM
211+
210212
/* Set stack top to end of RAM, and stack limit move down by
211213
* size of stack_dummy section */
212214
__StackTop = ORIGIN(RAM) + LENGTH(RAM);

targets/TARGET_ARM_SSG/TARGET_BEETLE/device/TOOLCHAIN_GCC_ARM/startup_BEETLE.S

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@
2424
.syntax unified
2525
.arch armv7-m
2626

27+
.section .stack
28+
.align 3
29+
#ifdef __STACK_SIZE
30+
.equ Stack_Size, __STACK_SIZE
31+
#else
32+
#if defined(MBED_CONF_RTOS_PRESENT)
33+
.equ Stack_Size, 0x400
34+
#else
35+
.equ Stack_Size, 0x1000
36+
#endif
37+
#endif
38+
.globl Stack_Size
39+
2740
.section .vector_table,"a",%progbits
2841
.align 2
2942
.globl __isr_vector

targets/TARGET_ARM_SSG/TARGET_BEETLE/device/TOOLCHAIN_IAR/BEETLE.icf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ define symbol __ICFEDIT_region_RAM_start__ = 0x20000140;
3030
define symbol __ICFEDIT_region_RAM_end__ = 0x2001FFFF;
3131
/*-Sizes-*/
3232
/* Heap and Stack size */
33-
define symbol __ICFEDIT_size_cstack__ = 0x1000;
33+
define symbol __ICFEDIT_size_cstack__ = 0x400;
3434
define symbol __ICFEDIT_size_heap__ = 0x4000;
3535
/**** End of ICF editor section. ###ICF###*/
3636

targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/device/TOOLCHAIN_ARM_STD/MPS2.sct

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#! armcc -E
2+
#include "mbed_config.h"
23

34
/*
45
* MPS2 CMSIS Library
@@ -29,6 +30,16 @@
2930
#include "../memory_zones.h"
3031
#include "../cmsis_nvic.h"
3132

33+
#if (defined(__stack_size__))
34+
#define Stack_Size __stack_size__
35+
#else
36+
#if (defined(MBED_CONF_RTOS_PRESENT))
37+
#define Stack_Size 0x0400
38+
#else
39+
#define Stack_Size 0x1000
40+
#endif
41+
#endif
42+
3243
; The vector table is loaded at address 0x00000000 in Flash memory region.
3344
LR_IROM1 FLASH_START FLASH_SIZE {
3445
ER_IROM1 FLASH_START FLASH_SIZE {
@@ -44,8 +55,10 @@ LR_IROM2 ZBT_SSRAM1_START ZBT_SSRAM1_SIZE {
4455
}
4556
; At execution, RAM is set to be in ZBT SSRAM2 and 3, just after the vector
4657
; table previously moved from Flash.
47-
RW_IRAM1 (ZBT_SSRAM23_START + NVIC_VECTORS_SIZE) (ZBT_SSRAM23_SIZE - NVIC_VECTORS_SIZE) {
58+
RW_IRAM1 (ZBT_SSRAM23_START + NVIC_VECTORS_SIZE) (ZBT_SSRAM23_SIZE - NVIC_VECTORS_SIZE - Stack_Size) {
4859
.ANY (+RW +ZI)
4960
}
61+
ARM_LIB_STACK (ZBT_SSRAM23_START + ZBT_SSRAM23_SIZE) EMPTY -Stack_Size { ; Stack region growing down
62+
}
5063
}
5164

targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/device/TOOLCHAIN_GCC_ARM/MPS2.ld

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ MEMORY
6060
*/
6161
ENTRY(Reset_Handler)
6262

63-
HEAP_SIZE = 0x4000;
64-
STACK_SIZE = 0x1000;
65-
6663
/* Size of the vector table in SRAM */
6764
M_VECTOR_RAM_SIZE = NVIC_VECTORS_SIZE;
6865

@@ -192,15 +189,21 @@ SECTIONS
192189
__end__ = .;
193190
PROVIDE(end = .);
194191
__HeapBase = .;
195-
. += HEAP_SIZE;
192+
. = ORIGIN(RAM) + LENGTH(RAM) - Stack_Size;
196193
__HeapLimit = .;
197194
__heap_limit = .; /* Add for _sbrk */
198195
} > RAM
199196

197+
.stack_dummy :
198+
{
199+
*(.stack)
200+
. += Stack_Size;
201+
} > RAM
202+
200203
/* Set stack top to end of RAM, and stack limit move down by
201204
* size of stack_dummy section */
202205
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
203-
__StackLimit = __StackTop - STACK_SIZE;
206+
__StackLimit = __StackTop - Stack_Size;
204207
PROVIDE(__stack = __StackTop);
205208

206209
/* Check if data + heap + stack exceeds RAM limit */

targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/device/TOOLCHAIN_GCC_ARM/startup_MPS2.S

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@
2424
.syntax unified
2525
.arch armv7-m
2626

27+
.section .stack
28+
.align 3
29+
#ifdef __STACK_SIZE
30+
.equ Stack_Size, __STACK_SIZE
31+
#else
32+
#if defined(MBED_CONF_RTOS_PRESENT)
33+
.equ Stack_Size, 0x400
34+
#else
35+
.equ Stack_Size, 0x1000
36+
#endif
37+
#endif
38+
.globl Stack_Size
39+
2740
.section .vector_table,"a",%progbits
2841
.align 2
2942
.globl __isr_vector

targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/device/TOOLCHAIN_IAR/MPS2.icf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ define symbol __ICFEDIT_region_RAM_end__ = ZBT_SSRAM23_START + ZBT_SSRAM23_
5858
/* Sizes */
5959
/* Heap and Stack size */
6060
define symbol __ICFEDIT_size_heap__ = 0xF000;
61-
define symbol __ICFEDIT_size_cstack__ = 0x1000;
61+
define symbol __ICFEDIT_size_cstack__ = 0x400;
6262

6363
define memory mem with size = 4G;
6464
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];

0 commit comments

Comments
 (0)