[esp8266] Keep switch lookup tables out of RAM (#20398)

This commit is contained in:
J. Nick Koston
2026-10-09 07:15:59 -10:00
committed by GitHub
parent 279f68c432
commit f89a603582
4 changed files with 24 additions and 0 deletions
+2
View File
@@ -444,6 +444,8 @@ async def to_code(config: ConfigType) -> None:
cg.add_build_flag("-DUSE_ARDUINO")
cg.add_build_flag("-DUSE_ESP8266_FRAMEWORK_ARDUINO")
cg.add_build_flag("-Wno-nonnull-compare")
# .rodata is linked into RAM on ESP8266; keep switch lookup tables (CSWTCH) out of it
cg.add_build_flag("-fno-tree-switch-conversion")
if use_platformio:
cg.add_platformio_option("framework", "arduino")
cg.add_platformio_option("platform", conf[CONF_PLATFORM_VERSION])
@@ -0,0 +1,5 @@
esphome:
name: test
esp8266:
board: d1_mini
@@ -0,0 +1,17 @@
"""Tests for ESP8266 build flags."""
from __future__ import annotations
from collections.abc import Callable
from pathlib import Path
from esphome.core import CORE
def test_esp8266_keeps_switches_out_of_ram(
generate_main: Callable[[str | Path], str],
component_config_path: Callable[[str], Path],
) -> None:
generate_main(component_config_path("minimal.yaml"))
assert "-fno-tree-switch-conversion" in CORE.build_flags