Description
I want to allocate memory from LV_STDLIB_BUILTIN to use PSRAM with ps_malloc
on ESP32. Is this possible, and how can it be done?
Thank you.
What MCU/Processor/Board and compiler are you using?
ESP32, ESP32S3
What LVGL version are you using?
v9.2.2
What do you want to achieve?
use PSRAM with ps_malloc
for widgets
in your sdkconfig file you need to set
CONFIG_SPIRAM_USE_MALLOC=y
optionally you can use menuconfig to configure the project and you can locate that setting in Component config > ESP PSRAM > CONFIG_SPIRAM > SPI RAM config
also I an not sure what ps_malloc
is because it is not in the SDK for the ESP32. The memory allocation function for the ESP32 begin with heap_caps_
.
Thank you for your response.
Currently, I am using the Arduino platform, and PSRAM has been successfully set up using ESP-IDF as you suggested earlier.
Now, I want to use ps_malloc(…) to replace the default LV_STDLIB_MALLOC, which is currently set to LV_STDLIB_BUILDIN. I intend to change it to LV_STDLIB_CUSTOM in lv_conf.h.
However, I am unsure how to configure it when using LV_STDLIB_CUSTOM. Specifically, how should I set ps_malloc(…) to be called as a custom allocation function?
In earlier versions of LVGL, it was possible to replace malloc with an external function like ps_malloc(…). However, in LVGL 9.x, I don’t understand how to configure this for using external malloc ( ps_malloc(…) .
If you open up src/stdlib/builtin/lv_mem_core_builtin.c
in lvgl you will see all of the different memory functions. You need to create your own version of all of those functions. Then set LV_USE_STDLIB_MALLOC
to LV_STDLIB_CUSTOM
make sure in the C course file that contain your versions of the functions that you include src/stdlib/lv_mem.h
as that is where the function prototypes are