Description
We are currently developing a platform using the STM32L151CC processor - 32kB of RAM and 256kB of flash. We added platform support to mbed 2.0 during the transition to 5.x and are now adding support to 5.x so we can make a pull request and have our platform enabled.
We've noticed significantly higher memory consumption in mbed 5.x vs mbed 2.0. This is a problem for us because our application (an AT parser and a LoRa stack) currently can't run due to the system running out of memory during initialization.
We've done some testing with a similar platform to ours, NUCLEO-L152RE. We took the same main.cpp and built it with mbed-os revision 2244, mbed 125 & rtos 121, and mbed 121 & rtos 117. All of these builds were using the mbed online compiler. The main from the app is below:
#include "mbed.h"
#include "rtos.h" // only in the mbed 2.0 version
void func(void const*) {
while (true) {
osDelay(100);
}
}
int main() {
uint8_t* mem_buf = NULL;
uint32_t mem_size = 0;
Thread t(func);
while (true) {
// malloc until we die
mem_buf = new uint8_t[256];
if (! mem_buf) {
printf("malloc failed: %lu\r\n", mem_size);
} else {
mem_size += 256;
printf("%lu\r\n", mem_size);
}
}
}
Our results are as follows:
with mbed revision 121 mbed-rtos revision 117
binary size: 20kB
free memory: 74752
with mbed revision 125 mbed-rtos revision 121
binary size: 29K
free memory: 66816
with mbed-os revision 2244
binary size: 37kB
free memory: 65792
When I compile our LoRa stack (offline) for our new platform with mbed 2.0, I'm able to allocate over 13kB before the system runs out of memory. When I compile (offline) with mbed 5.1, I'm only able to allocate 2kB.
I'm hoping there are some switches in mbed 5.x that I can flip to reduce memory consumption. Reducing the consumption of our application and stack will be time-consuming and is considered a last resort.
Any ideas or insight appreciated.