From 2d56559f04d43095467c4a37c46ad5a97e471f18 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 3 Oct 2026 06:36:33 -0500 Subject: [PATCH] [lvgl] Reject ESP8266 at validation (#20099) --- esphome/components/lvgl/__init__.py | 9 +++++++++ esphome/components/lvgl/lvgl_esphome.cpp | 4 ++-- tests/component_tests/lvgl/test_platforms.py | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 tests/component_tests/lvgl/test_platforms.py diff --git a/esphome/components/lvgl/__init__.py b/esphome/components/lvgl/__init__.py index ca9a317fec..66aaac5301 100644 --- a/esphome/components/lvgl/__init__.py +++ b/esphome/components/lvgl/__init__.py @@ -48,6 +48,7 @@ from esphome.cpp_generator import MockObj from esphome.final_validate import full_config from esphome.helpers import write_file_if_changed from esphome.schema_extractors import SCHEMA_EXTRACT, schema_extractor +from esphome.types import ConfigType from esphome.writer import clean_build from esphome.yaml_util import load_yaml @@ -641,7 +642,15 @@ LVGL_TOP_LEVEL_SCHEMA = ( ) +def _not_on_esp8266(config: ConfigType) -> ConfigType: + # ESP8266 does not have enough RAM for LVGL to be practical. + if CORE.is_esp8266: + raise cv.Invalid("LVGL is not supported on ESP8266") + return config + + LVGL_SCHEMA = cv.All( + _not_on_esp8266, container_schema(obj_spec, LVGL_TOP_LEVEL_SCHEMA), cv.has_at_most_one_key(CONF_PAGES, df.CONF_LAYOUT), add_hello_world, diff --git a/esphome/components/lvgl/lvgl_esphome.cpp b/esphome/components/lvgl/lvgl_esphome.cpp index 90a770ac3b..466d400023 100644 --- a/esphome/components/lvgl/lvgl_esphome.cpp +++ b/esphome/components/lvgl/lvgl_esphome.cpp @@ -1037,7 +1037,7 @@ void lv_mem_init() {} void lv_mem_deinit() {} -#if defined(USE_HOST) || defined(USE_RP2) || defined(USE_ESP8266) +#ifndef USE_ESP32 void *lv_malloc_core(size_t size) { auto *ptr = malloc(size); // NOLINT if (ptr == nullptr) { @@ -1053,7 +1053,7 @@ static void *lv_alloc_draw_buf(size_t size, bool internal) { return malloc(size); // NOLINT } -#elif defined(USE_ESP32) +#else static unsigned cap_bits = MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT; // NOLINT static void *lv_alloc_draw_buf(size_t size, bool internal) { diff --git a/tests/component_tests/lvgl/test_platforms.py b/tests/component_tests/lvgl/test_platforms.py new file mode 100644 index 0000000000..ac4da769ee --- /dev/null +++ b/tests/component_tests/lvgl/test_platforms.py @@ -0,0 +1,14 @@ +"""LVGL rejects ESP8266 at validation time.""" + +import pytest + +from esphome.components import lvgl +from esphome.config_validation import Invalid +from esphome.const import PlatformFramework +from tests.component_tests.types import SetCoreConfigCallable + + +def test_esp8266_is_rejected(set_core_config: SetCoreConfigCallable) -> None: + set_core_config(PlatformFramework.ESP8266_ARDUINO) + with pytest.raises(Invalid, match="not supported on ESP8266"): + lvgl.CONFIG_SCHEMA({})