Open
Description
Hardware
BGM220
Core version
2.1.0
Arduino IDE version
any
Operating system
any
Radio stack variant
No radio
OpenThread Border Router device (if using Matter)
none
Issue description
Current version of the API does not contain a function that would return a free heap size:

If I'll try to use classic ARM GCC or FreeRTOS approach - the free heap return values are not realistic.
This is a test sketch:
extern "C" void * _sbrk (int);
static uint32_t ARM_getFreeHeap()
{
char top;
return &top - reinterpret_cast<char*>(_sbrk(0));
}
void setup()
{
Serial.begin(38400);
Serial.print("Free Heap #1 = "); Serial.println(ARM_getFreeHeap());
Serial.println();
HeapStats_t HeapStats;
vPortGetHeapStats(&HeapStats);
Serial.println("Heap Stats:");
Serial.println(HeapStats.xAvailableHeapSpaceInBytes);
Serial.println(HeapStats.xSizeOfLargestFreeBlockInBytes);
Serial.println(HeapStats.xSizeOfSmallestFreeBlockInBytes);
Serial.println(HeapStats.xNumberOfFreeBlocks);
Serial.println(HeapStats.xMinimumEverFreeBytesRemaining);
Serial.println(HeapStats.xNumberOfSuccessfulAllocations);
Serial.println(HeapStats.xNumberOfSuccessfulFrees);
Serial.flush();
}
void loop()
{
}
And this is the output:
Free Heap #1 = 4294956124
Heap Stats:
0
0
4294967295
0
0
0
0
The output above indicates that neither sbrk() nor FreeRTOS methods work properly.
The request is:
Could you, please, provide an API function that would return the free heap size ?