Page 1 of 1

ESP32 S2 PSRAM

Posted: Tue Jan 10, 2023 6:19 am
by kcchang61
Hi!

I'm using LOLIN S2 Mini, it support 2MB PSRAM.
In Arduino IDE, PSRAM is automatically enabled by board.txt file even PSRAM menu does not exist.

But, I could not initialize PSRAM and found any PSRAM area like this. How can I solve this problem?

Code: Select all

#define SERIAL_PRINTF_MAX_BUFF      256

void serialPrintf(const char *fmt, ...) {
  char buff[SERIAL_PRINTF_MAX_BUFF];
  va_list pargs;
  va_start(pargs, fmt);
  vsnprintf(buff, SERIAL_PRINTF_MAX_BUFF, fmt, pargs);
  va_end(pargs);
  Serial.print(buff);
}

void setup() {
  Serial.begin(115200);
  delay(3000);      // for Serial Display
  
  if (psramInit())
    serialPrintf("PSRAM init OK\n");
  else
    serialPrintf("PSRAM init NG\n");

  serialPrintf("Total RAM: %d, Free RAM: %d\n", ESP.getHeapSize(), ESP.getFreeHeap());
  serialPrintf("Total PSRAM: %d, Free PSRAM: %d\n", ESP.getPsramSize(), ESP.getFreePsram());

}

void loop() {
}
PSRAM init NG
Total RAM: 240820, Free RAM: 214684
Total PSRAM: 0, Free PSRAM: 0