Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[request] getFreeHeap() function is missing in the API #82

Open
lyusupov opened this issue Aug 27, 2024 · 0 comments
Open

[request] getFreeHeap() function is missing in the API #82

lyusupov opened this issue Aug 27, 2024 · 0 comments
Labels
featurerequest Feature request

Comments

@lyusupov
Copy link

lyusupov commented Aug 27, 2024

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:

image

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 ?

@lyusupov lyusupov added the featurerequest Feature request label Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
featurerequest Feature request
Projects
None yet
Development

No branches or pull requests

1 participant