Skip to content

Commit 9d1ce66

Browse files
author
deepikabhavnani
committed
ISR_STACK_START/ HEAP_START defines not used by GCC_ARM toolchain
1 parent 9ed7e4d commit 9d1ce66

File tree

2 files changed

+8
-26
lines changed

2 files changed

+8
-26
lines changed

platform/mbed_retarget.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,15 +1241,8 @@ extern "C" WEAK void __cxa_pure_virtual(void)
12411241
// SP. This make it compatible with RTX RTOS thread stacks.
12421242
#if defined(TOOLCHAIN_GCC_ARM)
12431243

1244-
#if !defined(HEAP_START)
1245-
/* Defined by linker script */
12461244
extern "C" uint32_t __end__;
12471245
extern "C" uint32_t __HeapLimit;
1248-
#define HEAP_START __end__
1249-
#define HEAP_LIMIT __HeapLimit
1250-
#else
1251-
#define HEAP_LIMIT ((uint32_t)(HEAP_START + HEAP_SIZE))
1252-
#endif
12531246

12541247
// Turn off the errno macro and use actual global variable instead.
12551248
#undef errno
@@ -1258,12 +1251,12 @@ extern "C" int errno;
12581251
// Weak attribute allows user to override, e.g. to use external RAM for dynamic memory.
12591252
extern "C" WEAK caddr_t _sbrk(int incr)
12601253
{
1261-
static unsigned char *heap = (unsigned char *) &HEAP_START;
1254+
static unsigned char *heap = (unsigned char *) &__end__;
12621255
unsigned char *prev_heap = heap;
12631256
unsigned char *new_heap = heap + incr;
12641257

12651258
/* __HeapLimit is end of heap section */
1266-
if (new_heap >= (unsigned char *) &HEAP_LIMIT) {
1259+
if (new_heap >= (unsigned char *) &__HeapLimit) {
12671260
errno = ENOMEM;
12681261
return (caddr_t) -1;
12691262
}

rtos/TARGET_CORTEX/TOOLCHAIN_GCC_ARM/mbed_boot_gcc_arm.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,10 @@ static osMutexId_t env_mutex_id;
2929
static mbed_rtos_storage_mutex_t env_mutex_obj;
3030
static osMutexAttr_t env_mutex_attr;
3131

32-
#if !defined(ISR_STACK_SIZE)
33-
extern uint32_t __StackLimit;
34-
extern uint32_t __StackTop;
35-
#define ISR_STACK_START __StackLimit
36-
#define ISR_STACK_SIZE ((uint32_t)((uint32_t)__StackTop - (uint32_t)__StackLimit))
37-
#endif
38-
39-
#if !defined(HEAP_START)
40-
/* Defined by linker script */
32+
extern uint32_t __StackLimit;
33+
extern uint32_t __StackTop;
4134
extern uint32_t __end__;
4235
extern uint32_t __HeapLimit;
43-
#define HEAP_START __end__
44-
#define HEAP_LIMIT __HeapLimit
45-
#define HEAP_SIZE ((uint32_t)((uint32_t)HEAP_LIMIT - (uint32_t)HEAP_START))
46-
#endif
4736

4837
extern void __libc_init_array(void);
4938

@@ -54,10 +43,10 @@ extern void __libc_init_array(void);
5443
*/
5544
void software_init_hook(void)
5645
{
57-
mbed_stack_isr_start = (unsigned char *)ISR_STACK_START;
58-
mbed_stack_isr_size = (uint32_t) ISR_STACK_SIZE;
59-
mbed_heap_start = (unsigned char *) HEAP_START;
60-
mbed_heap_size = (uint32_t) HEAP_SIZE;
46+
mbed_stack_isr_start = (unsigned char *) &__StackLimit;
47+
mbed_stack_isr_size = ((uint32_t)((uint32_t) &__StackTop - (uint32_t) &__StackLimit));
48+
mbed_heap_start = (unsigned char *) &__end__;
49+
mbed_heap_size = ((uint32_t)((uint32_t) &__HeapLimit - (uint32_t) &__end__));
6150

6251
mbed_init();
6352
mbed_rtos_start();

0 commit comments

Comments
 (0)