So I have a ESP32 project that I am working on and it uses a ESP32 S3 Part # ESP32-S3R8. This device has a PSRAM of 8 MB built into it. Also I have added 16 MB of external flash on it as well. Here is the schematic:

Problem 1 – PSRAM Pins
So, I would like to state the importance to ignore the following pins on this S3 schematic as this was the first mistake I made when I attempted to build this board. Cannot use 33-37 pins as it is used by internal PSRAM. I found this out and it was throwing an initialization error. I do not have the error right now but on init it was indicating it could not initalize the PSRAM. After, removing the above mentioned pins from use I no longer receive that message. Finally, problem 1 solved and unfortunately it required me to build another revision of the board.
Problem 2 – Platform IO Initialization
Below is what I added to Platform IO platformio.ini parameters I added.
board_build.arduino.memory_type = qio_opi
build_flags =
${common.build_flags}
-D BOARD_ESP32_S3_WROOM
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
-mfix-esp32-psram-cache-strategy=memwProblem 3 – Now to Initialize in Code and Use PSRAM
Next, I had to figure out how to use PSRAM. Ok, so this is where I am at with that option at this point.
psramInit and Do it in new operator
Below, is the code to get this working. It seems to be but I am still figuring it out.
#include "esp32-hal-psram.h"
bool psramInited = false;
bool serialInited = false;
// Override global new and delete operators
void* operator new(size_t size) {
if(!serialInited){
Serial.begin(115200);
serialInited = true;
}
if(!psramInited){
if( psramInit()){
psramInited = true;
Serial.println("PSRAM intiated!!!");
}else{
Serial.println("PSRAM Failed!!!");
}
}
if(psramInited){
void* ptr = ps_malloc(size); // Use ps_malloc
if (!ptr) {
// Handle allocation failure if necessary
#ifdef ARDUINO
ets_printf("ps_malloc failed\n");
#else
abort();
#endif
}
return ptr;
}
void* ptr = malloc(size); // Use ps_malloc
if (!ptr) {
// Handle allocation failure if necessary
#ifdef ARDUINO
ets_printf("malloc failed\n");
#else
abort();
#endif
}
}
void operator delete(void* ptr) noexcept {
free(ptr);
}
// ... (also override new[] and delete[] for arrays)
void* operator new[](size_t size) {
return operator new(size);
}
void operator delete[](void* ptr) noexcept {
operator delete(ptr);
}
In this code, it is possible to see that I have added boolean that starts serial and then inits PSRAM. I did the serial thing so I can debug this thing. So far so good, it works for now but I am not sure it is really using the memory like I expect it.
const float MB_MULTIPLIER = 1.0/(1024.0*1024.0);
// respond to GET requests on URL /heap
server.on("/heap", HTTP_GET, [](AsyncWebServerRequest *request)
{
String json = "{";
json += "\"free heap\":" + String(ESP.getFreeHeap());
json += ",\"free psram MB\":" + String(ESP.getFreePsram() * MB_MULTIPLIER);
json += ",\"used psram MB\":" + String((ESP.getPsramSize() - ESP.getFreePsram()) * MB_MULTIPLIER);
json += "}";
request->send(200, "application/json", json);
json = String();
});This is showing the following:
{
"free heap": 270880,
"free psram MB": 7.97,
"used psram MB": 0.02
}Well, it appears to be using some PSRAM but I expected more memory used than that 0.02 MB mentioned but maybe that is true. More to follow on this PSRAM and ESP32 on PlatformIO. There is a lot of stuff I am learning on this code right now.
BTW Here is the board:

More to come? Its up to you!!!
This is the initial article on this topic. If I get feedback that this is useful I will make it a series that covers code, schematic, and PCB design related to this project. Interest is key, if there is interest in this topic I will expand the topic further. If there are no comments then I feel nobody cares about this topic! So, please let me know!!!

