PlatformIO Community

ESP32 WROVER Platform RAM size

@ivankravets & @valeros; Is it possible to push this feature?

The possibility to enable additional RAM would be great and probably widely valued.

best regards, Reza Anwar

Sure, we wait for the final release of ESP-IDF 3.0.

Thanks for taking the time to crate that tutorial!

Hello - I’m new here and have been struggling trying to understand how to enable psRAM on a WEMOS WROVER board using PlatformIO IDE with VSCode on either Mac or Linux.

If I build the esp-idf from GitHub in a terminal on my Linux box (independent of using VSCode and PlatformIO-IDE
I can get the new menuconfig options to enable psRAM but I don’t understand how to get PlatformIO-IDE to integrate the newer esp-idf.

I have read this thread, but it seems as if the PlatformIO Team has not yet updated to the newer version

Does anyone here know if/when this will be happening? Thank you!!

Does Pre-release 3.0-rc1count?
I wonder if it would be a good feature (unless I missed it if you have it already) to allow us to select what version to use.

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? https://github.com/platformio/platform-espressif32/blob/develop/boards/esp-wrover-kit.json

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: https://github.com/platformio/platform-espressif32/pull/110

@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 = https://github.com/platformio/platform-espressif32.git#feature/stage
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.