From 91925b1826f8cbefe01cdfedf66a247f68130f22 Mon Sep 17 00:00:00 2001
From: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
Date: Wed, 23 Nov 2022 09:54:55 +1300
Subject: [PATCH] Update ESP-IDF and platform version (#3565)

Co-authored-by: Otto Winter <otto@otto-winter.com>
---
 esphome/components/esp32/__init__.py               | 6 +++---
 esphome/components/ethernet/__init__.py            | 1 -
 esphome/components/ethernet/ethernet_component.cpp | 4 ++--
 esphome/components/ethernet/ethernet_component.h   | 4 ++--
 esphome/core/defines.h                             | 3 +--
 esphome/core/helpers.cpp                           | 2 +-
 esphome/core/helpers.h                             | 2 +-
 platformio.ini                                     | 4 ++--
 8 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/esphome/components/esp32/__init__.py b/esphome/components/esp32/__init__.py
index 1a52ee7314..2e9d9708a5 100644
--- a/esphome/components/esp32/__init__.py
+++ b/esphome/components/esp32/__init__.py
@@ -138,11 +138,11 @@ ARDUINO_PLATFORM_VERSION = cv.Version(5, 2, 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, 3, 2)
+RECOMMENDED_ESP_IDF_FRAMEWORK_VERSION = cv.Version(4, 4, 2)
 # 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(3, 5, 0)
+ESP_IDF_PLATFORM_VERSION = cv.Version(5, 2, 0)
 
 
 def _arduino_check_versions(value):
@@ -184,7 +184,7 @@ def _esp_idf_check_versions(value):
     value = value.copy()
     lookups = {
         "dev": (cv.Version(5, 0, 0), "https://github.com/espressif/esp-idf.git"),
-        "latest": (cv.Version(4, 3, 2), None),
+        "latest": (cv.Version(4, 4, 2), None),
         "recommended": (RECOMMENDED_ESP_IDF_FRAMEWORK_VERSION, None),
     }
 
diff --git a/esphome/components/ethernet/__init__.py b/esphome/components/ethernet/__init__.py
index 9b7a086d8d..b3614d8fcf 100644
--- a/esphome/components/ethernet/__init__.py
+++ b/esphome/components/ethernet/__init__.py
@@ -90,7 +90,6 @@ CONFIG_SCHEMA = cv.All(
         }
     ).extend(cv.COMPONENT_SCHEMA),
     _validate,
-    cv.only_with_arduino,
 )
 
 
diff --git a/esphome/components/ethernet/ethernet_component.cpp b/esphome/components/ethernet/ethernet_component.cpp
index c125b45ec1..c4be83d5d3 100644
--- a/esphome/components/ethernet/ethernet_component.cpp
+++ b/esphome/components/ethernet/ethernet_component.cpp
@@ -3,7 +3,7 @@
 #include "esphome/core/util.h"
 #include "esphome/core/application.h"
 
-#ifdef USE_ESP32_FRAMEWORK_ARDUINO
+#ifdef USE_ESP32
 
 #include <lwip/dns.h>
 #include "esp_event.h"
@@ -326,4 +326,4 @@ void EthernetComponent::set_use_address(const std::string &use_address) { this->
 }  // namespace ethernet
 }  // namespace esphome
 
-#endif  // USE_ESP32_FRAMEWORK_ARDUINO
+#endif  // USE_ESP32
diff --git a/esphome/components/ethernet/ethernet_component.h b/esphome/components/ethernet/ethernet_component.h
index 409dbd8ca5..ed784e1bc0 100644
--- a/esphome/components/ethernet/ethernet_component.h
+++ b/esphome/components/ethernet/ethernet_component.h
@@ -4,7 +4,7 @@
 #include "esphome/core/hal.h"
 #include "esphome/components/network/ip_address.h"
 
-#ifdef USE_ESP32_FRAMEWORK_ARDUINO
+#ifdef USE_ESP32
 
 #include "esp_eth.h"
 #include "esp_eth_mac.h"
@@ -86,4 +86,4 @@ extern EthernetComponent *global_eth_component;
 }  // namespace ethernet
 }  // namespace esphome
 
-#endif  // USE_ESP32_FRAMEWORK_ARDUINO
+#endif  // USE_ESP32
diff --git a/esphome/core/defines.h b/esphome/core/defines.h
index c1ec7d2213..01fc16cc02 100644
--- a/esphome/core/defines.h
+++ b/esphome/core/defines.h
@@ -79,8 +79,7 @@
 #endif
 
 #ifdef USE_ESP_IDF
-#define USE_ARDUINO_VERSION_CODE VERSION_CODE(4, 3, 0)
-#define USE_ESP32_IGNORE_EFUSE_MAC_CRC
+#define USE_ESP_IDF_VERSION_CODE VERSION_CODE(4, 4, 2)
 #endif
 #endif
 
diff --git a/esphome/core/helpers.cpp b/esphome/core/helpers.cpp
index 9f9a1f10b1..7ec5d9d23c 100644
--- a/esphome/core/helpers.cpp
+++ b/esphome/core/helpers.cpp
@@ -422,7 +422,7 @@ void HighFrequencyLoopRequester::stop() {
 }
 bool HighFrequencyLoopRequester::is_high_frequency() { return num_requests > 0; }
 
-void get_mac_address_raw(uint8_t *mac) {
+void get_mac_address_raw(uint8_t *mac) {  // NOLINT(readability-non-const-parameter)
 #if defined(USE_ESP32)
 #if defined(USE_ESP32_IGNORE_EFUSE_MAC_CRC)
   // On some devices, the MAC address that is burnt into EFuse does not
diff --git a/esphome/core/helpers.h b/esphome/core/helpers.h
index 6f3b5805cf..477dadc187 100644
--- a/esphome/core/helpers.h
+++ b/esphome/core/helpers.h
@@ -568,7 +568,7 @@ class HighFrequencyLoopRequester {
 };
 
 /// Get the device MAC address as raw bytes, written into the provided byte array (6 bytes).
-void get_mac_address_raw(uint8_t *mac);
+void get_mac_address_raw(uint8_t *mac);  // NOLINT(readability-non-const-parameter)
 
 /// Get the device MAC address as a string, in lowercase hex notation.
 std::string get_mac_address();
diff --git a/platformio.ini b/platformio.ini
index 144dd83229..918cd40888 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -133,9 +133,9 @@ extra_scripts = post:esphome/components/esp32/post_build.py.script
 ; This are common settings for the ESP32 (all variants) using IDF.
 [common:esp32-idf]
 extends = common:idf
-platform = platformio/espressif32 @ 3.5.0
+platform = platformio/espressif32 @ 5.2.0
 platform_packages =
-    platformio/framework-espidf @ ~3.40302.0
+    platformio/framework-espidf @ ~3.40402.0
 
 framework = espidf
 lib_deps =