Compare commits

..
20 changed files with 42 additions and 82 deletions

No files matched your search

+2 -7
View File
@@ -10,12 +10,7 @@ from typing import TYPE_CHECKING
from esphome.build_helpers.ccache import resolve_absolute_ccache_path
from esphome.build_helpers.native import warn_ignored_platformio_options
from esphome.build_helpers.ninja import refresh_compile_commands
from esphome.const import (
CONF_COMPILE_PROCESS_LIMIT,
CONF_ESPHOME,
KEY_CORE,
KEY_FRAMEWORK_VERSION,
)
from esphome.const import CONF_COMPILE_PROCESS_LIMIT, CONF_ESPHOME
from esphome.core import CORE
from esphome.types import ConfigType
@@ -73,7 +68,7 @@ def run_compile(config: ConfigType, verbose: bool) -> int:
from esphome.core.config import NATIVE_ARDUINO_CONSUMED_PIO_OPTIONS
warn_ignored_platformio_options(NATIVE_ARDUINO_CONSUMED_PIO_OPTIONS)
paths = framework.check_and_install(CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION])
paths = framework.check_and_install(CORE.framework_version)
# Resolved once: the probe is not free and three consumers need it
ccache = resolve_absolute_ccache_path()
ninja_changed = build_gen.write_project(paths, ccache)
+1 -3
View File
@@ -36,8 +36,6 @@ from esphome.const import (
CONF_ESPHOME,
CONF_ID,
CONF_PLATFORMIO_OPTIONS,
KEY_CORE,
KEY_FRAMEWORK_VERSION,
)
from esphome.core import CORE, EsphomeError
import esphome.final_validate as fv
@@ -128,7 +126,7 @@ def _final_validate(config: ConfigType) -> None:
_LOGGER.warning("%s (this configuration cannot compile)", msg)
options = fv.full_config.get()[CONF_ESPHOME].get(CONF_PLATFORMIO_OPTIONS) or {}
check_bdk_version(options.get(BEKEN_BDK_VERSION_OPTION))
check_libretiny_version(CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION])
check_libretiny_version(CORE.framework_version)
FINAL_VALIDATE_SCHEMA = _final_validate
+3 -4
View File
@@ -3001,7 +3001,7 @@ async def _finalize_arduino_aware_flags():
async def to_code(config):
framework_ver: cv.Version = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
framework_ver = CORE.framework_version
conf = config[CONF_FRAMEWORK]
# Check if using ESP-IDF toolchain
@@ -3838,9 +3838,8 @@ def _write_sdkconfig():
# version switch that happens to leave the option set unchanged still
# bumps this file's content -- which is what has_outdated_files()
# uses to decide whether to reconfigure.
framework_version = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
contents = (
f"# ESPHOME_IDF_VERSION={framework_version}\n"
f"# ESPHOME_IDF_VERSION={CORE.framework_version}\n"
+ "\n".join(
f"{name}={_format_sdkconfig_val(value)}"
for name, value in sorted(want_opts.items())
@@ -3991,7 +3990,7 @@ def _write_idf_component_yml():
if CORE.using_toolchain_esp_idf:
add_idf_component(
name=ARDUINO_ESP32_COMPONENT_NAME,
ref=str(CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]),
ref=str(CORE.framework_version),
)
for component in converted:
+1 -1
View File
@@ -529,7 +529,7 @@ async def to_code(config: ConfigType) -> None:
# keeping one source of truth
cg.add_platformio_option("board_build.flash_mode", config[CONF_BOARD_FLASH_MODE])
ver: cv.Version = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
ver = CORE.framework_version
cg.add_define(
"USE_ARDUINO_VERSION_CODE",
cg.RawExpression(f"VERSION_CODE({ver.major}, {ver.minor}, {ver.patch})"),
+2 -4
View File
@@ -46,8 +46,6 @@ from esphome.const import (
CONF_USE_ADDRESS,
CONF_VALUE,
CONF_WIFI,
KEY_CORE,
KEY_FRAMEWORK_VERSION,
Platform,
PlatformFramework,
)
@@ -347,13 +345,13 @@ def _validate(config: ConfigType) -> ConfigType:
if CONF_POLLING_INTERVAL in config:
raise cv.Invalid(
"In this version of the framework "
f"({CORE.target_framework} {CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]}), "
f"({CORE.target_framework} {CORE.framework_version}), "
f"'{CONF_POLLING_INTERVAL}' is not supported."
)
if CONF_INTERRUPT_PIN not in config:
raise cv.Invalid(
"In this version of the framework "
f"({CORE.target_framework} {CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]}), "
f"({CORE.target_framework} {CORE.framework_version}), "
f"'{CONF_INTERRUPT_PIN}' is a required option for [ethernet]."
)
elif config[CONF_TYPE] in ("GENERIC", "YT8531"):
+2 -3
View File
@@ -241,7 +241,7 @@ def has_software_serial() -> bool:
def can_choose_uart_pins() -> bool:
"""True when SerialClass::begin() takes the pins, which LibreTiny added in 1.12.0."""
return CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] >= cv.Version(1, 12, 0)
return CORE.framework_version >= cv.Version(1, 12, 0)
def only_on_family(*, supported=None, unsupported=None):
@@ -643,8 +643,7 @@ async def component_to_code(config):
build_src_flags += " -Os"
cg.add_platformio_option("build_src_flags", build_src_flags)
# LibreTiny before 1.14.0 breaks under SCons 4.11 without this script; see the script
version = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
if (version.major, version.minor, version.patch) < (1, 14, 0):
if CORE.framework_version < cv.Version(1, 14, 0):
cg.add_platformio_option("extra_scripts", ["pre:scons_dont_inherit.py"])
cg.add_platformio_option("extra_scripts", ["pre:ccache.py"])
# IRAM_ATTR is a no-op on BK72xx (SDK masks FIQ+IRQ around flash ops).
+5 -5
View File
@@ -588,7 +588,7 @@ async def to_code(config: ConfigType) -> None:
cg.add_platformio_option(
"platform_packages",
[
f"platformio/framework-zephyr@https://github.com/tomaszduda23/framework-sdk-nrf/archive/refs/tags/v{CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]}.zip",
f"platformio/framework-zephyr@https://github.com/tomaszduda23/framework-sdk-nrf/archive/refs/tags/v{CORE.framework_version}.zip",
],
)
if config[KEY_BOOTLOADER] != BOOTLOADER_MCUBOOT:
@@ -634,7 +634,7 @@ async def to_code(config: ConfigType) -> None:
if dfu_config := config.get(CONF_DFU):
CORE.add_job(_dfu_to_code, dfu_config)
framework_ver: cv.Version = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
framework_ver = CORE.framework_version
if (dcdc := config.get(CONF_DCDC)) is not None:
if framework_ver < cv.Version(2, 9, 2):
zephyr_add_prj_conf("BOARD_ENABLE_DCDC", dcdc)
@@ -1298,13 +1298,13 @@ def _write_pch_checksum(build_dir: Path, source_dir: Path) -> None:
The app image dir follows the SDK version, like get_elf_path;
2.9.2+ always wraps the build in sysbuild."""
app_dir = build_dir
if CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] >= cv.Version(2, 9, 2):
if CORE.framework_version >= cv.Version(2, 9, 2):
app_dir = build_dir / "zephyr"
checksum = pch.pch_checksum(
CORE.relative_src_path(),
pch.PCH_DEFAULT_HEADERS,
(
str(CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]),
str(CORE.framework_version),
zephyr_data()[KEY_BOARD],
# Kconfig inputs that reach autoconf.h without a .conf line
",".join(sorted(wanted_west_projects())),
@@ -1552,7 +1552,7 @@ def run_compile(args, config: ConfigType) -> bool:
raise EsphomeError("nRF52 native build failed")
zephyr_dir = build_dir / "zephyr"
framework_ver = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
framework_ver = CORE.framework_version
bootloader = zephyr_data()[KEY_BOOTLOADER]
# (dev_type, sd_req) per bootloader — values from Nordic SoftDevice release notes.
+3 -3
View File
@@ -8,7 +8,7 @@ import subprocess
import sys
import esphome.config_validation as cv
from esphome.const import CONF_OTA, CONF_PLATFORM, KEY_CORE, KEY_FRAMEWORK_VERSION
from esphome.const import CONF_OTA, CONF_PLATFORM
from esphome.core import CORE, EsphomeError
from esphome.framework_helpers import run_command_ok
@@ -82,7 +82,7 @@ def can_upload_using_cmsis_dap() -> bool:
if (
CORE.using_toolchain_platformio
or variant not in _PYOCD_TARGETS
or CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] < cv.Version(2, 9, 2)
or CORE.framework_version < cv.Version(2, 9, 2)
):
return False
if (target_file := _PYOCD_TARGET_FILES.get(variant)) is None:
@@ -113,7 +113,7 @@ def _images(build_dir: Path) -> list[Path]:
Chosen by SDK version and by whether MCUboot is built, so a file left by another build is
never picked and a missing part is an error rather than a partial flash.
"""
framework_ver = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
framework_ver = CORE.framework_version
if framework_ver < cv.Version(2, 9, 2):
raise EsphomeError(
"Flashing with pyOCD needs nRF52 framework version 2.9.2 or newer"
+5 -7
View File
@@ -24,7 +24,6 @@ from esphome.components.zephyr.sdk_install import (
sdk_toolchain_path,
)
import esphome.config_validation as cv
from esphome.const import KEY_CORE, KEY_FRAMEWORK_VERSION
from esphome.core import CORE, EsphomeError
from esphome.framework_helpers import (
create_venv,
@@ -48,7 +47,7 @@ _TOOLCHAIN_VERSIONS = (TOOLCHAIN_VERSION, _TOOLCHAIN_VERSION_NCS_3_4_0)
def _uses_sdk_ng_1_toolchain() -> bool:
"""True when the framework needs Zephyr SDK 1.0+."""
return CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] >= cv.Version(3, 4, 0)
return CORE.framework_version >= cv.Version(3, 4, 0)
def _get_toolchain_version() -> str:
@@ -97,7 +96,7 @@ def toolchain_tool(name: str) -> Path:
def _get_version_str() -> str:
framework_ver = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
framework_ver = CORE.framework_version
return f"v{framework_ver.major}.{framework_ver.minor}.{framework_ver.patch}"
@@ -390,7 +389,7 @@ def include_west_project(name: str) -> None:
def bluetooth_west_projects() -> tuple[str, ...]:
"""Bluetooth's crypto: TinyCrypt up to SDK 3.1, PSA (mbedtls, Oberon) from 3.2."""
if CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] >= cv.Version(3, 2, 0):
if CORE.framework_version >= cv.Version(3, 2, 0):
return ("mbedtls", "oberon-psa-crypto")
return ("tinycrypt",)
@@ -398,7 +397,7 @@ def bluetooth_west_projects() -> tuple[str, ...]:
def wanted_west_projects() -> set[str]:
projects = set(_get_data().west_projects)
# Zephyr 4.1 moved the Cortex-M core headers to cmsis_6
if CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] >= cv.Version(3, 1, 0):
if CORE.framework_version >= cv.Version(3, 1, 0):
projects.add("cmsis_6")
# Sysbuild builds the MCUboot image with any bootloader
if CORE.data.get(KEY_ZEPHYR, {}).get(KEY_SYSBUILD):
@@ -580,8 +579,7 @@ def _check_and_install(version: str) -> None:
projects = wanted_west_projects()
if not sentinel.exists() or not zephyr_reqs.exists():
_install_framework(env_python_path, framework_path, version, projects)
framework_ver = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
if framework_ver < cv.Version(2, 9, 2):
if CORE.framework_version < cv.Version(2, 9, 2):
_patch_uf2conv_escape_sequences(framework_path)
sentinel.touch()
else:
+1 -2
View File
@@ -7,7 +7,6 @@ gives the binutils, the linked image and idedata of that build.
from pathlib import Path
import esphome.config_validation as cv
from esphome.const import KEY_CORE, KEY_FRAMEWORK_VERSION
from esphome.core import CORE
from .framework import toolchain_tool
@@ -27,7 +26,7 @@ def get_elf_path() -> Path:
Chosen by version rather than by probing so a leftover image from another
SDK layout is never analyzed in place of the current build.
"""
if CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] < cv.Version(2, 9, 2):
if CORE.framework_version < cv.Version(2, 9, 2):
return CORE.relative_pioenvs_path(CORE.name, "zephyr", "zephyr.elf")
return CORE.relative_pioenvs_path(CORE.name, "zephyr", "zephyr", "zephyr.elf")
+1 -3
View File
@@ -56,8 +56,6 @@ from esphome.const import (
CONF_TX_PIN,
CONF_USE_ADDRESS,
CONF_WIFI,
KEY_CORE,
KEY_FRAMEWORK_VERSION,
PLATFORM_ESP32,
PlatformFramework,
)
@@ -584,7 +582,7 @@ async def to_code(config: ConfigType) -> None:
# Crypto through PSA: mbedtls, plus Oberon from SDK 2.7
include_west_project("mbedtls")
include_west_project("openthread")
if CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] >= cv.Version(2, 7, 0):
if CORE.framework_version >= cv.Version(2, 7, 0):
include_west_project("oberon-psa-crypto")
zephyr_add_prj_conf("NET_L2_OPENTHREAD", True)
zephyr_add_prj_conf(
+1 -1
View File
@@ -382,7 +382,7 @@ async def to_code(config: ConfigType) -> None:
"board_build.filesystem_size", "0m" if CORE.testing_mode else "1m"
)
ver: cv.Version = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
ver = CORE.framework_version
cg.add_define(
"USE_ARDUINO_VERSION_CODE",
cg.RawExpression(f"VERSION_CODE({ver.major}, {ver.minor}, {ver.patch})"),
+1 -3
View File
@@ -26,8 +26,6 @@ from esphome.const import (
CONF_SECONDS,
CONF_TIMEZONE,
CONF_TRIGGER_ID,
KEY_CORE,
KEY_FRAMEWORK_VERSION,
PLATFORM_BK72XX,
PLATFORM_ESP32,
PLATFORM_ESP8266,
@@ -473,7 +471,7 @@ async def to_code(config):
# From sdk-nrf 2.8.0 newlib time() gets the clock through gettimeofday(),
# which Zephyr only provides with XSI_SINGLE_PROCESS. Without it time()
# always returns -1.
if CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] >= cv.Version(2, 8, 0):
if CORE.framework_version >= cv.Version(2, 8, 0):
zephyr_add_prj_conf("POSIX_SINGLE_PROCESS", True)
zephyr_add_prj_conf("XSI_SINGLE_PROCESS", True)
cg.add_define("USE_TIME")
+2 -3
View File
@@ -5,7 +5,7 @@ from typing import Literal, NamedTuple, TypedDict
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.const import CONF_BOARD, KEY_CORE, KEY_FRAMEWORK_VERSION
from esphome.const import CONF_BOARD
from esphome.core import CORE, CoroPriority, coroutine_with_priority
from esphome.helpers import copy_file_if_changed, write_file_if_changed
from esphome.types import ConfigType
@@ -281,8 +281,7 @@ def zephyr_use_usb_device_next() -> bool:
The new stack (device_next) is used from nRF Connect SDK 3.4.1, where the
legacy stack is deprecated. Older SDKs keep the legacy stack.
"""
framework_ver: cv.Version = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
return CORE.is_nrf52 and framework_ver >= cv.Version(3, 4, 1)
return CORE.is_nrf52 and CORE.framework_version >= cv.Version(3, 4, 1)
def _disable_board_cdc_acm_overlay() -> str:
@@ -17,7 +17,7 @@ from esphome.components.zephyr.const import (
KEY_PM_STATIC,
)
import esphome.config_validation as cv
from esphome.const import CONF_ID, KEY_CORE, KEY_FRAMEWORK_VERSION
from esphome.const import CONF_ID
from esphome.core import CORE, CoroPriority, coroutine_with_priority
from esphome.types import ConfigType
@@ -40,10 +40,6 @@ CONFIG_SCHEMA = cv.All(
)
def _framework_version() -> cv.Version:
return CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
def _partition_address() -> int:
"""Place the partition below the lowest section reserved above the SoftDevice
(the bootloader), or at the end of flash with MCUboot, on an erase page boundary."""
@@ -91,7 +87,7 @@ async def to_code(config: ConfigType) -> None:
cg.add_define("USE_CRASH_HANDLER")
zephyr_add_prj_conf("DEBUG_COREDUMP", True)
zephyr_add_prj_conf("DEBUG_COREDUMP_BACKEND_FLASH_PARTITION", True)
framework_ver = _framework_version()
framework_ver = CORE.framework_version
if framework_ver >= DUMP_THREADS_MIN_VERSION:
zephyr_add_prj_conf("DEBUG_COREDUMP_MEMORY_DUMP_THREADS", True)
else:
@@ -36,8 +36,6 @@ from esphome.const import (
CONF_NUMBER,
CONF_PIN,
CONF_STATUS,
KEY_CORE,
KEY_FRAMEWORK_VERSION,
Framework,
)
from esphome.core import CORE, coroutine_with_priority
@@ -133,8 +131,7 @@ def _validate_bootloader(config: ConfigType) -> None:
return
if bootloader not in MCUMGR_OTA_BOOTLOADERS:
raise cv.Invalid(f"{bootloader} does not support OTA")
framework_ver: cv.Version = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
if framework_ver < cv.Version(2, 9, 2):
if CORE.framework_version < cv.Version(2, 9, 2):
raise cv.Invalid(
"OTA with Adafruit_nRF52_Bootloader requires at least SDK 2.9.2"
)
@@ -252,8 +249,7 @@ async def to_code(config: ConfigType) -> None:
""",
image="mcuboot",
)
framework_ver = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
if framework_ver >= cv.Version(2, 9, 2):
if CORE.framework_version >= cv.Version(2, 9, 2):
zephyr_data()[KEY_SYSBUILD] = True
bootloader = zephyr_data()[KEY_BOOTLOADER]
+3 -7
View File
@@ -68,9 +68,6 @@ from esphome.const import (
ENTITY_CATEGORY_CONFIG,
ENTITY_CATEGORY_DIAGNOSTIC,
ENTITY_CATEGORY_NONE,
KEY_CORE,
KEY_FRAMEWORK_VERSION,
KEY_TARGET_FRAMEWORK,
PLATFORM_ESP32,
PLATFORM_ESP8266,
PLATFORM_NRF52,
@@ -2937,8 +2934,7 @@ def require_framework_version(
"""
def validator(value):
core_data = CORE.data[KEY_CORE]
framework = core_data[KEY_TARGET_FRAMEWORK]
framework = CORE.target_framework
keys_to_try: list[str] = []
if CORE.is_host and framework == "host":
@@ -2984,14 +2980,14 @@ def require_framework_version(
required = kwargs[key]
if max_version:
if core_data[KEY_FRAMEWORK_VERSION] > required:
if CORE.framework_version > required:
msg = f"This feature requires framework version {required} or lower"
if extra_message:
msg += f". {extra_message}"
raise Invalid(msg)
return value
if core_data[KEY_FRAMEWORK_VERSION] < required:
if CORE.framework_version < required:
msg = f"This feature requires at least framework version {required}"
if extra_message:
msg += f". {extra_message}"
+1 -1
View File
@@ -214,7 +214,7 @@ class StorageJSON:
hardware = esp32.get_esp32_variant(esph)
framework_version = str(esp32.idf_version())
elif esph.is_nrf52:
framework_version = str(esph.data[KEY_CORE][KEY_FRAMEWORK_VERSION])
framework_version = str(esph.framework_version)
return StorageJSON(
storage_version=1,
name=esph.name,
@@ -15,13 +15,7 @@ from esphome.components.nrf52.const import (
)
from esphome.components.nrf52.framework import get_nrf52_variant, set_nrf52_variant
import esphome.config_validation as cv
from esphome.const import (
CONF_BOARD,
CONF_FRAMEWORK,
CONF_VERSION,
KEY_CORE,
KEY_FRAMEWORK_VERSION,
)
from esphome.const import CONF_BOARD, CONF_FRAMEWORK, CONF_VERSION, KEY_CORE
from esphome.core import CORE, EsphomeCore
from esphome.types import ConfigType
@@ -79,7 +73,7 @@ def test_default_sdk_version(variant: str, default: str) -> None:
set_nrf52_variant(variant)
config = _set_framework(None)
assert config[CONF_FRAMEWORK][CONF_VERSION] == default
assert CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] == cv.Version.parse(default)
assert CORE.framework_version == cv.Version.parse(default)
@pytest.mark.usefixtures("platformio")
+2 -5
View File
@@ -369,8 +369,6 @@ def test_storage_json_from_esphome_core_mdns_enabled(setup_core: Path) -> None:
def test_storage_json_from_esphome_core_nrf52(setup_core: Path) -> None:
"""Test from_esphome_core captures the framework version on nRF52."""
from esphome.const import KEY_CORE, KEY_FRAMEWORK_VERSION
mock_core = MagicMock()
mock_core.name = "nrf_device"
mock_core.friendly_name = "nRF Device"
@@ -380,7 +378,7 @@ def test_storage_json_from_esphome_core_nrf52(setup_core: Path) -> None:
mock_core.target_platform = "nrf52"
mock_core.is_esp32 = False
mock_core.is_nrf52 = True
mock_core.data = {KEY_CORE: {KEY_FRAMEWORK_VERSION: cv.Version(2, 9, 2)}}
mock_core.framework_version = cv.Version(2, 9, 2)
mock_core.build_path = "/build/nrf_device"
mock_core.firmware_bin = "/build/nrf_device/firmware.bin"
mock_core.loaded_integrations = set()
@@ -842,7 +840,6 @@ def _make_nrf52_storage(
def test_storage_json_nrf52_framework_version_round_trip(setup_core: Path) -> None:
"""Sidecar framework_version restores CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]."""
from esphome.const import KEY_CORE, KEY_FRAMEWORK_VERSION
storage = _make_nrf52_storage("2.9.2")
path = setup_core / "storage.json"
@@ -855,7 +852,7 @@ def test_storage_json_nrf52_framework_version_round_trip(setup_core: Path) -> No
assert loaded.framework_version == "2.9.2"
loaded.apply_to_core()
assert CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] == cv.Version(2, 9, 2)
assert CORE.framework_version == cv.Version(2, 9, 2)
def test_storage_json_nrf52_apply_to_core_without_framework_version(