diff --git a/arch/arm/src/mps/mps_allocateheap.c b/arch/arm/src/mps/mps_allocateheap.c index 78a0d34fe3e..ab838df831d 100644 --- a/arch/arm/src/mps/mps_allocateheap.c +++ b/arch/arm/src/mps/mps_allocateheap.c @@ -174,7 +174,19 @@ void up_allocate_heap(void **heap_start, size_t *heap_size) /* Return the heap settings */ *heap_start = (void *)g_idle_topstack; - *heap_size = MPS_SRAM1_START + MPS_SRAM1_SIZE - g_idle_topstack; + if (g_idle_topstack > MPS_SRAM1_START + MPS_SRAM1_SIZE) + { + /* If the range of SRAM1 is exceeded, we think that the extern REGION + * is enabled + */ + + *heap_size = PRIMARY_RAM_END - g_idle_topstack; + } + else + { + *heap_size = MPS_SRAM1_START + MPS_SRAM1_SIZE - g_idle_topstack; + } + #endif }