ESP-IDF : Using External RAM present in ESP32 WROVER module
|The standard ESP32 module (ESP-WROOM-32) present in the market has 512KB SRAM. For most the applications this RAM is more than sufficient. In fact it is nearly 4 times of what we get on ESP8266. There might be cases where you need more RAM to buffer data from a server or run complex calculations on large amount data you have collected from sensors. Recently I came across a similar situation where I had to store 1 MB of data in RAM, little research showed that ESP32 supports external SPI RAM (PSRAM) of 4 MB and whats more, Espressif sells a module named WROVER with this external RAM (WROVER is basically WROOM with external RAM). The ESP-WROVER-KIT V3 has this module on board.
In this post we will see how to use/enable the external ram present in the WROVER module.
We can use the external RAM present in WROVER module in three modes.
you can select the mode of operation by using menuconfig, to start the menuconfig app run the following cmd (Refer this post if you haven’t setup ESP-IDF)
make menuconfig
Using external RAM with WROVER
mode 1
Manually allocate memory in external RAM (address starting from 0x3F800000 and up)
you need to include memory management logic in your code
choose option 1 in menuconfig SPIRAM_USE_MEMMAP to enable this mode
mode 2
Initilize and add it to capability allocator , you can get memory from external ram by using a special malloc method
heap_caps_malloc(size, MALLOC_CAP_SPIRAM)
to free the memory just call free ()
this seems best method if you are developing a new application
choose option 2 in menuconfig SPIRAM_USE_CAP_ALLOC to enable this mode
mode 3
add external ram to memory pool which can be returned by standard malloc call. this way you don’t need rewrite any old applications that use malloc call to get memory
choose option 3 in menuconfig SPIRAM_USE_MALLOC to enable this mode
You need to be careful when using the external because there are some restrictions on using the external RAM
Restrictions on usage of External RAM
stack can’t be allocated on external ram (you can add exception while compiling if you are sure that the task won’t be accessing any code in ROM)
RAM can’t be access while the cache is disabled
can’t be used for DMA transactions or buffers
for more information on support for external RAM consult this page
Hi,
How to use PSRAM on ESP32-WROVER if I am using Arduino IDE instead of ESP-IDF
Hey i am using doit esp32 devoit v1 and i am getting this error in arduino IDE serial monitor
Shows on arduino serial monitor
rst:1×10(RTCWDT_RTC_RESET) , boot:0x1f(SPI_FAST_FLASH_BOOT)
flash read err,1000
ets_main.c 371
ets jun 8 2016 00:22:57
I don’t know what to do. Please let me know if you can solve this.
I am using doit esp32 devkit v1 in arduino ide and in my projeck i inserted my esp and it worked fine and afrer that i changed some pwm values and tried to upload code again and i am getting this error
Shows on arduino serial monitor
rst:1×10(RTCWDT_RTC_RESET) , boot:0x1f(SPI_FAST_FLASH_BOOT)
flash read err,1000
ets_main.c 371
ets jun 8 2016 00:22:57