ESP32 DRAM usage


Developing an application, I set up the environments in PlatformIo to develop simulator and ESP32 target side by side. I set up these environments following the instructions, and I can compile both. Unfortunately compiling the target I get into the dram0_0_seg overflow. I added the build flags CONFIG_ESP32_SPIRAM_SUPPORT and CONFIG_SPIRAM_CACHE_WORKAROUND but still the compiler uses DRAM too much. Are there guidelines/switches to efficiently use ESP-IDF framework with lvgl?

What MCU/Processor/Board and compiler are you using?

ESP-32 NodeMCU board
PlatformIO + VS Code
Espressif32 platform
ESP-IDF framework
LVGL version 7.9.1

What do you want to achieve?

Make lvgl fit ESP-32

What have you tried so far?

Enabling the external RAM, reduced LVGL functionality in lv_conf.h

Code to reproduce


Screenshot and/or video


Are you using the menuconfig interface to configure LVGL?
Also, this issue may be related to your issue

Hi Carlos, thank you for your reply.

I configured LVGL setting lv_conf.h manually (by the way, I haven’t been able to use menuconfig or other IDF tools from VS Code/Platformio, any help will be appreciated!).

I checked the issue you mentioned, but that’s about IRAM, while DRAM is involved in my case. AFAIK all variables will go DRAM, while I might play with some flags to decide where they go. Flags like LV_MEM_ATTR or LV_ATTRIBUTE_LARGE_CONST might help me to put larger data into SPIRAM of ESP32?

Edit: Maybe I should install Espressif IDF extension in PlatofrmIo to make IDF tools working…


Starting with LVGL 7.7, LVGL included a Kconfig file, so users of ESP-IDF, Nuttx and Zephyr projects can configure most of the LVGL options using the menuconfig interface.

They might, I’m not very familiar with ESP32 memories, but I’ve been using the lv_port_esp32 project without memory issues. I will try to take a look at the memory consumption and how to improve it on ESP32 platforms tomorrow.


Thank you, I will study the menuconfig utility, then.

In the meantime I spent quite some time analyzing the map file, and I found out that hidden in macros and definitions there’s a huge array: that’s the one causing the memory overflow.

So I now need to find out how to put it in the external memory, as the EXT_RAM_ATTR has no effect. I will play with other flags.

Thank you for your suggestions.

Would you mind mentioning the name? I can check why it would be large.

I’m sorry, I forgot to mention that the large array is in one of my modules, not in LVGL library.

The project is converted from a lvgl version 6 project, and just to test some displays, so it’s surely not optimized by my side. But still I might use a large array, and I want to solve data placement issue. Any suggestion about correctly configuring PlatformIO to make the EXT_RAM_ATTR attribute work will be appreciated.

Ok, I managed to run menuconfig and now my project compiles putting the large array in external RAM.
I was now wondering how can I include LVGL settings in the same menuconfig. I’m using LVGL library 7.9.1 installed from PlatformIO home (library goes into .pio/libdeps folder, I have no components folder).

As I’m also having a configuration to build the emulator, I think I can’t use the ESP32 port, right?

Do you think having an option to use your lv_conf.hfile instead of the menuconfig would help?

Yes, that’s what I did so far. I will have to use two slightly different lv_conf.h files, one for target and one for simulator. Anyway, making a couple of changes I’ve been able to include LVGL options into menuconfig.

  1. CMakeLists.txt in my project folder - Added the line
    list(APPEND EXTRA_COMPONENT_DIRS .pio/libdeps/ESP32/lvgl)

  2. CMakeLists.txt in LVGL library folder - Removed the directive
    REQUIRES main

All the options are there, and I can use the saved sdkconfig to create the corresponding lv_conf.h, unless there’s a way to have build command to create it!

Thanks for the details, maybe we can include it on the lv_port_esp32 README.

@kisvegabor Do you think this is a valid use case to let the users choose between menuconfig and lv_conf? We can make menuconfig the selected option by default on ESP, Nuttx and Zephyr.

Could you please confirm in which case the sdkconfig is used in building LVGL instead of lv_conf.h?

If you’re using the menuconfig tool to configure LVGL then lv_conf.h is not used, the symbols on sdkconfig are used instead.

Got it, thank you!