Honor board_build.f_cpu under the native ESP8266 Arduino toolchain

Dropping it was a real regression: many published ESP8266 configs pin
board_build.f_cpu: 160000000L for timing-sensitive integrations
(MHI-AC-Ctrl documents the 160 MHz requirement in its example), and the
warn-and-drop left those devices at 80 MHz. The option now routes into
CORE.platformio_options under toolchain: arduino for the generator to
consume; other native toolchains keep the warning.
This commit is contained in:
J. Nick Koston
2026-08-21 20:25:23 -05:00
parent c93cf55967
commit 7fb18f395f
2 changed files with 15 additions and 3 deletions
+7
View File
@@ -593,6 +593,13 @@ async def _add_platformio_options(pio_options: dict[str, str | list[str]]) -> No
# platformio/library.py); filters top-level libraries and
# discovered dependencies
cg.add_platformio_option(key, vals)
elif key == "board_build.f_cpu" and CORE.using_toolchain_arduino:
# A real-world overclock knob (many published ESP8266 configs
# pin 160000000L for timing-sensitive integrations); the
# esp8266 native generator reads it for -DF_CPU. Other native
# toolchains have no equivalent and fall through to the
# warning.
cg.add_platformio_option(key, val)
elif key != "upload_speed":
# upload_speed needs no handling: it is read from the raw
# config at upload time (upload_using_esptool)
+8 -3
View File
@@ -1397,8 +1397,8 @@ def test_esphome_build_internals_are_yaml_only() -> None:
async def test_add_platformio_options_native_arduino(
caplog: pytest.LogCaptureFixture,
) -> None:
"""The native ESP8266 Arduino toolchain warns about ignored options the
same way the native IDF toolchain does."""
"""The native ESP8266 Arduino toolchain honors board_build.f_cpu (a
real-world overclock knob) and warns about the rest like native IDF."""
CORE.toolchain = Toolchain.ARDUINO
CORE.data[KEY_CORE] = {
KEY_TARGET_PLATFORM: "esp8266",
@@ -1408,11 +1408,16 @@ async def test_add_platformio_options_native_arduino(
await config._add_platformio_options(
{
"board_build.f_cpu": "160000000L",
"board_build.filesystem": "littlefs",
"upload_speed": "115200",
}
)
assert "esphome->platformio_options->board_build.f_cpu is ignored" in caplog.text
assert CORE.platformio_options["board_build.f_cpu"] == "160000000L"
assert "board_build.f_cpu is ignored" not in caplog.text
assert (
"esphome->platformio_options->board_build.filesystem is ignored" in caplog.text
)
assert "'arduino' toolchain" in caplog.text
assert "upload_speed" not in caplog.text