Skip to content

Allow configuring memory location (Internal RAM / PSRAM) for LVGL task stack allocation in esp_lvgl_port (BSP-673) #567

@BatuhanKaratas

Description

@BatuhanKaratas

Related area

Component: esp-bsp/esp_lvgl_port

Hardware specification

ESP32-S3

Is your feature request related to a problem?

Yes.
I'm using esp_lvgl_port version 2.5.0 and trying to run a Lottie animation, which requires a large LVGL task stack size. However, currently the LVGL task is always created in Internal RAM.
Since Internal RAM is limited, allocating a large stack for LVGL task is not feasible.
The task is created using either xTaskCreate or xTaskCreatePinnedToCore, but no memory capability configuration is available.

The relevant code section:

BaseType_t res;
if (cfg->task_affinity < 0) {
res = xTaskCreate(lvgl_port_task, "taskLVGL", cfg->task_stack, xTaskGetCurrentTaskHandle(), cfg->task_priority, &lvgl_port_ctx.lvgl_task);
} else {
res = xTaskCreatePinnedToCore(lvgl_port_task, "taskLVGL", cfg->task_stack, xTaskGetCurrentTaskHandle(), cfg->task_priority, &lvgl_port_ctx.lvgl_task, cfg->task_affinity);
}

Current lvgl_port_cfg_t struct:

typedef struct {
int task_priority; /*!< LVGL task priority /
int task_stack; /
!< LVGL task stack size /
int task_affinity; /
!< LVGL task pinned to core (-1 is no affinity) /
int task_max_sleep_ms; /
!< Maximum sleep in LVGL task /
int timer_period_ms; /
!< LVGL timer tick period in ms */
} lvgl_port_cfg_t;

It does not allow specifying memory capabilities for the task stack allocation.

Describe the solution you'd like

It would be great if the lvgl_port_cfg_t structure could include a new field to select memory capability (e.g., Internal RAM or PSRAM).
When creating the LVGL task, if PSRAM is selected, xTaskCreateStatic with a PSRAM-allocated stack could be used instead of xTaskCreate.

typedef enum {
LVGL_PORT_TASK_MEMORY_INTERNAL,
LVGL_PORT_TASK_MEMORY_PSRAM,
} lvgl_port_task_memory_t;

typedef struct {
int task_priority;
int task_stack;
int task_affinity;
int task_max_sleep_ms;
int timer_period_ms;
lvgl_port_task_memory_t task_memory_type; /*!< New field */
} lvgl_port_cfg_t;

And update task creation accordingly.

Describe alternatives you've considered

I considered modifying the esp_lvgl_port source locally to allocate the LVGL task stack in PSRAM using heap_caps_malloc and xTaskCreateStatic, but maintaining local modifications to BSP components is not ideal for long-term maintenance.

Additional context

This would be especially useful for projects involving large animations, such as Lottie files, where the LVGL task needs a significantly larger stack than usual.

I have checked existing list of Feature requests and the Contribution Guide

  • I confirm I have checked existing list of Feature requests and Contribution Guide.

Metadata

Metadata

Labels

Area: LVGLrelated to LVGL and LVGL port

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions