ESP32S3 PSRAM usage

Description

My project is working but really limit with internal memory.
I thought PSRAM was used by default but no so i configured it and interessting problems pop up :slight_smile: .

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

Custom board
ESP32S3-Wroom1-N16R8
320*240 rgb

What LVGL version are you using?

lvgl 8.x
Esp-IDF in vs code
wifi+ble so finally short in ram usage…

What do you want to achieve?

Use external psram properly detected to export the maximum of ram usage in it, and save internal memory for ble and wifi.

What have you tried so far?

  • I took inspiration from the few related topics on the forum but can’t make mine to work.
  • I add MALLOC_CAP_SPIRAM but each time i do, the program stuck on these two line, as if it was not able to allocate the buffer in the psram:
lv_color_t *buf1 = heap_caps_malloc(EXAMPLE_LCD_H_RES * 40* sizeof(lv_color_t), MALLOC_CAP_DMA | MALLOC_CAP_SPIRAM);
    assert(buf1);
    lv_color_t *buf2 = heap_caps_malloc(EXAMPLE_LCD_H_RES * 40 * sizeof(lv_color_t), MALLOC_CAP_DMA | MALLOC_CAP_SPIRAM);
    assert(buf2);
  • I also tried to adjust the lv_conf.h
#define LV_MEM_CUSTOM 1
#if LV_MEM_CUSTOM == 0
    /*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
    #define LV_MEM_SIZE (48U * 1024U)          /*[bytes]*/

          
    /*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
    #define LV_MEM_ADR 0     /*0: unused*/
    /*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/
    #if LV_MEM_ADR == 0
        #undef LV_MEM_POOL_INCLUDE
        #undef LV_MEM_POOL_ALLOC
    #endif

          
#else       /*LV_MEM_CUSTOM*/
#define LV_MEM_POOL_INCLUDE     "esp_heap_caps.h"
#define LV_MEM_POOL_ALLOC(size) heap_caps_malloc(size, MALLOC_CAP_SPIRAM)

Here is menuconfig for psram.

I have mounted a 8MB on the board because i thought my 2MB was not suffisant as i was still overflowed the ram ( that was in reallity the internal ram, but i didn’t know at this time).

But i can still see in the log console the presence of my psram but it seems to not save internal ram space. The confuguration is not good i think.

If you have a better idea of the lines to add here and there :).

I also checked the spiram usage for wifi and i can see that it is effective via heap_size_free functions.

Thanks a lot !

Try and forget to combine SPIRAM and DMA

lv_color_t *buf1 = NULL;
    buf1 = heap_caps_aligned_alloc(EXAMPLE_PSRAM_DATA_ALIGNMENT, EXAMPLE_LCD_H_RES * 100 * sizeof(lv_color_t), MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);