|
|
|
@@ -65,6 +65,8 @@ _LOGGER = logging.getLogger(__name__)
|
|
|
|
|
CODEOWNERS = ["@esphome/core"]
|
|
|
|
|
AUTO_LOAD = ["preferences"]
|
|
|
|
|
|
|
|
|
|
CONF_RELEASE = "release"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_core_data(config):
|
|
|
|
|
CORE.data[KEY_ESP32] = {}
|
|
|
|
@@ -216,11 +218,17 @@ def _format_framework_arduino_version(ver: cv.Version) -> str:
|
|
|
|
|
return f"~3.{ver.major}{ver.minor:02d}{ver.patch:02d}.0"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _format_framework_espidf_version(ver: cv.Version) -> str:
|
|
|
|
|
def _format_framework_espidf_version(
|
|
|
|
|
ver: cv.Version, release: str, for_platformio: bool
|
|
|
|
|
) -> str:
|
|
|
|
|
# format the given arduino (https://github.com/espressif/esp-idf/releases) version to
|
|
|
|
|
# a PIO platformio/framework-espidf value
|
|
|
|
|
# List of package versions: https://api.registry.platformio.org/v3/packages/platformio/tool/framework-espidf
|
|
|
|
|
return f"~3.{ver.major}{ver.minor:02d}{ver.patch:02d}.0"
|
|
|
|
|
if for_platformio:
|
|
|
|
|
return f"platformio/framework-espidf@~3.{ver.major}{ver.minor:02d}{ver.patch:02d}.0"
|
|
|
|
|
if release:
|
|
|
|
|
return f"pioarduino/framework-espidf@https://github.com/pioarduino/esp-idf/releases/download/v{str(ver)}.{release}/esp-idf-v{str(ver)}.zip"
|
|
|
|
|
return f"pioarduino/framework-espidf@https://github.com/pioarduino/esp-idf/releases/download/v{str(ver)}/esp-idf-v{str(ver)}.zip"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# NOTE: Keep this in mind when updating the recommended version:
|
|
|
|
@@ -241,11 +249,33 @@ ARDUINO_PLATFORM_VERSION = cv.Version(5, 4, 0)
|
|
|
|
|
# The default/recommended esp-idf framework version
|
|
|
|
|
# - https://github.com/espressif/esp-idf/releases
|
|
|
|
|
# - https://api.registry.platformio.org/v3/packages/platformio/tool/framework-espidf
|
|
|
|
|
RECOMMENDED_ESP_IDF_FRAMEWORK_VERSION = cv.Version(4, 4, 8)
|
|
|
|
|
RECOMMENDED_ESP_IDF_FRAMEWORK_VERSION = cv.Version(5, 1, 5)
|
|
|
|
|
# The platformio/espressif32 version to use for esp-idf frameworks
|
|
|
|
|
# - https://github.com/platformio/platform-espressif32/releases
|
|
|
|
|
# - https://api.registry.platformio.org/v3/packages/platformio/platform/espressif32
|
|
|
|
|
ESP_IDF_PLATFORM_VERSION = cv.Version(5, 4, 0)
|
|
|
|
|
ESP_IDF_PLATFORM_VERSION = cv.Version(51, 3, 7)
|
|
|
|
|
|
|
|
|
|
# List based on https://registry.platformio.org/tools/platformio/framework-espidf/versions
|
|
|
|
|
SUPPORTED_PLATFORMIO_ESP_IDF_5X = [
|
|
|
|
|
cv.Version(5, 3, 1),
|
|
|
|
|
cv.Version(5, 3, 0),
|
|
|
|
|
cv.Version(5, 2, 2),
|
|
|
|
|
cv.Version(5, 2, 1),
|
|
|
|
|
cv.Version(5, 1, 2),
|
|
|
|
|
cv.Version(5, 1, 1),
|
|
|
|
|
cv.Version(5, 1, 0),
|
|
|
|
|
cv.Version(5, 0, 2),
|
|
|
|
|
cv.Version(5, 0, 1),
|
|
|
|
|
cv.Version(5, 0, 0),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
# pioarduino versions that don't require a release number
|
|
|
|
|
# List based on https://github.com/pioarduino/esp-idf/releases
|
|
|
|
|
SUPPORTED_PIOARDUINO_ESP_IDF_5X = [
|
|
|
|
|
cv.Version(5, 3, 1),
|
|
|
|
|
cv.Version(5, 3, 0),
|
|
|
|
|
cv.Version(5, 1, 5),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _arduino_check_versions(value):
|
|
|
|
@@ -286,8 +316,8 @@ def _arduino_check_versions(value):
|
|
|
|
|
def _esp_idf_check_versions(value):
|
|
|
|
|
value = value.copy()
|
|
|
|
|
lookups = {
|
|
|
|
|
"dev": (cv.Version(5, 1, 2), "https://github.com/espressif/esp-idf.git"),
|
|
|
|
|
"latest": (cv.Version(5, 1, 2), None),
|
|
|
|
|
"dev": (cv.Version(5, 1, 5), "https://github.com/espressif/esp-idf.git"),
|
|
|
|
|
"latest": (cv.Version(5, 1, 5), None),
|
|
|
|
|
"recommended": (RECOMMENDED_ESP_IDF_FRAMEWORK_VERSION, None),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -305,13 +335,51 @@ def _esp_idf_check_versions(value):
|
|
|
|
|
if version < cv.Version(4, 0, 0):
|
|
|
|
|
raise cv.Invalid("Only ESP-IDF 4.0+ is supported.")
|
|
|
|
|
|
|
|
|
|
value[CONF_VERSION] = str(version)
|
|
|
|
|
value[CONF_SOURCE] = source or _format_framework_espidf_version(version)
|
|
|
|
|
# flag this for later *before* we set value[CONF_PLATFORM_VERSION] below
|
|
|
|
|
has_platform_ver = CONF_PLATFORM_VERSION in value
|
|
|
|
|
|
|
|
|
|
value[CONF_PLATFORM_VERSION] = value.get(
|
|
|
|
|
CONF_PLATFORM_VERSION, _parse_platform_version(str(ESP_IDF_PLATFORM_VERSION))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
(is_platformio := _platform_is_platformio(value[CONF_PLATFORM_VERSION]))
|
|
|
|
|
and version.major >= 5
|
|
|
|
|
and version not in SUPPORTED_PLATFORMIO_ESP_IDF_5X
|
|
|
|
|
):
|
|
|
|
|
raise cv.Invalid(
|
|
|
|
|
f"ESP-IDF {str(version)} not supported by platformio/espressif32"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
version.major < 5
|
|
|
|
|
or (
|
|
|
|
|
version in SUPPORTED_PLATFORMIO_ESP_IDF_5X
|
|
|
|
|
and version not in SUPPORTED_PIOARDUINO_ESP_IDF_5X
|
|
|
|
|
)
|
|
|
|
|
) and not has_platform_ver:
|
|
|
|
|
raise cv.Invalid(
|
|
|
|
|
f"ESP-IDF {value[CONF_VERSION]} may be supported by platformio/espressif32; please specify '{CONF_PLATFORM_VERSION}'"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
not is_platformio
|
|
|
|
|
and CONF_RELEASE not in value
|
|
|
|
|
and version not in SUPPORTED_PIOARDUINO_ESP_IDF_5X
|
|
|
|
|
):
|
|
|
|
|
raise cv.Invalid(
|
|
|
|
|
f"ESP-IDF {value[CONF_VERSION]} is not available with pioarduino; you may need to specify '{CONF_RELEASE}'"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
value[CONF_VERSION] = str(version)
|
|
|
|
|
value[CONF_SOURCE] = source or _format_framework_espidf_version(
|
|
|
|
|
version, value.get(CONF_RELEASE, None), is_platformio
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if value[CONF_SOURCE].startswith("http"):
|
|
|
|
|
# prefix is necessary or platformio will complain with a cryptic error
|
|
|
|
|
value[CONF_SOURCE] = f"framework-espidf@{value[CONF_SOURCE]}"
|
|
|
|
|
|
|
|
|
|
if version != RECOMMENDED_ESP_IDF_FRAMEWORK_VERSION:
|
|
|
|
|
_LOGGER.warning(
|
|
|
|
|
"The selected ESP-IDF framework version is not the recommended one. "
|
|
|
|
@@ -323,6 +391,12 @@ def _esp_idf_check_versions(value):
|
|
|
|
|
|
|
|
|
|
def _parse_platform_version(value):
|
|
|
|
|
try:
|
|
|
|
|
ver = cv.Version.parse(cv.version_number(value))
|
|
|
|
|
if ver.major >= 50: # a pioarduino version
|
|
|
|
|
if "-" in value:
|
|
|
|
|
# maybe a release candidate?...definitely not our default, just use it as-is...
|
|
|
|
|
return f"https://github.com/pioarduino/platform-espressif32.git#{value}"
|
|
|
|
|
return f"https://github.com/pioarduino/platform-espressif32.git#{ver.major}.{ver.minor:02d}.{ver.patch:02d}"
|
|
|
|
|
# if platform version is a valid version constraint, prefix the default package
|
|
|
|
|
cv.platformio_version_constraint(value)
|
|
|
|
|
return f"platformio/espressif32@{value}"
|
|
|
|
@@ -330,6 +404,14 @@ def _parse_platform_version(value):
|
|
|
|
|
return value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _platform_is_platformio(value):
|
|
|
|
|
try:
|
|
|
|
|
ver = cv.Version.parse(cv.version_number(value))
|
|
|
|
|
return ver.major < 50
|
|
|
|
|
except cv.Invalid:
|
|
|
|
|
return "platformio" in value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _detect_variant(value):
|
|
|
|
|
board = value[CONF_BOARD]
|
|
|
|
|
if board in BOARDS:
|
|
|
|
@@ -412,6 +494,7 @@ ESP_IDF_FRAMEWORK_SCHEMA = cv.All(
|
|
|
|
|
cv.Schema(
|
|
|
|
|
{
|
|
|
|
|
cv.Optional(CONF_VERSION, default="recommended"): cv.string_strict,
|
|
|
|
|
cv.Optional(CONF_RELEASE): cv.string_strict,
|
|
|
|
|
cv.Optional(CONF_SOURCE): cv.string_strict,
|
|
|
|
|
cv.Optional(CONF_PLATFORM_VERSION): _parse_platform_version,
|
|
|
|
|
cv.Optional(CONF_SDKCONFIG_OPTIONS, default={}): {
|
|
|
|
@@ -515,10 +598,9 @@ async def to_code(config):
|
|
|
|
|
cg.add_build_flag("-DUSE_ESP_IDF")
|
|
|
|
|
cg.add_build_flag("-DUSE_ESP32_FRAMEWORK_ESP_IDF")
|
|
|
|
|
cg.add_build_flag("-Wno-nonnull-compare")
|
|
|
|
|
cg.add_platformio_option(
|
|
|
|
|
"platform_packages",
|
|
|
|
|
[f"platformio/framework-espidf@{conf[CONF_SOURCE]}"],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
cg.add_platformio_option("platform_packages", [conf[CONF_SOURCE]])
|
|
|
|
|
|
|
|
|
|
# platformio/toolchain-esp32ulp does not support linux_aarch64 yet and has not been updated for over 2 years
|
|
|
|
|
# This is espressif's own published version which is more up to date.
|
|
|
|
|
cg.add_platformio_option(
|
|
|
|
|