ESP32 WROVER Platform RAM size

Any news here? Is it possible to access external PSRAM on Arduino Framework with platform Espressif 1.0.2?

What should be done from our side? How does it work Arduino IDE?

It’s done already. After last upgrade of arduino-espressif32 core v1.0.3 -> v1.1.0 PSRAM is automatically detected and enabled.by the ESP32 core.

Is this valid for the esp8266 chip as well?

Thanks @cyberman54 for pointing out that it’s done!

I just tried it and it works! But we do need to add a build flag to get it enabled.

build_flags = -DBOARD_HAS_PSRAM
platform = https://github.com/platformio/platform-espressif32.git#feature/stage
framework = arduino
board = esp32dev

This worked, the ESP.getFreeHeap() function reports over 4 MB of free ram which is expected (internal RAM + external RAM).

@ivankravets you might want to define a new board for esp32wrover. In this other thread you told people to use esp32dev but they will not get the RAM automatically.

For your reference, this is the commit that added support for that extra RAM in the esp32 arduino framework:

You can see that they edit the boards.txt file to pass the define flag:

esp32wrover.build.defines=-DBOARD_HAS_PSRAM
1 Like

@mrred128 this is only for esp32. I do not think the esp8266 supports external RAM.

It works on TTGO T-Beam without the build option “BOARD_HAS_PSRAM”.

But we have it? platform-espressif32/boards/esp-wrover-kit.json at develop · platformio/platform-espressif32 · GitHub

Right - I had not seen this. So without the build_flag the extra 4MB are not visible. With the build flags they are. I guess you just need to add -DBOARD_HAS_PSRAM in this file.

I just made a PR and confirmed that it works on the WROVER-KIT: add psram build flag for wrover kit by sarfata · Pull Request #110 · platformio/platform-espressif32 · GitHub

@cyberman54: Which board are you using in your platformio.ini flag?

For anyone else watching, if you want to use the memory, you need to call ps_malloc(). The default malloc() does not allocate from PSRAM.

I did not use the build flag, but i get the 4MB with ESP.getFreeHeap()).
I am using a std:set container in RAM, and can see with ESP.getFreeHeap()) that the 4MB is shrinking when i fill up the std::set. Did not use any malloc() or ps_malloc(). Seems to work without. Board = esp32dev

1 Like

what is std:set? Where do I read about it, how would I use it? I find very few std references online and non specific to set.

Not quite sure what you were searching for then, as the first two results for std::set are both the standard C++ reference sites. This is probably the easier to understand info on it… http://www.cplusplus.com/reference/set/set/

@pfeerrick
Thank you. I am trying to learn how to manage PSRAM. I also always like to at least have an idea of what any new code pattern I run across. Google did not find anything I understood. The site you supplied at least show what context sdt:set belongs to. While I have stumbled across templates, I have never understood why I need them, so I have not forced myself to learn them. I have tried to find a simple tutorial that would be “ease” me into it. But everything I find is very complex, so I just work around it. I’m sure when I get stuck somewhere, I will sit down and commit the time. Thanks again.

1 Like

Yeah, unfortunately a lot of the reference sites jump in too quickly… like a textbook on the topic, they expect you to have read everything prior, so start off at a high level. Questions on sites like stackexchange are often a good start - ie. “c++ why use templates?”.

Templates are a way to write code that is class/variable type agnostic, but this probably the best explanation I’ve come across:

Templates are a simple way to save yourself on copy/paste code & then edit it.

template<class T>
T Max(const T& a, const T& b){ return (a>b)?a:b: }

Will work with int,double,string, and anything else which supports the > symbol.

Yes, you could do it with a macro, but a lot of more complex template examples cannot reasonably be done so.

btw, all the C++ container classes (vector, list, map) are all templated.

I am using WROVER, I did follow the advice here and configured PIO.init
build_flags = -DBOARD_HAS_PSRAM
platform = GitHub - platformio/platform-espressif32: Espressif 32: development platform for PlatformIO
framework = arduino
board = esp32dev
I have the most ESP.getMinFreeHeap() return was 32K and when I start WIFI, ESP.getMinFreeHeap() drop to 17K. I running real low on heap and I have not managed to see 4MB heap coming from the PSRAM… what I am missing? I was encouraged to see some they managed to get 4MB RAM.

I have an ESP32-SE-WROOM-1 with OPI PSRAM and 16MB flash. I had success on Arduino IDE using this board with an RGB display. But I still can’t put this to work on PlatformIO. I think is some trouble with the PSRAM… I got this error message:
E (145) cpu_start: Octal Flash option selected, but EFUSE not configured!
Can anyone help me? Please?