PlatformIO Community

Correct settings to enable external RAM on ESP32

Hi everyone!

I’m working on a project needing a large array. As it’s developed using the ESP32 platform, I need to use the external RAM available. I’ve been reading posts and tried different switches in project platformio.ini but I could’t find a way to make it work, as the variable stays in low memory.

This is my environment:

  • PlatformIO Core 5.0.4/Home 3.3.1
  • VS Code 1.52.1
  • Platform: Espressif32 2.1.0
  • Board: AZ Delivery ESP32 V4
  • Framework: ESP-IDF

I’m also unable to use menuconfig from a command window inside platformIO, so I’m wondering if there’s a way to set environment variables to make it work.

Thank you for any help and suggestion.

Paolo

You want that a variable is allocated in external RAM if you e.g. declare it globally? With what exact code and platformio.ini are you currently testing this?

You mean “doesn’t work” as in https://github.com/platformio/platform-espressif32/issues/423? There’s also a workaround in there.

Hi!

The variable is defined in a module of my project with:

static EXT_RAM_ATTR uint16_t cbuf["constant value"];

Is the “static” keeping it in regular DRAM?

My “doesn’t work” about menuconfig is that I tried different paths, but I couldn’t find the correct command not giving a “file not found” or “can’t open file”

Well foremost in order for this placement macro to work the SPIRAM needs to configured properly. If you can’t access the menuconfig that is probably not the case.

grafik

Per docs you should be able to open a PIO CLI and run pio run -t menuconfig.

grafik

grafik

Once you can open menuconfig you need to configure it as Espressif’s docs say for SPIRAM. See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/external-ram.html and https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/kconfig.html#spi-ram-config.

This is configurable through the menuconfig, too.

grafik

I included the directive
-D CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
in project build_flags with no luck. I also see the error
undefined reference to '_ext_ram_bss_end'
Are there any other flags I should include in platformio.ini? Or should i go thru menuconfig only?

I tried the above command to run menuconfig, but I have the error

Do not know how to make File target 'menuconfig'

as it was expected to have menuconfig in project folder (and it’s not there). Could it be a problem with the OS environment setup (I’m using Windows10)?

Can you show a screenshot of where you typed that in and what error occurred?

Output of that command should be like

PS C:\Users\Max\Documents\espidf_test> pio run -t menuconfig
Processing esp32dev (platform: espressif32; framework: espidf; board: esp32dev)
------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (2.1.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-espidf 3.40100.200827 (4.1.0)
 - tool-cmake 3.16.4
 - tool-esptoolpy 1.30000.201119 (3.0.0)
 - tool-idf 1.0.1
 - tool-mconf 1.4060000.20190628 (406.0.0)
 - tool-ninja 1.9.0
 - toolchain-esp32ulp 1.22851.191205 (2.28.51)
 - toolchain-xtensa32 2.80200.200827 (8.2.0)
Reading CMake configuration...
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Running menuconfig...
[0/1] cmd.exe /C "cd /D C:\Users\Max\Documents\espidf_test...utput config C:/Users/Max/Documents/espidf_test/sdkconfig" 
Loaded configuration 'C:/Users/Max/Documents/espidf_test/sdkconfig'
No changes to save (for 'C:/Users/Max/Documents/espidf_test/sdkconfig')
============================================= [SUCCESS] Took 12.25 seconds =============================================

(next to opening the menuconfig of course)

I reloaded PltaformIO and I was able to run menuconfig! First time… What I did in between was uninstalling the Espressif IDF extension I installed few days ago in trying to see if my setup was working.

I then configured my project according to documentation, and variable has been correctly placed in external RAM.

Thank you for your help!