mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	Merge remote-tracking branch 'origin/dev' into ota_base_extract
This commit is contained in:
		| @@ -15,8 +15,7 @@ namespace adc { | ||||
|  | ||||
| #ifdef USE_ESP32 | ||||
| // clang-format off | ||||
| #if (ESP_IDF_VERSION_MAJOR == 4 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 7)) || \ | ||||
|     (ESP_IDF_VERSION_MAJOR == 5 && \ | ||||
| #if (ESP_IDF_VERSION_MAJOR == 5 && \ | ||||
|      ((ESP_IDF_VERSION_MINOR == 0 && ESP_IDF_VERSION_PATCH >= 5) || \ | ||||
|       (ESP_IDF_VERSION_MINOR == 1 && ESP_IDF_VERSION_PATCH >= 3) || \ | ||||
|       (ESP_IDF_VERSION_MINOR >= 2)) \ | ||||
| @@ -100,11 +99,7 @@ class ADCSensor : public sensor::Sensor, public PollingComponent, public voltage | ||||
|   adc1_channel_t channel1_{ADC1_CHANNEL_MAX}; | ||||
|   adc2_channel_t channel2_{ADC2_CHANNEL_MAX}; | ||||
|   bool autorange_{false}; | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
|   esp_adc_cal_characteristics_t cal_characteristics_[SOC_ADC_ATTEN_NUM] = {}; | ||||
| #else | ||||
|   esp_adc_cal_characteristics_t cal_characteristics_[ADC_ATTEN_MAX] = {}; | ||||
| #endif  // ESP_IDF_VERSION_MAJOR | ||||
| #endif  // USE_ESP32 | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -411,8 +411,8 @@ def _esp_idf_check_versions(value): | ||||
|         version = cv.Version.parse(cv.version_number(value[CONF_VERSION])) | ||||
|         source = value.get(CONF_SOURCE, None) | ||||
|  | ||||
|     if version < cv.Version(4, 0, 0): | ||||
|         raise cv.Invalid("Only ESP-IDF 4.0+ is supported.") | ||||
|     if version < cv.Version(5, 0, 0): | ||||
|         raise cv.Invalid("Only ESP-IDF 5.0+ is supported.") | ||||
|  | ||||
|     # flag this for later *before* we set value[CONF_PLATFORM_VERSION] below | ||||
|     has_platform_ver = CONF_PLATFORM_VERSION in value | ||||
| @@ -422,20 +422,15 @@ def _esp_idf_check_versions(value): | ||||
|     ) | ||||
|  | ||||
|     if ( | ||||
|         (is_platformio := _platform_is_platformio(value[CONF_PLATFORM_VERSION])) | ||||
|         and version.major >= 5 | ||||
|         and version not in SUPPORTED_PLATFORMIO_ESP_IDF_5X | ||||
|     ): | ||||
|         is_platformio := _platform_is_platformio(value[CONF_PLATFORM_VERSION]) | ||||
|     ) 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 | ||||
|         ) | ||||
|         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}'" | ||||
| @@ -801,14 +796,9 @@ async def to_code(config): | ||||
|  | ||||
|         if advanced.get(CONF_IGNORE_EFUSE_MAC_CRC): | ||||
|             add_idf_sdkconfig_option("CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR", True) | ||||
|             if (framework_ver.major, framework_ver.minor) >= (4, 4): | ||||
|                 add_idf_sdkconfig_option( | ||||
|                     "CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE", False | ||||
|                 ) | ||||
|             else: | ||||
|                 add_idf_sdkconfig_option( | ||||
|                     "CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE", False | ||||
|                 ) | ||||
|             add_idf_sdkconfig_option( | ||||
|                 "CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE", False | ||||
|             ) | ||||
|         if advanced.get(CONF_ENABLE_IDF_EXPERIMENTAL_FEATURES): | ||||
|             _LOGGER.warning( | ||||
|                 "Using experimental features in ESP-IDF may result in unexpected failures." | ||||
|   | ||||
| @@ -56,11 +56,7 @@ void arch_init() { | ||||
| void IRAM_ATTR HOT arch_feed_wdt() { esp_task_wdt_reset(); } | ||||
|  | ||||
| uint8_t progmem_read_byte(const uint8_t *addr) { return *addr; } | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
| uint32_t arch_get_cpu_cycle_count() { return esp_cpu_get_cycle_count(); } | ||||
| #else | ||||
| uint32_t arch_get_cpu_cycle_count() { return cpu_hal_get_cycle_count(); } | ||||
| #endif | ||||
| uint32_t arch_get_cpu_freq_hz() { | ||||
|   uint32_t freq = 0; | ||||
| #ifdef USE_ESP_IDF | ||||
|   | ||||
| @@ -29,8 +29,6 @@ from esphome.const import ( | ||||
|     CONF_ON_BLE_SERVICE_DATA_ADVERTISE, | ||||
|     CONF_SERVICE_UUID, | ||||
|     CONF_TRIGGER_ID, | ||||
|     KEY_CORE, | ||||
|     KEY_FRAMEWORK_VERSION, | ||||
| ) | ||||
| from esphome.core import CORE | ||||
|  | ||||
| @@ -323,10 +321,7 @@ async def to_code(config): | ||||
|         # https://github.com/espressif/esp-idf/issues/2503 | ||||
|         # Match arduino CONFIG_BTU_TASK_STACK_SIZE | ||||
|         # https://github.com/espressif/arduino-esp32/blob/fd72cf46ad6fc1a6de99c1d83ba8eba17d80a4ee/tools/sdk/esp32/sdkconfig#L1866 | ||||
|         if CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] >= cv.Version(4, 4, 6): | ||||
|             add_idf_sdkconfig_option("CONFIG_BT_BTU_TASK_STACK_SIZE", 8192) | ||||
|         else: | ||||
|             add_idf_sdkconfig_option("CONFIG_BTU_TASK_STACK_SIZE", 8192) | ||||
|         add_idf_sdkconfig_option("CONFIG_BT_BTU_TASK_STACK_SIZE", 8192) | ||||
|         add_idf_sdkconfig_option("CONFIG_BT_ACL_CONNECTIONS", 9) | ||||
|         add_idf_sdkconfig_option( | ||||
|             "CONFIG_BTDM_CTRL_BLE_MAX_CONN", config[CONF_MAX_CONNECTIONS] | ||||
| @@ -335,8 +330,7 @@ async def to_code(config): | ||||
|         # max notifications in 5.x, setting CONFIG_BT_ACL_CONNECTIONS | ||||
|         # is enough in 4.x | ||||
|         # https://github.com/esphome/issues/issues/6808 | ||||
|         if CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] >= cv.Version(5, 0, 0): | ||||
|             add_idf_sdkconfig_option("CONFIG_BT_GATTC_NOTIF_REG_MAX", 9) | ||||
|         add_idf_sdkconfig_option("CONFIG_BT_GATTC_NOTIF_REG_MAX", 9) | ||||
|  | ||||
|     cg.add_define("USE_OTA_STATE_CALLBACK")  # To be notified when an OTA update starts | ||||
|     cg.add_define("USE_ESP32_BLE_CLIENT") | ||||
|   | ||||
| @@ -19,11 +19,7 @@ | ||||
| #include <sys/cdefs.h> | ||||
| #include "esp_log.h" | ||||
| #include "esp_eth.h" | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
| #include "esp_eth_phy_802_3.h" | ||||
| #else | ||||
| #include "eth_phy_regs_struct.h" | ||||
| #endif | ||||
| #include "freertos/FreeRTOS.h" | ||||
| #include "freertos/task.h" | ||||
| #include "driver/gpio.h" | ||||
| @@ -174,11 +170,7 @@ static esp_err_t jl1101_reset_hw(esp_eth_phy_t *phy) { | ||||
|   return ESP_OK; | ||||
| } | ||||
|  | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
| static esp_err_t jl1101_negotiate(esp_eth_phy_t *phy, eth_phy_autoneg_cmd_t cmd, bool *nego_state) { | ||||
| #else | ||||
| static esp_err_t jl1101_negotiate(esp_eth_phy_t *phy) { | ||||
| #endif | ||||
|   phy_jl1101_t *jl1101 = __containerof(phy, phy_jl1101_t, parent); | ||||
|   esp_eth_mediator_t *eth = jl1101->eth; | ||||
|   /* in case any link status has changed, let's assume we're in link down status */ | ||||
| @@ -293,11 +285,7 @@ static esp_err_t jl1101_init(esp_eth_phy_t *phy) { | ||||
|   esp_eth_mediator_t *eth = jl1101->eth; | ||||
|   // Detect PHY address | ||||
|   if (jl1101->addr == ESP_ETH_PHY_ADDR_AUTO) { | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
|     PHY_CHECK(esp_eth_phy_802_3_detect_phy_addr(eth, &jl1101->addr) == ESP_OK, "Detect PHY address failed", err); | ||||
| #else | ||||
|     PHY_CHECK(esp_eth_detect_phy_addr(eth, &jl1101->addr) == ESP_OK, "Detect PHY address failed", err); | ||||
| #endif | ||||
|   } | ||||
|   /* Power on Ethernet PHY */ | ||||
|   PHY_CHECK(jl1101_pwrctl(phy, true) == ESP_OK, "power control failed", err); | ||||
| @@ -336,11 +324,7 @@ esp_eth_phy_t *esp_eth_phy_new_jl1101(const eth_phy_config_t *config) { | ||||
|   jl1101->parent.init = jl1101_init; | ||||
|   jl1101->parent.deinit = jl1101_deinit; | ||||
|   jl1101->parent.set_mediator = jl1101_set_mediator; | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
|   jl1101->parent.autonego_ctrl = jl1101_negotiate; | ||||
| #else | ||||
|   jl1101->parent.negotiate = jl1101_negotiate; | ||||
| #endif | ||||
|   jl1101->parent.get_link = jl1101_get_link; | ||||
|   jl1101->parent.pwrctl = jl1101_pwrctl; | ||||
|   jl1101->parent.get_addr = jl1101_get_addr; | ||||
|   | ||||
| @@ -122,25 +122,12 @@ void EthernetComponent::setup() { | ||||
|       .post_cb = nullptr, | ||||
|   }; | ||||
|  | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
| #if CONFIG_ETH_SPI_ETHERNET_W5500 | ||||
|   eth_w5500_config_t w5500_config = ETH_W5500_DEFAULT_CONFIG(host, &devcfg); | ||||
| #endif | ||||
| #if CONFIG_ETH_SPI_ETHERNET_DM9051 | ||||
|   eth_dm9051_config_t dm9051_config = ETH_DM9051_DEFAULT_CONFIG(host, &devcfg); | ||||
| #endif | ||||
| #else | ||||
|   spi_device_handle_t spi_handle = nullptr; | ||||
|   err = spi_bus_add_device(host, &devcfg, &spi_handle); | ||||
|   ESPHL_ERROR_CHECK(err, "SPI bus add device error"); | ||||
|  | ||||
| #if CONFIG_ETH_SPI_ETHERNET_W5500 | ||||
|   eth_w5500_config_t w5500_config = ETH_W5500_DEFAULT_CONFIG(spi_handle); | ||||
| #endif | ||||
| #if CONFIG_ETH_SPI_ETHERNET_DM9051 | ||||
|   eth_dm9051_config_t dm9051_config = ETH_DM9051_DEFAULT_CONFIG(spi_handle); | ||||
| #endif | ||||
| #endif  // ESP_IDF_VERSION_MAJOR >= 5 | ||||
|  | ||||
| #if CONFIG_ETH_SPI_ETHERNET_W5500 | ||||
|   w5500_config.int_gpio_num = this->interrupt_pin_; | ||||
| @@ -211,11 +198,7 @@ void EthernetComponent::setup() { | ||||
|     } | ||||
|     case ETHERNET_TYPE_KSZ8081: | ||||
|     case ETHERNET_TYPE_KSZ8081RNA: { | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
|       this->phy_ = esp_eth_phy_new_ksz80xx(&phy_config); | ||||
| #else | ||||
|       this->phy_ = esp_eth_phy_new_ksz8081(&phy_config); | ||||
| #endif | ||||
|       break; | ||||
|     } | ||||
| #endif | ||||
|   | ||||
| @@ -9,14 +9,7 @@ from esphome.components.esp32.const import ( | ||||
|     VARIANT_ESP32S3, | ||||
| ) | ||||
| import esphome.config_validation as cv | ||||
| from esphome.const import ( | ||||
|     CONF_BITS_PER_SAMPLE, | ||||
|     CONF_CHANNEL, | ||||
|     CONF_ID, | ||||
|     CONF_SAMPLE_RATE, | ||||
|     KEY_CORE, | ||||
|     KEY_FRAMEWORK_VERSION, | ||||
| ) | ||||
| from esphome.const import CONF_BITS_PER_SAMPLE, CONF_CHANNEL, CONF_ID, CONF_SAMPLE_RATE | ||||
| from esphome.core import CORE | ||||
| from esphome.cpp_generator import MockObjClass | ||||
| import esphome.final_validate as fv | ||||
| @@ -250,8 +243,7 @@ def _final_validate(_): | ||||
|  | ||||
|  | ||||
| def use_legacy(): | ||||
|     framework_version = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] | ||||
|     if CORE.using_esp_idf and framework_version >= cv.Version(5, 0, 0): | ||||
|     if CORE.using_esp_idf: | ||||
|         if not _use_legacy_driver: | ||||
|             return False | ||||
|     return True | ||||
|   | ||||
| @@ -9,15 +9,11 @@ namespace i2s_audio { | ||||
|  | ||||
| static const char *const TAG = "i2s_audio"; | ||||
|  | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
| static const uint8_t I2S_NUM_MAX = SOC_I2S_NUM;  // because IDF 5+ took this away :( | ||||
| #endif | ||||
|  | ||||
| void I2SAudioComponent::setup() { | ||||
|   ESP_LOGCONFIG(TAG, "Running setup"); | ||||
|  | ||||
|   static i2s_port_t next_port_num = I2S_NUM_0; | ||||
|   if (next_port_num >= I2S_NUM_MAX) { | ||||
|   if (next_port_num >= SOC_I2S_NUM) { | ||||
|     ESP_LOGE(TAG, "Too many components"); | ||||
|     this->mark_failed(); | ||||
|     return; | ||||
|   | ||||
| @@ -59,11 +59,7 @@ optional<uint8_t> ImprovSerialComponent::read_byte_() { | ||||
|       break; | ||||
| #if defined(USE_LOGGER_USB_CDC) && defined(CONFIG_ESP_CONSOLE_USB_CDC) | ||||
|     case logger::UART_SELECTION_USB_CDC: | ||||
| #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) | ||||
|       if (esp_usb_console_available_for_read()) { | ||||
| #else | ||||
|       if (esp_usb_console_read_available()) { | ||||
| #endif | ||||
|         esp_usb_console_read_buf((char *) &data, 1); | ||||
|         byte = data; | ||||
|       } | ||||
|   | ||||
| @@ -10,11 +10,7 @@ uint8_t temprature_sens_read(); | ||||
| #elif defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || \ | ||||
|     defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32H2) || \ | ||||
|     defined(USE_ESP32_VARIANT_ESP32C2) || defined(USE_ESP32_VARIANT_ESP32P4) | ||||
| #if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) | ||||
| #include "driver/temp_sensor.h" | ||||
| #else | ||||
| #include "driver/temperature_sensor.h" | ||||
| #endif  // ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) | ||||
| #endif  // USE_ESP32_VARIANT | ||||
| #endif  // USE_ESP32 | ||||
| #ifdef USE_RP2040 | ||||
| @@ -31,12 +27,11 @@ namespace internal_temperature { | ||||
|  | ||||
| static const char *const TAG = "internal_temperature"; | ||||
| #ifdef USE_ESP32 | ||||
| #if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) && \ | ||||
|     (defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S2) || \ | ||||
|      defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32H2) || defined(USE_ESP32_VARIANT_ESP32C2) || \ | ||||
|      defined(USE_ESP32_VARIANT_ESP32P4)) | ||||
| #if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S2) || \ | ||||
|     defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32H2) || defined(USE_ESP32_VARIANT_ESP32C2) || \ | ||||
|     defined(USE_ESP32_VARIANT_ESP32P4) | ||||
| static temperature_sensor_handle_t tsensNew = NULL; | ||||
| #endif  // ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) && USE_ESP32_VARIANT | ||||
| #endif  // USE_ESP32_VARIANT | ||||
| #endif  // USE_ESP32 | ||||
|  | ||||
| void InternalTemperatureSensor::update() { | ||||
| @@ -51,24 +46,11 @@ void InternalTemperatureSensor::update() { | ||||
| #elif defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || \ | ||||
|     defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32H2) || \ | ||||
|     defined(USE_ESP32_VARIANT_ESP32C2) || defined(USE_ESP32_VARIANT_ESP32P4) | ||||
| #if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) | ||||
|   temp_sensor_config_t tsens = TSENS_CONFIG_DEFAULT(); | ||||
|   temp_sensor_set_config(tsens); | ||||
|   temp_sensor_start(); | ||||
| #if defined(USE_ESP32_VARIANT_ESP32S3) && (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 4, 3)) | ||||
| #error \ | ||||
|     "ESP32-S3 internal temperature sensor requires ESP IDF V4.4.3 or higher. See https://github.com/esphome/issues/issues/4271" | ||||
| #endif | ||||
|   esp_err_t result = temp_sensor_read_celsius(&temperature); | ||||
|   temp_sensor_stop(); | ||||
|   success = (result == ESP_OK); | ||||
| #else | ||||
|   esp_err_t result = temperature_sensor_get_celsius(tsensNew, &temperature); | ||||
|   success = (result == ESP_OK); | ||||
|   if (!success) { | ||||
|     ESP_LOGE(TAG, "Reading failed (%d)", result); | ||||
|   } | ||||
| #endif  // ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) | ||||
| #endif  // USE_ESP32_VARIANT | ||||
| #endif  // USE_ESP32 | ||||
| #ifdef USE_RP2040 | ||||
| @@ -99,10 +81,9 @@ void InternalTemperatureSensor::update() { | ||||
|  | ||||
| void InternalTemperatureSensor::setup() { | ||||
| #ifdef USE_ESP32 | ||||
| #if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) && \ | ||||
|     (defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S2) || \ | ||||
|      defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32H2) || defined(USE_ESP32_VARIANT_ESP32C2) || \ | ||||
|      defined(USE_ESP32_VARIANT_ESP32P4)) | ||||
| #if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S2) || \ | ||||
|     defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32H2) || defined(USE_ESP32_VARIANT_ESP32C2) || \ | ||||
|     defined(USE_ESP32_VARIANT_ESP32P4) | ||||
|   ESP_LOGCONFIG(TAG, "Running setup"); | ||||
|  | ||||
|   temperature_sensor_config_t tsens_config = TEMPERATURE_SENSOR_CONFIG_DEFAULT(-10, 80); | ||||
| @@ -120,7 +101,7 @@ void InternalTemperatureSensor::setup() { | ||||
|     this->mark_failed(); | ||||
|     return; | ||||
|   } | ||||
| #endif  // ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) && USE_ESP32_VARIANT | ||||
| #endif  // USE_ESP32_VARIANT | ||||
| #endif  // USE_ESP32 | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,46 +1,21 @@ | ||||
| import esphome.codegen as cg | ||||
| from esphome.components import sensor | ||||
| from esphome.components.esp32 import get_esp32_variant | ||||
| from esphome.components.esp32.const import VARIANT_ESP32S3 | ||||
| import esphome.config_validation as cv | ||||
| from esphome.const import ( | ||||
|     DEVICE_CLASS_TEMPERATURE, | ||||
|     ENTITY_CATEGORY_DIAGNOSTIC, | ||||
|     KEY_CORE, | ||||
|     KEY_FRAMEWORK_VERSION, | ||||
|     PLATFORM_BK72XX, | ||||
|     PLATFORM_ESP32, | ||||
|     PLATFORM_RP2040, | ||||
|     STATE_CLASS_MEASUREMENT, | ||||
|     UNIT_CELSIUS, | ||||
| ) | ||||
| from esphome.core import CORE | ||||
|  | ||||
| internal_temperature_ns = cg.esphome_ns.namespace("internal_temperature") | ||||
| InternalTemperatureSensor = internal_temperature_ns.class_( | ||||
|     "InternalTemperatureSensor", sensor.Sensor, cg.PollingComponent | ||||
| ) | ||||
|  | ||||
|  | ||||
| def validate_config(config): | ||||
|     if CORE.is_esp32: | ||||
|         variant = get_esp32_variant() | ||||
|         if variant == VARIANT_ESP32S3: | ||||
|             if CORE.using_arduino and CORE.data[KEY_CORE][ | ||||
|                 KEY_FRAMEWORK_VERSION | ||||
|             ] < cv.Version(2, 0, 6): | ||||
|                 raise cv.Invalid( | ||||
|                     "ESP32-S3 Internal Temperature Sensor requires framework version 2.0.6 or higher. See <https://github.com/esphome/issues/issues/4271>." | ||||
|                 ) | ||||
|             if CORE.using_esp_idf and CORE.data[KEY_CORE][ | ||||
|                 KEY_FRAMEWORK_VERSION | ||||
|             ] < cv.Version(4, 4, 3): | ||||
|                 raise cv.Invalid( | ||||
|                     "ESP32-S3 Internal Temperature Sensor requires framework version 4.4.3 or higher. See <https://github.com/esphome/issues/issues/4271>." | ||||
|                 ) | ||||
|     return config | ||||
|  | ||||
|  | ||||
| CONFIG_SCHEMA = cv.All( | ||||
|     sensor.sensor_schema( | ||||
|         InternalTemperatureSensor, | ||||
| @@ -51,7 +26,6 @@ CONFIG_SCHEMA = cv.All( | ||||
|         entity_category=ENTITY_CATEGORY_DIAGNOSTIC, | ||||
|     ).extend(cv.polling_component_schema("60s")), | ||||
|     cv.only_on([PLATFORM_ESP32, PLATFORM_RP2040, PLATFORM_BK72XX]), | ||||
|     validate_config, | ||||
| ) | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -83,9 +83,7 @@ void init_uart(uart_port_t uart_num, uint32_t baud_rate, int tx_buffer_size) { | ||||
|   uart_config.parity = UART_PARITY_DISABLE; | ||||
|   uart_config.stop_bits = UART_STOP_BITS_1; | ||||
|   uart_config.flow_ctrl = UART_HW_FLOWCTRL_DISABLE; | ||||
| #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) | ||||
|   uart_config.source_clk = UART_SCLK_DEFAULT; | ||||
| #endif | ||||
|   uart_param_config(uart_num, &uart_config); | ||||
|   const int uart_buffer_size = tx_buffer_size; | ||||
|   // Install UART driver using an event queue here | ||||
|   | ||||
| @@ -8,8 +8,6 @@ from esphome.const import ( | ||||
|     CONF_PROTOCOL, | ||||
|     CONF_SERVICE, | ||||
|     CONF_SERVICES, | ||||
|     KEY_CORE, | ||||
|     KEY_FRAMEWORK_VERSION, | ||||
| ) | ||||
| from esphome.core import CORE, coroutine_with_priority | ||||
|  | ||||
| @@ -85,9 +83,7 @@ async def to_code(config): | ||||
|         elif CORE.is_rp2040: | ||||
|             cg.add_library("LEAmDNS", None) | ||||
|  | ||||
|     if CORE.using_esp_idf and CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] >= cv.Version( | ||||
|         5, 0, 0 | ||||
|     ): | ||||
|     if CORE.using_esp_idf: | ||||
|         add_idf_component(name="espressif/mdns", ref="1.8.2") | ||||
|  | ||||
|     cg.add_define("USE_MDNS") | ||||
|   | ||||
| @@ -14,49 +14,6 @@ namespace mqtt { | ||||
| static const char *const TAG = "mqtt.idf"; | ||||
|  | ||||
| bool MQTTBackendESP32::initialize_() { | ||||
| #if ESP_IDF_VERSION_MAJOR < 5 | ||||
|   mqtt_cfg_.user_context = (void *) this; | ||||
|   mqtt_cfg_.buffer_size = MQTT_BUFFER_SIZE; | ||||
|  | ||||
|   mqtt_cfg_.host = this->host_.c_str(); | ||||
|   mqtt_cfg_.port = this->port_; | ||||
|   mqtt_cfg_.keepalive = this->keep_alive_; | ||||
|   mqtt_cfg_.disable_clean_session = !this->clean_session_; | ||||
|  | ||||
|   if (!this->username_.empty()) { | ||||
|     mqtt_cfg_.username = this->username_.c_str(); | ||||
|     if (!this->password_.empty()) { | ||||
|       mqtt_cfg_.password = this->password_.c_str(); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   if (!this->lwt_topic_.empty()) { | ||||
|     mqtt_cfg_.lwt_topic = this->lwt_topic_.c_str(); | ||||
|     this->mqtt_cfg_.lwt_qos = this->lwt_qos_; | ||||
|     this->mqtt_cfg_.lwt_retain = this->lwt_retain_; | ||||
|  | ||||
|     if (!this->lwt_message_.empty()) { | ||||
|       mqtt_cfg_.lwt_msg = this->lwt_message_.c_str(); | ||||
|       mqtt_cfg_.lwt_msg_len = this->lwt_message_.size(); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   if (!this->client_id_.empty()) { | ||||
|     mqtt_cfg_.client_id = this->client_id_.c_str(); | ||||
|   } | ||||
|   if (ca_certificate_.has_value()) { | ||||
|     mqtt_cfg_.cert_pem = ca_certificate_.value().c_str(); | ||||
|     mqtt_cfg_.skip_cert_common_name_check = skip_cert_cn_check_; | ||||
|     mqtt_cfg_.transport = MQTT_TRANSPORT_OVER_SSL; | ||||
|  | ||||
|     if (this->cl_certificate_.has_value() && this->cl_key_.has_value()) { | ||||
|       mqtt_cfg_.client_cert_pem = this->cl_certificate_.value().c_str(); | ||||
|       mqtt_cfg_.client_key_pem = this->cl_key_.value().c_str(); | ||||
|     } | ||||
|   } else { | ||||
|     mqtt_cfg_.transport = MQTT_TRANSPORT_OVER_TCP; | ||||
|   } | ||||
| #else | ||||
|   mqtt_cfg_.broker.address.hostname = this->host_.c_str(); | ||||
|   mqtt_cfg_.broker.address.port = this->port_; | ||||
|   mqtt_cfg_.session.keepalive = this->keep_alive_; | ||||
| @@ -95,7 +52,7 @@ bool MQTTBackendESP32::initialize_() { | ||||
|   } else { | ||||
|     mqtt_cfg_.broker.address.transport = MQTT_TRANSPORT_OVER_TCP; | ||||
|   } | ||||
| #endif | ||||
|  | ||||
|   auto *mqtt_client = esp_mqtt_client_init(&mqtt_cfg_); | ||||
|   if (mqtt_client) { | ||||
|     handler_.reset(mqtt_client); | ||||
|   | ||||
| @@ -272,18 +272,13 @@ bool OpenTherm::init_esp32_timer_() { | ||||
|   this->timer_idx_ = timer_idx; | ||||
|  | ||||
|   timer_config_t const config = { | ||||
|     .alarm_en = TIMER_ALARM_EN, | ||||
|     .counter_en = TIMER_PAUSE, | ||||
|     .intr_type = TIMER_INTR_LEVEL, | ||||
|     .counter_dir = TIMER_COUNT_UP, | ||||
|     .auto_reload = TIMER_AUTORELOAD_EN, | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
|     .clk_src = TIMER_SRC_CLK_DEFAULT, | ||||
| #endif | ||||
|     .divider = 80, | ||||
| #if defined(SOC_TIMER_GROUP_SUPPORT_XTAL) && ESP_IDF_VERSION_MAJOR < 5 | ||||
|     .clk_src = TIMER_SRC_CLK_APB | ||||
| #endif | ||||
|       .alarm_en = TIMER_ALARM_EN, | ||||
|       .counter_en = TIMER_PAUSE, | ||||
|       .intr_type = TIMER_INTR_LEVEL, | ||||
|       .counter_dir = TIMER_COUNT_UP, | ||||
|       .auto_reload = TIMER_AUTORELOAD_EN, | ||||
|       .clk_src = TIMER_SRC_CLK_DEFAULT, | ||||
|       .divider = 80, | ||||
|   }; | ||||
|  | ||||
|   esp_err_t result; | ||||
|   | ||||
| @@ -6,10 +6,7 @@ | ||||
|  | ||||
| #include <esp_ota_ops.h> | ||||
| #include <esp_task_wdt.h> | ||||
|  | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
| #include <spi_flash_mmap.h> | ||||
| #endif | ||||
|  | ||||
| namespace esphome { | ||||
| namespace ota_base { | ||||
| @@ -24,7 +21,6 @@ OTAResponseTypes IDFOTABackend::begin(size_t image_size) { | ||||
|  | ||||
| #if CONFIG_ESP_TASK_WDT_TIMEOUT_S < 15 | ||||
|   // The following function takes longer than the 5 seconds timeout of WDT | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
|   esp_task_wdt_config_t wdtc; | ||||
|   wdtc.idle_core_mask = 0; | ||||
| #if CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0 | ||||
| @@ -36,21 +32,14 @@ OTAResponseTypes IDFOTABackend::begin(size_t image_size) { | ||||
|   wdtc.timeout_ms = 15000; | ||||
|   wdtc.trigger_panic = false; | ||||
|   esp_task_wdt_reconfigure(&wdtc); | ||||
| #else | ||||
|   esp_task_wdt_init(15, false); | ||||
| #endif | ||||
| #endif | ||||
|  | ||||
|   esp_err_t err = esp_ota_begin(this->partition_, image_size, &this->update_handle_); | ||||
|  | ||||
| #if CONFIG_ESP_TASK_WDT_TIMEOUT_S < 15 | ||||
|   // Set the WDT back to the configured timeout | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
|   wdtc.timeout_ms = CONFIG_ESP_TASK_WDT_TIMEOUT_S * 1000; | ||||
|   esp_task_wdt_reconfigure(&wdtc); | ||||
| #else | ||||
|   esp_task_wdt_init(CONFIG_ESP_TASK_WDT_TIMEOUT_S, false); | ||||
| #endif | ||||
| #endif | ||||
|  | ||||
|   if (err != ESP_OK) { | ||||
|   | ||||
| @@ -2,9 +2,7 @@ | ||||
| #ifdef USE_ESP32 | ||||
| #include "psram.h" | ||||
| #include <esp_idf_version.h> | ||||
| #if defined(USE_ESP_IDF) && ESP_IDF_VERSION_MAJOR >= 5 | ||||
| #include <esp_psram.h> | ||||
| #endif  // USE_ESP_IDF | ||||
|  | ||||
| #include "esphome/core/log.h" | ||||
|  | ||||
| @@ -16,7 +14,6 @@ static const char *const TAG = "psram"; | ||||
|  | ||||
| void PsramComponent::dump_config() { | ||||
|   ESP_LOGCONFIG(TAG, "PSRAM:"); | ||||
| #if defined(USE_ESP_IDF) && ESP_IDF_VERSION_MAJOR >= 5 | ||||
|   bool available = esp_psram_is_initialized(); | ||||
|  | ||||
|   ESP_LOGCONFIG(TAG, "  Available: %s", YESNO(available)); | ||||
| @@ -26,23 +23,6 @@ void PsramComponent::dump_config() { | ||||
|     ESP_LOGCONFIG(TAG, "  ECC enabled: YES"); | ||||
| #endif | ||||
|   } | ||||
| #else | ||||
|   // Technically this can be false if the PSRAM is full, but heap_caps_get_total_size() isn't always available, and it's | ||||
|   // very unlikely for the PSRAM to be full. | ||||
|   bool available = heap_caps_get_free_size(MALLOC_CAP_SPIRAM) > 0; | ||||
|   ESP_LOGCONFIG(TAG, "  Available: %s", YESNO(available)); | ||||
|  | ||||
|   if (available) { | ||||
|     const size_t psram_total_size_bytes = heap_caps_get_total_size(MALLOC_CAP_SPIRAM); | ||||
|     const float psram_total_size_kb = psram_total_size_bytes / 1024.0f; | ||||
|  | ||||
|     if (abs(std::round(psram_total_size_kb) - psram_total_size_kb) < 0.05f) { | ||||
|       ESP_LOGCONFIG(TAG, "  Size: %.0f KB", psram_total_size_kb); | ||||
|     } else { | ||||
|       ESP_LOGCONFIG(TAG, "  Size: %zu bytes", psram_total_size_bytes); | ||||
|     } | ||||
|   } | ||||
| #endif  // USE_ESP_IDF | ||||
| } | ||||
|  | ||||
| }  // namespace psram | ||||
|   | ||||
| @@ -146,11 +146,7 @@ void PVVXDisplay::sync_time_() { | ||||
|   } | ||||
|   time.recalc_timestamp_utc(true);  // calculate timestamp of local time | ||||
|   uint8_t blk[5] = {}; | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
|   ESP_LOGD(TAG, "[%s] Sync time with timestamp %" PRIu64 ".", this->parent_->address_str().c_str(), time.timestamp); | ||||
| #else | ||||
|   ESP_LOGD(TAG, "[%s] Sync time with timestamp %lu.", this->parent_->address_str().c_str(), time.timestamp); | ||||
| #endif | ||||
|   blk[0] = 0x23; | ||||
|   blk[1] = time.timestamp & 0xff; | ||||
|   blk[2] = (time.timestamp >> 8) & 0xff; | ||||
|   | ||||
| @@ -10,10 +10,8 @@ void RpiDpiRgb::setup() { | ||||
|   this->reset_display_(); | ||||
|   esp_lcd_rgb_panel_config_t config{}; | ||||
|   config.flags.fb_in_psram = 1; | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
|   config.bounce_buffer_size_px = this->width_ * 10; | ||||
|   config.num_fbs = 1; | ||||
| #endif  // ESP_IDF_VERSION_MAJOR | ||||
|   config.timings.h_res = this->width_; | ||||
|   config.timings.v_res = this->height_; | ||||
|   config.timings.hsync_pulse_width = this->hsync_pulse_width_; | ||||
| @@ -47,10 +45,8 @@ void RpiDpiRgb::setup() { | ||||
|   ESP_LOGCONFIG(TAG, "RPI_DPI_RGB setup complete"); | ||||
| } | ||||
| void RpiDpiRgb::loop() { | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
|   if (this->handle_ != nullptr) | ||||
|     esp_lcd_rgb_panel_restart(this->handle_); | ||||
| #endif  // ESP_IDF_VERSION_MAJOR | ||||
| } | ||||
|  | ||||
| void RpiDpiRgb::draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorOrder order, | ||||
|   | ||||
| @@ -12,10 +12,8 @@ void ST7701S::setup() { | ||||
|  | ||||
|   esp_lcd_rgb_panel_config_t config{}; | ||||
|   config.flags.fb_in_psram = 1; | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
|   config.bounce_buffer_size_px = this->width_ * 10; | ||||
|   config.num_fbs = 1; | ||||
| #endif  // ESP_IDF_VERSION_MAJOR | ||||
|   config.timings.h_res = this->width_; | ||||
|   config.timings.v_res = this->height_; | ||||
|   config.timings.hsync_pulse_width = this->hsync_pulse_width_; | ||||
| @@ -48,10 +46,8 @@ void ST7701S::setup() { | ||||
| } | ||||
|  | ||||
| void ST7701S::loop() { | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
|   if (this->handle_ != nullptr) | ||||
|     esp_lcd_rgb_panel_restart(this->handle_); | ||||
| #endif  // ESP_IDF_VERSION_MAJOR | ||||
| } | ||||
|  | ||||
| void ST7701S::draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorOrder order, | ||||
|   | ||||
| @@ -48,11 +48,7 @@ uart_config_t IDFUARTComponent::get_config_() { | ||||
|   uart_config.parity = parity; | ||||
|   uart_config.stop_bits = this->stop_bits_ == 1 ? UART_STOP_BITS_1 : UART_STOP_BITS_2; | ||||
|   uart_config.flow_ctrl = UART_HW_FLOWCTRL_DISABLE; | ||||
| #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) | ||||
|   uart_config.source_clk = UART_SCLK_DEFAULT; | ||||
| #else | ||||
|   uart_config.source_clk = UART_SCLK_APB; | ||||
| #endif | ||||
|   uart_config.rx_flow_ctrl_thresh = 122; | ||||
|  | ||||
|   return uart_config; | ||||
|   | ||||
| @@ -38,16 +38,12 @@ WatchdogManager::~WatchdogManager() { | ||||
| void WatchdogManager::set_timeout_(uint32_t timeout_ms) { | ||||
|   ESP_LOGV(TAG, "Adjusting WDT to %" PRIu32 "ms", timeout_ms); | ||||
| #ifdef USE_ESP32 | ||||
| #if ESP_IDF_VERSION_MAJOR >= 5 | ||||
|   esp_task_wdt_config_t wdt_config = { | ||||
|       .timeout_ms = timeout_ms, | ||||
|       .idle_core_mask = (1 << SOC_CPU_CORES_NUM) - 1, | ||||
|       .trigger_panic = true, | ||||
|   }; | ||||
|   esp_task_wdt_reconfigure(&wdt_config); | ||||
| #else | ||||
|   esp_task_wdt_init(timeout_ms / 1000, true); | ||||
| #endif  // ESP_IDF_VERSION_MAJOR | ||||
| #endif  // USE_ESP32 | ||||
|  | ||||
| #ifdef USE_RP2040 | ||||
|   | ||||
| @@ -6,14 +6,7 @@ import esphome.codegen as cg | ||||
| from esphome.components import time | ||||
| from esphome.components.esp32 import CORE, add_idf_sdkconfig_option | ||||
| import esphome.config_validation as cv | ||||
| from esphome.const import ( | ||||
|     CONF_ADDRESS, | ||||
|     CONF_ID, | ||||
|     CONF_REBOOT_TIMEOUT, | ||||
|     CONF_TIME_ID, | ||||
|     KEY_CORE, | ||||
|     KEY_FRAMEWORK_VERSION, | ||||
| ) | ||||
| from esphome.const import CONF_ADDRESS, CONF_ID, CONF_REBOOT_TIMEOUT, CONF_TIME_ID | ||||
| from esphome.core import TimePeriod | ||||
|  | ||||
| CONF_NETMASK = "netmask" | ||||
| @@ -125,9 +118,7 @@ async def to_code(config): | ||||
|  | ||||
|     # Workaround for crash on IDF 5+ | ||||
|     # See https://github.com/trombik/esp_wireguard/issues/33#issuecomment-1568503651 | ||||
|     if CORE.using_esp_idf and CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] >= cv.Version( | ||||
|         5, 0, 0 | ||||
|     ): | ||||
|     if CORE.using_esp_idf: | ||||
|         add_idf_sdkconfig_option("CONFIG_LWIP_PPP_SUPPORT", True) | ||||
|  | ||||
|     # This flag is added here because the esp_wireguard library statically | ||||
|   | ||||
		Reference in New Issue
	
	Block a user