As per title, I’ve been trying to figure out how to get LVGL to use the PSRAM on my esp32-wrover, but after hours of searching, I can’t seem to find any articles or advice on how to accomplish it!
Any help would be much appreciated!
Could you solve the problem?
what do u want to store in external psram? videobuffer? objects?
check this link.
there is 2 solutions i think that would work
- setup memory mapping for entire esp32 (as described in espressif appnote)
- add some sort of HAL that will use ur custom alloc,malloc methods and will handle read write operations from/to external ram and force lvgl to use them by defining them in configuration file.
import espidf as esp
import lvgl as lv
factor = 8
width = 320
height = 480
buf_size = (width * height * lv.color_t.__SIZE__) // factor
disp_buf = lv.disp_draw_buf_t()
buf1 = esp.heap_caps_malloc(buf_size, esp.MALLOC_CAP.SPIRAM)
buf2 = esp.heap_caps_malloc(buf_size, esp.MALLOC_CAP.SPIRAM)
disp_buf.init(buf1, buf2, buf_size // lv.color_t.__SIZE__)
in MicroPython code for the esp32 it would be the following which isn’t all that far off what it would be in C code
on latter version of the ESP32 like the ESP32-S3 the SPIRAM is also DMAable. so using the following you can direct what memory the frame buffers should use
DMA that is available anywhere:
DMA in spi ram:
MALLOC_CAP.DMA | MALLOC_CAP.SPIRAM
DMA in internal ram:
MALLOC_CAP.DMA | MALLOC_CAP.INTERNAL
if not using DMA memory