How to use external SRAM to allocate memory pool?


define LV_MEM_ADR 0xC0080000

0xC0080000 is an address in SDRAM.

I set the value of LV_MEM_ADR, but “LV_LOG_WARN(“Couldn’t allocate memory”);” was reported when allocating memory.

What settings do I need?

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


What LVGL version are you using?


What do you want to achieve?

What have you tried so far?

Did you also change LV_MEM_SIZE?

1 Like
#define LV_MEM_CUSTOM      0
#if LV_MEM_CUSTOM == 0
/* Size of the memory used by `lv_mem_alloc` in bytes (>= 2kB)*/
#  define LV_MEM_SIZE    (128U * 1024U)

/* Complier prefix for a big array declaration */
#  define LV_MEM_ATTR

/* Set an address for the memory pool instead of allocating it as an array.
 * Can be in external SRAM too. */
#  define LV_MEM_ADR          0xC0080000

Could you add a printf above this line to find out how much memory it’s trying to allocate? Maybe 128K is not enough.

1 Like