LVGL - Memory limitations, can use SDRAM

Hi Arduino guys,

Currently the lv_conf has only 48K of memory which is not enough for anything non basic.

It can be setup to use SDRAM though, I have included an example section here. Might it be a good idea to have this added maybe?

There is one catch, on the M4 this is not working correctly, I'm not sure exactly why yet but for the M7 it works fine.

/*=========================
   MEMORY SETTINGS
 *=========================*/

/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/
#define LV_MEM_CUSTOM 0
#if LV_MEM_CUSTOM == 0
#define USE_SDRAM 1
#if USE_SDRAM
    /*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
    #define LV_MEM_SIZE (512U * 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
        #define LV_MEM_POOL_ALLOC ea_malloc
    #endif

#else
    /*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
#endif


#else       /*LV_MEM_CUSTOM*/
    #define LV_MEM_CUSTOM_INCLUDE <stdlib.h>   /*Header for the dynamic memory function*/
    #define LV_MEM_CUSTOM_ALLOC   malloc
    #define LV_MEM_CUSTOM_FREE    free
    #define LV_MEM_CUSTOM_REALLOC realloc
#endif     /*LV_MEM_CUSTOM*/

edit: M4 SDRAM issue here: SDRAM - Read not working correctly on M4

Hi Bob,

Did you get this working with the Giga board?
I'm hitting some really weird compilation errors and I'm trying to figure out why.
What were the issues that you ran into?

cheers, Giles

Yep that should work fine with th M7, what errors are you seeing?

Hi Bob - I started a new thread on that:

I added your code to my lv_conf.h It didn't solve my compilation errors, but I'm happy to have it there as it makes a lot of sense.

There has been another answer on the other thread, lvgl versions looks like.