diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e760225a04..29c01d2ec4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,6 @@ endif() set(CORE_SRCS cores/esp32/base64.cpp cores/esp32/cbuf.cpp - cores/esp32/chip-debug-report.cpp cores/esp32/esp32-hal-adc.c cores/esp32/esp32-hal-bt.c cores/esp32/esp32-hal-cpu.c @@ -78,38 +77,27 @@ set(CORE_SRCS set(ARDUINO_ALL_LIBRARIES ArduinoOTA AsyncUDP - BLE - BluetoothSerial DNSServer EEPROM - ESP_I2S - ESP_NOW - ESP_SR ESPmDNS Ethernet FFat FS HTTPClient HTTPUpdate - Insights LittleFS NetBIOS Network PPP Preferences - RainMaker SD_MMC SD - SimpleBLE - SPIFFS SPI Ticker Update USB WebServer - NetworkClientSecure WiFi - WiFiProv Wire ) @@ -118,26 +106,10 @@ set(ARDUINO_LIBRARY_ArduinoOTA_REQUIRES esp_https_ota) set(ARDUINO_LIBRARY_AsyncUDP_SRCS libraries/AsyncUDP/src/AsyncUDP.cpp) -set(ARDUINO_LIBRARY_BluetoothSerial_SRCS - libraries/BluetoothSerial/src/BluetoothSerial.cpp - libraries/BluetoothSerial/src/BTAddress.cpp - libraries/BluetoothSerial/src/BTAdvertisedDeviceSet.cpp - libraries/BluetoothSerial/src/BTScanResultsSet.cpp) - set(ARDUINO_LIBRARY_DNSServer_SRCS libraries/DNSServer/src/DNSServer.cpp) set(ARDUINO_LIBRARY_EEPROM_SRCS libraries/EEPROM/src/EEPROM.cpp) -set(ARDUINO_LIBRARY_ESP_I2S_SRCS libraries/ESP_I2S/src/ESP_I2S.cpp) - -set(ARDUINO_LIBRARY_ESP_NOW_SRCS - libraries/ESP_NOW/src/ESP32_NOW.cpp - libraries/ESP_NOW/src/ESP32_NOW_Serial.cpp) - -set(ARDUINO_LIBRARY_ESP_SR_SRCS - libraries/ESP_SR/src/ESP_SR.cpp - libraries/ESP_SR/src/esp32-hal-sr.c) - set(ARDUINO_LIBRARY_ESPmDNS_SRCS libraries/ESPmDNS/src/ESPmDNS.cpp) set(ARDUINO_LIBRARY_Ethernet_SRCS libraries/Ethernet/src/ETH.cpp) @@ -152,8 +124,6 @@ set(ARDUINO_LIBRARY_HTTPClient_SRCS libraries/HTTPClient/src/HTTPClient.cpp) set(ARDUINO_LIBRARY_HTTPUpdate_SRCS libraries/HTTPUpdate/src/HTTPUpdate.cpp) -set(ARDUINO_LIBRARY_Insights_SRCS libraries/Insights/src/Insights.cpp) - set(ARDUINO_LIBRARY_LittleFS_SRCS libraries/LittleFS/src/LittleFS.cpp) set(ARDUINO_LIBRARY_NetBIOS_SRCS libraries/NetBIOS/src/NetBIOS.cpp) @@ -164,16 +134,6 @@ set(ARDUINO_LIBRARY_PPP_SRCS set(ARDUINO_LIBRARY_Preferences_SRCS libraries/Preferences/src/Preferences.cpp) -set(ARDUINO_LIBRARY_RainMaker_SRCS - libraries/RainMaker/src/RMaker.cpp - libraries/RainMaker/src/RMakerNode.cpp - libraries/RainMaker/src/RMakerParam.cpp - libraries/RainMaker/src/RMakerDevice.cpp - libraries/RainMaker/src/RMakerType.cpp - libraries/RainMaker/src/RMakerQR.cpp - libraries/RainMaker/src/RMakerUtils.cpp - libraries/RainMaker/src/AppInsights.cpp) - set(ARDUINO_LIBRARY_SD_MMC_SRCS libraries/SD_MMC/src/SD_MMC.cpp) set(ARDUINO_LIBRARY_SD_SRCS @@ -181,10 +141,6 @@ set(ARDUINO_LIBRARY_SD_SRCS libraries/SD/src/sd_diskio.cpp libraries/SD/src/sd_diskio_crc.c) -set(ARDUINO_LIBRARY_SimpleBLE_SRCS libraries/SimpleBLE/src/SimpleBLE.cpp) - -set(ARDUINO_LIBRARY_SPIFFS_SRCS libraries/SPIFFS/src/SPIFFS.cpp) - set(ARDUINO_LIBRARY_SPI_SRCS libraries/SPI/src/SPI.cpp) set(ARDUINO_LIBRARY_Ticker_SRCS libraries/Ticker/src/Ticker.cpp) @@ -209,10 +165,6 @@ set(ARDUINO_LIBRARY_WebServer_SRCS libraries/WebServer/src/Parsing.cpp libraries/WebServer/src/detail/mimetable.cpp) -set(ARDUINO_LIBRARY_NetworkClientSecure_SRCS - libraries/NetworkClientSecure/src/ssl_client.cpp - libraries/NetworkClientSecure/src/NetworkClientSecure.cpp) - set(ARDUINO_LIBRARY_Network_SRCS libraries/Network/src/NetworkInterface.cpp libraries/Network/src/NetworkEvents.cpp @@ -231,42 +183,8 @@ set(ARDUINO_LIBRARY_WiFi_SRCS libraries/WiFi/src/STA.cpp libraries/WiFi/src/AP.cpp) -set(ARDUINO_LIBRARY_WiFiProv_SRCS libraries/WiFiProv/src/WiFiProv.cpp) - set(ARDUINO_LIBRARY_Wire_SRCS libraries/Wire/src/Wire.cpp) -set(ARDUINO_LIBRARY_BLE_SRCS - libraries/BLE/src/BLE2902.cpp - libraries/BLE/src/BLE2904.cpp - libraries/BLE/src/BLEAddress.cpp - libraries/BLE/src/BLEAdvertisedDevice.cpp - libraries/BLE/src/BLEAdvertising.cpp - libraries/BLE/src/BLEBeacon.cpp - libraries/BLE/src/BLECharacteristic.cpp - libraries/BLE/src/BLECharacteristicMap.cpp - libraries/BLE/src/BLEClient.cpp - libraries/BLE/src/BLEDescriptor.cpp - libraries/BLE/src/BLEDescriptorMap.cpp - libraries/BLE/src/BLEDevice.cpp - libraries/BLE/src/BLEEddystoneTLM.cpp - libraries/BLE/src/BLEEddystoneURL.cpp - libraries/BLE/src/BLEExceptions.cpp - libraries/BLE/src/BLEHIDDevice.cpp - libraries/BLE/src/BLERemoteCharacteristic.cpp - libraries/BLE/src/BLERemoteDescriptor.cpp - libraries/BLE/src/BLERemoteService.cpp - libraries/BLE/src/BLEScan.cpp - libraries/BLE/src/BLESecurity.cpp - libraries/BLE/src/BLEServer.cpp - libraries/BLE/src/BLEService.cpp - libraries/BLE/src/BLEServiceMap.cpp - libraries/BLE/src/BLEUtils.cpp - libraries/BLE/src/BLEUUID.cpp - libraries/BLE/src/BLEValue.cpp - libraries/BLE/src/FreeRTOS.cpp - libraries/BLE/src/GeneralUtils.cpp - ) - set(ARDUINO_LIBRARIES_SRCS) set(ARDUINO_LIBRARIES_REQUIRES) set(ARDUINO_LIBRARIES_INCLUDEDIRS) @@ -287,8 +205,8 @@ endforeach() set(includedirs variants/${CONFIG_ARDUINO_VARIANT}/ cores/esp32/ ${ARDUINO_LIBRARIES_INCLUDEDIRS}) set(srcs ${CORE_SRCS} ${ARDUINO_LIBRARIES_SRCS}) set(priv_includes cores/esp32/libb64) -set(requires spi_flash esp_partition mbedtls wifi_provisioning wpa_supplicant esp_adc esp_eth http_parser) -set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support bt esp_hid ${ARDUINO_LIBRARIES_REQUIRES}) +set(requires spi_flash esp_partition mbedtls wpa_supplicant esp_adc esp_eth http_parser) +set(priv_requires fatfs nvs_flash app_update bootloader_support bt esp_hid ${ARDUINO_LIBRARIES_REQUIRES}) idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires}) diff --git a/Kconfig.projbuild b/Kconfig.projbuild index 979afc02213..f1c5d3ba0d5 100644 --- a/Kconfig.projbuild +++ b/Kconfig.projbuild @@ -301,11 +301,6 @@ config ARDUINO_SELECTIVE_SD_MMC depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_FS default y -config ARDUINO_SELECTIVE_SPIFFS - bool "Enable SPIFFS" - depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_FS - default y - config ARDUINO_SELECTIVE_FFat bool "Enable FFat" depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_FS @@ -374,29 +369,4 @@ config ARDUINO_SELECTIVE_WiFi depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_Networking default y -config ARDUINO_SELECTIVE_WiFiClientSecure - bool "Enable WiFiClientSecure" - depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_Networking - default y - -config ARDUINO_SELECTIVE_WiFiProv - bool "Enable WiFiProv" - depends on ARDUINO_SELECTIVE_COMPILATION && ARDUINO_SELECTIVE_Networking && ARDUINO_SELECTIVE_WiFi - default y - -config ARDUINO_SELECTIVE_BLE - bool "Enable BLE" - depends on ARDUINO_SELECTIVE_COMPILATION - default y - -config ARDUINO_SELECTIVE_BluetoothSerial - bool "Enable BluetoothSerial" - depends on ARDUINO_SELECTIVE_COMPILATION - default y - -config ARDUINO_SELECTIVE_SimpleBLE - bool "Enable SimpleBLE" - depends on ARDUINO_SELECTIVE_COMPILATION - default y - endmenu diff --git a/README.md b/README.md index 940a9b7102b..bacb40b5ec4 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,6 @@ -# Arduino core for the ESP32, ESP32-S2, ESP32-S3, ESP32-C3, ESP32-C6 and ESP32-H2 +# Tasmota Platformio Arduino for ESP32, ESP32-S2, ESP32-S3, ESP32-C2, ESP32-C3, ESP32-C6 and ESP32-H2 -![Build Status](https://github.com/espressif/arduino-esp32/workflows/ESP32%20Arduino%20CI/badge.svg) [![External Libraries Test](https://github.com/espressif/arduino-esp32/actions/workflows/lib.yml/badge.svg?branch=master&event=schedule)](https://github.com/espressif/arduino-esp32/blob/gh-pages/LIBRARIES_TEST.md) [![Hardware Tests](https://github.com/espressif/arduino-esp32/actions/workflows/hil.yml/badge.svg?branch=master&event=schedule)](https://github.com/espressif/arduino-esp32/actions/workflows/hil.yml?query=event%3Aschedule) - -### Need help or have a question? Join the chat at [Gitter](https://gitter.im/espressif/arduino-esp32) or [open a new Discussion](https://github.com/espressif/arduino-esp32/discussions) - -## Contents - - - [Development Status](#development-status) - - [Development Planning](#development-planning) - - [Documentation](#documentation) - - [Supported Chips](#supported-chips) - - [Decoding exceptions](#decoding-exceptions) - - [Issue/Bug report template](#issuebug-report-template) - - [Contributing](#contributing) - -### Development Status - -Latest Stable Release [![Release Version](https://img.shields.io/github/release/espressif/arduino-esp32.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/latest/) [![Release Date](https://img.shields.io/github/release-date/espressif/arduino-esp32.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/latest/) [![Downloads](https://img.shields.io/github/downloads/espressif/arduino-esp32/latest/total.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/latest/) - -Latest Development Release [![Release Version](https://img.shields.io/github/release/espressif/arduino-esp32/all.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/) [![Release Date](https://img.shields.io/github/release-date-pre/espressif/arduino-esp32.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/) [![Downloads](https://img.shields.io/github/downloads-pre/espressif/arduino-esp32/latest/total.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/) - -### Development Planning - -Our Development is fully tracked on this public **[Roadmap 🎉](https://github.com/orgs/espressif/projects/3)** - -For even more information you can join our **[Monthly Community Meetings 🔔](https://github.com/espressif/arduino-esp32/discussions/categories/monthly-community-meetings).** +### [![GitHub Releases](https://img.shields.io/github/downloads/tasmota/arduino-esp32/total?label=downloads)](https://github.com/tasmota/arduino-esp32/releases/latest) ### Documentation @@ -36,51 +12,19 @@ You can use the [Arduino-ESP32 Online Documentation](https://docs.espressif.com/ --- -**APIs compatibility with ESP8266 and Arduino-CORE (Arduino.cc) is explained [here](https://docs.espressif.com/projects/arduino-esp32/en/latest/libraries.html#apis).** - ---- - -* [Getting Started](https://docs.espressif.com/projects/arduino-esp32/en/latest/getting_started.html) -* [Installing (Windows, Linux and macOS)](https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html) -* [Libraries](https://docs.espressif.com/projects/arduino-esp32/en/latest/libraries.html) -* [Arduino as an ESP-IDF component](https://docs.espressif.com/projects/arduino-esp32/en/latest/esp-idf_component.html) -* [FAQ](https://docs.espressif.com/projects/arduino-esp32/en/latest/faq.html) -* [Troubleshooting](https://docs.espressif.com/projects/arduino-esp32/en/latest/troubleshooting.html) - ### Supported Chips -Here are the ESP32 series supported by the Arduino-ESP32 project: +Here are the ESP32 series supported by the Tasmota Arduino-ESP32 project: | **SoC** | **Stable** | **Development** | **Datasheet** | |----------|:----------:|:---------------:|:-------------------------------------------------------------------------------------------------:| -| ESP32 | Yes | Yes | [ESP32](https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf) | +| ESP32 | Yes | Yes | [ESP32](https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf) | +| ESP32solo1| Yes | Yes | [ESP32solo1](https://www.espressif.com/sites/default/files/documentation/esp32-solo-1_datasheet_en.pdf) | | ESP32-S2 | Yes | Yes | [ESP32-S2](https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf) | -| ESP32-C3 | Yes | Yes | [ESP32-C3](https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf) | | ESP32-S3 | Yes | Yes | [ESP32-S3](https://www.espressif.com/sites/default/files/documentation/esp32-s3_datasheet_en.pdf) | +| ESP32-C3 | Yes | Yes | [ESP32-C3](https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf) | +| ESP32-C2 | No | Yes | [ESP32-C2](https://www.espressif.com/sites/default/files/documentation/esp8684_datasheet_en.pdf) | | ESP32-C6 | No | Yes | [ESP32-C6](https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf) | | ESP32-H2 | No | Yes | [ESP32-H2](https://www.espressif.com/sites/default/files/documentation/esp32-h2_datasheet_en.pdf) | For more details visit the [supported chips](https://docs.espressif.com/projects/arduino-esp32/en/latest/getting_started.html#supported-soc-s) documentation page. - -### Decoding exceptions - -You can use [EspExceptionDecoder](https://github.com/me-no-dev/EspExceptionDecoder) to get meaningful call trace. - -### Issue/Bug report template - -Before reporting an issue, make sure you've searched for similar one that was already created. Also make sure to go through all the issues labeled as [Type: For reference](https://github.com/espressif/arduino-esp32/issues?q=is%3Aissue+label%3A%22Type%3A+For+reference%22+). - -Finally, if you are sure no one else had the issue, follow the **Issue template** or **Feature request template** while reporting any [new Issue](https://github.com/espressif/arduino-esp32/issues/new/choose). - -### External libraries compilation test - -We have set-up CI testing for external libraries for ESP32 Arduino core. You can check test results in the file [LIBRARIES_TEST](https://github.com/espressif/arduino-esp32/blob/gh-pages/LIBRARIES_TEST.md). -For more information and how to add your library to the test see [external library testing](https://docs.espressif.com/projects/arduino-esp32/en/latest/external_libraries_test.html) in the documentation. - -### Contributing - -We welcome contributions to the Arduino ESP32 project! - -See [contributing](https://docs.espressif.com/projects/arduino-esp32/en/latest/contributing.html) in the documentation for more information on how to contribute to the project. - -> We would like to have this repository in a polite and friendly atmosphere, so please be kind and respectful to others. For more details, look at [Code of Conduct](https://github.com/espressif/arduino-esp32/blob/master/CODE_OF_CONDUCT.md). diff --git a/cores/esp32/HWCDC.cpp b/cores/esp32/HWCDC.cpp index 0b54b82d685..ded100f86b0 100644 --- a/cores/esp32/HWCDC.cpp +++ b/cores/esp32/HWCDC.cpp @@ -242,8 +242,8 @@ void HWCDC::begin(unsigned long baud) { } // the HW Serial pins needs to be first deinited in order to allow `if(Serial)` to work :-( - deinit(NULL); - delay(10); // USB Host has to enumerate it again + //deinit(NULL); + //delay(10); // USB Host has to enumerate it again // Peripheral Manager setting for USB D+ D- pins uint8_t pin = USB_DM_GPIO_NUM; @@ -265,6 +265,7 @@ void HWCDC::begin(unsigned long baud) { // Enable USB pad function USB_SERIAL_JTAG.conf0.usb_pad_enable = 1; usb_serial_jtag_ll_disable_intr_mask(USB_SERIAL_JTAG_LL_INTR_MASK); + usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_LL_INTR_MASK); usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY | USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT | USB_SERIAL_JTAG_INTR_BUS_RESET); if (!intr_handle && esp_intr_alloc(ETS_USB_SERIAL_JTAG_INTR_SOURCE, 0, hw_cdc_isr_handler, NULL, &intr_handle) != ESP_OK) { isr_log_e("HW USB CDC failed to init interrupts"); diff --git a/cores/esp32/main.cpp b/cores/esp32/main.cpp index 21f15083473..d4d3e116a8a 100644 --- a/cores/esp32/main.cpp +++ b/cores/esp32/main.cpp @@ -9,7 +9,9 @@ #endif #endif +#if defined __has_include && __has_include("chip-debug-report.h") #include "chip-debug-report.h" +#endif #ifndef ARDUINO_LOOP_STACK_SIZE #ifndef CONFIG_ARDUINO_LOOP_STACK_SIZE @@ -48,20 +50,24 @@ void loopTask(void *pvParameters) { // sets UART0 (default console) RX/TX pins as already configured in boot or as defined in variants/pins_arduino.h Serial0.setPins(gpioNumberToDigitalPin(SOC_RX0), gpioNumberToDigitalPin(SOC_TX0)); #endif +#if defined __has_include && __has_include("chip-debug-report.h") #if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG printBeforeSetupInfo(); #else if (shouldPrintChipDebugReport()) { printBeforeSetupInfo(); } +#endif #endif setup(); +#if defined __has_include && __has_include("chip-debug-report.h") #if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG printAfterSetupInfo(); #else if (shouldPrintChipDebugReport()) { printAfterSetupInfo(); } +#endif #endif for (;;) { #if CONFIG_FREERTOS_UNICORE diff --git a/idf_component.yml b/idf_component.yml index 2a76aec4d81..ae548c41d44 100644 --- a/idf_component.yml +++ b/idf_component.yml @@ -43,44 +43,7 @@ files: - "programmers.txt" dependencies: idf: ">=5.1" - # mdns 1.2.1 is necessary to build H2 with no WiFi + # mdns 1.2.3 is necessary to build H2 with no WiFi mdns: "^1.2.3" espressif/esp_modem: "^1.1.0" - chmorgan/esp-libhelix-mp3: - version: "1.0.3" - require: public - espressif/esp-zboss-lib: - version: "^1.0.1" - rules: - - if: "target != esp32c2" - espressif/esp-zigbee-lib: - version: "^1.0.1" - rules: - - if: "target != esp32c2" - esp-dsp: - version: "^1.3.4" - rules: - - if: "target != esp32c2" - espressif/esp_rainmaker: - version: "^1.0.0" - rules: - - if: "target != esp32c2" - espressif/rmaker_common: - version: "^1.4.3" - rules: - - if: "target != esp32c2" - espressif/esp_insights: - version: "^1.0.1" - rules: - - if: "target != esp32c2" - espressif/qrcode: - version: "^0.1.0~1" - rules: - - if: "target != esp32c2" - joltwallet/littlefs: "^1.10.2" - espressif/esp-sr: - version: "^1.4.2" - rules: - - if: "target in [esp32s3]" -examples: - - path: ./idf_component_examples/Hello_world + joltwallet/littlefs: "^1.14.1" diff --git a/libraries/Ethernet/src/ETH.cpp b/libraries/Ethernet/src/ETH.cpp index eeda93e3201..624bf74593e 100644 --- a/libraries/Ethernet/src/ETH.cpp +++ b/libraries/Ethernet/src/ETH.cpp @@ -234,6 +234,7 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i case ETH_PHY_TLK110: phy = esp_eth_phy_new_ip101(&phy_config); break; case ETH_PHY_RTL8201: phy = esp_eth_phy_new_rtl8201(&phy_config); break; case ETH_PHY_DP83848: phy = esp_eth_phy_new_dp83848(&phy_config); break; + case ETH_PHY_JL1101: phy = esp_eth_phy_new_jl1101(&phy_config); break; case ETH_PHY_KSZ8041: phy = esp_eth_phy_new_ksz80xx(&phy_config); break; case ETH_PHY_KSZ8081: phy = esp_eth_phy_new_ksz80xx(&phy_config); break; default: log_e("Unsupported PHY %d", type); break; diff --git a/libraries/Ethernet/src/ETH.h b/libraries/Ethernet/src/ETH.h index d2404391fbf..5570e430364 100644 --- a/libraries/Ethernet/src/ETH.h +++ b/libraries/Ethernet/src/ETH.h @@ -63,6 +63,9 @@ // This will be uncommented once custom SPI support is available in ESP-IDF #define ETH_SPI_SUPPORTS_CUSTOM 1 +// This will be removed when the support is backported to official IDF 5.1 +#define ETH_SPI_SUPPORTS_NO_IRQ 1 + #include "Network.h" #if ETH_SPI_SUPPORTS_CUSTOM @@ -100,6 +103,7 @@ typedef enum { ETH_PHY_LAN8720, ETH_PHY_TLK110, ETH_PHY_RTL8201, + ETH_PHY_JL1101, ETH_PHY_DP83848, ETH_PHY_KSZ8041, ETH_PHY_KSZ8081, diff --git a/libraries/HTTPClient/src/HTTPClient.cpp b/libraries/HTTPClient/src/HTTPClient.cpp index 54eedf0ac2e..080737b7334 100644 --- a/libraries/HTTPClient/src/HTTPClient.cpp +++ b/libraries/HTTPClient/src/HTTPClient.cpp @@ -31,7 +31,6 @@ #ifdef HTTPCLIENT_1_1_COMPATIBLE #include -#include #endif #include @@ -55,32 +54,6 @@ class TransportTraits { return true; } }; - -class TLSTraits : public TransportTraits { -public: - TLSTraits(const char *CAcert, const char *clicert = nullptr, const char *clikey = nullptr) : _cacert(CAcert), _clicert(clicert), _clikey(clikey) {} - - std::unique_ptr create() override { - return std::unique_ptr(new NetworkClientSecure()); - } - - bool verify(NetworkClient &client, const char *host) override { - NetworkClientSecure &wcs = static_cast(client); - if (_cacert == nullptr) { - wcs.setInsecure(); - } else { - wcs.setCACert(_cacert); - wcs.setCertificate(_clicert); - wcs.setPrivateKey(_clikey); - } - return true; - } - -protected: - const char *_cacert; - const char *_clicert; - const char *_clikey; -}; #endif // HTTPCLIENT_1_1_COMPATIBLE /** @@ -178,28 +151,6 @@ bool HTTPClient::begin(NetworkClient &client, String host, uint16_t port, String } #ifdef HTTPCLIENT_1_1_COMPATIBLE -bool HTTPClient::begin(String url, const char *CAcert) { - if (_client && !_tcpDeprecated) { - log_d("mix up of new and deprecated api"); - _canReuse = false; - end(); - } - - clear(); - _port = 443; - if (!beginInternal(url, "https")) { - return false; - } - _secure = true; - _transportTraits = TransportTraitsPtr(new TLSTraits(CAcert)); - if (!_transportTraits) { - log_e("could not create transport traits"); - return false; - } - - return true; -} - /** * parsing the url for all needed parameters * @param url String @@ -298,46 +249,6 @@ bool HTTPClient::begin(String host, uint16_t port, String uri) { log_d("host: %s port: %d uri: %s", host.c_str(), port, uri.c_str()); return true; } - -bool HTTPClient::begin(String host, uint16_t port, String uri, const char *CAcert) { - if (_client && !_tcpDeprecated) { - log_d("mix up of new and deprecated api"); - _canReuse = false; - end(); - } - - clear(); - _host = host; - _port = port; - _uri = uri; - - if (strlen(CAcert) == 0) { - return false; - } - _secure = true; - _transportTraits = TransportTraitsPtr(new TLSTraits(CAcert)); - return true; -} - -bool HTTPClient::begin(String host, uint16_t port, String uri, const char *CAcert, const char *cli_cert, const char *cli_key) { - if (_client && !_tcpDeprecated) { - log_d("mix up of new and deprecated api"); - _canReuse = false; - end(); - } - - clear(); - _host = host; - _port = port; - _uri = uri; - - if (strlen(CAcert) == 0) { - return false; - } - _secure = true; - _transportTraits = TransportTraitsPtr(new TLSTraits(CAcert, cli_cert, cli_key)); - return true; -} #endif // HTTPCLIENT_1_1_COMPATIBLE /** diff --git a/libraries/HTTPClient/src/HTTPClient.h b/libraries/HTTPClient/src/HTTPClient.h index 7841f355640..35b5bb4fc61 100644 --- a/libraries/HTTPClient/src/HTTPClient.h +++ b/libraries/HTTPClient/src/HTTPClient.h @@ -34,7 +34,6 @@ #include #include #include -#include /// Cookie jar support #include diff --git a/libraries/Network/src/NetworkEvents.h b/libraries/Network/src/NetworkEvents.h index 6c0e82f4d81..aa5080fe39c 100644 --- a/libraries/Network/src/NetworkEvents.h +++ b/libraries/Network/src/NetworkEvents.h @@ -20,8 +20,10 @@ #if SOC_WIFI_SUPPORTED #include "esp_wifi_types.h" #include "esp_smartconfig.h" +#if defined __has_include && __has_include("wifi_provisioning/wifi_config.h") #include "wifi_provisioning/wifi_config.h" #endif +#endif #if SOC_WIFI_SUPPORTED static const int WIFI_SCANNING_BIT = BIT0; @@ -105,7 +107,9 @@ typedef union { wifi_event_ap_stadisconnected_t wifi_ap_stadisconnected; wifi_event_ftm_report_t wifi_ftm_report; wifi_sta_config_t prov_cred_recv; +#if defined __has_include && __has_include("wifi_provisioning/wifi_config.h") wifi_prov_sta_fail_reason_t prov_fail_reason; +#endif smartconfig_event_got_ssid_pswd_t sc_got_ssid_pswd; #endif } arduino_event_info_t; diff --git a/libraries/Update/src/Update.h b/libraries/Update/src/Update.h index 7ae5e980751..ece90a2af1a 100644 --- a/libraries/Update/src/Update.h +++ b/libraries/Update/src/Update.h @@ -25,7 +25,6 @@ #define UPDATE_ERROR_NO_PARTITION (10) #define UPDATE_ERROR_BAD_ARGUMENT (11) #define UPDATE_ERROR_ABORT (12) -#define UPDATE_ERROR_DECRYPT (13) #define UPDATE_SIZE_UNKNOWN 0xFFFFFFFF @@ -33,15 +32,7 @@ #define U_SPIFFS 100 #define U_AUTH 200 -#define ENCRYPTED_BLOCK_SIZE 16 -#define ENCRYPTED_TWEAK_BLOCK_SIZE 32 -#define ENCRYPTED_KEY_SIZE 32 - -#define U_AES_DECRYPT_NONE 0 -#define U_AES_DECRYPT_AUTO 1 -#define U_AES_DECRYPT_ON 2 -#define U_AES_DECRYPT_MODE_MASK 3 -#define U_AES_IMAGE_DECRYPTING_BIT 4 +#define ENCRYPTED_BLOCK_SIZE 16 #define SPI_SECTORS_PER_BLOCK 16 // usually large erase block is 32k/64k #define SPI_FLASH_BLOCK_SIZE (SPI_SECTORS_PER_BLOCK * SPI_FLASH_SEC_SIZE) @@ -63,15 +54,6 @@ class UpdateClass { */ bool begin(size_t size = UPDATE_SIZE_UNKNOWN, int command = U_FLASH, int ledPin = -1, uint8_t ledOn = LOW, const char *label = NULL); - /* - Setup decryption configuration - Crypt Key is 32bytes(256bits) block of data, use the same key as used to encrypt image file - Crypt Address, use the same value as used to encrypt image file - Crypt Config, use the same value as used to encrypt image file - Crypt Mode, used to select if image files should be decrypted or not - */ - bool setupCrypt(const uint8_t *cryptKey = 0, size_t cryptAddress = 0, uint8_t cryptConfig = 0xf, int cryptMode = U_AES_DECRYPT_AUTO); - /* Writes a buffer to the flash and increments the address Returns the amount written @@ -95,34 +77,10 @@ class UpdateClass { or there is an error this will clear everything and return false the last error is available through getError() - evenIfRemaining is helpful when you update without knowing the final size first + evenIfRemaining is helpfull when you update without knowing the final size first */ bool end(bool evenIfRemaining = false); - /* - sets AES256 key(32 bytes) used for decrypting image file - */ - bool setCryptKey(const uint8_t *cryptKey); - - /* - sets crypt mode used on image files - */ - bool setCryptMode(const int cryptMode); - - /* - sets address used for decrypting image file - */ - void setCryptAddress(const size_t cryptAddress) { - _cryptAddress = cryptAddress & 0x00fffff0; - } - - /* - sets crypt config used for decrypting image file - */ - void setCryptConfig(const uint8_t cryptConfig) { - _cryptCfg = cryptConfig & 0x0f; - } - /* Aborts the running update */ @@ -235,8 +193,6 @@ class UpdateClass { private: void _reset(); void _abort(uint8_t err); - void _cryptKeyTweak(size_t cryptAddress, uint8_t *tweaked_key); - bool _decryptBuffer(); bool _writeBuffer(); bool _verifyHeader(uint8_t data); bool _verifyEnd(); @@ -244,8 +200,6 @@ class UpdateClass { bool _chkDataInBlock(const uint8_t *data, size_t len) const; // check if block contains any data or is empty uint8_t _error; - uint8_t *_cryptKey; - uint8_t *_cryptBuffer; uint8_t *_buffer; uint8_t *_skipBuffer; size_t _bufferLen; @@ -261,10 +215,6 @@ class UpdateClass { int _ledPin; uint8_t _ledOn; - - uint8_t _cryptMode; - size_t _cryptAddress; - uint8_t _cryptCfg; }; #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_UPDATE) diff --git a/libraries/Update/src/Updater.cpp b/libraries/Update/src/Updater.cpp index f5f6992db5a..e5717c5beea 100644 --- a/libraries/Update/src/Updater.cpp +++ b/libraries/Update/src/Updater.cpp @@ -9,7 +9,6 @@ #include "spi_flash_mmap.h" #include "esp_ota_ops.h" #include "esp_image_format.h" -#include "mbedtls/aes.h" static const char *_err2str(uint8_t _error) { if (_error == UPDATE_ERROR_OK) { @@ -38,8 +37,6 @@ static const char *_err2str(uint8_t _error) { return ("Bad Argument"); } else if (_error == UPDATE_ERROR_ABORT) { return ("Aborted"); - } else if (_error == UPDATE_ERROR_DECRYPT) { - return ("Decryption error"); } return ("UNKNOWN"); } @@ -67,8 +64,7 @@ bool UpdateClass::_enablePartition(const esp_partition_t *partition) { } UpdateClass::UpdateClass() - : _error(0), _cryptKey(0), _cryptBuffer(0), _buffer(0), _skipBuffer(0), _bufferLen(0), _size(0), _progress_callback(NULL), _progress(0), _paroffset(0), - _command(U_FLASH), _partition(NULL), _cryptMode(U_AES_DECRYPT_AUTO), _cryptAddress(0), _cryptCfg(0xf) {} + : _error(0), _buffer(0), _bufferLen(0), _size(0), _progress_callback(NULL), _progress(0), _paroffset(0), _command(U_FLASH), _partition(NULL) {} UpdateClass &UpdateClass::onProgress(THandlerFunction_Progress fn) { _progress_callback = fn; @@ -83,7 +79,6 @@ void UpdateClass::_reset() { delete[] _skipBuffer; } - _cryptBuffer = nullptr; _buffer = nullptr; _skipBuffer = nullptr; _bufferLen = 0; @@ -175,48 +170,6 @@ bool UpdateClass::begin(size_t size, int command, int ledPin, uint8_t ledOn, con return true; } -bool UpdateClass::setupCrypt(const uint8_t *cryptKey, size_t cryptAddress, uint8_t cryptConfig, int cryptMode) { - if (setCryptKey(cryptKey)) { - if (setCryptMode(cryptMode)) { - setCryptAddress(cryptAddress); - setCryptConfig(cryptConfig); - return true; - } - } - return false; -} - -bool UpdateClass::setCryptKey(const uint8_t *cryptKey) { - if (!cryptKey) { - if (_cryptKey) { - delete[] _cryptKey; - _cryptKey = 0; - log_d("AES key unset"); - } - return false; //key cleared, no key to decrypt with - } - //initialize - if (!_cryptKey) { - _cryptKey = new (std::nothrow) uint8_t[ENCRYPTED_KEY_SIZE]; - } - if (!_cryptKey) { - log_e("new failed"); - return false; - } - memcpy(_cryptKey, cryptKey, ENCRYPTED_KEY_SIZE); - return true; -} - -bool UpdateClass::setCryptMode(const int cryptMode) { - if (cryptMode >= U_AES_DECRYPT_NONE && cryptMode <= U_AES_DECRYPT_ON) { - _cryptMode = cryptMode; - } else { - log_e("bad crypt mode argument %i", cryptMode); - return false; - } - return true; -} - void UpdateClass::_abort(uint8_t err) { _reset(); _error = err; @@ -226,135 +179,7 @@ void UpdateClass::abort() { _abort(UPDATE_ERROR_ABORT); } -void UpdateClass::_cryptKeyTweak(size_t cryptAddress, uint8_t *tweaked_key) { - memcpy(tweaked_key, _cryptKey, ENCRYPTED_KEY_SIZE); - if (_cryptCfg == 0) { - return; //no tweaking needed, use crypt key as-is - } - - const uint8_t pattern[] = {23, 23, 23, 14, 23, 23, 23, 12, 23, 23, 23, 10, 23, 23, 23, 8}; - int pattern_idx = 0; - int key_idx = 0; - int bit_len = 0; - uint32_t tweak = 0; - cryptAddress &= 0x00ffffe0; //bit 23-5 - cryptAddress <<= 8; //bit23 shifted to bit31(MSB) - while (pattern_idx < sizeof(pattern)) { - tweak = cryptAddress << (23 - pattern[pattern_idx]); //bit shift for small patterns - // alternative to: tweak = rotl32(tweak,8 - bit_len); - tweak = (tweak << (8 - bit_len)) | (tweak >> (24 + bit_len)); //rotate to line up with end of previous tweak bits - bit_len += pattern[pattern_idx++] - 4; //add number of bits in next pattern(23-4 = 19bits = 23bit to 5bit) - while (bit_len > 7) { - tweaked_key[key_idx++] ^= tweak; //XOR byte - // alternative to: tweak = rotl32(tweak, 8); - tweak = (tweak << 8) | (tweak >> 24); //compiler should optimize to use rotate(fast) - bit_len -= 8; - } - tweaked_key[key_idx] ^= tweak; //XOR remaining bits, will XOR zeros if no remaining bits - } - if (_cryptCfg == 0xf) { - return; //return with fully tweaked key - } - - //some of tweaked key bits need to be restore back to crypt key bits - const uint8_t cfg_bits[] = {67, 65, 63, 61}; - key_idx = 0; - pattern_idx = 0; - while (key_idx < ENCRYPTED_KEY_SIZE) { - bit_len += cfg_bits[pattern_idx]; - if ((_cryptCfg & (1 << pattern_idx)) == 0) { //restore crypt key bits - while (bit_len > 0) { - if (bit_len > 7 || ((_cryptCfg & (2 << pattern_idx)) == 0)) { //restore a crypt key byte - tweaked_key[key_idx] = _cryptKey[key_idx]; - } else { //MSBits restore crypt key bits, LSBits keep as tweaked bits - tweaked_key[key_idx] &= (0xff >> bit_len); - tweaked_key[key_idx] |= (_cryptKey[key_idx] & (~(0xff >> bit_len))); - } - key_idx++; - bit_len -= 8; - } - } else { //keep tweaked key bits - while (bit_len > 0) { - if (bit_len < 8 && ((_cryptCfg & (2 << pattern_idx)) == 0)) { //MSBits keep as tweaked bits, LSBits restore crypt key bits - tweaked_key[key_idx] &= (~(0xff >> bit_len)); - tweaked_key[key_idx] |= (_cryptKey[key_idx] & (0xff >> bit_len)); - } - key_idx++; - bit_len -= 8; - } - } - pattern_idx++; - } -} - -bool UpdateClass::_decryptBuffer() { - if (!_cryptKey) { - log_w("AES key not set"); - return false; - } - if (_bufferLen % ENCRYPTED_BLOCK_SIZE != 0) { - log_e("buffer size error"); - return false; - } - if (!_cryptBuffer) { - _cryptBuffer = new (std::nothrow) uint8_t[ENCRYPTED_BLOCK_SIZE]; - } - if (!_cryptBuffer) { - log_e("new failed"); - return false; - } - uint8_t tweaked_key[ENCRYPTED_KEY_SIZE]; //tweaked crypt key - int done = 0; - - /* - Mbedtls functions will be replaced with esp_aes functions when hardware acceleration is available - - To Do: - Replace mbedtls for the cases where there's no hardware acceleration - */ - - mbedtls_aes_context ctx; //initialize AES - mbedtls_aes_init(&ctx); - while ((_bufferLen - done) >= ENCRYPTED_BLOCK_SIZE) { - for (int i = 0; i < ENCRYPTED_BLOCK_SIZE; i++) { - _cryptBuffer[(ENCRYPTED_BLOCK_SIZE - 1) - i] = _buffer[i + done]; //reverse order 16 bytes to decrypt - } - if (((_cryptAddress + _progress + done) % ENCRYPTED_TWEAK_BLOCK_SIZE) == 0 || done == 0) { - _cryptKeyTweak(_cryptAddress + _progress + done, tweaked_key); //update tweaked crypt key - if (mbedtls_aes_setkey_enc(&ctx, tweaked_key, 256)) { - return false; - } - if (mbedtls_aes_setkey_dec(&ctx, tweaked_key, 256)) { - return false; - } - } - if (mbedtls_aes_crypt_ecb(&ctx, MBEDTLS_AES_ENCRYPT, _cryptBuffer, _cryptBuffer)) { //use MBEDTLS_AES_ENCRYPT to decrypt flash code - return false; - } - for (int i = 0; i < ENCRYPTED_BLOCK_SIZE; i++) { - _buffer[i + done] = _cryptBuffer[(ENCRYPTED_BLOCK_SIZE - 1) - i]; //reverse order 16 bytes from decrypt - } - done += ENCRYPTED_BLOCK_SIZE; - } - return true; -} - bool UpdateClass::_writeBuffer() { - //first bytes of loading image, check to see if loading image needs decrypting - if (!_progress) { - _cryptMode &= U_AES_DECRYPT_MODE_MASK; - if ((_cryptMode == U_AES_DECRYPT_ON) || ((_command == U_FLASH) && (_cryptMode & U_AES_DECRYPT_AUTO) && (_buffer[0] != ESP_IMAGE_HEADER_MAGIC))) { - _cryptMode |= U_AES_IMAGE_DECRYPTING_BIT; //set to decrypt the loading image - log_d("Decrypting OTA Image"); - } - } - //check if data in buffer needs decrypting - if (_cryptMode & U_AES_IMAGE_DECRYPTING_BIT) { - if (!_decryptBuffer()) { - _abort(UPDATE_ERROR_DECRYPT); - return false; - } - } //first bytes of new firmware uint8_t skip = 0; if (!_progress && _command == U_FLASH) { diff --git a/libraries/WiFi/src/STA.cpp b/libraries/WiFi/src/STA.cpp index c3fbe9c52c9..fe01735c5d0 100644 --- a/libraries/WiFi/src/STA.cpp +++ b/libraries/WiFi/src/STA.cpp @@ -415,97 +415,6 @@ bool STAClass::connect(const char *ssid, const char *passphrase, int32_t channel return true; } -/** - * Start Wifi connection with a WPA2 Enterprise AP - * if passphrase is set the most secure supported mode will be automatically selected - * @param ssid const char* Pointer to the SSID string. - * @param method wpa2_method_t The authentication method of WPA2 (WPA2_AUTH_TLS, WPA2_AUTH_PEAP, WPA2_AUTH_TTLS) - * @param wpa2_identity const char* Pointer to the entity - * @param wpa2_username const char* Pointer to the username - * @param password const char * Pointer to the password. - * @param ca_pem const char* Pointer to a string with the contents of a .pem file with CA cert - * @param client_crt const char* Pointer to a string with the contents of a .crt file with client cert - * @param client_key const char* Pointer to a string with the contents of a .key file with client key - * @param bssid uint8_t[6] Optional. BSSID / MAC of AP - * @param channel Optional. Channel of AP - * @param connect Optional. call connect - * @return - */ -bool STAClass::connect( - 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 tryConnect -) { - if (_esp_netif == NULL) { - log_e("STA not started! You must call begin() first."); - return false; - } - - if (connected()) { - log_w("STA currently connected. Disconnecting..."); - if (!disconnect(true, 1000)) { - return false; - } - } - - if (!wpa2_ssid || *wpa2_ssid == 0x00 || strlen(wpa2_ssid) > 32) { - log_e("SSID too long or missing!"); - return false; - } - - if (wpa2_identity && strlen(wpa2_identity) > 64) { - log_e("identity too long!"); - return false; - } - - if (wpa2_username && strlen(wpa2_username) > 64) { - log_e("username too long!"); - return false; - } - - if (wpa2_password && strlen(wpa2_password) > 64) { - log_e("password too long!"); - return false; - } - - if (ca_pem) { -#if __has_include("esp_eap_client.h") - esp_eap_client_set_ca_cert((uint8_t *)ca_pem, strlen(ca_pem)); -#else - esp_wifi_sta_wpa2_ent_set_ca_cert((uint8_t *)ca_pem, strlen(ca_pem)); -#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); -#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); -#endif - } - -#if __has_include("esp_eap_client.h") - esp_eap_client_set_identity((uint8_t *)wpa2_identity, strlen(wpa2_identity)); -#else - esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)wpa2_identity, strlen(wpa2_identity)); -#endif - if (method == WPA2_AUTH_PEAP || method == WPA2_AUTH_TTLS) { -#if __has_include("esp_eap_client.h") - esp_eap_client_set_username((uint8_t *)wpa2_username, strlen(wpa2_username)); - esp_eap_client_set_password((uint8_t *)wpa2_password, strlen(wpa2_password)); -#else - esp_wifi_sta_wpa2_ent_set_username((uint8_t *)wpa2_username, strlen(wpa2_username)); - esp_wifi_sta_wpa2_ent_set_password((uint8_t *)wpa2_password, strlen(wpa2_password)); -#endif - } -#if __has_include("esp_eap_client.h") - esp_wifi_sta_enterprise_enable(); //set config settings to enable function -#else - esp_wifi_sta_wpa2_ent_enable(); //set config settings to enable function -#endif - - return connect(wpa2_ssid, NULL, 0, NULL, tryConnect); //connect to wifi -} - bool STAClass::disconnect(bool eraseap, unsigned long timeout) { if (eraseap) { if (!started()) { diff --git a/libraries/WiFi/src/WiFiGeneric.cpp b/libraries/WiFi/src/WiFiGeneric.cpp index 1903a5c9c41..983efbe5f36 100644 --- a/libraries/WiFi/src/WiFiGeneric.cpp +++ b/libraries/WiFi/src/WiFiGeneric.cpp @@ -126,7 +126,9 @@ static void _arduino_event_cb(void *arg, esp_event_base_t event_base, int32_t ev /* * Provisioning * */ - } else if (event_base == WIFI_PROV_EVENT && event_id == WIFI_PROV_INIT) { + } +#if defined __has_include && __has_include("wifi_provisioning/wifi_config.h") + else if (event_base == WIFI_PROV_EVENT && event_id == WIFI_PROV_INIT) { log_v("Provisioning Initialized!"); arduino_event.event_id = ARDUINO_EVENT_PROV_INIT; } else if (event_base == WIFI_PROV_EVENT && event_id == WIFI_PROV_DEINIT) { @@ -157,6 +159,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; } +#endif // __has_include ("wifi_provisioning/wifi_config.h") if (arduino_event.event_id < ARDUINO_EVENT_MAX) { Network.postEvent(&arduino_event); @@ -174,10 +177,12 @@ static bool initWiFiEvents() { return false; } +#if defined __has_include && __has_include("wifi_provisioning/wifi_config.h") if (esp_event_handler_instance_register(WIFI_PROV_EVENT, ESP_EVENT_ANY_ID, &_arduino_event_cb, NULL, NULL)) { log_e("event_handler_instance_register for WIFI_PROV_EVENT Failed!"); return false; } +#endif // __has_include ("wifi_provisioning/wifi_config.h") return true; } @@ -193,10 +198,12 @@ static bool deinitWiFiEvents() { return false; } +#if defined __has_include && __has_include("wifi_provisioning/wifi_config.h") if (esp_event_handler_unregister(WIFI_PROV_EVENT, ESP_EVENT_ANY_ID, &_arduino_event_cb)) { log_e("esp_event_handler_unregister for WIFI_PROV_EVENT Failed!"); return false; } +#endif // __has_include ("wifi_provisioning/wifi_config.h") return true; } diff --git a/libraries/WiFi/src/WiFiGeneric.h b/libraries/WiFi/src/WiFiGeneric.h index 6ed74dfed84..7900b4e9d47 100644 --- a/libraries/WiFi/src/WiFiGeneric.h +++ b/libraries/WiFi/src/WiFiGeneric.h @@ -33,7 +33,9 @@ #include "esp_smartconfig.h" #include "esp_netif_types.h" #include "esp_eth_driver.h" +#if defined __has_include && __has_include("wifi_provisioning/manager.h") #include "wifi_provisioning/manager.h" +#endif #include "lwip/ip_addr.h" #include "Network.h" diff --git a/tools/platformio-build.py b/tools/platformio-build.py index 06b5dac2e1b..8f90e29004f 100644 --- a/tools/platformio-build.py +++ b/tools/platformio-build.py @@ -35,7 +35,7 @@ partitions_name = board_config.get("build.partitions", board_config.get("build.arduino.partitions", "")) FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32") -FRAMEWORK_LIBS_DIR = platform.get_package_dir("framework-arduinoespressif32-libs") +FRAMEWORK_LIBS_DIR = join(FRAMEWORK_DIR, "tools", "esp32-arduino-libs") assert isdir(FRAMEWORK_DIR) @@ -175,9 +175,15 @@ def add_tinyuf2_extra_image(): libs = [] variants_dir = join(FRAMEWORK_DIR, "variants") +try: + build_variants_dir = join(board_config.get("build.variants_dir")) +except Exception: + build_variants_dir = "" if "build.variants_dir" in board_config: - variants_dir = join("$PROJECT_DIR", board_config.get("build.variants_dir")) + if len(build_variants_dir) > 1: + variants_dir = join("$PROJECT_DIR", board_config.get("build.variants_dir")) + if "build.variant" in board_config: env.Append(CPPPATH=[join(variants_dir, board_config.get("build.variant"))]) @@ -200,6 +206,15 @@ def add_tinyuf2_extra_image(): # Process framework extra images # +# Tasmota places extra images "safeboot" in custom variants folder in project directory +build_name = join(board_config.get("name")) +if len(build_variants_dir) > 1: + EXTRA_IMG_DIR = join(variants_dir) +else: + EXTRA_IMG_DIR = FRAMEWORK_DIR + if "tasmota" in build_name.lower(): + EXTRA_IMG_DIR = join(EXTRA_IMG_DIR, "variants", "tasmota") + env.Append( LIBSOURCE_DIRS=[join(FRAMEWORK_DIR, "libraries")], FLASH_EXTRA_IMAGES=[ @@ -210,7 +225,7 @@ def add_tinyuf2_extra_image(): ("0x8000", join(env.subst("$BUILD_DIR"), "partitions.bin")), ("0xe000", join(FRAMEWORK_DIR, "tools", "partitions", "boot_app0.bin")), ] - + [(offset, join(FRAMEWORK_DIR, img)) for offset, img in board_config.get("upload.arduino.flash_extra_images", [])], + + [(offset, join(EXTRA_IMG_DIR, img)) for offset, img in board_config.get("upload.arduino.flash_extra_images", [])], ) # Add an extra UF2 image if the 'TinyUF2' partition is selected