Skip to content

feat(esp_lvgl_port): add native cmakev2 build path#780

Draft
fhrbata wants to merge 2 commits into
espressif:masterfrom
fhrbata:feat/esp_lvgl_port_cmakev2
Draft

feat(esp_lvgl_port): add native cmakev2 build path#780
fhrbata wants to merge 2 commits into
espressif:masterfrom
fhrbata:feat/esp_lvgl_port_cmakev2

Conversation

@fhrbata
Copy link
Copy Markdown

@fhrbata fhrbata commented May 11, 2026

Summary

Adds a v2-native build path for esp_lvgl_port, dispatched from CMakeLists.txt
when IDF_BUILD_V2 is set. The existing v1 code stays in place for legacy IDF
builds.

  • New file: components/esp_lvgl_port/CMakeLists_v2.txt -- pure cmakev2, no
    idf_component_register shim. Single STATIC component target instead of
    v1's INTERFACE component + separate lvgl_port_lib. Short-name resolution
    collapses the dual-namespace optional-integration blocks.
  • components/esp_lvgl_port/CMakeLists.txt -- 7-line dispatch.
  • components/esp_lvgl_port/project_include.cmake -- branch inside
    lvgl_port_create_c_image's LVGL version probe.

Notes

  • CMakeLists_v2.txt wraps one underscore-prefixed IDF helper
    (__get_component_interface) in a local _lvgl_port_optional_include
    function. The docstring explains it stands in for a missing public
    cmakev2 API (a non-fatal idf_component_include). The wrapper can be
    deleted when the build system grows that API.
  • v1 codepath is untouched -- no-op for existing users.

Test plan

  • Build components/esp_lvgl_port/test_apps/lvgl_port under cmakev1 and
    cmakev2; both succeed to .bin.
  • Object files for esp_lvgl_port.c, esp_lvgl_port_disp.c,
    esp_lvgl_port_touch.c byte-identical between v1 and v2 builds (after
    xtensa-esp32s3-elf-strip -g).
  • Same set of lvgl_port_* symbols in the final ELF in both builds.
  • Verify on a wider matrix of esp-bsp examples / targets.

Adds CMakeLists_v2.txt with a pure cmakev2 component definition.
CMakeLists.txt dispatches to it when IDF_BUILD_V2 is set; the existing
v1 code path is unchanged. project_include.cmake branches the LVGL
version probe in lvgl_port_create_c_image to use the v2 short-name
interface cache when IDF_BUILD_V2 is set.

The v2 file uses native cmake primitives -- add_library +
target_sources / target_link_libraries -- instead of an
idf_component_register call. Optional integrations (button,
esp_lcd_touch, knob, usb_host_hid) collapse to one block each because
the v2 interface cache resolves the short name to either the local
component or the espressif__* managed variant.

Verified on components/esp_lvgl_port/test_apps/lvgl_port: v1 and v2
produce byte-identical object files (after stripping debug-info paths)
and the same set of lvgl_port_* symbols in the final ELF.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
Comment thread components/esp_lvgl_port/project_include.cmake Outdated
In lvgl_port_create_c_image, set lvgl_name via
idf_component_get_property(... lvgl COMPONENT_NAME) so it holds the
resolved full name (lvgl or lvgl__lvgl), matching the v1 branch
semantics. The previous hardcoded short name worked only because the
v2 interface cache resolves short names in later property lookups too.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
@espzav
Copy link
Copy Markdown
Collaborator

espzav commented May 12, 2026

@fhrbata Thank you very much for this help!
I am trying it and I have two issues:

  1. With rgb_lcd example inside LVGL port:
/Users/espzav/Desktop/GIT/esp-idf_gitlab/components/esp_hw_support/esp_memory_utils.c:17:10: fatal error: esp_private/esp_psram_extram.h: No such file or directory
   17 | #include "esp_private/esp_psram_extram.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[109/155] Building C object esp-idf/esp_hw_support/CMakeFiles/_idf_esp_hw_support.dir/port/esp32s3/rtc_clk.c.obj
ninja: build stopped: subcommand failed.
[1204/1214] Linking C static library esp-idf/lvgl__lvgl/liblvgl__lvgl.a
ninja: build stopped: subcommand failed.
BUG: component_requirements.py: esp_private/esp_psram_extram.h found in component esp_psram which is already in the requirements list of esp_hw_support
  1. With display_usb_hid BSP example:
  • It is not working, when I have components in BSP YML like this:
  espressif/esp_lvgl_port:
    version: "^2"
    public: true
    override_path: "../../components/esp_lvgl_port"

when I remove espressif/, it is working. Like this:

 esp_lvgl_port:
    version: "^2"
    public: true
    override_path: "../../components/esp_lvgl_port"

Should I update all BSPs to components without espressif namespace?

Thank you!

@fhrbata
Copy link
Copy Markdown
Author

fhrbata commented May 12, 2026

@fhrbata Thank you very much for this help! I am trying it and I have two issues:

Sorry for the troubles.

  1. With rgb_lcd example inside LVGL port:
/Users/espzav/Desktop/GIT/esp-idf_gitlab/components/esp_hw_support/esp_memory_utils.c:17:10: fatal error: esp_private/esp_psram_extram.h: No such file or directory
   17 | #include "esp_private/esp_psram_extram.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[109/155] Building C object esp-idf/esp_hw_support/CMakeFiles/_idf_esp_hw_support.dir/port/esp32s3/rtc_clk.c.obj
ninja: build stopped: subcommand failed.
[1204/1214] Linking C static library esp-idf/lvgl__lvgl/liblvgl__lvgl.a
ninja: build stopped: subcommand failed.
BUG: component_requirements.py: esp_private/esp_psram_extram.h found in component esp_psram which is already in the requirements list of esp_hw_support

I think this is a bug we are currently working on. When PSRAM is enabled by application, the bootloader compilation fails because the esp_hw_support component is shared between app and bootloader and bootloader now sees full configuration. Hopefully we will be able to figure this out soon.

  1. With display_usb_hid BSP example:
  • It is not working, when I have components in BSP YML like this:
  espressif/esp_lvgl_port:
    version: "^2"
    public: true
    override_path: "../../components/esp_lvgl_port"

when I remove espressif/, it is working. Like this:

 esp_lvgl_port:
    version: "^2"
    public: true
    override_path: "../../components/esp_lvgl_port"

Should I update all BSPs to components without espressif namespace?

Thank you!

I think I've seen similar problem yesterday when I was testing this PR. IIUC the problem is that we don't pass full list of local components to the component manager when dependencies are injected. So component manager reports back espressif__esp_lvgl_port component, but such component is not known to the build system.

Unless I've missed something I believe both are unfortunately bugs in the cmakev2.

@espzav
Copy link
Copy Markdown
Collaborator

espzav commented May 12, 2026

Unless I've missed something I believe both are unfortunately bugs in the cmakev2.

Thank you! It seems that I should wait for fix both issues. Could you ping me, when it will be fixed? Or can I watch some task or PR?

@fhrbata
Copy link
Copy Markdown
Author

fhrbata commented May 12, 2026

Unless I've missed something I believe both are unfortunately bugs in the cmakev2.

Thank you! It seems that I should wait for fix both issues. Could you ping me, when it will be fixed? Or can I watch some task or PR?

I will post the update here once it's fixed. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants