File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -534,14 +534,20 @@ extern uint32_t __end__[];
534
534
#define HEAP_START (__end__)
535
535
#elif defined(__ICCARM__ )
536
536
#pragma section="HEAP"
537
- #define HEAP_START (void *)__section_begin ("HEAP")
537
+ #define HEAP_END (void *)__section_end ("HEAP")
538
538
#endif
539
539
540
540
void set_main_stack (void ) {
541
541
uint32_t interrupt_stack_size = ((uint32_t )OS_MAINSTKSIZE * 4 );
542
+ #if defined(__ICCARM__ )
543
+ /* For IAR heap is defined .icf file */
544
+ uint32_t main_stack_size = ((uint32_t )INITIAL_SP - (uint32_t )HEAP_END ) - interrupt_stack_size ;
545
+ #else
546
+ /* For ARM , uARM, or GCC_ARM , heap can grow and reach main stack */
542
547
uint32_t heap_plus_stack_size = ((uint32_t )INITIAL_SP - (uint32_t )HEAP_START ) - interrupt_stack_size ;
543
548
// Main thread's stack is 1/4 of the heap
544
- uint32_t main_stack_size = heap_plus_stack_size / 4 ;
549
+ uint32_t main_stack_size = heap_plus_stack_size /4 ;
550
+ #endif
545
551
// The main thread must be 4 byte aligned
546
552
uint32_t main_stack_start = ((uint32_t )INITIAL_SP - interrupt_stack_size - main_stack_size ) & ~0x7 ;
547
553
You can’t perform that action at this time.
0 commit comments