1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-02 14:22:55 +03:00

Fix VM Address mask (#8440)

* Fix VM Address mask

Adjust VM Address mask to allow up to 8M Byte parts.
Allow for free heap size values over 64K
  ESP.getHeapStats(, uint32_t,)
  uint32_t getMaxFreeBlockSize();

* Fix example

* Update MockEsp.cpp for uint32_t on EspClass::getMaxFreeBlockSize()

* Added comment about heap size limitation and static_assert to verify.
Updated boards.txt to show correct External memory size and Heap size.
This commit is contained in:
M Hightower
2022-01-11 14:35:46 -08:00
committed by GitHub
parent 378fcfcda4
commit 9fcf14f81f
10 changed files with 178 additions and 138 deletions

View File

@ -10,11 +10,11 @@ void stats(const char* what) {
// we could use getFreeHeap() getMaxFreeBlockSize() and getHeapFragmentation()
// or all at once:
uint32_t free;
uint16_t max;
uint32_t max;
uint8_t frag;
ESP.getHeapStats(&free, &max, &frag);
Serial.printf("free: %5d - max: %5d - frag: %3d%% <- ", free, max, frag);
Serial.printf("free: %7u - max: %7u - frag: %3d%% <- ", free, max, frag);
// %s requires a malloc that could fail, using println instead:
Serial.println(what);
}
@ -109,6 +109,7 @@ void tryit(int blocksize) {
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_OFF);
delay(50);
Serial.printf("\r\nDemo Heap Metrics for DRAM\r\n");
tryit(8000);
@ -135,6 +136,26 @@ void setup() {
tryit(15);
}
#endif
#ifdef MMU_EXTERNAL_HEAP
{
HeapSelect ephemeral = HeapSelect(UMM_HEAP_EXTERNAL);
Serial.printf("\r\nDemo Heap Metrics for External RAM\r\n");
#if (MMU_EXTERNAL_HEAP > 64)
tryit(64000);
tryit(32000);
#endif
tryit(16000);
tryit(8000);
tryit(4000);
tryit(2000);
tryit(1000);
tryit(500);
tryit(200);
tryit(100);
tryit(50);
tryit(15);
}
#endif
}
void loop() {

View File

@ -592,7 +592,7 @@ void setup() {
size_t free_iram = ESP.getFreeHeap();
ETS_PRINTF("IRAM free: %6d\n", free_iram);
uint32_t hfree;
uint16_t hmax;
uint32_t hmax;
uint8_t hfrag;
ESP.getHeapStats(&hfree, &hmax, &hfrag);
ETS_PRINTF("ESP.getHeapStats(free: %u, max: %u, frag: %u)\n",