diff --git a/esphome/core/config.py b/esphome/core/config.py index 71f2ebfc94..c6463beebb 100644 --- a/esphome/core/config.py +++ b/esphome/core/config.py @@ -593,12 +593,16 @@ 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. + elif ( + key in ("board_build.f_cpu", "board_build.ldscript") + and CORE.using_toolchain_arduino + ): + # Real-world knobs many published ESP8266 configs rely on: + # f_cpu 160000000L for timing-sensitive integrations, and a + # custom ldscript to reserve a filesystem region or correct + # a board's flash size. The esp8266 native generator reads + # both; 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 diff --git a/tests/unit_tests/core/test_config.py b/tests/unit_tests/core/test_config.py index 0a143c466c..063da34556 100644 --- a/tests/unit_tests/core/test_config.py +++ b/tests/unit_tests/core/test_config.py @@ -1408,13 +1408,16 @@ async def test_add_platformio_options_native_arduino( await config._add_platformio_options( { "board_build.f_cpu": "160000000L", + "board_build.ldscript": "eagle.flash.4m2m.ld", "board_build.filesystem": "littlefs", "upload_speed": "115200", } ) assert CORE.platformio_options["board_build.f_cpu"] == "160000000L" + assert CORE.platformio_options["board_build.ldscript"] == "eagle.flash.4m2m.ld" assert "board_build.f_cpu is ignored" not in caplog.text + assert "board_build.ldscript is ignored" not in caplog.text assert ( "esphome->platformio_options->board_build.filesystem is ignored" in caplog.text )