diff --git a/esphome/espidf/size_summary.py b/esphome/espidf/size_summary.py index d4816872f2..06e0ecba5c 100644 --- a/esphome/espidf/size_summary.py +++ b/esphome/espidf/size_summary.py @@ -11,7 +11,10 @@ byte-identical to PlatformIO's output: The format matches ``script/ci_memory_impact_extract.py`` so CI memory analysis works unchanged on native ESP-IDF builds. RAM usage comes from the DRAM (or unified DIRAM) region of the linker map; Flash used is the -size of the app ``.bin`` on disk, and Flash total is taken from +size of the app ``.bin`` on disk, which includes esptool's 16-byte +image padding and appended SHA-256, so it reads slightly above the +map-derived ``Total image size`` line and moves in 16-byte steps. +Flash total is taken from ``partitions.csv`` using PlatformIO's rule (first app partition whose subtype is ``factory`` or ``ota_0``; see ``platform-espressif32/builder/main.py::_update_max_upload_size``). diff --git a/tests/unit_tests/test_espidf_toolchain.py b/tests/unit_tests/test_espidf_toolchain.py index 9deb27d83c..e72ff007d0 100644 --- a/tests/unit_tests/test_espidf_toolchain.py +++ b/tests/unit_tests/test_espidf_toolchain.py @@ -638,6 +638,27 @@ def test_run_compile_passes_compile_process_limit(setup_core: Path) -> None: mock_run.assert_called_once_with("build", "size", jobs=1) +def test_run_compile_passes_size_summary_paths(setup_core: Path) -> None: + """print_summary receives the size json, partitions.csv, and the firmware + bin from get_firmware_path, which must stay in lockstep with the + project() name in the generated CMakeLists.""" + _setup_build(setup_core) + config = {CONF_ESPHOME: {}} + + with ( + patch.object(toolchain, "need_reconfigure", return_value=False), + patch.object(toolchain, "run_idf_py", return_value=0), + patch.object(toolchain, "print_summary") as mock_summary, + ): + assert toolchain.run_compile(config, verbose=False) == 0 + + mock_summary.assert_called_once_with( + CORE.relative_build_path("build", "esp_idf_size.json"), + CORE.relative_build_path("partitions.csv"), + toolchain.get_firmware_path(), + ) + + def test_run_compile_without_compile_process_limit(setup_core: Path) -> None: """When no compile_process_limit is set, no job limit is passed to idf.py.""" _setup_build(setup_core)