ESP32, ESP32-S2, ESP32-C3 available RAM

preview_player
Показать описание
The ESP32-S2 WROOM has 208 KByte available RAM, the largest continous block is 191 KByte with Arduino IDE. The numbers for ESP32 WROOM are 235 K and 107 K. The ESP32-C3 has 312 K and 180 K. The ESP32-S2 WROVER has 2251 K and 2015 K and the ESP32 WROVER has 4328 K and 4031 K. The datasheet tells the build-in RAM. But you can only use the available RAM. I use malloc() to get memory from PSRAM or on-chip RAM.
Рекомендации по теме
Комментарии
Автор

The source code (Arduino IDE sketch):
/*
PSRAM ESP32
Tell available RAM (PSRAM, on-chip RAM)


18 Aug 2021, Andre Adrian
*/

/*
Output example (ESP32-S2 WROOM):
Free total: 230 K
malloc: 191 K allocated: 191 K
malloc: 11 K allocated: 202 K
malloc: 4 K allocated: 206 K
malloc: 1 K allocated: 207 K
malloc: 1 K allocated: 208 K
*/

// the setup function runs once when you press reset or power the board
void setup() {
Serial.begin(115200);
delay(100); // time to get serial running
char buf[100];

sprintf(buf, "Free total: %d K", (ESP.getFreeHeap() + ESP.getFreePsram()) / 1024);
Serial.println(buf);

int heap = 0;
for (int i = 0; i < 19; ++i) {
int mytry = ((ESP.getFreeHeap() + ESP.getFreePsram()) / 1024 + 1) * 1024;
for (;;) {
void *p = malloc(mytry);
if (p != NULL) {
heap += mytry;
sprintf(buf, "malloc: %d K allocated: %d K", mytry / 1024, heap / 1024);
Serial.println(buf);
}
mytry -= 1024;
if (mytry < 0) break;
}
}
}

paulfalke