From e9559ca24c8e4b8050015767aca50004ec58fc0c Mon Sep 17 00:00:00 2001 From: Erik Fleckstein Date: Thu, 17 Oct 2024 10:29:20 +0200 Subject: [PATCH] patches: Update for ESP-IDF 5.3 and arduino-esp32 3.1. Remove patches that were backported to 4.4 or are just not necessary anymore. Update other patches to compile against the new versions. Currently not all patches are applied automatically, for example lib-builder/managed_components/* --- ...Use-default-implementation-of-exists.patch | 41 ---- .../0002-ETH-Make-eth_handle-public.patch | 25 ++- ...03-WiFiGeneric-Add-ETH_LOST_IP-event.patch | 40 ---- ...ntSecure-esp_crt_bundle-re-implement.patch | 19 -- .../0005-WiFi-Increase-scan-timeout.patch | 38 ---- ...-reconnect-if-first-connect-after-st.patch | 74 +++--- .../0007-WiFi-Disable-11b-rates.patch | 75 ++++--- ...08-ETH-Do-not-enable-DHCP-by-default.patch | 55 +++-- ...-wifi-Add-setWriteNonBlocking-option.patch | 48 ---- ...-Fix-WPA-enterprise-cert-key-lengths.patch | 39 ++++ ...-patch-wifi-begin-for-wpa-enterprise.patch | 146 ------------ ...fi-provide-api-for-failure_retry_cnt.patch | 113 ---------- ...-wifi-set-STA-failure_retry_cnt-to-3.patch | 25 +++ ...work-Remove-unnecessary-subnet-check.patch | 37 +++ ...i_ap-remove-unnecessary-subnet-check.patch | 97 -------- ...ure-Don-t-break-if-PSK-cyphersuites-.patch | 53 +++++ ...-Don-t-break-if-PSK-cyphersuites-are.patch | 53 ----- ...ition-in-WiFiGenericClass-hostByName.patch | 77 ------- .../0001-Disable-unused-components.patch | 210 +++++++++++------- .../0002-Don-t-build-unused-variants.patch | 40 ---- ...round-for-interrupted-backtraces-on-.patch | 0 ...1-lwip-Increase-DNS_TABLE_SIZE-to-16.patch | 10 +- ...ement-active-socket-count-for-SSL-se.patch | 44 ---- ...cket-allow-users-to-attach-CA-bundle.patch | 50 ----- ...lient-Fix-esp_http_client-async-mode.patch | 31 --- .../lwip/0001-dns-Add-dns_removehost.patch | 34 +-- ...002-dns-Enforce-a-minimum-TTL-of-30s.patch | 61 ++--- ...in-netif_loop_output-if-tcpip_try_ca.patch | 85 ------- ...-around-for-broken-asymmetric-buffer.patch | 18 +- ...d-esp_mqtt_client_en-disable_receive.patch | 63 +++--- ...et-ws-path-if-not-set-via-passed-uri.patch | 18 +- ...fer-to-assemble-packets-on-stac.raw_patch} | 8 +- 32 files changed, 506 insertions(+), 1221 deletions(-) delete mode 100644 software/patches/arduino-esp32/0001-LittleFS-Use-default-implementation-of-exists.patch delete mode 100644 software/patches/arduino-esp32/0003-WiFiGeneric-Add-ETH_LOST_IP-event.patch delete mode 100644 software/patches/arduino-esp32/0004-Disable-WiFiClientSecure-esp_crt_bundle-re-implement.patch delete mode 100644 software/patches/arduino-esp32/0005-WiFi-Increase-scan-timeout.patch delete mode 100644 software/patches/arduino-esp32/0009-wifi-Add-setWriteNonBlocking-option.patch create mode 100644 software/patches/arduino-esp32/0010-STA-Fix-WPA-enterprise-cert-key-lengths.patch delete mode 100644 software/patches/arduino-esp32/0010-arduino_wifi-patch-wifi-begin-for-wpa-enterprise.patch delete mode 100644 software/patches/arduino-esp32/0011-wifi-provide-api-for-failure_retry_cnt.patch create mode 100644 software/patches/arduino-esp32/0011-wifi-set-STA-failure_retry_cnt-to-3.patch create mode 100644 software/patches/arduino-esp32/0012-network-Remove-unnecessary-subnet-check.patch delete mode 100644 software/patches/arduino-esp32/0012-wifi_ap-remove-unnecessary-subnet-check.patch create mode 100644 software/patches/arduino-esp32/0013-NetworkClientSecure-Don-t-break-if-PSK-cyphersuites-.patch delete mode 100644 software/patches/arduino-esp32/0013-WifiClientSecure-Don-t-break-if-PSK-cyphersuites-are.patch delete mode 100644 software/patches/arduino-esp32/0014-Fix-race-condition-in-WiFiGenericClass-hostByName.patch delete mode 100644 software/patches/lib-builder-pre/0002-Don-t-build-unused-variants.patch rename software/patches/{lib-builder => lib-builder-unknown}/esp-idf/0006-system-Add-workaround-for-interrupted-backtraces-on-.patch (100%) delete mode 100644 software/patches/lib-builder/esp-idf/0002-http_server-Increment-active-socket-count-for-SSL-se.patch delete mode 100644 software/patches/lib-builder/esp-idf/0003-feat-websocket-allow-users-to-attach-CA-bundle.patch delete mode 100644 software/patches/lib-builder/esp-idf/0007-fix-esp_http_client-Fix-esp_http_client-async-mode.patch delete mode 100644 software/patches/lib-builder/esp-idf/components/lwip/lwip/0003-fix-memory-leak-in-netif_loop_output-if-tcpip_try_ca.patch rename software/patches/lib-builder/{esp-idf/0004-mdns-Place-static-buffer-to-assemble-packets-on-stac.patch => managed_components/espressif__mdns/0004-mdns-Place-static-buffer-to-assemble-packets-on-stac.raw_patch} (83%) diff --git a/software/patches/arduino-esp32/0001-LittleFS-Use-default-implementation-of-exists.patch b/software/patches/arduino-esp32/0001-LittleFS-Use-default-implementation-of-exists.patch deleted file mode 100644 index bdde0abaa..000000000 --- a/software/patches/arduino-esp32/0001-LittleFS-Use-default-implementation-of-exists.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 842c7b8121b9fa9c39ee97b54a6528135f1aba1c Mon Sep 17 00:00:00 2001 -From: Erik Fleckstein -Date: Tue, 30 Nov 2021 11:52:01 +0100 -Subject: [PATCH] LittleFS: Use default implementation of ::exists(). - -This fixes the log spam when calling LittleFS::exists() on a -non-existing file. ---- - libraries/LittleFS/src/LittleFS.cpp | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/libraries/LittleFS/src/LittleFS.cpp b/libraries/LittleFS/src/LittleFS.cpp -index 9ea2320e..b4531c7e 100644 ---- a/libraries/LittleFS/src/LittleFS.cpp -+++ b/libraries/LittleFS/src/LittleFS.cpp -@@ -36,19 +36,19 @@ class LittleFSImpl : public VFSImpl - public: - LittleFSImpl(); - virtual ~LittleFSImpl() { } -- virtual bool exists(const char* path); -+ //virtual bool exists(const char* path); - }; - - LittleFSImpl::LittleFSImpl() - { - } -- -+/* - bool LittleFSImpl::exists(const char* path) - { - File f = open(path, "r",false); - return (f == true); - } -- -+*/ - LittleFSFS::LittleFSFS() : FS(FSImplPtr(new LittleFSImpl())), partitionLabel_(NULL) - { - } --- -2.33.1 - diff --git a/software/patches/arduino-esp32/0002-ETH-Make-eth_handle-public.patch b/software/patches/arduino-esp32/0002-ETH-Make-eth_handle-public.patch index f0787d0a7..d6e4cde70 100644 --- a/software/patches/arduino-esp32/0002-ETH-Make-eth_handle-public.patch +++ b/software/patches/arduino-esp32/0002-ETH-Make-eth_handle-public.patch @@ -1,6 +1,6 @@ -From 0cd6d432a38a5ff1a89f34778fec9df78236fd08 Mon Sep 17 00:00:00 2001 +From 2b8d6d219b740426a957a525ea43392fefc5fd7b Mon Sep 17 00:00:00 2001 From: Erik Fleckstein -Date: Fri, 3 Dec 2021 14:02:41 +0100 +Date: Wed, 16 Oct 2024 10:41:08 +0200 Subject: [PATCH] ETH: Make eth_handle public. --- @@ -8,18 +8,19 @@ Subject: [PATCH] ETH: Make eth_handle public. 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Ethernet/src/ETH.h b/libraries/Ethernet/src/ETH.h -index 918cd357..824b066d 100644 +index 14d2d042..10ab283b 100644 --- a/libraries/Ethernet/src/ETH.h +++ b/libraries/Ethernet/src/ETH.h -@@ -57,7 +57,7 @@ typedef enum { ETH_PHY_LAN8720, ETH_PHY_TLK110, ETH_PHY_RTL8201, ETH_PHY_DP83848 - #define ETH_PHY_IP101 ETH_PHY_TLK110 +@@ -182,8 +182,8 @@ protected: + public: + void _onEthEvent(int32_t event_id, void *event_data); - class ETHClass { -- private: -+ public: - bool initialized; - bool staticIP; - #if ESP_IDF_VERSION_MAJOR > 3 +-private: + esp_eth_handle_t _eth_handle; ++private: + uint8_t _eth_index; + eth_phy_type_t _phy_type; + esp_eth_netif_glue_handle_t _glue_handle; -- -2.33.1 +2.47.0 diff --git a/software/patches/arduino-esp32/0003-WiFiGeneric-Add-ETH_LOST_IP-event.patch b/software/patches/arduino-esp32/0003-WiFiGeneric-Add-ETH_LOST_IP-event.patch deleted file mode 100644 index 0946801c0..000000000 --- a/software/patches/arduino-esp32/0003-WiFiGeneric-Add-ETH_LOST_IP-event.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0c9d71e55b20cea6150fc683f77be6d0477a54c7 Mon Sep 17 00:00:00 2001 -From: Erik Fleckstein -Date: Fri, 13 May 2022 11:22:43 +0200 -Subject: [PATCH] WiFiGeneric: Add ETH_LOST_IP event. - ---- - libraries/WiFi/src/WiFiGeneric.cpp | 4 ++++ - libraries/WiFi/src/WiFiGeneric.h | 1 + - 2 files changed, 5 insertions(+) - -diff --git a/libraries/WiFi/src/WiFiGeneric.cpp b/libraries/WiFi/src/WiFiGeneric.cpp -index 41e06d59..d6ed38f8 100644 ---- a/libraries/WiFi/src/WiFiGeneric.cpp -+++ b/libraries/WiFi/src/WiFiGeneric.cpp -@@ -384,6 +384,10 @@ static void _arduino_event_cb(void* arg, esp_event_base_t event_base, int32_t ev - } else if (event_base == ETH_EVENT && event_id == ETHERNET_EVENT_STOP) { - log_v("Ethernet Stopped"); - arduino_event.event_id = ARDUINO_EVENT_ETH_STOP; -+ } else if (event_base == IP_EVENT && event_id == IP_EVENT_ETH_LOST_IP) { -+ ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data; -+ log_v("Ethernet lost ip."); -+ arduino_event.event_id = ARDUINO_EVENT_ETH_LOST_IP; - } else if (event_base == IP_EVENT && event_id == IP_EVENT_ETH_GOT_IP) { - #if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_VERBOSE - ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data; -diff --git a/libraries/WiFi/src/WiFiGeneric.h b/libraries/WiFi/src/WiFiGeneric.h -index 62642b43..3bbf0346 100644 ---- a/libraries/WiFi/src/WiFiGeneric.h -+++ b/libraries/WiFi/src/WiFiGeneric.h -@@ -58,6 +58,7 @@ typedef enum { - ARDUINO_EVENT_ETH_DISCONNECTED, - ARDUINO_EVENT_ETH_GOT_IP, - ARDUINO_EVENT_ETH_GOT_IP6, -+ ARDUINO_EVENT_ETH_LOST_IP, - ARDUINO_EVENT_WPS_ER_SUCCESS, - ARDUINO_EVENT_WPS_ER_FAILED, - ARDUINO_EVENT_WPS_ER_TIMEOUT, --- -2.36.0 - diff --git a/software/patches/arduino-esp32/0004-Disable-WiFiClientSecure-esp_crt_bundle-re-implement.patch b/software/patches/arduino-esp32/0004-Disable-WiFiClientSecure-esp_crt_bundle-re-implement.patch deleted file mode 100644 index 0e6017135..000000000 --- a/software/patches/arduino-esp32/0004-Disable-WiFiClientSecure-esp_crt_bundle-re-implement.patch +++ /dev/null @@ -1,19 +0,0 @@ -From ae7cdb0f7fa90f8b2500063f6a2d7081b5f5e2c3 Mon Sep 17 00:00:00 2001 -From: Erik Fleckstein -Date: Wed, 26 Oct 2022 14:36:11 +0200 -Subject: [PATCH] Disable WiFiClientSecure esp_crt_bundle re-implementation. - -Registering the default cert bundle does not work with this, however -with the original ESP-IDF implementation it does. ---- - .../src/{esp_crt_bundle.c => esp_crt_bundle.c.disabled} | 0 - 1 file changed, 0 insertions(+), 0 deletions(-) - rename libraries/WiFiClientSecure/src/{esp_crt_bundle.c => esp_crt_bundle.c.disabled} (100%) - -diff --git a/libraries/WiFiClientSecure/src/esp_crt_bundle.c b/libraries/WiFiClientSecure/src/esp_crt_bundle.c.disabled -similarity index 100% -rename from libraries/WiFiClientSecure/src/esp_crt_bundle.c -rename to libraries/WiFiClientSecure/src/esp_crt_bundle.c.disabled --- -2.38.0 - diff --git a/software/patches/arduino-esp32/0005-WiFi-Increase-scan-timeout.patch b/software/patches/arduino-esp32/0005-WiFi-Increase-scan-timeout.patch deleted file mode 100644 index 8ce8909a5..000000000 --- a/software/patches/arduino-esp32/0005-WiFi-Increase-scan-timeout.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 123e6c6e03121cc2d3ad72130fc6ae505704afce Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Mattias=20Sch=C3=A4ffersmann?= -Date: Fri, 2 Dec 2022 13:58:17 +0100 -Subject: [PATCH] WiFi: Increase scan timeout. - -Previous timeout might be long enough to scan 11 channels but it is barely not enough to scan 13 channels. -Also fix misleading indentation. ---- - libraries/WiFi/src/WiFiScan.cpp | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/libraries/WiFi/src/WiFiScan.cpp b/libraries/WiFi/src/WiFiScan.cpp -index f4a32e49..e3909c5f 100644 ---- a/libraries/WiFi/src/WiFiScan.cpp -+++ b/libraries/WiFi/src/WiFiScan.cpp -@@ -60,7 +60,7 @@ int16_t WiFiScanClass::scanNetworks(bool async, bool show_hidden, bool passive, - return WIFI_SCAN_RUNNING; - } - -- WiFiScanClass::_scanTimeout = max_ms_per_chan * 20; -+ WiFiScanClass::_scanTimeout = max_ms_per_chan * 30; // Previous multiplicator of 20 might be enough for 11 channels, but 13 channels require a multiplicator of at least 22. - WiFiScanClass::_scanAsync = async; - - WiFi.enableSTA(true); -@@ -83,8 +83,8 @@ int16_t WiFiScanClass::scanNetworks(bool async, bool show_hidden, bool passive, - if(esp_wifi_scan_start(&config, false) == ESP_OK) { - _scanStarted = millis(); - if (!_scanStarted) { //Prevent 0 from millis overflow -- ++_scanStarted; -- } -+ ++_scanStarted; -+ } - - WiFiGenericClass::clearStatusBits(WIFI_SCAN_DONE_BIT); - WiFiGenericClass::setStatusBits(WIFI_SCANNING_BIT); --- -2.30.2 - diff --git a/software/patches/arduino-esp32/0006-Remove-automatic-reconnect-if-first-connect-after-st.patch b/software/patches/arduino-esp32/0006-Remove-automatic-reconnect-if-first-connect-after-st.patch index c555a5ee4..2bc9ae5a0 100644 --- a/software/patches/arduino-esp32/0006-Remove-automatic-reconnect-if-first-connect-after-st.patch +++ b/software/patches/arduino-esp32/0006-Remove-automatic-reconnect-if-first-connect-after-st.patch @@ -1,47 +1,45 @@ -From bd8c0377eac15db67cac1746bebc411aeed94933 Mon Sep 17 00:00:00 2001 +From 84d66d04511edab3be8c2f62f982f342326522e4 Mon Sep 17 00:00:00 2001 From: Erik Fleckstein -Date: Mon, 13 Nov 2023 13:09:19 +0100 +Date: Wed, 16 Oct 2024 10:49:53 +0200 Subject: [PATCH] Remove automatic reconnect if first connect after startup fails. --- - libraries/WiFi/src/WiFiGeneric.cpp | 9 +-------- - 1 file changed, 1 insertion(+), 8 deletions(-) + libraries/WiFi/src/STA.cpp | 7 +------ + 1 file changed, 1 insertion(+), 6 deletions(-) -diff --git a/libraries/WiFi/src/WiFiGeneric.cpp b/libraries/WiFi/src/WiFiGeneric.cpp -index 3760285d..d182adc6 100644 ---- a/libraries/WiFi/src/WiFiGeneric.cpp -+++ b/libraries/WiFi/src/WiFiGeneric.cpp -@@ -1036,8 +1036,6 @@ void WiFiGenericClass::removeEvent(wifi_event_id_t id) - */ - esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event) - { -- static bool first_connect = true; -- - if(!event) return ESP_OK; //Null would crash this function +diff --git a/libraries/WiFi/src/STA.cpp b/libraries/WiFi/src/STA.cpp +index 443d2621..582d5c52 100644 +--- a/libraries/WiFi/src/STA.cpp ++++ b/libraries/WiFi/src/STA.cpp +@@ -106,7 +106,6 @@ static void _onStaArduinoEvent(arduino_event_t *ev) { + if (_sta_network_if == NULL || ev->event_id < ARDUINO_EVENT_WIFI_STA_START || ev->event_id > ARDUINO_EVENT_WIFI_STA_LOST_IP) { + return; + } +- static bool first_connect = true; + log_v("Arduino STA Event: %d - %s", ev->event_id, Network.eventName(ev->event_id)); - log_d("Arduino Event: %d - %s", event->event_id, WiFi.eventName(event->event_id)); -@@ -1065,7 +1063,7 @@ esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event) - log_w("Reason: %u - %s", reason, WiFi.disconnectReasonName((wifi_err_reason_t)reason)); - if(reason == WIFI_REASON_NO_AP_FOUND) { - WiFiSTAClass::_setStatus(WL_NO_SSID_AVAIL); -- } else if((reason == WIFI_REASON_AUTH_FAIL) && !first_connect){ -+ } else if((reason == WIFI_REASON_AUTH_FAIL)){ - WiFiSTAClass::_setStatus(WL_CONNECT_FAILED); - } else if(reason == WIFI_REASON_BEACON_TIMEOUT || reason == WIFI_REASON_HANDSHAKE_TIMEOUT) { - WiFiSTAClass::_setStatus(WL_CONNECTION_LOST); -@@ -1079,11 +1077,6 @@ esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event) - bool DoReconnect = false; - if(reason == WIFI_REASON_ASSOC_LEAVE) { //Voluntarily disconnected. Don't reconnect! - } -- else if(first_connect) { //Retry once for all failure reasons -- first_connect = false; -- DoReconnect = true; -- log_d("WiFi Reconnect Running"); -- } - else if(WiFi.getAutoReconnect() && _isReconnectableReason(reason)) { - DoReconnect = true; - log_d("WiFi AutoReconnect Running"); + if (ev->event_id == ARDUINO_EVENT_WIFI_STA_START) { +@@ -135,7 +134,7 @@ static void _onStaArduinoEvent(arduino_event_t *ev) { + log_w("Reason: %u - %s", reason, WiFi.STA.disconnectReasonName((wifi_err_reason_t)reason)); + if (reason == WIFI_REASON_NO_AP_FOUND) { + _sta_network_if->_setStatus(WL_NO_SSID_AVAIL); +- } else if ((reason == WIFI_REASON_AUTH_FAIL) && !first_connect) { ++ } else if ((reason == WIFI_REASON_AUTH_FAIL)) { + _sta_network_if->_setStatus(WL_CONNECT_FAILED); + } else if (reason == WIFI_REASON_BEACON_TIMEOUT || reason == WIFI_REASON_HANDSHAKE_TIMEOUT) { + _sta_network_if->_setStatus(WL_CONNECTION_LOST); +@@ -147,10 +146,6 @@ static void _onStaArduinoEvent(arduino_event_t *ev) { + + bool DoReconnect = false; + if (reason == WIFI_REASON_ASSOC_LEAVE) { //Voluntarily disconnected. Don't reconnect! +- } else if (first_connect) { //Retry once for all failure reasons +- first_connect = false; +- DoReconnect = true; +- log_d("WiFi Reconnect Running"); + } else if (_sta_network_if->getAutoReconnect() && _is_staReconnectableReason(reason)) { + DoReconnect = true; + log_d("WiFi AutoReconnect Running"); -- -2.42.0 +2.47.0 diff --git a/software/patches/arduino-esp32/0007-WiFi-Disable-11b-rates.patch b/software/patches/arduino-esp32/0007-WiFi-Disable-11b-rates.patch index 6ef9e7b87..41f1547b0 100644 --- a/software/patches/arduino-esp32/0007-WiFi-Disable-11b-rates.patch +++ b/software/patches/arduino-esp32/0007-WiFi-Disable-11b-rates.patch @@ -1,20 +1,20 @@ -From ae2270cb8d16c9cb3b63707ef67b03255943d160 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Mattias=20Sch=C3=A4ffersmann?= -Date: Thu, 23 May 2024 17:13:04 +0200 +From e9f4396e362918b8fe535c764b222dcec941f8e2 Mon Sep 17 00:00:00 2001 +From: Erik Fleckstein +Date: Wed, 16 Oct 2024 10:54:17 +0200 Subject: [PATCH] WiFi: Disable 11b rates 802.11b has been obsolete for about 20 years. Keeping compatibility around slows down devices not 20 years old. --- - libraries/WiFi/src/WiFiGeneric.cpp | 15 +++++++++++++++ + libraries/WiFi/src/WiFiGeneric.cpp | 16 ++++++++++++++++ libraries/WiFi/src/WiFiGeneric.h | 2 ++ - 2 files changed, 17 insertions(+) + 2 files changed, 18 insertions(+) diff --git a/libraries/WiFi/src/WiFiGeneric.cpp b/libraries/WiFi/src/WiFiGeneric.cpp -index 98fb6e60..d7328f8d 100644 +index ccc95181..2f363389 100644 --- a/libraries/WiFi/src/WiFiGeneric.cpp +++ b/libraries/WiFi/src/WiFiGeneric.cpp -@@ -766,6 +766,7 @@ static std::vector cbEventList; +@@ -333,6 +333,7 @@ static bool espWiFiStop() { bool WiFiGenericClass::_persistent = true; bool WiFiGenericClass::_long_range = false; @@ -22,8 +22,8 @@ index 98fb6e60..d7328f8d 100644 wifi_mode_t WiFiGenericClass::_forceSleepLastMode = WIFI_MODE_NULL; #if CONFIG_IDF_TARGET_ESP32S2 wifi_ps_type_t WiFiGenericClass::_sleepEnabled = WIFI_PS_NONE; -@@ -1238,6 +1239,14 @@ void WiFiGenericClass::enableLongRange(bool enable) - _long_range = enable; +@@ -444,6 +445,15 @@ void WiFiGenericClass::enableLongRange(bool enable) { + _long_range = enable; } +/** @@ -34,42 +34,43 @@ index 98fb6e60..d7328f8d 100644 +{ + _disable_sta_11b = disable; +} - ++ /** * set new mode -@@ -1286,6 +1295,12 @@ bool WiFiGenericClass::mode(wifi_mode_t m) - } - } + * @param m WiFiMode_t +@@ -526,6 +536,12 @@ bool WiFiGenericClass::mode(wifi_mode_t m) { + } } -+ // 11b is long obsolete. true = disable. Don't care if it can't be disabled. -+ // Disable both because neither can be changed when trying to switch mode later. -+ // Always disable 11b on AP because beacons are sent at minimum rate. -+ esp_wifi_config_11b_rate(WIFI_IF_STA, _disable_sta_11b); -+ esp_wifi_config_11b_rate(WIFI_IF_AP, true); + } ++ // 11b is long obsolete. true = disable. Don't care if it can't be disabled. ++ // Disable both because neither can be changed when trying to switch mode later. ++ // Always disable 11b on AP because beacons are sent at minimum rate. ++ esp_wifi_config_11b_rate(WIFI_IF_STA, _disable_sta_11b); ++ esp_wifi_config_11b_rate(WIFI_IF_AP, true); + - if(!espWiFiStart()){ - return false; - } + if (!espWiFiStart()) { + return false; + } diff --git a/libraries/WiFi/src/WiFiGeneric.h b/libraries/WiFi/src/WiFiGeneric.h -index 894c1346..e5d04100 100644 +index 2a5ca812..1886b95b 100644 --- a/libraries/WiFi/src/WiFiGeneric.h +++ b/libraries/WiFi/src/WiFiGeneric.h -@@ -173,6 +173,7 @@ class WiFiGenericClass +@@ -92,6 +92,7 @@ public: - void persistent(bool persistent); - void enableLongRange(bool enable); -+ void disableSTA11b(bool disable); + void persistent(bool persistent); + void enableLongRange(bool enable); ++ void disableSTA11b(bool disable); - static bool mode(wifi_mode_t); - static wifi_mode_t getMode(); -@@ -205,6 +206,7 @@ class WiFiGenericClass - protected: - static bool _persistent; - static bool _long_range; -+ static bool _disable_sta_11b; - static wifi_mode_t _forceSleepLastMode; - static wifi_ps_type_t _sleepEnabled; - static bool _wifiUseStaticBuffers; + static bool mode(wifi_mode_t); + static wifi_mode_t getMode(); +@@ -133,6 +134,7 @@ public: + protected: + static bool _persistent; + static bool _long_range; ++ static bool _disable_sta_11b; + static wifi_mode_t _forceSleepLastMode; + static wifi_ps_type_t _sleepEnabled; + static bool _wifiUseStaticBuffers; -- -2.39.2 +2.47.0 diff --git a/software/patches/arduino-esp32/0008-ETH-Do-not-enable-DHCP-by-default.patch b/software/patches/arduino-esp32/0008-ETH-Do-not-enable-DHCP-by-default.patch index ed2fec517..7c257a803 100644 --- a/software/patches/arduino-esp32/0008-ETH-Do-not-enable-DHCP-by-default.patch +++ b/software/patches/arduino-esp32/0008-ETH-Do-not-enable-DHCP-by-default.patch @@ -1,6 +1,6 @@ -From b98f2f92763e480d440c9db3090c3c8c2e8e3d3b Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Mattias=20Sch=C3=A4ffersmann?= -Date: Tue, 11 Apr 2023 14:19:16 +0200 +From ca51496b2cebf5b6df7514d53bfebe2acb039ef1 Mon Sep 17 00:00:00 2001 +From: Erik Fleckstein +Date: Wed, 16 Oct 2024 11:07:19 +0200 Subject: [PATCH] ETH: Do not enable DHCP by default. Leaving DHCP enabled by default leads to race conditions during @@ -9,40 +9,35 @@ turned on if actually required. As this fixes the race condition, the 50ms delay to work around it isn't required anymore. - -Also disable extraneous ARP spam while we're at it. --- - libraries/Ethernet/src/ETH.cpp | 10 +++++++--- - 1 file changed, 7 insertions(+), 3 deletions(-) + libraries/Ethernet/src/ETH.cpp | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libraries/Ethernet/src/ETH.cpp b/libraries/Ethernet/src/ETH.cpp -index 166f212f..592afbe9 100644 +index 13f9c11f..5b43e599 100644 --- a/libraries/Ethernet/src/ETH.cpp +++ b/libraries/Ethernet/src/ETH.cpp -@@ -243,6 +243,13 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ - tcpip_adapter_set_default_eth_handlers(); - - esp_netif_config_t cfg = ESP_NETIF_DEFAULT_ETH(); -+ -+ // Do not enable DHCP by default. -+ // Also disable "GAP" while we're at it. It's not Gratuitous ARP but instead polls the device's own IP every minute. -+ auto base_cfg = *cfg.base; -+ base_cfg.flags = (esp_netif_flags_t)(base_cfg.flags - ESP_NETIF_DHCP_CLIENT - ESP_NETIF_FLAG_GARP); -+ cfg.base = &base_cfg; -+ - esp_netif_t *eth_netif = esp_netif_new(&cfg); +@@ -284,6 +284,9 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i + esp_netif_config.if_key = if_key_str; + esp_netif_config.if_desc = if_desc_str; + esp_netif_config.route_prio -= _eth_index * 5; ++ // Do not enable DHCP by default. ++ // Also disable "GAP" while we're at it. It's not Gratuitous ARP but instead polls the device's own IP every minute. ++ esp_netif_config.flags = (esp_netif_flags_t)(esp_netif_config.flags - ESP_NETIF_DHCP_CLIENT - ESP_NETIF_FLAG_GARP); + + cfg.base = &esp_netif_config; - esp_eth_mac_t *eth_mac = NULL; -@@ -396,9 +403,6 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ - log_e("esp_eth_init error: %d", err); +@@ -357,10 +360,6 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i } - #endif -- // holds a few milliseconds to let DHCP start and enter into a good state -- // FIX ME -- adresses issue https://github.com/espressif/arduino-esp32/issues/5733 -- delay(50); + } + +- // holds a few milliseconds to let DHCP start and enter into a good state +- // FIX ME -- addresses issue https://github.com/espressif/arduino-esp32/issues/5733 +- delay(50); +- + return true; - return true; - } + err: -- -2.30.2 +2.47.0 diff --git a/software/patches/arduino-esp32/0009-wifi-Add-setWriteNonBlocking-option.patch b/software/patches/arduino-esp32/0009-wifi-Add-setWriteNonBlocking-option.patch deleted file mode 100644 index b6a45e263..000000000 --- a/software/patches/arduino-esp32/0009-wifi-Add-setWriteNonBlocking-option.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 9526bb0163f052a75950c3a63be1bd05e2814e8f Mon Sep 17 00:00:00 2001 -From: Matthias Bolte -Date: Wed, 25 Oct 2023 14:06:24 +0200 -Subject: [PATCH] wifi: Add setWriteNonBlocking option - -Needed to stop ModbusTCP from blocking 10 seconds on a write in case -of connection loss. ---- - libraries/WiFi/src/WiFiClient.cpp | 2 +- - libraries/WiFi/src/WiFiClient.h | 2 ++ - 2 files changed, 3 insertions(+), 1 deletion(-) - -diff --git a/libraries/WiFi/src/WiFiClient.cpp b/libraries/WiFi/src/WiFiClient.cpp -index 85c34832..66fd85c5 100644 ---- a/libraries/WiFi/src/WiFiClient.cpp -+++ b/libraries/WiFi/src/WiFiClient.cpp -@@ -405,7 +405,7 @@ size_t WiFiClient::write(const uint8_t *buf, size_t size) - FD_ZERO(&set); // empties the set - FD_SET(socketFileDescriptor, &set); // adds FD to the set - tv.tv_sec = 0; -- tv.tv_usec = WIFI_CLIENT_SELECT_TIMEOUT_US; -+ tv.tv_usec = _writeNonBlocking ? 0 : WIFI_CLIENT_SELECT_TIMEOUT_US; - retry--; - - if(select(socketFileDescriptor + 1, NULL, &set, NULL, &tv) < 0) { -diff --git a/libraries/WiFi/src/WiFiClient.h b/libraries/WiFi/src/WiFiClient.h -index b18f9324..fe7ac1e0 100644 ---- a/libraries/WiFi/src/WiFiClient.h -+++ b/libraries/WiFi/src/WiFiClient.h -@@ -43,6 +43,7 @@ protected: - std::shared_ptr _rxBuffer; - bool _connected; - int _timeout; -+ bool _writeNonBlocking; - - public: - WiFiClient *next; -@@ -57,6 +58,7 @@ public: - size_t write(const uint8_t *buf, size_t size); - size_t write_P(PGM_P buf, size_t size); - size_t write(Stream &stream); -+ void setWriteNonBlocking(bool nonBlocking) { _writeNonBlocking = nonBlocking; } - int available(); - int read(); - int read(uint8_t *buf, size_t size); --- -2.34.1 - diff --git a/software/patches/arduino-esp32/0010-STA-Fix-WPA-enterprise-cert-key-lengths.patch b/software/patches/arduino-esp32/0010-STA-Fix-WPA-enterprise-cert-key-lengths.patch new file mode 100644 index 000000000..502d4db85 --- /dev/null +++ b/software/patches/arduino-esp32/0010-STA-Fix-WPA-enterprise-cert-key-lengths.patch @@ -0,0 +1,39 @@ +From 9afa90f11455c7c5f3741b19420b6ade6bbe8306 Mon Sep 17 00:00:00 2001 +From: Erik Fleckstein +Date: Wed, 16 Oct 2024 13:45:32 +0200 +Subject: [PATCH] STA: Fix WPA enterprise cert/key lengths. + +The eap_client wants lengths including the null terminator. +--- + libraries/WiFi/src/STA.cpp | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/libraries/WiFi/src/STA.cpp b/libraries/WiFi/src/STA.cpp +index 5649bd53..c13b0da2 100644 +--- a/libraries/WiFi/src/STA.cpp ++++ b/libraries/WiFi/src/STA.cpp +@@ -477,17 +477,17 @@ bool STAClass::connect( + + if (ca_pem) { + #if __has_include("esp_eap_client.h") +- esp_eap_client_set_ca_cert((uint8_t *)ca_pem, strlen(ca_pem)); ++ esp_eap_client_set_ca_cert((uint8_t *)ca_pem, strlen(ca_pem) + 1); + #else +- esp_wifi_sta_wpa2_ent_set_ca_cert((uint8_t *)ca_pem, strlen(ca_pem)); ++ esp_wifi_sta_wpa2_ent_set_ca_cert((uint8_t *)ca_pem, strlen(ca_pem) + 1); + #endif + } + + if (client_crt) { + #if __has_include("esp_eap_client.h") +- esp_eap_client_set_certificate_and_key((uint8_t *)client_crt, strlen(client_crt), (uint8_t *)client_key, strlen(client_key), NULL, 0); ++ esp_eap_client_set_certificate_and_key((uint8_t *)client_crt, strlen(client_crt) + 1, (uint8_t *)client_key, strlen(client_key) + 1, NULL, 0); + #else +- esp_wifi_sta_wpa2_ent_set_cert_key((uint8_t *)client_crt, strlen(client_crt), (uint8_t *)client_key, strlen(client_key), NULL, 0); ++ esp_wifi_sta_wpa2_ent_set_cert_key((uint8_t *)client_crt, strlen(client_crt) + 1, (uint8_t *)client_key, strlen(client_key) + 1, NULL, 0); + #endif + } + +-- +2.47.0 + diff --git a/software/patches/arduino-esp32/0010-arduino_wifi-patch-wifi-begin-for-wpa-enterprise.patch b/software/patches/arduino-esp32/0010-arduino_wifi-patch-wifi-begin-for-wpa-enterprise.patch deleted file mode 100644 index c0430e437..000000000 --- a/software/patches/arduino-esp32/0010-arduino_wifi-patch-wifi-begin-for-wpa-enterprise.patch +++ /dev/null @@ -1,146 +0,0 @@ -From de7e7c9e495727d6a5d0d32d9ef99b9aeec77619 Mon Sep 17 00:00:00 2001 -From: Frederic Henrichs -Date: Wed, 29 Nov 2023 10:28:25 +0100 -Subject: [PATCH] arduino_wifi: patch wifi begin for wpa enterprise. - - - add certificate sizes - - actually use channel, bssid and connect arguments ---- - libraries/WiFi/src/WiFiSTA.cpp | 34 ++++++++++++++++++++++++---------- - libraries/WiFi/src/WiFiSTA.h | 8 ++++---- - 2 files changed, 28 insertions(+), 14 deletions(-) - -diff --git a/libraries/WiFi/src/WiFiSTA.cpp b/libraries/WiFi/src/WiFiSTA.cpp -index 185aaa84..2ba06079 100644 ---- a/libraries/WiFi/src/WiFiSTA.cpp -+++ b/libraries/WiFi/src/WiFiSTA.cpp -@@ -165,7 +165,21 @@ wl_status_t WiFiSTAClass::status() - * @param connect Optional. call connect - * @return - */ --wl_status_t WiFiSTAClass::begin(const char* wpa2_ssid, wpa2_auth_method_t method, const char* wpa2_identity, const char* wpa2_username, const char *wpa2_password, const char* ca_pem, const char* client_crt, const char* client_key, int32_t channel, const uint8_t* bssid, bool connect) -+wl_status_t WiFiSTAClass::begin(const char* wpa2_ssid, -+ wpa2_auth_method_t method, -+ const char* wpa2_identity, -+ const char* wpa2_username, -+ const char *wpa2_password, -+ const char* ca_pem, -+ const size_t ca_size, -+ const char* client_crt, -+ const size_t client_crt_size, -+ const char* client_key, -+ const size_t client_key_size, -+ const char *client_key_password, -+ int32_t channel, -+ const uint8_t* bssid, -+ bool connect) - { - if(!WiFi.enableSTA(true)) { - log_e("STA enable failed!"); -@@ -192,11 +206,11 @@ wl_status_t WiFiSTAClass::begin(const char* wpa2_ssid, wpa2_auth_method_t method - } - - if(ca_pem) { -- esp_wifi_sta_wpa2_ent_set_ca_cert((uint8_t *)ca_pem, strlen(ca_pem)); -+ esp_wifi_sta_wpa2_ent_set_ca_cert((uint8_t *)ca_pem, ca_size + 1); - } - - if(client_crt) { -- esp_wifi_sta_wpa2_ent_set_cert_key((uint8_t *)client_crt, strlen(client_crt), (uint8_t *)client_key, strlen(client_key), NULL, 0); -+ esp_wifi_sta_wpa2_ent_set_cert_key((uint8_t *)client_crt, client_crt_size + 1, (uint8_t *)client_key, client_key_size + 1, (uint8_t *)client_key_password, strlen(client_key_password)); - } - - esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)wpa2_identity, strlen(wpa2_identity)); -@@ -205,7 +219,7 @@ wl_status_t WiFiSTAClass::begin(const char* wpa2_ssid, wpa2_auth_method_t method - esp_wifi_sta_wpa2_ent_set_password((uint8_t *)wpa2_password, strlen(wpa2_password)); - } - esp_wifi_sta_wpa2_ent_enable(); //set config settings to enable function -- WiFi.begin(wpa2_ssid); //connect to wifi -+ WiFi.begin(wpa2_ssid, nullptr, channel, bssid, connect); //connect to wifi - - return status(); - } -@@ -425,7 +439,7 @@ void WiFiSTAClass::setMinSecurity(wifi_auth_mode_t minSecurity) - } - - /** -- * Set the way that AP is chosen. -+ * Set the way that AP is chosen. - * First SSID match[WIFI_FAST_SCAN] or Sorted[WIFI_ALL_CHANNEL_SCAN] (RSSI or Security) - * Must be called before WiFi.begin() - * @param scanMethod wifi_scan_method_t -@@ -436,7 +450,7 @@ void WiFiSTAClass::setScanMethod(wifi_scan_method_t scanMethod) - } - - /** -- * Set the way that AP is sorted. (requires scanMethod WIFI_ALL_CHANNEL_SCAN) -+ * Set the way that AP is sorted. (requires scanMethod WIFI_ALL_CHANNEL_SCAN) - * By SSID[WIFI_CONNECT_AP_BY_SIGNAL] or Security[WIFI_CONNECT_AP_BY_SECURITY] - * Must be called before WiFi.begin() - * @param sortMethod wifi_sort_method_t -@@ -470,9 +484,9 @@ bool WiFiSTAClass::getAutoConnect() - } - - /** -- * Function used to set the automatic reconnection if the connection is lost. -+ * Function used to set the automatic reconnection if the connection is lost. - * @param autoReconnect `true` to enable this option. -- * @return true -+ * @return true - */ - bool WiFiSTAClass::setAutoReconnect(bool autoReconnect) - { -@@ -769,8 +783,8 @@ bool WiFiSTAClass::_smartConfigStarted = false; - bool WiFiSTAClass::_smartConfigDone = false; - - /** -- * @brief -- * -+ * @brief -+ * - * @param type Select type of SmartConfig. Default type is SC_TYPE_ESPTOUCH - * @param crypt_key When using type SC_TYPE_ESPTOUTCH_V2 crypt key needed, else ignored. Lenght should be 16 chars. - * @return true if configuration is successful. -diff --git a/libraries/WiFi/src/WiFiSTA.h b/libraries/WiFi/src/WiFiSTA.h -index 0b8f9daf..2face262 100644 ---- a/libraries/WiFi/src/WiFiSTA.h -+++ b/libraries/WiFi/src/WiFiSTA.h -@@ -44,7 +44,7 @@ class WiFiSTAClass - - public: - -- wl_status_t begin(const char* wpa2_ssid, wpa2_auth_method_t method, const char* wpa2_identity=NULL, const char* wpa2_username=NULL, const char *wpa2_password=NULL, const char* ca_pem=NULL, const char* client_crt=NULL, const char* client_key=NULL, int32_t channel=0, const uint8_t* bssid=0, bool connect=true); -+ wl_status_t begin(const char* wpa2_ssid, wpa2_auth_method_t method, const char* wpa2_identity=NULL, const char* wpa2_username=NULL, const char *wpa2_password=NULL, const char* ca_pem=NULL, const size_t ca_size = 0, const char* client_crt=NULL, const size_t client_crt_size = 0, const char* client_key=NULL, const size_t client_key_size = 0, const char *client_key_password = NULL, int32_t channel=0, const uint8_t* bssid=0, bool connect=true); - wl_status_t begin(const String& wpa2_ssid, wpa2_auth_method_t method, const String& wpa2_identity = (const char*)NULL, const String& wpa2_username = (const char*)NULL, const String& wpa2_password = (const char*)NULL, const String& ca_pem = (const char*)NULL, const String& client_crt = (const char*)NULL, const String& client_key = (const char*)NULL, int32_t channel=0, const uint8_t* bssid=0, bool connect=true) { - return begin(wpa2_ssid.c_str(), method, wpa2_identity.c_str(), wpa2_username.c_str(), wpa2_password.c_str(), ca_pem.c_str(), client_crt.c_str(), client_key.c_str(), channel, bssid, connect); - } -@@ -89,7 +89,7 @@ public: - IPAddress broadcastIP(); - IPAddress networkID(); - uint8_t subnetCIDR(); -- -+ - bool enableIpV6(); - IPv6Address localIPv6(); - -@@ -104,7 +104,7 @@ public: - int8_t RSSI(); - - static void _setStatus(wl_status_t status); -- -+ - protected: - static bool _useStaticIp; - static bool _autoReconnect; -@@ -112,7 +112,7 @@ protected: - static wifi_scan_method_t _scanMethod; - static wifi_sort_method_t _sortMethod; - --public: -+public: - bool beginSmartConfig(smartconfig_type_t type = SC_TYPE_ESPTOUCH, char* crypt_key = NULL); - bool stopSmartConfig(); - bool smartConfigDone(); --- -2.34.1 - diff --git a/software/patches/arduino-esp32/0011-wifi-provide-api-for-failure_retry_cnt.patch b/software/patches/arduino-esp32/0011-wifi-provide-api-for-failure_retry_cnt.patch deleted file mode 100644 index 515db85e9..000000000 --- a/software/patches/arduino-esp32/0011-wifi-provide-api-for-failure_retry_cnt.patch +++ /dev/null @@ -1,113 +0,0 @@ -From eb6513f8adc464cb4b4f66a108e865777922f24d Mon Sep 17 00:00:00 2001 -From: Frederic Henrichs -Date: Fri, 1 Dec 2023 15:51:35 +0100 -Subject: [PATCH] wifi: provide api for failure_retry_cnt. - -see https://github.com/Tinkerforge/esp32-firmware/issues/234 ---- - libraries/WiFi/src/WiFiSTA.cpp | 25 ++++++++++++++----------- - libraries/WiFi/src/WiFiSTA.h | 10 ++++++---- - 2 files changed, 20 insertions(+), 15 deletions(-) - -diff --git a/libraries/WiFi/src/WiFiSTA.cpp b/libraries/WiFi/src/WiFiSTA.cpp -index 2ba06079..a8e6c7b8 100644 ---- a/libraries/WiFi/src/WiFiSTA.cpp -+++ b/libraries/WiFi/src/WiFiSTA.cpp -@@ -83,10 +83,17 @@ static bool sta_config_equal(const wifi_config_t& lhs, const wifi_config_t& rhs) - return true; - } - --static void wifi_sta_config(wifi_config_t * wifi_config, const char * ssid=NULL, const char * password=NULL, const uint8_t * bssid=NULL, uint8_t channel=0, wifi_auth_mode_t min_security=WIFI_AUTH_WPA2_PSK, wifi_scan_method_t scan_method=WIFI_ALL_CHANNEL_SCAN, wifi_sort_method_t sort_method=WIFI_CONNECT_AP_BY_SIGNAL, uint16_t listen_interval=0, bool pmf_required=false){ -+static void wifi_sta_config(wifi_config_t * wifi_config, const char * ssid=NULL, const char * password=NULL, const uint8_t * bssid=NULL, uint8_t channel=0, wifi_auth_mode_t min_security=WIFI_AUTH_WPA2_PSK, wifi_scan_method_t scan_method=WIFI_ALL_CHANNEL_SCAN, wifi_sort_method_t sort_method=WIFI_CONNECT_AP_BY_SIGNAL, uint16_t listen_interval=0, bool pmf_required=false, uint8_t retries=0){ - wifi_config->sta.channel = channel; - wifi_config->sta.listen_interval = listen_interval; -- wifi_config->sta.scan_method = scan_method;//WIFI_ALL_CHANNEL_SCAN or WIFI_FAST_SCAN -+ -+ // according to the espressif documentation failure_retry_cnt is only used when scan_method is set to WIFI_ALL_CHANNEL_SCAN -+ if (retries != 0) { -+ wifi_config->sta.scan_method = WIFI_ALL_CHANNEL_SCAN; -+ wifi_config->sta.failure_retry_cnt = retries; -+ } else { -+ wifi_config->sta.scan_method = scan_method;//WIFI_ALL_CHANNEL_SCAN or WIFI_FAST_SCAN -+ } - wifi_config->sta.sort_method = sort_method;//WIFI_CONNECT_AP_BY_SIGNAL or WIFI_CONNECT_AP_BY_SECURITY - wifi_config->sta.threshold.rssi = -127; - wifi_config->sta.pmf_cfg.capable = true; -@@ -179,7 +186,8 @@ wl_status_t WiFiSTAClass::begin(const char* wpa2_ssid, - const char *client_key_password, - int32_t channel, - const uint8_t* bssid, -- bool connect) -+ bool connect, -+ uint8_t retries) - { - if(!WiFi.enableSTA(true)) { - log_e("STA enable failed!"); -@@ -219,7 +227,7 @@ wl_status_t WiFiSTAClass::begin(const char* wpa2_ssid, - esp_wifi_sta_wpa2_ent_set_password((uint8_t *)wpa2_password, strlen(wpa2_password)); - } - esp_wifi_sta_wpa2_ent_enable(); //set config settings to enable function -- WiFi.begin(wpa2_ssid, nullptr, channel, bssid, connect); //connect to wifi -+ WiFi.begin(wpa2_ssid, nullptr, channel, bssid, connect, retries); //connect to wifi - - return status(); - } -@@ -234,7 +242,7 @@ wl_status_t WiFiSTAClass::begin(const char* wpa2_ssid, - * @param connect Optional. call connect - * @return - */ --wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_t channel, const uint8_t* bssid, bool connect) -+wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_t channel, const uint8_t* bssid, bool connect, uint8_t retries) - { - - if(!WiFi.enableSTA(true)) { -@@ -255,7 +263,7 @@ wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_ - wifi_config_t conf; - memset(&conf, 0, sizeof(wifi_config_t)); - -- wifi_sta_config(&conf, ssid, passphrase, bssid, channel, _minSecurity, _scanMethod, _sortMethod); -+ wifi_sta_config(&conf, ssid, passphrase, bssid, channel, _minSecurity, _scanMethod, _sortMethod, 0, false, retries); - - wifi_config_t current_conf; - if(esp_wifi_get_config((wifi_interface_t)ESP_IF_WIFI_STA, ¤t_conf) != ESP_OK){ -@@ -297,11 +305,6 @@ wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_ - return status(); - } - --wl_status_t WiFiSTAClass::begin(char* ssid, char *passphrase, int32_t channel, const uint8_t* bssid, bool connect) --{ -- return begin((const char*) ssid, (const char*) passphrase, channel, bssid, connect); --} -- - /** - * Use to connect to SDK config. - * @return wl_status_t -diff --git a/libraries/WiFi/src/WiFiSTA.h b/libraries/WiFi/src/WiFiSTA.h -index 2face262..c1689b1e 100644 ---- a/libraries/WiFi/src/WiFiSTA.h -+++ b/libraries/WiFi/src/WiFiSTA.h -@@ -44,15 +44,17 @@ class WiFiSTAClass - - public: - -- wl_status_t begin(const char* wpa2_ssid, wpa2_auth_method_t method, const char* wpa2_identity=NULL, const char* wpa2_username=NULL, const char *wpa2_password=NULL, const char* ca_pem=NULL, const size_t ca_size = 0, const char* client_crt=NULL, const size_t client_crt_size = 0, const char* client_key=NULL, const size_t client_key_size = 0, const char *client_key_password = NULL, int32_t channel=0, const uint8_t* bssid=0, bool connect=true); -+ wl_status_t begin(const char* wpa2_ssid, wpa2_auth_method_t method, const char* wpa2_identity=NULL, const char* wpa2_username=NULL, const char *wpa2_password=NULL, const char* ca_pem=NULL, const size_t ca_size = 0, const char* client_crt=NULL, const size_t client_crt_size = 0, const char* client_key=NULL, const size_t client_key_size = 0, const char *client_key_password = NULL, int32_t channel=0, const uint8_t* bssid=0, bool connect=true, uint8_t retries = 0); - wl_status_t begin(const String& wpa2_ssid, wpa2_auth_method_t method, const String& wpa2_identity = (const char*)NULL, const String& wpa2_username = (const char*)NULL, const String& wpa2_password = (const char*)NULL, const String& ca_pem = (const char*)NULL, const String& client_crt = (const char*)NULL, const String& client_key = (const char*)NULL, int32_t channel=0, const uint8_t* bssid=0, bool connect=true) { - return begin(wpa2_ssid.c_str(), method, wpa2_identity.c_str(), wpa2_username.c_str(), wpa2_password.c_str(), ca_pem.c_str(), client_crt.c_str(), client_key.c_str(), channel, bssid, connect); - } -- wl_status_t begin(const char* ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true); -- wl_status_t begin(const String& ssid, const String& passphrase = (const char*)NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true) { -+ wl_status_t begin(const char* ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true, uint8_t retries = 0); -+ wl_status_t begin(const String& ssid, const String& passphrase = (const char*)NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true, uint8_t retries = 0) { - return begin(ssid.c_str(), passphrase.c_str(), channel, bssid, connect); - } -- wl_status_t begin(char* ssid, char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true); -+ wl_status_t begin(char* ssid, char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true, uint8_t retries = 0) { -+ return begin((const char*)ssid, (const char*)passphrase, channel, bssid, connect, retries); -+ } - wl_status_t begin(); - - bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000); --- -2.34.1 - diff --git a/software/patches/arduino-esp32/0011-wifi-set-STA-failure_retry_cnt-to-3.patch b/software/patches/arduino-esp32/0011-wifi-set-STA-failure_retry_cnt-to-3.patch new file mode 100644 index 000000000..d6e3f1e5b --- /dev/null +++ b/software/patches/arduino-esp32/0011-wifi-set-STA-failure_retry_cnt-to-3.patch @@ -0,0 +1,25 @@ +From 0679c61e0075edf5636046669bbb8c721ef187ba Mon Sep 17 00:00:00 2001 +From: Erik Fleckstein +Date: Wed, 16 Oct 2024 11:26:14 +0200 +Subject: [PATCH] wifi: set STA failure_retry_cnt to 3. + +See https://github.com/Tinkerforge/esp32-firmware/issues/234 +--- + libraries/WiFi/src/STA.cpp | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libraries/WiFi/src/STA.cpp b/libraries/WiFi/src/STA.cpp +index 582d5c52..5649bd53 100644 +--- a/libraries/WiFi/src/STA.cpp ++++ b/libraries/WiFi/src/STA.cpp +@@ -381,6 +381,7 @@ bool STAClass::connect(const char *ssid, const char *passphrase, int32_t channel + conf.sta.sort_method = _sortMethod; + conf.sta.threshold.rssi = -127; + conf.sta.pmf_cfg.capable = true; ++ conf.sta.failure_retry_cnt = 3; + if (ssid != NULL && ssid[0] != 0) { + _wifi_strncpy((char *)conf.sta.ssid, ssid, 32); + if (passphrase != NULL && passphrase[0] != 0) { +-- +2.47.0 + diff --git a/software/patches/arduino-esp32/0012-network-Remove-unnecessary-subnet-check.patch b/software/patches/arduino-esp32/0012-network-Remove-unnecessary-subnet-check.patch new file mode 100644 index 000000000..5210dbc70 --- /dev/null +++ b/software/patches/arduino-esp32/0012-network-Remove-unnecessary-subnet-check.patch @@ -0,0 +1,37 @@ +From 73be1acc6e1bc56a57a3ffdefffc549dafac7eb0 Mon Sep 17 00:00:00 2001 +From: Erik Fleckstein +Date: Wed, 16 Oct 2024 11:47:25 +0200 +Subject: [PATCH] network: Remove unnecessary subnet check. + +--- + libraries/Network/src/NetworkInterface.cpp | 9 --------- + 1 file changed, 9 deletions(-) + +diff --git a/libraries/Network/src/NetworkInterface.cpp b/libraries/Network/src/NetworkInterface.cpp +index f4bb1d48..e59525bf 100644 +--- a/libraries/Network/src/NetworkInterface.cpp ++++ b/libraries/Network/src/NetworkInterface.cpp +@@ -427,20 +427,11 @@ bool NetworkInterface::config(IPAddress local_ip, IPAddress gateway, IPAddress s + + dhcps_lease_t lease; + lease.enable = true; +- uint8_t CIDR = calculateSubnetCIDR(subnet); + log_v( + "SoftAP: %s | Gateway: %s | DHCP Start: %s | Netmask: %s", local_ip.toString().c_str(), gateway.toString().c_str(), dns1.toString().c_str(), + subnet.toString().c_str() + ); +- // netmask must have room for at least 12 IP addresses (AP + GW + 10 DHCP Leasing addresses) +- // netmask also must be limited to the last 8 bits of IPv4, otherwise this function won't work +- // IDF NETIF checks netmask for the 3rd byte: https://github.com/espressif/esp-idf/blob/master/components/esp_netif/lwip/esp_netif_lwip.c#L1857-L1862 +- if (CIDR > 28 || CIDR < 24) { +- log_e("Bad netmask. It must be from /24 to /28 (255.255.255. 0<->240)"); +- return false; // ESP_FAIL if initializing failed +- } + #define _byte_swap32(num) (((num >> 24) & 0xff) | ((num << 8) & 0xff0000) | ((num >> 8) & 0xff00) | ((num << 24) & 0xff000000)) +- // The code below is ready for any netmask, not limited to 255.255.255.0 + uint32_t netmask = _byte_swap32(info.netmask.addr); + uint32_t ap_ipaddr = _byte_swap32(info.ip.addr); + uint32_t dhcp_ipaddr = _byte_swap32(static_cast(dns1)); +-- +2.47.0 + diff --git a/software/patches/arduino-esp32/0012-wifi_ap-remove-unnecessary-subnet-check.patch b/software/patches/arduino-esp32/0012-wifi_ap-remove-unnecessary-subnet-check.patch deleted file mode 100644 index 11c4b5729..000000000 --- a/software/patches/arduino-esp32/0012-wifi_ap-remove-unnecessary-subnet-check.patch +++ /dev/null @@ -1,97 +0,0 @@ -From f8c6172014c394b843e1066364248ddd3149b4a1 Mon Sep 17 00:00:00 2001 -From: Frederic Henrichs -Date: Tue, 5 Dec 2023 14:15:54 +0100 -Subject: [PATCH] wifi_ap: remove unnecessary subnet check. - ---- - libraries/WiFi/src/WiFiGeneric.cpp | 24 ++++++++---------------- - 1 file changed, 8 insertions(+), 16 deletions(-) - -diff --git a/libraries/WiFi/src/WiFiGeneric.cpp b/libraries/WiFi/src/WiFiGeneric.cpp -index 78026313..d4e7d4ed 100644 ---- a/libraries/WiFi/src/WiFiGeneric.cpp -+++ b/libraries/WiFi/src/WiFiGeneric.cpp -@@ -139,16 +139,8 @@ esp_err_t set_esp_interface_ip(esp_interface_t interface, IPAddress local_ip=IPA - - dhcps_lease_t lease; - lease.enable = true; -- uint8_t CIDR = WiFiGenericClass::calculateSubnetCIDR(subnet); - log_v("SoftAP: %s | Gateway: %s | DHCP Start: %s | Netmask: %s", local_ip.toString().c_str(), gateway.toString().c_str(), dhcp_lease_start.toString().c_str(), subnet.toString().c_str()); -- // netmask must have room for at least 12 IP addresses (AP + GW + 10 DHCP Leasing addresses) -- // netmask also must be limited to the last 8 bits of IPv4, otherwise this function won't work -- // IDF NETIF checks netmask for the 3rd byte: https://github.com/espressif/esp-idf/blob/master/components/esp_netif/lwip/esp_netif_lwip.c#L1857-L1862 -- if (CIDR > 28 || CIDR < 24) { -- log_e("Bad netmask. It must be from /24 to /28 (255.255.255. 0<->240)"); -- return ESP_FAIL; // ESP_FAIL if initializing failed -- } -- // The code below is ready for any netmask, not limited to 255.255.255.0 -+ - uint32_t netmask = _byte_swap32(info.netmask.addr); - uint32_t ap_ipaddr = _byte_swap32(info.ip.addr); - uint32_t dhcp_ipaddr = _byte_swap32(static_cast(dhcp_lease_start)); -@@ -159,7 +151,7 @@ esp_err_t set_esp_interface_ip(esp_interface_t interface, IPAddress local_ip=IPA - lease.end_ip.addr = lease.start_ip.addr + 10; - // Check if local_ip is in the same subnet as the dhcp leasing range initial address - if ((ap_ipaddr & netmask) != (dhcp_ipaddr & netmask)) { -- log_e("The AP IP address (%s) and the DHCP start address (%s) must be in the same subnet", -+ log_e("The AP IP address (%s) and the DHCP start address (%s) must be in the same subnet", - local_ip.toString().c_str(), IPAddress(_byte_swap32(dhcp_ipaddr)).toString().c_str()); - return ESP_FAIL; // ESP_FAIL if initializing failed - } -@@ -172,7 +164,7 @@ esp_err_t set_esp_interface_ip(esp_interface_t interface, IPAddress local_ip=IPA - } - // Check if local_ip is within DHCP range - if (ap_ipaddr >= lease.start_ip.addr && ap_ipaddr <= lease.end_ip.addr) { -- log_e("The AP IP address (%s) can't be within the DHCP range (%s -- %s)", -+ log_e("The AP IP address (%s) can't be within the DHCP range (%s -- %s)", - local_ip.toString().c_str(), IPAddress(_byte_swap32(lease.start_ip.addr)).toString().c_str(), IPAddress(_byte_swap32(lease.end_ip.addr)).toString().c_str()); - return ESP_FAIL; // ESP_FAIL if initializing failed - } -@@ -180,7 +172,7 @@ esp_err_t set_esp_interface_ip(esp_interface_t interface, IPAddress local_ip=IPA - uint32_t gw_ipaddr = _byte_swap32(info.gw.addr); - bool gw_in_same_subnet = (gw_ipaddr & netmask) == (ap_ipaddr & netmask); - if (gw_in_same_subnet && gw_ipaddr >= lease.start_ip.addr && gw_ipaddr <= lease.end_ip.addr) { -- log_e("The GatewayP address (%s) can't be within the DHCP range (%s -- %s)", -+ log_e("The GatewayP address (%s) can't be within the DHCP range (%s -- %s)", - gateway.toString().c_str(), IPAddress(_byte_swap32(lease.start_ip.addr)).toString().c_str(), IPAddress(_byte_swap32(lease.end_ip.addr)).toString().c_str()); - return ESP_FAIL; // ESP_FAIL if initializing failed - } -@@ -548,7 +540,7 @@ static void _arduino_event_cb(void* arg, esp_event_base_t event_base, int32_t ev - log_v("Provisioning Success!"); - arduino_event.event_id = ARDUINO_EVENT_PROV_CRED_SUCCESS; - } -- -+ - if(arduino_event.event_id < ARDUINO_EVENT_MAX){ - postArduinoEvent(&arduino_event); - } -@@ -649,7 +641,7 @@ bool WiFiGenericClass::useStaticBuffers(){ - void WiFiGenericClass::useStaticBuffers(bool bufferMode){ - if (lowLevelInitDone) { - log_w("WiFi already started. Call WiFi.mode(WIFI_MODE_NULL) before setting Static Buffer Mode."); -- } -+ } - _wifiUseStaticBuffers = bufferMode; - } - -@@ -772,7 +764,7 @@ wifi_ps_type_t WiFiGenericClass::_sleepEnabled = WIFI_PS_NONE; - wifi_ps_type_t WiFiGenericClass::_sleepEnabled = WIFI_PS_MIN_MODEM; - #endif - --WiFiGenericClass::WiFiGenericClass() -+WiFiGenericClass::WiFiGenericClass() - { - } - -@@ -1598,7 +1590,7 @@ IPAddress WiFiGenericClass::calculateNetworkID(IPAddress ip, IPAddress subnet) { - - IPAddress WiFiGenericClass::calculateBroadcast(IPAddress ip, IPAddress subnet) { - IPAddress broadcastIp; -- -+ - for (int i = 0; i < 4; i++) - broadcastIp[i] = ~subnet[i] | ip[i]; - --- -2.34.1 - diff --git a/software/patches/arduino-esp32/0013-NetworkClientSecure-Don-t-break-if-PSK-cyphersuites-.patch b/software/patches/arduino-esp32/0013-NetworkClientSecure-Don-t-break-if-PSK-cyphersuites-.patch new file mode 100644 index 000000000..ef74c28cb --- /dev/null +++ b/software/patches/arduino-esp32/0013-NetworkClientSecure-Don-t-break-if-PSK-cyphersuites-.patch @@ -0,0 +1,53 @@ +From 76f5a9141ca375b7c9affc5b492689f65d1d995b Mon Sep 17 00:00:00 2001 +From: Erik Fleckstein +Date: Wed, 16 Oct 2024 11:51:17 +0200 +Subject: [PATCH] NetworkClientSecure: Don't break if PSK cyphersuites are + disabled. + +--- + libraries/NetworkClientSecure/src/ssl_client.cpp | 11 +++++------ + 1 file changed, 5 insertions(+), 6 deletions(-) + +diff --git a/libraries/NetworkClientSecure/src/ssl_client.cpp b/libraries/NetworkClientSecure/src/ssl_client.cpp +index 0f93f5cd..244d146b 100644 +--- a/libraries/NetworkClientSecure/src/ssl_client.cpp ++++ b/libraries/NetworkClientSecure/src/ssl_client.cpp +@@ -19,11 +19,6 @@ + #include "ssl_client.h" + #include "esp_crt_bundle.h" + +-#if !defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) && !defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) +-#warning \ +- "Please call `idf.py menuconfig` then go to Component config -> mbedTLS -> TLS Key Exchange Methods -> Enable pre-shared-key ciphersuites and then check `Enable PSK based ciphersuite modes`. Save and Quit." +-#else +- + const char *pers = "esp32-tls"; + + static int _handle_error(int err, const char *function, int line) { +@@ -213,6 +208,10 @@ int start_ssl_client( + log_e("useRootCABundle is set, but attach_ssl_certificate_bundle(ssl, true); was not called!"); + } + } else if (pskIdent != NULL && psKey != NULL) { ++#if !defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) && !defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) ++ log_e("PSK based cyphersuite modes not supported"); ++ return -1; ++#else + log_v("Setting up PSK"); + // convert PSK from hex to binary + if ((strlen(psKey) & 1) != 0 || strlen(psKey) > 2 * MBEDTLS_PSK_MAX_LEN) { +@@ -251,6 +250,7 @@ int start_ssl_client( + log_e("mbedtls_ssl_conf_psk returned %d", ret); + return handle_error(ret); + } ++#endif + } else { + return -1; + } +@@ -630,4 +630,3 @@ bool verify_ssl_dn(sslclient_context *ssl_client, const char *domain_name) { + + return false; + } +-#endif +-- +2.47.0 + diff --git a/software/patches/arduino-esp32/0013-WifiClientSecure-Don-t-break-if-PSK-cyphersuites-are.patch b/software/patches/arduino-esp32/0013-WifiClientSecure-Don-t-break-if-PSK-cyphersuites-are.patch deleted file mode 100644 index f108f0515..000000000 --- a/software/patches/arduino-esp32/0013-WifiClientSecure-Don-t-break-if-PSK-cyphersuites-are.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 4123f20682276f8d9ab4db2907160df2e6fdf835 Mon Sep 17 00:00:00 2001 -From: Erik Fleckstein -Date: Tue, 6 Feb 2024 16:29:49 +0100 -Subject: [PATCH] WifiClientSecure: Don't break if PSK cyphersuites are - disabled. - ---- - libraries/WiFiClientSecure/src/ssl_client.cpp | 11 +++++------ - 1 file changed, 5 insertions(+), 6 deletions(-) - -diff --git a/libraries/WiFiClientSecure/src/ssl_client.cpp b/libraries/WiFiClientSecure/src/ssl_client.cpp -index a8b570a8..41ac4428 100644 ---- a/libraries/WiFiClientSecure/src/ssl_client.cpp -+++ b/libraries/WiFiClientSecure/src/ssl_client.cpp -@@ -20,10 +20,6 @@ - #include "esp_crt_bundle.h" - #include "WiFi.h" - --#if !defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) && !defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) --# warning "Please call `idf.py menuconfig` then go to Component config -> mbedTLS -> TLS Key Exchange Methods -> Enable pre-shared-key ciphersuites and then check `Enable PSK based cyphersuite modes`. Save and Quit." --#else -- - const char *pers = "esp32-tls"; - - static int _handle_error(int err, const char * function, int line) -@@ -194,6 +190,10 @@ int start_ssl_client(sslclient_context *ssl_client, const IPAddress& ip, uint32_ - return handle_error(ret); - } - } else if (pskIdent != NULL && psKey != NULL) { -+#if !defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) && !defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) -+ log_e("PSK based cyphersuite modes not supported"); -+ return -1; -+#else - log_v("Setting up PSK"); - // convert PSK from hex to binary - if ((strlen(psKey) & 1) != 0 || strlen(psKey) > 2*MBEDTLS_PSK_MAX_LEN) { -@@ -223,6 +223,7 @@ int start_ssl_client(sslclient_context *ssl_client, const IPAddress& ip, uint32_ - log_e("mbedtls_ssl_conf_psk returned %d", ret); - return handle_error(ret); - } -+#endif - } else { - return -1; - } -@@ -551,5 +552,3 @@ bool verify_ssl_dn(sslclient_context *ssl_client, const char* domain_name) - - return false; - } --#endif -- --- -2.43.0 - diff --git a/software/patches/arduino-esp32/0014-Fix-race-condition-in-WiFiGenericClass-hostByName.patch b/software/patches/arduino-esp32/0014-Fix-race-condition-in-WiFiGenericClass-hostByName.patch deleted file mode 100644 index 10dcae9af..000000000 --- a/software/patches/arduino-esp32/0014-Fix-race-condition-in-WiFiGenericClass-hostByName.patch +++ /dev/null @@ -1,77 +0,0 @@ -From 70101e58a6802269db95e49985c891eeca2e7491 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Mattias=20Sch=C3=A4ffersmann?= -Date: Tue, 26 Sep 2023 14:41:41 +0200 -Subject: [PATCH] Fix race condition in WiFiGenericClass::hostByName - -dns_gethostbyname, as used in hostByName, is required to run in lwIP's TCP/IP -context. This can be verified by enabling LWIP_CHECK_THREAD_SAFETY in the -sdkconfig. - -Calling dns_gethostbyname from the Arduino task can trigger race conditions -in lwIP or lower layers. One possibility is a corruption of IDF's Ethernet -buffers, causing an unstoppable flood of "insufficient TX buffer size" errors, -effectively severing all Ethernet connectivity. - -This patch makes sure to call dns_gethostbyname from lwIP's TCP/IP context. ---- - libraries/WiFi/src/WiFiGeneric.cpp | 27 +++++++++++++++++++++++---- - 1 file changed, 23 insertions(+), 4 deletions(-) - -diff --git a/libraries/WiFi/src/WiFiGeneric.cpp b/libraries/WiFi/src/WiFiGeneric.cpp -index a6bc47e8..c7faf7f2 100644 ---- a/libraries/WiFi/src/WiFiGeneric.cpp -+++ b/libraries/WiFi/src/WiFiGeneric.cpp -@@ -36,6 +36,7 @@ extern "C" { - #include - #include - #include -+#include - #include "lwip/ip_addr.h" - #include "lwip/opt.h" - #include "lwip/err.h" -@@ -1550,6 +1551,22 @@ static void wifi_dns_found_callback(const char *name, const ip_addr_t *ipaddr, v - xEventGroupSetBits(_arduino_event_group, WIFI_DNS_DONE_BIT); - } - -+typedef struct gethostbynameParameters { -+ const char *hostname; -+ ip_addr_t addr; -+ void *callback_arg; -+} gethostbynameParameters_t; -+ -+/** -+ * Callback to execute dns_gethostbyname in lwIP's TCP/IP context -+ * @param param Parameters for dns_gethostbyname call -+ */ -+static esp_err_t wifi_gethostbyname_tcpip_ctx(void *param) -+{ -+ gethostbynameParameters_t *parameters = static_cast(param); -+ return dns_gethostbyname(parameters->hostname, ¶meters->addr, &wifi_dns_found_callback, parameters->callback_arg); -+} -+ - /** - * Resolve the given hostname to an IP address. If passed hostname is an IP address, it will be parsed into IPAddress structure. - * @param aHostname Name to be resolved or string containing IP address -@@ -1561,13 +1578,15 @@ int WiFiGenericClass::hostByName(const char* aHostname, IPAddress& aResult) - { - if (!aResult.fromString(aHostname)) - { -- ip_addr_t addr; -+ gethostbynameParameters_t params; -+ params.hostname = aHostname; -+ params.callback_arg = &aResult; - aResult = static_cast(0); - waitStatusBits(WIFI_DNS_IDLE_BIT, 16000); - clearStatusBits(WIFI_DNS_IDLE_BIT | WIFI_DNS_DONE_BIT); -- err_t err = dns_gethostbyname(aHostname, &addr, &wifi_dns_found_callback, &aResult); -- if(err == ERR_OK && addr.u_addr.ip4.addr) { -- aResult = addr.u_addr.ip4.addr; -+ err_t err = esp_netif_tcpip_exec(wifi_gethostbyname_tcpip_ctx, ¶ms); -+ if(err == ERR_OK && params.addr.u_addr.ip4.addr) { -+ aResult = params.addr.u_addr.ip4.addr; - } else if(err == ERR_INPROGRESS) { - waitStatusBits(WIFI_DNS_DONE_BIT, 15000); //real internal timeout in lwip library is 14[s] - clearStatusBits(WIFI_DNS_DONE_BIT); --- -2.39.2 - diff --git a/software/patches/lib-builder-pre/0001-Disable-unused-components.patch b/software/patches/lib-builder-pre/0001-Disable-unused-components.patch index d3290737f..b0c5392c1 100644 --- a/software/patches/lib-builder-pre/0001-Disable-unused-components.patch +++ b/software/patches/lib-builder-pre/0001-Disable-unused-components.patch @@ -1,85 +1,141 @@ -From dcd4c7d30c90b14c2fa51626d7e8406289df42c6 Mon Sep 17 00:00:00 2001 +From d759800b7c6b6d56a8bb6a33781a6635f2de733f Mon Sep 17 00:00:00 2001 From: Erik Fleckstein -Date: Mon, 13 Nov 2023 09:55:16 +0100 +Date: Thu, 10 Oct 2024 10:35:51 +0200 Subject: [PATCH] Disable unused components. --- - CMakeLists.txt | 4 ++-- - tools/update-components.sh | 18 +++++++++--------- - 2 files changed, 11 insertions(+), 11 deletions(-) + main/idf_component.yml | 118 ++++++++++++++++++++--------------------- + 1 file changed, 59 insertions(+), 59 deletions(-) -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 63540cc..1a68e70 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -2,8 +2,8 @@ - # CMakeLists in this exact order for cmake to work correctly - cmake_minimum_required(VERSION 3.5) +diff --git a/main/idf_component.yml b/main/idf_component.yml +index 4414085..7c17b48 100644 +--- a/main/idf_component.yml ++++ b/main/idf_component.yml +@@ -1,65 +1,65 @@ + dependencies: + # Required IDF version + idf: ">=5.3" +- espressif/esp32-camera: +- version: "master" +- git: https://github.com/espressif/esp32-camera.git +- require: public +- rules: +- - if: "target in [esp32, esp32s2, esp32s3]" +- - if: "$COMPONENTS_SUBSET in [full, all]" +- espressif/esp-tflite-micro: +- version: ">=1.2.0" +- require: public +- rules: +- - if: "target not in [esp32c2]" +- - if: "$COMPONENTS_SUBSET in [full, all]" +- # ESP-DL for ESP32, ESP32S2 and ESP32-S3 +- espressif/esp-dl-old: +- version: "af7808ba09448ce82c704455975d4cf1e4305fd7" +- git: https://github.com/espressif/esp-dl.git +- require: public +- rules: +- - if: "target in [esp32s3, esp32s2, esp32]" +- - if: "$COMPONENTS_SUBSET in [full, all]" +- # ESP-DL for ESP32-P4 +- espressif/esp-dl: +- version: "master" +- git: https://github.com/espressif/esp-dl.git +- path: esp-dl +- require: public +- rules: +- - if: "target in [esp32p4]" +- - if: "$COMPONENTS_SUBSET in [full, all]" +- # ESP-DL Face Detection for ESP32-P4 +- espressif/human_face_detect: +- version: "master" +- git: https://github.com/espressif/esp-dl.git +- path: models/human_face_detect +- require: public +- rules: +- - if: "target in [esp32p4]" +- - if: "$COMPONENTS_SUBSET in [full, all]" +- # ESP-DL Pedestrian Detection for ESP32-P4 +- espressif/pedestrian_detect: +- version: "master" +- git: https://github.com/espressif/esp-dl.git +- path: models/pedestrian_detect +- require: public +- rules: +- - if: "target in [esp32p4]" +- - if: "$COMPONENTS_SUBSET in [full, all]" +- espressif/esp-sr: +- version: ">=1.4.2" +- rules: +- - if: "target in [esp32s3]" +- - if: "$COMPONENTS_SUBSET in [full, all]" +- espressif/esp_matter: +- version: "^1.3.0" +- require: public +- rules: +- - if: "target not in [esp32c2, esp32h2, esp32p4]" +- - if: "$COMPONENTS_SUBSET in [full, all]" ++ # espressif/esp32-camera: ++ # version: "master" ++ # git: https://github.com/espressif/esp32-camera.git ++ # require: public ++ # rules: ++ # - if: "target in [esp32, esp32s2, esp32s3]" ++ # - if: "$COMPONENTS_SUBSET in [full, all]" ++ # espressif/esp-tflite-micro: ++ # version: ">=1.2.0" ++ # require: public ++ # rules: ++ # - if: "target not in [esp32c2]" ++ # - if: "$COMPONENTS_SUBSET in [full, all]" ++ # # ESP-DL for ESP32, ESP32S2 and ESP32-S3 ++ # espressif/esp-dl-old: ++ # version: "af7808ba09448ce82c704455975d4cf1e4305fd7" ++ # git: https://github.com/espressif/esp-dl.git ++ # require: public ++ # rules: ++ # - if: "target in [esp32s3, esp32s2, esp32]" ++ # - if: "$COMPONENTS_SUBSET in [full, all]" ++ # # ESP-DL for ESP32-P4 ++ # espressif/esp-dl: ++ # version: "master" ++ # git: https://github.com/espressif/esp-dl.git ++ # path: esp-dl ++ # require: public ++ # rules: ++ # - if: "target in [esp32p4]" ++ # - if: "$COMPONENTS_SUBSET in [full, all]" ++ # # ESP-DL Face Detection for ESP32-P4 ++ # espressif/human_face_detect: ++ # version: "master" ++ # git: https://github.com/espressif/esp-dl.git ++ # path: models/human_face_detect ++ # require: public ++ # rules: ++ # - if: "target in [esp32p4]" ++ # - if: "$COMPONENTS_SUBSET in [full, all]" ++ # # ESP-DL Pedestrian Detection for ESP32-P4 ++ # espressif/pedestrian_detect: ++ # version: "master" ++ # git: https://github.com/espressif/esp-dl.git ++ # path: models/pedestrian_detect ++ # require: public ++ # rules: ++ # - if: "target in [esp32p4]" ++ # - if: "$COMPONENTS_SUBSET in [full, all]" ++ # espressif/esp-sr: ++ # version: ">=1.4.2" ++ # rules: ++ # - if: "target in [esp32s3]" ++ # - if: "$COMPONENTS_SUBSET in [full, all]" ++ # espressif/esp_matter: ++ # version: "^1.3.0" ++ # require: public ++ # rules: ++ # - if: "target not in [esp32c2, esp32h2, esp32p4]" ++ # - if: "$COMPONENTS_SUBSET in [full, all]" --set(RMAKER_PATH ${CMAKE_SOURCE_DIR}/components/esp-rainmaker) --set(EXTRA_COMPONENT_DIRS ${RMAKER_PATH}/components/esp-insights/components ${RMAKER_PATH}/components) -+#set(RMAKER_PATH ${CMAKE_SOURCE_DIR}/components/esp-rainmaker) -+#set(EXTRA_COMPONENT_DIRS ${RMAKER_PATH}/components/esp-insights/components ${RMAKER_PATH}/components) - - include($ENV{IDF_PATH}/tools/cmake/project.cmake) - project(arduino-lib-builder) -diff --git a/tools/update-components.sh b/tools/update-components.sh -index bd0e394..bf0b25f 100755 ---- a/tools/update-components.sh -+++ b/tools/update-components.sh -@@ -57,7 +57,7 @@ if [ $? -ne 0 ]; then exit 1; fi - # - echo "Updating ESP32 Camera..." - if [ ! -d "$AR_COMPS/esp32-camera" ]; then -- git clone $CAMERA_REPO_URL "$AR_COMPS/esp32-camera" -+ true #git clone $CAMERA_REPO_URL "$AR_COMPS/esp32-camera" - else - git -C "$AR_COMPS/esp32-camera" fetch && \ - git -C "$AR_COMPS/esp32-camera" pull --ff-only -@@ -69,9 +69,9 @@ if [ $? -ne 0 ]; then exit 1; fi - # - echo "Updating ESP-DL..." - if [ ! -d "$AR_COMPS/esp-dl" ]; then -- git clone $DL_REPO_URL "$AR_COMPS/esp-dl" && \ -- git -C "$AR_COMPS/esp-dl" reset --hard 0632d2447dd49067faabe9761d88fa292589d5d9 -- if [ $? -ne 0 ]; then exit 1; fi -+ true #git clone $DL_REPO_URL "$AR_COMPS/esp-dl" && \ -+ true #git -C "$AR_COMPS/esp-dl" reset --hard 0632d2447dd49067faabe9761d88fa292589d5d9 -+ true #if [ $? -ne 0 ]; then exit 1; fi - fi - - # -@@ -93,9 +93,9 @@ if [ $? -ne 0 ]; then exit 1; fi - # - echo "Updating ESP-RainMaker..." - if [ ! -d "$AR_COMPS/esp-rainmaker" ]; then -- git clone $RMAKER_REPO_URL "$AR_COMPS/esp-rainmaker" && \ -- git -C "$AR_COMPS/esp-rainmaker" reset --hard d8e93454f495bd8a414829ec5e86842b373ff555 && \ -- git -C "$AR_COMPS/esp-rainmaker" submodule update --init --recursive -+ true #git clone $RMAKER_REPO_URL "$AR_COMPS/esp-rainmaker" && \ -+ true #git -C "$AR_COMPS/esp-rainmaker" reset --hard d8e93454f495bd8a414829ec5e86842b373ff555 && \ -+ true #git -C "$AR_COMPS/esp-rainmaker" submodule update --init --recursive - fi - if [ $? -ne 0 ]; then exit 1; fi - -@@ -104,7 +104,7 @@ if [ $? -ne 0 ]; then exit 1; fi - # - echo "Updating ESP-DSP..." - if [ ! -d "$AR_COMPS/espressif__esp-dsp" ]; then -- git clone $DSP_REPO_URL "$AR_COMPS/espressif__esp-dsp" -+ true #git clone $DSP_REPO_URL "$AR_COMPS/espressif__esp-dsp" - else - git -C "$AR_COMPS/espressif__esp-dsp" fetch && \ - git -C "$AR_COMPS/espressif__esp-dsp" pull --ff-only -@@ -116,7 +116,7 @@ if [ $? -ne 0 ]; then exit 1; fi - # - echo "Updating TinyUSB..." - if [ ! -d "$AR_COMPS/arduino_tinyusb/tinyusb" ]; then -- git clone $TINYUSB_REPO_URL "$AR_COMPS/arduino_tinyusb/tinyusb" -+ true #git clone $TINYUSB_REPO_URL "$AR_COMPS/arduino_tinyusb/tinyusb" - else - git -C "$AR_COMPS/arduino_tinyusb/tinyusb" fetch && \ - git -C "$AR_COMPS/arduino_tinyusb/tinyusb" pull --ff-only + # esp-sr: "^1.3.1" + # esp32-camera: "^2.0.4" -- -2.42.0 +2.47.0 diff --git a/software/patches/lib-builder-pre/0002-Don-t-build-unused-variants.patch b/software/patches/lib-builder-pre/0002-Don-t-build-unused-variants.patch deleted file mode 100644 index 30f497239..000000000 --- a/software/patches/lib-builder-pre/0002-Don-t-build-unused-variants.patch +++ /dev/null @@ -1,40 +0,0 @@ -From dfc88f4d633369d0bb722318ccb02b7d70e3569d Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Mattias=20Sch=C3=A4ffersmann?= -Date: Tue, 19 Sep 2023 15:07:53 +0200 -Subject: [PATCH] Don't build unused variants. - ---- - configs/builds.json | 12 +++--------- - 1 file changed, 3 insertions(+), 9 deletions(-) - -diff --git a/configs/builds.json b/configs/builds.json -index c32e465..65341ff 100644 ---- a/configs/builds.json -+++ b/configs/builds.json -@@ -102,19 +102,13 @@ - "idf_libs":["qio","80m"], - "bootloaders":[ - ["qio","80m"], -- ["qout","80m"], - ["dio","80m"], -- ["dout","80m"], - ["qio","40m"], -- ["qout","40m"], -- ["dio","40m"], -- ["dout","40m"] -+ ["dio","40m"] - ], - "mem_variants":[ -- ["qout","80m"], -- ["dio","80m"], -- ["dout","80m"] -+ ["dio","80m"] - ] - } - ] --} -\ No newline at end of file -+} --- -2.30.2 - diff --git a/software/patches/lib-builder/esp-idf/0006-system-Add-workaround-for-interrupted-backtraces-on-.patch b/software/patches/lib-builder-unknown/esp-idf/0006-system-Add-workaround-for-interrupted-backtraces-on-.patch similarity index 100% rename from software/patches/lib-builder/esp-idf/0006-system-Add-workaround-for-interrupted-backtraces-on-.patch rename to software/patches/lib-builder-unknown/esp-idf/0006-system-Add-workaround-for-interrupted-backtraces-on-.patch diff --git a/software/patches/lib-builder/esp-idf/0001-lwip-Increase-DNS_TABLE_SIZE-to-16.patch b/software/patches/lib-builder/esp-idf/0001-lwip-Increase-DNS_TABLE_SIZE-to-16.patch index 6b0054643..7724a36f7 100644 --- a/software/patches/lib-builder/esp-idf/0001-lwip-Increase-DNS_TABLE_SIZE-to-16.patch +++ b/software/patches/lib-builder/esp-idf/0001-lwip-Increase-DNS_TABLE_SIZE-to-16.patch @@ -4,15 +4,15 @@ Date: Mon, 12 Feb 2024 16:19:51 +0100 Subject: [PATCH] lwip: Increase DNS_TABLE_SIZE to 16. --- - components/lwip/port/esp32/include/lwipopts.h | 2 ++ + components/lwip/port/include/lwipopts.h | 2 ++ 1 file changed, 2 insertions(+) -diff --git a/components/lwip/port/esp32/include/lwipopts.h b/components/lwip/port/esp32/include/lwipopts.h +diff --git a/components/lwip/port/include/lwipopts.h b/components/lwip/port/include/lwipopts.h index ef838b65a7..26685ee289 100644 ---- a/components/lwip/port/esp32/include/lwipopts.h -+++ b/components/lwip/port/esp32/include/lwipopts.h +--- a/components/lwip/port/include/lwipopts.h ++++ b/components/lwip/port/include/lwipopts.h @@ -378,6 +378,8 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min) - #define DNS_MAX_SERVERS CONFIG_LWIP_DNS_MAX_SERVERS + */ #define DNS_FALLBACK_SERVER_INDEX (DNS_MAX_SERVERS - 1) +#define DNS_TABLE_SIZE 16 diff --git a/software/patches/lib-builder/esp-idf/0002-http_server-Increment-active-socket-count-for-SSL-se.patch b/software/patches/lib-builder/esp-idf/0002-http_server-Increment-active-socket-count-for-SSL-se.patch deleted file mode 100644 index e0efd1860..000000000 --- a/software/patches/lib-builder/esp-idf/0002-http_server-Increment-active-socket-count-for-SSL-se.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 463b02eeec52e3b06bbea19469539eaae63eacaa Mon Sep 17 00:00:00 2001 -From: Laukik Hase -Date: Tue, 6 Sep 2022 17:20:35 +0530 -Subject: [PATCH] http_server: Increment active socket count for SSL session - - The callback `open_fn` is used for creating a new SSL session with - httpd_sess_new. - If the call fails, the active socket count - (httpd_data->hd_sd_active_count) is not incremented. But, httpd_sess_delete - is called, which decrements the count, resulting in a negative value for - several failed session creations in a row. - -Closes https://github.com/espressif/esp-idf/issues/9683 ---- - components/esp_http_server/src/httpd_sess.c | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -diff --git a/components/esp_http_server/src/httpd_sess.c b/components/esp_http_server/src/httpd_sess.c -index dea8e67d1a..04aa8d937c 100644 ---- a/components/esp_http_server/src/httpd_sess.c -+++ b/components/esp_http_server/src/httpd_sess.c -@@ -204,6 +204,9 @@ esp_err_t httpd_sess_new(struct httpd_data *hd, int newfd) - session->send_fn = httpd_default_send; - session->recv_fn = httpd_default_recv; - -+ // increment number of sessions -+ hd->hd_sd_active_count++; -+ - // Call user-defined session opening function - if (hd->config.open_fn) { - esp_err_t ret = hd->config.open_fn(hd, session->fd); -@@ -214,10 +217,8 @@ esp_err_t httpd_sess_new(struct httpd_data *hd, int newfd) - } - } - -- // increment number of sessions -- hd->hd_sd_active_count++; -- ESP_LOGD(TAG, LOG_FMT("active sockets: %d"), hd->hd_sd_active_count); - -+ ESP_LOGD(TAG, LOG_FMT("active sockets: %d"), hd->hd_sd_active_count); - return ESP_OK; - } - --- -2.37.3 - diff --git a/software/patches/lib-builder/esp-idf/0003-feat-websocket-allow-users-to-attach-CA-bundle.patch b/software/patches/lib-builder/esp-idf/0003-feat-websocket-allow-users-to-attach-CA-bundle.patch deleted file mode 100644 index 3c11089e0..000000000 --- a/software/patches/lib-builder/esp-idf/0003-feat-websocket-allow-users-to-attach-CA-bundle.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 0dbef699045b89313c0efc1737842a12405313b6 Mon Sep 17 00:00:00 2001 -From: Tomoyuki Sakurai -Date: Thu, 2 Jun 2022 12:16:46 +0700 -Subject: [PATCH] feat(websocket): allow users to attach CA bundle - -with esp_transport_ssl_crt_bundle_attach(), it is not necessary to -include a specific certificate. other protocol clients, such as -esp_http_client, do the same. - -fixes #48 ---- - components/esp_websocket_client/esp_websocket_client.c | 9 +++++++++ - .../esp_websocket_client/include/esp_websocket_client.h | 1 + - 2 files changed, 10 insertions(+) - -diff --git a/components/esp_websocket_client/esp_websocket_client.c b/components/esp_websocket_client/esp_websocket_client.c -index 2f6405d47d..87d6707a28 100644 ---- a/components/esp_websocket_client/esp_websocket_client.c -+++ b/components/esp_websocket_client/esp_websocket_client.c -@@ -378,6 +378,15 @@ esp_websocket_client_handle_t esp_websocket_client_init(const esp_websocket_clie - esp_transport_ssl_set_client_key_data_der(ssl, config->client_key, config->client_key_len); - } - } -+ -+ if (config->crt_bundle_attach) { -+#ifdef CONFIG_MBEDTLS_CERTIFICATE_BUNDLE -+ esp_transport_ssl_crt_bundle_attach(ssl, config->crt_bundle_attach); -+#else //CONFIG_MBEDTLS_CERTIFICATE_BUNDLE -+ ESP_LOGE(TAG, "crt_bundle_attach configured but not enabled in menuconfig: Please enable MBEDTLS_CERTIFICATE_BUNDLE option"); -+#endif -+ } -+ - if (config->skip_cert_common_name_check) { - esp_transport_ssl_skip_common_name_check(ssl); - } -diff --git a/components/esp_websocket_client/include/esp_websocket_client.h b/components/esp_websocket_client/include/esp_websocket_client.h -index 0ed6353467..a13bec117b 100644 ---- a/components/esp_websocket_client/include/esp_websocket_client.h -+++ b/components/esp_websocket_client/include/esp_websocket_client.h -@@ -95,6 +95,7 @@ typedef struct { - int pingpong_timeout_sec; /*!< Period before connection is aborted due to no PONGs received */ - bool disable_pingpong_discon; /*!< Disable auto-disconnect due to no PONG received within pingpong_timeout_sec */ - bool use_global_ca_store; /*!< Use a global ca_store for all the connections in which this bool is set. */ -+ esp_err_t (*crt_bundle_attach)(void *conf); /*!< Function pointer to esp_crt_bundle_attach. Enables the use of certification bundle for server verification, MBEDTLS_CERTIFICATE_BUNDLE must be enabled in menuconfig. Include esp_crt_bundle.h, and use `esp_crt_bundle_attach` here to include bundled CA certificates. */ - bool skip_cert_common_name_check;/*!< Skip any validation of server certificate CN field */ - bool keep_alive_enable; /*!< Enable keep-alive timeout */ - int keep_alive_idle; /*!< Keep-alive idle time. Default is 5 (second) */ --- -2.34.1 - diff --git a/software/patches/lib-builder/esp-idf/0007-fix-esp_http_client-Fix-esp_http_client-async-mode.patch b/software/patches/lib-builder/esp-idf/0007-fix-esp_http_client-Fix-esp_http_client-async-mode.patch deleted file mode 100644 index 0211b6b5c..000000000 --- a/software/patches/lib-builder/esp-idf/0007-fix-esp_http_client-Fix-esp_http_client-async-mode.patch +++ /dev/null @@ -1,31 +0,0 @@ -From c0d3fdf7db53e722fb7fdf76e96e443e7d345889 Mon Sep 17 00:00:00 2001 -From: Harshit Malpani -Date: Fri, 6 Oct 2023 11:48:55 +0530 -Subject: [PATCH 2/2] fix(esp_http_client): Fix esp_http_client async mode - -Closes https://github.com/espressif/esp-idf/issues/12358 ---- - components/esp_http_client/esp_http_client.c | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -diff --git a/components/esp_http_client/esp_http_client.c b/components/esp_http_client/esp_http_client.c -index 48a5589edc..3fd2a48515 100644 ---- a/components/esp_http_client/esp_http_client.c -+++ b/components/esp_http_client/esp_http_client.c -@@ -1018,7 +1018,12 @@ static int esp_http_client_get_data(esp_http_client_handle_t client) - - int rlen = esp_transport_read(client->transport, res_buffer->data, client->buffer_size_rx, client->timeout_ms); - if (rlen >= 0) { -- http_parser_execute(client->parser, client->parser_settings, res_buffer->data, rlen); -+ // When tls error is ESP_TLS_ERR_SSL_WANT_READ (-0x6900), esp_trasnport_read returns ERR_TCP_TRANSPORT_CONNECTION_TIMEOUT (0x0). -+ // We should not execute http_parser_execute() on this condition as it sets the internal state machine in an -+ // invalid state. -+ if (!(client->is_async && rlen == 0)) { -+ http_parser_execute(client->parser, client->parser_settings, res_buffer->data, rlen); -+ } - } - return rlen; - } --- -2.34.1 - diff --git a/software/patches/lib-builder/esp-idf/components/lwip/lwip/0001-dns-Add-dns_removehost.patch b/software/patches/lib-builder/esp-idf/components/lwip/lwip/0001-dns-Add-dns_removehost.patch index 48ffafa21..7e17980f7 100644 --- a/software/patches/lib-builder/esp-idf/components/lwip/lwip/0001-dns-Add-dns_removehost.patch +++ b/software/patches/lib-builder/esp-idf/components/lwip/lwip/0001-dns-Add-dns_removehost.patch @@ -1,22 +1,21 @@ -From 1366fff78bcb821a57b5767a1b06c24ade01a569 Mon Sep 17 00:00:00 2001 +From 277003ad7b72d8001b9e3593313ed26945bf0e44 Mon Sep 17 00:00:00 2001 From: Erik Fleckstein -Date: Mon, 17 Apr 2023 12:50:32 +0200 +Date: Thu, 10 Oct 2024 15:43:05 +0200 Subject: [PATCH] dns: Add dns_removehost. --- - src/core/dns.c | 22 +++++++++++++++++++--- + src/core/dns.c | 16 ++++++++++++++++ src/include/lwip/dns.h | 2 ++ - 2 files changed, 21 insertions(+), 3 deletions(-) + 2 files changed, 18 insertions(+) diff --git a/src/core/dns.c b/src/core/dns.c -index bd02aa83..5a0ad78e 100644 +index 0b135ab7..7afeb489 100644 --- a/src/core/dns.c +++ b/src/core/dns.c -@@ -408,6 +408,22 @@ dns_clear_cache(void) - { +@@ -411,6 +411,22 @@ dns_clear_cache(void) memset(dns_table, 0, sizeof(struct dns_table_entry) * DNS_TABLE_SIZE); } -+ + +err_t +dns_removehost(const char *hostname, const ip_addr_t *addr) +{ @@ -26,28 +25,29 @@ index bd02aa83..5a0ad78e 100644 + + for (i = 0; i < DNS_TABLE_SIZE; ++i) { + if (((hostname == NULL) || (lwip_strnicmp(hostname, dns_table[i].name, sizeof(dns_table[i].name)) == 0)) -+ && ((addr == NULL) || ip_addr_cmp(addr, &dns_table[i].ipaddr))) { ++ && ((addr == NULL) || ip_addr_cmp(addr, dns_table[i].ipaddr))) { + memset(&dns_table[i], 0, sizeof(struct dns_table_entry)); + } + } + return ERR_OK; +} - #endif - ++ /** + * @ingroup dns + * Obtain one of the currently configured DNS server. diff --git a/src/include/lwip/dns.h b/src/include/lwip/dns.h -index 7c9933ea..0d96b6ef 100644 +index 964daafb..955fffb4 100644 --- a/src/include/lwip/dns.h +++ b/src/include/lwip/dns.h -@@ -116,6 +116,8 @@ void dns_clear_servers(bool keep_fallback); +@@ -113,6 +113,8 @@ err_t dns_gethostbyname_addrtype(const char *hostname, ip_addr_t *add + u8_t dns_addrtype); void dns_clear_cache(void); - #endif - + +err_t dns_removehost(const char *hostname, const ip_addr_t *addr); + #if DNS_LOCAL_HOSTLIST size_t dns_local_iterate(dns_found_callback iterator_fn, void *iterator_arg); err_t dns_local_lookup(const char *hostname, ip_addr_t *addr, u8_t dns_addrtype); --- -2.40.0 +-- +2.47.0 diff --git a/software/patches/lib-builder/esp-idf/components/lwip/lwip/0002-dns-Enforce-a-minimum-TTL-of-30s.patch b/software/patches/lib-builder/esp-idf/components/lwip/lwip/0002-dns-Enforce-a-minimum-TTL-of-30s.patch index 4737166a6..3cdd09abc 100644 --- a/software/patches/lib-builder/esp-idf/components/lwip/lwip/0002-dns-Enforce-a-minimum-TTL-of-30s.patch +++ b/software/patches/lib-builder/esp-idf/components/lwip/lwip/0002-dns-Enforce-a-minimum-TTL-of-30s.patch @@ -1,43 +1,46 @@ -From 99b0b3152f28146c510c7a955b7382c619162e92 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Mattias=20Sch=C3=A4ffersmann?= -Date: Thu, 4 Apr 2024 18:41:02 +0200 +From bd46e676148d743e5f61addd7db5d2a63be53d65 Mon Sep 17 00:00:00 2001 +From: Erik Fleckstein +Date: Thu, 10 Oct 2024 16:18:04 +0200 Subject: [PATCH] dns: Enforce a minimum TTL of 30s --- - src/core/dns.c | 19 ++++++++----------- - 1 file changed, 8 insertions(+), 11 deletions(-) + src/core/dns.c | 20 ++++++++------------ + 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/core/dns.c b/src/core/dns.c -index 81a4c20b..1b2a7ba8 100644 +index 7afeb489..2be6e374 100644 --- a/src/core/dns.c +++ b/src/core/dns.c -@@ -1246,18 +1246,15 @@ dns_correct_response(u8_t idx, u32_t ttl) - if (entry->ttl > DNS_MAX_TTL) { - entry->ttl = DNS_MAX_TTL; +@@ -1264,21 +1264,17 @@ dns_correct_response(u8_t idx) + LWIP_DEBUGF(DNS_DEBUG, ("\n")); } -+ + +- dns_call_found(idx, entry->ipaddr); +- +- initial_ipaddr_cnt = entry->ipaddr_cnt; +- for (i=0; ittl[i] == 0) { +- /* RFC 883, page 29: "Zero values are +- interpreted to mean that the RR can only be used for the +- transaction in progress, and should not be cached." +- -> flush this entry now */ +- /* entry reused during callback? */ +- ip_addr_set_zero(&entry->ipaddr[i]); +- entry->ipaddr_cnt--; + /* Enforce a minimum TTL of 30s to avoid excessive DNS queries in certain + workloads. This is not recommended in RFC 1035, but 30s should be + short enough for this to be safe. */ -+ if (entry->ttl < 30) { -+ entry->ttl = 30; -+ } -+ - dns_call_found(idx, &entry->ipaddr); -- -- if (entry->ttl == 0) { -- /* RFC 883, page 29: "Zero values are -- interpreted to mean that the RR can only be used for the -- transaction in progress, and should not be cached." -- -> flush this entry now */ -- /* entry reused during callback? */ -- if (entry->state == DNS_STATE_DONE) { -- entry->state = DNS_STATE_UNUSED; -- } -- } - } ++ for (i=0; iipaddr_cnt; i++) { ++ if (entry->ttl[i] < 30) { ++ entry->ttl[i] = 30; + } + } - /** ++ dns_call_found(idx, entry->ipaddr); ++ + if (entry->ipaddr_cnt == 0) { + if (entry->state == DNS_STATE_DONE) { + entry->state = DNS_STATE_UNUSED; -- -2.39.2 +2.47.0 diff --git a/software/patches/lib-builder/esp-idf/components/lwip/lwip/0003-fix-memory-leak-in-netif_loop_output-if-tcpip_try_ca.patch b/software/patches/lib-builder/esp-idf/components/lwip/lwip/0003-fix-memory-leak-in-netif_loop_output-if-tcpip_try_ca.patch deleted file mode 100644 index c50e80f4a..000000000 --- a/software/patches/lib-builder/esp-idf/components/lwip/lwip/0003-fix-memory-leak-in-netif_loop_output-if-tcpip_try_ca.patch +++ /dev/null @@ -1,85 +0,0 @@ -From a0f6c21dd4c7f69d6facb352774bc88896f9ce2b Mon Sep 17 00:00:00 2001 -From: Nick Ballhorn-Wagner -Date: Fri, 21 Feb 2020 17:17:08 +0100 -Subject: [PATCH] fix memory leak in netif_loop_output if tcpip_try_callback fails - ---- - src/core/netif.c | 24 +++++++++++++++++++----- - src/include/lwip/netif.h | 4 ++++ - 2 files changed, 23 insertions(+), 5 deletions(-) - -diff --git a/src/core/netif.c b/src/core/netif.c -index 45f8e34f..d9bbb410 100644 ---- a/src/core/netif.c -+++ b/src/core/netif.c -@@ -366,6 +366,9 @@ netif_add(struct netif *netif, - #if ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS - netif->loop_cnt_current = 0; - #endif /* ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS */ -+#if ENABLE_LOOPBACK && LWIP_NETIF_LOOPBACK_MULTITHREADING -+ netif->reschedule_poll = 0; -+#endif /* ENABLE_LOOPBACK && LWIP_NETIF_LOOPBACK_MULTITHREADING */ - - #if ESP_LWIP - #if IP_NAPT -@@ -1089,11 +1092,12 @@ netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callb - /** - * @ingroup netif - * Send an IP packet to be received on the same netif (loopif-like). -- * The pbuf is simply copied and handed back to netif->input. -- * In multithreaded mode, this is done directly since netif->input must put -- * the packet on a queue. -- * In callback mode, the packet is put on an internal queue and is fed to -+ * The pbuf is copied and added to an internal queue which is fed to - * netif->input by netif_poll(). -+ * In multithreaded mode, the call to netif_poll() is queued to be done on the -+ * TCP/IP thread. -+ * In callback mode, the user has the responsibility to call netif_poll() in -+ * the main loop of their application. - * - * @param netif the lwip network interface structure - * @param p the (IP) packet to 'send' -@@ -1170,6 +1174,12 @@ netif_loop_output(struct netif *netif, struct pbuf *p) - LWIP_ASSERT("if first != NULL, last must also be != NULL", netif->loop_last != NULL); - netif->loop_last->next = r; - netif->loop_last = last; -+#if LWIP_NETIF_LOOPBACK_MULTITHREADING -+ if (netif->reschedule_poll) { -+ schedule_poll = 1; -+ netif->reschedule_poll = 0; -+ } -+#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */ - } else { - netif->loop_first = r; - netif->loop_last = last; -@@ -1187,7 +1197,11 @@ netif_loop_output(struct netif *netif, struct pbuf *p) - #if LWIP_NETIF_LOOPBACK_MULTITHREADING - /* For multithreading environment, schedule a call to netif_poll */ - if (schedule_poll) { -- tcpip_try_callback((tcpip_callback_fn)netif_poll, netif); -+ if (tcpip_try_callback((tcpip_callback_fn)netif_poll, netif) != ERR_OK) { -+ SYS_ARCH_PROTECT(lev); -+ netif->reschedule_poll = 1; -+ SYS_ARCH_UNPROTECT(lev); -+ } - } - #endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */ - -diff --git a/src/include/lwip/netif.h b/src/include/lwip/netif.h -index dd1c0d31..aa0f4e7c 100644 ---- a/src/include/lwip/netif.h -+++ b/src/include/lwip/netif.h -@@ -405,6 +405,10 @@ struct netif { - #if LWIP_LOOPBACK_MAX_PBUFS - u16_t loop_cnt_current; - #endif /* LWIP_LOOPBACK_MAX_PBUFS */ -+#if LWIP_NETIF_LOOPBACK_MULTITHREADING -+ /* Used if the original scheduling failed. */ -+ u8_t reschedule_poll; -+#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */ - #endif /* ENABLE_LOOPBACK */ - #if ESP_PBUF - void (*l2_buffer_free_notify)(struct netif *lwip_netif, void *user_buf); /* Allows LWIP to notify driver when a L2-supplied pbuf can be freed */ --- -2.39.2 - diff --git a/software/patches/lib-builder/esp-idf/components/mbedtls/mbedtls/0001-ssl_tls-Add-work-around-for-broken-asymmetric-buffer.patch b/software/patches/lib-builder/esp-idf/components/mbedtls/mbedtls/0001-ssl_tls-Add-work-around-for-broken-asymmetric-buffer.patch index 79f41400d..f9dd78f2c 100644 --- a/software/patches/lib-builder/esp-idf/components/mbedtls/mbedtls/0001-ssl_tls-Add-work-around-for-broken-asymmetric-buffer.patch +++ b/software/patches/lib-builder/esp-idf/components/mbedtls/mbedtls/0001-ssl_tls-Add-work-around-for-broken-asymmetric-buffer.patch @@ -1,6 +1,6 @@ -From 5e9b62f68a51e8bc3ff6a18bd5accaaf015f0298 Mon Sep 17 00:00:00 2001 +From 755af6231fadae5b36dcce54c2ed3c2e36662c94 Mon Sep 17 00:00:00 2001 From: Erik Fleckstein -Date: Tue, 27 Aug 2024 10:10:45 +0200 +Date: Thu, 10 Oct 2024 16:22:32 +0200 Subject: [PATCH] ssl_tls: Add work-around for broken asymmetric buffers. --- @@ -8,13 +8,13 @@ Subject: [PATCH] ssl_tls: Add work-around for broken asymmetric buffers. 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c -index c667a2923..fd5948329 100644 +index c5e06491c..4fa0b5c44 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c -@@ -5015,6 +5015,17 @@ const char *mbedtls_ssl_get_version(const mbedtls_ssl_context *ssl) +@@ -3160,6 +3160,17 @@ size_t mbedtls_ssl_get_output_record_size_limit(const mbedtls_ssl_context *ssl) size_t mbedtls_ssl_get_input_max_frag_len(const mbedtls_ssl_context *ssl) { - size_t max_len = MBEDTLS_SSL_MAX_CONTENT_LEN; + size_t max_len = MBEDTLS_SSL_IN_CONTENT_LEN; + + /* + * The buffer management is broken somewhere resulting in an input buffer @@ -28,9 +28,9 @@ index c667a2923..fd5948329 100644 + size_t read_mfl; - /* Use the configured MFL for the client if we're past SERVER_HELLO_DONE */ -@@ -5024,8 +5035,8 @@ size_t mbedtls_ssl_get_input_max_frag_len(const mbedtls_ssl_context *ssl) - } + #if defined(MBEDTLS_SSL_PROTO_TLS1_2) +@@ -3171,8 +3182,8 @@ size_t mbedtls_ssl_get_input_max_frag_len(const mbedtls_ssl_context *ssl) + #endif /* Check if a smaller max length was negotiated */ - if (ssl->session_out != NULL) { @@ -41,5 +41,5 @@ index c667a2923..fd5948329 100644 max_len = read_mfl; } -- -2.46.0 +2.47.0 diff --git a/software/patches/lib-builder/esp-idf/components/mqtt/esp-mqtt/0001-Add-esp_mqtt_client_en-disable_receive.patch b/software/patches/lib-builder/esp-idf/components/mqtt/esp-mqtt/0001-Add-esp_mqtt_client_en-disable_receive.patch index a55eebd45..4adae7516 100644 --- a/software/patches/lib-builder/esp-idf/components/mqtt/esp-mqtt/0001-Add-esp_mqtt_client_en-disable_receive.patch +++ b/software/patches/lib-builder/esp-idf/components/mqtt/esp-mqtt/0001-Add-esp_mqtt_client_en-disable_receive.patch @@ -1,6 +1,6 @@ -From 3bc1ec8dd2b5e9ab79be71132c14635efbbfe962 Mon Sep 17 00:00:00 2001 +From 3298993f1eadc98cd1ed7d294a2fcba7e68c9ad3 Mon Sep 17 00:00:00 2001 From: Erik Fleckstein -Date: Mon, 7 Aug 2023 12:17:15 +0200 +Date: Thu, 10 Oct 2024 15:21:05 +0200 Subject: [PATCH] Add esp_mqtt_client_en/disable_receive. Calling _disable_receive stops receiving new MQTT messages to allow @@ -10,24 +10,16 @@ delay time per MQTT task loop. Call _enable_receive to continue receiving MQTT messages after one was processed. --- - include/mqtt_client.h | 6 +++++- - mqtt_client.c | 29 ++++++++++++++++++++++++++--- - 2 files changed, 31 insertions(+), 4 deletions(-) + include/mqtt_client.h | 4 ++++ + lib/include/mqtt_client_priv.h | 2 ++ + mqtt_client.c | 27 ++++++++++++++++++++++++--- + 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/include/mqtt_client.h b/include/mqtt_client.h -index 07feed3..f42552d 100644 +index 66558aa..41a41c8 100644 --- a/include/mqtt_client.h +++ b/include/mqtt_client.h -@@ -43,7 +43,7 @@ typedef enum { - - msg_id message id - - data pointer to the received data - - data_len length of the data for this event -- */ -+ */ - MQTT_EVENT_UNSUBSCRIBED, /*!< unsubscribed event */ - MQTT_EVENT_PUBLISHED, /*!< published event, additional context: msg_id */ - MQTT_EVENT_DATA, /*!< data event, additional context: -@@ -416,6 +416,10 @@ esp_err_t esp_mqtt_client_register_event(esp_mqtt_client_handle_t client, esp_mq +@@ -651,6 +651,10 @@ esp_err_t esp_mqtt_client_unregister_event(esp_mqtt_client_handle_t client, esp_ */ int esp_mqtt_client_get_outbox_size(esp_mqtt_client_handle_t client); @@ -35,21 +27,22 @@ index 07feed3..f42552d 100644 + +void esp_mqtt_client_enable_receive(esp_mqtt_client_handle_t client); + - #ifdef __cplusplus - } - #endif //__cplusplus -diff --git a/mqtt_client.c b/mqtt_client.c -index 98c27b2..0369aa3 100644 ---- a/mqtt_client.c -+++ b/mqtt_client.c -@@ -1,5 +1,6 @@ - #include + /** + * @brief Dispatch user event to the mqtt internal event loop + * +diff --git a/lib/include/mqtt_client_priv.h b/lib/include/mqtt_client_priv.h +index 0b152b0..e82fddd 100644 +--- a/lib/include/mqtt_client_priv.h ++++ b/lib/include/mqtt_client_priv.h +@@ -13,6 +13,7 @@ + #include + #include "esp_err.h" #include "platform.h" +#include #include "esp_event.h" #include "mqtt_client.h" -@@ -113,6 +114,7 @@ struct esp_mqtt_client { +@@ -127,6 +128,7 @@ struct esp_mqtt_client { esp_mqtt_event_t event; bool run; bool wait_for_ping_resp; @@ -57,15 +50,19 @@ index 98c27b2..0369aa3 100644 outbox_handle_t outbox; EventGroupHandle_t status_bits; SemaphoreHandle_t api_lock; -@@ -1436,6 +1438,7 @@ static void esp_mqtt_task(void *pv) +diff --git a/mqtt_client.c b/mqtt_client.c +index bcd1a74..e2c7890 100644 +--- a/mqtt_client.c ++++ b/mqtt_client.c +@@ -1573,6 +1573,7 @@ static void esp_mqtt_task(void *pv) uint64_t last_retransmit = 0; outbox_tick_t msg_tick = 0; client->run = true; + client->disable_receive = 0; - //get transport by scheme - client->transport = esp_transport_list_get_transport(client->transport_list, client->config->scheme); -@@ -1500,9 +1503,15 @@ static void esp_mqtt_task(void *pv) + client->state = MQTT_STATE_INIT; + xEventGroupClearBits(client->status_bits, STOPPED_BIT); +@@ -1650,9 +1651,15 @@ static void esp_mqtt_task(void *pv) break; } // receive and process data @@ -83,8 +80,8 @@ index 98c27b2..0369aa3 100644 + MQTT_API_LOCK(client); } - // delete long pending messages -@@ -1999,3 +2008,17 @@ int esp_mqtt_client_get_outbox_size(esp_mqtt_client_handle_t client) + if (last_retransmit == 0) { +@@ -2285,3 +2292,17 @@ int esp_mqtt_client_get_outbox_size(esp_mqtt_client_handle_t client) return outbox_size; } @@ -103,5 +100,5 @@ index 98c27b2..0369aa3 100644 + client->disable_receive = 0; +} -- -2.41.0 +2.47.0 diff --git a/software/patches/lib-builder/esp-idf/components/mqtt/esp-mqtt/0002-mqtt-Set-ws-path-if-not-set-via-passed-uri.patch b/software/patches/lib-builder/esp-idf/components/mqtt/esp-mqtt/0002-mqtt-Set-ws-path-if-not-set-via-passed-uri.patch index c11183a27..8a55634a6 100644 --- a/software/patches/lib-builder/esp-idf/components/mqtt/esp-mqtt/0002-mqtt-Set-ws-path-if-not-set-via-passed-uri.patch +++ b/software/patches/lib-builder/esp-idf/components/mqtt/esp-mqtt/0002-mqtt-Set-ws-path-if-not-set-via-passed-uri.patch @@ -1,20 +1,21 @@ -From 8705890ab99010fa4c921d3ae8d9638218bc998a Mon Sep 17 00:00:00 2001 +From f4b9d5e709812f5886082d9a4ad4d3593df9341c Mon Sep 17 00:00:00 2001 From: Erik Fleckstein -Date: Mon, 12 Feb 2024 16:28:00 +0100 +Date: Thu, 10 Oct 2024 15:24:34 +0200 Subject: [PATCH] mqtt: Set ws path if not set via passed uri. --- - mqtt_client.c | 13 +++++++++++++ - 1 file changed, 13 insertions(+) + mqtt_client.c | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mqtt_client.c b/mqtt_client.c -index 0369aa3..aca5f94 100644 +index e2c7890..5bdcb17 100644 --- a/mqtt_client.c +++ b/mqtt_client.c -@@ -561,6 +561,19 @@ esp_err_t esp_mqtt_set_config(esp_mqtt_client_handle_t client, const esp_mqtt_cl +@@ -613,7 +613,20 @@ esp_err_t esp_mqtt_set_config(esp_mqtt_client_handle_t client, const esp_mqtt_cl err = ESP_FAIL; goto _mqtt_set_config_failed; } +- } + } else if (client->config->path) { +#if MQTT_ENABLE_WS + esp_transport_handle_t ws_trans = esp_transport_list_get_transport(client->transport_list, "ws"); @@ -28,9 +29,10 @@ index 0369aa3..aca5f94 100644 + esp_transport_ws_set_path(wss_trans, client->config->path); + } +#endif - } ++ } + client->config->outbox_limit = config->outbox.limit; esp_err_t config_has_conflict = esp_mqtt_check_cfg_conflict(client->config, config); -- -2.43.1 +2.47.0 diff --git a/software/patches/lib-builder/esp-idf/0004-mdns-Place-static-buffer-to-assemble-packets-on-stac.patch b/software/patches/lib-builder/managed_components/espressif__mdns/0004-mdns-Place-static-buffer-to-assemble-packets-on-stac.raw_patch similarity index 83% rename from software/patches/lib-builder/esp-idf/0004-mdns-Place-static-buffer-to-assemble-packets-on-stac.patch rename to software/patches/lib-builder/managed_components/espressif__mdns/0004-mdns-Place-static-buffer-to-assemble-packets-on-stac.raw_patch index 89c076438..017342ddf 100644 --- a/software/patches/lib-builder/esp-idf/0004-mdns-Place-static-buffer-to-assemble-packets-on-stac.patch +++ b/software/patches/lib-builder/managed_components/espressif__mdns/0004-mdns-Place-static-buffer-to-assemble-packets-on-stac.raw_patch @@ -5,13 +5,13 @@ Subject: [PATCH] mdns: Place static buffer to assemble packets on stack instead --- - components/mdns/mdns.c | 2 +- + mdns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c +diff --git a/mdns.c b/mdns.c index b658b16ea1..97600c5ee1 100644 ---- a/components/mdns/mdns.c -+++ b/components/mdns/mdns.c +--- a/mdns.c ++++ b/mdns.c @@ -1138,7 +1138,7 @@ static uint8_t _mdns_append_answer(uint8_t * packet, uint16_t * index, mdns_out_ */ static void _mdns_dispatch_tx_packet(mdns_tx_packet_t * p)