diff --git a/cmsis/device/rtos/TOOLCHAIN_GCC_ARM/mbed_boot_gcc_arm.c b/cmsis/device/rtos/TOOLCHAIN_GCC_ARM/mbed_boot_gcc_arm.c index 48a34f7540c..edf5a2d0f56 100644 --- a/cmsis/device/rtos/TOOLCHAIN_GCC_ARM/mbed_boot_gcc_arm.c +++ b/cmsis/device/rtos/TOOLCHAIN_GCC_ARM/mbed_boot_gcc_arm.c @@ -60,9 +60,13 @@ void software_init_hook(void) mbed_heap_size = (uint32_t) &__mbed_krbs_start - (uint32_t) &__mbed_sbrk_start; mbed_heap_start_0 = (unsigned char *) &__mbed_sbrk_start_0; mbed_heap_size_0 = (uint32_t) &__mbed_krbs_start_0 - (uint32_t) &__mbed_sbrk_start_0; + + mbed_heap_size_total = mbed_heap_size + mbed_heap_size_0; #else mbed_heap_start = (unsigned char *) &__end__; mbed_heap_size = (uint32_t) &__HeapLimit - (uint32_t) &__end__; + + mbed_heap_size_total = mbed_heap_size; #endif mbed_init(); diff --git a/cmsis/device/rtos/include/mbed_boot.h b/cmsis/device/rtos/include/mbed_boot.h index a7411086d8d..6594512543b 100644 --- a/cmsis/device/rtos/include/mbed_boot.h +++ b/cmsis/device/rtos/include/mbed_boot.h @@ -57,6 +57,7 @@ extern "C" { /* Heap limits - only used if set */ extern unsigned char *mbed_heap_start; extern uint32_t mbed_heap_size; +extern uint32_t mbed_heap_size_total; #if defined(MBED_SPLIT_HEAP) extern unsigned char *mbed_heap_start_0; diff --git a/platform/source/mbed_alloc_wrappers.cpp b/platform/source/mbed_alloc_wrappers.cpp index f9c625aac59..c810a91864f 100644 --- a/platform/source/mbed_alloc_wrappers.cpp +++ b/platform/source/mbed_alloc_wrappers.cpp @@ -73,8 +73,8 @@ static int get_malloc_block_total_size(void *ptr) void mbed_stats_heap_get(mbed_stats_heap_t *stats) { #if MBED_HEAP_STATS_ENABLED - extern uint32_t mbed_heap_size; - heap_stats.reserved_size = mbed_heap_size; + extern uint32_t mbed_heap_size_total; + heap_stats.reserved_size = mbed_heap_size_total; malloc_stats_mutex->lock(); memcpy(stats, &heap_stats, sizeof(mbed_stats_heap_t)); diff --git a/platform/source/mbed_retarget.cpp b/platform/source/mbed_retarget.cpp index e9395638291..e9aebf0d64e 100644 --- a/platform/source/mbed_retarget.cpp +++ b/platform/source/mbed_retarget.cpp @@ -119,6 +119,7 @@ extern const char __stderr_name[] = "/stderr"; unsigned char *mbed_heap_start = 0; uint32_t mbed_heap_size = 0; +uint32_t mbed_heap_size_total = 0; #if defined(MBED_SPLIT_HEAP) unsigned char *mbed_heap_start_0 = 0; diff --git a/platform/source/mbed_sdk_boot.c b/platform/source/mbed_sdk_boot.c index 0ddac07a404..d4754e1ec62 100644 --- a/platform/source/mbed_sdk_boot.c +++ b/platform/source/mbed_sdk_boot.c @@ -174,9 +174,13 @@ void software_init_hook(void) mbed_heap_size = (uint32_t) &__mbed_krbs_start - (uint32_t) &__mbed_sbrk_start; mbed_heap_start_0 = (unsigned char *) &__mbed_sbrk_start_0; mbed_heap_size_0 = (uint32_t) &__mbed_krbs_start_0 - (uint32_t) &__mbed_sbrk_start_0; + + mbed_heap_size_total = mbed_heap_size + mbed_heap_size_0; #else mbed_heap_start = (unsigned char *) &__end__; mbed_heap_size = (uint32_t) &__HeapLimit - (uint32_t) &__end__; + + mbed_heap_size_total = mbed_heap_size; #endif mbed_init();