From 1a261e8f69cf50e1e5e52ef5a80c2b6e79aabf35 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 29 Aug 2023 13:17:47 +0200 Subject: [PATCH 001/211] Update push.yml --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 436e62527..82bc556fa 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,4 +1,4 @@ -name: Arduino IDF 5.1 without DSP and MP3 +name: Arduino IDF 5.1 solo1 on: workflow_dispatch: # Manually start a workflow From c4fe7f469d96b26393bb86ff334d0326ee5e1f02 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 29 Aug 2023 13:22:58 +0200 Subject: [PATCH 002/211] solo1 --- tools/archive-build.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index 118f0a454..c5b0d4459 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -4,15 +4,15 @@ IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD || echo "") IDF_BRANCH=$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD || echo "") idf_version_string=${IDF_BRANCH//\//_}"-$IDF_COMMIT" -archive_path="dist/arduino-esp32-libs-ITEAD-$idf_version_string.tar.gz" -build_archive_path="dist/arduino-esp32-build-ITEAD-$idf_version_string.tar.gz" -pio_archive_path="dist/framework-arduinoespressif32-ITEAD-$idf_version_string.tar.gz" -pio_zip_archive_path="dist/framework-arduinoespressif32-ITEAD-$idf_version_string.zip" +archive_path="dist/arduino-esp32-libs-solo1-$idf_version_string.tar.gz" +build_archive_path="dist/arduino-esp32-build-solo1-$idf_version_string.tar.gz" +pio_archive_path="dist/framework-arduinoespressif32-solo1-$idf_version_string.tar.gz" +pio_zip_archive_path="dist/framework-arduinoespressif32-solo1-$idf_version_string.zip" mkdir -p dist && rm -rf "$archive_path" "$build_archive_path" cd out -echo "Creating PlatformIO Tasmota framework-arduinoespressif32" +echo "Creating PlatformIO Tasmota framework-arduinoespressif32-solo1" cp -rf ../components/arduino arduino-esp32 rm -rf arduino-esp32/docs rm -rf arduino-esp32/tests @@ -38,9 +38,9 @@ rm -rf arduino-esp32/*.md cp -Rf tools/esp32-arduino-libs arduino-esp32/tools/ cp ../package.json arduino-esp32/package.json cp ../core_version.h arduino-esp32/cores/esp32/core_version.h -# Replace "framework-arduinoespressif32" with "framework-arduino-ITEAD" -awk -i inplace -v cuv1="framework-arduinoespressif32" -v cuv2="framework-arduino-ITEAD" '{gsub(cuv1,cuv2); print;}' "arduino-esp32/tools/esp32-arduino-libs/esp32/platformio-build.py" -awk -i inplace -v cuv1="framework-arduinoespressif32" -v cuv2="framework-arduino-ITEAD" '{gsub(cuv1,cuv2); print;}' "arduino-esp32/tools/platformio-build.py" +# Replace "framework-arduinoespressif32" with "framework-arduino-solo1" +awk -i inplace -v cuv1="framework-arduinoespressif32" -v cuv2="framework-arduino-solo1" '{gsub(cuv1,cuv2); print;}' "arduino-esp32/tools/esp32-arduino-libs/esp32/platformio-build.py" +awk -i inplace -v cuv1="framework-arduinoespressif32" -v cuv2="framework-arduino-solo1" '{gsub(cuv1,cuv2); print;}' "arduino-esp32/tools/platformio-build.py" mv arduino-esp32/ framework-arduinoespressif32/ # If the framework is needed as tar.gz uncomment next line # tar --exclude=.* -zcf ../$pio_archive_path framework-arduinoespressif32/ From de1f273587cbcf2a330d5aed794a33a46967daa5 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 29 Aug 2023 13:23:49 +0200 Subject: [PATCH 003/211] solo1 --- configs/pio_start.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/pio_start.txt b/configs/pio_start.txt index 2beb2e745..87972813a 100644 --- a/configs/pio_start.txt +++ b/configs/pio_start.txt @@ -30,7 +30,7 @@ from SCons.Script import DefaultEnvironment env = DefaultEnvironment() -FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduino-ITEAD") +FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduino-solo1") FRAMEWORK_SDK_DIR = join(FRAMEWORK_DIR, "tools", "esp32-arduino-libs") board_config = env.BoardConfig() From c61e29526ccfc319862b445d9662b98cd42cc114 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 29 Aug 2023 13:24:59 +0200 Subject: [PATCH 004/211] Update defconfig.esp32 --- configs/defconfig.esp32 | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/defconfig.esp32 b/configs/defconfig.esp32 index cccfea48e..3c33e31c7 100644 --- a/configs/defconfig.esp32 +++ b/configs/defconfig.esp32 @@ -1,3 +1,4 @@ +CONFIG_FREERTOS_UNICORE=y CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR=y # # Bluetooth From 7e290e5b5d8eb75887bd3b2ef9e0cd847b9f6746 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 29 Aug 2023 13:26:40 +0200 Subject: [PATCH 005/211] Update build.sh --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 51b086e7e..bd68d59a7 100755 --- a/build.sh +++ b/build.sh @@ -10,7 +10,7 @@ if ! [ -x "$(command -v git)" ]; then exit 1 fi -TARGET="all" +TARGET="esp32" BUILD_TYPE="all" SKIP_ENV=0 COPY_OUT=0 From 2916932e090558bfaf6e156bcf2fa2181e92f4f3 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 29 Aug 2023 18:38:53 +0200 Subject: [PATCH 006/211] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c184e5481..69477b14d 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "framework-arduinoespressif32", + "name": "framework-arduinoespressif32-solo1", "version": "3.0.0", "description": "Tasmota Arduino Framework for the Espressif ESP32, ESP32-S and ESP32-C series of SoCs", "keywords": [ From 8f3feaeef3813d50dffe35c1052c7562b3bf9fee Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 29 Aug 2023 18:40:19 +0200 Subject: [PATCH 007/211] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 69477b14d..6b5589241 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "framework-arduinoespressif32-solo1", "version": "3.0.0", - "description": "Tasmota Arduino Framework for the Espressif ESP32, ESP32-S and ESP32-C series of SoCs", + "description": "Tasmota Arduino Framework for the Espressif ESP32-solo1", "keywords": [ "tasmota", "framework", From 5db64d4951ae8d70ef02ceb69ea9f5c9c1c84c20 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 30 Aug 2023 14:20:20 +0200 Subject: [PATCH 008/211] CONFIG_ETH_SPI_ETHERNET_W5500=y --- configs/defconfig.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index 9104fe94e..ebe5f29d5 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -41,7 +41,7 @@ CONFIG_ESP_WIFI_CSI_ENABLED=n CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=y # CONFIG_ESP_WIFI_IRAM_OPT is not set # CONFIG_ESP_WIFI_RX_IRAM_OPT is not set -# CONFIG_ETH_SPI_ETHERNET_W5500 is not set +CONFIG_ETH_SPI_ETHERNET_W5500=y CONFIG_FATFS_CODEPAGE_850=y CONFIG_FATFS_LFN_STACK=y # CONFIG_FATFS_API_ENCODING_ANSI_OEM is not set From 29bea7f87289d110c76ea8db1c316d5f1ba8e4fb Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 30 Aug 2023 14:21:15 +0200 Subject: [PATCH 009/211] CONFIG_ETH_USE_SPI_ETHERNET=y --- configs/defconfig.esp32 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/defconfig.esp32 b/configs/defconfig.esp32 index 3c33e31c7..486de7ffc 100644 --- a/configs/defconfig.esp32 +++ b/configs/defconfig.esp32 @@ -16,7 +16,7 @@ CONFIG_BT_NIMBLE_MAX_CONNECTIONS=1 CONFIG_ETH_ENABLED=y CONFIG_ETH_USE_ESP32_EMAC=y CONFIG_ETH_PHY_INTERFACE_RMII=y -# CONFIG_ETH_USE_SPI_ETHERNET is not set +CONFIG_ETH_USE_SPI_ETHERNET=y # CONFIG_BTDM_CTRL_MODE_BTDM is not set CONFIG_BT_BTC_TASK_STACK_SIZE=8192 From b141d9ff47c0cab9b59ec0f9df439dd104149e6d Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 30 Aug 2023 14:22:40 +0200 Subject: [PATCH 010/211] AR_BRANCH="feature/eth_spi" --- tools/config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/config.sh b/tools/config.sh index 22397992f..15d54b770 100755 --- a/tools/config.sh +++ b/tools/config.sh @@ -30,7 +30,7 @@ AR_USER="tasmota" # Arduino branch to use if [ -z $AR_BRANCH ]; then - AR_BRANCH="esp-idf-v5.1-c2" + AR_BRANCH="feature/eth_spi" fi # IDF commit to use From d9e0db8a455d10e138d91a2a6b77dd2e13cbbbaa Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 4 Sep 2023 12:03:20 +0200 Subject: [PATCH 011/211] add source patches --- tools/install-esp-idf.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index 6c74775df..7096e49a8 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -34,6 +34,16 @@ if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then $IDF_PATH/install.sh export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD) export IDF_BRANCH=$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD) + + # Temporarily patch the ETH driver to support custom SPI + cd $IDF_PATH + patch -p1 -i ../patches/spi_eth.diff + cd - + + # Patch espressif nimble driver to support esp-nimble-cpp from h2zero + cd $IDF_PATH + patch -p1 -i ../patches/nimble.diff + cd - fi # From 89d5be7b4a0b7fc4ce5ea3d864c273f15db20c62 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 4 Sep 2023 12:04:55 +0200 Subject: [PATCH 012/211] Create nimble.diff --- patches/nimble.diff | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 patches/nimble.diff diff --git a/patches/nimble.diff b/patches/nimble.diff new file mode 100644 index 000000000..4b6e60c7d --- /dev/null +++ b/patches/nimble.diff @@ -0,0 +1,12 @@ +diff --git a/nimble/host/services/gap/include/services/gap/ble_svc_gap.h b/nimble/host/services/gap/include/services/gap/ble_svc_gap.h +index a1f84f1d6..f748d6494 100644 +--- a/nimble/host/services/gap/include/services/gap/ble_svc_gap.h ++++ b/nimble/host/services/gap/include/services/gap/ble_svc_gap.h +@@ -20,6 +20,7 @@ + #ifndef H_BLE_SVC_GAP_ + #define H_BLE_SVC_GAP_ + ++#include "syscfg/syscfg.h" + #include + #if MYNEWT_VAL(ENC_ADV_DATA) + #include "host/ble_ead.h" From 408bf48591f89490ebc0c720180e956d68d3227a Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 4 Sep 2023 12:05:21 +0200 Subject: [PATCH 013/211] Create spi_eth.diff --- patches/spi_eth.diff | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 patches/spi_eth.diff diff --git a/patches/spi_eth.diff b/patches/spi_eth.diff new file mode 100644 index 000000000..4b6e60c7d --- /dev/null +++ b/patches/spi_eth.diff @@ -0,0 +1,12 @@ +diff --git a/nimble/host/services/gap/include/services/gap/ble_svc_gap.h b/nimble/host/services/gap/include/services/gap/ble_svc_gap.h +index a1f84f1d6..f748d6494 100644 +--- a/nimble/host/services/gap/include/services/gap/ble_svc_gap.h ++++ b/nimble/host/services/gap/include/services/gap/ble_svc_gap.h +@@ -20,6 +20,7 @@ + #ifndef H_BLE_SVC_GAP_ + #define H_BLE_SVC_GAP_ + ++#include "syscfg/syscfg.h" + #include + #if MYNEWT_VAL(ENC_ADV_DATA) + #include "host/ble_ead.h" From ef4a999c6c46b2942c019108f6fd6a04b3b906f6 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 4 Sep 2023 12:09:47 +0200 Subject: [PATCH 014/211] Enable all SPI ETH --- configs/defconfig.common | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/defconfig.common b/configs/defconfig.common index ebe5f29d5..9fb552d55 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -41,7 +41,9 @@ CONFIG_ESP_WIFI_CSI_ENABLED=n CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=y # CONFIG_ESP_WIFI_IRAM_OPT is not set # CONFIG_ESP_WIFI_RX_IRAM_OPT is not set +CONFIG_ETH_SPI_ETHERNET_DM9051=y CONFIG_ETH_SPI_ETHERNET_W5500=y +CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL=y CONFIG_FATFS_CODEPAGE_850=y CONFIG_FATFS_LFN_STACK=y # CONFIG_FATFS_API_ENCODING_ANSI_OEM is not set From f19d22a8494c5e7054062a4e6c089a0238373fd8 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 4 Sep 2023 12:51:16 +0200 Subject: [PATCH 015/211] Update spi_eth.diff --- patches/spi_eth.diff | 1115 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 1103 insertions(+), 12 deletions(-) diff --git a/patches/spi_eth.diff b/patches/spi_eth.diff index 4b6e60c7d..6b5281fef 100644 --- a/patches/spi_eth.diff +++ b/patches/spi_eth.diff @@ -1,12 +1,1103 @@ -diff --git a/nimble/host/services/gap/include/services/gap/ble_svc_gap.h b/nimble/host/services/gap/include/services/gap/ble_svc_gap.h -index a1f84f1d6..f748d6494 100644 ---- a/nimble/host/services/gap/include/services/gap/ble_svc_gap.h -+++ b/nimble/host/services/gap/include/services/gap/ble_svc_gap.h -@@ -20,6 +20,7 @@ - #ifndef H_BLE_SVC_GAP_ - #define H_BLE_SVC_GAP_ - -+#include "syscfg/syscfg.h" - #include - #if MYNEWT_VAL(ENC_ADV_DATA) - #include "host/ble_ead.h" +diff --git a/components/esp_eth/include/esp_eth_mac.h b/components/esp_eth/include/esp_eth_mac.h +index dfc1af2c73b5e6a872a5c0583e0223ca86b49ae2..c2600a178df7fd756624e200148ec899ba522807 100644 +--- a/components/esp_eth/include/esp_eth_mac.h ++++ b/components/esp_eth/include/esp_eth_mac.h +@@ -1,5 +1,5 @@ + /* +- * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD ++ * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +@@ -470,15 +470,113 @@ typedef struct { + esp_eth_mac_t *esp_eth_mac_new_esp32(const eth_esp32_emac_config_t *esp32_config, const eth_mac_config_t *config); + #endif // CONFIG_ETH_USE_ESP32_EMAC + ++#if CONFIG_ETH_USE_SPI_ETHERNET ++/** ++ * @brief Custom SPI Driver Configuration. ++ * This structure declares configuration and callback functions to access Ethernet SPI module via ++ * user's custom SPI driver. ++ * ++ */ ++typedef struct ++{ ++ /** ++ * @brief Custom driver specific configuration structure used by `init()` function. ++ * ++ * @note Type and its content is fully under user's control ++ * ++ */ ++ void *config; ++ ++ /** ++ * @brief Custom driver SPI Initialization ++ * ++ * @param[in] spi_config: Custom driver specific configuration ++ * ++ * @return ++ * - spi_ctx: when initialization is successful, a pointer to context structure holding all variables ++ * needed for subsequent SPI access operations (e.g. SPI bus identification, mutexes, etc.) ++ * - NULL: driver initialization failed ++ * ++ * @note return type and its content is fully under user's control ++ */ ++ void *(*init)(const void *spi_config); ++ ++ /** ++ * @brief Custom driver De-initialization ++ * ++ * @param[in] spi_ctx: a pointer to driver specific context structure ++ * ++ * @return ++ * - ESP_OK: driver de-initialization was successful ++ * - ESP_FAIL: driver de-initialization failed ++ * - any other failure codes are allowed to be used to provide failure isolation ++ */ ++ esp_err_t (*deinit)(void *spi_ctx); ++ ++ /** ++ * @brief Custom driver SPI read ++ * ++ * @note The read function is responsible to construct command, address and data fields ++ * of the SPI frame in format expected by particular SPI Ethernet module ++ * ++ * @param[in] spi_ctx: a pointer to driver specific context structure ++ * @param[in] cmd: command ++ * @param[in] addr: register address ++ * @param[out] data: read data ++ * @param[in] data_len: read data length in bytes ++ * ++ * @return ++ * - ESP_OK: read was successful ++ * - ESP_FAIL: read failed ++ * - any other failure codes are allowed to be used to provide failure isolation ++ */ ++ esp_err_t (*read)(void *spi_ctx, uint32_t cmd, uint32_t addr, void *data, uint32_t data_len); ++ ++ /** ++ * @brief Custom driver SPI write ++ * ++ * @note The write function is responsible to construct command, address and data fields ++ * of the SPI frame in format expected by particular SPI Ethernet module ++ * ++ * @param[in] spi_ctx: a pointer to driver specific context structure ++ * @param[in] cmd: command ++ * @param[in] addr: register address ++ * @param[in] data: data to write ++ * @param[in] data_len: length of data to write in bytes ++ * ++ * @return ++ * - ESP_OK: write was successful ++ * - ESP_FAIL: write failed ++ * - any other failure codes are allowed to be used to provide failure isolation ++ */ ++ esp_err_t (*write)(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *data, uint32_t data_len); ++} eth_spi_custom_driver_t; ++ ++/** ++ * @brief Default configuration of the custom SPI driver. ++ * Internal ESP-IDF SPI Master driver is used by default. ++ * ++ */ ++#define ETH_NO_CUSTOM_SPI \ ++ { \ ++ .config = NULL, \ ++ .init = NULL, \ ++ .deinit = NULL, \ ++ .read = NULL, \ ++ .write = NULL \ ++ } ++#endif // CONFIG_ETH_USE_SPI_ETHERNET ++ + #if CONFIG_ETH_SPI_ETHERNET_DM9051 + /** + * @brief DM9051 specific configuration + * + */ + typedef struct { +- spi_host_device_t spi_host_id; /*!< SPI peripheral */ +- spi_device_interface_config_t *spi_devcfg; /*!< SPI device configuration */ + int int_gpio_num; /*!< Interrupt GPIO number */ ++ spi_host_device_t spi_host_id; /*!< SPI peripheral (this field is invalid when custom SPI driver is defined) */ ++ spi_device_interface_config_t *spi_devcfg; /*!< SPI device configuration (this field is invalid when custom SPI driver is defined) */ ++ eth_spi_custom_driver_t custom_spi_driver; /*!< Custom SPI driver definitions */ + } eth_dm9051_config_t; + + /** +@@ -487,9 +585,10 @@ typedef struct { + */ + #define ETH_DM9051_DEFAULT_CONFIG(spi_host, spi_devcfg_p) \ + { \ ++ .int_gpio_num = 4, \ + .spi_host_id = spi_host, \ + .spi_devcfg = spi_devcfg_p, \ +- .int_gpio_num = 4, \ ++ .custom_spi_driver = ETH_NO_CUSTOM_SPI, \ + } + + /** +@@ -511,9 +610,10 @@ esp_eth_mac_t *esp_eth_mac_new_dm9051(const eth_dm9051_config_t *dm9051_config, + * + */ + typedef struct { +- spi_host_device_t spi_host_id; /*!< SPI peripheral */ +- spi_device_interface_config_t *spi_devcfg; /*!< SPI device configuration */ + int int_gpio_num; /*!< Interrupt GPIO number */ ++ spi_host_device_t spi_host_id; /*!< SPI peripheral (this field is invalid when custom SPI driver is defined)*/ ++ spi_device_interface_config_t *spi_devcfg; /*!< SPI device configuration (this field is invalid when custom SPI driver is defined)*/ ++ eth_spi_custom_driver_t custom_spi_driver; /*!< Custom SPI driver definitions */ + } eth_w5500_config_t; + + /** +@@ -521,10 +621,11 @@ typedef struct { + * + */ + #define ETH_W5500_DEFAULT_CONFIG(spi_host, spi_devcfg_p) \ +- { \ +- .spi_host_id = spi_host, \ +- .spi_devcfg = spi_devcfg_p, \ +- .int_gpio_num = 4, \ ++ { \ ++ .int_gpio_num = 4, \ ++ .spi_host_id = spi_host, \ ++ .spi_devcfg = spi_devcfg_p, \ ++ .custom_spi_driver = ETH_NO_CUSTOM_SPI, \ + } + + /** +@@ -546,9 +647,10 @@ esp_eth_mac_t *esp_eth_mac_new_w5500(const eth_w5500_config_t *w5500_config, con + * + */ + typedef struct { +- spi_host_device_t spi_host_id; /*!< SPI peripheral */ +- spi_device_interface_config_t *spi_devcfg; /*!< SPI device configuration */ + int int_gpio_num; /*!< Interrupt GPIO number */ ++ spi_host_device_t spi_host_id; /*!< SPI peripheral (this field is invalid when custom SPI driver is defined) */ ++ spi_device_interface_config_t *spi_devcfg; /*!< SPI device configuration (this field is invalid when custom SPI driver is defined) */ ++ eth_spi_custom_driver_t custom_spi_driver; /*!< Custom SPI driver definitions */ + } eth_ksz8851snl_config_t; + + /** +@@ -557,9 +659,10 @@ typedef struct { + */ + #define ETH_KSZ8851SNL_DEFAULT_CONFIG(spi_host, spi_devcfg_p) \ + { \ ++ .int_gpio_num = 4, \ + .spi_host_id = spi_host, \ + .spi_devcfg = spi_devcfg_p, \ +- .int_gpio_num = 14, \ ++ .custom_spi_driver = ETH_NO_CUSTOM_SPI, \ + } + + /** +diff --git a/components/esp_eth/src/esp_eth_mac_dm9051.c b/components/esp_eth/src/esp_eth_mac_dm9051.c +index b0d339cc93d1d6ef39b1e819102c220d431114b2..22b9efa2b2eb353b4493ac9f0437bcd829a49d7d 100644 +--- a/components/esp_eth/src/esp_eth_mac_dm9051.c ++++ b/components/esp_eth/src/esp_eth_mac_dm9051.c +@@ -1,5 +1,5 @@ + /* +- * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD ++ * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +@@ -47,11 +47,23 @@ typedef struct { + uint8_t length_high; + } dm9051_rx_header_t; + ++typedef struct { ++ spi_device_handle_t hdl; ++ SemaphoreHandle_t lock; ++} spi_info_t; ++ ++typedef struct { ++ void *ctx; ++ void *(*init)(const void *spi_config); ++ esp_err_t (*deinit)(void *spi_ctx); ++ esp_err_t (*read)(void *spi_ctx, uint32_t cmd, uint32_t addr, void *data, uint32_t data_len); ++ esp_err_t (*write)(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *data, uint32_t data_len); ++} spi_interface_t; ++ + typedef struct { + esp_eth_mac_t parent; + esp_eth_mediator_t *eth; +- spi_device_handle_t spi_hdl; +- SemaphoreHandle_t spi_lock; ++ spi_interface_t spi; + TaskHandle_t rx_task_hdl; + uint32_t sw_reset_timeout_ms; + int int_gpio_num; +@@ -61,89 +73,133 @@ typedef struct { + uint8_t *rx_buffer; + } emac_dm9051_t; + +-static inline bool dm9051_lock(emac_dm9051_t *emac) ++static void *spi_init_std(const void *spi_config) ++{ ++ void *ret = NULL; ++ eth_dm9051_config_t *dm9051_config = (eth_dm9051_config_t *)spi_config; ++ spi_info_t *spi = calloc(1, sizeof(spi_info_t)); ++ ESP_GOTO_ON_FALSE(spi, NULL, err, TAG, "no memory for SPI context data"); ++ ++ /* SPI device init */ ++ spi_device_interface_config_t spi_devcfg; ++ memcpy(&spi_devcfg, dm9051_config->spi_devcfg, sizeof(spi_device_interface_config_t)); ++ if (dm9051_config->spi_devcfg->command_bits == 0 && dm9051_config->spi_devcfg->address_bits == 0) { ++ /* configure default SPI frame format */ ++ spi_devcfg.command_bits = 1; ++ spi_devcfg.address_bits = 7; ++ } else { ++ ESP_GOTO_ON_FALSE(dm9051_config->spi_devcfg->command_bits == 1 || dm9051_config->spi_devcfg->address_bits == 7, ++ NULL, err, TAG, "incorrect SPI frame format (command_bits/address_bits)"); ++ } ++ ESP_GOTO_ON_FALSE(spi_bus_add_device(dm9051_config->spi_host_id, &spi_devcfg, &spi->hdl) == ESP_OK, ++ NULL, err, TAG, "adding device to SPI host #%d failed", dm9051_config->spi_host_id + 1); ++ ++ /* create mutex */ ++ spi->lock = xSemaphoreCreateMutex(); ++ ESP_GOTO_ON_FALSE(spi->lock, NULL, err, TAG, "create lock failed"); ++ ++ return spi; ++err: ++ if (spi->lock) { ++ vSemaphoreDelete(spi->lock); ++ } ++ return ret; ++} ++ ++static esp_err_t spi_deinit_std(void *spi_ctx) ++{ ++ esp_err_t ret = ESP_OK; ++ spi_info_t *spi = (spi_info_t *)spi_ctx; ++ ++ spi_bus_remove_device(spi->hdl); ++ vSemaphoreDelete(spi->lock); ++ ++ free(spi); ++ return ret; ++} ++ ++static inline bool dm9051_lock(spi_info_t *spi) + { +- return xSemaphoreTake(emac->spi_lock, pdMS_TO_TICKS(DM9051_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; ++ return xSemaphoreTake(spi->lock, pdMS_TO_TICKS(DM9051_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; + } + +-static inline bool dm9051_unlock(emac_dm9051_t *emac) ++static inline bool dm9051_unlock(spi_info_t *spi) + { +- return xSemaphoreGive(emac->spi_lock) == pdTRUE; ++ return xSemaphoreGive(spi->lock) == pdTRUE; + } + +-/** +- * @brief write value to dm9051 internal register +- */ +-static esp_err_t dm9051_register_write(emac_dm9051_t *emac, uint8_t reg_addr, uint8_t value) ++static esp_err_t spi_write_std(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *value, uint32_t len) + { + esp_err_t ret = ESP_OK; ++ spi_info_t *spi = (spi_info_t *)spi_ctx; ++ + spi_transaction_t trans = { +- .cmd = DM9051_SPI_WR, +- .addr = reg_addr, +- .length = 8, +- .flags = SPI_TRANS_USE_TXDATA ++ .cmd = cmd, ++ .addr = addr, ++ .length = 8 * len, ++ .tx_buffer = value + }; +- trans.tx_data[0] = value; +- if (dm9051_lock(emac)) { +- if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) { ++ if (dm9051_lock(spi)) { ++ if (spi_device_polling_transmit(spi->hdl, &trans) != ESP_OK) { + ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); + ret = ESP_FAIL; + } +- dm9051_unlock(emac); ++ dm9051_unlock(spi); + } else { + ret = ESP_ERR_TIMEOUT; + } + return ret; + } + +-/** +- * @brief read value from dm9051 internal register +- */ +-static esp_err_t dm9051_register_read(emac_dm9051_t *emac, uint8_t reg_addr, uint8_t *value) ++static esp_err_t spi_read_std(void *spi_ctx, uint32_t cmd, uint32_t addr, void *value, uint32_t len) + { + esp_err_t ret = ESP_OK; ++ spi_info_t *spi = (spi_info_t *)spi_ctx; ++ + spi_transaction_t trans = { +- .cmd = DM9051_SPI_RD, +- .addr = reg_addr, +- .length = 8, +- .flags = SPI_TRANS_USE_TXDATA | SPI_TRANS_USE_RXDATA ++ .flags = len <= 4 ? SPI_TRANS_USE_RXDATA : 0, // use direct reads for registers to prevent overwrites by 4-byte boundary writes ++ .cmd = cmd, ++ .addr = addr, ++ .length = 8 * len, ++ .rx_buffer = value + }; +- if (dm9051_lock(emac)) { +- if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) { ++ if (dm9051_lock(spi)) { ++ if (spi_device_polling_transmit(spi->hdl, &trans) != ESP_OK) { + ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); + ret = ESP_FAIL; +- } else { +- *value = trans.rx_data[0]; + } +- dm9051_unlock(emac); ++ dm9051_unlock(spi); + } else { + ret = ESP_ERR_TIMEOUT; + } ++ if ((trans.flags&SPI_TRANS_USE_RXDATA) && len <= 4) { ++ memcpy(value, trans.rx_data, len); // copy register values to output ++ } + return ret; + } + ++/** ++ * @brief write value to dm9051 internal register ++ */ ++static esp_err_t dm9051_register_write(emac_dm9051_t *emac, uint8_t reg_addr, uint8_t value) ++{ ++ return emac->spi.write(emac->spi.ctx, DM9051_SPI_WR, reg_addr, &value, 1); ++} ++ ++/** ++ * @brief read value from dm9051 internal register ++ */ ++static esp_err_t dm9051_register_read(emac_dm9051_t *emac, uint8_t reg_addr, uint8_t *value) ++{ ++ return emac->spi.read(emac->spi.ctx, DM9051_SPI_RD, reg_addr, value, 1); ++} ++ + /** + * @brief write buffer to dm9051 internal memory + */ + static esp_err_t dm9051_memory_write(emac_dm9051_t *emac, uint8_t *buffer, uint32_t len) + { +- esp_err_t ret = ESP_OK; +- spi_transaction_t trans = { +- .cmd = DM9051_SPI_WR, +- .addr = DM9051_MWCMD, +- .length = len * 8, +- .tx_buffer = buffer +- }; +- if (dm9051_lock(emac)) { +- if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) { +- ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); +- ret = ESP_FAIL; +- } +- dm9051_unlock(emac); +- } else { +- ret = ESP_ERR_TIMEOUT; +- } +- return ret; ++ return emac->spi.write(emac->spi.ctx, DM9051_SPI_WR, DM9051_MWCMD, buffer, len); + } + + /** +@@ -151,23 +207,7 @@ static esp_err_t dm9051_memory_write(emac_dm9051_t *emac, uint8_t *buffer, uint3 + */ + static esp_err_t dm9051_memory_read(emac_dm9051_t *emac, uint8_t *buffer, uint32_t len) + { +- esp_err_t ret = ESP_OK; +- spi_transaction_t trans = { +- .cmd = DM9051_SPI_RD, +- .addr = DM9051_MRCMD, +- .length = len * 8, +- .rx_buffer = buffer +- }; +- if (dm9051_lock(emac)) { +- if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) { +- ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); +- ret = ESP_FAIL; +- } +- dm9051_unlock(emac); +- } else { +- ret = ESP_ERR_TIMEOUT; +- } +- return ret; ++ return emac->spi.read(emac->spi.ctx, DM9051_SPI_RD, DM9051_MRCMD, buffer, len); + } + + /** +@@ -175,23 +215,7 @@ static esp_err_t dm9051_memory_read(emac_dm9051_t *emac, uint8_t *buffer, uint32 + */ + static esp_err_t dm9051_memory_peek(emac_dm9051_t *emac, uint8_t *buffer, uint32_t len) + { +- esp_err_t ret = ESP_OK; +- spi_transaction_t trans = { +- .cmd = DM9051_SPI_RD, +- .addr = DM9051_MRCMDX1, +- .length = len * 8, +- .rx_buffer = buffer +- }; +- if (dm9051_lock(emac)) { +- if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) { +- ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); +- ret = ESP_FAIL; +- } +- dm9051_unlock(emac); +- } else { +- ret = ESP_ERR_TIMEOUT; +- } +- return ret; ++ return emac->spi.read(emac->spi.ctx, DM9051_SPI_RD, DM9051_MRCMDX1, buffer, len); + } + + /** +@@ -840,8 +864,7 @@ static esp_err_t emac_dm9051_del(esp_eth_mac_t *mac) + { + emac_dm9051_t *emac = __containerof(mac, emac_dm9051_t, parent); + vTaskDelete(emac->rx_task_hdl); +- spi_bus_remove_device(emac->spi_hdl); +- vSemaphoreDelete(emac->spi_lock); ++ emac->spi.deinit(emac->spi.ctx); + heap_caps_free(emac->rx_buffer); + free(emac); + return ESP_OK; +@@ -857,19 +880,6 @@ esp_eth_mac_t *esp_eth_mac_new_dm9051(const eth_dm9051_config_t *dm9051_config, + ESP_GOTO_ON_FALSE(emac, NULL, err, TAG, "calloc emac failed"); + /* dm9051 receive is driven by interrupt only for now*/ + ESP_GOTO_ON_FALSE(dm9051_config->int_gpio_num >= 0, NULL, err, TAG, "error interrupt gpio number"); +- /* SPI device init */ +- spi_device_interface_config_t spi_devcfg; +- memcpy(&spi_devcfg, dm9051_config->spi_devcfg, sizeof(spi_device_interface_config_t)); +- if (dm9051_config->spi_devcfg->command_bits == 0 && dm9051_config->spi_devcfg->address_bits == 0) { +- /* configure default SPI frame format */ +- spi_devcfg.command_bits = 1; +- spi_devcfg.address_bits = 7; +- } else { +- ESP_GOTO_ON_FALSE(dm9051_config->spi_devcfg->command_bits == 1 || dm9051_config->spi_devcfg->address_bits == 7, +- NULL, err, TAG, "incorrect SPI frame format (command_bits/address_bits)"); +- } +- ESP_GOTO_ON_FALSE(spi_bus_add_device(dm9051_config->spi_host_id, &spi_devcfg, &emac->spi_hdl) == ESP_OK, +- NULL, err, TAG, "adding device to SPI host #%d failed", dm9051_config->spi_host_id + 1); + /* bind methods and attributes */ + emac->sw_reset_timeout_ms = mac_config->sw_reset_timeout_ms; + emac->int_gpio_num = dm9051_config->int_gpio_num; +@@ -891,9 +901,26 @@ esp_eth_mac_t *esp_eth_mac_new_dm9051(const eth_dm9051_config_t *dm9051_config, + emac->parent.enable_flow_ctrl = emac_dm9051_enable_flow_ctrl; + emac->parent.transmit = emac_dm9051_transmit; + emac->parent.receive = emac_dm9051_receive; +- /* create mutex */ +- emac->spi_lock = xSemaphoreCreateMutex(); +- ESP_GOTO_ON_FALSE(emac->spi_lock, NULL, err, TAG, "create lock failed"); ++ ++ if (dm9051_config->custom_spi_driver.init != NULL && dm9051_config->custom_spi_driver.deinit != NULL ++ && dm9051_config->custom_spi_driver.read != NULL && dm9051_config->custom_spi_driver.write != NULL) { ++ ESP_LOGD(TAG, "custom SPI Driver is used"); ++ emac->spi.init = dm9051_config->custom_spi_driver.init; ++ emac->spi.deinit = dm9051_config->custom_spi_driver.deinit; ++ emac->spi.read = dm9051_config->custom_spi_driver.read; ++ emac->spi.write = dm9051_config->custom_spi_driver.write; ++ /* Custom SPI driver device init */ ++ ESP_GOTO_ON_FALSE((emac->spi.ctx = emac->spi.init(dm9051_config->custom_spi_driver.config)) != NULL, NULL, err, TAG, "SPI initialization failed"); ++ } else { ++ ESP_LOGD(TAG, "internal SPI Master Driver is used"); ++ emac->spi.init = spi_init_std; ++ emac->spi.deinit = spi_deinit_std; ++ emac->spi.read = spi_read_std; ++ emac->spi.write = spi_write_std; ++ /* SPI device init */ ++ ESP_GOTO_ON_FALSE((emac->spi.ctx = emac->spi.init(dm9051_config)) != NULL, NULL, err, TAG, "SPI initialization failed"); ++ } ++ + /* create dm9051 task */ + BaseType_t core_num = tskNO_AFFINITY; + if (mac_config->flags & ETH_MAC_FLAG_PIN_TO_CORE) { +@@ -913,9 +940,6 @@ err: + if (emac->rx_task_hdl) { + vTaskDelete(emac->rx_task_hdl); + } +- if (emac->spi_lock) { +- vSemaphoreDelete(emac->spi_lock); +- } + heap_caps_free(emac->rx_buffer); + free(emac); + } +diff --git a/components/esp_eth/src/esp_eth_mac_ksz8851snl.c b/components/esp_eth/src/esp_eth_mac_ksz8851snl.c +index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f22f0f5520 100644 +--- a/components/esp_eth/src/esp_eth_mac_ksz8851snl.c ++++ b/components/esp_eth/src/esp_eth_mac_ksz8851snl.c +@@ -3,7 +3,7 @@ + * + * SPDX-License-Identifier: MIT + * +- * SPDX-FileContributor: 2021-2022 Espressif Systems (Shanghai) CO LTD ++ * SPDX-FileContributor: 2021-2023 Espressif Systems (Shanghai) CO LTD + */ + + #include +@@ -22,10 +22,22 @@ + + #define KSZ8851_ETH_MAC_RX_BUF_SIZE_AUTO (0) + ++typedef struct { ++ spi_device_handle_t hdl; ++} spi_info_t; ++ ++typedef struct { ++ void *ctx; ++ void *(*init)(const void *spi_config); ++ esp_err_t (*deinit)(void *spi_ctx); ++ esp_err_t (*read)(void *spi_ctx, uint32_t cmd,uint32_t addr, void *data, uint32_t data_len); ++ esp_err_t (*write)(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *data, uint32_t data_len); ++} spi_interface_t; ++ + typedef struct { + esp_eth_mac_t parent; + esp_eth_mediator_t *eth; +- spi_device_handle_t spi_hdl; ++ spi_interface_t spi; + SemaphoreHandle_t spi_lock; + TaskHandle_t rx_task_hdl; + uint32_t sw_reset_timeout_ms; +@@ -73,6 +85,32 @@ IRAM_ATTR static void ksz8851_isr_handler(void *arg) + } + } + ++static void *spi_init_std(const void *spi_config) ++{ ++ void *ret = NULL; ++ eth_ksz8851snl_config_t *ksz8851snl_config = (eth_ksz8851snl_config_t *)spi_config; ++ spi_info_t *spi = calloc(1, sizeof(spi_info_t)); // TODO maybe replace with static variable spi_host_id ++ ESP_GOTO_ON_FALSE(spi, NULL, err, TAG, "no memory for SPI context data"); ++ ++ /* SPI device init */ ++ ESP_GOTO_ON_FALSE(spi_bus_add_device(ksz8851snl_config->spi_host_id, ksz8851snl_config->spi_devcfg, &spi->hdl) == ESP_OK, NULL, ++ err, TAG, "adding device to SPI host #%d failed", ksz8851snl_config->spi_host_id + 1); ++ return spi; ++err: ++ return ret; ++} ++ ++static esp_err_t spi_deinit_std(void *spi_ctx) ++{ ++ esp_err_t ret = ESP_OK; ++ spi_info_t *spi = (spi_info_t *)spi_ctx; ++ ++ spi_bus_remove_device(spi->hdl); ++ ++ free(spi); ++ return ret; ++} ++ + static inline bool ksz8851_mutex_lock(emac_ksz8851snl_t *emac) + { + return xSemaphoreTakeRecursive(emac->spi_lock, pdMS_TO_TICKS(KSZ8851_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; +@@ -83,70 +121,102 @@ static inline bool ksz8851_mutex_unlock(emac_ksz8851snl_t *emac) + return xSemaphoreGiveRecursive(emac->spi_lock) == pdTRUE; + } + +-static esp_err_t ksz8851_read_reg(emac_ksz8851snl_t *emac, uint32_t address, uint16_t *value) ++static esp_err_t spi_read_std(void *spi_ctx, uint32_t cmd, uint32_t addr, void *value, uint32_t len) + { + esp_err_t ret = ESP_OK; +- ESP_GOTO_ON_FALSE(value != NULL, ESP_ERR_INVALID_ARG, err, TAG, "out pointer must not be null"); +- ESP_GOTO_ON_FALSE((address & ~KSZ8851_VALID_ADDRESS_MASK) == 0U, ESP_ERR_INVALID_ARG, err, TAG, "address is out of bounds"); ++ spi_info_t *spi = (spi_info_t *)spi_ctx; + +- const unsigned data_size = 16U; // NOTE(v.chistyakov): bits +- // NOTE(v.chistyakov): select upper or lower word inside a dword +- const unsigned byte_mask = 0x3U << (KSZ8851_SPI_BYTE_MASK_SHIFT + (address & 0x2U)); +- address <<= KSZ8851_SPI_ADDR_SHIFT; ++ spi_transaction_ext_t trans = { ++ .base.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY | (len <= 4 ? SPI_TRANS_USE_RXDATA : 0), ++ .base.cmd = cmd, ++ .base.addr = addr, ++ .base.length = 8 * len, ++ .base.rx_buffer = value, ++ .command_bits = KSZ8851_SPI_COMMAND_BITS ++ }; ++ if (cmd >= KSZ8851_SPI_COMMAND_READ_FIFO) { ++ trans.address_bits = 8 - KSZ8851_SPI_COMMAND_BITS; ++ } else { ++ trans.address_bits = 16 - KSZ8851_SPI_COMMAND_BITS; ++ } ++ ++ if (spi_device_polling_transmit(spi->hdl, &trans.base) != ESP_OK) { ++ ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); ++ ret = ESP_FAIL; ++ } ++ ++ if ((trans.base.flags & SPI_TRANS_USE_RXDATA) && len <= 4) { ++ memcpy(value, trans.base.rx_data, len); // copy register values to output ++ //ESP_LOGV(TAG, "reading reg 0x%02x == 0x%04x", addr, *value); // TODO ++ } ++ return ret; ++} ++ ++static esp_err_t spi_write_std(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *value, uint32_t len) ++{ ++ esp_err_t ret = ESP_OK; ++ spi_info_t *spi = (spi_info_t *)spi_ctx; + + spi_transaction_ext_t trans = { +- .base.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY | SPI_TRANS_USE_RXDATA, +- .base.cmd = KSZ8851_SPI_COMMAND_READ_REG, +- .base.addr = address | byte_mask, +- .base.length = data_size, +- .command_bits = KSZ8851_SPI_COMMAND_BITS, +- .address_bits = 16 - KSZ8851_SPI_COMMAND_BITS, ++ .base.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY, ++ .base.cmd = cmd, ++ .base.addr = addr, ++ .base.length = 8 * len, ++ .base.tx_buffer = value, ++ .command_bits = KSZ8851_SPI_COMMAND_BITS + }; ++ if (cmd >= KSZ8851_SPI_COMMAND_READ_FIFO) { ++ trans.address_bits = 8 - KSZ8851_SPI_COMMAND_BITS; ++ } else { ++ trans.address_bits = 16 - KSZ8851_SPI_COMMAND_BITS; ++ } ++ ++ if (spi_device_polling_transmit(spi->hdl, &trans.base) != ESP_OK) { ++ ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); ++ ret = ESP_FAIL; ++ } ++ ++ return ret; ++} ++ ++static esp_err_t ksz8851_read_reg(emac_ksz8851snl_t *emac, uint32_t reg_addr, uint16_t *value) ++{ ++ esp_err_t ret = ESP_OK; ++ ESP_GOTO_ON_FALSE(value != NULL, ESP_ERR_INVALID_ARG, err, TAG, "out pointer must not be null"); ++ ESP_GOTO_ON_FALSE((reg_addr & ~KSZ8851_VALID_ADDRESS_MASK) == 0U, ESP_ERR_INVALID_ARG, err, TAG, "address is out of bounds"); ++ ++ // NOTE(v.chistyakov): select upper or lower word inside a dword ++ const unsigned byte_mask = 0x3U << (KSZ8851_SPI_BYTE_MASK_SHIFT + (reg_addr & 0x2U)); ++ reg_addr <<= KSZ8851_SPI_ADDR_SHIFT; ++ + if (ksz8851_mutex_lock(emac)) { +- if (spi_device_polling_transmit(emac->spi_hdl, &trans.base) != ESP_OK) { +- ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); +- ret = ESP_FAIL; +- } +- ksz8851_mutex_unlock(emac); +- memcpy(value, trans.base.rx_data, data_size >> 3U); +- ESP_LOGV(TAG, "reading reg 0x%02x == 0x%04x", address, *value); ++ ret = emac->spi.read(emac->spi.ctx, KSZ8851_SPI_COMMAND_READ_REG, reg_addr | byte_mask, value, 2); + } else { + ret = ESP_ERR_TIMEOUT; + } ++ ksz8851_mutex_unlock(emac); ++ + err: + return ret; + } + +-static esp_err_t ksz8851_write_reg(emac_ksz8851snl_t *emac, uint32_t address, uint16_t value) ++static esp_err_t ksz8851_write_reg(emac_ksz8851snl_t *emac, uint32_t reg_addr, uint16_t value) + { + esp_err_t ret = ESP_OK; +- ESP_GOTO_ON_FALSE((address & ~KSZ8851_VALID_ADDRESS_MASK) == 0U, ESP_ERR_INVALID_ARG, err, TAG, "address is out of bounds"); +- ESP_LOGV(TAG, "writing reg 0x%02x = 0x%04x", address, value); ++ ESP_GOTO_ON_FALSE((reg_addr & ~KSZ8851_VALID_ADDRESS_MASK) == 0U, ESP_ERR_INVALID_ARG, err, TAG, "address is out of bounds"); ++ ESP_LOGV(TAG, "writing reg 0x%02x = 0x%04x", reg_addr, value); + +- const unsigned data_size = 16U; // NOTE(v.chistyakov): bits + // NOTE(v.chistyakov): select upper or lower word inside a dword +- const unsigned byte_mask = 0x3U << (KSZ8851_SPI_BYTE_MASK_SHIFT + (address & 0x2U)); +- address <<= KSZ8851_SPI_ADDR_SHIFT; +- +- spi_transaction_ext_t trans = { +- .base.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY | SPI_TRANS_USE_TXDATA, +- .base.cmd = KSZ8851_SPI_COMMAND_WRITE_REG, +- .base.addr = address | byte_mask, +- .base.length = data_size, +- .command_bits = KSZ8851_SPI_COMMAND_BITS, +- .address_bits = 16 - KSZ8851_SPI_COMMAND_BITS, +- }; ++ const unsigned byte_mask = 0x3U << (KSZ8851_SPI_BYTE_MASK_SHIFT + (reg_addr & 0x2U)); ++ reg_addr <<= KSZ8851_SPI_ADDR_SHIFT; + +- memcpy(trans.base.tx_data, &value, data_size >> 3U); + if (ksz8851_mutex_lock(emac)) { +- if (spi_device_polling_transmit(emac->spi_hdl, &trans.base) != ESP_OK) { +- ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); +- ret = ESP_FAIL; +- } +- ksz8851_mutex_unlock(emac); ++ ret = emac->spi.write(emac->spi.ctx, KSZ8851_SPI_COMMAND_WRITE_REG, reg_addr | byte_mask, &value, 2); + } else { + ret = ESP_ERR_TIMEOUT; + } ++ ksz8851_mutex_unlock(emac); ++ + err: + return ret; + } +@@ -333,24 +403,12 @@ static esp_err_t emac_ksz8851snl_transmit(esp_eth_mac_t *mac, uint8_t *buf, uint + emac->tx_buffer[3] = (length >> 8U) & 0xFFU; + memcpy(emac->tx_buffer + 4U, buf, length); + +- spi_transaction_ext_t trans = { +- .base.flags = SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_CMD, +- .base.cmd = KSZ8851_SPI_COMMAND_WRITE_FIFO, +- .base.length = transmit_length * 8U, // NOTE(v.chistyakov): bits +- .base.tx_buffer = emac->tx_buffer, +- .command_bits = 2U, +- .address_bits = 6U, +- }; +- + uint16_t ier; + ESP_GOTO_ON_ERROR(ksz8851_read_reg(emac, KSZ8851_IER, &ier), err, TAG, "IER read failed"); + ESP_GOTO_ON_ERROR(ksz8851_write_reg(emac, KSZ8851_IER, 0), err, TAG, "IER write failed"); + + ESP_GOTO_ON_ERROR(ksz8851_set_bits(emac, KSZ8851_RXQCR, RXQCR_SDA), err, TAG, "RXQCR write failed"); +- if (spi_device_polling_transmit(emac->spi_hdl, &trans.base) != ESP_OK) { +- ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); +- ret = ESP_FAIL; +- } ++ ret = emac->spi.write(emac->spi.ctx, KSZ8851_SPI_COMMAND_WRITE_FIFO, 0, emac->tx_buffer, transmit_length); + ESP_GOTO_ON_ERROR(ksz8851_clear_bits(emac, KSZ8851_RXQCR, RXQCR_SDA), err, TAG, "RXQCR write failed"); + + ESP_GOTO_ON_ERROR(ksz8851_write_reg(emac, KSZ8851_IER, ier), err, TAG, "IER write failed"); +@@ -438,23 +496,12 @@ static esp_err_t emac_ksz8851_receive(esp_eth_mac_t *mac, uint8_t *buf, uint32_t + + // NOTE(v.chistyakov): 4 dummy + 4 header + alignment + const unsigned receive_size = 8U + ((byte_count + 3U) & ~0x3U); +- spi_transaction_ext_t trans = { +- .base.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY, +- .base.cmd = KSZ8851_SPI_COMMAND_READ_FIFO, +- .base.length = receive_size * 8U, // NOTE(v.chistyakov): bits +- .base.rx_buffer = emac->rx_buffer, +- .command_bits = 2U, +- .address_bits = 6U, +- }; + if (!ksz8851_mutex_lock(emac)) { + return ESP_ERR_TIMEOUT; + } + ESP_GOTO_ON_ERROR(ksz8851_clear_bits(emac, KSZ8851_RXFDPR, RXFDPR_RXFP_MASK), err, TAG, "RXFDPR write failed"); + ESP_GOTO_ON_ERROR(ksz8851_set_bits(emac, KSZ8851_RXQCR, RXQCR_SDA), err, TAG, "RXQCR write failed"); +- if (spi_device_polling_transmit(emac->spi_hdl, &trans.base) != ESP_OK) { +- ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); +- ret = ESP_FAIL; +- } ++ ret = emac->spi.read(emac->spi.ctx, KSZ8851_SPI_COMMAND_READ_FIFO, 0, emac->rx_buffer, receive_size); + ESP_GOTO_ON_ERROR(ksz8851_clear_bits(emac, KSZ8851_RXQCR, RXQCR_SDA), err, TAG, "RXQCR write failed"); + ksz8851_mutex_unlock(emac); + // NOTE(v.chistyakov): skip 4 dummy, 4 header +@@ -728,7 +775,7 @@ static esp_err_t emac_ksz8851_del(esp_eth_mac_t *mac) + { + emac_ksz8851snl_t *emac = __containerof(mac, emac_ksz8851snl_t, parent); + vTaskDelete(emac->rx_task_hdl); +- spi_bus_remove_device(emac->spi_hdl); ++ emac->spi.deinit(emac->spi.ctx); + vSemaphoreDelete(emac->spi_lock); + heap_caps_free(emac->rx_buffer); + heap_caps_free(emac->tx_buffer); +@@ -748,10 +795,6 @@ esp_eth_mac_t *esp_eth_mac_new_ksz8851snl(const eth_ksz8851snl_config_t *ksz8851 + emac = calloc(1, sizeof(emac_ksz8851snl_t)); + ESP_GOTO_ON_FALSE(emac, NULL, err, TAG, "no mem for MAC instance"); + +- /* SPI device init */ +- ESP_GOTO_ON_FALSE(spi_bus_add_device(ksz8851snl_config->spi_host_id, ksz8851snl_config->spi_devcfg, &emac->spi_hdl) == ESP_OK, +- NULL, err, TAG, "adding device to SPI host #%d failed", ksz8851snl_config->spi_host_id + 1); +- + emac->sw_reset_timeout_ms = mac_config->sw_reset_timeout_ms; + emac->int_gpio_num = ksz8851snl_config->int_gpio_num; + emac->parent.set_mediator = emac_ksz8851_set_mediator; +@@ -772,8 +815,6 @@ esp_eth_mac_t *esp_eth_mac_new_ksz8851snl(const eth_ksz8851snl_config_t *ksz8851 + emac->parent.enable_flow_ctrl = emac_ksz8851_enable_flow_ctrl; + emac->parent.set_peer_pause_ability = emac_ksz8851_set_peer_pause_ability; + emac->parent.del = emac_ksz8851_del; +- emac->spi_lock = xSemaphoreCreateRecursiveMutex(); +- ESP_GOTO_ON_FALSE(emac->spi_lock, NULL, err, TAG, "create lock failed"); + emac->rx_buffer = NULL; + emac->tx_buffer = NULL; + emac->rx_buffer = heap_caps_malloc(KSZ8851_QMU_PACKET_LENGTH + KSZ8851_QMU_PACKET_PADDING, MALLOC_CAP_DMA); +@@ -781,6 +822,29 @@ esp_eth_mac_t *esp_eth_mac_new_ksz8851snl(const eth_ksz8851snl_config_t *ksz8851 + ESP_GOTO_ON_FALSE(emac->rx_buffer, NULL, err, TAG, "RX buffer allocation failed"); + ESP_GOTO_ON_FALSE(emac->tx_buffer, NULL, err, TAG, "TX buffer allocation failed"); + ++ /* create mutex */ ++ emac->spi_lock = xSemaphoreCreateRecursiveMutex(); ++ ESP_GOTO_ON_FALSE(emac->spi_lock, NULL, err, TAG, "create lock failed"); ++ ++ if (ksz8851snl_config->custom_spi_driver.init != NULL && ksz8851snl_config->custom_spi_driver.deinit != NULL ++ && ksz8851snl_config->custom_spi_driver.read != NULL && ksz8851snl_config->custom_spi_driver.write != NULL) { ++ ESP_LOGD(TAG, "custom SPI Driver is used"); ++ emac->spi.init = ksz8851snl_config->custom_spi_driver.init; ++ emac->spi.deinit = ksz8851snl_config->custom_spi_driver.deinit; ++ emac->spi.read = ksz8851snl_config->custom_spi_driver.read; ++ emac->spi.write = ksz8851snl_config->custom_spi_driver.write; ++ /* Custom SPI driver device init */ ++ ESP_GOTO_ON_FALSE((emac->spi.ctx = emac->spi.init(ksz8851snl_config->custom_spi_driver.config)) != NULL, NULL, err, TAG, "SPI initialization failed"); ++ } else { ++ ESP_LOGD(TAG, "internal SPI Master Driver is used"); ++ emac->spi.init = spi_init_std; ++ emac->spi.deinit = spi_deinit_std; ++ emac->spi.read = spi_read_std; ++ emac->spi.write = spi_write_std; ++ /* SPI device init */ ++ ESP_GOTO_ON_FALSE((emac->spi.ctx = emac->spi.init(ksz8851snl_config)) != NULL, NULL, err, TAG, "SPI initialization failed"); ++ } ++ + BaseType_t core_num = tskNO_AFFINITY; + if (mac_config->flags & ETH_MAC_FLAG_PIN_TO_CORE) { + core_num = esp_cpu_get_core_id(); +diff --git a/components/esp_eth/src/esp_eth_mac_w5500.c b/components/esp_eth/src/esp_eth_mac_w5500.c +index 7a7708d0ca8bbbf77b32d9cb01ce34e57cc1f242..1d5bdc19f6749cd8b02112d7a31f3538b2903f98 100644 +--- a/components/esp_eth/src/esp_eth_mac_w5500.c ++++ b/components/esp_eth/src/esp_eth_mac_w5500.c +@@ -37,11 +37,23 @@ typedef struct { + uint32_t remain; + }__attribute__((packed)) emac_w5500_auto_buf_info_t; + ++typedef struct { ++ spi_device_handle_t hdl; ++ SemaphoreHandle_t lock; ++} spi_info_t; ++ ++typedef struct { ++ void *ctx; ++ void *(*init)(const void *spi_config); ++ esp_err_t (*deinit)(void *spi_ctx); ++ esp_err_t (*read)(void *spi_ctx, uint32_t cmd,uint32_t addr, void *data, uint32_t data_len); ++ esp_err_t (*write)(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *data, uint32_t data_len); ++} spi_interface_t; ++ + typedef struct { + esp_eth_mac_t parent; + esp_eth_mediator_t *eth; +- spi_device_handle_t spi_hdl; +- SemaphoreHandle_t spi_lock; ++ spi_interface_t spi; + TaskHandle_t rx_task_hdl; + uint32_t sw_reset_timeout_ms; + int int_gpio_num; +@@ -50,55 +62,101 @@ typedef struct { + uint8_t *rx_buffer; + } emac_w5500_t; + +-static inline bool w5500_lock(emac_w5500_t *emac) ++static void *spi_init_std(const void *spi_config) ++{ ++ void *ret = NULL; ++ eth_w5500_config_t *w5500_config = (eth_w5500_config_t *)spi_config; ++ spi_info_t *spi = calloc(1, sizeof(spi_info_t)); ++ ESP_GOTO_ON_FALSE(spi, NULL, err, TAG, "no memory for SPI context data"); ++ ++ /* SPI device init */ ++ spi_device_interface_config_t spi_devcfg; ++ memcpy(&spi_devcfg, w5500_config->spi_devcfg, sizeof(spi_device_interface_config_t)); ++ if (w5500_config->spi_devcfg->command_bits == 0 && w5500_config->spi_devcfg->address_bits == 0) { ++ /* configure default SPI frame format */ ++ spi_devcfg.command_bits = 16; // Actually it's the address phase in W5500 SPI frame ++ spi_devcfg.address_bits = 8; // Actually it's the control phase in W5500 SPI frame ++ } else { ++ ESP_GOTO_ON_FALSE(w5500_config->spi_devcfg->command_bits == 16 || w5500_config->spi_devcfg->address_bits == 8, ++ NULL, err, TAG, "incorrect SPI frame format (command_bits/address_bits)"); ++ } ++ ESP_GOTO_ON_FALSE(spi_bus_add_device(w5500_config->spi_host_id, &spi_devcfg, &spi->hdl) == ESP_OK, NULL, ++ err, TAG, "adding device to SPI host #%d failed", w5500_config->spi_host_id + 1); ++ /* create mutex */ ++ spi->lock = xSemaphoreCreateMutex(); ++ ESP_GOTO_ON_FALSE(spi->lock, NULL, err, TAG, "create lock failed"); ++ ++ return spi; ++err: ++ if (spi->lock) { ++ vSemaphoreDelete(spi->lock); ++ } ++ return ret; ++} ++ ++static esp_err_t spi_deinit_std(void *spi_ctx) ++{ ++ esp_err_t ret = ESP_OK; ++ spi_info_t *spi = (spi_info_t *)spi_ctx; ++ ++ spi_bus_remove_device(spi->hdl); ++ vSemaphoreDelete(spi->lock); ++ ++ free(spi); ++ return ret; ++} ++ ++static inline bool w5500_lock(spi_info_t *spi) + { +- return xSemaphoreTake(emac->spi_lock, pdMS_TO_TICKS(W5500_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; ++ return xSemaphoreTake(spi->lock, pdMS_TO_TICKS(W5500_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; + } + +-static inline bool w5500_unlock(emac_w5500_t *emac) ++static inline bool w5500_unlock(spi_info_t *spi) + { +- return xSemaphoreGive(emac->spi_lock) == pdTRUE; ++ return xSemaphoreGive(spi->lock) == pdTRUE; + } + +-static esp_err_t w5500_write(emac_w5500_t *emac, uint32_t address, const void *value, uint32_t len) ++static esp_err_t spi_write_std(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *value, uint32_t len) + { + esp_err_t ret = ESP_OK; ++ spi_info_t *spi = (spi_info_t *)spi_ctx; + + spi_transaction_t trans = { +- .cmd = (address >> W5500_ADDR_OFFSET), +- .addr = ((address & 0xFFFF) | (W5500_ACCESS_MODE_WRITE << W5500_RWB_OFFSET) | W5500_SPI_OP_MODE_VDM), ++ .cmd = cmd, ++ .addr = addr, + .length = 8 * len, + .tx_buffer = value + }; +- if (w5500_lock(emac)) { +- if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) { ++ if (w5500_lock(spi)) { ++ if (spi_device_polling_transmit(spi->hdl, &trans) != ESP_OK) { + ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); + ret = ESP_FAIL; + } +- w5500_unlock(emac); ++ w5500_unlock(spi); + } else { + ret = ESP_ERR_TIMEOUT; + } + return ret; + } + +-static esp_err_t w5500_read(emac_w5500_t *emac, uint32_t address, void *value, uint32_t len) ++static esp_err_t spi_read_std(void *spi_ctx, uint32_t cmd, uint32_t addr, void *value, uint32_t len) + { + esp_err_t ret = ESP_OK; ++ spi_info_t *spi = (spi_info_t *)spi_ctx; + + spi_transaction_t trans = { + .flags = len <= 4 ? SPI_TRANS_USE_RXDATA : 0, // use direct reads for registers to prevent overwrites by 4-byte boundary writes +- .cmd = (address >> W5500_ADDR_OFFSET), +- .addr = ((address & 0xFFFF) | (W5500_ACCESS_MODE_READ << W5500_RWB_OFFSET) | W5500_SPI_OP_MODE_VDM), ++ .cmd = cmd, ++ .addr = addr, + .length = 8 * len, + .rx_buffer = value + }; +- if (w5500_lock(emac)) { +- if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) { ++ if (w5500_lock(spi)) { ++ if (spi_device_polling_transmit(spi->hdl, &trans) != ESP_OK) { + ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); + ret = ESP_FAIL; + } +- w5500_unlock(emac); ++ w5500_unlock(spi); + } else { + ret = ESP_ERR_TIMEOUT; + } +@@ -108,6 +166,24 @@ static esp_err_t w5500_read(emac_w5500_t *emac, uint32_t address, void *value, u + return ret; + } + ++static esp_err_t w5500_read(emac_w5500_t *emac, uint32_t address, void *data, uint32_t len) ++{ ++ uint32_t cmd = (address >> W5500_ADDR_OFFSET); // Actually it's the address phase in W5500 SPI frame ++ uint32_t addr = ((address & 0xFFFF) | (W5500_ACCESS_MODE_READ << W5500_RWB_OFFSET) ++ | W5500_SPI_OP_MODE_VDM); // Actually it's the command phase in W5500 SPI frame ++ ++ return emac->spi.read(emac->spi.ctx, cmd, addr, data, len); ++} ++ ++static esp_err_t w5500_write(emac_w5500_t *emac, uint32_t address, const void *data, uint32_t len) ++{ ++ uint32_t cmd = (address >> W5500_ADDR_OFFSET); // Actually it's the address phase in W5500 SPI frame ++ uint32_t addr = ((address & 0xFFFF) | (W5500_ACCESS_MODE_WRITE << W5500_RWB_OFFSET) ++ | W5500_SPI_OP_MODE_VDM); // Actually it's the command phase in W5500 SPI frame ++ ++ return emac->spi.write(emac->spi.ctx, cmd, addr, data, len); ++} ++ + static esp_err_t w5500_send_command(emac_w5500_t *emac, uint8_t command, uint32_t timeout_ms) + { + esp_err_t ret = ESP_OK; +@@ -738,8 +814,7 @@ static esp_err_t emac_w5500_del(esp_eth_mac_t *mac) + { + emac_w5500_t *emac = __containerof(mac, emac_w5500_t, parent); + vTaskDelete(emac->rx_task_hdl); +- spi_bus_remove_device(emac->spi_hdl); +- vSemaphoreDelete(emac->spi_lock); ++ emac->spi.deinit(emac->spi.ctx); + heap_caps_free(emac->rx_buffer); + free(emac); + return ESP_OK; +@@ -754,19 +829,6 @@ esp_eth_mac_t *esp_eth_mac_new_w5500(const eth_w5500_config_t *w5500_config, con + ESP_GOTO_ON_FALSE(emac, NULL, err, TAG, "no mem for MAC instance"); + /* w5500 driver is interrupt driven */ + ESP_GOTO_ON_FALSE(w5500_config->int_gpio_num >= 0, NULL, err, TAG, "invalid interrupt gpio number"); +- /* SPI device init */ +- spi_device_interface_config_t spi_devcfg; +- memcpy(&spi_devcfg, w5500_config->spi_devcfg, sizeof(spi_device_interface_config_t)); +- if (w5500_config->spi_devcfg->command_bits == 0 && w5500_config->spi_devcfg->address_bits == 0) { +- /* configure default SPI frame format */ +- spi_devcfg.command_bits = 16; // Actually it's the address phase in W5500 SPI frame +- spi_devcfg.address_bits = 8; // Actually it's the control phase in W5500 SPI frame +- } else { +- ESP_GOTO_ON_FALSE(w5500_config->spi_devcfg->command_bits == 16 || w5500_config->spi_devcfg->address_bits == 8, +- NULL, err, TAG, "incorrect SPI frame format (command_bits/address_bits)"); +- } +- ESP_GOTO_ON_FALSE(spi_bus_add_device(w5500_config->spi_host_id, &spi_devcfg, &emac->spi_hdl) == ESP_OK, +- NULL, err, TAG, "adding device to SPI host #%d failed", w5500_config->spi_host_id + 1); + /* bind methods and attributes */ + emac->sw_reset_timeout_ms = mac_config->sw_reset_timeout_ms; + emac->int_gpio_num = w5500_config->int_gpio_num; +@@ -788,9 +850,26 @@ esp_eth_mac_t *esp_eth_mac_new_w5500(const eth_w5500_config_t *w5500_config, con + emac->parent.enable_flow_ctrl = emac_w5500_enable_flow_ctrl; + emac->parent.transmit = emac_w5500_transmit; + emac->parent.receive = emac_w5500_receive; +- /* create mutex */ +- emac->spi_lock = xSemaphoreCreateMutex(); +- ESP_GOTO_ON_FALSE(emac->spi_lock, NULL, err, TAG, "create lock failed"); ++ ++ if (w5500_config->custom_spi_driver.init != NULL && w5500_config->custom_spi_driver.deinit != NULL ++ && w5500_config->custom_spi_driver.read != NULL && w5500_config->custom_spi_driver.write != NULL) { ++ ESP_LOGD(TAG, "custom SPI Driver is used"); ++ emac->spi.init = w5500_config->custom_spi_driver.init; ++ emac->spi.deinit = w5500_config->custom_spi_driver.deinit; ++ emac->spi.read = w5500_config->custom_spi_driver.read; ++ emac->spi.write = w5500_config->custom_spi_driver.write; ++ /* Custom SPI driver device init */ ++ ESP_GOTO_ON_FALSE((emac->spi.ctx = emac->spi.init(w5500_config->custom_spi_driver.config)) != NULL, NULL, err, TAG, "SPI initialization failed"); ++ } else { ++ ESP_LOGD(TAG, "internal SPI Master Driver is used"); ++ emac->spi.init = spi_init_std; ++ emac->spi.deinit = spi_deinit_std; ++ emac->spi.read = spi_read_std; ++ emac->spi.write = spi_write_std; ++ /* SPI device init */ ++ ESP_GOTO_ON_FALSE((emac->spi.ctx = emac->spi.init(w5500_config)) != NULL, NULL, err, TAG, "SPI initialization failed"); ++ } ++ + /* create w5500 task */ + BaseType_t core_num = tskNO_AFFINITY; + if (mac_config->flags & ETH_MAC_FLAG_PIN_TO_CORE) { +@@ -806,13 +885,11 @@ esp_eth_mac_t *esp_eth_mac_new_w5500(const eth_w5500_config_t *w5500_config, con + return &(emac->parent); + + err: ++ // TODO SPI deinit? + if (emac) { + if (emac->rx_task_hdl) { + vTaskDelete(emac->rx_task_hdl); + } +- if (emac->spi_lock) { +- vSemaphoreDelete(emac->spi_lock); +- } + heap_caps_free(emac->rx_buffer); + free(emac); + } + From 9b4e917f9e52f749e85e281b92ac47e3d8c80364 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 4 Sep 2023 13:14:17 +0200 Subject: [PATCH 016/211] Update nimble.diff --- patches/nimble.diff | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/patches/nimble.diff b/patches/nimble.diff index 4b6e60c7d..10803bb6c 100644 --- a/patches/nimble.diff +++ b/patches/nimble.diff @@ -1,7 +1,7 @@ -diff --git a/nimble/host/services/gap/include/services/gap/ble_svc_gap.h b/nimble/host/services/gap/include/services/gap/ble_svc_gap.h +diff --git a/components/bt/host/nimble/nimble/nimble/host/services/gap/include/services/gap/ble_svc_gap.h b/components/bt/host/nimble/nimble/nimble/host/services/gap/include/services/gap/ble_svc_gap.h index a1f84f1d6..f748d6494 100644 ---- a/nimble/host/services/gap/include/services/gap/ble_svc_gap.h -+++ b/nimble/host/services/gap/include/services/gap/ble_svc_gap.h +--- a/components/bt/host/nimble/nimble/nimble/host/services/gap/include/services/gap/ble_svc_gap.h ++++ b/components/bt/host/nimble/nimble/nimble/host/services/gap/include/services/gap/ble_svc_gap.h @@ -20,6 +20,7 @@ #ifndef H_BLE_SVC_GAP_ #define H_BLE_SVC_GAP_ @@ -10,3 +10,4 @@ index a1f84f1d6..f748d6494 100644 #include #if MYNEWT_VAL(ENC_ADV_DATA) #include "host/ble_ead.h" + From e329cc40f7c0808dee96f17d6e050708008e474d Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 4 Sep 2023 18:17:14 +0200 Subject: [PATCH 017/211] Update build.sh --- build.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.sh b/build.sh index bd68d59a7..b61b3743b 100755 --- a/build.sh +++ b/build.sh @@ -155,6 +155,12 @@ done component_version="tinyusb: "$(git -C "$AR_COMPS/arduino_tinyusb/tinyusb" symbolic-ref --short HEAD || git -C "$AR_COMPS/arduino_tinyusb/tinyusb" tag --points-at HEAD)" "$(git -C "$AR_COMPS/arduino_tinyusb/tinyusb" rev-parse --short HEAD) echo $component_version >> version.txt && echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt" +# Add release-info +rm -rf release-info.txt +IDF_Commit_short=$(git -C "$IDF_PATH" rev-parse --short HEAD || echo "") +AR_Commit_short=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "") +echo "Framework built from $IDF_REPO branch $IDF_BRANCH commit $IDF_Commit_short and $AR_REPO branch $AR_BRANCH commit $AR_Commit_short" >> release-info.txt + #targets_count=`jq -c '.targets[] | length' configs/builds.json` for target_json in `jq -c '.targets[]' configs/builds.json`; do target=$(echo "$target_json" | jq -c '.target' | tr -d '"') From f4203c49c8667f53290e5398f0defa0216ed1c19 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 4 Sep 2023 18:17:34 +0200 Subject: [PATCH 018/211] Update config.sh --- tools/config.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/config.sh b/tools/config.sh index 15d54b770..baf75167b 100755 --- a/tools/config.sh +++ b/tools/config.sh @@ -77,8 +77,8 @@ else AR_COMMIT=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "") fi -rm -rf release-info.txt -echo "Framework built from Tasmota IDF branch $IDF_BRANCH commit $IDF_COMMIT and $AR_REPO branch $AR_BRANCH commit $AR_COMMIT" >> release-info.txt +#rm -rf release-info.txt +#echo "Framework built from Tasmota IDF branch $IDF_BRANCH commit $IDF_COMMIT and $AR_REPO branch $AR_BRANCH commit $AR_COMMIT" >> release-info.txt function get_os(){ OSBITS=`arch` From e0f924a65cd6b257c5234872661199187bd42520 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 5 Sep 2023 13:10:55 +0200 Subject: [PATCH 019/211] Add a temporary fix for relative include in BT lib --- tools/copy-libs.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/copy-libs.sh b/tools/copy-libs.sh index 2542a9a31..a20358c6a 100755 --- a/tools/copy-libs.sh +++ b/tools/copy-libs.sh @@ -402,6 +402,11 @@ for item; do mkdir -p "$out_cpath$rel_p" cp -n $f "$out_cpath$rel_p/" done + # Temporary measure to fix issues caused by https://github.com/espressif/esp-idf/commit/dc4731101dd567cc74bbe4d0f03afe52b7db9afb#diff-1d2ce0d3989a80830fdf230bcaafb3117f32046d16cf46616ac3d55b4df2a988R17 + if [[ "$fname" == "bt" && "$out_sub" == "/include/$IDF_TARGET/include" && -f "$ipath/controller/$IDF_TARGET/esp_bt_cfg.h" ]]; then + mkdir -p "$AR_SDK/include/$fname/controller/$IDF_TARGET" + cp -n "$ipath/controller/$IDF_TARGET/esp_bt_cfg.h" "$AR_SDK/include/$fname/controller/$IDF_TARGET/esp_bt_cfg.h" + fi fi done echo " join($PIO_SDK, board_config.get(\"build.arduino.memory_type\", (board_config.get(\"build.flash_mode\", \"dio\") + \"_qspi\")), \"include\")," >> "$AR_PLATFORMIO_PY" From 1ffafcdffa6d88c03d5969e764a7fa0294b16169 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 15 Sep 2023 14:31:30 +0200 Subject: [PATCH 020/211] Update spi_eth.diff --- patches/spi_eth.diff | 358 ++++++++++++++++++++++++------------------- 1 file changed, 197 insertions(+), 161 deletions(-) diff --git a/patches/spi_eth.diff b/patches/spi_eth.diff index 6b5281fef..1e57dbef1 100644 --- a/patches/spi_eth.diff +++ b/patches/spi_eth.diff @@ -1,5 +1,5 @@ diff --git a/components/esp_eth/include/esp_eth_mac.h b/components/esp_eth/include/esp_eth_mac.h -index dfc1af2c73b5e6a872a5c0583e0223ca86b49ae2..c2600a178df7fd756624e200148ec899ba522807 100644 +index dfc1af2c73b5e6a872a5c0583e0223ca86b49ae2..885d332d4363e093d84af1a196c532450386b8ce 100644 --- a/components/esp_eth/include/esp_eth_mac.h +++ b/components/esp_eth/include/esp_eth_mac.h @@ -1,5 +1,5 @@ @@ -23,7 +23,7 @@ index dfc1af2c73b5e6a872a5c0583e0223ca86b49ae2..c2600a178df7fd756624e200148ec899 +typedef struct +{ + /** -+ * @brief Custom driver specific configuration structure used by `init()` function. ++ * @brief Custom driver specific configuration data used by `init()` function. + * + * @note Type and its content is fully under user's control + * @@ -100,13 +100,13 @@ index dfc1af2c73b5e6a872a5c0583e0223ca86b49ae2..c2600a178df7fd756624e200148ec899 + * Internal ESP-IDF SPI Master driver is used by default. + * + */ -+#define ETH_NO_CUSTOM_SPI \ -+ { \ -+ .config = NULL, \ -+ .init = NULL, \ -+ .deinit = NULL, \ -+ .read = NULL, \ -+ .write = NULL \ ++#define ETH_DEFAULT_SPI \ ++ { \ ++ .config = NULL, \ ++ .init = NULL, \ ++ .deinit = NULL, \ ++ .read = NULL, \ ++ .write = NULL \ + } +#endif // CONFIG_ETH_USE_SPI_ETHERNET + @@ -133,7 +133,7 @@ index dfc1af2c73b5e6a872a5c0583e0223ca86b49ae2..c2600a178df7fd756624e200148ec899 .spi_host_id = spi_host, \ .spi_devcfg = spi_devcfg_p, \ - .int_gpio_num = 4, \ -+ .custom_spi_driver = ETH_NO_CUSTOM_SPI, \ ++ .custom_spi_driver = ETH_DEFAULT_SPI, \ } /** @@ -162,7 +162,7 @@ index dfc1af2c73b5e6a872a5c0583e0223ca86b49ae2..c2600a178df7fd756624e200148ec899 + .int_gpio_num = 4, \ + .spi_host_id = spi_host, \ + .spi_devcfg = spi_devcfg_p, \ -+ .custom_spi_driver = ETH_NO_CUSTOM_SPI, \ ++ .custom_spi_driver = ETH_DEFAULT_SPI, \ } /** @@ -187,12 +187,12 @@ index dfc1af2c73b5e6a872a5c0583e0223ca86b49ae2..c2600a178df7fd756624e200148ec899 .spi_host_id = spi_host, \ .spi_devcfg = spi_devcfg_p, \ - .int_gpio_num = 14, \ -+ .custom_spi_driver = ETH_NO_CUSTOM_SPI, \ ++ .custom_spi_driver = ETH_DEFAULT_SPI, \ } /** diff --git a/components/esp_eth/src/esp_eth_mac_dm9051.c b/components/esp_eth/src/esp_eth_mac_dm9051.c -index b0d339cc93d1d6ef39b1e819102c220d431114b2..22b9efa2b2eb353b4493ac9f0437bcd829a49d7d 100644 +index b0d339cc93d1d6ef39b1e819102c220d431114b2..ba796121b7065ba984cfbc683283e82a6702a04a 100644 --- a/components/esp_eth/src/esp_eth_mac_dm9051.c +++ b/components/esp_eth/src/esp_eth_mac_dm9051.c @@ -1,5 +1,5 @@ @@ -228,27 +228,27 @@ index b0d339cc93d1d6ef39b1e819102c220d431114b2..22b9efa2b2eb353b4493ac9f0437bcd8 TaskHandle_t rx_task_hdl; uint32_t sw_reset_timeout_ms; int int_gpio_num; -@@ -61,89 +73,133 @@ typedef struct { +@@ -61,89 +73,137 @@ typedef struct { uint8_t *rx_buffer; } emac_dm9051_t; -static inline bool dm9051_lock(emac_dm9051_t *emac) -+static void *spi_init_std(const void *spi_config) ++static void *dm9051_spi_init(const void *spi_config) +{ + void *ret = NULL; + eth_dm9051_config_t *dm9051_config = (eth_dm9051_config_t *)spi_config; + spi_info_t *spi = calloc(1, sizeof(spi_info_t)); + ESP_GOTO_ON_FALSE(spi, NULL, err, TAG, "no memory for SPI context data"); + -+ /* SPI device init */ ++ /* SPI device init */ + spi_device_interface_config_t spi_devcfg; -+ memcpy(&spi_devcfg, dm9051_config->spi_devcfg, sizeof(spi_device_interface_config_t)); ++ spi_devcfg = *(dm9051_config->spi_devcfg); + if (dm9051_config->spi_devcfg->command_bits == 0 && dm9051_config->spi_devcfg->address_bits == 0) { + /* configure default SPI frame format */ + spi_devcfg.command_bits = 1; + spi_devcfg.address_bits = 7; + } else { -+ ESP_GOTO_ON_FALSE(dm9051_config->spi_devcfg->command_bits == 1 || dm9051_config->spi_devcfg->address_bits == 7, ++ ESP_GOTO_ON_FALSE(dm9051_config->spi_devcfg->command_bits == 1 && dm9051_config->spi_devcfg->address_bits == 7, + NULL, err, TAG, "incorrect SPI frame format (command_bits/address_bits)"); + } + ESP_GOTO_ON_FALSE(spi_bus_add_device(dm9051_config->spi_host_id, &spi_devcfg, &spi->hdl) == ESP_OK, @@ -258,16 +258,21 @@ index b0d339cc93d1d6ef39b1e819102c220d431114b2..22b9efa2b2eb353b4493ac9f0437bcd8 + spi->lock = xSemaphoreCreateMutex(); + ESP_GOTO_ON_FALSE(spi->lock, NULL, err, TAG, "create lock failed"); + -+ return spi; ++ ret = spi; ++ return ret; +err: -+ if (spi->lock) { -+ vSemaphoreDelete(spi->lock); ++ if (spi) { ++ if (spi->lock) { ++ vSemaphoreDelete(spi->lock); ++ } ++ free(spi); + } + return ret; +} + -+static esp_err_t spi_deinit_std(void *spi_ctx) -+{ ++static esp_err_t dm9051_spi_deinit(void *spi_ctx) + { +- return xSemaphoreTake(emac->spi_lock, pdMS_TO_TICKS(DM9051_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; + esp_err_t ret = ESP_OK; + spi_info_t *spi = (spi_info_t *)spi_ctx; + @@ -276,26 +281,25 @@ index b0d339cc93d1d6ef39b1e819102c220d431114b2..22b9efa2b2eb353b4493ac9f0437bcd8 + + free(spi); + return ret; -+} -+ -+static inline bool dm9051_lock(spi_info_t *spi) - { -- return xSemaphoreTake(emac->spi_lock, pdMS_TO_TICKS(DM9051_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; -+ return xSemaphoreTake(spi->lock, pdMS_TO_TICKS(DM9051_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; } -static inline bool dm9051_unlock(emac_dm9051_t *emac) -+static inline bool dm9051_unlock(spi_info_t *spi) ++static inline bool dm9051_spi_lock(spi_info_t *spi) { - return xSemaphoreGive(emac->spi_lock) == pdTRUE; -+ return xSemaphoreGive(spi->lock) == pdTRUE; ++ return xSemaphoreTake(spi->lock, pdMS_TO_TICKS(DM9051_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; } -/** - * @brief write value to dm9051 internal register - */ -static esp_err_t dm9051_register_write(emac_dm9051_t *emac, uint8_t reg_addr, uint8_t value) -+static esp_err_t spi_write_std(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *value, uint32_t len) ++static inline bool dm9051_spi_unlock(spi_info_t *spi) ++{ ++ return xSemaphoreGive(spi->lock) == pdTRUE; ++} ++ ++static esp_err_t dm9051_spi_write(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *value, uint32_t len) { esp_err_t ret = ESP_OK; + spi_info_t *spi = (spi_info_t *)spi_ctx; @@ -313,13 +317,13 @@ index b0d339cc93d1d6ef39b1e819102c220d431114b2..22b9efa2b2eb353b4493ac9f0437bcd8 - trans.tx_data[0] = value; - if (dm9051_lock(emac)) { - if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) { -+ if (dm9051_lock(spi)) { ++ if (dm9051_spi_lock(spi)) { + if (spi_device_polling_transmit(spi->hdl, &trans) != ESP_OK) { ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); ret = ESP_FAIL; } - dm9051_unlock(emac); -+ dm9051_unlock(spi); ++ dm9051_spi_unlock(spi); } else { ret = ESP_ERR_TIMEOUT; } @@ -330,7 +334,7 @@ index b0d339cc93d1d6ef39b1e819102c220d431114b2..22b9efa2b2eb353b4493ac9f0437bcd8 - * @brief read value from dm9051 internal register - */ -static esp_err_t dm9051_register_read(emac_dm9051_t *emac, uint8_t reg_addr, uint8_t *value) -+static esp_err_t spi_read_std(void *spi_ctx, uint32_t cmd, uint32_t addr, void *value, uint32_t len) ++static esp_err_t dm9051_spi_read(void *spi_ctx, uint32_t cmd, uint32_t addr, void *value, uint32_t len) { esp_err_t ret = ESP_OK; + spi_info_t *spi = (spi_info_t *)spi_ctx; @@ -348,7 +352,7 @@ index b0d339cc93d1d6ef39b1e819102c220d431114b2..22b9efa2b2eb353b4493ac9f0437bcd8 }; - if (dm9051_lock(emac)) { - if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) { -+ if (dm9051_lock(spi)) { ++ if (dm9051_spi_lock(spi)) { + if (spi_device_polling_transmit(spi->hdl, &trans) != ESP_OK) { ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); ret = ESP_FAIL; @@ -356,7 +360,7 @@ index b0d339cc93d1d6ef39b1e819102c220d431114b2..22b9efa2b2eb353b4493ac9f0437bcd8 - *value = trans.rx_data[0]; } - dm9051_unlock(emac); -+ dm9051_unlock(spi); ++ dm9051_spi_unlock(spi); } else { ret = ESP_ERR_TIMEOUT; } @@ -408,7 +412,7 @@ index b0d339cc93d1d6ef39b1e819102c220d431114b2..22b9efa2b2eb353b4493ac9f0437bcd8 } /** -@@ -151,23 +207,7 @@ static esp_err_t dm9051_memory_write(emac_dm9051_t *emac, uint8_t *buffer, uint3 +@@ -151,23 +211,7 @@ static esp_err_t dm9051_memory_write(emac_dm9051_t *emac, uint8_t *buffer, uint3 */ static esp_err_t dm9051_memory_read(emac_dm9051_t *emac, uint8_t *buffer, uint32_t len) { @@ -433,7 +437,7 @@ index b0d339cc93d1d6ef39b1e819102c220d431114b2..22b9efa2b2eb353b4493ac9f0437bcd8 } /** -@@ -175,23 +215,7 @@ static esp_err_t dm9051_memory_read(emac_dm9051_t *emac, uint8_t *buffer, uint32 +@@ -175,23 +219,7 @@ static esp_err_t dm9051_memory_read(emac_dm9051_t *emac, uint8_t *buffer, uint32 */ static esp_err_t dm9051_memory_peek(emac_dm9051_t *emac, uint8_t *buffer, uint32_t len) { @@ -458,7 +462,7 @@ index b0d339cc93d1d6ef39b1e819102c220d431114b2..22b9efa2b2eb353b4493ac9f0437bcd8 } /** -@@ -840,8 +864,7 @@ static esp_err_t emac_dm9051_del(esp_eth_mac_t *mac) +@@ -840,8 +868,7 @@ static esp_err_t emac_dm9051_del(esp_eth_mac_t *mac) { emac_dm9051_t *emac = __containerof(mac, emac_dm9051_t, parent); vTaskDelete(emac->rx_task_hdl); @@ -468,7 +472,7 @@ index b0d339cc93d1d6ef39b1e819102c220d431114b2..22b9efa2b2eb353b4493ac9f0437bcd8 heap_caps_free(emac->rx_buffer); free(emac); return ESP_OK; -@@ -857,19 +880,6 @@ esp_eth_mac_t *esp_eth_mac_new_dm9051(const eth_dm9051_config_t *dm9051_config, +@@ -857,19 +884,6 @@ esp_eth_mac_t *esp_eth_mac_new_dm9051(const eth_dm9051_config_t *dm9051_config, ESP_GOTO_ON_FALSE(emac, NULL, err, TAG, "calloc emac failed"); /* dm9051 receive is driven by interrupt only for now*/ ESP_GOTO_ON_FALSE(dm9051_config->int_gpio_num >= 0, NULL, err, TAG, "error interrupt gpio number"); @@ -488,7 +492,7 @@ index b0d339cc93d1d6ef39b1e819102c220d431114b2..22b9efa2b2eb353b4493ac9f0437bcd8 /* bind methods and attributes */ emac->sw_reset_timeout_ms = mac_config->sw_reset_timeout_ms; emac->int_gpio_num = dm9051_config->int_gpio_num; -@@ -891,9 +901,26 @@ esp_eth_mac_t *esp_eth_mac_new_dm9051(const eth_dm9051_config_t *dm9051_config, +@@ -891,9 +905,26 @@ esp_eth_mac_t *esp_eth_mac_new_dm9051(const eth_dm9051_config_t *dm9051_config, emac->parent.enable_flow_ctrl = emac_dm9051_enable_flow_ctrl; emac->parent.transmit = emac_dm9051_transmit; emac->parent.receive = emac_dm9051_receive; @@ -498,7 +502,7 @@ index b0d339cc93d1d6ef39b1e819102c220d431114b2..22b9efa2b2eb353b4493ac9f0437bcd8 + + if (dm9051_config->custom_spi_driver.init != NULL && dm9051_config->custom_spi_driver.deinit != NULL + && dm9051_config->custom_spi_driver.read != NULL && dm9051_config->custom_spi_driver.write != NULL) { -+ ESP_LOGD(TAG, "custom SPI Driver is used"); ++ ESP_LOGD(TAG, "Using user's custom SPI Driver"); + emac->spi.init = dm9051_config->custom_spi_driver.init; + emac->spi.deinit = dm9051_config->custom_spi_driver.deinit; + emac->spi.read = dm9051_config->custom_spi_driver.read; @@ -506,11 +510,11 @@ index b0d339cc93d1d6ef39b1e819102c220d431114b2..22b9efa2b2eb353b4493ac9f0437bcd8 + /* Custom SPI driver device init */ + ESP_GOTO_ON_FALSE((emac->spi.ctx = emac->spi.init(dm9051_config->custom_spi_driver.config)) != NULL, NULL, err, TAG, "SPI initialization failed"); + } else { -+ ESP_LOGD(TAG, "internal SPI Master Driver is used"); -+ emac->spi.init = spi_init_std; -+ emac->spi.deinit = spi_deinit_std; -+ emac->spi.read = spi_read_std; -+ emac->spi.write = spi_write_std; ++ ESP_LOGD(TAG, "Using default SPI Driver"); ++ emac->spi.init = dm9051_spi_init; ++ emac->spi.deinit = dm9051_spi_deinit; ++ emac->spi.read = dm9051_spi_read; ++ emac->spi.write = dm9051_spi_write; + /* SPI device init */ + ESP_GOTO_ON_FALSE((emac->spi.ctx = emac->spi.init(dm9051_config)) != NULL, NULL, err, TAG, "SPI initialization failed"); + } @@ -518,18 +522,19 @@ index b0d339cc93d1d6ef39b1e819102c220d431114b2..22b9efa2b2eb353b4493ac9f0437bcd8 /* create dm9051 task */ BaseType_t core_num = tskNO_AFFINITY; if (mac_config->flags & ETH_MAC_FLAG_PIN_TO_CORE) { -@@ -913,9 +940,6 @@ err: +@@ -913,8 +944,8 @@ err: if (emac->rx_task_hdl) { vTaskDelete(emac->rx_task_hdl); } - if (emac->spi_lock) { - vSemaphoreDelete(emac->spi_lock); -- } ++ if (emac->spi.ctx) { ++ emac->spi.deinit(emac->spi.ctx); + } heap_caps_free(emac->rx_buffer); free(emac); - } diff --git a/components/esp_eth/src/esp_eth_mac_ksz8851snl.c b/components/esp_eth/src/esp_eth_mac_ksz8851snl.c -index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f22f0f5520 100644 +index b6aea4df90ead8dc2162e0735bdc310717881c97..cda12f0159835ea1cb818736bdc2611056b131ff 100644 --- a/components/esp_eth/src/esp_eth_mac_ksz8851snl.c +++ b/components/esp_eth/src/esp_eth_mac_ksz8851snl.c @@ -3,7 +3,7 @@ @@ -565,26 +570,30 @@ index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f2 SemaphoreHandle_t spi_lock; TaskHandle_t rx_task_hdl; uint32_t sw_reset_timeout_ms; -@@ -73,6 +85,32 @@ IRAM_ATTR static void ksz8851_isr_handler(void *arg) +@@ -73,6 +85,95 @@ IRAM_ATTR static void ksz8851_isr_handler(void *arg) } } -+static void *spi_init_std(const void *spi_config) ++static void *ksz8851_spi_init(const void *spi_config) +{ + void *ret = NULL; + eth_ksz8851snl_config_t *ksz8851snl_config = (eth_ksz8851snl_config_t *)spi_config; -+ spi_info_t *spi = calloc(1, sizeof(spi_info_t)); // TODO maybe replace with static variable spi_host_id ++ spi_info_t *spi = calloc(1, sizeof(spi_info_t)); + ESP_GOTO_ON_FALSE(spi, NULL, err, TAG, "no memory for SPI context data"); + -+ /* SPI device init */ ++ // SPI device init + ESP_GOTO_ON_FALSE(spi_bus_add_device(ksz8851snl_config->spi_host_id, ksz8851snl_config->spi_devcfg, &spi->hdl) == ESP_OK, NULL, + err, TAG, "adding device to SPI host #%d failed", ksz8851snl_config->spi_host_id + 1); -+ return spi; ++ ret = spi; ++ return ret; +err: ++ if (spi) { ++ free(spi); ++ } + return ret; +} + -+static esp_err_t spi_deinit_std(void *spi_ctx) ++static esp_err_t ksz8851_spi_deinit(void *spi_ctx) +{ + esp_err_t ret = ESP_OK; + spi_info_t *spi = (spi_info_t *)spi_ctx; @@ -595,25 +604,11 @@ index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f2 + return ret; +} + - static inline bool ksz8851_mutex_lock(emac_ksz8851snl_t *emac) - { - return xSemaphoreTakeRecursive(emac->spi_lock, pdMS_TO_TICKS(KSZ8851_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; -@@ -83,70 +121,102 @@ static inline bool ksz8851_mutex_unlock(emac_ksz8851snl_t *emac) - return xSemaphoreGiveRecursive(emac->spi_lock) == pdTRUE; - } - --static esp_err_t ksz8851_read_reg(emac_ksz8851snl_t *emac, uint32_t address, uint16_t *value) -+static esp_err_t spi_read_std(void *spi_ctx, uint32_t cmd, uint32_t addr, void *value, uint32_t len) - { - esp_err_t ret = ESP_OK; -- ESP_GOTO_ON_FALSE(value != NULL, ESP_ERR_INVALID_ARG, err, TAG, "out pointer must not be null"); -- ESP_GOTO_ON_FALSE((address & ~KSZ8851_VALID_ADDRESS_MASK) == 0U, ESP_ERR_INVALID_ARG, err, TAG, "address is out of bounds"); ++static esp_err_t ksz8851_spi_read(void *spi_ctx, uint32_t cmd, uint32_t addr, void *value, uint32_t len) ++{ ++ esp_err_t ret = ESP_OK; + spi_info_t *spi = (spi_info_t *)spi_ctx; - -- const unsigned data_size = 16U; // NOTE(v.chistyakov): bits -- // NOTE(v.chistyakov): select upper or lower word inside a dword -- const unsigned byte_mask = 0x3U << (KSZ8851_SPI_BYTE_MASK_SHIFT + (address & 0x2U)); -- address <<= KSZ8851_SPI_ADDR_SHIFT; ++ + spi_transaction_ext_t trans = { + .base.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY | (len <= 4 ? SPI_TRANS_USE_RXDATA : 0), + .base.cmd = cmd, @@ -628,6 +623,7 @@ index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f2 + trans.address_bits = 16 - KSZ8851_SPI_COMMAND_BITS; + } + ++ // No need for mutex here since SPI access is protected at higher layer of this driver + if (spi_device_polling_transmit(spi->hdl, &trans.base) != ESP_OK) { + ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); + ret = ESP_FAIL; @@ -635,36 +631,30 @@ index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f2 + + if ((trans.base.flags & SPI_TRANS_USE_RXDATA) && len <= 4) { + memcpy(value, trans.base.rx_data, len); // copy register values to output -+ //ESP_LOGV(TAG, "reading reg 0x%02x == 0x%04x", addr, *value); // TODO + } + return ret; +} + -+static esp_err_t spi_write_std(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *value, uint32_t len) ++static esp_err_t ksz8851_spi_write(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *value, uint32_t len) +{ + esp_err_t ret = ESP_OK; + spi_info_t *spi = (spi_info_t *)spi_ctx; - - spi_transaction_ext_t trans = { -- .base.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY | SPI_TRANS_USE_RXDATA, -- .base.cmd = KSZ8851_SPI_COMMAND_READ_REG, -- .base.addr = address | byte_mask, -- .base.length = data_size, -- .command_bits = KSZ8851_SPI_COMMAND_BITS, -- .address_bits = 16 - KSZ8851_SPI_COMMAND_BITS, ++ ++ spi_transaction_ext_t trans = { + .base.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY, + .base.cmd = cmd, + .base.addr = addr, + .base.length = 8 * len, + .base.tx_buffer = value, + .command_bits = KSZ8851_SPI_COMMAND_BITS - }; ++ }; + if (cmd >= KSZ8851_SPI_COMMAND_READ_FIFO) { + trans.address_bits = 8 - KSZ8851_SPI_COMMAND_BITS; + } else { + trans.address_bits = 16 - KSZ8851_SPI_COMMAND_BITS; + } + ++ // No need for mutex here since SPI access is protected at higher layer of this driver + if (spi_device_polling_transmit(spi->hdl, &trans.base) != ESP_OK) { + ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); + ret = ESP_FAIL; @@ -673,16 +663,38 @@ index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f2 + return ret; +} + + static inline bool ksz8851_mutex_lock(emac_ksz8851snl_t *emac) + { + return xSemaphoreTakeRecursive(emac->spi_lock, pdMS_TO_TICKS(KSZ8851_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; +@@ -83,70 +184,49 @@ static inline bool ksz8851_mutex_unlock(emac_ksz8851snl_t *emac) + return xSemaphoreGiveRecursive(emac->spi_lock) == pdTRUE; + } + +-static esp_err_t ksz8851_read_reg(emac_ksz8851snl_t *emac, uint32_t address, uint16_t *value) +static esp_err_t ksz8851_read_reg(emac_ksz8851snl_t *emac, uint32_t reg_addr, uint16_t *value) -+{ -+ esp_err_t ret = ESP_OK; -+ ESP_GOTO_ON_FALSE(value != NULL, ESP_ERR_INVALID_ARG, err, TAG, "out pointer must not be null"); + { + esp_err_t ret = ESP_OK; + ESP_GOTO_ON_FALSE(value != NULL, ESP_ERR_INVALID_ARG, err, TAG, "out pointer must not be null"); +- ESP_GOTO_ON_FALSE((address & ~KSZ8851_VALID_ADDRESS_MASK) == 0U, ESP_ERR_INVALID_ARG, err, TAG, "address is out of bounds"); + ESP_GOTO_ON_FALSE((reg_addr & ~KSZ8851_VALID_ADDRESS_MASK) == 0U, ESP_ERR_INVALID_ARG, err, TAG, "address is out of bounds"); -+ -+ // NOTE(v.chistyakov): select upper or lower word inside a dword + +- const unsigned data_size = 16U; // NOTE(v.chistyakov): bits + // NOTE(v.chistyakov): select upper or lower word inside a dword +- const unsigned byte_mask = 0x3U << (KSZ8851_SPI_BYTE_MASK_SHIFT + (address & 0x2U)); +- address <<= KSZ8851_SPI_ADDR_SHIFT; + const unsigned byte_mask = 0x3U << (KSZ8851_SPI_BYTE_MASK_SHIFT + (reg_addr & 0x2U)); + reg_addr <<= KSZ8851_SPI_ADDR_SHIFT; -+ + +- spi_transaction_ext_t trans = { +- .base.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY | SPI_TRANS_USE_RXDATA, +- .base.cmd = KSZ8851_SPI_COMMAND_READ_REG, +- .base.addr = address | byte_mask, +- .base.length = data_size, +- .command_bits = KSZ8851_SPI_COMMAND_BITS, +- .address_bits = 16 - KSZ8851_SPI_COMMAND_BITS, +- }; ++ // Need to protect SPI access at higher layer of the driver since once packet transmit/receive is started (`SDA Start DMA Access` bit is set), ++ // all registers access are disabled. if (ksz8851_mutex_lock(emac)) { - if (spi_device_polling_transmit(emac->spi_hdl, &trans.base) != ESP_OK) { - ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); @@ -696,6 +708,7 @@ index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f2 ret = ESP_ERR_TIMEOUT; } + ksz8851_mutex_unlock(emac); ++ ESP_LOGV(TAG, "reading reg 0x%02x == 0x%02x", reg_addr, *value); + err: return ret; @@ -708,13 +721,15 @@ index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f2 - ESP_GOTO_ON_FALSE((address & ~KSZ8851_VALID_ADDRESS_MASK) == 0U, ESP_ERR_INVALID_ARG, err, TAG, "address is out of bounds"); - ESP_LOGV(TAG, "writing reg 0x%02x = 0x%04x", address, value); + ESP_GOTO_ON_FALSE((reg_addr & ~KSZ8851_VALID_ADDRESS_MASK) == 0U, ESP_ERR_INVALID_ARG, err, TAG, "address is out of bounds"); -+ ESP_LOGV(TAG, "writing reg 0x%02x = 0x%04x", reg_addr, value); ++ ESP_LOGV(TAG, "writing reg 0x%02x = 0x%02x", reg_addr, value); - const unsigned data_size = 16U; // NOTE(v.chistyakov): bits // NOTE(v.chistyakov): select upper or lower word inside a dword - const unsigned byte_mask = 0x3U << (KSZ8851_SPI_BYTE_MASK_SHIFT + (address & 0x2U)); - address <<= KSZ8851_SPI_ADDR_SHIFT; -- ++ const unsigned byte_mask = 0x3U << (KSZ8851_SPI_BYTE_MASK_SHIFT + (reg_addr & 0x2U)); ++ reg_addr <<= KSZ8851_SPI_ADDR_SHIFT; + - spi_transaction_ext_t trans = { - .base.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY | SPI_TRANS_USE_TXDATA, - .base.cmd = KSZ8851_SPI_COMMAND_WRITE_REG, @@ -723,10 +738,10 @@ index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f2 - .command_bits = KSZ8851_SPI_COMMAND_BITS, - .address_bits = 16 - KSZ8851_SPI_COMMAND_BITS, - }; -+ const unsigned byte_mask = 0x3U << (KSZ8851_SPI_BYTE_MASK_SHIFT + (reg_addr & 0x2U)); -+ reg_addr <<= KSZ8851_SPI_ADDR_SHIFT; - +- - memcpy(trans.base.tx_data, &value, data_size >> 3U); ++ // Need to protect SPI access at higher layer of the driver since once packet transmit/receive is started (`SDA Start DMA Access` bit is set), ++ // all registers access are disabled. if (ksz8851_mutex_lock(emac)) { - if (spi_device_polling_transmit(emac->spi_hdl, &trans.base) != ESP_OK) { - ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); @@ -742,7 +757,15 @@ index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f2 err: return ret; } -@@ -333,24 +403,12 @@ static esp_err_t emac_ksz8851snl_transmit(esp_eth_mac_t *mac, uint8_t *buf, uint +@@ -313,6 +393,7 @@ static esp_err_t emac_ksz8851snl_transmit(esp_eth_mac_t *mac, uint8_t *buf, uint + ESP_LOGV(TAG, "transmitting frame of size %u", length); + esp_err_t ret = ESP_OK; + emac_ksz8851snl_t *emac = __containerof(mac, emac_ksz8851snl_t, parent); ++ // Lock SPI since once `SDA Start DMA Access` bit is set, all registers access are disabled. + if (!ksz8851_mutex_lock(emac)) { + return ESP_ERR_TIMEOUT; + } +@@ -333,24 +414,12 @@ static esp_err_t emac_ksz8851snl_transmit(esp_eth_mac_t *mac, uint8_t *buf, uint emac->tx_buffer[3] = (length >> 8U) & 0xFFU; memcpy(emac->tx_buffer + 4U, buf, length); @@ -768,7 +791,7 @@ index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f2 ESP_GOTO_ON_ERROR(ksz8851_clear_bits(emac, KSZ8851_RXQCR, RXQCR_SDA), err, TAG, "RXQCR write failed"); ESP_GOTO_ON_ERROR(ksz8851_write_reg(emac, KSZ8851_IER, ier), err, TAG, "IER write failed"); -@@ -438,23 +496,12 @@ static esp_err_t emac_ksz8851_receive(esp_eth_mac_t *mac, uint8_t *buf, uint32_t +@@ -438,23 +507,13 @@ static esp_err_t emac_ksz8851_receive(esp_eth_mac_t *mac, uint8_t *buf, uint32_t // NOTE(v.chistyakov): 4 dummy + 4 header + alignment const unsigned receive_size = 8U + ((byte_count + 3U) & ~0x3U); @@ -780,6 +803,7 @@ index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f2 - .command_bits = 2U, - .address_bits = 6U, - }; ++ // Lock SPI since once `SDA Start DMA Access` bit is set, all registers access are disabled. if (!ksz8851_mutex_lock(emac)) { return ESP_ERR_TIMEOUT; } @@ -793,7 +817,7 @@ index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f2 ESP_GOTO_ON_ERROR(ksz8851_clear_bits(emac, KSZ8851_RXQCR, RXQCR_SDA), err, TAG, "RXQCR write failed"); ksz8851_mutex_unlock(emac); // NOTE(v.chistyakov): skip 4 dummy, 4 header -@@ -728,7 +775,7 @@ static esp_err_t emac_ksz8851_del(esp_eth_mac_t *mac) +@@ -728,7 +787,7 @@ static esp_err_t emac_ksz8851_del(esp_eth_mac_t *mac) { emac_ksz8851snl_t *emac = __containerof(mac, emac_ksz8851snl_t, parent); vTaskDelete(emac->rx_task_hdl); @@ -802,7 +826,7 @@ index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f2 vSemaphoreDelete(emac->spi_lock); heap_caps_free(emac->rx_buffer); heap_caps_free(emac->tx_buffer); -@@ -748,10 +795,6 @@ esp_eth_mac_t *esp_eth_mac_new_ksz8851snl(const eth_ksz8851snl_config_t *ksz8851 +@@ -748,10 +807,6 @@ esp_eth_mac_t *esp_eth_mac_new_ksz8851snl(const eth_ksz8851snl_config_t *ksz8851 emac = calloc(1, sizeof(emac_ksz8851snl_t)); ESP_GOTO_ON_FALSE(emac, NULL, err, TAG, "no mem for MAC instance"); @@ -813,7 +837,7 @@ index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f2 emac->sw_reset_timeout_ms = mac_config->sw_reset_timeout_ms; emac->int_gpio_num = ksz8851snl_config->int_gpio_num; emac->parent.set_mediator = emac_ksz8851_set_mediator; -@@ -772,8 +815,6 @@ esp_eth_mac_t *esp_eth_mac_new_ksz8851snl(const eth_ksz8851snl_config_t *ksz8851 +@@ -772,8 +827,6 @@ esp_eth_mac_t *esp_eth_mac_new_ksz8851snl(const eth_ksz8851snl_config_t *ksz8851 emac->parent.enable_flow_ctrl = emac_ksz8851_enable_flow_ctrl; emac->parent.set_peer_pause_ability = emac_ksz8851_set_peer_pause_ability; emac->parent.del = emac_ksz8851_del; @@ -822,7 +846,7 @@ index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f2 emac->rx_buffer = NULL; emac->tx_buffer = NULL; emac->rx_buffer = heap_caps_malloc(KSZ8851_QMU_PACKET_LENGTH + KSZ8851_QMU_PACKET_PADDING, MALLOC_CAP_DMA); -@@ -781,6 +822,29 @@ esp_eth_mac_t *esp_eth_mac_new_ksz8851snl(const eth_ksz8851snl_config_t *ksz8851 +@@ -781,6 +834,29 @@ esp_eth_mac_t *esp_eth_mac_new_ksz8851snl(const eth_ksz8851snl_config_t *ksz8851 ESP_GOTO_ON_FALSE(emac->rx_buffer, NULL, err, TAG, "RX buffer allocation failed"); ESP_GOTO_ON_FALSE(emac->tx_buffer, NULL, err, TAG, "TX buffer allocation failed"); @@ -832,7 +856,7 @@ index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f2 + + if (ksz8851snl_config->custom_spi_driver.init != NULL && ksz8851snl_config->custom_spi_driver.deinit != NULL + && ksz8851snl_config->custom_spi_driver.read != NULL && ksz8851snl_config->custom_spi_driver.write != NULL) { -+ ESP_LOGD(TAG, "custom SPI Driver is used"); ++ ESP_LOGD(TAG, "Using user's custom SPI Driver"); + emac->spi.init = ksz8851snl_config->custom_spi_driver.init; + emac->spi.deinit = ksz8851snl_config->custom_spi_driver.deinit; + emac->spi.read = ksz8851snl_config->custom_spi_driver.read; @@ -840,11 +864,11 @@ index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f2 + /* Custom SPI driver device init */ + ESP_GOTO_ON_FALSE((emac->spi.ctx = emac->spi.init(ksz8851snl_config->custom_spi_driver.config)) != NULL, NULL, err, TAG, "SPI initialization failed"); + } else { -+ ESP_LOGD(TAG, "internal SPI Master Driver is used"); -+ emac->spi.init = spi_init_std; -+ emac->spi.deinit = spi_deinit_std; -+ emac->spi.read = spi_read_std; -+ emac->spi.write = spi_write_std; ++ ESP_LOGD(TAG, "Using default SPI Driver"); ++ emac->spi.init = ksz8851_spi_init; ++ emac->spi.deinit = ksz8851_spi_deinit; ++ emac->spi.read = ksz8851_spi_read; ++ emac->spi.write = ksz8851_spi_write; + /* SPI device init */ + ESP_GOTO_ON_FALSE((emac->spi.ctx = emac->spi.init(ksz8851snl_config)) != NULL, NULL, err, TAG, "SPI initialization failed"); + } @@ -852,8 +876,18 @@ index b6aea4df90ead8dc2162e0735bdc310717881c97..9690a6364c6775ecb5941e8fdcad69f2 BaseType_t core_num = tskNO_AFFINITY; if (mac_config->flags & ETH_MAC_FLAG_PIN_TO_CORE) { core_num = esp_cpu_get_core_id(); +@@ -798,6 +874,9 @@ err: + if (emac->spi_lock) { + vSemaphoreDelete(emac->spi_lock); + } ++ if (emac->spi.ctx) { ++ emac->spi.deinit(emac->spi.ctx); ++ } + // NOTE(v.chistyakov): safe to call with NULL + heap_caps_free(emac->rx_buffer); + heap_caps_free(emac->tx_buffer); diff --git a/components/esp_eth/src/esp_eth_mac_w5500.c b/components/esp_eth/src/esp_eth_mac_w5500.c -index 7a7708d0ca8bbbf77b32d9cb01ce34e57cc1f242..1d5bdc19f6749cd8b02112d7a31f3538b2903f98 100644 +index 7a7708d0ca8bbbf77b32d9cb01ce34e57cc1f242..5b19d5cfcdfc67105809cbca33e780850b9d4fea 100644 --- a/components/esp_eth/src/esp_eth_mac_w5500.c +++ b/components/esp_eth/src/esp_eth_mac_w5500.c @@ -37,11 +37,23 @@ typedef struct { @@ -882,13 +916,14 @@ index 7a7708d0ca8bbbf77b32d9cb01ce34e57cc1f242..1d5bdc19f6749cd8b02112d7a31f3538 TaskHandle_t rx_task_hdl; uint32_t sw_reset_timeout_ms; int int_gpio_num; -@@ -50,55 +62,101 @@ typedef struct { +@@ -50,64 +62,132 @@ typedef struct { uint8_t *rx_buffer; } emac_w5500_t; -static inline bool w5500_lock(emac_w5500_t *emac) -+static void *spi_init_std(const void *spi_config) -+{ ++static void *w5500_spi_init(const void *spi_config) + { +- return xSemaphoreTake(emac->spi_lock, pdMS_TO_TICKS(W5500_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; + void *ret = NULL; + eth_w5500_config_t *w5500_config = (eth_w5500_config_t *)spi_config; + spi_info_t *spi = calloc(1, sizeof(spi_info_t)); @@ -896,13 +931,13 @@ index 7a7708d0ca8bbbf77b32d9cb01ce34e57cc1f242..1d5bdc19f6749cd8b02112d7a31f3538 + + /* SPI device init */ + spi_device_interface_config_t spi_devcfg; -+ memcpy(&spi_devcfg, w5500_config->spi_devcfg, sizeof(spi_device_interface_config_t)); ++ spi_devcfg = *(w5500_config->spi_devcfg); + if (w5500_config->spi_devcfg->command_bits == 0 && w5500_config->spi_devcfg->address_bits == 0) { + /* configure default SPI frame format */ + spi_devcfg.command_bits = 16; // Actually it's the address phase in W5500 SPI frame + spi_devcfg.address_bits = 8; // Actually it's the control phase in W5500 SPI frame + } else { -+ ESP_GOTO_ON_FALSE(w5500_config->spi_devcfg->command_bits == 16 || w5500_config->spi_devcfg->address_bits == 8, ++ ESP_GOTO_ON_FALSE(w5500_config->spi_devcfg->command_bits == 16 && w5500_config->spi_devcfg->address_bits == 8, + NULL, err, TAG, "incorrect SPI frame format (command_bits/address_bits)"); + } + ESP_GOTO_ON_FALSE(spi_bus_add_device(w5500_config->spi_host_id, &spi_devcfg, &spi->hdl) == ESP_OK, NULL, @@ -911,16 +946,22 @@ index 7a7708d0ca8bbbf77b32d9cb01ce34e57cc1f242..1d5bdc19f6749cd8b02112d7a31f3538 + spi->lock = xSemaphoreCreateMutex(); + ESP_GOTO_ON_FALSE(spi->lock, NULL, err, TAG, "create lock failed"); + -+ return spi; ++ ret = spi; ++ return ret; +err: -+ if (spi->lock) { -+ vSemaphoreDelete(spi->lock); ++ if (spi) { ++ if (spi->lock) { ++ vSemaphoreDelete(spi->lock); ++ } ++ free(spi); + } + return ret; -+} -+ -+static esp_err_t spi_deinit_std(void *spi_ctx) -+{ + } + +-static inline bool w5500_unlock(emac_w5500_t *emac) ++static esp_err_t w5500_spi_deinit(void *spi_ctx) + { +- return xSemaphoreGive(emac->spi_lock) == pdTRUE; + esp_err_t ret = ESP_OK; + spi_info_t *spi = (spi_info_t *)spi_ctx; + @@ -929,23 +970,20 @@ index 7a7708d0ca8bbbf77b32d9cb01ce34e57cc1f242..1d5bdc19f6749cd8b02112d7a31f3538 + + free(spi); + return ret; -+} -+ -+static inline bool w5500_lock(spi_info_t *spi) - { -- return xSemaphoreTake(emac->spi_lock, pdMS_TO_TICKS(W5500_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; -+ return xSemaphoreTake(spi->lock, pdMS_TO_TICKS(W5500_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; - } - --static inline bool w5500_unlock(emac_w5500_t *emac) -+static inline bool w5500_unlock(spi_info_t *spi) - { -- return xSemaphoreGive(emac->spi_lock) == pdTRUE; -+ return xSemaphoreGive(spi->lock) == pdTRUE; } -static esp_err_t w5500_write(emac_w5500_t *emac, uint32_t address, const void *value, uint32_t len) -+static esp_err_t spi_write_std(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *value, uint32_t len) ++static inline bool w5500_spi_lock(spi_info_t *spi) ++{ ++ return xSemaphoreTake(spi->lock, pdMS_TO_TICKS(W5500_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; ++} ++ ++static inline bool w5500_spi_unlock(spi_info_t *spi) ++{ ++ return xSemaphoreGive(spi->lock) == pdTRUE; ++} ++ ++static esp_err_t w5500_spi_write(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *value, uint32_t len) { esp_err_t ret = ESP_OK; + spi_info_t *spi = (spi_info_t *)spi_ctx; @@ -960,13 +998,13 @@ index 7a7708d0ca8bbbf77b32d9cb01ce34e57cc1f242..1d5bdc19f6749cd8b02112d7a31f3538 }; - if (w5500_lock(emac)) { - if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) { -+ if (w5500_lock(spi)) { ++ if (w5500_spi_lock(spi)) { + if (spi_device_polling_transmit(spi->hdl, &trans) != ESP_OK) { ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); ret = ESP_FAIL; } - w5500_unlock(emac); -+ w5500_unlock(spi); ++ w5500_spi_unlock(spi); } else { ret = ESP_ERR_TIMEOUT; } @@ -974,7 +1012,7 @@ index 7a7708d0ca8bbbf77b32d9cb01ce34e57cc1f242..1d5bdc19f6749cd8b02112d7a31f3538 } -static esp_err_t w5500_read(emac_w5500_t *emac, uint32_t address, void *value, uint32_t len) -+static esp_err_t spi_read_std(void *spi_ctx, uint32_t cmd, uint32_t addr, void *value, uint32_t len) ++static esp_err_t w5500_spi_read(void *spi_ctx, uint32_t cmd, uint32_t addr, void *value, uint32_t len) { esp_err_t ret = ESP_OK; + spi_info_t *spi = (spi_info_t *)spi_ctx; @@ -990,17 +1028,20 @@ index 7a7708d0ca8bbbf77b32d9cb01ce34e57cc1f242..1d5bdc19f6749cd8b02112d7a31f3538 }; - if (w5500_lock(emac)) { - if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) { -+ if (w5500_lock(spi)) { ++ if (w5500_spi_lock(spi)) { + if (spi_device_polling_transmit(spi->hdl, &trans) != ESP_OK) { ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); ret = ESP_FAIL; } - w5500_unlock(emac); -+ w5500_unlock(spi); ++ w5500_spi_unlock(spi); } else { ret = ESP_ERR_TIMEOUT; } -@@ -108,6 +166,24 @@ static esp_err_t w5500_read(emac_w5500_t *emac, uint32_t address, void *value, u +- if ((trans.flags&SPI_TRANS_USE_RXDATA) && len <= 4) { ++ if ((trans.flags & SPI_TRANS_USE_RXDATA) && len <= 4) { + memcpy(value, trans.rx_data, len); // copy register values to output + } return ret; } @@ -1025,7 +1066,7 @@ index 7a7708d0ca8bbbf77b32d9cb01ce34e57cc1f242..1d5bdc19f6749cd8b02112d7a31f3538 static esp_err_t w5500_send_command(emac_w5500_t *emac, uint8_t command, uint32_t timeout_ms) { esp_err_t ret = ESP_OK; -@@ -738,8 +814,7 @@ static esp_err_t emac_w5500_del(esp_eth_mac_t *mac) +@@ -738,8 +818,7 @@ static esp_err_t emac_w5500_del(esp_eth_mac_t *mac) { emac_w5500_t *emac = __containerof(mac, emac_w5500_t, parent); vTaskDelete(emac->rx_task_hdl); @@ -1035,7 +1076,7 @@ index 7a7708d0ca8bbbf77b32d9cb01ce34e57cc1f242..1d5bdc19f6749cd8b02112d7a31f3538 heap_caps_free(emac->rx_buffer); free(emac); return ESP_OK; -@@ -754,19 +829,6 @@ esp_eth_mac_t *esp_eth_mac_new_w5500(const eth_w5500_config_t *w5500_config, con +@@ -754,19 +833,6 @@ esp_eth_mac_t *esp_eth_mac_new_w5500(const eth_w5500_config_t *w5500_config, con ESP_GOTO_ON_FALSE(emac, NULL, err, TAG, "no mem for MAC instance"); /* w5500 driver is interrupt driven */ ESP_GOTO_ON_FALSE(w5500_config->int_gpio_num >= 0, NULL, err, TAG, "invalid interrupt gpio number"); @@ -1055,7 +1096,7 @@ index 7a7708d0ca8bbbf77b32d9cb01ce34e57cc1f242..1d5bdc19f6749cd8b02112d7a31f3538 /* bind methods and attributes */ emac->sw_reset_timeout_ms = mac_config->sw_reset_timeout_ms; emac->int_gpio_num = w5500_config->int_gpio_num; -@@ -788,9 +850,26 @@ esp_eth_mac_t *esp_eth_mac_new_w5500(const eth_w5500_config_t *w5500_config, con +@@ -788,9 +854,26 @@ esp_eth_mac_t *esp_eth_mac_new_w5500(const eth_w5500_config_t *w5500_config, con emac->parent.enable_flow_ctrl = emac_w5500_enable_flow_ctrl; emac->parent.transmit = emac_w5500_transmit; emac->parent.receive = emac_w5500_receive; @@ -1065,7 +1106,7 @@ index 7a7708d0ca8bbbf77b32d9cb01ce34e57cc1f242..1d5bdc19f6749cd8b02112d7a31f3538 + + if (w5500_config->custom_spi_driver.init != NULL && w5500_config->custom_spi_driver.deinit != NULL + && w5500_config->custom_spi_driver.read != NULL && w5500_config->custom_spi_driver.write != NULL) { -+ ESP_LOGD(TAG, "custom SPI Driver is used"); ++ ESP_LOGD(TAG, "Using user's custom SPI Driver"); + emac->spi.init = w5500_config->custom_spi_driver.init; + emac->spi.deinit = w5500_config->custom_spi_driver.deinit; + emac->spi.read = w5500_config->custom_spi_driver.read; @@ -1073,11 +1114,11 @@ index 7a7708d0ca8bbbf77b32d9cb01ce34e57cc1f242..1d5bdc19f6749cd8b02112d7a31f3538 + /* Custom SPI driver device init */ + ESP_GOTO_ON_FALSE((emac->spi.ctx = emac->spi.init(w5500_config->custom_spi_driver.config)) != NULL, NULL, err, TAG, "SPI initialization failed"); + } else { -+ ESP_LOGD(TAG, "internal SPI Master Driver is used"); -+ emac->spi.init = spi_init_std; -+ emac->spi.deinit = spi_deinit_std; -+ emac->spi.read = spi_read_std; -+ emac->spi.write = spi_write_std; ++ ESP_LOGD(TAG, "Using default SPI Driver"); ++ emac->spi.init = w5500_spi_init; ++ emac->spi.deinit = w5500_spi_deinit; ++ emac->spi.read = w5500_spi_read; ++ emac->spi.write = w5500_spi_write; + /* SPI device init */ + ESP_GOTO_ON_FALSE((emac->spi.ctx = emac->spi.init(w5500_config)) != NULL, NULL, err, TAG, "SPI initialization failed"); + } @@ -1085,19 +1126,14 @@ index 7a7708d0ca8bbbf77b32d9cb01ce34e57cc1f242..1d5bdc19f6749cd8b02112d7a31f3538 /* create w5500 task */ BaseType_t core_num = tskNO_AFFINITY; if (mac_config->flags & ETH_MAC_FLAG_PIN_TO_CORE) { -@@ -806,13 +885,11 @@ esp_eth_mac_t *esp_eth_mac_new_w5500(const eth_w5500_config_t *w5500_config, con - return &(emac->parent); - - err: -+ // TODO SPI deinit? - if (emac) { +@@ -810,8 +893,8 @@ err: if (emac->rx_task_hdl) { vTaskDelete(emac->rx_task_hdl); } - if (emac->spi_lock) { - vSemaphoreDelete(emac->spi_lock); -- } ++ if (emac->spi.ctx) { ++ emac->spi.deinit(emac->spi.ctx); + } heap_caps_free(emac->rx_buffer); free(emac); - } - From 67c5ddcbcef2bcf9394a25ba9f2eb00ce686eb58 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 26 Sep 2023 12:54:28 +0200 Subject: [PATCH 021/211] Update archive-build.sh --- tools/archive-build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index c5b0d4459..3ee5a4334 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -18,6 +18,7 @@ rm -rf arduino-esp32/docs rm -rf arduino-esp32/tests rm -rf arduino-esp32/libraries/RainMaker rm -rf arduino-esp32/libraries/Insights +rm -rf arduino-esp32/libraries/SPIFFS rm -rf arduino-esp32/libraries/BLE rm -rf arduino-esp32/libraries/SimpleBLE rm -rf arduino-esp32/libraries/WiFiProv From bc6ff687f01e2e87e1b20b9450d14c35acaf6ade Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 3 Oct 2023 21:09:58 +0200 Subject: [PATCH 022/211] Update config.sh --- tools/config.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/config.sh b/tools/config.sh index baf75167b..7d95f8467 100755 --- a/tools/config.sh +++ b/tools/config.sh @@ -9,6 +9,11 @@ if [ -z $IDF_BRANCH ]; then IDF_BRANCH="release/v5.1" fi +# Arduino branch to use +if [ -z $AR_BRANCH ]; then + AR_BRANCH="feature/eth_spi" +fi + if [ -z $AR_PR_TARGET_BRANCH ]; then # Temporary to get CI working. original is master AR_PR_TARGET_BRANCH="esp-idf-v5.1-libs" @@ -28,11 +33,6 @@ fi # Owner of the target ESP32 Arduino repository AR_USER="tasmota" -# Arduino branch to use -if [ -z $AR_BRANCH ]; then - AR_BRANCH="feature/eth_spi" -fi - # IDF commit to use #IDF_COMMIT="cf913a00e34d61adeee0dc52414a9e10c9b3737e" From 6ed69e1a68d6f17220cd3c647636e289be416fe1 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 5 Oct 2023 14:24:10 +0200 Subject: [PATCH 023/211] LittleFS v.1.10.0 --- tools/update-components.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/update-components.sh b/tools/update-components.sh index 6e490e1d5..9e28557da 100755 --- a/tools/update-components.sh +++ b/tools/update-components.sh @@ -24,17 +24,17 @@ if [ $? -ne 0 ]; then exit 1; fi cp "$AR_COMPS/esp32-camera/driver/private_include/cam_hal.h" "$AR_COMPS/esp32-camera/driver/include/" # -# CLONE/UPDATE ESP-LITTLEFS v1.5.5 commit 9eeac09... +# CLONE/UPDATE ESP-LITTLEFS v1.10.0 commit 032f9eb2... # echo "Updating ESP-LITTLEFS..." if [ ! -d "$AR_COMPS/esp_littlefs" ]; then git clone $LITTLEFS_REPO_URL "$AR_COMPS/esp_littlefs" - git -C "$AR_COMPS/esp_littlefs" checkout 9eeac09c9c250643a32df47ea870dae2dd042648 + git -C "$AR_COMPS/esp_littlefs" checkout 032f9eb2e291e7c4df63c3e6a3cb3bc766ded495 git -C "$AR_COMPS/esp_littlefs" submodule update --init --recursive else git -C "$AR_COMPS/esp_littlefs" fetch git -C "$AR_COMPS/esp_littlefs" pull --ff-only - git -C "$AR_COMPS/esp_littlefs" checkout 9eeac09c9c250643a32df47ea870dae2dd042648 + git -C "$AR_COMPS/esp_littlefs" checkout 032f9eb2e291e7c4df63c3e6a3cb3bc766ded495 git -C "$AR_COMPS/esp_littlefs" submodule update --init --recursive fi if [ $? -ne 0 ]; then exit 1; fi From 4de08487f5ea425ce976b3264bd5df1186fcd3e1 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 5 Oct 2023 14:33:12 +0200 Subject: [PATCH 024/211] add LittleFS settings --- configs/defconfig.common | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index 9fb552d55..66665292e 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -140,14 +140,13 @@ CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=4096 CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096 CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=0 -CONFIG_SPIFFS_MAX_PARTITIONS=1 -# CONFIG_SPIFFS_PAGE_CHECK is not set -# CONFIG_SPIFFS_USE_MAGIC is not set -# CONFIG_SPIFFS_USE_MTIME is not set CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=1 -CONFIG_LITTLEFS_MAX_PARTITIONS=2 CONFIG_DSP_MAX_FFT_SIZE_1024=y +CONFIG_LITTLEFS_MAX_PARTITIONS=2 +CONFIG_LITTLEFS_MULTIVERSION=y +CONFIG_LITTLEFS_DISK_VERSION_2_0=y + # # Disable Cameras not used # From 1ba87b70d683b89823253732ae7749ac1d1a4df8 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 5 Oct 2023 17:51:36 +0200 Subject: [PATCH 025/211] Arduino 3.0 is now `main` --- tools/config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/config.sh b/tools/config.sh index 7d95f8467..894d25ec6 100755 --- a/tools/config.sh +++ b/tools/config.sh @@ -11,7 +11,7 @@ fi # Arduino branch to use if [ -z $AR_BRANCH ]; then - AR_BRANCH="feature/eth_spi" + AR_BRANCH="main" fi if [ -z $AR_PR_TARGET_BRANCH ]; then From cdde63939c2b728401b9ed823db4c3e517f12a78 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 9 Oct 2023 11:00:51 +0200 Subject: [PATCH 026/211] rm TFLiteMicro --- tools/archive-build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index 3ee5a4334..83516e706 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -22,6 +22,7 @@ rm -rf arduino-esp32/libraries/SPIFFS rm -rf arduino-esp32/libraries/BLE rm -rf arduino-esp32/libraries/SimpleBLE rm -rf arduino-esp32/libraries/WiFiProv +rm -rf arduino-esp32/libraries/TFLiteMicro rm -rf arduino-esp32/libraries/ESP32 rm -rf arduino-esp32/package rm -rf arduino-esp32/tools/esp32-arduino-libs From 113d15a2074388019445322d14ff9e201853d9de Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 9 Oct 2023 11:02:05 +0200 Subject: [PATCH 027/211] rm TFLiteMicro --- tools/install-arduino.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index 18254011e..61c030b82 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -56,6 +56,7 @@ rm -rf "$AR_COMPS/arduino/libraries/BLE" rm -rf "$AR_COMPS/arduino/libraries/SimpleBLE" rm -rf "$AR_COMPS/arduino/libraries/WiFiProv" rm -rf "$AR_COMPS/arduino/libraries/ESP32" +rm -rf "$AR_COMPS/arduino/libraries/TFLiteMicro" # # CLONE/UPDATE ESP32-ARDUINO-LIBS From 08aebb3c805abe00509edaceaac2ec9ff837075c Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 9 Oct 2023 17:22:44 +0200 Subject: [PATCH 028/211] rm sr left overs --- build.sh | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/build.sh b/build.sh index b61b3743b..fa8484bcd 100755 --- a/build.sh +++ b/build.sh @@ -107,10 +107,6 @@ else source ./tools/config.sh fi -if [ -f "./managed_components/espressif__esp-sr/.component_hash" ]; then - rm -rf ./managed_components/espressif__esp-sr/.component_hash -fi - if [ "$BUILD_TYPE" != "all" ]; then if [ "$TARGET" = "all" ]; then echo "ERROR: You need to specify target for non-default builds" @@ -161,6 +157,7 @@ IDF_Commit_short=$(git -C "$IDF_PATH" rev-parse --short HEAD || echo "") AR_Commit_short=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "") echo "Framework built from $IDF_REPO branch $IDF_BRANCH commit $IDF_Commit_short and $AR_REPO branch $AR_BRANCH commit $AR_Commit_short" >> release-info.txt + #targets_count=`jq -c '.targets[] | length' configs/builds.json` for target_json in `jq -c '.targets[]' configs/builds.json`; do target=$(echo "$target_json" | jq -c '.target' | tr -d '"') @@ -184,10 +181,6 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do idf_libs_configs="$idf_libs_configs;configs/defconfig.$defconf" done - if [ -f "./managed_components/espressif__esp-sr/.component_hash" ]; then - rm -rf ./managed_components/espressif__esp-sr/.component_hash - fi - echo "* Build IDF-Libs: $idf_libs_configs" rm -rf build sdkconfig idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$idf_libs_configs" idf_libs @@ -200,10 +193,6 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do bootloader_configs="$bootloader_configs;configs/defconfig.$defconf"; done - if [ -f "./managed_components/espressif__esp-sr/.component_hash" ]; then - rm -rf ./managed_components/espressif__esp-sr/.component_hash - fi - echo "* Build BootLoader: $bootloader_configs" rm -rf build sdkconfig idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$bootloader_configs" copy_bootloader @@ -217,10 +206,6 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do mem_configs="$mem_configs;configs/defconfig.$defconf"; done - if [ -f "./managed_components/espressif__esp-sr/.component_hash" ]; then - rm -rf ./managed_components/espressif__esp-sr/.component_hash - fi - echo "* Build Memory Variant: $mem_configs" rm -rf build sdkconfig idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$mem_configs" mem_variant From 935abac8c0bf3e3862a8b8fe4b9a828918753334 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 9 Oct 2023 18:09:51 +0200 Subject: [PATCH 029/211] Delete configs/defconfig.esp_sr --- configs/defconfig.esp_sr | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 configs/defconfig.esp_sr diff --git a/configs/defconfig.esp_sr b/configs/defconfig.esp_sr deleted file mode 100644 index 03b7c462e..000000000 --- a/configs/defconfig.esp_sr +++ /dev/null @@ -1,37 +0,0 @@ -CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y -CONFIG_PARTITION_TABLE_CUSTOM=y -CONFIG_SR_WN_WN9_HIESP=y -CONFIG_SR_MN_CN_NONE=y -CONFIG_SR_MN_EN_MULTINET5_SINGLE_RECOGNITION_QUANT8=y -CONFIG_EN_SPEECH_COMMAND_ID0="" -CONFIG_EN_SPEECH_COMMAND_ID1="" -CONFIG_EN_SPEECH_COMMAND_ID2="" -CONFIG_EN_SPEECH_COMMAND_ID3="" -CONFIG_EN_SPEECH_COMMAND_ID4="" -CONFIG_EN_SPEECH_COMMAND_ID5="" -CONFIG_EN_SPEECH_COMMAND_ID6="" -CONFIG_EN_SPEECH_COMMAND_ID7="" -CONFIG_EN_SPEECH_COMMAND_ID8="" -CONFIG_EN_SPEECH_COMMAND_ID9="" -CONFIG_EN_SPEECH_COMMAND_ID10="" -CONFIG_EN_SPEECH_COMMAND_ID11="" -CONFIG_EN_SPEECH_COMMAND_ID12="" -CONFIG_EN_SPEECH_COMMAND_ID13="" -CONFIG_EN_SPEECH_COMMAND_ID14="" -CONFIG_EN_SPEECH_COMMAND_ID15="" -CONFIG_EN_SPEECH_COMMAND_ID16="" -CONFIG_EN_SPEECH_COMMAND_ID17="" -CONFIG_EN_SPEECH_COMMAND_ID18="" -CONFIG_EN_SPEECH_COMMAND_ID19="" -CONFIG_EN_SPEECH_COMMAND_ID20="" -CONFIG_EN_SPEECH_COMMAND_ID21="" -CONFIG_EN_SPEECH_COMMAND_ID22="" -CONFIG_EN_SPEECH_COMMAND_ID23="" -CONFIG_EN_SPEECH_COMMAND_ID24="" -CONFIG_EN_SPEECH_COMMAND_ID25="" -CONFIG_EN_SPEECH_COMMAND_ID26="" -CONFIG_EN_SPEECH_COMMAND_ID27="" -CONFIG_EN_SPEECH_COMMAND_ID28="" -CONFIG_EN_SPEECH_COMMAND_ID29="" -CONFIG_EN_SPEECH_COMMAND_ID30="" -CONFIG_EN_SPEECH_COMMAND_ID31="" From 473264d1ccc0a7745137f2d3a3729315a52e1c21 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:27:11 +0200 Subject: [PATCH 030/211] # CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT is not set --- configs/defconfig.common | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/defconfig.common b/configs/defconfig.common index 66665292e..ad6bc75b6 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -96,6 +96,8 @@ CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN=n CONFIG_MBEDTLS_PSK_MODES=n +# CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT is not set + # CONFIG_MBEDTLS_HARDWARE_AES is not set # CONFIG_MBEDTLS_HARDWARE_MPI is not set # CONFIG_MBEDTLS_HARDWARE_SHA is not set From ab29fee7482acc5184def094130e03fa32277b2e Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 11 Oct 2023 16:35:38 +0200 Subject: [PATCH 031/211] reduce footprint --- configs/defconfig.common | 67 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 6 deletions(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index ad6bc75b6..c97349109 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -88,26 +88,82 @@ CONFIG_LWIP_TCP_RECVMBOX_SIZE=16 CONFIG_LWIP_UDP_RECVMBOX_SIZE=64 CONFIG_NEWLIB_NANO_FORMAT=y -# CONFIG_ESP_WIFI_MBEDTLS_CRYPTO is not set +# CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT is not set + # CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA is not set CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=0 +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y +# CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT is not set CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN=n -CONFIG_MBEDTLS_PSK_MODES=n +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=100 -# CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT is not set +# CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE is not set +# CONFIG_MBEDTLS_PKCS7_C is not set + +# +# Symmetric Ciphers +# +# CONFIG_MBEDTLS_AES_C is not set +# CONFIG_MBEDTLS_CAMELLIA_C is not set +# CONFIG_MBEDTLS_DES_C is not set +# CONFIG_MBEDTLS_BLOWFISH_C is not set +# CONFIG_MBEDTLS_XTEA_C is not set +# CONFIG_MBEDTLS_CCM_C is not set +# CONFIG_MBEDTLS_GCM_C is not set +# CONFIG_MBEDTLS_NIST_KW_C is not set +# end of Symmetric Ciphers + +# CONFIG_MBEDTLS_RIPEMD160_C is not set + +# +# TLS Key Exchange Methods +# +CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y +# CONFIG_MBEDTLS_PSK_MODES is not set +# CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE is not set +# CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA is not set +# CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA is not set +# CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA is not set +# CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA is not set +# CONFIG_MBEDTLS_SSL_RENEGOTIATION is not set +# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set +# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set +# CONFIG_MBEDTLS_SSL_ALPN is not set +# CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS is not set + +# CONFIG_MBEDTLS_CMAC_C is not set +# CONFIG_MBEDTLS_HARDWARE_ECC is not set +# CONFIG_MBEDTLS_ECC_OTHER_CURVES_SOFT_FALLBACK is not set # CONFIG_MBEDTLS_HARDWARE_AES is not set # CONFIG_MBEDTLS_HARDWARE_MPI is not set # CONFIG_MBEDTLS_HARDWARE_SHA is not set # CONFIG_MBEDTLS_HAVE_TIME is not set +# CONFIG_MBEDTLS_ECDSA_DETERMINISTIC is not set +# CONFIG_MBEDTLS_SHA512_C is not set + +# +# Certificates +# +# CONFIG_MBEDTLS_PEM_PARSE_C is not set +# CONFIG_MBEDTLS_PEM_WRITE_C is not set +# CONFIG_MBEDTLS_X509_CRL_PARSE_C is not set +# CONFIG_MBEDTLS_X509_CSR_PARSE_C is not set +# end of Certificates + +# CONFIG_MBEDTLS_ECP_C is not set +# CONFIG_MBEDTLS_DHM_C is not set +# CONFIG_MBEDTLS_ECDH_C is not set +# CONFIG_MBEDTLS_ECDSA_C is not set +# CONFIG_MBEDTLS_ECJPAKE_C is not set # CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS is not set # CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS is not set # CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED is not set # CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED is not set # CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED is not set +# CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED is not set # CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED is not set # CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED is not set # CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED is not set @@ -116,7 +172,7 @@ CONFIG_MBEDTLS_PSK_MODES=n # CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED is not set # CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED is not set # CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED is not set - +# CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM is not set # CONFIG_MBEDTLS_ECP_NIST_OPTIM is not set # CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set @@ -163,4 +219,3 @@ CONFIG_LITTLEFS_DISK_VERSION_2_0=y # CONFIG_BF3005_SUPPORT is not set # CONFIG_BF20A6_SUPPORT is not set # CONFIG_SC030IOT_SUPPORT is not set - From 1569629d25ac57408ef6d6fe31a9a54b71dc3705 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 12 Oct 2023 20:36:20 +0200 Subject: [PATCH 032/211] rm -rf arduino-esp32/libraries/WiFiClientSecure --- tools/archive-build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index 83516e706..c20a14575 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -22,6 +22,7 @@ rm -rf arduino-esp32/libraries/SPIFFS rm -rf arduino-esp32/libraries/BLE rm -rf arduino-esp32/libraries/SimpleBLE rm -rf arduino-esp32/libraries/WiFiProv +rm -rf arduino-esp32/libraries/WiFiClientSecure rm -rf arduino-esp32/libraries/TFLiteMicro rm -rf arduino-esp32/libraries/ESP32 rm -rf arduino-esp32/package From 472fab79109d43f6ccb73ee4fa1f51ab8cf1827d Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 12 Oct 2023 20:42:29 +0200 Subject: [PATCH 033/211] Update install-arduino.sh --- tools/install-arduino.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index 61c030b82..bb8dafb94 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -55,6 +55,7 @@ rm -rf "$AR_COMPS/arduino/libraries/Insights" rm -rf "$AR_COMPS/arduino/libraries/BLE" rm -rf "$AR_COMPS/arduino/libraries/SimpleBLE" rm -rf "$AR_COMPS/arduino/libraries/WiFiProv" +rm -rf "$AR_COMPS/arduino/libraries/WiFiClientSecure" rm -rf "$AR_COMPS/arduino/libraries/ESP32" rm -rf "$AR_COMPS/arduino/libraries/TFLiteMicro" From 769a8d9fd601bc45612bf046497a7200838c50cf Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 12 Oct 2023 21:37:54 +0200 Subject: [PATCH 034/211] clean up --- configs/defconfig.common | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index c97349109..e919ac673 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -88,15 +88,18 @@ CONFIG_LWIP_TCP_RECVMBOX_SIZE=16 CONFIG_LWIP_UDP_RECVMBOX_SIZE=64 CONFIG_NEWLIB_NANO_FORMAT=y +# CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT is not set # CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT is not set - +# CONFIG_ESP_WIFI_SOFTAP_SAE_SUPPORT is not set # CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA is not set CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=0 +# CONFIG_ESP_WIFI_MBEDTLS_CRYPTO is not set +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y -# CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT is not set +CONFIG_MBEDTLS_TLS_DISABLED=y CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=100 +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=10 # CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE is not set # CONFIG_MBEDTLS_PKCS7_C is not set @@ -104,7 +107,7 @@ CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=100 # # Symmetric Ciphers # -# CONFIG_MBEDTLS_AES_C is not set +CONFIG_MBEDTLS_AES_C=y # CONFIG_MBEDTLS_CAMELLIA_C is not set # CONFIG_MBEDTLS_DES_C is not set # CONFIG_MBEDTLS_BLOWFISH_C is not set @@ -114,11 +117,11 @@ CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=100 # CONFIG_MBEDTLS_NIST_KW_C is not set # end of Symmetric Ciphers -# CONFIG_MBEDTLS_RIPEMD160_C is not set # # TLS Key Exchange Methods # + CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y # CONFIG_MBEDTLS_PSK_MODES is not set # CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE is not set @@ -127,13 +130,14 @@ CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y # CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA is not set # CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA is not set +CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y # CONFIG_MBEDTLS_SSL_RENEGOTIATION is not set # CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set # CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set # CONFIG_MBEDTLS_SSL_ALPN is not set # CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS is not set -# CONFIG_MBEDTLS_CMAC_C is not set +CONFIG_MBEDTLS_CMAC_C=y # CONFIG_MBEDTLS_HARDWARE_ECC is not set # CONFIG_MBEDTLS_ECC_OTHER_CURVES_SOFT_FALLBACK is not set # CONFIG_MBEDTLS_HARDWARE_AES is not set @@ -142,6 +146,7 @@ CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y # CONFIG_MBEDTLS_HAVE_TIME is not set # CONFIG_MBEDTLS_ECDSA_DETERMINISTIC is not set # CONFIG_MBEDTLS_SHA512_C is not set +# CONFIG_MBEDTLS_RIPEMD160_C is not set # # Certificates @@ -152,17 +157,16 @@ CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y # CONFIG_MBEDTLS_X509_CSR_PARSE_C is not set # end of Certificates -# CONFIG_MBEDTLS_ECP_C is not set +CONFIG_MBEDTLS_ECP_C=y +CONFIG_MBEDTLS_ECDH_C=y +CONFIG_MBEDTLS_ECDSA_C=y +CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y # CONFIG_MBEDTLS_DHM_C is not set -# CONFIG_MBEDTLS_ECDH_C is not set -# CONFIG_MBEDTLS_ECDSA_C is not set # CONFIG_MBEDTLS_ECJPAKE_C is not set - # CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS is not set # CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS is not set # CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED is not set # CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED is not set -# CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED is not set # CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED is not set # CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED is not set # CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED is not set @@ -173,11 +177,9 @@ CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y # CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED is not set # CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED is not set # CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM is not set - # CONFIG_MBEDTLS_ECP_NIST_OPTIM is not set # CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set # CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set -# CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN is not set CONFIG_OPENSSL_ASSERT_DO_NOTHING=y CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=2048 From a24bd2b749df7e0701a945635a26b8b8d1c7a4e7 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 13 Oct 2023 13:17:17 +0200 Subject: [PATCH 035/211] use Hardware mbedtls --- configs/defconfig.common | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index e919ac673..88581f1c9 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -138,11 +138,12 @@ CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y # CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS is not set CONFIG_MBEDTLS_CMAC_C=y -# CONFIG_MBEDTLS_HARDWARE_ECC is not set +CONFIG_MBEDTLS_ROM_MD5=y +CONFIG_MBEDTLS_HARDWARE_ECC=y +CONFIG_MBEDTLS_HARDWARE_AES=y +CONFIG_MBEDTLS_HARDWARE_MPI=y +CONFIG_MBEDTLS_HARDWARE_SHA=y # CONFIG_MBEDTLS_ECC_OTHER_CURVES_SOFT_FALLBACK is not set -# CONFIG_MBEDTLS_HARDWARE_AES is not set -# CONFIG_MBEDTLS_HARDWARE_MPI is not set -# CONFIG_MBEDTLS_HARDWARE_SHA is not set # CONFIG_MBEDTLS_HAVE_TIME is not set # CONFIG_MBEDTLS_ECDSA_DETERMINISTIC is not set # CONFIG_MBEDTLS_SHA512_C is not set From 8f07a1ce2383318c2171ead420541ca08abe904c Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 18 Oct 2023 14:17:20 +0200 Subject: [PATCH 036/211] rm -rf arduino-esp32/libraries/ESP_I2S --- tools/archive-build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index c20a14575..60ed04732 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -18,6 +18,7 @@ rm -rf arduino-esp32/docs rm -rf arduino-esp32/tests rm -rf arduino-esp32/libraries/RainMaker rm -rf arduino-esp32/libraries/Insights +rm -rf arduino-esp32/libraries/ESP_I2S rm -rf arduino-esp32/libraries/SPIFFS rm -rf arduino-esp32/libraries/BLE rm -rf arduino-esp32/libraries/SimpleBLE From ef6636d875d8ecfa5c60aa93f097c16dbfeb494d Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 18 Oct 2023 14:20:28 +0200 Subject: [PATCH 037/211] rm -rf "$AR_COMPS/arduino/libraries/ESP_I2S --- tools/install-arduino.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index bb8dafb94..5730d14e8 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -52,6 +52,7 @@ if [ $? -ne 0 ]; then exit 1; fi # rm -rf "$AR_COMPS/arduino/libraries/RainMaker" rm -rf "$AR_COMPS/arduino/libraries/Insights" +rm -rf "$AR_COMPS/arduino/libraries/ESP_I2S rm -rf "$AR_COMPS/arduino/libraries/BLE" rm -rf "$AR_COMPS/arduino/libraries/SimpleBLE" rm -rf "$AR_COMPS/arduino/libraries/WiFiProv" From 0ddcd77d71c0fa25a22149a2a9a9003d841e3b98 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 18 Oct 2023 14:22:13 +0200 Subject: [PATCH 038/211] Update install-arduino.sh --- tools/install-arduino.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index 5730d14e8..f0da248be 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -52,7 +52,7 @@ if [ $? -ne 0 ]; then exit 1; fi # rm -rf "$AR_COMPS/arduino/libraries/RainMaker" rm -rf "$AR_COMPS/arduino/libraries/Insights" -rm -rf "$AR_COMPS/arduino/libraries/ESP_I2S +rm -rf "$AR_COMPS/arduino/libraries/ESP_I2S" rm -rf "$AR_COMPS/arduino/libraries/BLE" rm -rf "$AR_COMPS/arduino/libraries/SimpleBLE" rm -rf "$AR_COMPS/arduino/libraries/WiFiProv" From a9e99bceffe6d8006bfe806b7e37f15ea9b83ccb Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 24 Oct 2023 13:53:03 +0200 Subject: [PATCH 039/211] rm -rf "$AR_COMPS/arduino/libraries/ESP_SR" --- tools/install-arduino.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index f0da248be..e490916a9 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -58,6 +58,7 @@ rm -rf "$AR_COMPS/arduino/libraries/SimpleBLE" rm -rf "$AR_COMPS/arduino/libraries/WiFiProv" rm -rf "$AR_COMPS/arduino/libraries/WiFiClientSecure" rm -rf "$AR_COMPS/arduino/libraries/ESP32" +rm -rf "$AR_COMPS/arduino/libraries/ESP_SR" rm -rf "$AR_COMPS/arduino/libraries/TFLiteMicro" # From c79bc0ec3f169cf38e1e56ef2ab7510af67bbe9f Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 24 Oct 2023 13:55:55 +0200 Subject: [PATCH 040/211] rm -rf arduino-esp32/libraries/ESP_SR --- tools/archive-build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index 60ed04732..512e3964e 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -24,6 +24,7 @@ rm -rf arduino-esp32/libraries/BLE rm -rf arduino-esp32/libraries/SimpleBLE rm -rf arduino-esp32/libraries/WiFiProv rm -rf arduino-esp32/libraries/WiFiClientSecure +rm -rf arduino-esp32/libraries/ESP_SR rm -rf arduino-esp32/libraries/TFLiteMicro rm -rf arduino-esp32/libraries/ESP32 rm -rf arduino-esp32/package From 249bc36ddff9fe2407f14f21b9d438f5881e45c9 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 27 Oct 2023 18:47:47 +0200 Subject: [PATCH 041/211] rm examples --- tools/archive-build.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index 512e3964e..a7d116a74 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -13,7 +13,16 @@ mkdir -p dist && rm -rf "$archive_path" "$build_archive_path" cd out echo "Creating PlatformIO Tasmota framework-arduinoespressif32-solo1" -cp -rf ../components/arduino arduino-esp32 +mkdir -p arduino-esp32/cores/esp32 +mkdir -p arduino-esp32/tools/partitions +cp -rf ../components/arduino/tools arduino-esp32 +cp -rf ../components/arduino/cores arduino-esp32 +cp -rf ../components/arduino/libraries arduino-esp32 +cp -rf ../components/arduino/variants arduino-esp32 +cp -f ../components/arduino/CMa* arduino-esp32 +cp -f ../components/arduino/idf* arduino-esp32 +cp -f ../components/arduino/Kco* arduino-esp32 +cp -f ../components/arduino/pac* arduino-esp32 rm -rf arduino-esp32/docs rm -rf arduino-esp32/tests rm -rf arduino-esp32/libraries/RainMaker @@ -22,6 +31,7 @@ rm -rf arduino-esp32/libraries/ESP_I2S rm -rf arduino-esp32/libraries/SPIFFS rm -rf arduino-esp32/libraries/BLE rm -rf arduino-esp32/libraries/SimpleBLE +rm -rf arduino-esp32/libraries/BluetoothSerial rm -rf arduino-esp32/libraries/WiFiProv rm -rf arduino-esp32/libraries/WiFiClientSecure rm -rf arduino-esp32/libraries/ESP_SR @@ -47,6 +57,9 @@ cp ../core_version.h arduino-esp32/cores/esp32/core_version.h awk -i inplace -v cuv1="framework-arduinoespressif32" -v cuv2="framework-arduino-solo1" '{gsub(cuv1,cuv2); print;}' "arduino-esp32/tools/esp32-arduino-libs/esp32/platformio-build.py" awk -i inplace -v cuv1="framework-arduinoespressif32" -v cuv2="framework-arduino-solo1" '{gsub(cuv1,cuv2); print;}' "arduino-esp32/tools/platformio-build.py" mv arduino-esp32/ framework-arduinoespressif32/ +cd framework-arduinoespressif32/libraries +rm -rf **/examples +cd ../../ # If the framework is needed as tar.gz uncomment next line # tar --exclude=.* -zcf ../$pio_archive_path framework-arduinoespressif32/ 7z a -mx=9 -tzip -xr'!.*' ../$pio_zip_archive_path framework-arduinoespressif32/ From caff069fa2dd6b210b5137a50255b50d47c97408 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 10 Nov 2023 10:26:37 +0100 Subject: [PATCH 042/211] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5cdb4a45..88cede199 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ idf_build_get_property(elf EXECUTABLE GENERATOR_EXPRESSION) add_custom_command( OUTPUT "idf_libs" COMMAND ${CMAKE_SOURCE_DIR}/tools/copy-libs.sh ${IDF_TARGET} "${CONFIG_LIB_BUILDER_FLASHMODE}" "${CONFIG_SPIRAM_MODE_OCT}" "${CONFIG_IDF_TARGET_ARCH_XTENSA}" - DEPENDS all + DEPENDS ${elf} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} VERBATIM ) From a9810df01fb874dca9b87860e5fe3fe39e6c62b4 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 10 Nov 2023 10:34:15 +0100 Subject: [PATCH 043/211] Update idf_component.yml --- main/idf_component.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/main/idf_component.yml b/main/idf_component.yml index fb3137b46..da7132ddd 100644 --- a/main/idf_component.yml +++ b/main/idf_component.yml @@ -1,12 +1,11 @@ dependencies: # Required IDF version idf: ">=5.1" - - mdns: "^1.2.0" - #libsodium: "^1.0.20" - #chmorgan/esp-libhelix-mp3: "1.0.3" - #esp-dsp: "^1.3.4" - + espressif/esp32-camera: + version: "*" + git: https://github.com/espressif/esp32-camera.git + require: public + # esp-sr: "^1.3.1" # esp32-camera: "^2.0.4" # esp-dl: From 0b330c19ed28bfa4ff02f5ff71393dad9610af0e Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 10 Nov 2023 10:40:54 +0100 Subject: [PATCH 044/211] Update update-components.sh --- tools/update-components.sh | 44 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/tools/update-components.sh b/tools/update-components.sh index 9e28557da..954c87f48 100755 --- a/tools/update-components.sh +++ b/tools/update-components.sh @@ -9,14 +9,14 @@ TINYUSB_REPO_URL="https://github.com/hathach/tinyusb.git" # # CLONE/UPDATE ESP32-CAMERA # -echo "Updating ESP32 Camera..." -if [ ! -d "$AR_COMPS/esp32-camera" ]; then - 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 -fi -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" +#else +# git -C "$AR_COMPS/esp32-camera" fetch && \ +# git -C "$AR_COMPS/esp32-camera" pull --ff-only +#fi +#if [ $? -ne 0 ]; then exit 1; fi # # Arduino needs cam_hal.h from esp32-camera in include folder @@ -24,20 +24,20 @@ if [ $? -ne 0 ]; then exit 1; fi cp "$AR_COMPS/esp32-camera/driver/private_include/cam_hal.h" "$AR_COMPS/esp32-camera/driver/include/" # -# CLONE/UPDATE ESP-LITTLEFS v1.10.0 commit 032f9eb2... -# -echo "Updating ESP-LITTLEFS..." -if [ ! -d "$AR_COMPS/esp_littlefs" ]; then - git clone $LITTLEFS_REPO_URL "$AR_COMPS/esp_littlefs" - git -C "$AR_COMPS/esp_littlefs" checkout 032f9eb2e291e7c4df63c3e6a3cb3bc766ded495 - git -C "$AR_COMPS/esp_littlefs" submodule update --init --recursive -else - git -C "$AR_COMPS/esp_littlefs" fetch - git -C "$AR_COMPS/esp_littlefs" pull --ff-only - git -C "$AR_COMPS/esp_littlefs" checkout 032f9eb2e291e7c4df63c3e6a3cb3bc766ded495 - git -C "$AR_COMPS/esp_littlefs" submodule update --init --recursive -fi -if [ $? -ne 0 ]; then exit 1; fi +# CLONE/UPDATE ESP-LITTLEFS v1.10.0 commit 032f9... +# +#echo "Updating ESP-LITTLEFS..." +#if [ ! -d "$AR_COMPS/esp_littlefs" ]; then +# git clone $LITTLEFS_REPO_URL "$AR_COMPS/esp_littlefs" +# git -C "$AR_COMPS/esp_littlefs" checkout 032f9eb2e291e7c4df63c3e6a3cb3bc766ded495 +# git -C "$AR_COMPS/esp_littlefs" submodule update --init --recursive +#else +# git -C "$AR_COMPS/esp_littlefs" fetch +# git -C "$AR_COMPS/esp_littlefs" pull --ff-only +# git -C "$AR_COMPS/esp_littlefs" checkout 032f9eb2e291e7c4df63c3e6a3cb3bc766ded495 +# git -C "$AR_COMPS/esp_littlefs" submodule update --init --recursive +#fi +#if [ $? -ne 0 ]; then exit 1; fi # # CLONE/UPDATE TINYUSB From b72278892bd2b85ab3fa211f1aee7d3dfbd27006 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 11 Nov 2023 13:14:39 +0100 Subject: [PATCH 045/211] Update idf_component.yml --- main/idf_component.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/idf_component.yml b/main/idf_component.yml index da7132ddd..861798c19 100644 --- a/main/idf_component.yml +++ b/main/idf_component.yml @@ -2,7 +2,7 @@ dependencies: # Required IDF version idf: ">=5.1" espressif/esp32-camera: - version: "*" + version: "master" git: https://github.com/espressif/esp32-camera.git require: public From 735397eea5550543d6b8aff59f21ede9798f763c Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 18 Nov 2023 11:50:53 +0100 Subject: [PATCH 046/211] Update idf_component.yml --- main/idf_component.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main/idf_component.yml b/main/idf_component.yml index 861798c19..b119e44da 100644 --- a/main/idf_component.yml +++ b/main/idf_component.yml @@ -1,11 +1,11 @@ dependencies: # Required IDF version idf: ">=5.1" - espressif/esp32-camera: - version: "master" - git: https://github.com/espressif/esp32-camera.git - require: public - + + # espressif/esp32-camera: + # version: "master" + # git: https://github.com/espressif/esp32-camera.git + # require: public # esp-sr: "^1.3.1" # esp32-camera: "^2.0.4" # esp-dl: From 274551abeaa5be1a1f24ef345789b3d80f30fc18 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 18 Nov 2023 11:51:17 +0100 Subject: [PATCH 047/211] Update update-components.sh --- tools/update-components.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/update-components.sh b/tools/update-components.sh index 954c87f48..06e24d23a 100755 --- a/tools/update-components.sh +++ b/tools/update-components.sh @@ -9,14 +9,14 @@ TINYUSB_REPO_URL="https://github.com/hathach/tinyusb.git" # # CLONE/UPDATE ESP32-CAMERA # -#echo "Updating ESP32 Camera..." -#if [ ! -d "$AR_COMPS/esp32-camera" ]; then -# 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 -#fi -#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" +else + git -C "$AR_COMPS/esp32-camera" fetch && \ + git -C "$AR_COMPS/esp32-camera" pull --ff-only +fi +if [ $? -ne 0 ]; then exit 1; fi # # Arduino needs cam_hal.h from esp32-camera in include folder From 98d8dcf0c46cf4b74d94548501cd076e7f63e463 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 18 Nov 2023 17:32:29 +0100 Subject: [PATCH 048/211] Update defconfig.common --- configs/defconfig.common | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index 88581f1c9..b0792e933 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -11,7 +11,7 @@ CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_NONE=y CONFIG_I2S_SUPPRESS_DEPRECATE_WARN=y CONFIG_BT_ENABLED=y CONFIG_BT_STACK_NO_LOG=y -CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y +# CONFIG_BT_BLE_42_FEATURES_SUPPORTED is not set # CONFIG_BLE_MESH is not set CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_SIZE=y @@ -73,6 +73,8 @@ CONFIG_LWIP_IPV4_NAPT=y CONFIG_LWIP_TCP_SYNMAXRTX=6 CONFIG_LWIP_TCP_MSS=1436 CONFIG_LWIP_TCP_RTO_TIME=3000 +CONFIG_LWIP_TCP_MSL=6000 +CONFIG_LWIP_TCP_FIN_WAIT_TIMEOUT=2000 CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=2560 CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0=y CONFIG_LWIP_IPV6_AUTOCONFIG=y From 0b6a444af465142fbc68598a31425a94afbbf0ed Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 18 Nov 2023 17:39:34 +0100 Subject: [PATCH 049/211] No BT Stack size --- configs/defconfig.esp32 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configs/defconfig.esp32 b/configs/defconfig.esp32 index 486de7ffc..a059e5f9d 100644 --- a/configs/defconfig.esp32 +++ b/configs/defconfig.esp32 @@ -19,8 +19,8 @@ CONFIG_ETH_PHY_INTERFACE_RMII=y CONFIG_ETH_USE_SPI_ETHERNET=y # CONFIG_BTDM_CTRL_MODE_BTDM is not set -CONFIG_BT_BTC_TASK_STACK_SIZE=8192 -CONFIG_BT_BTU_TASK_STACK_SIZE=8192 +# CONFIG_BT_BTC_TASK_STACK_SIZE is not set +# CONFIG_BT_BTU_TASK_STACK_SIZE is not set CONFIG_BT_STACK_NO_LOG=y CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY=y CONFIG_SPIRAM=y From c200ba2b8c80486c2a54096f10e0b535d6b2393e Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 18 Nov 2023 17:41:51 +0100 Subject: [PATCH 050/211] # CONFIG_DAC_DMA_AUTO_16BIT_ALIGN is not set --- configs/defconfig.common | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/defconfig.common b/configs/defconfig.common index b0792e933..364d3e1d1 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -89,6 +89,7 @@ CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=48 CONFIG_LWIP_TCP_RECVMBOX_SIZE=16 CONFIG_LWIP_UDP_RECVMBOX_SIZE=64 CONFIG_NEWLIB_NANO_FORMAT=y +# CONFIG_DAC_DMA_AUTO_16BIT_ALIGN is not set # CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT is not set # CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT is not set From 079902df4904f3b3c61f20797ae6d48cb6e7750b Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 27 Nov 2023 16:55:45 +0100 Subject: [PATCH 051/211] Delete patches/nimble.diff --- patches/nimble.diff | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 patches/nimble.diff diff --git a/patches/nimble.diff b/patches/nimble.diff deleted file mode 100644 index 10803bb6c..000000000 --- a/patches/nimble.diff +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/components/bt/host/nimble/nimble/nimble/host/services/gap/include/services/gap/ble_svc_gap.h b/components/bt/host/nimble/nimble/nimble/host/services/gap/include/services/gap/ble_svc_gap.h -index a1f84f1d6..f748d6494 100644 ---- a/components/bt/host/nimble/nimble/nimble/host/services/gap/include/services/gap/ble_svc_gap.h -+++ b/components/bt/host/nimble/nimble/nimble/host/services/gap/include/services/gap/ble_svc_gap.h -@@ -20,6 +20,7 @@ - #ifndef H_BLE_SVC_GAP_ - #define H_BLE_SVC_GAP_ - -+#include "syscfg/syscfg.h" - #include - #if MYNEWT_VAL(ENC_ADV_DATA) - #include "host/ble_ead.h" - From 400535053192b43dd1ba3f5503d55df20cd9ec2d Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 27 Nov 2023 16:56:45 +0100 Subject: [PATCH 052/211] Update defconfig.common --- configs/defconfig.common | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index 364d3e1d1..6a7da076b 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -101,9 +101,8 @@ CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=0 CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y CONFIG_MBEDTLS_TLS_DISABLED=y -CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y +# CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN is not set CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=10 - # CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE is not set # CONFIG_MBEDTLS_PKCS7_C is not set From 4e539a1cc7156dbf47089718a94d6a9175f83ef6 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 27 Nov 2023 17:00:27 +0100 Subject: [PATCH 053/211] Update builder (#72) * SPI_ETHERNET * Update defconfig.esp32 * AR branch "feature/eth_spi" * Update push.yml * Create spi_eth.diff * Add temporary support for Arduino SPI Ethernet * Enable all SPI ETH PHY * Update push.yml * Create nimble.diff * Patch nimble to support h2zero `esp-nimble-cpp` * Update nimble.diff * freeze IDF to commit 707b703... * Update config.sh * Update build.sh * add repo owner in release-info.txt * Add a temporary fix for relative include in BT lib * use latest IDF 5.1 * Update spi_eth.diff * rm Nimble patch * Delete patches/nimble.diff * Update install-esp-idf.sh * ESP-LITTLEFS v1.9.0 * LittleFS v1.9.0 * esp_littlefs branch lfs2.8 * Update push.yml * Update archive-build.sh * rm SPIFFS / set LittleFS disk 2.0 * C6: use newlib from ROM * ESP-LITTLEFS v1.10.0 * Update config.sh * Arduino 3.0 is now `main` * rm TFLiteMicro * rm TFLiteMicro * Update gen_platformio_manifest.py * rm sr left overs * Update push.yml * CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y * CONFIG_MBEDTLS_CMAC_C=y * CONFIG_SOC_WIFI_GCMP_SUPPORT=y * # CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT is not set * Update defconfig.common * reduce footprint * use v5.1.1.231006 * Update config.sh * Update config.sh * main_old * Update push.yml * Update defconfig.common * Update config.sh * rm -rf arduino-esp32/libraries/WiFiClientSecure * rm -rf "$AR_COMPS/arduino/libraries/WiFiClientSecure" * clean up * Use Hardware mbedtls * rm -rf arduino-esp32/libraries/ESP_I2S * rm -rf "$AR_COMPS/arduino/libraries/ESP_I2S * Update install-arduino.sh * rm -rf "$AR_COMPS/arduino/libraries/ESP_SR" * rm -rf arduino-esp32/libraries/ESP_SR * Update config.sh * Update push.yml * rm -rf arduino-esp32/libraries/BluetoothSerial * rm -rf "$AR_COMPS/arduino/libraries/libraries/BluetoothSerial" * rm -rf "$AR_COMPS/arduino/libraries/BluetoothSerial" * rm arduino examples * rm all Arduino examples * rm examples / reduce build zip time * Update config.sh * Update push.yml * Update CMakeLists.txt * Update idf_component.yml * Update update-components.sh * Just one Arduino 5.1 (#69) * rm `rm -rf arduino-esp32/libraries/WiFiClientSecure` * rm -rf "$AR_COMPS/arduino/libraries/WiFiClientSecure" * clean up * use Hardware mbedtls * rm -rf arduino-esp32/libraries/ESP_I2S * rm -rf "$AR_COMPS/arduino/libraries/ESP_I2S * Update install-arduino.sh * rm -rf "$AR_COMPS/arduino/libraries/ESP_SR" * rm -rf arduino-esp32/libraries/ESP_SR * Update CMakeLists.txt * Update idf_component.yml * Update update-components.sh * Update idf_component.yml * Update defconfig.esp32c2 * Update defconfig.esp32c2 * # CONFIG_DAC_DMA_AUTO_16BIT_ALIGN is not set * Disable BLE4.2 * Disable BT Stack size * add var for managed_components * changed folder of webcam *.h * changed path for webcam *.h * fix webcam setup * MBEDTLS_USE_CRYPTO_ROM_IMPL * Update defconfig.esp32c2 * Update defconfig.common * # CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN is not set * Try to reduce mbedtls footprint * Update defconfig.common * Copy dependencies.lock for each target * Make PR title use the info from versions.txt * Update config.sh * changed components info generating * Update update-components.sh * Update copy-libs.sh * add release info txt * Create eth_multicast.diff * Create esp32s2_i2c_ll_master_init.diff * Multicast / s2 i2c fix * Update esp32s2_i2c_ll_master_init.diff * Update esp32s2_i2c_ll_master_init.diff * Update eth_multicast.diff * Update config.sh --- build.sh | 50 ++++++++--- configs/defconfig.esp32c2 | 1 + configs/defconfig.esp32c6 | 3 + patches/esp32s2_i2c_ll_master_init.diff | 17 ++++ patches/eth_multicast.diff | 109 ++++++++++++++++++++++++ tools/config.sh | 13 +-- tools/copy-libs.sh | 3 + tools/gen_platformio_manifest.py | 2 +- tools/install-arduino.sh | 1 + tools/install-esp-idf.sh | 9 +- tools/update-components.sh | 9 +- 11 files changed, 184 insertions(+), 33 deletions(-) create mode 100644 patches/esp32s2_i2c_ll_master_init.diff create mode 100644 patches/eth_multicast.diff diff --git a/build.sh b/build.sh index fa8484bcd..2e1bb0a85 100755 --- a/build.sh +++ b/build.sh @@ -87,6 +87,7 @@ shift $((OPTIND -1)) CONFIGS=$@ mkdir -p dist +rm -rf dependencies.lock if [ $SKIP_ENV -eq 0 ]; then echo "* Installing/Updating ESP-IDF and all components..." @@ -137,19 +138,13 @@ if [ "$BUILD_TYPE" != "all" ]; then fi rm -rf build sdkconfig out +mkdir -p "$AR_TOOLS/esp32-arduino-libs" -# Add components version info -mkdir -p "$AR_TOOLS/esp32-arduino-libs" && rm -rf version.txt && rm -rf "$AR_TOOLS/esp32-arduino-libs/versions.txt" -component_version="esp-idf: "$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD)" "$(git -C "$IDF_PATH" rev-parse --short HEAD) -echo $component_version >> version.txt && echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt" -for component in `ls "$AR_COMPS"`; do - if [ -d "$AR_COMPS/$component/.git" ] || [ -d "$AR_COMPS/$component/.github" ]; then - component_version="$component: "$(git -C "$AR_COMPS/$component" symbolic-ref --short HEAD || git -C "$AR_COMPS/$component" tag --points-at HEAD)" "$(git -C "$AR_COMPS/$component" rev-parse --short HEAD) - echo $component_version >> version.txt && echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt" - fi -done -component_version="tinyusb: "$(git -C "$AR_COMPS/arduino_tinyusb/tinyusb" symbolic-ref --short HEAD || git -C "$AR_COMPS/arduino_tinyusb/tinyusb" tag --points-at HEAD)" "$(git -C "$AR_COMPS/arduino_tinyusb/tinyusb" rev-parse --short HEAD) -echo $component_version >> version.txt && echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt" +# Add release-info +rm -rf release-info.txt +IDF_Commit_short=$(git -C "$IDF_PATH" rev-parse --short HEAD || echo "") +AR_Commit_short=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "") +echo "Framework built from $IDF_REPO branch $IDF_BRANCH commit $IDF_Commit_short and $AR_REPO branch $AR_BRANCH commit $AR_Commit_short" >> release-info.txt # Add release-info rm -rf release-info.txt @@ -213,6 +208,37 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do done done +# +# Add components version info +# +rm -rf "$AR_TOOLS/esp32-arduino-libs/versions.txt" +# The lib-builder version +component_version="lib-builder: "$(git -C "$AR_ROOT" symbolic-ref --short HEAD || git -C "$AR_ROOT" tag --points-at HEAD)" "$(git -C "$AR_ROOT" rev-parse --short HEAD) +echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt" +# ESP-IDF version +component_version="esp-idf: "$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD)" "$(git -C "$IDF_PATH" rev-parse --short HEAD) +echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt" +# components version +for component in `ls "$AR_COMPS"`; do + if [ -d "$AR_COMPS/$component/.git" ]; then + component_version="$component: "$(git -C "$AR_COMPS/$component" symbolic-ref --short HEAD || git -C "$AR_COMPS/$component" tag --points-at HEAD)" "$(git -C "$AR_COMPS/$component" rev-parse --short HEAD) + echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt" + fi +done +# TinyUSB version +component_version="tinyusb: "$(git -C "$AR_COMPS/arduino_tinyusb/tinyusb" symbolic-ref --short HEAD || git -C "$AR_COMPS/arduino_tinyusb/tinyusb" tag --points-at HEAD)" "$(git -C "$AR_COMPS/arduino_tinyusb/tinyusb" rev-parse --short HEAD) +echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt" +# managed components version +for component in `ls "$AR_MANAGED_COMPS"`; do + if [ -d "$AR_MANAGED_COMPS/$component/.git" ]; then + component_version="$component: "$(git -C "$AR_MANAGED_COMPS/$component" symbolic-ref --short HEAD || git -C "$AR_MANAGED_COMPS/$component" tag --points-at HEAD)" "$(git -C "$AR_MANAGED_COMPS/$component" rev-parse --short HEAD) + echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt" + elif [ -f "$AR_MANAGED_COMPS/$component/idf_component.yml" ]; then + component_version="$component: "$(cat "$AR_MANAGED_COMPS/$component/idf_component.yml" | grep "^version: " | cut -d ' ' -f 2) + echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt" + fi +done + # update package_esp32_index.template.json if [ "$BUILD_TYPE" = "all" ]; then python3 ./tools/gen_tools_json.py -i "$IDF_PATH" -j "$AR_COMPS/arduino/package/package_esp32_index.template.json" -o "$AR_OUT/" diff --git a/configs/defconfig.esp32c2 b/configs/defconfig.esp32c2 index 6441674b0..2e3ecad3d 100644 --- a/configs/defconfig.esp32c2 +++ b/configs/defconfig.esp32c2 @@ -1,5 +1,6 @@ CONFIG_XTAL_FREQ_26=y CONFIG_XTAL_FREQ=26 + # # Bluetooth # diff --git a/configs/defconfig.esp32c6 b/configs/defconfig.esp32c6 index 96296de58..76c575e4e 100644 --- a/configs/defconfig.esp32c6 +++ b/configs/defconfig.esp32c6 @@ -1,3 +1,6 @@ +# C6 has full Newlib in Rom +# CONFIG_NEWLIB_NANO_FORMAT is not set + # # Bluetooth # diff --git a/patches/esp32s2_i2c_ll_master_init.diff b/patches/esp32s2_i2c_ll_master_init.diff new file mode 100644 index 000000000..2a129c695 --- /dev/null +++ b/patches/esp32s2_i2c_ll_master_init.diff @@ -0,0 +1,17 @@ +diff --git a/components/hal/esp32s2/include/hal/i2c_ll.h b/components/hal/esp32s2/include/hal/i2c_ll.h +index f9a66b61d6..2f669b68c0 100644 +--- a/components/hal/esp32s2/include/hal/i2c_ll.h ++++ b/components/hal/esp32s2/include/hal/i2c_ll.h +@@ -653,10 +653,12 @@ static inline void i2c_ll_enable_controller_clock(i2c_dev_t *hw, bool en) + static inline void i2c_ll_master_init(i2c_dev_t *hw) + { + typeof(hw->ctr) ctrl_reg; ++ uint32_t ref_always_on = hw->ctr.ref_always_on; + ctrl_reg.val = 0; + ctrl_reg.ms_mode = 1; + ctrl_reg.sda_force_out = 1; + ctrl_reg.scl_force_out = 1; ++ ctrl_reg.ref_always_on = ref_always_on; + hw->ctr.val = ctrl_reg.val; + } + diff --git a/patches/eth_multicast.diff b/patches/eth_multicast.diff new file mode 100644 index 000000000..da7f8691b --- /dev/null +++ b/patches/eth_multicast.diff @@ -0,0 +1,109 @@ +diff --git a/components/esp_eth/src/esp_eth_mac_esp.c b/components/esp_eth/src/esp_eth_mac_esp.c +index 7704d9ac48cbe572aefcacd24bfcf6097a9a0562..d59e1e33b4ab3d8a9bde7527ec8f68175bf5dc1e 100644 +--- a/components/esp_eth/src/esp_eth_mac_esp.c ++++ b/components/esp_eth/src/esp_eth_mac_esp.c +@@ -634,7 +634,6 @@ esp_eth_mac_t *esp_eth_mac_new_esp32(const eth_esp32_emac_config_t *esp32_config + emac->smi_mdio_gpio_num = esp32_config->smi_mdio_gpio_num; + emac->flow_control_high_water_mark = FLOW_CONTROL_HIGH_WATER_MARK; + emac->flow_control_low_water_mark = FLOW_CONTROL_LOW_WATER_MARK; +- emac->use_apll = false; + emac->parent.set_mediator = emac_esp32_set_mediator; + emac->parent.init = emac_esp32_init; + emac->parent.deinit = emac_esp32_deinit; +diff --git a/components/esp_eth/src/esp_eth_mac_ksz8851snl.c b/components/esp_eth/src/esp_eth_mac_ksz8851snl.c +index 10ab357fc4c68141361e5038af1856fa769fe168..473195a83b236236a604f26f5ce1765eed2c1d91 100644 +--- a/components/esp_eth/src/esp_eth_mac_ksz8851snl.c ++++ b/components/esp_eth/src/esp_eth_mac_ksz8851snl.c +@@ -298,7 +298,7 @@ static esp_err_t init_set_defaults(emac_ksz8851snl_t *emac) + ESP_GOTO_ON_ERROR(ksz8851_set_bits(emac, KSZ8851_RXDTTR, RXDTTR_INIT_VALUE), err, TAG, "RXDTTR write failed"); + ESP_GOTO_ON_ERROR(ksz8851_set_bits(emac, KSZ8851_RXDBCTR, RXDBCTR_INIT_VALUE), err, TAG, "RXDBCTR write failed"); + ESP_GOTO_ON_ERROR(ksz8851_set_bits(emac, KSZ8851_RXCR1, +- RXCR1_RXUDPFCC | RXCR1_RXTCPFCC | RXCR1_RXIPFCC | RXCR1_RXPAFMA | RXCR1_RXFCE | RXCR1_RXBE | RXCR1_RXUE | RXCR1_RXME), err, TAG, "RXCR1 write failed"); ++ RXCR1_RXUDPFCC | RXCR1_RXTCPFCC | RXCR1_RXIPFCC | RXCR1_RXPAFMA | RXCR1_RXFCE | RXCR1_RXUE | RXCR1_RXME | RXCR1_RXMAFMA | RXCR1_RXAE), err, TAG, "RXCR1 write failed"); + ESP_GOTO_ON_ERROR(ksz8851_set_bits(emac, KSZ8851_RXCR2, + (4 << RXCR2_SRDBL_SHIFT) | RXCR2_IUFFP | RXCR2_RXIUFCEZ | RXCR2_UDPLFE | RXCR2_RXICMPFCC), err, TAG, "RXCR2 write failed"); + ESP_GOTO_ON_ERROR(ksz8851_set_bits(emac, KSZ8851_RXQCR, RXQCR_RXFCTE | RXQCR_ADRFE), err, TAG, "RXQCR write failed"); +@@ -650,13 +650,13 @@ static esp_err_t emac_ksz8851_set_promiscuous(esp_eth_mac_t *mac, bool enable) + if (enable) { + // NOTE(v.chistyakov): set promiscuous mode + ESP_LOGD(TAG, "setting promiscuous mode"); +- rxcr1 |= RXCR1_RXINVF | RXCR1_RXAE; ++ rxcr1 |= RXCR1_RXAE | RXCR1_RXINVF; + rxcr1 &= ~(RXCR1_RXPAFMA | RXCR1_RXMAFMA); + } else { + // NOTE(v.chistyakov): set hash perfect (default) +- ESP_LOGD(TAG, "setting hash perfect mode"); +- rxcr1 |= RXCR1_RXPAFMA; +- rxcr1 &= ~(RXCR1_RXINVF | RXCR1_RXAE | RXCR1_RXMAFMA); ++ ESP_LOGD(TAG, "setting perfect with multicast passed"); ++ rxcr1 |= RXCR1_RXAE| RXCR1_RXPAFMA | RXCR1_RXMAFMA; ++ rxcr1 &= ~RXCR1_RXINVF; + } + ESP_GOTO_ON_ERROR(ksz8851_write_reg(emac, KSZ8851_RXCR1, rxcr1), err, TAG, "RXCR1 write failed"); + err: +diff --git a/components/esp_eth/src/esp_eth_phy_802_3.c b/components/esp_eth/src/esp_eth_phy_802_3.c +index 51a10fd551820bda41db581a3f65d63f63306972..785a0c0feb7725e5f9ce7174220d4df37cb14b45 100644 +--- a/components/esp_eth/src/esp_eth_phy_802_3.c ++++ b/components/esp_eth/src/esp_eth_phy_802_3.c +@@ -302,16 +302,18 @@ esp_err_t esp_eth_phy_802_3_detect_phy_addr(esp_eth_mediator_t *eth, int *detect + } + int addr_try = 0; + uint32_t reg_value = 0; +- for (; addr_try < 16; addr_try++) { +- eth->phy_reg_read(eth, addr_try, ETH_PHY_IDR1_REG_ADDR, ®_value); +- if (reg_value != 0xFFFF && reg_value != 0x00) { +- *detected_addr = addr_try; +- break; ++ for (int i = 0; i < 3; i++){ ++ for (addr_try = 0; addr_try < 32; addr_try++) { ++ eth->phy_reg_read(eth, addr_try, ETH_PHY_IDR1_REG_ADDR, ®_value); ++ if (reg_value != 0xFFFF && reg_value != 0x00) { ++ *detected_addr = addr_try; ++ break; ++ } ++ } ++ if (addr_try < 32) { ++ ESP_LOGD(TAG, "Found PHY address: %d", addr_try); ++ return ESP_OK; + } +- } +- if (addr_try < 16) { +- ESP_LOGD(TAG, "Found PHY address: %d", addr_try); +- return ESP_OK; + } + ESP_LOGE(TAG, "No PHY device detected"); + return ESP_ERR_NOT_FOUND; +diff --git a/components/esp_eth/src/esp_eth_phy_dm9051.c b/components/esp_eth/src/esp_eth_phy_dm9051.c +index d8f9bad9fc8a4da396f65c47f283335bf5448b2f..6db49f8fad0adacf78c52e78525b856bfb53b643 100644 +--- a/components/esp_eth/src/esp_eth_phy_dm9051.c ++++ b/components/esp_eth/src/esp_eth_phy_dm9051.c +@@ -95,7 +95,7 @@ static esp_err_t dm9051_update_link_duplex_speed(phy_dm9051_t *dm9051) + eth_duplex_t duplex = ETH_DUPLEX_HALF; + uint32_t peer_pause_ability = false; + bmsr_reg_t bmsr; +- dscsr_reg_t dscsr; ++ bmcr_reg_t bmcr; + anlpar_reg_t anlpar; + // BMSR is a latch low register + // after power up, the first latched value must be 0, which means down +@@ -108,17 +108,9 @@ static esp_err_t dm9051_update_link_duplex_speed(phy_dm9051_t *dm9051) + if (dm9051->phy_802_3.link_status != link) { + /* when link up, read negotiation result */ + if (link == ETH_LINK_UP) { +- ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ETH_PHY_DSCSR_REG_ADDR, &(dscsr.val)), err, TAG, "read DSCSR failed"); +- if (dscsr.fdx100 || dscsr.hdx100) { +- speed = ETH_SPEED_100M; +- } else { +- speed = ETH_SPEED_10M; +- } +- if (dscsr.fdx100 || dscsr.fdx10) { +- duplex = ETH_DUPLEX_FULL; +- } else { +- duplex = ETH_DUPLEX_HALF; +- } ++ ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); ++ speed = bmcr.speed_select == 1 ? ETH_SPEED_100M : ETH_SPEED_10M; ++ duplex = bmcr.duplex_mode == 1 ? ETH_DUPLEX_FULL : ETH_DUPLEX_HALF; + ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_SPEED, (void *)speed), err, TAG, "change speed failed"); + ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_DUPLEX, (void *)duplex), err, TAG, "change duplex failed"); + /* if we're in duplex mode, and peer has the flow control ability */ diff --git a/tools/config.sh b/tools/config.sh index 894d25ec6..7c9723443 100755 --- a/tools/config.sh +++ b/tools/config.sh @@ -34,7 +34,7 @@ fi AR_USER="tasmota" # IDF commit to use -#IDF_COMMIT="cf913a00e34d61adeee0dc52414a9e10c9b3737e" +#IDF_COMMIT="ec31b4d09d3da05001648eaa58aa582c5cc923c8" # Arduino commit to use #AR_COMMIT="" @@ -54,6 +54,7 @@ fi AR_ROOT="$PWD" AR_COMPS="$AR_ROOT/components" +AR_MANAGED_COMPS="$AR_ROOT/managed_components" AR_OUT="$AR_ROOT/out" AR_TOOLS="$AR_OUT/tools" AR_PLATFORM_TXT="$AR_OUT/platform.txt" @@ -176,15 +177,7 @@ function git_create_pr(){ # git_create_pr local pr_title="$2" local pr_target="$3" local pr_body="" - pr_body+="esp-idf: "$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD)" "$(git -C "$IDF_PATH" rev-parse --short HEAD)"\r\n" - for component in `ls "$AR_COMPS"`; do - if [ ! $component == "arduino" ]; then - if [ -d "$AR_COMPS/$component/.git" ] || [ -d "$AR_COMPS/$component/.github" ]; then - pr_body+="$component: "$(git -C "$AR_COMPS/$component" symbolic-ref --short HEAD || git -C "$AR_COMPS/$component" tag --points-at HEAD)" "$(git -C "$AR_COMPS/$component" rev-parse --short HEAD)"\r\n" - fi - fi - done - pr_body+="tinyusb: "$(git -C "$AR_COMPS/arduino_tinyusb/tinyusb" symbolic-ref --short HEAD || git -C "$AR_COMPS/arduino_tinyusb/tinyusb" tag --points-at HEAD)" "$(git -C "$AR_COMPS/arduino_tinyusb/tinyusb" rev-parse --short HEAD)"\r\n" + pr_body+="\`\`\`\r\n"$(cat "$AR_TOOLS/esp32-arduino-libs/versions.txt")"\r\n\`\`\`\r\n" local pr_data="{\"title\": \"$pr_title\", \"body\": \"$pr_body\", \"head\": \"$AR_USER:$pr_branch\", \"base\": \"$pr_target\"}" git_create_pr_res=`echo "$pr_data" | curl -k -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" --data @- "https://api.github.com/repos/$AR_REPO/pulls"` local done_pr=`echo "$git_create_pr_res" | jq -r '.title'` diff --git a/tools/copy-libs.sh b/tools/copy-libs.sh index a20358c6a..f49434462 100755 --- a/tools/copy-libs.sh +++ b/tools/copy-libs.sh @@ -488,6 +488,9 @@ fi # sdkconfig cp -f "sdkconfig" "$AR_SDK/sdkconfig" +# dependencies.lock +cp -f "dependencies.lock" "$AR_SDK/dependencies.lock" + # gen_esp32part.py # cp "$IDF_PATH/components/partition_table/gen_esp32part.py" "$AR_GEN_PART_PY" diff --git a/tools/gen_platformio_manifest.py b/tools/gen_platformio_manifest.py index 2d031b687..02057d9a2 100644 --- a/tools/gen_platformio_manifest.py +++ b/tools/gen_platformio_manifest.py @@ -11,7 +11,7 @@ "license": "LGPL-2.1-or-later", "repository": { "type": "git", - "url": "https://github.com/espressif/esp32-arduino-libs", + "url": "https://github.com/tasmota/esp32-arduino-libs", }, } diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index e490916a9..78668b7f3 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -55,6 +55,7 @@ rm -rf "$AR_COMPS/arduino/libraries/Insights" rm -rf "$AR_COMPS/arduino/libraries/ESP_I2S" rm -rf "$AR_COMPS/arduino/libraries/BLE" rm -rf "$AR_COMPS/arduino/libraries/SimpleBLE" +rm -rf "$AR_COMPS/arduino/libraries/BluetoothSerial" rm -rf "$AR_COMPS/arduino/libraries/WiFiProv" rm -rf "$AR_COMPS/arduino/libraries/WiFiClientSecure" rm -rf "$AR_COMPS/arduino/libraries/ESP32" diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index 7096e49a8..0c1298eb6 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -37,13 +37,10 @@ if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then # Temporarily patch the ETH driver to support custom SPI cd $IDF_PATH - patch -p1 -i ../patches/spi_eth.diff + patch -p1 -N -i ../patches/spi_eth.diff + patch -p1 -N -i ../patches/eth_multicast.diff + patch -p1 -N -i ../patches/esp32s2_i2c_ll_master_init.diff cd - - - # Patch espressif nimble driver to support esp-nimble-cpp from h2zero - cd $IDF_PATH - patch -p1 -i ../patches/nimble.diff - cd - fi # diff --git a/tools/update-components.sh b/tools/update-components.sh index 06e24d23a..d2d819fdd 100755 --- a/tools/update-components.sh +++ b/tools/update-components.sh @@ -5,6 +5,7 @@ source ./tools/config.sh CAMERA_REPO_URL="https://github.com/espressif/esp32-camera.git" LITTLEFS_REPO_URL="https://github.com/joltwallet/esp_littlefs.git" TINYUSB_REPO_URL="https://github.com/hathach/tinyusb.git" +TINYUSB_REPO_DIR="$AR_COMPS/arduino_tinyusb/tinyusb" # # CLONE/UPDATE ESP32-CAMERA @@ -43,10 +44,10 @@ cp "$AR_COMPS/esp32-camera/driver/private_include/cam_hal.h" "$AR_COMPS/esp32-ca # CLONE/UPDATE TINYUSB # echo "Updating TinyUSB..." -if [ ! -d "$AR_COMPS/arduino_tinyusb/tinyusb" ]; then - git clone $TINYUSB_REPO_URL "$AR_COMPS/arduino_tinyusb/tinyusb" +if [ ! -d "$TINYUSB_REPO_DIR" ]; then + git clone "$TINYUSB_REPO_URL" "$TINYUSB_REPO_DIR" else - git -C "$AR_COMPS/arduino_tinyusb/tinyusb" fetch && \ - git -C "$AR_COMPS/arduino_tinyusb/tinyusb" pull --ff-only + git -C "$TINYUSB_REPO_DIR" fetch && \ + git -C "$TINYUSB_REPO_DIR" pull --ff-only fi if [ $? -ne 0 ]; then exit 1; fi From d2023bf7cc311fae8eb03490cc765c3249098aa8 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 27 Nov 2023 17:02:56 +0100 Subject: [PATCH 054/211] Update install-esp-idf.sh --- tools/install-esp-idf.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index 0c1298eb6..9175b83dc 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -38,7 +38,7 @@ if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then # Temporarily patch the ETH driver to support custom SPI cd $IDF_PATH patch -p1 -N -i ../patches/spi_eth.diff - patch -p1 -N -i ../patches/eth_multicast.diff + patch -p1 -N -i ../patches/eth_multicast.diff patch -p1 -N -i ../patches/esp32s2_i2c_ll_master_init.diff cd - fi From a9d43d0f207f5abe353eb0be6abc6e8c7e0f8073 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:42:36 +0100 Subject: [PATCH 055/211] rm -rf arduino-esp32/idf_component_examples --- tools/archive-build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index a7d116a74..275e8495f 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -25,6 +25,7 @@ cp -f ../components/arduino/Kco* arduino-esp32 cp -f ../components/arduino/pac* arduino-esp32 rm -rf arduino-esp32/docs rm -rf arduino-esp32/tests +rm -rf arduino-esp32/idf_component_examples rm -rf arduino-esp32/libraries/RainMaker rm -rf arduino-esp32/libraries/Insights rm -rf arduino-esp32/libraries/ESP_I2S From 7f91d1737f93de3c30a5790df7c5db715894717f Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 29 Nov 2023 22:09:31 +0100 Subject: [PATCH 056/211] Update config.sh --- tools/config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/config.sh b/tools/config.sh index 7c9723443..4db94e1b2 100755 --- a/tools/config.sh +++ b/tools/config.sh @@ -177,7 +177,7 @@ function git_create_pr(){ # git_create_pr <branch> <title> local pr_title="$2" local pr_target="$3" local pr_body="" - pr_body+="\`\`\`\r\n"$(cat "$AR_TOOLS/esp32-arduino-libs/versions.txt")"\r\n\`\`\`\r\n" + while read -r line; do pr_body+=$line"\r\n"; done < "$AR_TOOLS/esp32-arduino-libs/versions.txt" local pr_data="{\"title\": \"$pr_title\", \"body\": \"$pr_body\", \"head\": \"$AR_USER:$pr_branch\", \"base\": \"$pr_target\"}" git_create_pr_res=`echo "$pr_data" | curl -k -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" --data @- "https://api.github.com/repos/$AR_REPO/pulls"` local done_pr=`echo "$git_create_pr_res" | jq -r '.title'` From 7ce4a3d99f607e374d8167c4323f27c8323c9273 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 1 Dec 2023 16:53:58 +0100 Subject: [PATCH 057/211] CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y --- configs/defconfig.common | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/defconfig.common b/configs/defconfig.common index 6a7da076b..8dfa7a1b2 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -33,6 +33,7 @@ CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2048 CONFIG_ESP_TASK_WDT_PANIC=y CONFIG_ESP_TIMER_TASK_STACK_SIZE=4096 CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y CONFIG_ESP_WIFI_FTM_ENABLE=n CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=8 CONFIG_ESP_WIFI_STATIC_TX_BUFFER_NUM=8 From a237c35422f569d4380ccec0610dec08d8074150 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 6 Dec 2023 22:05:34 +0100 Subject: [PATCH 058/211] V5.1 git clone optimize --- build.sh | 19 ++++++------------ tools/archive-build.sh | 1 + tools/config.sh | 10 +++------ tools/install-arduino.sh | 37 +++++++++++++++++++++++++++------- tools/install-esp-idf.sh | 39 ++++++++++++++++++++++++++++++++---- tools/repository_dispatch.sh | 2 +- tools/update-components.sh | 35 +++++++++++--------------------- 7 files changed, 88 insertions(+), 55 deletions(-) diff --git a/build.sh b/build.sh index 2e1bb0a85..65b7b8a33 100755 --- a/build.sh +++ b/build.sh @@ -63,11 +63,11 @@ while getopts ":A:I:i:c:t:b:sde" opt; do ;; b ) b=$OPTARG - if [ "$b" != "build" ] && - [ "$b" != "menuconfig" ] && - [ "$b" != "reconfigure" ] && - [ "$b" != "idf_libs" ] && - [ "$b" != "copy_bootloader" ] && + if [ "$b" != "build" ] && + [ "$b" != "menuconfig" ] && + [ "$b" != "reconfigure" ] && + [ "$b" != "idf_libs" ] && + [ "$b" != "copy_bootloader" ] && [ "$b" != "mem_variant" ]; then print_help fi @@ -114,7 +114,7 @@ if [ "$BUILD_TYPE" != "all" ]; then print_help fi configs="configs/defconfig.common;configs/defconfig.$TARGET" - + # Target Features Configs for target_json in `jq -c '.targets[]' configs/builds.json`; do target=$(echo "$target_json" | jq -c '.target' | tr -d '"') @@ -146,13 +146,6 @@ IDF_Commit_short=$(git -C "$IDF_PATH" rev-parse --short HEAD || echo "") AR_Commit_short=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "") echo "Framework built from $IDF_REPO branch $IDF_BRANCH commit $IDF_Commit_short and $AR_REPO branch $AR_BRANCH commit $AR_Commit_short" >> release-info.txt -# Add release-info -rm -rf release-info.txt -IDF_Commit_short=$(git -C "$IDF_PATH" rev-parse --short HEAD || echo "") -AR_Commit_short=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "") -echo "Framework built from $IDF_REPO branch $IDF_BRANCH commit $IDF_Commit_short and $AR_REPO branch $AR_BRANCH commit $AR_Commit_short" >> release-info.txt - - #targets_count=`jq -c '.targets[] | length' configs/builds.json` for target_json in `jq -c '.targets[]' configs/builds.json`; do target=$(echo "$target_json" | jq -c '.target' | tr -d '"') diff --git a/tools/archive-build.sh b/tools/archive-build.sh index 275e8495f..a79f23762 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -23,6 +23,7 @@ cp -f ../components/arduino/CMa* arduino-esp32 cp -f ../components/arduino/idf* arduino-esp32 cp -f ../components/arduino/Kco* arduino-esp32 cp -f ../components/arduino/pac* arduino-esp32 +rm -rf arduino-esp32/idf_component_examples rm -rf arduino-esp32/docs rm -rf arduino-esp32/tests rm -rf arduino-esp32/idf_component_examples diff --git a/tools/config.sh b/tools/config.sh index 4db94e1b2..fe8a65d4f 100755 --- a/tools/config.sh +++ b/tools/config.sh @@ -14,11 +14,6 @@ if [ -z $AR_BRANCH ]; then AR_BRANCH="main" fi -if [ -z $AR_PR_TARGET_BRANCH ]; then - # Temporary to get CI working. original is master - AR_PR_TARGET_BRANCH="esp-idf-v5.1-libs" -fi - if [ -z $IDF_TARGET ]; then if [ -f sdkconfig ]; then IDF_TARGET=`cat sdkconfig | grep CONFIG_IDF_TARGET= | cut -d'"' -f2` @@ -34,7 +29,7 @@ fi AR_USER="tasmota" # IDF commit to use -#IDF_COMMIT="ec31b4d09d3da05001648eaa58aa582c5cc923c8" +#IDF_COMMIT="" # Arduino commit to use #AR_COMMIT="" @@ -176,8 +171,9 @@ function git_create_pr(){ # git_create_pr <branch> <title> local pr_branch="$1" local pr_title="$2" local pr_target="$3" - local pr_body="" + local pr_body="\`\`\`\r\n" while read -r line; do pr_body+=$line"\r\n"; done < "$AR_TOOLS/esp32-arduino-libs/versions.txt" + pr_body+="\`\`\`\r\n" local pr_data="{\"title\": \"$pr_title\", \"body\": \"$pr_body\", \"head\": \"$AR_USER:$pr_branch\", \"base\": \"$pr_target\"}" git_create_pr_res=`echo "$pr_data" | curl -k -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" --data @- "https://api.github.com/repos/$AR_REPO/pulls"` local done_pr=`echo "$git_create_pr_res" | jq -r '.title'` diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index 78668b7f3..93b53a6e2 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -5,9 +5,38 @@ source ./tools/config.sh # # CLONE/UPDATE ARDUINO # -echo "Updating ESP32 Arduino..." +if [ "$AR_BRANCH" ]; then + echo "Installing Arduino from branch '$AR_BRANCH'" + if [ ! -d "$AR_COMPS/arduino" ]; then + # for using a branch we need no full clone + git clone -b "$AR_BRANCH" --recursive --depth 1 --shallow-submodule $AR_REPO_URL "$AR_COMPS/arduino" + else + # update existing branch + cd "$AR_COMPS/arduino" + git pull + git reset --hard $AR_BRANCH + # -ff is for cleaning untracked files as well as submodules + git clean -ffdx + cd - + fi +fi + if [ ! -d "$AR_COMPS/arduino" ]; then + # we need a full clone since no branch was set + echo "Full cloning of ESP32 Arduino repo '$AR_REPO_URL'" git clone $AR_REPO_URL "$AR_COMPS/arduino" +else + if [ "$AR_BRANCH" ]; then + echo "ESP32 Arduino is up to date" + else + # update existing branch + echo "Updating ESP32 Arduino" + cd "$AR_COMPS/arduino" + git pull + # -ff is for cleaning untracked files as well as submodules + git clean -ffdx + cd - + fi fi if [ -z $AR_BRANCH ]; then @@ -39,12 +68,6 @@ if [ -z $AR_BRANCH ]; then fi fi -if [ "$AR_BRANCH" ]; then - echo "AR_BRANCH='$AR_BRANCH'" - git -C "$AR_COMPS/arduino" checkout "$AR_BRANCH" && \ - git -C "$AR_COMPS/arduino" fetch && \ - git -C "$AR_COMPS/arduino" pull --ff-only -fi if [ $? -ne 0 ]; then exit 1; fi # diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index 9175b83dc..e3433e9c1 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -10,11 +10,42 @@ fi # # CLONE ESP-IDF # +if [ "$IDF_TAG" ] || [ "$IDF_COMMIT" ]; then + if [ ! -d "$IDF_PATH" ]; then + # full clone needed to check out tag or commit + echo "ESP-IDF is not installed! Installing with full clone from $IDF_REPO_URL branch $IDF_BRANCH" + git clone $IDF_REPO_URL -b $IDF_BRANCH + idf_was_installed="1" + else + # update local clone + echo "ESP-IDF is installed, updating..." + cd $IDF_PATH + git pull + git reset --hard $IDF_BRANCH + git submodule update + # -ff is for cleaning untracked files as well as submodules + git clean -ffdx + cd - + idf_was_installed="1" + fi +fi if [ ! -d "$IDF_PATH" ]; then - echo "ESP-IDF is not installed! Installing from $IDF_REPO_URL branch $IDF_BRANCH" - git clone $IDF_REPO_URL -b $IDF_BRANCH - idf_was_installed="1" + # for using a branch we need no full clone + echo "ESP-IDF is not installed! Installing branch $IDF_BRANCH from $IDF_REPO_URL" + git clone -b $IDF_BRANCH --recursive --depth 1 --shallow-submodule $IDF_REPO_URL + idf_was_installed="1" +else + # update existing branch + echo "ESP-IDF is already installed, updating branch '$IDF_BRANCH'" + cd $IDF_PATH + git pull + git reset --hard $IDF_BRANCH + git submodule update --depth 1 + # -ff is for cleaning untracked files as well as submodules + git clean -ffdx + cd - + idf_was_installed="1" fi if [ "$IDF_TAG" ]; then @@ -30,7 +61,7 @@ fi # if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then - git -C $IDF_PATH submodule update --init --recursive + git submodule update --recursive $IDF_PATH/install.sh export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD) export IDF_BRANCH=$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD) diff --git a/tools/repository_dispatch.sh b/tools/repository_dispatch.sh index 15198e98e..ad23620a8 100755 --- a/tools/repository_dispatch.sh +++ b/tools/repository_dispatch.sh @@ -14,7 +14,7 @@ commit=`echo "$payload" | jq -r '.commit'` builder=`echo "$payload" | jq -r '.builder'` arduino=`echo "$payload" | jq -r '.arduino'` -echo "Action: $action, Branch: $branch, Tag: $tag, Commit: $commit, Builder: $builder, Arduino: $arduino, Actor: $GITHUB_ACTOR" +echo "Action: $action, IDF Branch: $branch, IDF Tag: $tag, IDF Commit: $commit, Builder Branch: $builder, Arduino Branch: $arduino, Actor: $GITHUB_ACTOR" if [ ! "$action" == "deploy" ] && [ ! "$action" == "build" ]; then echo "Bad Action $action" diff --git a/tools/update-components.sh b/tools/update-components.sh index d2d819fdd..9fdbb8ea6 100755 --- a/tools/update-components.sh +++ b/tools/update-components.sh @@ -3,7 +3,6 @@ source ./tools/config.sh CAMERA_REPO_URL="https://github.com/espressif/esp32-camera.git" -LITTLEFS_REPO_URL="https://github.com/joltwallet/esp_littlefs.git" TINYUSB_REPO_URL="https://github.com/hathach/tinyusb.git" TINYUSB_REPO_DIR="$AR_COMPS/arduino_tinyusb/tinyusb" @@ -12,10 +11,14 @@ TINYUSB_REPO_DIR="$AR_COMPS/arduino_tinyusb/tinyusb" # echo "Updating ESP32 Camera..." if [ ! -d "$AR_COMPS/esp32-camera" ]; then - git clone $CAMERA_REPO_URL "$AR_COMPS/esp32-camera" + git clone -b master --recursive --depth 1 --shallow-submodule $CAMERA_REPO_URL "$AR_COMPS/esp32-camera" else - git -C "$AR_COMPS/esp32-camera" fetch && \ - git -C "$AR_COMPS/esp32-camera" pull --ff-only + cd "$AR_COMPS/esp32-camera" + git pull + git submodule update --depth 1 + # -ff is for cleaning untracked files as well as submodules + git clean -ffdx + cd - fi if [ $? -ne 0 ]; then exit 1; fi @@ -24,30 +27,16 @@ if [ $? -ne 0 ]; then exit 1; fi # cp "$AR_COMPS/esp32-camera/driver/private_include/cam_hal.h" "$AR_COMPS/esp32-camera/driver/include/" -# -# CLONE/UPDATE ESP-LITTLEFS v1.10.0 commit 032f9... -# -#echo "Updating ESP-LITTLEFS..." -#if [ ! -d "$AR_COMPS/esp_littlefs" ]; then -# git clone $LITTLEFS_REPO_URL "$AR_COMPS/esp_littlefs" -# git -C "$AR_COMPS/esp_littlefs" checkout 032f9eb2e291e7c4df63c3e6a3cb3bc766ded495 -# git -C "$AR_COMPS/esp_littlefs" submodule update --init --recursive -#else -# git -C "$AR_COMPS/esp_littlefs" fetch -# git -C "$AR_COMPS/esp_littlefs" pull --ff-only -# git -C "$AR_COMPS/esp_littlefs" checkout 032f9eb2e291e7c4df63c3e6a3cb3bc766ded495 -# git -C "$AR_COMPS/esp_littlefs" submodule update --init --recursive -#fi -#if [ $? -ne 0 ]; then exit 1; fi - # # CLONE/UPDATE TINYUSB # echo "Updating TinyUSB..." if [ ! -d "$TINYUSB_REPO_DIR" ]; then - git clone "$TINYUSB_REPO_URL" "$TINYUSB_REPO_DIR" + git clone -b master --depth 1 "$TINYUSB_REPO_URL" "$TINYUSB_REPO_DIR" else - git -C "$TINYUSB_REPO_DIR" fetch && \ - git -C "$TINYUSB_REPO_DIR" pull --ff-only + cd $TINYUSB_REPO_DIR + git pull + # -ff is for cleaning untracked files as well as submodules + git clean -ffdx fi if [ $? -ne 0 ]; then exit 1; fi From c388c75b7051d9061d2ceb79568f7e10dd4c52b6 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 20 Dec 2023 12:31:38 +0100 Subject: [PATCH 059/211] add URL to release --- build.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 65b7b8a33..a1d475a61 100755 --- a/build.sh +++ b/build.sh @@ -144,7 +144,9 @@ mkdir -p "$AR_TOOLS/esp32-arduino-libs" rm -rf release-info.txt IDF_Commit_short=$(git -C "$IDF_PATH" rev-parse --short HEAD || echo "") AR_Commit_short=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "") -echo "Framework built from $IDF_REPO branch $IDF_BRANCH commit $IDF_Commit_short and $AR_REPO branch $AR_BRANCH commit $AR_Commit_short" >> release-info.txt +#echo "Framework built from $IDF_REPO branch $IDF_BRANCH commit $IDF_Commit_short and $AR_REPO branch $AR_BRANCH commit $AR_Commit_short" >> release-info.txt +echo "Framework built from $IDF_REPO branch [$IDF_BRANCH](https://github.com/$IDF_REPO/tree/$IDF_BRANCH) commit [$IDF_Commit_short](https://github.com/$IDF_REPO/commits/$IDF_BRANCH/#:~:text=$IDF_Commit_short) +and $AR_REPO branch [$AR_BRANCH](https://github.com/$AR_REPO/tree/$AR_BRANCH) commit [$AR_Commit_short](https://github.com/$AR_REPO/commits/$AR_BRANCH/#:~:text=$AR_Commit_short)" >> release-info.txt #targets_count=`jq -c '.targets[] | length' configs/builds.json` for target_json in `jq -c '.targets[]' configs/builds.json`; do From 580b71488134179cab7e47da48ce8683fcb1103c Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 20 Dec 2023 21:50:58 +0100 Subject: [PATCH 060/211] Update build.sh --- build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index a1d475a61..5b707821a 100755 --- a/build.sh +++ b/build.sh @@ -144,9 +144,9 @@ mkdir -p "$AR_TOOLS/esp32-arduino-libs" rm -rf release-info.txt IDF_Commit_short=$(git -C "$IDF_PATH" rev-parse --short HEAD || echo "") AR_Commit_short=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "") -#echo "Framework built from $IDF_REPO branch $IDF_BRANCH commit $IDF_Commit_short and $AR_REPO branch $AR_BRANCH commit $AR_Commit_short" >> release-info.txt -echo "Framework built from $IDF_REPO branch [$IDF_BRANCH](https://github.com/$IDF_REPO/tree/$IDF_BRANCH) commit [$IDF_Commit_short](https://github.com/$IDF_REPO/commits/$IDF_BRANCH/#:~:text=$IDF_Commit_short) -and $AR_REPO branch [$AR_BRANCH](https://github.com/$AR_REPO/tree/$AR_BRANCH) commit [$AR_Commit_short](https://github.com/$AR_REPO/commits/$AR_BRANCH/#:~:text=$AR_Commit_short)" >> release-info.txt +echo "Framework built from +- $IDF_REPO branch [$IDF_BRANCH](https://github.com/$IDF_REPO/tree/$IDF_BRANCH) commit [$IDF_Commit_short](https://github.com/$IDF_REPO/commits/$IDF_BRANCH/#:~:text=$IDF_Commit_short) +- $AR_REPO branch [$AR_BRANCH](https://github.com/$AR_REPO/tree/$AR_BRANCH) commit [$AR_Commit_short](https://github.com/$AR_REPO/commits/$AR_BRANCH/#:~:text=$AR_Commit_short)" >> release-info.txt #targets_count=`jq -c '.targets[] | length' configs/builds.json` for target_json in `jq -c '.targets[]' configs/builds.json`; do From b047ca929572a3aa16c08f5ca245892ee7a3e2c4 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 8 Jan 2024 14:14:05 +0100 Subject: [PATCH 061/211] rm not needed patches --- tools/install-esp-idf.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index e3433e9c1..45d3c21af 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -66,10 +66,8 @@ if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD) export IDF_BRANCH=$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD) - # Temporarily patch the ETH driver to support custom SPI + # Temporarily patch the ESP32-S2 I2C LL driver to keep the clock source cd $IDF_PATH - patch -p1 -N -i ../patches/spi_eth.diff - patch -p1 -N -i ../patches/eth_multicast.diff patch -p1 -N -i ../patches/esp32s2_i2c_ll_master_init.diff cd - fi From d41aea0b9c5a464e840744b2bdc556deab68c4f5 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 8 Jan 2024 14:17:09 +0100 Subject: [PATCH 062/211] Delete patches/eth_multicast.diff --- patches/eth_multicast.diff | 109 ------------------------------------- 1 file changed, 109 deletions(-) delete mode 100644 patches/eth_multicast.diff diff --git a/patches/eth_multicast.diff b/patches/eth_multicast.diff deleted file mode 100644 index da7f8691b..000000000 --- a/patches/eth_multicast.diff +++ /dev/null @@ -1,109 +0,0 @@ -diff --git a/components/esp_eth/src/esp_eth_mac_esp.c b/components/esp_eth/src/esp_eth_mac_esp.c -index 7704d9ac48cbe572aefcacd24bfcf6097a9a0562..d59e1e33b4ab3d8a9bde7527ec8f68175bf5dc1e 100644 ---- a/components/esp_eth/src/esp_eth_mac_esp.c -+++ b/components/esp_eth/src/esp_eth_mac_esp.c -@@ -634,7 +634,6 @@ esp_eth_mac_t *esp_eth_mac_new_esp32(const eth_esp32_emac_config_t *esp32_config - emac->smi_mdio_gpio_num = esp32_config->smi_mdio_gpio_num; - emac->flow_control_high_water_mark = FLOW_CONTROL_HIGH_WATER_MARK; - emac->flow_control_low_water_mark = FLOW_CONTROL_LOW_WATER_MARK; -- emac->use_apll = false; - emac->parent.set_mediator = emac_esp32_set_mediator; - emac->parent.init = emac_esp32_init; - emac->parent.deinit = emac_esp32_deinit; -diff --git a/components/esp_eth/src/esp_eth_mac_ksz8851snl.c b/components/esp_eth/src/esp_eth_mac_ksz8851snl.c -index 10ab357fc4c68141361e5038af1856fa769fe168..473195a83b236236a604f26f5ce1765eed2c1d91 100644 ---- a/components/esp_eth/src/esp_eth_mac_ksz8851snl.c -+++ b/components/esp_eth/src/esp_eth_mac_ksz8851snl.c -@@ -298,7 +298,7 @@ static esp_err_t init_set_defaults(emac_ksz8851snl_t *emac) - ESP_GOTO_ON_ERROR(ksz8851_set_bits(emac, KSZ8851_RXDTTR, RXDTTR_INIT_VALUE), err, TAG, "RXDTTR write failed"); - ESP_GOTO_ON_ERROR(ksz8851_set_bits(emac, KSZ8851_RXDBCTR, RXDBCTR_INIT_VALUE), err, TAG, "RXDBCTR write failed"); - ESP_GOTO_ON_ERROR(ksz8851_set_bits(emac, KSZ8851_RXCR1, -- RXCR1_RXUDPFCC | RXCR1_RXTCPFCC | RXCR1_RXIPFCC | RXCR1_RXPAFMA | RXCR1_RXFCE | RXCR1_RXBE | RXCR1_RXUE | RXCR1_RXME), err, TAG, "RXCR1 write failed"); -+ RXCR1_RXUDPFCC | RXCR1_RXTCPFCC | RXCR1_RXIPFCC | RXCR1_RXPAFMA | RXCR1_RXFCE | RXCR1_RXUE | RXCR1_RXME | RXCR1_RXMAFMA | RXCR1_RXAE), err, TAG, "RXCR1 write failed"); - ESP_GOTO_ON_ERROR(ksz8851_set_bits(emac, KSZ8851_RXCR2, - (4 << RXCR2_SRDBL_SHIFT) | RXCR2_IUFFP | RXCR2_RXIUFCEZ | RXCR2_UDPLFE | RXCR2_RXICMPFCC), err, TAG, "RXCR2 write failed"); - ESP_GOTO_ON_ERROR(ksz8851_set_bits(emac, KSZ8851_RXQCR, RXQCR_RXFCTE | RXQCR_ADRFE), err, TAG, "RXQCR write failed"); -@@ -650,13 +650,13 @@ static esp_err_t emac_ksz8851_set_promiscuous(esp_eth_mac_t *mac, bool enable) - if (enable) { - // NOTE(v.chistyakov): set promiscuous mode - ESP_LOGD(TAG, "setting promiscuous mode"); -- rxcr1 |= RXCR1_RXINVF | RXCR1_RXAE; -+ rxcr1 |= RXCR1_RXAE | RXCR1_RXINVF; - rxcr1 &= ~(RXCR1_RXPAFMA | RXCR1_RXMAFMA); - } else { - // NOTE(v.chistyakov): set hash perfect (default) -- ESP_LOGD(TAG, "setting hash perfect mode"); -- rxcr1 |= RXCR1_RXPAFMA; -- rxcr1 &= ~(RXCR1_RXINVF | RXCR1_RXAE | RXCR1_RXMAFMA); -+ ESP_LOGD(TAG, "setting perfect with multicast passed"); -+ rxcr1 |= RXCR1_RXAE| RXCR1_RXPAFMA | RXCR1_RXMAFMA; -+ rxcr1 &= ~RXCR1_RXINVF; - } - ESP_GOTO_ON_ERROR(ksz8851_write_reg(emac, KSZ8851_RXCR1, rxcr1), err, TAG, "RXCR1 write failed"); - err: -diff --git a/components/esp_eth/src/esp_eth_phy_802_3.c b/components/esp_eth/src/esp_eth_phy_802_3.c -index 51a10fd551820bda41db581a3f65d63f63306972..785a0c0feb7725e5f9ce7174220d4df37cb14b45 100644 ---- a/components/esp_eth/src/esp_eth_phy_802_3.c -+++ b/components/esp_eth/src/esp_eth_phy_802_3.c -@@ -302,16 +302,18 @@ esp_err_t esp_eth_phy_802_3_detect_phy_addr(esp_eth_mediator_t *eth, int *detect - } - int addr_try = 0; - uint32_t reg_value = 0; -- for (; addr_try < 16; addr_try++) { -- eth->phy_reg_read(eth, addr_try, ETH_PHY_IDR1_REG_ADDR, ®_value); -- if (reg_value != 0xFFFF && reg_value != 0x00) { -- *detected_addr = addr_try; -- break; -+ for (int i = 0; i < 3; i++){ -+ for (addr_try = 0; addr_try < 32; addr_try++) { -+ eth->phy_reg_read(eth, addr_try, ETH_PHY_IDR1_REG_ADDR, ®_value); -+ if (reg_value != 0xFFFF && reg_value != 0x00) { -+ *detected_addr = addr_try; -+ break; -+ } -+ } -+ if (addr_try < 32) { -+ ESP_LOGD(TAG, "Found PHY address: %d", addr_try); -+ return ESP_OK; - } -- } -- if (addr_try < 16) { -- ESP_LOGD(TAG, "Found PHY address: %d", addr_try); -- return ESP_OK; - } - ESP_LOGE(TAG, "No PHY device detected"); - return ESP_ERR_NOT_FOUND; -diff --git a/components/esp_eth/src/esp_eth_phy_dm9051.c b/components/esp_eth/src/esp_eth_phy_dm9051.c -index d8f9bad9fc8a4da396f65c47f283335bf5448b2f..6db49f8fad0adacf78c52e78525b856bfb53b643 100644 ---- a/components/esp_eth/src/esp_eth_phy_dm9051.c -+++ b/components/esp_eth/src/esp_eth_phy_dm9051.c -@@ -95,7 +95,7 @@ static esp_err_t dm9051_update_link_duplex_speed(phy_dm9051_t *dm9051) - eth_duplex_t duplex = ETH_DUPLEX_HALF; - uint32_t peer_pause_ability = false; - bmsr_reg_t bmsr; -- dscsr_reg_t dscsr; -+ bmcr_reg_t bmcr; - anlpar_reg_t anlpar; - // BMSR is a latch low register - // after power up, the first latched value must be 0, which means down -@@ -108,17 +108,9 @@ static esp_err_t dm9051_update_link_duplex_speed(phy_dm9051_t *dm9051) - if (dm9051->phy_802_3.link_status != link) { - /* when link up, read negotiation result */ - if (link == ETH_LINK_UP) { -- ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ETH_PHY_DSCSR_REG_ADDR, &(dscsr.val)), err, TAG, "read DSCSR failed"); -- if (dscsr.fdx100 || dscsr.hdx100) { -- speed = ETH_SPEED_100M; -- } else { -- speed = ETH_SPEED_10M; -- } -- if (dscsr.fdx100 || dscsr.fdx10) { -- duplex = ETH_DUPLEX_FULL; -- } else { -- duplex = ETH_DUPLEX_HALF; -- } -+ ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); -+ speed = bmcr.speed_select == 1 ? ETH_SPEED_100M : ETH_SPEED_10M; -+ duplex = bmcr.duplex_mode == 1 ? ETH_DUPLEX_FULL : ETH_DUPLEX_HALF; - ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_SPEED, (void *)speed), err, TAG, "change speed failed"); - ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_DUPLEX, (void *)duplex), err, TAG, "change duplex failed"); - /* if we're in duplex mode, and peer has the flow control ability */ From 1a1f0fa0c749b115d7233e934a7e125f0a0840a2 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 8 Jan 2024 14:17:16 +0100 Subject: [PATCH 063/211] Delete patches/spi_eth.diff --- patches/spi_eth.diff | 1139 ------------------------------------------ 1 file changed, 1139 deletions(-) delete mode 100644 patches/spi_eth.diff diff --git a/patches/spi_eth.diff b/patches/spi_eth.diff deleted file mode 100644 index 1e57dbef1..000000000 --- a/patches/spi_eth.diff +++ /dev/null @@ -1,1139 +0,0 @@ -diff --git a/components/esp_eth/include/esp_eth_mac.h b/components/esp_eth/include/esp_eth_mac.h -index dfc1af2c73b5e6a872a5c0583e0223ca86b49ae2..885d332d4363e093d84af1a196c532450386b8ce 100644 ---- a/components/esp_eth/include/esp_eth_mac.h -+++ b/components/esp_eth/include/esp_eth_mac.h -@@ -1,5 +1,5 @@ - /* -- * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD -+ * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -@@ -470,15 +470,113 @@ typedef struct { - esp_eth_mac_t *esp_eth_mac_new_esp32(const eth_esp32_emac_config_t *esp32_config, const eth_mac_config_t *config); - #endif // CONFIG_ETH_USE_ESP32_EMAC - -+#if CONFIG_ETH_USE_SPI_ETHERNET -+/** -+ * @brief Custom SPI Driver Configuration. -+ * This structure declares configuration and callback functions to access Ethernet SPI module via -+ * user's custom SPI driver. -+ * -+ */ -+typedef struct -+{ -+ /** -+ * @brief Custom driver specific configuration data used by `init()` function. -+ * -+ * @note Type and its content is fully under user's control -+ * -+ */ -+ void *config; -+ -+ /** -+ * @brief Custom driver SPI Initialization -+ * -+ * @param[in] spi_config: Custom driver specific configuration -+ * -+ * @return -+ * - spi_ctx: when initialization is successful, a pointer to context structure holding all variables -+ * needed for subsequent SPI access operations (e.g. SPI bus identification, mutexes, etc.) -+ * - NULL: driver initialization failed -+ * -+ * @note return type and its content is fully under user's control -+ */ -+ void *(*init)(const void *spi_config); -+ -+ /** -+ * @brief Custom driver De-initialization -+ * -+ * @param[in] spi_ctx: a pointer to driver specific context structure -+ * -+ * @return -+ * - ESP_OK: driver de-initialization was successful -+ * - ESP_FAIL: driver de-initialization failed -+ * - any other failure codes are allowed to be used to provide failure isolation -+ */ -+ esp_err_t (*deinit)(void *spi_ctx); -+ -+ /** -+ * @brief Custom driver SPI read -+ * -+ * @note The read function is responsible to construct command, address and data fields -+ * of the SPI frame in format expected by particular SPI Ethernet module -+ * -+ * @param[in] spi_ctx: a pointer to driver specific context structure -+ * @param[in] cmd: command -+ * @param[in] addr: register address -+ * @param[out] data: read data -+ * @param[in] data_len: read data length in bytes -+ * -+ * @return -+ * - ESP_OK: read was successful -+ * - ESP_FAIL: read failed -+ * - any other failure codes are allowed to be used to provide failure isolation -+ */ -+ esp_err_t (*read)(void *spi_ctx, uint32_t cmd, uint32_t addr, void *data, uint32_t data_len); -+ -+ /** -+ * @brief Custom driver SPI write -+ * -+ * @note The write function is responsible to construct command, address and data fields -+ * of the SPI frame in format expected by particular SPI Ethernet module -+ * -+ * @param[in] spi_ctx: a pointer to driver specific context structure -+ * @param[in] cmd: command -+ * @param[in] addr: register address -+ * @param[in] data: data to write -+ * @param[in] data_len: length of data to write in bytes -+ * -+ * @return -+ * - ESP_OK: write was successful -+ * - ESP_FAIL: write failed -+ * - any other failure codes are allowed to be used to provide failure isolation -+ */ -+ esp_err_t (*write)(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *data, uint32_t data_len); -+} eth_spi_custom_driver_t; -+ -+/** -+ * @brief Default configuration of the custom SPI driver. -+ * Internal ESP-IDF SPI Master driver is used by default. -+ * -+ */ -+#define ETH_DEFAULT_SPI \ -+ { \ -+ .config = NULL, \ -+ .init = NULL, \ -+ .deinit = NULL, \ -+ .read = NULL, \ -+ .write = NULL \ -+ } -+#endif // CONFIG_ETH_USE_SPI_ETHERNET -+ - #if CONFIG_ETH_SPI_ETHERNET_DM9051 - /** - * @brief DM9051 specific configuration - * - */ - typedef struct { -- spi_host_device_t spi_host_id; /*!< SPI peripheral */ -- spi_device_interface_config_t *spi_devcfg; /*!< SPI device configuration */ - int int_gpio_num; /*!< Interrupt GPIO number */ -+ spi_host_device_t spi_host_id; /*!< SPI peripheral (this field is invalid when custom SPI driver is defined) */ -+ spi_device_interface_config_t *spi_devcfg; /*!< SPI device configuration (this field is invalid when custom SPI driver is defined) */ -+ eth_spi_custom_driver_t custom_spi_driver; /*!< Custom SPI driver definitions */ - } eth_dm9051_config_t; - - /** -@@ -487,9 +585,10 @@ typedef struct { - */ - #define ETH_DM9051_DEFAULT_CONFIG(spi_host, spi_devcfg_p) \ - { \ -+ .int_gpio_num = 4, \ - .spi_host_id = spi_host, \ - .spi_devcfg = spi_devcfg_p, \ -- .int_gpio_num = 4, \ -+ .custom_spi_driver = ETH_DEFAULT_SPI, \ - } - - /** -@@ -511,9 +610,10 @@ esp_eth_mac_t *esp_eth_mac_new_dm9051(const eth_dm9051_config_t *dm9051_config, - * - */ - typedef struct { -- spi_host_device_t spi_host_id; /*!< SPI peripheral */ -- spi_device_interface_config_t *spi_devcfg; /*!< SPI device configuration */ - int int_gpio_num; /*!< Interrupt GPIO number */ -+ spi_host_device_t spi_host_id; /*!< SPI peripheral (this field is invalid when custom SPI driver is defined)*/ -+ spi_device_interface_config_t *spi_devcfg; /*!< SPI device configuration (this field is invalid when custom SPI driver is defined)*/ -+ eth_spi_custom_driver_t custom_spi_driver; /*!< Custom SPI driver definitions */ - } eth_w5500_config_t; - - /** -@@ -521,10 +621,11 @@ typedef struct { - * - */ - #define ETH_W5500_DEFAULT_CONFIG(spi_host, spi_devcfg_p) \ -- { \ -- .spi_host_id = spi_host, \ -- .spi_devcfg = spi_devcfg_p, \ -- .int_gpio_num = 4, \ -+ { \ -+ .int_gpio_num = 4, \ -+ .spi_host_id = spi_host, \ -+ .spi_devcfg = spi_devcfg_p, \ -+ .custom_spi_driver = ETH_DEFAULT_SPI, \ - } - - /** -@@ -546,9 +647,10 @@ esp_eth_mac_t *esp_eth_mac_new_w5500(const eth_w5500_config_t *w5500_config, con - * - */ - typedef struct { -- spi_host_device_t spi_host_id; /*!< SPI peripheral */ -- spi_device_interface_config_t *spi_devcfg; /*!< SPI device configuration */ - int int_gpio_num; /*!< Interrupt GPIO number */ -+ spi_host_device_t spi_host_id; /*!< SPI peripheral (this field is invalid when custom SPI driver is defined) */ -+ spi_device_interface_config_t *spi_devcfg; /*!< SPI device configuration (this field is invalid when custom SPI driver is defined) */ -+ eth_spi_custom_driver_t custom_spi_driver; /*!< Custom SPI driver definitions */ - } eth_ksz8851snl_config_t; - - /** -@@ -557,9 +659,10 @@ typedef struct { - */ - #define ETH_KSZ8851SNL_DEFAULT_CONFIG(spi_host, spi_devcfg_p) \ - { \ -+ .int_gpio_num = 4, \ - .spi_host_id = spi_host, \ - .spi_devcfg = spi_devcfg_p, \ -- .int_gpio_num = 14, \ -+ .custom_spi_driver = ETH_DEFAULT_SPI, \ - } - - /** -diff --git a/components/esp_eth/src/esp_eth_mac_dm9051.c b/components/esp_eth/src/esp_eth_mac_dm9051.c -index b0d339cc93d1d6ef39b1e819102c220d431114b2..ba796121b7065ba984cfbc683283e82a6702a04a 100644 ---- a/components/esp_eth/src/esp_eth_mac_dm9051.c -+++ b/components/esp_eth/src/esp_eth_mac_dm9051.c -@@ -1,5 +1,5 @@ - /* -- * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD -+ * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -@@ -47,11 +47,23 @@ typedef struct { - uint8_t length_high; - } dm9051_rx_header_t; - -+typedef struct { -+ spi_device_handle_t hdl; -+ SemaphoreHandle_t lock; -+} spi_info_t; -+ -+typedef struct { -+ void *ctx; -+ void *(*init)(const void *spi_config); -+ esp_err_t (*deinit)(void *spi_ctx); -+ esp_err_t (*read)(void *spi_ctx, uint32_t cmd, uint32_t addr, void *data, uint32_t data_len); -+ esp_err_t (*write)(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *data, uint32_t data_len); -+} spi_interface_t; -+ - typedef struct { - esp_eth_mac_t parent; - esp_eth_mediator_t *eth; -- spi_device_handle_t spi_hdl; -- SemaphoreHandle_t spi_lock; -+ spi_interface_t spi; - TaskHandle_t rx_task_hdl; - uint32_t sw_reset_timeout_ms; - int int_gpio_num; -@@ -61,89 +73,137 @@ typedef struct { - uint8_t *rx_buffer; - } emac_dm9051_t; - --static inline bool dm9051_lock(emac_dm9051_t *emac) -+static void *dm9051_spi_init(const void *spi_config) -+{ -+ void *ret = NULL; -+ eth_dm9051_config_t *dm9051_config = (eth_dm9051_config_t *)spi_config; -+ spi_info_t *spi = calloc(1, sizeof(spi_info_t)); -+ ESP_GOTO_ON_FALSE(spi, NULL, err, TAG, "no memory for SPI context data"); -+ -+ /* SPI device init */ -+ spi_device_interface_config_t spi_devcfg; -+ spi_devcfg = *(dm9051_config->spi_devcfg); -+ if (dm9051_config->spi_devcfg->command_bits == 0 && dm9051_config->spi_devcfg->address_bits == 0) { -+ /* configure default SPI frame format */ -+ spi_devcfg.command_bits = 1; -+ spi_devcfg.address_bits = 7; -+ } else { -+ ESP_GOTO_ON_FALSE(dm9051_config->spi_devcfg->command_bits == 1 && dm9051_config->spi_devcfg->address_bits == 7, -+ NULL, err, TAG, "incorrect SPI frame format (command_bits/address_bits)"); -+ } -+ ESP_GOTO_ON_FALSE(spi_bus_add_device(dm9051_config->spi_host_id, &spi_devcfg, &spi->hdl) == ESP_OK, -+ NULL, err, TAG, "adding device to SPI host #%d failed", dm9051_config->spi_host_id + 1); -+ -+ /* create mutex */ -+ spi->lock = xSemaphoreCreateMutex(); -+ ESP_GOTO_ON_FALSE(spi->lock, NULL, err, TAG, "create lock failed"); -+ -+ ret = spi; -+ return ret; -+err: -+ if (spi) { -+ if (spi->lock) { -+ vSemaphoreDelete(spi->lock); -+ } -+ free(spi); -+ } -+ return ret; -+} -+ -+static esp_err_t dm9051_spi_deinit(void *spi_ctx) - { -- return xSemaphoreTake(emac->spi_lock, pdMS_TO_TICKS(DM9051_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; -+ esp_err_t ret = ESP_OK; -+ spi_info_t *spi = (spi_info_t *)spi_ctx; -+ -+ spi_bus_remove_device(spi->hdl); -+ vSemaphoreDelete(spi->lock); -+ -+ free(spi); -+ return ret; - } - --static inline bool dm9051_unlock(emac_dm9051_t *emac) -+static inline bool dm9051_spi_lock(spi_info_t *spi) - { -- return xSemaphoreGive(emac->spi_lock) == pdTRUE; -+ return xSemaphoreTake(spi->lock, pdMS_TO_TICKS(DM9051_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; - } - --/** -- * @brief write value to dm9051 internal register -- */ --static esp_err_t dm9051_register_write(emac_dm9051_t *emac, uint8_t reg_addr, uint8_t value) -+static inline bool dm9051_spi_unlock(spi_info_t *spi) -+{ -+ return xSemaphoreGive(spi->lock) == pdTRUE; -+} -+ -+static esp_err_t dm9051_spi_write(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *value, uint32_t len) - { - esp_err_t ret = ESP_OK; -+ spi_info_t *spi = (spi_info_t *)spi_ctx; -+ - spi_transaction_t trans = { -- .cmd = DM9051_SPI_WR, -- .addr = reg_addr, -- .length = 8, -- .flags = SPI_TRANS_USE_TXDATA -+ .cmd = cmd, -+ .addr = addr, -+ .length = 8 * len, -+ .tx_buffer = value - }; -- trans.tx_data[0] = value; -- if (dm9051_lock(emac)) { -- if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) { -+ if (dm9051_spi_lock(spi)) { -+ if (spi_device_polling_transmit(spi->hdl, &trans) != ESP_OK) { - ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); - ret = ESP_FAIL; - } -- dm9051_unlock(emac); -+ dm9051_spi_unlock(spi); - } else { - ret = ESP_ERR_TIMEOUT; - } - return ret; - } - --/** -- * @brief read value from dm9051 internal register -- */ --static esp_err_t dm9051_register_read(emac_dm9051_t *emac, uint8_t reg_addr, uint8_t *value) -+static esp_err_t dm9051_spi_read(void *spi_ctx, uint32_t cmd, uint32_t addr, void *value, uint32_t len) - { - esp_err_t ret = ESP_OK; -+ spi_info_t *spi = (spi_info_t *)spi_ctx; -+ - spi_transaction_t trans = { -- .cmd = DM9051_SPI_RD, -- .addr = reg_addr, -- .length = 8, -- .flags = SPI_TRANS_USE_TXDATA | SPI_TRANS_USE_RXDATA -+ .flags = len <= 4 ? SPI_TRANS_USE_RXDATA : 0, // use direct reads for registers to prevent overwrites by 4-byte boundary writes -+ .cmd = cmd, -+ .addr = addr, -+ .length = 8 * len, -+ .rx_buffer = value - }; -- if (dm9051_lock(emac)) { -- if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) { -+ if (dm9051_spi_lock(spi)) { -+ if (spi_device_polling_transmit(spi->hdl, &trans) != ESP_OK) { - ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); - ret = ESP_FAIL; -- } else { -- *value = trans.rx_data[0]; - } -- dm9051_unlock(emac); -+ dm9051_spi_unlock(spi); - } else { - ret = ESP_ERR_TIMEOUT; - } -+ if ((trans.flags&SPI_TRANS_USE_RXDATA) && len <= 4) { -+ memcpy(value, trans.rx_data, len); // copy register values to output -+ } - return ret; - } - -+/** -+ * @brief write value to dm9051 internal register -+ */ -+static esp_err_t dm9051_register_write(emac_dm9051_t *emac, uint8_t reg_addr, uint8_t value) -+{ -+ return emac->spi.write(emac->spi.ctx, DM9051_SPI_WR, reg_addr, &value, 1); -+} -+ -+/** -+ * @brief read value from dm9051 internal register -+ */ -+static esp_err_t dm9051_register_read(emac_dm9051_t *emac, uint8_t reg_addr, uint8_t *value) -+{ -+ return emac->spi.read(emac->spi.ctx, DM9051_SPI_RD, reg_addr, value, 1); -+} -+ - /** - * @brief write buffer to dm9051 internal memory - */ - static esp_err_t dm9051_memory_write(emac_dm9051_t *emac, uint8_t *buffer, uint32_t len) - { -- esp_err_t ret = ESP_OK; -- spi_transaction_t trans = { -- .cmd = DM9051_SPI_WR, -- .addr = DM9051_MWCMD, -- .length = len * 8, -- .tx_buffer = buffer -- }; -- if (dm9051_lock(emac)) { -- if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) { -- ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); -- ret = ESP_FAIL; -- } -- dm9051_unlock(emac); -- } else { -- ret = ESP_ERR_TIMEOUT; -- } -- return ret; -+ return emac->spi.write(emac->spi.ctx, DM9051_SPI_WR, DM9051_MWCMD, buffer, len); - } - - /** -@@ -151,23 +211,7 @@ static esp_err_t dm9051_memory_write(emac_dm9051_t *emac, uint8_t *buffer, uint3 - */ - static esp_err_t dm9051_memory_read(emac_dm9051_t *emac, uint8_t *buffer, uint32_t len) - { -- esp_err_t ret = ESP_OK; -- spi_transaction_t trans = { -- .cmd = DM9051_SPI_RD, -- .addr = DM9051_MRCMD, -- .length = len * 8, -- .rx_buffer = buffer -- }; -- if (dm9051_lock(emac)) { -- if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) { -- ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); -- ret = ESP_FAIL; -- } -- dm9051_unlock(emac); -- } else { -- ret = ESP_ERR_TIMEOUT; -- } -- return ret; -+ return emac->spi.read(emac->spi.ctx, DM9051_SPI_RD, DM9051_MRCMD, buffer, len); - } - - /** -@@ -175,23 +219,7 @@ static esp_err_t dm9051_memory_read(emac_dm9051_t *emac, uint8_t *buffer, uint32 - */ - static esp_err_t dm9051_memory_peek(emac_dm9051_t *emac, uint8_t *buffer, uint32_t len) - { -- esp_err_t ret = ESP_OK; -- spi_transaction_t trans = { -- .cmd = DM9051_SPI_RD, -- .addr = DM9051_MRCMDX1, -- .length = len * 8, -- .rx_buffer = buffer -- }; -- if (dm9051_lock(emac)) { -- if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) { -- ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); -- ret = ESP_FAIL; -- } -- dm9051_unlock(emac); -- } else { -- ret = ESP_ERR_TIMEOUT; -- } -- return ret; -+ return emac->spi.read(emac->spi.ctx, DM9051_SPI_RD, DM9051_MRCMDX1, buffer, len); - } - - /** -@@ -840,8 +868,7 @@ static esp_err_t emac_dm9051_del(esp_eth_mac_t *mac) - { - emac_dm9051_t *emac = __containerof(mac, emac_dm9051_t, parent); - vTaskDelete(emac->rx_task_hdl); -- spi_bus_remove_device(emac->spi_hdl); -- vSemaphoreDelete(emac->spi_lock); -+ emac->spi.deinit(emac->spi.ctx); - heap_caps_free(emac->rx_buffer); - free(emac); - return ESP_OK; -@@ -857,19 +884,6 @@ esp_eth_mac_t *esp_eth_mac_new_dm9051(const eth_dm9051_config_t *dm9051_config, - ESP_GOTO_ON_FALSE(emac, NULL, err, TAG, "calloc emac failed"); - /* dm9051 receive is driven by interrupt only for now*/ - ESP_GOTO_ON_FALSE(dm9051_config->int_gpio_num >= 0, NULL, err, TAG, "error interrupt gpio number"); -- /* SPI device init */ -- spi_device_interface_config_t spi_devcfg; -- memcpy(&spi_devcfg, dm9051_config->spi_devcfg, sizeof(spi_device_interface_config_t)); -- if (dm9051_config->spi_devcfg->command_bits == 0 && dm9051_config->spi_devcfg->address_bits == 0) { -- /* configure default SPI frame format */ -- spi_devcfg.command_bits = 1; -- spi_devcfg.address_bits = 7; -- } else { -- ESP_GOTO_ON_FALSE(dm9051_config->spi_devcfg->command_bits == 1 || dm9051_config->spi_devcfg->address_bits == 7, -- NULL, err, TAG, "incorrect SPI frame format (command_bits/address_bits)"); -- } -- ESP_GOTO_ON_FALSE(spi_bus_add_device(dm9051_config->spi_host_id, &spi_devcfg, &emac->spi_hdl) == ESP_OK, -- NULL, err, TAG, "adding device to SPI host #%d failed", dm9051_config->spi_host_id + 1); - /* bind methods and attributes */ - emac->sw_reset_timeout_ms = mac_config->sw_reset_timeout_ms; - emac->int_gpio_num = dm9051_config->int_gpio_num; -@@ -891,9 +905,26 @@ esp_eth_mac_t *esp_eth_mac_new_dm9051(const eth_dm9051_config_t *dm9051_config, - emac->parent.enable_flow_ctrl = emac_dm9051_enable_flow_ctrl; - emac->parent.transmit = emac_dm9051_transmit; - emac->parent.receive = emac_dm9051_receive; -- /* create mutex */ -- emac->spi_lock = xSemaphoreCreateMutex(); -- ESP_GOTO_ON_FALSE(emac->spi_lock, NULL, err, TAG, "create lock failed"); -+ -+ if (dm9051_config->custom_spi_driver.init != NULL && dm9051_config->custom_spi_driver.deinit != NULL -+ && dm9051_config->custom_spi_driver.read != NULL && dm9051_config->custom_spi_driver.write != NULL) { -+ ESP_LOGD(TAG, "Using user's custom SPI Driver"); -+ emac->spi.init = dm9051_config->custom_spi_driver.init; -+ emac->spi.deinit = dm9051_config->custom_spi_driver.deinit; -+ emac->spi.read = dm9051_config->custom_spi_driver.read; -+ emac->spi.write = dm9051_config->custom_spi_driver.write; -+ /* Custom SPI driver device init */ -+ ESP_GOTO_ON_FALSE((emac->spi.ctx = emac->spi.init(dm9051_config->custom_spi_driver.config)) != NULL, NULL, err, TAG, "SPI initialization failed"); -+ } else { -+ ESP_LOGD(TAG, "Using default SPI Driver"); -+ emac->spi.init = dm9051_spi_init; -+ emac->spi.deinit = dm9051_spi_deinit; -+ emac->spi.read = dm9051_spi_read; -+ emac->spi.write = dm9051_spi_write; -+ /* SPI device init */ -+ ESP_GOTO_ON_FALSE((emac->spi.ctx = emac->spi.init(dm9051_config)) != NULL, NULL, err, TAG, "SPI initialization failed"); -+ } -+ - /* create dm9051 task */ - BaseType_t core_num = tskNO_AFFINITY; - if (mac_config->flags & ETH_MAC_FLAG_PIN_TO_CORE) { -@@ -913,8 +944,8 @@ err: - if (emac->rx_task_hdl) { - vTaskDelete(emac->rx_task_hdl); - } -- if (emac->spi_lock) { -- vSemaphoreDelete(emac->spi_lock); -+ if (emac->spi.ctx) { -+ emac->spi.deinit(emac->spi.ctx); - } - heap_caps_free(emac->rx_buffer); - free(emac); -diff --git a/components/esp_eth/src/esp_eth_mac_ksz8851snl.c b/components/esp_eth/src/esp_eth_mac_ksz8851snl.c -index b6aea4df90ead8dc2162e0735bdc310717881c97..cda12f0159835ea1cb818736bdc2611056b131ff 100644 ---- a/components/esp_eth/src/esp_eth_mac_ksz8851snl.c -+++ b/components/esp_eth/src/esp_eth_mac_ksz8851snl.c -@@ -3,7 +3,7 @@ - * - * SPDX-License-Identifier: MIT - * -- * SPDX-FileContributor: 2021-2022 Espressif Systems (Shanghai) CO LTD -+ * SPDX-FileContributor: 2021-2023 Espressif Systems (Shanghai) CO LTD - */ - - #include <string.h> -@@ -22,10 +22,22 @@ - - #define KSZ8851_ETH_MAC_RX_BUF_SIZE_AUTO (0) - -+typedef struct { -+ spi_device_handle_t hdl; -+} spi_info_t; -+ -+typedef struct { -+ void *ctx; -+ void *(*init)(const void *spi_config); -+ esp_err_t (*deinit)(void *spi_ctx); -+ esp_err_t (*read)(void *spi_ctx, uint32_t cmd,uint32_t addr, void *data, uint32_t data_len); -+ esp_err_t (*write)(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *data, uint32_t data_len); -+} spi_interface_t; -+ - typedef struct { - esp_eth_mac_t parent; - esp_eth_mediator_t *eth; -- spi_device_handle_t spi_hdl; -+ spi_interface_t spi; - SemaphoreHandle_t spi_lock; - TaskHandle_t rx_task_hdl; - uint32_t sw_reset_timeout_ms; -@@ -73,6 +85,95 @@ IRAM_ATTR static void ksz8851_isr_handler(void *arg) - } - } - -+static void *ksz8851_spi_init(const void *spi_config) -+{ -+ void *ret = NULL; -+ eth_ksz8851snl_config_t *ksz8851snl_config = (eth_ksz8851snl_config_t *)spi_config; -+ spi_info_t *spi = calloc(1, sizeof(spi_info_t)); -+ ESP_GOTO_ON_FALSE(spi, NULL, err, TAG, "no memory for SPI context data"); -+ -+ // SPI device init -+ ESP_GOTO_ON_FALSE(spi_bus_add_device(ksz8851snl_config->spi_host_id, ksz8851snl_config->spi_devcfg, &spi->hdl) == ESP_OK, NULL, -+ err, TAG, "adding device to SPI host #%d failed", ksz8851snl_config->spi_host_id + 1); -+ ret = spi; -+ return ret; -+err: -+ if (spi) { -+ free(spi); -+ } -+ return ret; -+} -+ -+static esp_err_t ksz8851_spi_deinit(void *spi_ctx) -+{ -+ esp_err_t ret = ESP_OK; -+ spi_info_t *spi = (spi_info_t *)spi_ctx; -+ -+ spi_bus_remove_device(spi->hdl); -+ -+ free(spi); -+ return ret; -+} -+ -+static esp_err_t ksz8851_spi_read(void *spi_ctx, uint32_t cmd, uint32_t addr, void *value, uint32_t len) -+{ -+ esp_err_t ret = ESP_OK; -+ spi_info_t *spi = (spi_info_t *)spi_ctx; -+ -+ spi_transaction_ext_t trans = { -+ .base.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY | (len <= 4 ? SPI_TRANS_USE_RXDATA : 0), -+ .base.cmd = cmd, -+ .base.addr = addr, -+ .base.length = 8 * len, -+ .base.rx_buffer = value, -+ .command_bits = KSZ8851_SPI_COMMAND_BITS -+ }; -+ if (cmd >= KSZ8851_SPI_COMMAND_READ_FIFO) { -+ trans.address_bits = 8 - KSZ8851_SPI_COMMAND_BITS; -+ } else { -+ trans.address_bits = 16 - KSZ8851_SPI_COMMAND_BITS; -+ } -+ -+ // No need for mutex here since SPI access is protected at higher layer of this driver -+ if (spi_device_polling_transmit(spi->hdl, &trans.base) != ESP_OK) { -+ ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); -+ ret = ESP_FAIL; -+ } -+ -+ if ((trans.base.flags & SPI_TRANS_USE_RXDATA) && len <= 4) { -+ memcpy(value, trans.base.rx_data, len); // copy register values to output -+ } -+ return ret; -+} -+ -+static esp_err_t ksz8851_spi_write(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *value, uint32_t len) -+{ -+ esp_err_t ret = ESP_OK; -+ spi_info_t *spi = (spi_info_t *)spi_ctx; -+ -+ spi_transaction_ext_t trans = { -+ .base.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY, -+ .base.cmd = cmd, -+ .base.addr = addr, -+ .base.length = 8 * len, -+ .base.tx_buffer = value, -+ .command_bits = KSZ8851_SPI_COMMAND_BITS -+ }; -+ if (cmd >= KSZ8851_SPI_COMMAND_READ_FIFO) { -+ trans.address_bits = 8 - KSZ8851_SPI_COMMAND_BITS; -+ } else { -+ trans.address_bits = 16 - KSZ8851_SPI_COMMAND_BITS; -+ } -+ -+ // No need for mutex here since SPI access is protected at higher layer of this driver -+ if (spi_device_polling_transmit(spi->hdl, &trans.base) != ESP_OK) { -+ ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); -+ ret = ESP_FAIL; -+ } -+ -+ return ret; -+} -+ - static inline bool ksz8851_mutex_lock(emac_ksz8851snl_t *emac) - { - return xSemaphoreTakeRecursive(emac->spi_lock, pdMS_TO_TICKS(KSZ8851_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; -@@ -83,70 +184,49 @@ static inline bool ksz8851_mutex_unlock(emac_ksz8851snl_t *emac) - return xSemaphoreGiveRecursive(emac->spi_lock) == pdTRUE; - } - --static esp_err_t ksz8851_read_reg(emac_ksz8851snl_t *emac, uint32_t address, uint16_t *value) -+static esp_err_t ksz8851_read_reg(emac_ksz8851snl_t *emac, uint32_t reg_addr, uint16_t *value) - { - esp_err_t ret = ESP_OK; - ESP_GOTO_ON_FALSE(value != NULL, ESP_ERR_INVALID_ARG, err, TAG, "out pointer must not be null"); -- ESP_GOTO_ON_FALSE((address & ~KSZ8851_VALID_ADDRESS_MASK) == 0U, ESP_ERR_INVALID_ARG, err, TAG, "address is out of bounds"); -+ ESP_GOTO_ON_FALSE((reg_addr & ~KSZ8851_VALID_ADDRESS_MASK) == 0U, ESP_ERR_INVALID_ARG, err, TAG, "address is out of bounds"); - -- const unsigned data_size = 16U; // NOTE(v.chistyakov): bits - // NOTE(v.chistyakov): select upper or lower word inside a dword -- const unsigned byte_mask = 0x3U << (KSZ8851_SPI_BYTE_MASK_SHIFT + (address & 0x2U)); -- address <<= KSZ8851_SPI_ADDR_SHIFT; -+ const unsigned byte_mask = 0x3U << (KSZ8851_SPI_BYTE_MASK_SHIFT + (reg_addr & 0x2U)); -+ reg_addr <<= KSZ8851_SPI_ADDR_SHIFT; - -- spi_transaction_ext_t trans = { -- .base.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY | SPI_TRANS_USE_RXDATA, -- .base.cmd = KSZ8851_SPI_COMMAND_READ_REG, -- .base.addr = address | byte_mask, -- .base.length = data_size, -- .command_bits = KSZ8851_SPI_COMMAND_BITS, -- .address_bits = 16 - KSZ8851_SPI_COMMAND_BITS, -- }; -+ // Need to protect SPI access at higher layer of the driver since once packet transmit/receive is started (`SDA Start DMA Access` bit is set), -+ // all registers access are disabled. - if (ksz8851_mutex_lock(emac)) { -- if (spi_device_polling_transmit(emac->spi_hdl, &trans.base) != ESP_OK) { -- ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); -- ret = ESP_FAIL; -- } -- ksz8851_mutex_unlock(emac); -- memcpy(value, trans.base.rx_data, data_size >> 3U); -- ESP_LOGV(TAG, "reading reg 0x%02x == 0x%04x", address, *value); -+ ret = emac->spi.read(emac->spi.ctx, KSZ8851_SPI_COMMAND_READ_REG, reg_addr | byte_mask, value, 2); - } else { - ret = ESP_ERR_TIMEOUT; - } -+ ksz8851_mutex_unlock(emac); -+ ESP_LOGV(TAG, "reading reg 0x%02x == 0x%02x", reg_addr, *value); -+ - err: - return ret; - } - --static esp_err_t ksz8851_write_reg(emac_ksz8851snl_t *emac, uint32_t address, uint16_t value) -+static esp_err_t ksz8851_write_reg(emac_ksz8851snl_t *emac, uint32_t reg_addr, uint16_t value) - { - esp_err_t ret = ESP_OK; -- ESP_GOTO_ON_FALSE((address & ~KSZ8851_VALID_ADDRESS_MASK) == 0U, ESP_ERR_INVALID_ARG, err, TAG, "address is out of bounds"); -- ESP_LOGV(TAG, "writing reg 0x%02x = 0x%04x", address, value); -+ ESP_GOTO_ON_FALSE((reg_addr & ~KSZ8851_VALID_ADDRESS_MASK) == 0U, ESP_ERR_INVALID_ARG, err, TAG, "address is out of bounds"); -+ ESP_LOGV(TAG, "writing reg 0x%02x = 0x%02x", reg_addr, value); - -- const unsigned data_size = 16U; // NOTE(v.chistyakov): bits - // NOTE(v.chistyakov): select upper or lower word inside a dword -- const unsigned byte_mask = 0x3U << (KSZ8851_SPI_BYTE_MASK_SHIFT + (address & 0x2U)); -- address <<= KSZ8851_SPI_ADDR_SHIFT; -+ const unsigned byte_mask = 0x3U << (KSZ8851_SPI_BYTE_MASK_SHIFT + (reg_addr & 0x2U)); -+ reg_addr <<= KSZ8851_SPI_ADDR_SHIFT; - -- spi_transaction_ext_t trans = { -- .base.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY | SPI_TRANS_USE_TXDATA, -- .base.cmd = KSZ8851_SPI_COMMAND_WRITE_REG, -- .base.addr = address | byte_mask, -- .base.length = data_size, -- .command_bits = KSZ8851_SPI_COMMAND_BITS, -- .address_bits = 16 - KSZ8851_SPI_COMMAND_BITS, -- }; -- -- memcpy(trans.base.tx_data, &value, data_size >> 3U); -+ // Need to protect SPI access at higher layer of the driver since once packet transmit/receive is started (`SDA Start DMA Access` bit is set), -+ // all registers access are disabled. - if (ksz8851_mutex_lock(emac)) { -- if (spi_device_polling_transmit(emac->spi_hdl, &trans.base) != ESP_OK) { -- ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); -- ret = ESP_FAIL; -- } -- ksz8851_mutex_unlock(emac); -+ ret = emac->spi.write(emac->spi.ctx, KSZ8851_SPI_COMMAND_WRITE_REG, reg_addr | byte_mask, &value, 2); - } else { - ret = ESP_ERR_TIMEOUT; - } -+ ksz8851_mutex_unlock(emac); -+ - err: - return ret; - } -@@ -313,6 +393,7 @@ static esp_err_t emac_ksz8851snl_transmit(esp_eth_mac_t *mac, uint8_t *buf, uint - ESP_LOGV(TAG, "transmitting frame of size %u", length); - esp_err_t ret = ESP_OK; - emac_ksz8851snl_t *emac = __containerof(mac, emac_ksz8851snl_t, parent); -+ // Lock SPI since once `SDA Start DMA Access` bit is set, all registers access are disabled. - if (!ksz8851_mutex_lock(emac)) { - return ESP_ERR_TIMEOUT; - } -@@ -333,24 +414,12 @@ static esp_err_t emac_ksz8851snl_transmit(esp_eth_mac_t *mac, uint8_t *buf, uint - emac->tx_buffer[3] = (length >> 8U) & 0xFFU; - memcpy(emac->tx_buffer + 4U, buf, length); - -- spi_transaction_ext_t trans = { -- .base.flags = SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_CMD, -- .base.cmd = KSZ8851_SPI_COMMAND_WRITE_FIFO, -- .base.length = transmit_length * 8U, // NOTE(v.chistyakov): bits -- .base.tx_buffer = emac->tx_buffer, -- .command_bits = 2U, -- .address_bits = 6U, -- }; -- - uint16_t ier; - ESP_GOTO_ON_ERROR(ksz8851_read_reg(emac, KSZ8851_IER, &ier), err, TAG, "IER read failed"); - ESP_GOTO_ON_ERROR(ksz8851_write_reg(emac, KSZ8851_IER, 0), err, TAG, "IER write failed"); - - ESP_GOTO_ON_ERROR(ksz8851_set_bits(emac, KSZ8851_RXQCR, RXQCR_SDA), err, TAG, "RXQCR write failed"); -- if (spi_device_polling_transmit(emac->spi_hdl, &trans.base) != ESP_OK) { -- ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); -- ret = ESP_FAIL; -- } -+ ret = emac->spi.write(emac->spi.ctx, KSZ8851_SPI_COMMAND_WRITE_FIFO, 0, emac->tx_buffer, transmit_length); - ESP_GOTO_ON_ERROR(ksz8851_clear_bits(emac, KSZ8851_RXQCR, RXQCR_SDA), err, TAG, "RXQCR write failed"); - - ESP_GOTO_ON_ERROR(ksz8851_write_reg(emac, KSZ8851_IER, ier), err, TAG, "IER write failed"); -@@ -438,23 +507,13 @@ static esp_err_t emac_ksz8851_receive(esp_eth_mac_t *mac, uint8_t *buf, uint32_t - - // NOTE(v.chistyakov): 4 dummy + 4 header + alignment - const unsigned receive_size = 8U + ((byte_count + 3U) & ~0x3U); -- spi_transaction_ext_t trans = { -- .base.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR | SPI_TRANS_VARIABLE_DUMMY, -- .base.cmd = KSZ8851_SPI_COMMAND_READ_FIFO, -- .base.length = receive_size * 8U, // NOTE(v.chistyakov): bits -- .base.rx_buffer = emac->rx_buffer, -- .command_bits = 2U, -- .address_bits = 6U, -- }; -+ // Lock SPI since once `SDA Start DMA Access` bit is set, all registers access are disabled. - if (!ksz8851_mutex_lock(emac)) { - return ESP_ERR_TIMEOUT; - } - ESP_GOTO_ON_ERROR(ksz8851_clear_bits(emac, KSZ8851_RXFDPR, RXFDPR_RXFP_MASK), err, TAG, "RXFDPR write failed"); - ESP_GOTO_ON_ERROR(ksz8851_set_bits(emac, KSZ8851_RXQCR, RXQCR_SDA), err, TAG, "RXQCR write failed"); -- if (spi_device_polling_transmit(emac->spi_hdl, &trans.base) != ESP_OK) { -- ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); -- ret = ESP_FAIL; -- } -+ ret = emac->spi.read(emac->spi.ctx, KSZ8851_SPI_COMMAND_READ_FIFO, 0, emac->rx_buffer, receive_size); - ESP_GOTO_ON_ERROR(ksz8851_clear_bits(emac, KSZ8851_RXQCR, RXQCR_SDA), err, TAG, "RXQCR write failed"); - ksz8851_mutex_unlock(emac); - // NOTE(v.chistyakov): skip 4 dummy, 4 header -@@ -728,7 +787,7 @@ static esp_err_t emac_ksz8851_del(esp_eth_mac_t *mac) - { - emac_ksz8851snl_t *emac = __containerof(mac, emac_ksz8851snl_t, parent); - vTaskDelete(emac->rx_task_hdl); -- spi_bus_remove_device(emac->spi_hdl); -+ emac->spi.deinit(emac->spi.ctx); - vSemaphoreDelete(emac->spi_lock); - heap_caps_free(emac->rx_buffer); - heap_caps_free(emac->tx_buffer); -@@ -748,10 +807,6 @@ esp_eth_mac_t *esp_eth_mac_new_ksz8851snl(const eth_ksz8851snl_config_t *ksz8851 - emac = calloc(1, sizeof(emac_ksz8851snl_t)); - ESP_GOTO_ON_FALSE(emac, NULL, err, TAG, "no mem for MAC instance"); - -- /* SPI device init */ -- ESP_GOTO_ON_FALSE(spi_bus_add_device(ksz8851snl_config->spi_host_id, ksz8851snl_config->spi_devcfg, &emac->spi_hdl) == ESP_OK, -- NULL, err, TAG, "adding device to SPI host #%d failed", ksz8851snl_config->spi_host_id + 1); -- - emac->sw_reset_timeout_ms = mac_config->sw_reset_timeout_ms; - emac->int_gpio_num = ksz8851snl_config->int_gpio_num; - emac->parent.set_mediator = emac_ksz8851_set_mediator; -@@ -772,8 +827,6 @@ esp_eth_mac_t *esp_eth_mac_new_ksz8851snl(const eth_ksz8851snl_config_t *ksz8851 - emac->parent.enable_flow_ctrl = emac_ksz8851_enable_flow_ctrl; - emac->parent.set_peer_pause_ability = emac_ksz8851_set_peer_pause_ability; - emac->parent.del = emac_ksz8851_del; -- emac->spi_lock = xSemaphoreCreateRecursiveMutex(); -- ESP_GOTO_ON_FALSE(emac->spi_lock, NULL, err, TAG, "create lock failed"); - emac->rx_buffer = NULL; - emac->tx_buffer = NULL; - emac->rx_buffer = heap_caps_malloc(KSZ8851_QMU_PACKET_LENGTH + KSZ8851_QMU_PACKET_PADDING, MALLOC_CAP_DMA); -@@ -781,6 +834,29 @@ esp_eth_mac_t *esp_eth_mac_new_ksz8851snl(const eth_ksz8851snl_config_t *ksz8851 - ESP_GOTO_ON_FALSE(emac->rx_buffer, NULL, err, TAG, "RX buffer allocation failed"); - ESP_GOTO_ON_FALSE(emac->tx_buffer, NULL, err, TAG, "TX buffer allocation failed"); - -+ /* create mutex */ -+ emac->spi_lock = xSemaphoreCreateRecursiveMutex(); -+ ESP_GOTO_ON_FALSE(emac->spi_lock, NULL, err, TAG, "create lock failed"); -+ -+ if (ksz8851snl_config->custom_spi_driver.init != NULL && ksz8851snl_config->custom_spi_driver.deinit != NULL -+ && ksz8851snl_config->custom_spi_driver.read != NULL && ksz8851snl_config->custom_spi_driver.write != NULL) { -+ ESP_LOGD(TAG, "Using user's custom SPI Driver"); -+ emac->spi.init = ksz8851snl_config->custom_spi_driver.init; -+ emac->spi.deinit = ksz8851snl_config->custom_spi_driver.deinit; -+ emac->spi.read = ksz8851snl_config->custom_spi_driver.read; -+ emac->spi.write = ksz8851snl_config->custom_spi_driver.write; -+ /* Custom SPI driver device init */ -+ ESP_GOTO_ON_FALSE((emac->spi.ctx = emac->spi.init(ksz8851snl_config->custom_spi_driver.config)) != NULL, NULL, err, TAG, "SPI initialization failed"); -+ } else { -+ ESP_LOGD(TAG, "Using default SPI Driver"); -+ emac->spi.init = ksz8851_spi_init; -+ emac->spi.deinit = ksz8851_spi_deinit; -+ emac->spi.read = ksz8851_spi_read; -+ emac->spi.write = ksz8851_spi_write; -+ /* SPI device init */ -+ ESP_GOTO_ON_FALSE((emac->spi.ctx = emac->spi.init(ksz8851snl_config)) != NULL, NULL, err, TAG, "SPI initialization failed"); -+ } -+ - BaseType_t core_num = tskNO_AFFINITY; - if (mac_config->flags & ETH_MAC_FLAG_PIN_TO_CORE) { - core_num = esp_cpu_get_core_id(); -@@ -798,6 +874,9 @@ err: - if (emac->spi_lock) { - vSemaphoreDelete(emac->spi_lock); - } -+ if (emac->spi.ctx) { -+ emac->spi.deinit(emac->spi.ctx); -+ } - // NOTE(v.chistyakov): safe to call with NULL - heap_caps_free(emac->rx_buffer); - heap_caps_free(emac->tx_buffer); -diff --git a/components/esp_eth/src/esp_eth_mac_w5500.c b/components/esp_eth/src/esp_eth_mac_w5500.c -index 7a7708d0ca8bbbf77b32d9cb01ce34e57cc1f242..5b19d5cfcdfc67105809cbca33e780850b9d4fea 100644 ---- a/components/esp_eth/src/esp_eth_mac_w5500.c -+++ b/components/esp_eth/src/esp_eth_mac_w5500.c -@@ -37,11 +37,23 @@ typedef struct { - uint32_t remain; - }__attribute__((packed)) emac_w5500_auto_buf_info_t; - -+typedef struct { -+ spi_device_handle_t hdl; -+ SemaphoreHandle_t lock; -+} spi_info_t; -+ -+typedef struct { -+ void *ctx; -+ void *(*init)(const void *spi_config); -+ esp_err_t (*deinit)(void *spi_ctx); -+ esp_err_t (*read)(void *spi_ctx, uint32_t cmd,uint32_t addr, void *data, uint32_t data_len); -+ esp_err_t (*write)(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *data, uint32_t data_len); -+} spi_interface_t; -+ - typedef struct { - esp_eth_mac_t parent; - esp_eth_mediator_t *eth; -- spi_device_handle_t spi_hdl; -- SemaphoreHandle_t spi_lock; -+ spi_interface_t spi; - TaskHandle_t rx_task_hdl; - uint32_t sw_reset_timeout_ms; - int int_gpio_num; -@@ -50,64 +62,132 @@ typedef struct { - uint8_t *rx_buffer; - } emac_w5500_t; - --static inline bool w5500_lock(emac_w5500_t *emac) -+static void *w5500_spi_init(const void *spi_config) - { -- return xSemaphoreTake(emac->spi_lock, pdMS_TO_TICKS(W5500_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; -+ void *ret = NULL; -+ eth_w5500_config_t *w5500_config = (eth_w5500_config_t *)spi_config; -+ spi_info_t *spi = calloc(1, sizeof(spi_info_t)); -+ ESP_GOTO_ON_FALSE(spi, NULL, err, TAG, "no memory for SPI context data"); -+ -+ /* SPI device init */ -+ spi_device_interface_config_t spi_devcfg; -+ spi_devcfg = *(w5500_config->spi_devcfg); -+ if (w5500_config->spi_devcfg->command_bits == 0 && w5500_config->spi_devcfg->address_bits == 0) { -+ /* configure default SPI frame format */ -+ spi_devcfg.command_bits = 16; // Actually it's the address phase in W5500 SPI frame -+ spi_devcfg.address_bits = 8; // Actually it's the control phase in W5500 SPI frame -+ } else { -+ ESP_GOTO_ON_FALSE(w5500_config->spi_devcfg->command_bits == 16 && w5500_config->spi_devcfg->address_bits == 8, -+ NULL, err, TAG, "incorrect SPI frame format (command_bits/address_bits)"); -+ } -+ ESP_GOTO_ON_FALSE(spi_bus_add_device(w5500_config->spi_host_id, &spi_devcfg, &spi->hdl) == ESP_OK, NULL, -+ err, TAG, "adding device to SPI host #%d failed", w5500_config->spi_host_id + 1); -+ /* create mutex */ -+ spi->lock = xSemaphoreCreateMutex(); -+ ESP_GOTO_ON_FALSE(spi->lock, NULL, err, TAG, "create lock failed"); -+ -+ ret = spi; -+ return ret; -+err: -+ if (spi) { -+ if (spi->lock) { -+ vSemaphoreDelete(spi->lock); -+ } -+ free(spi); -+ } -+ return ret; - } - --static inline bool w5500_unlock(emac_w5500_t *emac) -+static esp_err_t w5500_spi_deinit(void *spi_ctx) - { -- return xSemaphoreGive(emac->spi_lock) == pdTRUE; -+ esp_err_t ret = ESP_OK; -+ spi_info_t *spi = (spi_info_t *)spi_ctx; -+ -+ spi_bus_remove_device(spi->hdl); -+ vSemaphoreDelete(spi->lock); -+ -+ free(spi); -+ return ret; - } - --static esp_err_t w5500_write(emac_w5500_t *emac, uint32_t address, const void *value, uint32_t len) -+static inline bool w5500_spi_lock(spi_info_t *spi) -+{ -+ return xSemaphoreTake(spi->lock, pdMS_TO_TICKS(W5500_SPI_LOCK_TIMEOUT_MS)) == pdTRUE; -+} -+ -+static inline bool w5500_spi_unlock(spi_info_t *spi) -+{ -+ return xSemaphoreGive(spi->lock) == pdTRUE; -+} -+ -+static esp_err_t w5500_spi_write(void *spi_ctx, uint32_t cmd, uint32_t addr, const void *value, uint32_t len) - { - esp_err_t ret = ESP_OK; -+ spi_info_t *spi = (spi_info_t *)spi_ctx; - - spi_transaction_t trans = { -- .cmd = (address >> W5500_ADDR_OFFSET), -- .addr = ((address & 0xFFFF) | (W5500_ACCESS_MODE_WRITE << W5500_RWB_OFFSET) | W5500_SPI_OP_MODE_VDM), -+ .cmd = cmd, -+ .addr = addr, - .length = 8 * len, - .tx_buffer = value - }; -- if (w5500_lock(emac)) { -- if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) { -+ if (w5500_spi_lock(spi)) { -+ if (spi_device_polling_transmit(spi->hdl, &trans) != ESP_OK) { - ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); - ret = ESP_FAIL; - } -- w5500_unlock(emac); -+ w5500_spi_unlock(spi); - } else { - ret = ESP_ERR_TIMEOUT; - } - return ret; - } - --static esp_err_t w5500_read(emac_w5500_t *emac, uint32_t address, void *value, uint32_t len) -+static esp_err_t w5500_spi_read(void *spi_ctx, uint32_t cmd, uint32_t addr, void *value, uint32_t len) - { - esp_err_t ret = ESP_OK; -+ spi_info_t *spi = (spi_info_t *)spi_ctx; - - spi_transaction_t trans = { - .flags = len <= 4 ? SPI_TRANS_USE_RXDATA : 0, // use direct reads for registers to prevent overwrites by 4-byte boundary writes -- .cmd = (address >> W5500_ADDR_OFFSET), -- .addr = ((address & 0xFFFF) | (W5500_ACCESS_MODE_READ << W5500_RWB_OFFSET) | W5500_SPI_OP_MODE_VDM), -+ .cmd = cmd, -+ .addr = addr, - .length = 8 * len, - .rx_buffer = value - }; -- if (w5500_lock(emac)) { -- if (spi_device_polling_transmit(emac->spi_hdl, &trans) != ESP_OK) { -+ if (w5500_spi_lock(spi)) { -+ if (spi_device_polling_transmit(spi->hdl, &trans) != ESP_OK) { - ESP_LOGE(TAG, "%s(%d): spi transmit failed", __FUNCTION__, __LINE__); - ret = ESP_FAIL; - } -- w5500_unlock(emac); -+ w5500_spi_unlock(spi); - } else { - ret = ESP_ERR_TIMEOUT; - } -- if ((trans.flags&SPI_TRANS_USE_RXDATA) && len <= 4) { -+ if ((trans.flags & SPI_TRANS_USE_RXDATA) && len <= 4) { - memcpy(value, trans.rx_data, len); // copy register values to output - } - return ret; - } - -+static esp_err_t w5500_read(emac_w5500_t *emac, uint32_t address, void *data, uint32_t len) -+{ -+ uint32_t cmd = (address >> W5500_ADDR_OFFSET); // Actually it's the address phase in W5500 SPI frame -+ uint32_t addr = ((address & 0xFFFF) | (W5500_ACCESS_MODE_READ << W5500_RWB_OFFSET) -+ | W5500_SPI_OP_MODE_VDM); // Actually it's the command phase in W5500 SPI frame -+ -+ return emac->spi.read(emac->spi.ctx, cmd, addr, data, len); -+} -+ -+static esp_err_t w5500_write(emac_w5500_t *emac, uint32_t address, const void *data, uint32_t len) -+{ -+ uint32_t cmd = (address >> W5500_ADDR_OFFSET); // Actually it's the address phase in W5500 SPI frame -+ uint32_t addr = ((address & 0xFFFF) | (W5500_ACCESS_MODE_WRITE << W5500_RWB_OFFSET) -+ | W5500_SPI_OP_MODE_VDM); // Actually it's the command phase in W5500 SPI frame -+ -+ return emac->spi.write(emac->spi.ctx, cmd, addr, data, len); -+} -+ - static esp_err_t w5500_send_command(emac_w5500_t *emac, uint8_t command, uint32_t timeout_ms) - { - esp_err_t ret = ESP_OK; -@@ -738,8 +818,7 @@ static esp_err_t emac_w5500_del(esp_eth_mac_t *mac) - { - emac_w5500_t *emac = __containerof(mac, emac_w5500_t, parent); - vTaskDelete(emac->rx_task_hdl); -- spi_bus_remove_device(emac->spi_hdl); -- vSemaphoreDelete(emac->spi_lock); -+ emac->spi.deinit(emac->spi.ctx); - heap_caps_free(emac->rx_buffer); - free(emac); - return ESP_OK; -@@ -754,19 +833,6 @@ esp_eth_mac_t *esp_eth_mac_new_w5500(const eth_w5500_config_t *w5500_config, con - ESP_GOTO_ON_FALSE(emac, NULL, err, TAG, "no mem for MAC instance"); - /* w5500 driver is interrupt driven */ - ESP_GOTO_ON_FALSE(w5500_config->int_gpio_num >= 0, NULL, err, TAG, "invalid interrupt gpio number"); -- /* SPI device init */ -- spi_device_interface_config_t spi_devcfg; -- memcpy(&spi_devcfg, w5500_config->spi_devcfg, sizeof(spi_device_interface_config_t)); -- if (w5500_config->spi_devcfg->command_bits == 0 && w5500_config->spi_devcfg->address_bits == 0) { -- /* configure default SPI frame format */ -- spi_devcfg.command_bits = 16; // Actually it's the address phase in W5500 SPI frame -- spi_devcfg.address_bits = 8; // Actually it's the control phase in W5500 SPI frame -- } else { -- ESP_GOTO_ON_FALSE(w5500_config->spi_devcfg->command_bits == 16 || w5500_config->spi_devcfg->address_bits == 8, -- NULL, err, TAG, "incorrect SPI frame format (command_bits/address_bits)"); -- } -- ESP_GOTO_ON_FALSE(spi_bus_add_device(w5500_config->spi_host_id, &spi_devcfg, &emac->spi_hdl) == ESP_OK, -- NULL, err, TAG, "adding device to SPI host #%d failed", w5500_config->spi_host_id + 1); - /* bind methods and attributes */ - emac->sw_reset_timeout_ms = mac_config->sw_reset_timeout_ms; - emac->int_gpio_num = w5500_config->int_gpio_num; -@@ -788,9 +854,26 @@ esp_eth_mac_t *esp_eth_mac_new_w5500(const eth_w5500_config_t *w5500_config, con - emac->parent.enable_flow_ctrl = emac_w5500_enable_flow_ctrl; - emac->parent.transmit = emac_w5500_transmit; - emac->parent.receive = emac_w5500_receive; -- /* create mutex */ -- emac->spi_lock = xSemaphoreCreateMutex(); -- ESP_GOTO_ON_FALSE(emac->spi_lock, NULL, err, TAG, "create lock failed"); -+ -+ if (w5500_config->custom_spi_driver.init != NULL && w5500_config->custom_spi_driver.deinit != NULL -+ && w5500_config->custom_spi_driver.read != NULL && w5500_config->custom_spi_driver.write != NULL) { -+ ESP_LOGD(TAG, "Using user's custom SPI Driver"); -+ emac->spi.init = w5500_config->custom_spi_driver.init; -+ emac->spi.deinit = w5500_config->custom_spi_driver.deinit; -+ emac->spi.read = w5500_config->custom_spi_driver.read; -+ emac->spi.write = w5500_config->custom_spi_driver.write; -+ /* Custom SPI driver device init */ -+ ESP_GOTO_ON_FALSE((emac->spi.ctx = emac->spi.init(w5500_config->custom_spi_driver.config)) != NULL, NULL, err, TAG, "SPI initialization failed"); -+ } else { -+ ESP_LOGD(TAG, "Using default SPI Driver"); -+ emac->spi.init = w5500_spi_init; -+ emac->spi.deinit = w5500_spi_deinit; -+ emac->spi.read = w5500_spi_read; -+ emac->spi.write = w5500_spi_write; -+ /* SPI device init */ -+ ESP_GOTO_ON_FALSE((emac->spi.ctx = emac->spi.init(w5500_config)) != NULL, NULL, err, TAG, "SPI initialization failed"); -+ } -+ - /* create w5500 task */ - BaseType_t core_num = tskNO_AFFINITY; - if (mac_config->flags & ETH_MAC_FLAG_PIN_TO_CORE) { -@@ -810,8 +893,8 @@ err: - if (emac->rx_task_hdl) { - vTaskDelete(emac->rx_task_hdl); - } -- if (emac->spi_lock) { -- vSemaphoreDelete(emac->spi_lock); -+ if (emac->spi.ctx) { -+ emac->spi.deinit(emac->spi.ctx); - } - heap_caps_free(emac->rx_buffer); - free(emac); From e86a7a9b4dc8bec94f4ed99079c5f6977c204f7e Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 24 Jan 2024 13:28:24 +0100 Subject: [PATCH 064/211] add two cam modules --- configs/defconfig.common | 2 -- 1 file changed, 2 deletions(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index 8dfa7a1b2..896ef78e8 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -217,8 +217,6 @@ CONFIG_LITTLEFS_DISK_VERSION_2_0=y # CONFIG_OV7670_SUPPORT is not set # CONFIG_OV7725_SUPPORT is not set # CONFIG_NT99141_SUPPORT is not set -# CONFIG_OV3660_SUPPORT is not set -# CONFIG_OV5640_SUPPORT is not set # CONFIG_GC2145_SUPPORT is not set # CONFIG_GC032A_SUPPORT is not set # CONFIG_GC0308_SUPPORT is not set From a9c0e89b7e1d7c79a6aab8ff9350177cfc1d4b71 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 27 Jan 2024 17:09:33 +0100 Subject: [PATCH 065/211] Update GH actions --- .github/workflows/push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 82bc556fa..e6566a71b 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -8,7 +8,7 @@ jobs: name: Build Arduino Libs runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: @@ -18,7 +18,7 @@ jobs: - name: Build Arduino Libs run: bash ./build.sh - name: Release - uses: jason2866/action-gh-release@v1.2 + uses: jason2866/action-gh-release@v1.3 with: tag_name: ${{ github.run_number }} body_path: release-info.txt From ca0580653d437b2c9123271e50fc3ff98c241cf3 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 27 Jan 2024 17:54:03 +0100 Subject: [PATCH 066/211] Update python --- .github/workflows/push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index e6566a71b..654bb670a 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -10,9 +10,9 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: '3.11' - name: Install dependencies run: bash ./tools/prepare-ci.sh - name: Build Arduino Libs From 7edc41683d9867c4a2d84cc68cc10b6365b0b9af Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 31 Jan 2024 16:48:52 +0100 Subject: [PATCH 067/211] CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y --- configs/defconfig.common | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/defconfig.common b/configs/defconfig.common index 896ef78e8..62156e7d1 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -188,6 +188,7 @@ CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y CONFIG_OPENSSL_ASSERT_DO_NOTHING=y CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=2048 CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED=y +CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=10 CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=2 CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=4096 From a7372d5838bfdae81724f2a9035b7875838a254e Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 31 Jan 2024 22:07:27 +0100 Subject: [PATCH 068/211] Use MacOS --- tools/prepare-ci.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/prepare-ci.sh b/tools/prepare-ci.sh index 711ce154f..436191a4c 100755 --- a/tools/prepare-ci.sh +++ b/tools/prepare-ci.sh @@ -1,4 +1,14 @@ #!/bin/bash -sudo apt-get install -y gperf cmake ninja-build -pip3 install wheel future pyelftools +# Ubuntu setup +#sudo apt-get install -y gperf cmake ninja-build +#pip3 install wheel future pyelftools + +# MacOS (ARM) setup +brew install gsed +brew install gawk +brew install gperf +brew install ninja +brew install ccache +python -m pip install --upgrade pip +pip install wheel future pyelftools From 34c9e053faf3430d30bd376080a1c041a9a61053 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 31 Jan 2024 22:09:37 +0100 Subject: [PATCH 069/211] Use MacOS ARM runner --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 654bb670a..ef063c8ab 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -6,7 +6,7 @@ on: jobs: build-libs: name: Build Arduino Libs - runs-on: ubuntu-22.04 + runs-on: macos-14 steps: - uses: actions/checkout@v4 - name: Set up Python From c03496862643e3d2f7ce3ed108887f32903a7ce7 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 11 Feb 2024 18:45:27 +0100 Subject: [PATCH 070/211] gawk for MacOS --- tools/archive-build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index a79f23762..62c3df126 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -56,8 +56,8 @@ cp -Rf tools/esp32-arduino-libs arduino-esp32/tools/ cp ../package.json arduino-esp32/package.json cp ../core_version.h arduino-esp32/cores/esp32/core_version.h # Replace "framework-arduinoespressif32" with "framework-arduino-solo1" -awk -i inplace -v cuv1="framework-arduinoespressif32" -v cuv2="framework-arduino-solo1" '{gsub(cuv1,cuv2); print;}' "arduino-esp32/tools/esp32-arduino-libs/esp32/platformio-build.py" -awk -i inplace -v cuv1="framework-arduinoespressif32" -v cuv2="framework-arduino-solo1" '{gsub(cuv1,cuv2); print;}' "arduino-esp32/tools/platformio-build.py" +gawk -i inplace -v cuv1="framework-arduinoespressif32" -v cuv2="framework-arduino-solo1" '{gsub(cuv1,cuv2); print;}' "arduino-esp32/tools/esp32-arduino-libs/esp32/platformio-build.py" +gawk -i inplace -v cuv1="framework-arduinoespressif32" -v cuv2="framework-arduino-solo1" '{gsub(cuv1,cuv2); print;}' "arduino-esp32/tools/platformio-build.py" mv arduino-esp32/ framework-arduinoespressif32/ cd framework-arduinoespressif32/libraries rm -rf **/examples From aa64162b29cf78aeb7f0fc313a99e89640b26662 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 11 Feb 2024 20:12:27 +0100 Subject: [PATCH 071/211] Update prepare-ci.sh --- tools/prepare-ci.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/prepare-ci.sh b/tools/prepare-ci.sh index 436191a4c..52773a90a 100755 --- a/tools/prepare-ci.sh +++ b/tools/prepare-ci.sh @@ -1,10 +1,12 @@ #!/bin/bash # Ubuntu setup +# Change in archive-build.sh gawk to awk #sudo apt-get install -y gperf cmake ninja-build #pip3 install wheel future pyelftools # MacOS (ARM) setup +# Change in archive-build.sh awk to gawk brew install gsed brew install gawk brew install gperf From c7cca1385e34de6597fbbd8cc101e73a398281f0 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 11 Feb 2024 23:15:27 +0100 Subject: [PATCH 072/211] add Arduino Lib Builder branch --- build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 5b707821a..fd58ece3a 100755 --- a/build.sh +++ b/build.sh @@ -146,7 +146,8 @@ IDF_Commit_short=$(git -C "$IDF_PATH" rev-parse --short HEAD || echo "") AR_Commit_short=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "") echo "Framework built from - $IDF_REPO branch [$IDF_BRANCH](https://github.com/$IDF_REPO/tree/$IDF_BRANCH) commit [$IDF_Commit_short](https://github.com/$IDF_REPO/commits/$IDF_BRANCH/#:~:text=$IDF_Commit_short) -- $AR_REPO branch [$AR_BRANCH](https://github.com/$AR_REPO/tree/$AR_BRANCH) commit [$AR_Commit_short](https://github.com/$AR_REPO/commits/$AR_BRANCH/#:~:text=$AR_Commit_short)" >> release-info.txt +- $AR_REPO branch [$AR_BRANCH](https://github.com/$AR_REPO/tree/$AR_BRANCH) commit [$AR_Commit_short](https://github.com/$AR_REPO/commits/$AR_BRANCH/#:~:text=$AR_Commit_short) +- Arduino lib builder branch: $GIT_BRANCH" >> release-info.txt #targets_count=`jq -c '.targets[] | length' configs/builds.json` for target_json in `jq -c '.targets[]' configs/builds.json`; do From 5623359e36480420c45261a798747fd92fab1ff3 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 11 Feb 2024 23:20:20 +0100 Subject: [PATCH 073/211] add env --- .github/workflows/push.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index ef063c8ab..56c1f527d 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -15,6 +15,9 @@ jobs: python-version: '3.11' - name: Install dependencies run: bash ./tools/prepare-ci.sh + - name: Get current branch + run: | + echo "GIT_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV - name: Build Arduino Libs run: bash ./build.sh - name: Release From d07419e53e9313e35f5af1046c5d08ec352d6092 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 14 Feb 2024 16:53:55 +0100 Subject: [PATCH 074/211] CONFIG_ETH_TRANSMIT_MUTEX --- configs/defconfig.common | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/defconfig.common b/configs/defconfig.common index 62156e7d1..eb900e418 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -42,6 +42,7 @@ CONFIG_ESP_WIFI_CSI_ENABLED=n CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=y # CONFIG_ESP_WIFI_IRAM_OPT is not set # CONFIG_ESP_WIFI_RX_IRAM_OPT is not set +CONFIG_ETH_TRANSMIT_MUTEX=y CONFIG_ETH_SPI_ETHERNET_DM9051=y CONFIG_ETH_SPI_ETHERNET_W5500=y CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL=y From 0d4203a96e58cd334c6b8e5868608b10d39b2de3 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 20 Feb 2024 13:42:59 +0100 Subject: [PATCH 075/211] Fix build of pio manifest --- build.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index fd58ece3a..c615b8da0 100755 --- a/build.sh +++ b/build.sh @@ -244,7 +244,11 @@ fi # Generate PlatformIO manifest file if [ "$BUILD_TYPE" = "all" ]; then - python3 ./tools/gen_platformio_manifest.py -o "$TOOLS_JSON_OUT/" -s $(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD) -c $(git -C "$IDF_PATH" rev-parse --short HEAD) + pushd $IDF_PATH + ibr=$(git branch --show-current) + ic=$(git -C "$IDF_PATH" rev-parse --short HEAD) + popd + python3 ./tools/gen_platformio_manifest.py -o "$TOOLS_JSON_OUT/" -s "$ibr" -c "$ic" if [ $? -ne 0 ]; then exit 1; fi fi From 2f39e56f17e8be21bcd6404e60118a6de52fbaa6 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 20 Feb 2024 18:42:20 +0100 Subject: [PATCH 076/211] Update archive-build.sh --- tools/archive-build.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index 62c3df126..c064d2472 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -1,7 +1,5 @@ #!/bin/bash -IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD || echo "") -IDF_BRANCH=$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD || echo "") idf_version_string=${IDF_BRANCH//\//_}"-$IDF_COMMIT" archive_path="dist/arduino-esp32-libs-solo1-$idf_version_string.tar.gz" From 081decc87ed2ed626eb3885ed7941370170fee90 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 20 Feb 2024 18:42:50 +0100 Subject: [PATCH 077/211] Update install-esp-idf.sh --- tools/install-esp-idf.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index 45d3c21af..27ae59289 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -63,8 +63,6 @@ fi if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then git submodule update --recursive $IDF_PATH/install.sh - export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD) - export IDF_BRANCH=$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD) # Temporarily patch the ESP32-S2 I2C LL driver to keep the clock source cd $IDF_PATH From c118b98626e317bed807f459e0ef5cb1ddfc206b Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 20 Feb 2024 18:44:29 +0100 Subject: [PATCH 078/211] Update config.sh --- tools/config.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/config.sh b/tools/config.sh index fe8a65d4f..94472f03a 100755 --- a/tools/config.sh +++ b/tools/config.sh @@ -6,7 +6,7 @@ if [ -z $IDF_PATH ]; then fi if [ -z $IDF_BRANCH ]; then - IDF_BRANCH="release/v5.1" + export IDF_BRANCH="release/v5.1" fi # Arduino branch to use @@ -60,17 +60,20 @@ TOOLS_JSON_OUT="$AR_TOOLS/esp32-arduino-libs" IDF_LIBS_DIR="$AR_ROOT/../esp32-arduino-libs" if [ "$IDF_COMMIT" ]; then - echo "Using IDF commit $IDF_COMMIT" export IDF_COMMIT -elif [ -d "$IDF_PATH" ]; then - export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD) - export IDF_BRANCH=$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD) fi +if [ -d "$IDF_PATH" ]; then + export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD) +fi + +echo "Using IDF branch $IDF_BRANCH" +echo "Using IDF commit $IDF_COMMIT" + if [ "$AR_COMMIT" ]; then - echo "Using commit $AR_COMMIT for Arduino" + echo "Using Arduino commit $AR_COMMIT" else - AR_COMMIT=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "") + export AR_COMMIT=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "") fi #rm -rf release-info.txt @@ -103,6 +106,7 @@ function get_os(){ AR_OS=`get_os` export SED="sed" +export AWK="awk" export SSTAT="stat -c %s" if [[ "$AR_OS" == "macos" ]]; then @@ -115,6 +119,7 @@ if [[ "$AR_OS" == "macos" ]]; then exit 1 fi export SED="gsed" + export AWK="gawk" export SSTAT="stat -f %z" fi From 68d2ec6fba2ff4ec05ae2a78b08de60a05e213a5 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 20 Feb 2024 18:45:18 +0100 Subject: [PATCH 079/211] Update build.sh --- build.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/build.sh b/build.sh index c615b8da0..b552d11cb 100755 --- a/build.sh +++ b/build.sh @@ -144,8 +144,8 @@ mkdir -p "$AR_TOOLS/esp32-arduino-libs" rm -rf release-info.txt IDF_Commit_short=$(git -C "$IDF_PATH" rev-parse --short HEAD || echo "") AR_Commit_short=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "") -echo "Framework built from -- $IDF_REPO branch [$IDF_BRANCH](https://github.com/$IDF_REPO/tree/$IDF_BRANCH) commit [$IDF_Commit_short](https://github.com/$IDF_REPO/commits/$IDF_BRANCH/#:~:text=$IDF_Commit_short) +echo "Framework built from +- $IDF_REPO branch [$IDF_BRANCH](https://github.com/$IDF_REPO/tree/$IDF_BRANCH) commit [$IDF_Commit_short](https://github.com/$IDF_REPO/commits/$IDF_BRANCH/#:~:text=$IDF_Commit_short) - $AR_REPO branch [$AR_BRANCH](https://github.com/$AR_REPO/tree/$AR_BRANCH) commit [$AR_Commit_short](https://github.com/$AR_REPO/commits/$AR_BRANCH/#:~:text=$AR_Commit_short) - Arduino lib builder branch: $GIT_BRANCH" >> release-info.txt @@ -244,11 +244,7 @@ fi # Generate PlatformIO manifest file if [ "$BUILD_TYPE" = "all" ]; then - pushd $IDF_PATH - ibr=$(git branch --show-current) - ic=$(git -C "$IDF_PATH" rev-parse --short HEAD) - popd - python3 ./tools/gen_platformio_manifest.py -o "$TOOLS_JSON_OUT/" -s "$ibr" -c "$ic" + python3 ./tools/gen_platformio_manifest.py -o "$TOOLS_JSON_OUT/" -s "$IDF_BRANCH" -c "$IDF_COMMIT" if [ $? -ne 0 ]; then exit 1; fi fi From 77e6e1dc6b36d5296ab1ee67907186546606cd16 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 20 Feb 2024 22:10:51 +0100 Subject: [PATCH 080/211] Fix adding commit to release --- build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.sh b/build.sh index b552d11cb..c7b8612a1 100755 --- a/build.sh +++ b/build.sh @@ -235,6 +235,8 @@ for component in `ls "$AR_MANAGED_COMPS"`; do fi done +export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD) + # update package_esp32_index.template.json if [ "$BUILD_TYPE" = "all" ]; then python3 ./tools/gen_tools_json.py -i "$IDF_PATH" -j "$AR_COMPS/arduino/package/package_esp32_index.template.json" -o "$AR_OUT/" From 4c3adfde495e9e665e4101fc88a2d84f27a363fb Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 21 Feb 2024 12:30:26 +0100 Subject: [PATCH 081/211] Update build.sh --- build.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index c7b8612a1..25d94dbe0 100755 --- a/build.sh +++ b/build.sh @@ -244,9 +244,16 @@ if [ "$BUILD_TYPE" = "all" ]; then if [ $? -ne 0 ]; then exit 1; fi fi -# Generate PlatformIO manifest file +# Generate PlatformIO library manifest file if [ "$BUILD_TYPE" = "all" ]; then - python3 ./tools/gen_platformio_manifest.py -o "$TOOLS_JSON_OUT/" -s "$IDF_BRANCH" -c "$IDF_COMMIT" + python3 ./tools/gen_pio_lib_manifest.py -o "$TOOLS_JSON_OUT/" -s "$IDF_BRANCH" -c "$IDF_COMMIT" + if [ $? -ne 0 ]; then exit 1; fi +fi + +# Generate PlatformIO framework manifest file +rm -rf "$AR_ROOT/package.json" +if [ "$BUILD_TYPE" = "all" ]; then + python3 ./tools/gen_pio_frmwk_manifest.py -o "$AR_ROOT/" -s "$IDF_BRANCH" -c "$IDF_COMMIT" if [ $? -ne 0 ]; then exit 1; fi fi From c5fe415f3c947f915a5327fc9a54b2984147fd9a Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 21 Feb 2024 12:31:35 +0100 Subject: [PATCH 082/211] Delete package.json --- package.json | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 package.json diff --git a/package.json b/package.json deleted file mode 100644 index 6b5589241..000000000 --- a/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "framework-arduinoespressif32-solo1", - "version": "3.0.0", - "description": "Tasmota Arduino Framework for the Espressif ESP32-solo1", - "keywords": [ - "tasmota", - "framework", - "arduino", - "espressif", - "esp32" - ], - "license": "LGPL-2.1-or-later", - "repository": { - "type": "git", - "url": "https://github.com/tasmota/arduino-esp32" - } -} From 26c2924fdae652edbd30803c6e163d80186eebc0 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 21 Feb 2024 12:32:33 +0100 Subject: [PATCH 083/211] Update defconfig.esp32c6 --- configs/defconfig.esp32c6 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configs/defconfig.esp32c6 b/configs/defconfig.esp32c6 index 76c575e4e..5aa525c0c 100644 --- a/configs/defconfig.esp32c6 +++ b/configs/defconfig.esp32c6 @@ -1,6 +1,11 @@ # C6 has full Newlib in Rom # CONFIG_NEWLIB_NANO_FORMAT is not set +# Enable LP Core +CONFIG_ULP_COPROC_ENABLED=y +CONFIG_ULP_COPROC_TYPE_LP_CORE=y +CONFIG_ULP_COPROC_RESERVE_MEM=8192 + # # Bluetooth # From 8b07896fe0b5c7f209b8e05c3feb788ac9624cdf Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 21 Feb 2024 12:36:14 +0100 Subject: [PATCH 084/211] Update install-arduino.sh --- tools/install-arduino.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index 93b53a6e2..865dc3fbb 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -76,6 +76,7 @@ if [ $? -ne 0 ]; then exit 1; fi rm -rf "$AR_COMPS/arduino/libraries/RainMaker" rm -rf "$AR_COMPS/arduino/libraries/Insights" rm -rf "$AR_COMPS/arduino/libraries/ESP_I2S" +rm -rf "$AR_COMPS/arduino/libraries/SPIFFS" rm -rf "$AR_COMPS/arduino/libraries/BLE" rm -rf "$AR_COMPS/arduino/libraries/SimpleBLE" rm -rf "$AR_COMPS/arduino/libraries/BluetoothSerial" From 92af8c2b23e0cc4647a6a3f8264133696261a655 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 21 Feb 2024 12:37:34 +0100 Subject: [PATCH 085/211] Update gen_platformio_manifest.py --- tools/gen_platformio_manifest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/gen_platformio_manifest.py b/tools/gen_platformio_manifest.py index 02057d9a2..22df9a730 100644 --- a/tools/gen_platformio_manifest.py +++ b/tools/gen_platformio_manifest.py @@ -7,7 +7,7 @@ MANIFEST_DATA = { "name": "framework-arduinoespressif32-libs", "description": "Precompiled libraries for Arduino Wiring-based Framework for the Espressif ESP32 series of SoCs", - "keywords": ["framework", "arduino", "espressif", "esp32"], + "keywords": ["framework", "tasmota", "arduino", "espressif", "esp32"], "license": "LGPL-2.1-or-later", "repository": { "type": "git", @@ -53,7 +53,7 @@ def main(dst_dir, version_string, commit_hash): json.dump(MANIFEST_DATA, fp, indent=2) print( - f"Generated PlatformIO manifest file '{manifest_file_path}' with '{converted_version}' version" + f"Generated PlatformIO libraries manifest file '{manifest_file_path}' with '{converted_version}' version" ) return 0 From 0c29ebf7de183e2c19f55d4bf785ce2b739aef6e Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 21 Feb 2024 12:38:28 +0100 Subject: [PATCH 086/211] Update and rename gen_platformio_manifest.py to gen_pio_lib_manifest.py --- tools/{gen_platformio_manifest.py => gen_pio_lib_manifest.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/{gen_platformio_manifest.py => gen_pio_lib_manifest.py} (100%) diff --git a/tools/gen_platformio_manifest.py b/tools/gen_pio_lib_manifest.py similarity index 100% rename from tools/gen_platformio_manifest.py rename to tools/gen_pio_lib_manifest.py From 1dfe8e589354e2d87407fd4339e26aa5c559a534 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 21 Feb 2024 12:38:58 +0100 Subject: [PATCH 087/211] Build framework manifest --- configs/defconfig.esp32s2 | 1 + configs/defconfig.esp32s3 | 4 ++ tools/gen_pio_frmwk_manifest.py | 87 +++++++++++++++++++++++++++++++++ tools/gen_tools_json.py | 2 +- 4 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 tools/gen_pio_frmwk_manifest.py diff --git a/configs/defconfig.esp32s2 b/configs/defconfig.esp32s2 index aa6d3ed5f..7aad2865d 100644 --- a/configs/defconfig.esp32s2 +++ b/configs/defconfig.esp32s2 @@ -2,6 +2,7 @@ CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y CONFIG_SPIRAM=y CONFIG_ESP32S2_KEEP_USB_ALIVE=y +CONFIG_ULP_COPROC_ENABLED=y CONFIG_ESP32_ULP_COPROC_RISCV=y CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=4096 # CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0 is not set diff --git a/configs/defconfig.esp32s3 b/configs/defconfig.esp32s3 index 3ac337072..0a4aae470 100644 --- a/configs/defconfig.esp32s3 +++ b/configs/defconfig.esp32s3 @@ -1,3 +1,7 @@ +CONFIG_ULP_COPROC_ENABLED=y +CONFIG_ULP_COPROC_TYPE_RISCV=y +CONFIG_ULP_COPROC_RESERVE_MEM=4096 + CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y CONFIG_SPIRAM=y CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y diff --git a/tools/gen_pio_frmwk_manifest.py b/tools/gen_pio_frmwk_manifest.py new file mode 100644 index 000000000..dc5c26471 --- /dev/null +++ b/tools/gen_pio_frmwk_manifest.py @@ -0,0 +1,87 @@ +import argparse +import json +import os +import re +import sys + +MANIFEST_DATA = { + "name": "framework-arduinoespressif32", + "description": "Platformio Tasmota Arduino framework for the Espressif ESP32 series of SoCs", + "keywords": ["framework", "tasmota", "arduino", "espressif", "esp32"], + "license": "LGPL-2.1-or-later", + "repository": { + "type": "git", + "url": "https://github.com/tasmota/arduino-esp32", + }, +} + + +def convert_version(version_string): + """A helper function that converts a custom IDF version string + extracted from a Git repository to a suitable SemVer alternative. For example: + 'release/v5.1' becomes '5.1.0', + 'v7.7.7' becomes '7.7.7' + """ + + regex_pattern = ( + r"v(?P<MAJOR>0|[1-9]\d*)\.(?P<MINOR>0|[1-9]\d*)\.*(?P<PATCH>0|[1-9]\d*)*" + ) + match = re.search(regex_pattern, version_string) + if not match: + sys.stderr.write( + f"Failed to find a regex match for '{regex_pattern}' in '{version_string}'\n" + ) + return "" + + major, minor, patch = match.groups() + if not patch: + patch = "0" + + return ".".join((major, minor, patch)) + + +def main(dst_dir, version_string, commit_hash): + + converted_version = convert_version(version_string) + if not converted_version: + sys.stderr.write(f"Failed to convert version '{version_string}'\n") + return -1 + + manifest_file_path = os.path.join(dst_dir, "package.json") + with open(manifest_file_path, "w", encoding="utf8") as fp: + MANIFEST_DATA["version"] = f"3.0.0+sha.{commit_hash}" + #MANIFEST_DATA["version"] = f"{converted_version}+sha.{commit_hash}" + json.dump(MANIFEST_DATA, fp, indent=2) + + print( + f"Generated PlatformIO framework manifest file '{manifest_file_path}' with '{converted_version}' version" + ) + return 0 + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument( + "-o", + "--dst-dir", + dest="dst_dir", + required=True, + help="Destination folder where the 'package.json' manifest will be located", + ) + parser.add_argument( + "-s", + "--version-string", + dest="version_string", + required=True, + help="ESP-IDF version string used for compiling libraries", + ) + parser.add_argument( + "-c", + "--commit-hash", + dest="commit_hash", + required=True, + help="ESP-IDF revision in form of a commit hash", + ) + args = parser.parse_args() + + sys.exit(main(args.dst_dir, args.version_string, args.commit_hash)) diff --git a/tools/gen_tools_json.py b/tools/gen_tools_json.py index ca53ec8cb..20d8f864b 100644 --- a/tools/gen_tools_json.py +++ b/tools/gen_tools_json.py @@ -59,7 +59,7 @@ if tool_name.endswith('-elf'): tool_name += '-gcc' print('Found {0}, version: {1}'.format(tool_name, tool_version)) - + if simple_output == False: dep_found = False dep_skip = False From c54bef0c69b9be0ecd71c610495c34ae841aa269 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 21 Feb 2024 12:40:58 +0100 Subject: [PATCH 088/211] Update gen_pio_frmwk_manifest.py --- tools/gen_pio_frmwk_manifest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/gen_pio_frmwk_manifest.py b/tools/gen_pio_frmwk_manifest.py index dc5c26471..439f6d223 100644 --- a/tools/gen_pio_frmwk_manifest.py +++ b/tools/gen_pio_frmwk_manifest.py @@ -6,7 +6,7 @@ MANIFEST_DATA = { "name": "framework-arduinoespressif32", - "description": "Platformio Tasmota Arduino framework for the Espressif ESP32 series of SoCs", + "description": "Platformio Tasmota Arduino framework for the Espressif ESP32-solo1", "keywords": ["framework", "tasmota", "arduino", "espressif", "esp32"], "license": "LGPL-2.1-or-later", "repository": { From 8334fd8597ab8edd8ea6923f2c79168521faaaf1 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 21 Feb 2024 12:41:26 +0100 Subject: [PATCH 089/211] Update gen_pio_lib_manifest.py --- tools/gen_pio_lib_manifest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/gen_pio_lib_manifest.py b/tools/gen_pio_lib_manifest.py index 22df9a730..f19ed5e8a 100644 --- a/tools/gen_pio_lib_manifest.py +++ b/tools/gen_pio_lib_manifest.py @@ -6,7 +6,7 @@ MANIFEST_DATA = { "name": "framework-arduinoespressif32-libs", - "description": "Precompiled libraries for Arduino Wiring-based Framework for the Espressif ESP32 series of SoCs", + "description": "Precompiled libraries for Arduino Wiring-based Framework for the Espressif ESP32-solo1", "keywords": ["framework", "tasmota", "arduino", "espressif", "esp32"], "license": "LGPL-2.1-or-later", "repository": { From d3f7d94d283966906baf749dcfc7a8775d9961da Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 21 Feb 2024 13:06:18 +0100 Subject: [PATCH 090/211] Update gen_pio_frmwk_manifest.py --- tools/gen_pio_frmwk_manifest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/gen_pio_frmwk_manifest.py b/tools/gen_pio_frmwk_manifest.py index 439f6d223..484b30422 100644 --- a/tools/gen_pio_frmwk_manifest.py +++ b/tools/gen_pio_frmwk_manifest.py @@ -5,7 +5,7 @@ import sys MANIFEST_DATA = { - "name": "framework-arduinoespressif32", + "name": "framework-arduinoespressif32-solo1", "description": "Platformio Tasmota Arduino framework for the Espressif ESP32-solo1", "keywords": ["framework", "tasmota", "arduino", "espressif", "esp32"], "license": "LGPL-2.1-or-later", From 96a5c6ed81029764a2b22711e5ce115e5a74dd7b Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 21 Feb 2024 17:26:53 +0100 Subject: [PATCH 091/211] fetch Arduino version from package.json (#81) --- build.sh | 4 +++- tools/gen_pio_frmwk_manifest.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 25d94dbe0..331882414 100755 --- a/build.sh +++ b/build.sh @@ -252,8 +252,10 @@ fi # Generate PlatformIO framework manifest file rm -rf "$AR_ROOT/package.json" +AR_VERSION=$(jq -c '.version' "$AR_COMPS/arduino/package.json" | tr -d '"') +#echo "* Arduino Version: $AR_VERSION" if [ "$BUILD_TYPE" = "all" ]; then - python3 ./tools/gen_pio_frmwk_manifest.py -o "$AR_ROOT/" -s "$IDF_BRANCH" -c "$IDF_COMMIT" + python3 ./tools/gen_pio_frmwk_manifest.py -o "$AR_ROOT/" -s "v$AR_VERSION" -c "$IDF_COMMIT" if [ $? -ne 0 ]; then exit 1; fi fi diff --git a/tools/gen_pio_frmwk_manifest.py b/tools/gen_pio_frmwk_manifest.py index 484b30422..d73c21464 100644 --- a/tools/gen_pio_frmwk_manifest.py +++ b/tools/gen_pio_frmwk_manifest.py @@ -49,8 +49,8 @@ def main(dst_dir, version_string, commit_hash): manifest_file_path = os.path.join(dst_dir, "package.json") with open(manifest_file_path, "w", encoding="utf8") as fp: - MANIFEST_DATA["version"] = f"3.0.0+sha.{commit_hash}" - #MANIFEST_DATA["version"] = f"{converted_version}+sha.{commit_hash}" + #MANIFEST_DATA["version"] = f"3.0.0+sha.{commit_hash}" + MANIFEST_DATA["version"] = f"{converted_version}+sha.{commit_hash}" json.dump(MANIFEST_DATA, fp, indent=2) print( From 5d37ce00164a6e1bffba13546f0363f97c3fe2bf Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 21 Feb 2024 17:28:34 +0100 Subject: [PATCH 092/211] Update build.sh --- build.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/build.sh b/build.sh index 331882414..8923bc543 100755 --- a/build.sh +++ b/build.sh @@ -253,7 +253,6 @@ fi # Generate PlatformIO framework manifest file rm -rf "$AR_ROOT/package.json" AR_VERSION=$(jq -c '.version' "$AR_COMPS/arduino/package.json" | tr -d '"') -#echo "* Arduino Version: $AR_VERSION" if [ "$BUILD_TYPE" = "all" ]; then python3 ./tools/gen_pio_frmwk_manifest.py -o "$AR_ROOT/" -s "v$AR_VERSION" -c "$IDF_COMMIT" if [ $? -ne 0 ]; then exit 1; fi From c3bf53a0e1a12034977f4b616e0275884d202f39 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 21 Feb 2024 17:31:01 +0100 Subject: [PATCH 093/211] Update gen_pio_frmwk_manifest.py --- tools/gen_pio_frmwk_manifest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/gen_pio_frmwk_manifest.py b/tools/gen_pio_frmwk_manifest.py index d73c21464..86210d276 100644 --- a/tools/gen_pio_frmwk_manifest.py +++ b/tools/gen_pio_frmwk_manifest.py @@ -49,7 +49,6 @@ def main(dst_dir, version_string, commit_hash): manifest_file_path = os.path.join(dst_dir, "package.json") with open(manifest_file_path, "w", encoding="utf8") as fp: - #MANIFEST_DATA["version"] = f"3.0.0+sha.{commit_hash}" MANIFEST_DATA["version"] = f"{converted_version}+sha.{commit_hash}" json.dump(MANIFEST_DATA, fp, indent=2) From 1b403d07ff7a1bf261eb13c8f4ef092c83557f79 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 21 Feb 2024 21:00:00 +0100 Subject: [PATCH 094/211] generate core_version.h --- build.sh | 11 ++++++++++- core_version.h | 4 ---- 2 files changed, 10 insertions(+), 5 deletions(-) delete mode 100644 core_version.h diff --git a/build.sh b/build.sh index 8923bc543..424b9dfe4 100755 --- a/build.sh +++ b/build.sh @@ -250,14 +250,23 @@ if [ "$BUILD_TYPE" = "all" ]; then if [ $? -ne 0 ]; then exit 1; fi fi +AR_VERSION=$(jq -c '.version' "$AR_COMPS/arduino/package.json" | tr -d '"') +AR_VERSION_UNDERSCORE=`echo "$AR_VERSION" | tr . _` + # Generate PlatformIO framework manifest file rm -rf "$AR_ROOT/package.json" -AR_VERSION=$(jq -c '.version' "$AR_COMPS/arduino/package.json" | tr -d '"') if [ "$BUILD_TYPE" = "all" ]; then python3 ./tools/gen_pio_frmwk_manifest.py -o "$AR_ROOT/" -s "v$AR_VERSION" -c "$IDF_COMMIT" if [ $? -ne 0 ]; then exit 1; fi fi +# Generate core_version.h +rm -rf "$AR_ROOT/core_version.h" +echo "#define ARDUINO_ESP32_GIT_VER 0x$IDF_Commit_short +#define ARDUINO_ESP32_GIT_DESC $AR_VERSION +#define ARDUINO_ESP32_RELEASE_$AR_VERSION_UNDERSCORE +#define ARDUINO_ESP32_RELEASE \"$AR_VERSION_UNDERSCORE\"" >> "$AR_ROOT/core_version.h" + # copy everything to arduino-esp32 installation if [ $COPY_OUT -eq 1 ] && [ -d "$ESP32_ARDUINO" ]; then ./tools/copy-to-arduino.sh diff --git a/core_version.h b/core_version.h deleted file mode 100644 index 468a2459e..000000000 --- a/core_version.h +++ /dev/null @@ -1,4 +0,0 @@ -#define ARDUINO_ESP32_GIT_VER 0xcbaeab4e -#define ARDUINO_ESP32_GIT_DESC 3.0.0 -#define ARDUINO_ESP32_RELEASE_3_0_0 -#define ARDUINO_ESP32_RELEASE "3_0_0" From a6b255daf7936daf1e0c2173a6c24ccea3c0de1d Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 21 Feb 2024 21:06:00 +0100 Subject: [PATCH 095/211] Update build.sh --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 424b9dfe4..ca6a99c1b 100755 --- a/build.sh +++ b/build.sh @@ -262,7 +262,7 @@ fi # Generate core_version.h rm -rf "$AR_ROOT/core_version.h" -echo "#define ARDUINO_ESP32_GIT_VER 0x$IDF_Commit_short +echo "#define ARDUINO_ESP32_GIT_VER 0x$AR_Commit_short #define ARDUINO_ESP32_GIT_DESC $AR_VERSION #define ARDUINO_ESP32_RELEASE_$AR_VERSION_UNDERSCORE #define ARDUINO_ESP32_RELEASE \"$AR_VERSION_UNDERSCORE\"" >> "$AR_ROOT/core_version.h" From 72c2c72e581791cc26ecafc5421252e44a53dda7 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 26 Feb 2024 21:57:21 +0100 Subject: [PATCH 096/211] Update .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 2d74868b1..99ced40ba 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ version.txt dependencies.lock managed_components/ target/ +core_version.h +package.json +release-info.txt From 6abf6ea75f85020a627dffb8caaa3a50a6287e32 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 27 Feb 2024 21:15:49 +0100 Subject: [PATCH 097/211] Update prepare-ci.sh --- tools/prepare-ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/prepare-ci.sh b/tools/prepare-ci.sh index 52773a90a..a18e63d5a 100755 --- a/tools/prepare-ci.sh +++ b/tools/prepare-ci.sh @@ -2,7 +2,7 @@ # Ubuntu setup # Change in archive-build.sh gawk to awk -#sudo apt-get install -y gperf cmake ninja-build +#sudo apt update && sudo apt install -y gperf cmake ninja-build #pip3 install wheel future pyelftools # MacOS (ARM) setup From ea6676d700ed35920da2e07eb16e15656aabd9b6 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 4 Mar 2024 20:28:07 +0100 Subject: [PATCH 098/211] get version from file --- tools/install-esp-idf.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index 27ae59289..57150e7c7 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -37,7 +37,7 @@ if [ ! -d "$IDF_PATH" ]; then idf_was_installed="1" else # update existing branch - echo "ESP-IDF is already installed, updating branch '$IDF_BRANCH'" + echo "ESP-IDF is already installed, updating branch $IDF_BRANCH" cd $IDF_PATH git pull git reset --hard $IDF_BRANCH @@ -68,6 +68,12 @@ if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then cd $IDF_PATH patch -p1 -N -i ../patches/esp32s2_i2c_ll_master_init.diff cd - + + # Get the exact IDF version from file "version.txt" + cd $IDF_PATH + export IDF_VERSION=$(<version.txt) + echo "IDF version: $IDF_VERSION" + cd - fi # From f33e9fdee22ee033c3d44f2b6a4d5c7b12cd6002 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 4 Mar 2024 20:30:36 +0100 Subject: [PATCH 099/211] Use exact IDF version --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index ca6a99c1b..bc569159e 100755 --- a/build.sh +++ b/build.sh @@ -246,7 +246,7 @@ fi # Generate PlatformIO library manifest file if [ "$BUILD_TYPE" = "all" ]; then - python3 ./tools/gen_pio_lib_manifest.py -o "$TOOLS_JSON_OUT/" -s "$IDF_BRANCH" -c "$IDF_COMMIT" + python3 ./tools/gen_pio_lib_manifest.py -o "$TOOLS_JSON_OUT/" -s "v$IDF_VERSION" -c "$IDF_COMMIT" if [ $? -ne 0 ]; then exit 1; fi fi From 464f3bfe4dc9084a3fbdb9e6ae376076a586f2e6 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 4 Mar 2024 20:37:55 +0100 Subject: [PATCH 100/211] CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT=y --- configs/defconfig.common | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index eb900e418..06e498a30 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -9,10 +9,6 @@ CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS=y CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_NONE=y CONFIG_I2S_SUPPRESS_DEPRECATE_WARN=y -CONFIG_BT_ENABLED=y -CONFIG_BT_STACK_NO_LOG=y -# CONFIG_BT_BLE_42_FEATURES_SUPPORTED is not set -# CONFIG_BLE_MESH is not set CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y @@ -34,12 +30,19 @@ CONFIG_ESP_TASK_WDT_PANIC=y CONFIG_ESP_TIMER_TASK_STACK_SIZE=4096 CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y -CONFIG_ESP_WIFI_FTM_ENABLE=n +# CONFIG_ESP_WIFI_FTM_ENABLE is not set CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=8 CONFIG_ESP_WIFI_STATIC_TX_BUFFER_NUM=8 CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM=16 -CONFIG_ESP_WIFI_CSI_ENABLED=n +# CONFIG_ESP_WIFI_CSI_ENABLED is not set CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=y +CONFIG_ESP_WIFI_ENABLE_SAE_PK=y +# CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT is not set +CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT=y +# CONFIG_ESP_WIFI_SOFTAP_SAE_SUPPORT is not set +# CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA is not set +CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=0 +# CONFIG_ESP_WIFI_MBEDTLS_CRYPTO is not set # CONFIG_ESP_WIFI_IRAM_OPT is not set # CONFIG_ESP_WIFI_RX_IRAM_OPT is not set CONFIG_ETH_TRANSMIT_MUTEX=y @@ -93,13 +96,6 @@ CONFIG_LWIP_UDP_RECVMBOX_SIZE=64 CONFIG_NEWLIB_NANO_FORMAT=y # CONFIG_DAC_DMA_AUTO_16BIT_ALIGN is not set -# CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT is not set -# CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT is not set -# CONFIG_ESP_WIFI_SOFTAP_SAE_SUPPORT is not set -# CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA is not set -CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=0 -# CONFIG_ESP_WIFI_MBEDTLS_CRYPTO is not set - CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y CONFIG_MBEDTLS_TLS_DISABLED=y From bd16ab05fd1e8803255226e1fe2e795ad0b2d792 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 4 Mar 2024 20:42:35 +0100 Subject: [PATCH 101/211] add BT --- configs/defconfig.esp32 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/configs/defconfig.esp32 b/configs/defconfig.esp32 index a059e5f9d..626d5368d 100644 --- a/configs/defconfig.esp32 +++ b/configs/defconfig.esp32 @@ -1,9 +1,12 @@ CONFIG_FREERTOS_UNICORE=y -CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR=y + # # Bluetooth # CONFIG_BT_ENABLED=y +CONFIG_BT_STACK_NO_LOG=y +# CONFIG_BT_BLE_42_FEATURES_SUPPORTED is not set +# CONFIG_BLE_MESH is not set CONFIG_BT_NIMBLE_ENABLED=y CONFIG_BT_NIMBLE_LOG_LEVEL_NONE=y CONFIG_BT_NIMBLE_MAX_CONNECTIONS=1 @@ -13,6 +16,8 @@ CONFIG_BT_NIMBLE_MAX_CONNECTIONS=1 # CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_CODED_PHY is not set # CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT is not set +CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR=y + CONFIG_ETH_ENABLED=y CONFIG_ETH_USE_ESP32_EMAC=y CONFIG_ETH_PHY_INTERFACE_RMII=y From ebb36ee59eca4e699929bb2ed02dc36b59674df6 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 5 Mar 2024 13:29:50 +0100 Subject: [PATCH 102/211] rm every exe from folder tools --- tools/archive-build.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index c064d2472..7f02360f2 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -39,12 +39,11 @@ rm -rf arduino-esp32/libraries/TFLiteMicro rm -rf arduino-esp32/libraries/ESP32 rm -rf arduino-esp32/package rm -rf arduino-esp32/tools/esp32-arduino-libs +rm -rf arduino-esp32/tools/*.exe rm -rf arduino-esp32/tools/esptool.py rm -rf arduino-esp32/tools/get.py -rm -rf arduino-esp32/tools/get.exe rm -rf arduino-esp32/tools/ide-debug rm -rf arduino-esp32/tools/gen_insights_package.py -rm -rf arduino-esp32/tools/gen_insights_package.exe rm -rf arduino-esp32/platform.txt rm -rf arduino-esp32/programmers.txt rm -rf arduino-esp32/boards.txt From e349356992f6b8c8738d7ccdba14f4eb808a686b Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 8 Mar 2024 16:24:01 +0100 Subject: [PATCH 103/211] rm chip debug report --- tools/install-arduino.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index 865dc3fbb..707fd7f4b 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -71,8 +71,10 @@ fi if [ $? -ne 0 ]; then exit 1; fi # -# remove libraries not needed for Tasmota +# remove code and libraries not needed/wanted for Tasmota framework # +rm -rf "$AR_COMPS/arduino/cores/esp32/chip-debug-report.cpp" +rm -rf "$AR_COMPS/arduino/cores/esp32/chip-debug-report.h" rm -rf "$AR_COMPS/arduino/libraries/RainMaker" rm -rf "$AR_COMPS/arduino/libraries/Insights" rm -rf "$AR_COMPS/arduino/libraries/ESP_I2S" From 7f3863d238a0fd5dbfca42e7b683f06a85aecff5 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 8 Mar 2024 16:50:37 +0100 Subject: [PATCH 104/211] Update build.sh --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index bc569159e..3859fd877 100755 --- a/build.sh +++ b/build.sh @@ -10,7 +10,7 @@ if ! [ -x "$(command -v git)" ]; then exit 1 fi -TARGET="esp32" +export TARGET="esp32" BUILD_TYPE="all" SKIP_ENV=0 COPY_OUT=0 From aa3cbcc6f78e691c26423204f9722d28c9898f9b Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 8 Mar 2024 20:10:28 +0100 Subject: [PATCH 105/211] deprecate warn --- configs/defconfig.common | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/defconfig.common b/configs/defconfig.common index 06e498a30..b983a3375 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -9,6 +9,8 @@ CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS=y CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_NONE=y CONFIG_I2S_SUPPRESS_DEPRECATE_WARN=y +CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y +CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y From 1fa0fde6cd0d6bdaac46178d8b34754691f0cade Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 8 Mar 2024 20:16:59 +0100 Subject: [PATCH 106/211] Update defconfig.common --- configs/defconfig.common | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/defconfig.common b/configs/defconfig.common index b983a3375..7a99a37dd 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -6,6 +6,7 @@ CONFIG_APP_EXCLUDE_PROJECT_VER_VAR=y CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR=y # CONFIG_APP_COMPILE_TIME_DATE is not set CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y +CONFIG_BOOT_ROM_LOG_ALWAYS_OFF CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS=y CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_NONE=y CONFIG_I2S_SUPPRESS_DEPRECATE_WARN=y From 554ad8bfc7a69d3b5a5e55f7d8071b1857d30a77 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 8 Mar 2024 20:18:02 +0100 Subject: [PATCH 107/211] Update defconfig.common --- configs/defconfig.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index 7a99a37dd..01329fdb0 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -6,7 +6,7 @@ CONFIG_APP_EXCLUDE_PROJECT_VER_VAR=y CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR=y # CONFIG_APP_COMPILE_TIME_DATE is not set CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y -CONFIG_BOOT_ROM_LOG_ALWAYS_OFF +CONFIG_BOOT_ROM_LOG_ALWAYS_OFF=y CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS=y CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_NONE=y CONFIG_I2S_SUPPRESS_DEPRECATE_WARN=y From c84555010228f9d4605c3c7857c117c434e8c180 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 8 Mar 2024 20:30:32 +0100 Subject: [PATCH 108/211] Update defconfig.common --- configs/defconfig.common | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/defconfig.common b/configs/defconfig.common index 01329fdb0..4a2be049d 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -1,6 +1,7 @@ CONFIG_AUTOSTART_ARDUINO=y # CONFIG_WS2812_LED_ENABLE is not set CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y +CONFIG_APP_REPRODUCIBLE_BUILD=y CONFIG_COMPILER_HIDE_PATHS_MACROS=y CONFIG_APP_EXCLUDE_PROJECT_VER_VAR=y CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR=y From dd05413d0082a3057e7a156fc626a04ab2628e94 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 10 Mar 2024 18:14:51 +0100 Subject: [PATCH 109/211] add build date --- tools/gen_pio_frmwk_manifest.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/gen_pio_frmwk_manifest.py b/tools/gen_pio_frmwk_manifest.py index 86210d276..c57275f63 100644 --- a/tools/gen_pio_frmwk_manifest.py +++ b/tools/gen_pio_frmwk_manifest.py @@ -3,6 +3,7 @@ import os import re import sys +import datetime MANIFEST_DATA = { "name": "framework-arduinoespressif32-solo1", @@ -48,8 +49,10 @@ def main(dst_dir, version_string, commit_hash): return -1 manifest_file_path = os.path.join(dst_dir, "package.json") + build_date = datetime.date.today() with open(manifest_file_path, "w", encoding="utf8") as fp: MANIFEST_DATA["version"] = f"{converted_version}+sha.{commit_hash}" + MANIFEST_DATA["date"] = f"{build_date}" json.dump(MANIFEST_DATA, fp, indent=2) print( From b9a1a5f0aaed98d69e698513781b4a5bd39dc67c Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 3 Apr 2024 22:19:29 +0200 Subject: [PATCH 110/211] rm -rf "$AR_COMPS/arduino/libraries/ESP_NOW" --- tools/install-arduino.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index 707fd7f4b..0108de4ee 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -86,6 +86,7 @@ rm -rf "$AR_COMPS/arduino/libraries/WiFiProv" rm -rf "$AR_COMPS/arduino/libraries/WiFiClientSecure" rm -rf "$AR_COMPS/arduino/libraries/ESP32" rm -rf "$AR_COMPS/arduino/libraries/ESP_SR" +rm -rf "$AR_COMPS/arduino/libraries/ESP_NOW" rm -rf "$AR_COMPS/arduino/libraries/TFLiteMicro" # From e6bb4132e094ea0ea3f70a3dd02f6fbc46eef114 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 3 Apr 2024 22:25:52 +0200 Subject: [PATCH 111/211] rm -rf arduino-esp32/libraries/ESP_NOW --- tools/archive-build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index 7f02360f2..5d17a6c3a 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -35,6 +35,7 @@ rm -rf arduino-esp32/libraries/BluetoothSerial rm -rf arduino-esp32/libraries/WiFiProv rm -rf arduino-esp32/libraries/WiFiClientSecure rm -rf arduino-esp32/libraries/ESP_SR +rm -rf arduino-esp32/libraries/ESP_NOW rm -rf arduino-esp32/libraries/TFLiteMicro rm -rf arduino-esp32/libraries/ESP32 rm -rf arduino-esp32/package From b22262c6dc634257e1f950228ded30ddc20dadef Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 3 Apr 2024 22:39:46 +0200 Subject: [PATCH 112/211] Update config.sh --- tools/config.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/config.sh b/tools/config.sh index 94472f03a..a5cdfe840 100755 --- a/tools/config.sh +++ b/tools/config.sh @@ -76,11 +76,8 @@ else export AR_COMMIT=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "") fi -#rm -rf release-info.txt -#echo "Framework built from Tasmota IDF branch $IDF_BRANCH commit $IDF_COMMIT and $AR_REPO branch $AR_BRANCH commit $AR_COMMIT" >> release-info.txt - function get_os(){ - OSBITS=`arch` + OSBITS=`uname -m` if [[ "$OSTYPE" == "linux"* ]]; then if [[ "$OSBITS" == "i686" ]]; then echo "linux32" From bced69bd8b7de60c4a100d47f8e7835760264b4b Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 5 Apr 2024 19:17:42 +0200 Subject: [PATCH 113/211] Update build.sh --- build.sh | 92 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 27 deletions(-) diff --git a/build.sh b/build.sh index 3859fd877..1f0375a7a 100755 --- a/build.sh +++ b/build.sh @@ -20,7 +20,7 @@ if [ -z $DEPLOY_OUT ]; then fi function print_help() { - echo "Usage: build.sh [-s] [-A <arduino_branch>] [-I <idf_branch>] [-i <idf_commit>] [-c <path>] [-t <target>] [-b <build|menuconfig|reconfigure|idf_libs|copy_bootloader|mem_variant>] [config ...]" + echo "Usage: build.sh [-s] [-A <arduino_branch>] [-I <idf_branch>] [-i <idf_commit>] [-c <path>] [-t <target>] [-b <build|menuconfig|reconfigure|idf-libs|copy-bootloader|mem-variant>] [config ...]" echo " -s Skip installing/updating of ESP-IDF and all components" echo " -A Set which branch of arduino-esp32 to be used for compilation" echo " -I Set which branch of ESP-IDF to be used for compilation" @@ -28,7 +28,7 @@ function print_help() { echo " -e Archive the build to dist" echo " -d Deploy the build to github arduino-esp32" echo " -c Set the arduino-esp32 folder to copy the result to. ex. '$HOME/Arduino/hardware/espressif/esp32'" - echo " -t Set the build target(chip). ex. 'esp32s3'" + echo " -t Set the build target(chip) ex. 'esp32s3' or select multiple targets(chips) by separating them with comma ex. 'esp32,esp32s3,esp32c3'" echo " -b Set the build type. ex. 'build' to build the project and prepare for uploading to a board" echo " ... Specify additional configs to be applied. ex. 'qio 80m' to compile for QIO Flash@80MHz. Requires -b" exit 1 @@ -59,16 +59,16 @@ while getopts ":A:I:i:c:t:b:sde" opt; do export IDF_COMMIT="$OPTARG" ;; t ) - TARGET=$OPTARG + IFS=',' read -ra TARGET <<< "$OPTARG" ;; b ) b=$OPTARG - if [ "$b" != "build" ] && - [ "$b" != "menuconfig" ] && - [ "$b" != "reconfigure" ] && - [ "$b" != "idf_libs" ] && - [ "$b" != "copy_bootloader" ] && - [ "$b" != "mem_variant" ]; then + if [ "$b" != "build" ] && + [ "$b" != "menuconfig" ] && + [ "$b" != "reconfigure" ] && + [ "$b" != "idf-libs" ] && + [ "$b" != "copy-bootloader" ] && + [ "$b" != "mem-variant" ]; then print_help fi BUILD_TYPE="$b" @@ -86,6 +86,9 @@ done shift $((OPTIND -1)) CONFIGS=$@ +# Output the TARGET array +echo "TARGET(s): ${TARGET[@]}" + mkdir -p dist rm -rf dependencies.lock @@ -113,27 +116,42 @@ if [ "$BUILD_TYPE" != "all" ]; then echo "ERROR: You need to specify target for non-default builds" print_help fi - configs="configs/defconfig.common;configs/defconfig.$TARGET" # Target Features Configs for target_json in `jq -c '.targets[]' configs/builds.json`; do target=$(echo "$target_json" | jq -c '.target' | tr -d '"') - if [ "$TARGET" == "$target" ]; then - for defconf in `echo "$target_json" | jq -c '.features[]' | tr -d '"'`; do - configs="$configs;configs/defconfig.$defconf" - done + + # Check if $target is in the $TARGET array + target_in_array=false + for item in "${TARGET[@]}"; do + if [ "$item" = "$target" ]; then + target_in_array=true + break + fi + done + + if [ "$target_in_array" = false ]; then + # Skip building for targets that are not in the $TARGET array + continue fi - done + + configs="configs/defconfig.common;configs/defconfig.$target" + for defconf in `echo "$target_json" | jq -c '.features[]' | tr -d '"'`; do + configs="$configs;configs/defconfig.$defconf" + done - # Configs From Arguments - for conf in $CONFIGS; do - configs="$configs;configs/defconfig.$conf" - done + echo "* Building for $target" - echo "idf.py -DIDF_TARGET=\"$TARGET\" -DSDKCONFIG_DEFAULTS=\"$configs\" $BUILD_TYPE" - rm -rf build sdkconfig - idf.py -DIDF_TARGET="$TARGET" -DSDKCONFIG_DEFAULTS="$configs" $BUILD_TYPE - if [ $? -ne 0 ]; then exit 1; fi + # Configs From Arguments + for conf in $CONFIGS; do + configs="$configs;configs/defconfig.$conf" + done + + echo "idf.py -DIDF_TARGET=\"$target\" -DSDKCONFIG_DEFAULTS=\"$configs\" $BUILD_TYPE" + rm -rf build sdkconfig + idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$configs" $BUILD_TYPE + if [ $? -ne 0 ]; then exit 1; fi + done exit 0 fi @@ -152,8 +170,28 @@ echo "Framework built from #targets_count=`jq -c '.targets[] | length' configs/builds.json` for target_json in `jq -c '.targets[]' configs/builds.json`; do target=$(echo "$target_json" | jq -c '.target' | tr -d '"') + target_skip=$(echo "$target_json" | jq -c '.skip // 0') + + # Check if $target is in the $TARGET array if not "all" + if [ "$TARGET" != "all" ]; then + target_in_array=false + for item in "${TARGET[@]}"; do + if [ "$item" = "$target" ]; then + target_in_array=true + break + fi + done - if [ "$TARGET" != "all" ] && [ "$TARGET" != "$target" ]; then + # If $target is not in the $TARGET array, skip processing + if [ "$target_in_array" = false ]; then + echo "* Skipping Target: $target" + continue + fi + fi + + # Skip chips that should not be a part of the final libs + # WARNING!!! this logic needs to be updated when cron builds are split into jobs + if [ "$TARGET" = "all" ] && [ $target_skip -eq 1 ]; then echo "* Skipping Target: $target" continue fi @@ -174,7 +212,7 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do echo "* Build IDF-Libs: $idf_libs_configs" rm -rf build sdkconfig - idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$idf_libs_configs" idf_libs + idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$idf_libs_configs" idf-libs if [ $? -ne 0 ]; then exit 1; fi # Build Bootloaders @@ -186,7 +224,7 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do echo "* Build BootLoader: $bootloader_configs" rm -rf build sdkconfig - idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$bootloader_configs" copy_bootloader + idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$bootloader_configs" copy-bootloader if [ $? -ne 0 ]; then exit 1; fi done @@ -199,7 +237,7 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do echo "* Build Memory Variant: $mem_configs" rm -rf build sdkconfig - idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$mem_configs" mem_variant + idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$mem_configs" mem-variant if [ $? -ne 0 ]; then exit 1; fi done done From 95eebc351e98b75328c8969b352d3e123868dfb5 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 6 Apr 2024 13:12:54 +0200 Subject: [PATCH 114/211] updates --- .github/workflows/push.yml | 3 +++ README.md | 5 +++-- configs/builds.json | 12 ++++++++++-- configs/defconfig.120m | 1 + configs/defconfig.esp32 | 10 +++++----- configs/defconfig.esp32c2 | 3 +++ configs/defconfig.esp32c3 | 3 +++ configs/defconfig.esp32c6 | 3 +++ configs/defconfig.esp32h2 | 3 +++ configs/defconfig.esp32s2 | 5 ++++- configs/defconfig.esp32s3 | 11 ++++++++++- 11 files changed, 48 insertions(+), 11 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 56c1f527d..0a1aef29e 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -19,6 +19,9 @@ jobs: run: | echo "GIT_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV - name: Build Arduino Libs + env: + GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }} + GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }} run: bash ./build.sh - name: Release uses: jason2866/action-gh-release@v1.3 diff --git a/README.md b/README.md index 6e94b2775..9e78ce862 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,9 @@ This repository contains the scripts that produce the libraries included with Ta ### Build on Ubuntu ```bash -sudo apt-get install git wget curl libssl-dev libncurses-dev flex bison gperf python3 python3-pip python3-setuptools python3-serial python3-click python3-cryptography python3-future python3-pyparsing python3-pyelftools cmake ninja-build ccache jq p7zip-full -sudo pip3 install --upgrade pip3 +sudo apt update && sudo apt install -y git wget curl libssl-dev libncurses-dev flex bison gperf python3 cmake ninja-build ccache jq +curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python3 get-pip.py && \ +pip3 install setuptools pyserial click future wheel cryptography pyparsing pyelftools git clone https://github.com/Jason2866/esp32-arduino-lib-builder cd esp32-arduino-lib-builder ./build.sh diff --git a/configs/builds.json b/configs/builds.json index 2de37abeb..02695519c 100644 --- a/configs/builds.json +++ b/configs/builds.json @@ -134,15 +134,23 @@ "idf_libs":["qio","80m","opi_ram"], "bootloaders":[ ["qio","120m","qio_ram"], + ["qio","120m","opi_ram"], ["qio","80m","qio_ram"], ["qio","80m","opi_ram"], + ["opi","120m","qio_ram"], + ["opi","120m","opi_ram"], + ["opi","80m","qio_ram"], ["opi","80m","opi_ram"] ], "mem_variants":[ ["qio","120m","qio_ram"], + ["qio","120m","opi_ram"], ["qio","80m","qio_ram"], - ["opi","80m","opi_ram"], - ["opi","80m","qio_ram"] + ["qio","80m","opi_ram"], + ["opi","120m","qio_ram"], + ["opi","120m","opi_ram"], + ["opi","80m","qio_ram"], + ["opi","80m","opi_ram"] ] } ] diff --git a/configs/defconfig.120m b/configs/defconfig.120m index 2dd8e0253..11d11177f 100644 --- a/configs/defconfig.120m +++ b/configs/defconfig.120m @@ -1,2 +1,3 @@ CONFIG_ESPTOOLPY_FLASHFREQ_120M=y CONFIG_SPIRAM_SPEED_120M=y +CONFIG_SPI_FLASH_HPM_ENA=y diff --git a/configs/defconfig.esp32 b/configs/defconfig.esp32 index 626d5368d..f4e80e76f 100644 --- a/configs/defconfig.esp32 +++ b/configs/defconfig.esp32 @@ -15,6 +15,11 @@ CONFIG_BT_NIMBLE_MAX_CONNECTIONS=1 # CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_2M_PHY is not set # CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_CODED_PHY is not set # CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT is not set +# CONFIG_BTDM_CTRL_MODE_BTDM is not set +# CONFIG_BT_BTC_TASK_STACK_SIZE is not set +# CONFIG_BT_BTU_TASK_STACK_SIZE is not set +CONFIG_BT_STACK_NO_LOG=y +CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY=y CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR=y @@ -23,11 +28,6 @@ CONFIG_ETH_USE_ESP32_EMAC=y CONFIG_ETH_PHY_INTERFACE_RMII=y CONFIG_ETH_USE_SPI_ETHERNET=y -# CONFIG_BTDM_CTRL_MODE_BTDM is not set -# CONFIG_BT_BTC_TASK_STACK_SIZE is not set -# CONFIG_BT_BTU_TASK_STACK_SIZE is not set -CONFIG_BT_STACK_NO_LOG=y -CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY=y CONFIG_SPIRAM=y CONFIG_SPIRAM_OCCUPY_HSPI_HOST=y CONFIG_ULP_COPROC_ENABLED=y diff --git a/configs/defconfig.esp32c2 b/configs/defconfig.esp32c2 index 2e3ecad3d..b0cb51820 100644 --- a/configs/defconfig.esp32c2 +++ b/configs/defconfig.esp32c2 @@ -5,6 +5,9 @@ CONFIG_XTAL_FREQ=26 # Bluetooth # CONFIG_BT_ENABLED=y +CONFIG_BT_STACK_NO_LOG=y +# CONFIG_BT_BLE_42_FEATURES_SUPPORTED is not set +# CONFIG_BLE_MESH is not set CONFIG_BT_NIMBLE_ENABLED=y CONFIG_BT_NIMBLE_LOG_LEVEL_NONE=y CONFIG_BT_NIMBLE_MAX_CONNECTIONS=1 diff --git a/configs/defconfig.esp32c3 b/configs/defconfig.esp32c3 index 96296de58..c3c5f8518 100644 --- a/configs/defconfig.esp32c3 +++ b/configs/defconfig.esp32c3 @@ -2,6 +2,9 @@ # Bluetooth # CONFIG_BT_ENABLED=y +CONFIG_BT_STACK_NO_LOG=y +# CONFIG_BT_BLE_42_FEATURES_SUPPORTED is not set +# CONFIG_BLE_MESH is not set CONFIG_BT_NIMBLE_ENABLED=y CONFIG_BT_NIMBLE_LOG_LEVEL_NONE=y CONFIG_BT_NIMBLE_MAX_CONNECTIONS=1 diff --git a/configs/defconfig.esp32c6 b/configs/defconfig.esp32c6 index 5aa525c0c..f2cfcded3 100644 --- a/configs/defconfig.esp32c6 +++ b/configs/defconfig.esp32c6 @@ -10,6 +10,9 @@ CONFIG_ULP_COPROC_RESERVE_MEM=8192 # Bluetooth # CONFIG_BT_ENABLED=y +CONFIG_BT_STACK_NO_LOG=y +# CONFIG_BT_BLE_42_FEATURES_SUPPORTED is not set +# CONFIG_BLE_MESH is not set CONFIG_BT_NIMBLE_ENABLED=y CONFIG_BT_NIMBLE_LOG_LEVEL_NONE=y CONFIG_BT_NIMBLE_MAX_CONNECTIONS=1 diff --git a/configs/defconfig.esp32h2 b/configs/defconfig.esp32h2 index 96296de58..c3c5f8518 100644 --- a/configs/defconfig.esp32h2 +++ b/configs/defconfig.esp32h2 @@ -2,6 +2,9 @@ # Bluetooth # CONFIG_BT_ENABLED=y +CONFIG_BT_STACK_NO_LOG=y +# CONFIG_BT_BLE_42_FEATURES_SUPPORTED is not set +# CONFIG_BLE_MESH is not set CONFIG_BT_NIMBLE_ENABLED=y CONFIG_BT_NIMBLE_LOG_LEVEL_NONE=y CONFIG_BT_NIMBLE_MAX_CONNECTIONS=1 diff --git a/configs/defconfig.esp32s2 b/configs/defconfig.esp32s2 index 7aad2865d..23842a80b 100644 --- a/configs/defconfig.esp32s2 +++ b/configs/defconfig.esp32s2 @@ -1,6 +1,9 @@ -CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y CONFIG_SPIRAM=y +CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y +CONFIG_SPIRAM_RODATA=y +CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y +CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y CONFIG_ESP32S2_KEEP_USB_ALIVE=y CONFIG_ULP_COPROC_ENABLED=y CONFIG_ESP32_ULP_COPROC_RISCV=y diff --git a/configs/defconfig.esp32s3 b/configs/defconfig.esp32s3 index 0a4aae470..210bbb8bd 100644 --- a/configs/defconfig.esp32s3 +++ b/configs/defconfig.esp32s3 @@ -1,10 +1,15 @@ +CONFIG_IDF_EXPERIMENTAL_FEATURES=y + CONFIG_ULP_COPROC_ENABLED=y CONFIG_ULP_COPROC_TYPE_RISCV=y CONFIG_ULP_COPROC_RESERVE_MEM=4096 CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y CONFIG_SPIRAM=y +CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y +CONFIG_SPIRAM_RODATA=y CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y +CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y CONFIG_RTC_CLK_CAL_CYCLES=576 CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES_TWO=y # CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND is not set @@ -12,16 +17,20 @@ CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES_TWO=y CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=3120 CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=n +CONFIG_BOOTLOADER_FLASH_DC_AWARE=y # # S3 Display shift fix -> https://espressif-docs.readthedocs-hosted.com/projects/esp-faq/en/latest/software-framework/peripherals/lcd.html # -CONFIG_LCD_RGB_RESTART_IN_VSYNC=y +# CONFIG_LCD_RGB_RESTART_IN_VSYNC is not set # # Bluetooth # CONFIG_BT_ENABLED=y +CONFIG_BT_STACK_NO_LOG=y +# CONFIG_BT_BLE_42_FEATURES_SUPPORTED is not set +# CONFIG_BLE_MESH is not set CONFIG_BT_NIMBLE_ENABLED=y CONFIG_BT_NIMBLE_LOG_LEVEL_NONE=y CONFIG_BT_NIMBLE_MAX_CONNECTIONS=1 From 818cf4695057ee98c498e982969f46984144ce89 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 8 Apr 2024 21:48:52 +0200 Subject: [PATCH 115/211] add `*.inc` files --- tools/copy-libs.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/copy-libs.sh b/tools/copy-libs.sh index f49434462..219b68add 100755 --- a/tools/copy-libs.sh +++ b/tools/copy-libs.sh @@ -402,6 +402,12 @@ for item; do mkdir -p "$out_cpath$rel_p" cp -n $f "$out_cpath$rel_p/" done + for f in `find "$item" -name '*.inc'`; do + rel_f=${f#*$item} + rel_p=${rel_f%/*} + mkdir -p "$out_cpath$rel_p" + cp -n $f "$out_cpath$rel_p/" + done # Temporary measure to fix issues caused by https://github.com/espressif/esp-idf/commit/dc4731101dd567cc74bbe4d0f03afe52b7db9afb#diff-1d2ce0d3989a80830fdf230bcaafb3117f32046d16cf46616ac3d55b4df2a988R17 if [[ "$fname" == "bt" && "$out_sub" == "/include/$IDF_TARGET/include" && -f "$ipath/controller/$IDF_TARGET/esp_bt_cfg.h" ]]; then mkdir -p "$AR_SDK/include/$fname/controller/$IDF_TARGET" From 503e186a956e3242a4e16ad718c085b149c6e036 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 10 Apr 2024 12:57:24 +0200 Subject: [PATCH 116/211] rm `-fdebug-prefix-map entrys` from "CCFLAGS" --- tools/copy-libs.sh | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/tools/copy-libs.sh b/tools/copy-libs.sh index 219b68add..2de6dbbbd 100755 --- a/tools/copy-libs.sh +++ b/tools/copy-libs.sh @@ -101,7 +101,7 @@ for item in "${@:2:${#@}-5}"; do elif [ "$prefix" = "-O" ]; then PIO_CC_FLAGS+="$item " elif [[ "$item" != "-Wall" && "$item" != "-Werror=all" && "$item" != "-Wextra" ]]; then - if [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:20}" != "-fdiagnostics-color=" ]]; then + if [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:20}" != "-fdiagnostics-color=" && "${item:0:19}" != "-fdebug-prefix-map=" ]]; then C_FLAGS+="$item " fi fi @@ -115,7 +115,7 @@ set -- $str for item in "${@:2:${#@}-5}"; do prefix="${item:0:2}" if [[ "$prefix" != "-I" && "$prefix" != "-D" && "$item" != "-Wall" && "$item" != "-Werror=all" && "$item" != "-Wextra" && "$prefix" != "-O" ]]; then - if [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:20}" != "-fdiagnostics-color=" ]]; then + if [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:20}" != "-fdiagnostics-color=" && "${item:0:19}" != "-fdebug-prefix-map=" ]]; then AS_FLAGS+="$item " if [[ $C_FLAGS == *"$item"* ]]; then PIO_CC_FLAGS+="$item " @@ -134,7 +134,7 @@ set -- $str for item in "${@:2:${#@}-5}"; do prefix="${item:0:2}" if [[ "$prefix" != "-I" && "$prefix" != "-D" && "$item" != "-Wall" && "$item" != "-Werror=all" && "$item" != "-Wextra" && "$prefix" != "-O" ]]; then - if [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:20}" != "-fdiagnostics-color=" ]]; then + if [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:20}" != "-fdiagnostics-color=" && "${item:0:19}" != "-fdebug-prefix-map=" ]]; then CPP_FLAGS+="$item " if [[ $PIO_CC_FLAGS != *"$item"* ]]; then PIO_CXX_FLAGS+="$item " @@ -204,7 +204,7 @@ for item; do add_next=0 is_script=0 is_dir=0 - elif [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:17}" != "-Wl,--start-group" && "${item:0:15}" != "-Wl,--end-group" ]]; then + elif [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:19}" != "-fdebug-prefix-map=" && "${item:0:17}" != "-Wl,--start-group" && "${item:0:15}" != "-Wl,--end-group" ]]; then LD_FLAGS+="$item " PIO_LD_FLAGS+="$item " fi @@ -484,13 +484,6 @@ echo -n "$LD_FLAGS" > "$FLAGS_DIR/ld_flags" echo -n "$LD_SCRIPTS" > "$FLAGS_DIR/ld_scripts" echo -n "$AR_LIBS" > "$FLAGS_DIR/ld_libs" -# sr model.bin -if [ -f "build/srmodels/srmodels.bin" ]; then - mkdir -p "$AR_SDK/esp_sr" - cp -f "build/srmodels/srmodels.bin" "$AR_SDK/esp_sr/" - cp -f "partitions.csv" "$AR_SDK/esp_sr/" -fi - # sdkconfig cp -f "sdkconfig" "$AR_SDK/sdkconfig" From e16f1cccde1a6897974483c79e56abbc42d7e291 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 10 Apr 2024 14:59:34 +0200 Subject: [PATCH 117/211] rm -rf **/flags --- tools/archive-build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index 5d17a6c3a..8d87c092d 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -59,6 +59,8 @@ gawk -i inplace -v cuv1="framework-arduinoespressif32" -v cuv2="framework-ardui mv arduino-esp32/ framework-arduinoespressif32/ cd framework-arduinoespressif32/libraries rm -rf **/examples +cd ../tools/esp32-arduino-libs +rm -rf **/flags cd ../../ # If the framework is needed as tar.gz uncomment next line # tar --exclude=.* -zcf ../$pio_archive_path framework-arduinoespressif32/ From 850f60e16a279271ee422018ef22f05658b14db5 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 10 Apr 2024 15:10:37 +0200 Subject: [PATCH 118/211] back to correct folder for packing --- tools/archive-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index 8d87c092d..45b4a44a3 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -61,7 +61,7 @@ cd framework-arduinoespressif32/libraries rm -rf **/examples cd ../tools/esp32-arduino-libs rm -rf **/flags -cd ../../ +cd ../../../ # If the framework is needed as tar.gz uncomment next line # tar --exclude=.* -zcf ../$pio_archive_path framework-arduinoespressif32/ 7z a -mx=9 -tzip -xr'!.*' ../$pio_zip_archive_path framework-arduinoespressif32/ From 1786a7b1aa091d7aa04f18df3f0ef15e9c7c13fe Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 10 Apr 2024 19:09:02 +0200 Subject: [PATCH 119/211] remove unneeded code --- tools/install-arduino.sh | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index 0108de4ee..a098a61c7 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -84,20 +84,8 @@ rm -rf "$AR_COMPS/arduino/libraries/SimpleBLE" rm -rf "$AR_COMPS/arduino/libraries/BluetoothSerial" rm -rf "$AR_COMPS/arduino/libraries/WiFiProv" rm -rf "$AR_COMPS/arduino/libraries/WiFiClientSecure" +rm -rf "$AR_COMPS/arduino/libraries/NetworkClientSecure" rm -rf "$AR_COMPS/arduino/libraries/ESP32" rm -rf "$AR_COMPS/arduino/libraries/ESP_SR" rm -rf "$AR_COMPS/arduino/libraries/ESP_NOW" rm -rf "$AR_COMPS/arduino/libraries/TFLiteMicro" - -# -# CLONE/UPDATE ESP32-ARDUINO-LIBS -# -#if [ ! -d "$IDF_LIBS_DIR" ]; then -# echo "Cloning esp32-arduino-libs..." -# git clone "$AR_LIBS_REPO_URL" "$IDF_LIBS_DIR" -#else -# echo "Updating esp32-arduino-libs..." -# git -C "$IDF_LIBS_DIR" fetch && \ -# git -C "$IDF_LIBS_DIR" pull --ff-only -#fi -#if [ $? -ne 0 ]; then exit 1; fi From 1ad1b6d45c7adba7c438b945bf0321bcaf8e127f Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 10 Apr 2024 19:11:27 +0200 Subject: [PATCH 120/211] rm -rf arduino-esp32/libraries/NetworkClientSecure --- tools/archive-build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index 45b4a44a3..c3ba8be96 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -34,6 +34,7 @@ rm -rf arduino-esp32/libraries/SimpleBLE rm -rf arduino-esp32/libraries/BluetoothSerial rm -rf arduino-esp32/libraries/WiFiProv rm -rf arduino-esp32/libraries/WiFiClientSecure +rm -rf arduino-esp32/libraries/NetworkClientSecure rm -rf arduino-esp32/libraries/ESP_SR rm -rf arduino-esp32/libraries/ESP_NOW rm -rf arduino-esp32/libraries/TFLiteMicro From fff1b3ab33b2a7e9960d159be61ca65810f3a8fd Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 15 Apr 2024 19:16:38 +0200 Subject: [PATCH 121/211] rm SPI Eth from solo1 --- configs/defconfig.common | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index 4a2be049d..ef68086d9 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -50,9 +50,9 @@ CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=0 # CONFIG_ESP_WIFI_IRAM_OPT is not set # CONFIG_ESP_WIFI_RX_IRAM_OPT is not set CONFIG_ETH_TRANSMIT_MUTEX=y -CONFIG_ETH_SPI_ETHERNET_DM9051=y -CONFIG_ETH_SPI_ETHERNET_W5500=y -CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL=y +# CONFIG_ETH_SPI_ETHERNET_DM9051 is not set +# CONFIG_ETH_SPI_ETHERNET_W5500 is not set +# CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL is not set CONFIG_FATFS_CODEPAGE_850=y CONFIG_FATFS_LFN_STACK=y # CONFIG_FATFS_API_ENCODING_ANSI_OEM is not set From 677e826904ebd0e8b7127b023fb0b18206fbcb7e Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 15 Apr 2024 19:19:03 +0200 Subject: [PATCH 122/211] Disable Camera and TinyUSB suport --- tools/update-components.sh | 46 +++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/tools/update-components.sh b/tools/update-components.sh index 9fdbb8ea6..a3bf4ac5f 100755 --- a/tools/update-components.sh +++ b/tools/update-components.sh @@ -9,34 +9,34 @@ TINYUSB_REPO_DIR="$AR_COMPS/arduino_tinyusb/tinyusb" # # CLONE/UPDATE ESP32-CAMERA # -echo "Updating ESP32 Camera..." -if [ ! -d "$AR_COMPS/esp32-camera" ]; then - git clone -b master --recursive --depth 1 --shallow-submodule $CAMERA_REPO_URL "$AR_COMPS/esp32-camera" -else - cd "$AR_COMPS/esp32-camera" - git pull - git submodule update --depth 1 - # -ff is for cleaning untracked files as well as submodules - git clean -ffdx - cd - -fi -if [ $? -ne 0 ]; then exit 1; fi +#echo "Updating ESP32 Camera..." +#if [ ! -d "$AR_COMPS/esp32-camera" ]; then +# git clone -b master --recursive --depth 1 --shallow-submodule $CAMERA_REPO_URL "$AR_COMPS/esp32-camera" +#else +# cd "$AR_COMPS/esp32-camera" +# git pull +# git submodule update --depth 1 +# # -ff is for cleaning untracked files as well as submodules +# git clean -ffdx +# cd - +#fi +#if [ $? -ne 0 ]; then exit 1; fi # # Arduino needs cam_hal.h from esp32-camera in include folder # -cp "$AR_COMPS/esp32-camera/driver/private_include/cam_hal.h" "$AR_COMPS/esp32-camera/driver/include/" +#cp "$AR_COMPS/esp32-camera/driver/private_include/cam_hal.h" "$AR_COMPS/esp32-camera/driver/include/" # # CLONE/UPDATE TINYUSB # -echo "Updating TinyUSB..." -if [ ! -d "$TINYUSB_REPO_DIR" ]; then - git clone -b master --depth 1 "$TINYUSB_REPO_URL" "$TINYUSB_REPO_DIR" -else - cd $TINYUSB_REPO_DIR - git pull - # -ff is for cleaning untracked files as well as submodules - git clean -ffdx -fi -if [ $? -ne 0 ]; then exit 1; fi +#echo "Updating TinyUSB..." +#if [ ! -d "$TINYUSB_REPO_DIR" ]; then +# git clone -b master --depth 1 "$TINYUSB_REPO_URL" "$TINYUSB_REPO_DIR" +#else +# cd $TINYUSB_REPO_DIR +# git pull +# # -ff is for cleaning untracked files as well as submodules +# git clean -ffdx +#fi +#if [ $? -ne 0 ]; then exit 1; fi From bb65f08afb8ca1f598ec7bfb113b4c25c3ab282f Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 15 Apr 2024 20:46:27 +0200 Subject: [PATCH 123/211] Update defconfig.esp32 --- configs/defconfig.esp32 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/defconfig.esp32 b/configs/defconfig.esp32 index f4e80e76f..a52783e90 100644 --- a/configs/defconfig.esp32 +++ b/configs/defconfig.esp32 @@ -26,7 +26,7 @@ CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR=y CONFIG_ETH_ENABLED=y CONFIG_ETH_USE_ESP32_EMAC=y CONFIG_ETH_PHY_INTERFACE_RMII=y -CONFIG_ETH_USE_SPI_ETHERNET=y +# CONFIG_ETH_USE_SPI_ETHERNET is not set CONFIG_SPIRAM=y CONFIG_SPIRAM_OCCUPY_HSPI_HOST=y From 65bad9c4a5835fb4f4093a0dbfd84a4fd843f6fe Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 15 Apr 2024 21:06:53 +0200 Subject: [PATCH 124/211] switch off SPI RAM support --- configs/defconfig.esp32 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configs/defconfig.esp32 b/configs/defconfig.esp32 index a52783e90..f8068a560 100644 --- a/configs/defconfig.esp32 +++ b/configs/defconfig.esp32 @@ -26,10 +26,10 @@ CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR=y CONFIG_ETH_ENABLED=y CONFIG_ETH_USE_ESP32_EMAC=y CONFIG_ETH_PHY_INTERFACE_RMII=y -# CONFIG_ETH_USE_SPI_ETHERNET is not set +CONFIG_ETH_USE_SPI_ETHERNET=y -CONFIG_SPIRAM=y -CONFIG_SPIRAM_OCCUPY_HSPI_HOST=y +# CONFIG_SPIRAM is not set +# CONFIG_SPIRAM_OCCUPY_HSPI_HOST is not set CONFIG_ULP_COPROC_ENABLED=y # CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1 is not set # CONFIG_UNITY_ENABLE_FLOAT is not set From d5389d74a08aea6caad10b4e44e20b6472d3d35c Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 15 Apr 2024 21:36:19 +0200 Subject: [PATCH 125/211] enable SPI Ethernet --- configs/defconfig.common | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index ef68086d9..4a2be049d 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -50,9 +50,9 @@ CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=0 # CONFIG_ESP_WIFI_IRAM_OPT is not set # CONFIG_ESP_WIFI_RX_IRAM_OPT is not set CONFIG_ETH_TRANSMIT_MUTEX=y -# CONFIG_ETH_SPI_ETHERNET_DM9051 is not set -# CONFIG_ETH_SPI_ETHERNET_W5500 is not set -# CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL is not set +CONFIG_ETH_SPI_ETHERNET_DM9051=y +CONFIG_ETH_SPI_ETHERNET_W5500=y +CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL=y CONFIG_FATFS_CODEPAGE_850=y CONFIG_FATFS_LFN_STACK=y # CONFIG_FATFS_API_ENCODING_ANSI_OEM is not set From a1d26a9641f3c040d555ed11bbed8e4c71945c69 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:56:59 +0200 Subject: [PATCH 126/211] Delete components/arduino_tinyusb directory --- components/arduino_tinyusb/CMakeLists.txt | 74 - components/arduino_tinyusb/Kconfig.projbuild | 243 --- .../arduino_tinyusb/include/tusb_config.h | 143 -- components/arduino_tinyusb/src/dcd_dwc2.c | 1389 ----------------- components/arduino_tinyusb/src/dcd_esp32sx.c | 954 ----------- 5 files changed, 2803 deletions(-) delete mode 100755 components/arduino_tinyusb/CMakeLists.txt delete mode 100755 components/arduino_tinyusb/Kconfig.projbuild delete mode 100755 components/arduino_tinyusb/include/tusb_config.h delete mode 100644 components/arduino_tinyusb/src/dcd_dwc2.c delete mode 100755 components/arduino_tinyusb/src/dcd_esp32sx.c diff --git a/components/arduino_tinyusb/CMakeLists.txt b/components/arduino_tinyusb/CMakeLists.txt deleted file mode 100755 index 792b2a39f..000000000 --- a/components/arduino_tinyusb/CMakeLists.txt +++ /dev/null @@ -1,74 +0,0 @@ -if(CONFIG_TINYUSB_ENABLED) - - ### variables ### - ################# - - if(IDF_TARGET STREQUAL "esp32s2") - set(compile_options - "-DCFG_TUSB_MCU=OPT_MCU_ESP32S2" - "-DCFG_TUSB_DEBUG=${CONFIG_TINYUSB_DEBUG_LEVEL}" - "-Wno-type-limits" # needed for the vanila tinyusb with turned off classes - ) - elseif(IDF_TARGET STREQUAL "esp32s3") - set(compile_options - "-DCFG_TUSB_MCU=OPT_MCU_ESP32S3" - "-DCFG_TUSB_DEBUG=${CONFIG_TINYUSB_DEBUG_LEVEL}" - "-Wno-type-limits" # needed for the vanila tinyusb with turned off classes - ) - endif() - - set(srcs - # espressif: - "${COMPONENT_DIR}/src/dcd_esp32sx.c" - #"${COMPONENT_DIR}/src/dcd_dwc2.c" - # tusb: - #"${COMPONENT_DIR}/tinyusb/src/portable/espressif/esp32sx/dcd_esp32sx.c" - #"{COMPONENT_DIR}/tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.c" - "${COMPONENT_DIR}/tinyusb/src/class/cdc/cdc_device.c" - "${COMPONENT_DIR}/tinyusb/src/class/hid/hid_device.c" - "${COMPONENT_DIR}/tinyusb/src/class/midi/midi_device.c" - "${COMPONENT_DIR}/tinyusb/src/class/msc/msc_device.c" - "${COMPONENT_DIR}/tinyusb/src/class/video/video_device.c" - "${COMPONENT_DIR}/tinyusb/src/class/dfu/dfu_rt_device.c" - "${COMPONENT_DIR}/tinyusb/src/class/dfu/dfu_device.c" - "${COMPONENT_DIR}/tinyusb/src/class/vendor/vendor_device.c" - "${COMPONENT_DIR}/tinyusb/src/common/tusb_fifo.c" - "${COMPONENT_DIR}/tinyusb/src/device/usbd_control.c" - "${COMPONENT_DIR}/tinyusb/src/device/usbd.c" - "${COMPONENT_DIR}/tinyusb/src/tusb.c") - - set(includes_private - # tusb: - "${COMPONENT_DIR}/tinyusb/hw/bsp/" - "${COMPONENT_DIR}/tinyusb/src/" - "${COMPONENT_DIR}/tinyusb/src/device" - "${COMPONENT_DIR}/tinyusb/src/portable/synopsys/dwc2" - ) - - idf_component_get_property(FREERTOS_ORIG_INCLUDE_PATH freertos - ORIG_INCLUDE_PATH) - set(includes_public - # tusb: - "${FREERTOS_ORIG_INCLUDE_PATH}" - "${COMPONENT_DIR}/tinyusb/src/" - # espressif: - "${COMPONENT_DIR}/include") - - set(requires esp_rom freertos soc) - set(priv_requires arduino main) - ### tinyusb lib ### - ################### - idf_component_register(INCLUDE_DIRS ${includes_public} PRIV_INCLUDE_DIRS ${includes_private} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires}) - # add_library(${COMPONENT_TARGET} STATIC ${srcs}) - # target_include_directories( - # ${COMPONENT_TARGET} - # PUBLIC ${includes_public} - # PRIVATE ${includes_private}) - target_compile_options(${COMPONENT_TARGET} PRIVATE ${compile_options}) - #target_link_libraries(${COMPONENT_TARGET} INTERFACE ${COMPONENT_TARGET}) - -else() - - idf_component_register() - -endif() diff --git a/components/arduino_tinyusb/Kconfig.projbuild b/components/arduino_tinyusb/Kconfig.projbuild deleted file mode 100755 index 80983657f..000000000 --- a/components/arduino_tinyusb/Kconfig.projbuild +++ /dev/null @@ -1,243 +0,0 @@ -menu "Arduino TinyUSB" - - config TINYUSB_ENABLED - bool "Enable TinyUSB driver" - default y - depends on IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 - select FREERTOS_SUPPORT_STATIC_ALLOCATION - select FREERTOS_USE_AUTHENTIC_INCLUDE_PATHS - help - Adds support for TinyUSB - - menu "Serial (CDC) driver" - depends on TINYUSB_ENABLED - - config TINYUSB_CDC_ENABLED - bool "Enable USB Serial (CDC) TinyUSB driver" - default y - help - Enable USB Serial (CDC) TinyUSB driver. - - config TINYUSB_DESC_CDC_STRING - string "CDC Device String" - default "Espressif CDC Device" - depends on TINYUSB_CDC_ENABLED - help - Specify name of the CDC device - - config TINYUSB_CDC_RX_BUFSIZE - int "CDC FIFO size of RX" - default 64 - depends on TINYUSB_CDC_ENABLED - help - CDC FIFO size of RX - - config TINYUSB_CDC_TX_BUFSIZE - int "CDC FIFO size of TX" - default 64 - depends on TINYUSB_CDC_ENABLED - help - CDC FIFO size of TX - - endmenu - - menu "Mass Storage (MSC) driver" - depends on TINYUSB_ENABLED - - config TINYUSB_MSC_ENABLED - bool "Enable USB Mass Storage (MSC) TinyUSB driver" - default y - help - Enable USB Mass Storage (MSC) TinyUSB driver. - - config TINYUSB_DESC_MSC_STRING - string "MSC Device String" - default "Espressif MSC Device" - depends on TINYUSB_MSC_ENABLED - help - Specify name of the MSC device - - config TINYUSB_MSC_BUFSIZE - int "MSC Buffer size" - range 512 4096 - default 4096 - depends on TINYUSB_MSC_ENABLED - help - MSC Buffer size - - endmenu - - menu "Human Interface (HID) driver" - depends on TINYUSB_ENABLED - - config TINYUSB_HID_ENABLED - bool "Enable USB Human Interface (HID) TinyUSB driver" - default y - help - Enable USB Human Interface (HID) TinyUSB driver. - - config TINYUSB_DESC_HID_STRING - string "HID Device String" - default "Espressif HID Device" - depends on TINYUSB_HID_ENABLED - help - Specify name of the HID device - - config TINYUSB_HID_BUFSIZE - int "HID Buffer size" - default 64 - depends on TINYUSB_HID_ENABLED - help - HID Buffer size. Should be sufficient to hold ID (if any) + Data - - endmenu - - menu "MIDI driver" - depends on TINYUSB_ENABLED - - config TINYUSB_MIDI_ENABLED - bool "Enable USB MIDI TinyUSB driver" - default y - help - Enable USB MIDI TinyUSB driver. - - config TINYUSB_DESC_MIDI_STRING - string "MIDI Device String" - default "Espressif MIDI Device" - depends on TINYUSB_MIDI_ENABLED - help - Specify name of the MIDI device - - config TINYUSB_MIDI_RX_BUFSIZE - int "MIDI FIFO size of RX" - default 64 - depends on TINYUSB_MIDI_ENABLED - help - MIDI FIFO size of RX - - config TINYUSB_MIDI_TX_BUFSIZE - int "MIDI FIFO size of TX" - default 64 - depends on TINYUSB_MIDI_ENABLED - help - MIDI FIFO size of TX - - endmenu - - menu "VIDEO driver" - depends on TINYUSB_ENABLED - - config TINYUSB_VIDEO_ENABLED - bool "Enable USB VIDEO TinyUSB driver" - default y - help - Enable USB VIDEO TinyUSB driver. - - config TINYUSB_DESC_VIDEO_STRING - string "VIDEO Device String" - default "Espressif VIDEO Device" - depends on TINYUSB_VIDEO_ENABLED - help - Specify name of the VIDEO device - - config TINYUSB_VIDEO_STREAMING_BUFSIZE - int "VIDEO streaming endpoint size" - range 0 64 - default 64 - depends on TINYUSB_VIDEO_ENABLED - help - VIDEO streaming endpoint size - - config TINYUSB_VIDEO_STREAMING_IFS - int "Number of VIDEO streaming interfaces" - range 1 3 - default 1 - depends on TINYUSB_VIDEO_ENABLED - help - The number of VIDEO streaming interfaces - endmenu - - menu "DFU Runtime driver" - depends on TINYUSB_ENABLED - - config TINYUSB_DFU_RT_ENABLED - bool "Enable USB DFU Runtime TinyUSB driver" - default y - help - Enable USB DFU Runtime TinyUSB driver. - - config TINYUSB_DESC_DFU_RT_STRING - string "DFU_RT Device String" - default "Espressif DFU_RT Device" - depends on TINYUSB_DFU_RT_ENABLED - help - Specify name of the DFU_RT device - - endmenu - - menu "DFU driver" - depends on TINYUSB_ENABLED - - config TINYUSB_DFU_ENABLED - bool "Enable USB DFU TinyUSB driver" - default y - help - Enable USB DFU TinyUSB driver. - - config TINYUSB_DESC_DFU_STRING - string "DFU Device String" - default "Espressif DFU Device" - depends on TINYUSB_DFU_ENABLED - help - Specify name of the DFU device - - config TINYUSB_DFU_BUFSIZE - int "DFU buffer size" - default 4096 - depends on TINYUSB_DFU_ENABLED - help - DFU buffer size - - endmenu - - menu "VENDOR driver" - depends on TINYUSB_ENABLED - - config TINYUSB_VENDOR_ENABLED - bool "Enable USB VENDOR TinyUSB driver" - default y - help - Enable USB VENDOR TinyUSB driver. - - config TINYUSB_DESC_VENDOR_STRING - string "VENDOR Device String" - default "Espressif VENDOR Device" - depends on TINYUSB_VENDOR_ENABLED - help - Specify name of the VENDOR device - - config TINYUSB_VENDOR_RX_BUFSIZE - int "VENDOR FIFO size of RX" - default 64 - depends on TINYUSB_VENDOR_ENABLED - help - VENDOR FIFO size of RX - - config TINYUSB_VENDOR_TX_BUFSIZE - int "VENDOR FIFO size of TX" - default 64 - depends on TINYUSB_VENDOR_ENABLED - help - VENDOR FIFO size of TX - - endmenu - - config TINYUSB_DEBUG_LEVEL - int "TinyUSB log level (0-3)" - default 0 - range 0 3 - depends on TINYUSB_ENABLED - help - Define amount of log output from TinyUSB - -endmenu diff --git a/components/arduino_tinyusb/include/tusb_config.h b/components/arduino_tinyusb/include/tusb_config.h deleted file mode 100755 index ee1e5d270..000000000 --- a/components/arduino_tinyusb/include/tusb_config.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Ha Thach (tinyusb.org), - * Additions Copyright (c) 2020, Espressif Systems (Shanghai) PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -#pragma once -#include "tusb_option.h" -#include "sdkconfig.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* */ -/* KCONFIG */ -/* */ - -#ifndef CONFIG_TINYUSB_CDC_ENABLED -# define CONFIG_TINYUSB_CDC_ENABLED 0 -#endif - -#ifndef CONFIG_TINYUSB_MSC_ENABLED -# define CONFIG_TINYUSB_MSC_ENABLED 0 -#endif - -#ifndef CONFIG_TINYUSB_HID_ENABLED -# define CONFIG_TINYUSB_HID_ENABLED 0 -#endif - -#ifndef CONFIG_TINYUSB_MIDI_ENABLED -# define CONFIG_TINYUSB_MIDI_ENABLED 0 -#endif - -#ifndef CONFIG_TINYUSB_VIDEO_ENABLED -# define CONFIG_TINYUSB_VIDEO_ENABLED 0 -#endif - -#ifndef CONFIG_TINYUSB_CUSTOM_CLASS_ENABLED -# define CONFIG_TINYUSB_CUSTOM_CLASS_ENABLED 0 -#endif - -#ifndef CONFIG_TINYUSB_DFU_RT_ENABLED -# define CONFIG_TINYUSB_DFU_RT_ENABLED 0 -#endif - -#ifndef CONFIG_TINYUSB_DFU_ENABLED -# define CONFIG_TINYUSB_DFU_ENABLED 0 -#endif - -#ifndef CONFIG_TINYUSB_VENDOR_ENABLED -# define CONFIG_TINYUSB_VENDOR_ENABLED 0 -#endif - -/* */ -/* COMMON CONFIGURATION */ -/* */ - -#define CFG_TUSB_MCU OPT_MCU_ESP32S2 -#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE -#define CFG_TUSB_OS OPT_OS_FREERTOS - -/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment. - * Tinyusb use follows macros to declare transferring memory so that they can be put - * into those specific section. - * e.g - * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") )) - * - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4))) - */ -#ifndef CFG_TUSB_MEM_SECTION -# define CFG_TUSB_MEM_SECTION -#endif - -#ifndef CFG_TUSB_MEM_ALIGN -# define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4) -#endif - -/* */ -/* DRIVER CONFIGURATION */ -/* */ - -#define CFG_TUD_MAINTASK_SIZE 4096 -#define CFG_TUD_ENDOINT0_SIZE 64 - -// Enabled Drivers -#define CFG_TUD_CDC CONFIG_TINYUSB_CDC_ENABLED -#define CFG_TUD_MSC CONFIG_TINYUSB_MSC_ENABLED -#define CFG_TUD_HID CONFIG_TINYUSB_HID_ENABLED -#define CFG_TUD_MIDI CONFIG_TINYUSB_MIDI_ENABLED -#define CFG_TUD_VIDEO CONFIG_TINYUSB_VIDEO_ENABLED -#define CFG_TUD_CUSTOM_CLASS CONFIG_TINYUSB_CUSTOM_CLASS_ENABLED -#define CFG_TUD_DFU_RUNTIME CONFIG_TINYUSB_DFU_RT_ENABLED -#define CFG_TUD_DFU CONFIG_TINYUSB_DFU_ENABLED -#define CFG_TUD_VENDOR CONFIG_TINYUSB_VENDOR_ENABLED - -// CDC FIFO size of TX and RX -#define CFG_TUD_CDC_RX_BUFSIZE CONFIG_TINYUSB_CDC_RX_BUFSIZE -#define CFG_TUD_CDC_TX_BUFSIZE CONFIG_TINYUSB_CDC_TX_BUFSIZE - -// MSC Buffer size of Device Mass storage: -#define CFG_TUD_MSC_BUFSIZE CONFIG_TINYUSB_MSC_BUFSIZE - -// HID buffer size Should be sufficient to hold ID (if any) + Data -#define CFG_TUD_HID_BUFSIZE CONFIG_TINYUSB_HID_BUFSIZE - -// MIDI FIFO size of TX and RX -#define CFG_TUD_MIDI_RX_BUFSIZE CONFIG_TINYUSB_MIDI_RX_BUFSIZE -#define CFG_TUD_MIDI_TX_BUFSIZE CONFIG_TINYUSB_MIDI_TX_BUFSIZE - -// The number of video streaming interfaces and endpoint size -#define CFG_TUD_VIDEO_STREAMING CONFIG_TINYUSB_VIDEO_STREAMING_IFS -#define CFG_TUD_VIDEO_STREAMING_EP_BUFSIZE CONFIG_TINYUSB_VIDEO_STREAMING_BUFSIZE - -// DFU buffer size -#define CFG_TUD_DFU_XFER_BUFSIZE CONFIG_TINYUSB_DFU_BUFSIZE - -// VENDOR FIFO size of TX and RX -#define CFG_TUD_VENDOR_RX_BUFSIZE CONFIG_TINYUSB_VENDOR_RX_BUFSIZE -#define CFG_TUD_VENDOR_TX_BUFSIZE CONFIG_TINYUSB_VENDOR_TX_BUFSIZE - -#ifdef __cplusplus -} -#endif diff --git a/components/arduino_tinyusb/src/dcd_dwc2.c b/components/arduino_tinyusb/src/dcd_dwc2.c deleted file mode 100644 index 67653fda0..000000000 --- a/components/arduino_tinyusb/src/dcd_dwc2.c +++ /dev/null @@ -1,1389 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 William D. Jones - * Copyright (c) 2019 Ha Thach (tinyusb.org) - * Copyright (c) 2020 Jan Duempelmann - * Copyright (c) 2020 Reinhard Panhuber - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#include "tusb_option.h" - -#if CFG_TUD_ENABLED && defined(TUP_USBIP_DWC2) - -#include "device/dcd.h" -#include "dwc2_type.h" - -// Following symbols must be defined by port header -// - _dwc2_controller[]: array of controllers -// - DWC2_EP_MAX: largest EP counts of all controllers -// - dwc2_phy_init/dwc2_phy_update: phy init called before and after core reset -// - dwc2_dcd_int_enable/dwc2_dcd_int_disable -// - dwc2_remote_wakeup_delay - -#if defined(TUP_USBIP_DWC2_STM32) - #include "dwc2_stm32.h" -#elif TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) - #include "dwc2_esp32.h" -#elif TU_CHECK_MCU(OPT_MCU_GD32VF103) - #include "dwc2_gd32.h" -#elif TU_CHECK_MCU(OPT_MCU_BCM2711, OPT_MCU_BCM2835, OPT_MCU_BCM2837) - #include "dwc2_bcm.h" -#elif TU_CHECK_MCU(OPT_MCU_EFM32GG) - #include "dwc2_efm32.h" -#elif TU_CHECK_MCU(OPT_MCU_XMC4000) - #include "dwc2_xmc.h" -#else - #error "Unsupported MCUs" -#endif - -//--------------------------------------------------------------------+ -// MACRO TYPEDEF CONSTANT ENUM -//--------------------------------------------------------------------+ - -// DWC2 registers -#define DWC2_REG(_port) ((dwc2_regs_t*) _dwc2_controller[_port].reg_base) - -// Debug level for DWC2 -#define DWC2_DEBUG 2 - -#ifndef dcache_clean -#define dcache_clean(_addr, _size) -#endif - -#ifndef dcache_invalidate -#define dcache_invalidate(_addr, _size) -#endif - -#ifndef dcache_clean_invalidate -#define dcache_clean_invalidate(_addr, _size) -#endif - -static TU_ATTR_ALIGNED(4) uint32_t _setup_packet[2]; - -typedef struct { - uint8_t * buffer; - tu_fifo_t * ff; - uint16_t total_len; - uint16_t max_size; - uint8_t interval; -} xfer_ctl_t; - -static xfer_ctl_t xfer_status[DWC2_EP_MAX][2]; -#define XFER_CTL_BASE(_ep, _dir) (&xfer_status[_ep][_dir]) - -// EP0 transfers are limited to 1 packet - larger sizes has to be split -static uint16_t ep0_pending[2]; // Index determines direction as tusb_dir_t type - -// TX FIFO RAM allocation so far in words - RX FIFO size is readily available from dwc2->grxfsiz -static uint16_t _allocated_fifo_words_tx; // TX FIFO size in words (IN EPs) -static bool _out_ep_closed; // Flag to check if RX FIFO size needs an update (reduce its size) - -// SOF enabling flag - required for SOF to not get disabled in ISR when SOF was enabled by -static bool _sof_en; - -// Calculate the RX FIFO size according to recommendations from reference manual -static inline uint16_t calc_grxfsiz(uint16_t max_ep_size, uint8_t ep_count) -{ - return 15 + 2*(max_ep_size/4) + 2*ep_count; -} - -static void update_grxfsiz(uint8_t rhport) -{ - dwc2_regs_t * dwc2 = DWC2_REG(rhport); - uint8_t const ep_count = _dwc2_controller[rhport].ep_count; - - // Determine largest EP size for RX FIFO - uint16_t max_epsize = 0; - for (uint8_t epnum = 0; epnum < ep_count; epnum++) - { - max_epsize = tu_max16(max_epsize, xfer_status[epnum][TUSB_DIR_OUT].max_size); - } - - // Update size of RX FIFO - dwc2->grxfsiz = calc_grxfsiz(max_epsize, ep_count); -} - -// Start of Bus Reset -static void bus_reset(uint8_t rhport) -{ - dwc2_regs_t * dwc2 = DWC2_REG(rhport); - uint8_t const ep_count = _dwc2_controller[rhport].ep_count; - - tu_memclr(xfer_status, sizeof(xfer_status)); - _out_ep_closed = false; - - _sof_en = false; - - // clear device address - dwc2->dcfg &= ~DCFG_DAD_Msk; - - // 1. NAK for all OUT endpoints - for ( uint8_t n = 0; n < ep_count; n++ ) - { - dwc2->epout[n].doepctl |= DOEPCTL_SNAK; - } - - // 2. Set up interrupt mask - dwc2->daintmsk = TU_BIT(DAINTMSK_OEPM_Pos) | TU_BIT(DAINTMSK_IEPM_Pos); - dwc2->doepmsk = DOEPMSK_STUPM | DOEPMSK_XFRCM; - dwc2->diepmsk = DIEPMSK_TOM | DIEPMSK_XFRCM; - - // "USB Data FIFOs" section in reference manual - // Peripheral FIFO architecture - // - // The FIFO is split up in a lower part where the RX FIFO is located and an upper part where the TX FIFOs start. - // We do this to allow the RX FIFO to grow dynamically which is possible since the free space is located - // between the RX and TX FIFOs. This is required by ISO OUT EPs which need a bigger FIFO than the standard - // configuration done below. - // - // Dynamically FIFO sizes are of interest only for ISO EPs since all others are usually not opened and closed. - // All EPs other than ISO are opened as soon as the driver starts up i.e. when the host sends a - // configure interface command. Hence, all IN EPs other the ISO will be located at the top. IN ISO EPs are usually - // opened when the host sends an additional command: setInterface. At this point in time - // the ISO EP will be located next to the free space and can change its size. In case more IN EPs change its size - // an additional memory - // - // --------------- 320 or 1024 ( 1280 or 4096 bytes ) - // | IN FIFO 0 | - // --------------- (320 or 1024) - 16 - // | IN FIFO 1 | - // --------------- (320 or 1024) - 16 - x - // | . . . . | - // --------------- (320 or 1024) - 16 - x - y - ... - z - // | IN FIFO MAX | - // --------------- - // | FREE | - // --------------- GRXFSIZ - // | OUT FIFO | - // | ( Shared ) | - // --------------- 0 - // - // According to "FIFO RAM allocation" section in RM, FIFO RAM are allocated as follows (each word 32-bits): - // - Each EP IN needs at least max packet size, 16 words is sufficient for EP0 IN - // - // - All EP OUT shared a unique OUT FIFO which uses - // - 13 for setup packets + control words (up to 3 setup packets). - // - 1 for global NAK (not required/used here). - // - Largest-EPsize / 4 + 1. ( FS: 64 bytes, HS: 512 bytes). Recommended is "2 x (Largest-EPsize/4) + 1" - // - 2 for each used OUT endpoint - // - // Therefore GRXFSIZ = 13 + 1 + 1 + 2 x (Largest-EPsize/4) + 2 x EPOUTnum - // - FullSpeed (64 Bytes ): GRXFSIZ = 15 + 2 x 16 + 2 x ep_count = 47 + 2 x ep_count - // - Highspeed (512 bytes): GRXFSIZ = 15 + 2 x 128 + 2 x ep_count = 271 + 2 x ep_count - // - // NOTE: Largest-EPsize & EPOUTnum is actual used endpoints in configuration. Since DCD has no knowledge - // of the overall picture yet. We will use the worst scenario: largest possible + ep_count - // - // For Isochronous, largest EP size can be 1023/1024 for FS/HS respectively. In addition if multiple ISO - // are enabled at least "2 x (Largest-EPsize/4) + 1" are recommended. Maybe provide a macro for application to - // overwrite this. - - // EP0 out max is 64 - dwc2->grxfsiz = calc_grxfsiz(64, ep_count); - - // Setup the control endpoint 0 - _allocated_fifo_words_tx = 16; - - // Control IN uses FIFO 0 with 64 bytes ( 16 32-bit word ) - dwc2->dieptxf0 = (16 << DIEPTXF0_TX0FD_Pos) | (_dwc2_controller[rhport].ep_fifo_size/4 - _allocated_fifo_words_tx); - - // Fixed control EP0 size to 64 bytes - dwc2->epin[0].diepctl &= ~(0x03 << DIEPCTL_MPSIZ_Pos); - xfer_status[0][TUSB_DIR_OUT].max_size = 64; - xfer_status[0][TUSB_DIR_IN ].max_size = 64; - - dwc2->epout[0].doeptsiz |= (3 << DOEPTSIZ_STUPCNT_Pos); - - dwc2->gintmsk |= GINTMSK_OEPINT | GINTMSK_IEPINT; -} - -static void edpt_schedule_packets(uint8_t rhport, uint8_t const epnum, uint8_t const dir, uint16_t const num_packets, uint16_t total_bytes) -{ - (void) rhport; - - dwc2_regs_t * dwc2 = DWC2_REG(rhport); - - // EP0 is limited to one packet each xfer - // We use multiple transaction of xfer->max_size length to get a whole transfer done - if ( epnum == 0 ) - { - xfer_ctl_t *const xfer = XFER_CTL_BASE(epnum, dir); - total_bytes = tu_min16(ep0_pending[dir], xfer->max_size); - ep0_pending[dir] -= total_bytes; - } - - // IN and OUT endpoint xfers are interrupt-driven, we just schedule them here. - if ( dir == TUSB_DIR_IN ) - { - dwc2_epin_t* epin = dwc2->epin; - - // A full IN transfer (multiple packets, possibly) triggers XFRC. - epin[epnum].dieptsiz = (num_packets << DIEPTSIZ_PKTCNT_Pos) | - ((total_bytes << DIEPTSIZ_XFRSIZ_Pos) & DIEPTSIZ_XFRSIZ_Msk); - - epin[epnum].diepctl |= DIEPCTL_EPENA | DIEPCTL_CNAK; - - // For ISO endpoint set correct odd/even bit for next frame. - if ( (epin[epnum].diepctl & DIEPCTL_EPTYP) == DIEPCTL_EPTYP_0 && (XFER_CTL_BASE(epnum, dir))->interval == 1 ) - { - // Take odd/even bit from frame counter. - uint32_t const odd_frame_now = (dwc2->dsts & (1u << DSTS_FNSOF_Pos)); - epin[epnum].diepctl |= (odd_frame_now ? DIEPCTL_SD0PID_SEVNFRM_Msk : DIEPCTL_SODDFRM_Msk); - } - // Enable fifo empty interrupt only if there are something to put in the fifo. - if ( total_bytes != 0 ) - { - dwc2->diepempmsk |= (1 << epnum); - } - } - else - { - dwc2_epout_t* epout = dwc2->epout; - - // A full OUT transfer (multiple packets, possibly) triggers XFRC. - epout[epnum].doeptsiz &= ~(DOEPTSIZ_PKTCNT_Msk | DOEPTSIZ_XFRSIZ); - epout[epnum].doeptsiz |= (num_packets << DOEPTSIZ_PKTCNT_Pos) | - ((total_bytes << DOEPTSIZ_XFRSIZ_Pos) & DOEPTSIZ_XFRSIZ_Msk); - - epout[epnum].doepctl |= DOEPCTL_EPENA | DOEPCTL_CNAK; - if ( (epout[epnum].doepctl & DOEPCTL_EPTYP) == DOEPCTL_EPTYP_0 && - XFER_CTL_BASE(epnum, dir)->interval == 1 ) - { - // Take odd/even bit from frame counter. - uint32_t const odd_frame_now = (dwc2->dsts & (1u << DSTS_FNSOF_Pos)); - epout[epnum].doepctl |= (odd_frame_now ? DOEPCTL_SD0PID_SEVNFRM_Msk : DOEPCTL_SODDFRM_Msk); - } - } -} - -/*------------------------------------------------------------------*/ -/* Controller API - *------------------------------------------------------------------*/ -#if CFG_TUSB_DEBUG >= DWC2_DEBUG -void print_dwc2_info(dwc2_regs_t * dwc2) -{ - dwc2_ghwcfg2_t const * hw_cfg2 = &dwc2->ghwcfg2_bm; - dwc2_ghwcfg3_t const * hw_cfg3 = &dwc2->ghwcfg3_bm; - dwc2_ghwcfg4_t const * hw_cfg4 = &dwc2->ghwcfg4_bm; - -// TU_LOG_HEX(DWC2_DEBUG, dwc2->gotgctl); -// TU_LOG_HEX(DWC2_DEBUG, dwc2->gusbcfg); -// TU_LOG_HEX(DWC2_DEBUG, dwc2->dcfg); - TU_LOG_HEX(DWC2_DEBUG, dwc2->guid); - TU_LOG_HEX(DWC2_DEBUG, dwc2->gsnpsid); - TU_LOG_HEX(DWC2_DEBUG, dwc2->ghwcfg1); - - // HW configure 2 - TU_LOG(DWC2_DEBUG, "\r\n"); - TU_LOG_HEX(DWC2_DEBUG, dwc2->ghwcfg2); - TU_LOG_INT(DWC2_DEBUG, hw_cfg2->op_mode ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg2->arch ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg2->point2point ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg2->hs_phy_type ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg2->fs_phy_type ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg2->num_dev_ep ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg2->num_host_ch ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg2->period_channel_support ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg2->enable_dynamic_fifo ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg2->mul_cpu_int ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg2->nperiod_tx_q_depth ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg2->host_period_tx_q_depth ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg2->dev_token_q_depth ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg2->otg_enable_ic_usb ); - - // HW configure 3 - TU_LOG(DWC2_DEBUG, "\r\n"); - TU_LOG_HEX(DWC2_DEBUG, dwc2->ghwcfg3); - TU_LOG_INT(DWC2_DEBUG, hw_cfg3->xfer_size_width ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg3->packet_size_width ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg3->otg_enable ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg3->i2c_enable ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg3->vendor_ctrl_itf ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg3->optional_feature_removed ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg3->synch_reset ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg3->otg_adp_support ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg3->otg_enable_hsic ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg3->battery_charger_support ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg3->lpm_mode ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg3->total_fifo_size ); - - // HW configure 4 - TU_LOG(DWC2_DEBUG, "\r\n"); - TU_LOG_HEX(DWC2_DEBUG, dwc2->ghwcfg4); - TU_LOG_INT(DWC2_DEBUG, hw_cfg4->num_dev_period_in_ep ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg4->power_optimized ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg4->ahb_freq_min ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg4->hibernation ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg4->service_interval_mode ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg4->ipg_isoc_en ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg4->acg_enable ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg4->utmi_phy_data_width ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg4->dev_ctrl_ep_num ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg4->iddg_filter_enabled ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg4->vbus_valid_filter_enabled ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg4->a_valid_filter_enabled ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg4->b_valid_filter_enabled ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg4->dedicated_fifos ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg4->num_dev_in_eps ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg4->dma_desc_enable ); - TU_LOG_INT(DWC2_DEBUG, hw_cfg4->dma_dynamic ); -} -#endif - -static void reset_core(dwc2_regs_t * dwc2) -{ - // reset core - dwc2->grstctl |= GRSTCTL_CSRST; - - // wait for reset bit is cleared - // TODO version 4.20a should wait for RESET DONE mask - while (dwc2->grstctl & GRSTCTL_CSRST) { } - - // wait for AHB master IDLE - while ( !(dwc2->grstctl & GRSTCTL_AHBIDL) ) { } - - // wait for device mode ? -} - -static bool phy_hs_supported(dwc2_regs_t * dwc2) -{ - // note: esp32 incorrect report its hs_phy_type as utmi -#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) - return false; -#else - return TUD_OPT_HIGH_SPEED && dwc2->ghwcfg2_bm.hs_phy_type != HS_PHY_TYPE_NONE; -#endif -} - -static void phy_fs_init(dwc2_regs_t * dwc2) -{ - TU_LOG(DWC2_DEBUG, "Fullspeed PHY init\r\n"); - - // Select FS PHY - dwc2->gusbcfg |= GUSBCFG_PHYSEL; - - // MCU specific PHY init before reset - dwc2_phy_init(dwc2, HS_PHY_TYPE_NONE); - - // Reset core after selecting PHY - reset_core(dwc2); - - // USB turnaround time is critical for certification where long cables and 5-Hubs are used. - // So if you need the AHB to run at less than 30 MHz, and if USB turnaround time is not critical, - // these bits can be programmed to a larger value. Default is 5 - dwc2->gusbcfg = (dwc2->gusbcfg & ~GUSBCFG_TRDT_Msk) | (5u << GUSBCFG_TRDT_Pos); - - // MCU specific PHY update post reset - dwc2_phy_update(dwc2, HS_PHY_TYPE_NONE); - - // set max speed - dwc2->dcfg = (dwc2->dcfg & ~DCFG_DSPD_Msk) | (DCFG_DSPD_FS << DCFG_DSPD_Pos); -} - -static void phy_hs_init(dwc2_regs_t * dwc2) -{ - uint32_t gusbcfg = dwc2->gusbcfg; - - // De-select FS PHY - gusbcfg &= ~GUSBCFG_PHYSEL; - - if (dwc2->ghwcfg2_bm.hs_phy_type == HS_PHY_TYPE_ULPI) - { - TU_LOG(DWC2_DEBUG, "Highspeed ULPI PHY init\r\n"); - - // Select ULPI - gusbcfg |= GUSBCFG_ULPI_UTMI_SEL; - - // ULPI 8-bit interface, single data rate - gusbcfg &= ~(GUSBCFG_PHYIF16 | GUSBCFG_DDRSEL); - - // default internal VBUS Indicator and Drive - gusbcfg &= ~(GUSBCFG_ULPIEVBUSD | GUSBCFG_ULPIEVBUSI); - - // Disable FS/LS ULPI - gusbcfg &= ~(GUSBCFG_ULPIFSLS | GUSBCFG_ULPICSM); - }else - { - TU_LOG(DWC2_DEBUG, "Highspeed UTMI+ PHY init\r\n"); - - // Select UTMI+ with 8-bit interface - gusbcfg &= ~(GUSBCFG_ULPI_UTMI_SEL | GUSBCFG_PHYIF16); - - // Set 16-bit interface if supported - if (dwc2->ghwcfg4_bm.utmi_phy_data_width) gusbcfg |= GUSBCFG_PHYIF16; - } - - // Apply config - dwc2->gusbcfg = gusbcfg; - - // mcu specific phy init - dwc2_phy_init(dwc2, dwc2->ghwcfg2_bm.hs_phy_type); - - // Reset core after selecting PHY - reset_core(dwc2); - - // Set turn-around, must after core reset otherwise it will be clear - // - 9 if using 8-bit PHY interface - // - 5 if using 16-bit PHY interface - gusbcfg &= ~GUSBCFG_TRDT_Msk; - gusbcfg |= (dwc2->ghwcfg4_bm.utmi_phy_data_width ? 5u : 9u) << GUSBCFG_TRDT_Pos; - dwc2->gusbcfg = gusbcfg; - - // MCU specific PHY update post reset - dwc2_phy_update(dwc2, dwc2->ghwcfg2_bm.hs_phy_type); - - // Set max speed - uint32_t dcfg = dwc2->dcfg; - dcfg &= ~DCFG_DSPD_Msk; - dcfg |= DCFG_DSPD_HS << DCFG_DSPD_Pos; - - // XCVRDLY: transceiver delay between xcvr_sel and txvalid during device chirp is required - // when using with some PHYs such as USB334x (USB3341, USB3343, USB3346, USB3347) - if (dwc2->ghwcfg2_bm.hs_phy_type == HS_PHY_TYPE_ULPI) dcfg |= DCFG_XCVRDLY; - - dwc2->dcfg = dcfg; -} - -static bool check_dwc2(dwc2_regs_t * dwc2) -{ -#if CFG_TUSB_DEBUG >= DWC2_DEBUG - print_dwc2_info(dwc2); -#endif - - // For some reasons: GD32VF103 snpsid and all hwcfg register are always zero (skip it) - (void) dwc2; -#if !TU_CHECK_MCU(OPT_MCU_GD32VF103) - uint32_t const gsnpsid = dwc2->gsnpsid & GSNPSID_ID_MASK; - TU_ASSERT(gsnpsid == DWC2_OTG_ID || gsnpsid == DWC2_FS_IOT_ID || gsnpsid == DWC2_HS_IOT_ID); -#endif - - return true; -} - -void dcd_init (uint8_t rhport) -{ - // Programming model begins in the last section of the chapter on the USB - // peripheral in each Reference Manual. - dwc2_regs_t * dwc2 = DWC2_REG(rhport); - - // Check Synopsys ID register, failed if controller clock/power is not enabled - TU_VERIFY(check_dwc2(dwc2), ); - - dcd_disconnect(rhport); - - // max number of endpoints & total_fifo_size are: - // hw_cfg2->num_dev_ep, hw_cfg2->total_fifo_size - - if( phy_hs_supported(dwc2) ) - { - // Highspeed - phy_hs_init(dwc2); - }else - { - // core does not support highspeed or hs-phy is not present - phy_fs_init(dwc2); - } - - // Restart PHY clock - dwc2->pcgctl &= ~(PCGCTL_STOPPCLK | PCGCTL_GATEHCLK | PCGCTL_PWRCLMP | PCGCTL_RSTPDWNMODULE); - - /* Set HS/FS Timeout Calibration to 7 (max available value). - * The number of PHY clocks that the application programs in - * this field is added to the high/full speed interpacket timeout - * duration in the core to account for any additional delays - * introduced by the PHY. This can be required, because the delay - * introduced by the PHY in generating the linestate condition - * can vary from one PHY to another. - */ - dwc2->gusbcfg |= (7ul << GUSBCFG_TOCAL_Pos); - - // Force device mode - dwc2->gusbcfg = (dwc2->gusbcfg & ~GUSBCFG_FHMOD) | GUSBCFG_FDMOD; - - // Clear A override, force B Valid - dwc2->gotgctl = (dwc2->gotgctl & ~GOTGCTL_AVALOEN) | GOTGCTL_BVALOEN | GOTGCTL_BVALOVAL; - - // If USB host misbehaves during status portion of control xfer - // (non zero-length packet), send STALL back and discard. - dwc2->dcfg |= DCFG_NZLSOHSK; - - // Clear all interrupts - uint32_t int_mask = dwc2->gintsts; - dwc2->gintsts |= int_mask; - int_mask = dwc2->gotgint; - dwc2->gotgint |= int_mask; - - // Required as part of core initialization. - // TODO: How should mode mismatch be handled? It will cause - // the core to stop working/require reset. - dwc2->gintmsk = GINTMSK_OTGINT | GINTMSK_MMISM | GINTMSK_RXFLVLM | - GINTMSK_USBSUSPM | GINTMSK_USBRST | GINTMSK_ENUMDNEM | GINTMSK_WUIM; - - // Enable global interrupt - dwc2->gahbcfg |= GAHBCFG_GINT; - - // make sure we are in device mode -// TU_ASSERT(!(dwc2->gintsts & GINTSTS_CMOD), ); - -// TU_LOG_HEX(DWC2_DEBUG, dwc2->gotgctl); -// TU_LOG_HEX(DWC2_DEBUG, dwc2->gusbcfg); -// TU_LOG_HEX(DWC2_DEBUG, dwc2->dcfg); -// TU_LOG_HEX(DWC2_DEBUG, dwc2->gahbcfg); - - dcd_connect(rhport); -} - -void dcd_int_enable (uint8_t rhport) -{ - dwc2_dcd_int_enable(rhport); -} - -void dcd_int_disable (uint8_t rhport) -{ - dwc2_dcd_int_disable(rhport); -} - -void dcd_set_address (uint8_t rhport, uint8_t dev_addr) -{ - dwc2_regs_t * dwc2 = DWC2_REG(rhport); - dwc2->dcfg = (dwc2->dcfg & ~DCFG_DAD_Msk) | (dev_addr << DCFG_DAD_Pos); - - // Response with status after changing device address - dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0); -} - -void dcd_remote_wakeup(uint8_t rhport) -{ - (void) rhport; - - dwc2_regs_t * dwc2 = DWC2_REG(rhport); - - // set remote wakeup - dwc2->dctl |= DCTL_RWUSIG; - - // enable SOF to detect bus resume - dwc2->gintsts = GINTSTS_SOF; - dwc2->gintmsk |= GINTMSK_SOFM; - - // Per specs: remote wakeup signal bit must be clear within 1-15ms - dwc2_remote_wakeup_delay(); - - dwc2->dctl &= ~DCTL_RWUSIG; -} - -void dcd_connect(uint8_t rhport) -{ - (void) rhport; - dwc2_regs_t * dwc2 = DWC2_REG(rhport); - dwc2->dctl &= ~DCTL_SDIS; -} - -void dcd_disconnect(uint8_t rhport) -{ - (void) rhport; - dwc2_regs_t * dwc2 = DWC2_REG(rhport); - dwc2->dctl |= DCTL_SDIS; -} - -// Be advised: audio, video and possibly other iso-ep classes use dcd_sof_enable() to enable/disable its corresponding ISR on purpose! -void dcd_sof_enable(uint8_t rhport, bool en) -{ - (void) rhport; - dwc2_regs_t * dwc2 = DWC2_REG(rhport); - - _sof_en = en; - - if (en) - { - dwc2->gintsts = GINTSTS_SOF; - dwc2->gintmsk |= GINTMSK_SOFM; - } - else - { - dwc2->gintmsk &= ~GINTMSK_SOFM; - } -} - -/*------------------------------------------------------------------*/ -/* DCD Endpoint port - *------------------------------------------------------------------*/ -#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) -// Keep count of how many FIFOs are in use -static uint8_t _allocated_fifos = 1; //FIFO0 is always in use - -// Will either return an unused FIFO number, or 0 if all are used. -static uint8_t get_free_fifo(void) -{ - if (_allocated_fifos < 5) return _allocated_fifos++; - return 0; -} -#endif - -bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * desc_edpt) -{ - (void) rhport; - - dwc2_regs_t * dwc2 = DWC2_REG(rhport); - uint8_t const ep_count = _dwc2_controller[rhport].ep_count; - - uint8_t const epnum = tu_edpt_number(desc_edpt->bEndpointAddress); - uint8_t const dir = tu_edpt_dir(desc_edpt->bEndpointAddress); - - TU_ASSERT(epnum < ep_count); - - xfer_ctl_t * xfer = XFER_CTL_BASE(epnum, dir); - xfer->max_size = tu_edpt_packet_size(desc_edpt); - xfer->interval = desc_edpt->bInterval; - - uint16_t const fifo_size = tu_div_ceil(xfer->max_size, 4); - - if(dir == TUSB_DIR_OUT) - { - // Calculate required size of RX FIFO - uint16_t const sz = calc_grxfsiz(4*fifo_size, ep_count); - - // If size_rx needs to be extended check if possible and if so enlarge it - if (dwc2->grxfsiz < sz) - { - TU_ASSERT(sz + _allocated_fifo_words_tx <= _dwc2_controller[rhport].ep_fifo_size/4); - - // Enlarge RX FIFO - dwc2->grxfsiz = sz; - } - - dwc2->epout[epnum].doepctl |= (1 << DOEPCTL_USBAEP_Pos) | - (desc_edpt->bmAttributes.xfer << DOEPCTL_EPTYP_Pos) | - (desc_edpt->bmAttributes.xfer != TUSB_XFER_ISOCHRONOUS ? DOEPCTL_SD0PID_SEVNFRM : 0) | - (xfer->max_size << DOEPCTL_MPSIZ_Pos); - - dwc2->daintmsk |= TU_BIT(DAINTMSK_OEPM_Pos + epnum); - } - else - { - // "USB Data FIFOs" section in reference manual - // Peripheral FIFO architecture - // - // --------------- 320 or 1024 ( 1280 or 4096 bytes ) - // | IN FIFO 0 | - // --------------- (320 or 1024) - 16 - // | IN FIFO 1 | - // --------------- (320 or 1024) - 16 - x - // | . . . . | - // --------------- (320 or 1024) - 16 - x - y - ... - z - // | IN FIFO MAX | - // --------------- - // | FREE | - // --------------- GRXFSIZ - // | OUT FIFO | - // | ( Shared ) | - // --------------- 0 - // - // In FIFO is allocated by following rules: - // - IN EP 1 gets FIFO 1, IN EP "n" gets FIFO "n". - - uint8_t fifo_num = epnum; -#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) - // Special Case for EP5, which is used by CDC but not actually called by the driver - // we can give it a fake FIFO - if (epnum == 5) { - fifo_num = epnum; - } else { - fifo_num = get_free_fifo(); - } - TU_ASSERT(fifo_num != 0); -#endif - // Check if free space is available - TU_ASSERT(_allocated_fifo_words_tx + fifo_size + dwc2->grxfsiz <= _dwc2_controller[rhport].ep_fifo_size/4); - - _allocated_fifo_words_tx += fifo_size; - - TU_LOG(DWC2_DEBUG, " Allocated %u bytes at offset %lu", fifo_size*4, _dwc2_controller[rhport].ep_fifo_size-_allocated_fifo_words_tx*4); - - // DIEPTXF starts at FIFO #1. - // Both TXFD and TXSA are in unit of 32-bit words. - dwc2->dieptxf[epnum - 1] = (fifo_size << DIEPTXF_INEPTXFD_Pos) | (_dwc2_controller[rhport].ep_fifo_size/4 - _allocated_fifo_words_tx); - - dwc2->epin[epnum].diepctl |= (1 << DIEPCTL_USBAEP_Pos) | - (fifo_num << DIEPCTL_TXFNUM_Pos) | - (desc_edpt->bmAttributes.xfer << DIEPCTL_EPTYP_Pos) | - (desc_edpt->bmAttributes.xfer != TUSB_XFER_ISOCHRONOUS ? DIEPCTL_SD0PID_SEVNFRM : 0) | - (xfer->max_size << DIEPCTL_MPSIZ_Pos); - - dwc2->daintmsk |= (1 << (DAINTMSK_IEPM_Pos + epnum)); - } - - return true; -} - -// Close all non-control endpoints, cancel all pending transfers if any. -void dcd_edpt_close_all (uint8_t rhport) -{ - dwc2_regs_t * dwc2 = DWC2_REG(rhport); - uint8_t const ep_count = _dwc2_controller[rhport].ep_count; - - // Disable non-control interrupt - dwc2->daintmsk = (1 << DAINTMSK_OEPM_Pos) | (1 << DAINTMSK_IEPM_Pos); - - for(uint8_t n = 1; n < ep_count; n++) - { - // disable OUT endpoint - dwc2->epout[n].doepctl = 0; - xfer_status[n][TUSB_DIR_OUT].max_size = 0; - - // disable IN endpoint - dwc2->epin[n].diepctl = 0; - xfer_status[n][TUSB_DIR_IN].max_size = 0; - } - - // reset allocated fifo IN - _allocated_fifo_words_tx = 16; -#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) - _allocated_fifos = 1; -#endif -} - -bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes) -{ - uint8_t const epnum = tu_edpt_number(ep_addr); - uint8_t const dir = tu_edpt_dir(ep_addr); - - xfer_ctl_t * xfer = XFER_CTL_BASE(epnum, dir); - xfer->buffer = buffer; - xfer->ff = NULL; - xfer->total_len = total_bytes; - - // EP0 can only handle one packet - if(epnum == 0) - { - ep0_pending[dir] = total_bytes; - - // Schedule the first transaction for EP0 transfer - edpt_schedule_packets(rhport, epnum, dir, 1, ep0_pending[dir]); - } - else - { - uint16_t num_packets = (total_bytes / xfer->max_size); - uint16_t const short_packet_size = total_bytes % xfer->max_size; - - // Zero-size packet is special case. - if ( (short_packet_size > 0) || (total_bytes == 0) ) num_packets++; - - // Schedule packets to be sent within interrupt - edpt_schedule_packets(rhport, epnum, dir, num_packets, total_bytes); - } - - return true; -} - -// The number of bytes has to be given explicitly to allow more flexible control of how many -// bytes should be written and second to keep the return value free to give back a boolean -// success message. If total_bytes is too big, the FIFO will copy only what is available -// into the USB buffer! -bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes) -{ - // USB buffers always work in bytes so to avoid unnecessary divisions we demand item_size = 1 - TU_ASSERT(ff->item_size == 1); - - uint8_t const epnum = tu_edpt_number(ep_addr); - uint8_t const dir = tu_edpt_dir(ep_addr); - - xfer_ctl_t * xfer = XFER_CTL_BASE(epnum, dir); - xfer->buffer = NULL; - xfer->ff = ff; - xfer->total_len = total_bytes; - - uint16_t num_packets = (total_bytes / xfer->max_size); - uint16_t const short_packet_size = total_bytes % xfer->max_size; - - // Zero-size packet is special case. - if ( short_packet_size > 0 || (total_bytes == 0) ) num_packets++; - - // Schedule packets to be sent within interrupt - edpt_schedule_packets(rhport, epnum, dir, num_packets, total_bytes); - - return true; -} - -static void dcd_edpt_disable (uint8_t rhport, uint8_t ep_addr, bool stall) -{ - (void) rhport; - - dwc2_regs_t *dwc2 = DWC2_REG(rhport); - - uint8_t const epnum = tu_edpt_number(ep_addr); - uint8_t const dir = tu_edpt_dir(ep_addr); - - if ( dir == TUSB_DIR_IN ) - { - dwc2_epin_t* epin = dwc2->epin; - - // Only disable currently enabled non-control endpoint - if ( (epnum == 0) || !(epin[epnum].diepctl & DIEPCTL_EPENA) ) - { - epin[epnum].diepctl |= DIEPCTL_SNAK | (stall ? DIEPCTL_STALL : 0); - } - else - { - // Stop transmitting packets and NAK IN xfers. - epin[epnum].diepctl |= DIEPCTL_SNAK; - while ( (epin[epnum].diepint & DIEPINT_INEPNE) == 0 ) {} - - // Disable the endpoint. - epin[epnum].diepctl |= DIEPCTL_EPDIS | (stall ? DIEPCTL_STALL : 0); - while ( (epin[epnum].diepint & DIEPINT_EPDISD_Msk) == 0 ) {} - - epin[epnum].diepint = DIEPINT_EPDISD; - } - - // Flush the FIFO, and wait until we have confirmed it cleared. - dwc2->grstctl = ((epnum << GRSTCTL_TXFNUM_Pos) | GRSTCTL_TXFFLSH); - while ( (dwc2->grstctl & GRSTCTL_TXFFLSH_Msk) != 0 ) {} - } - else - { - dwc2_epout_t* epout = dwc2->epout; - - // Only disable currently enabled non-control endpoint - if ( (epnum == 0) || !(epout[epnum].doepctl & DOEPCTL_EPENA) ) - { - epout[epnum].doepctl |= stall ? DOEPCTL_STALL : 0; - } - else - { - // Asserting GONAK is required to STALL an OUT endpoint. - // Simpler to use polling here, we don't use the "B"OUTNAKEFF interrupt - // anyway, and it can't be cleared by user code. If this while loop never - // finishes, we have bigger problems than just the stack. - dwc2->dctl |= DCTL_SGONAK; - while ( (dwc2->gintsts & GINTSTS_BOUTNAKEFF_Msk) == 0 ) {} - - // Ditto here- disable the endpoint. - epout[epnum].doepctl |= DOEPCTL_EPDIS | (stall ? DOEPCTL_STALL : 0); - while ( (epout[epnum].doepint & DOEPINT_EPDISD_Msk) == 0 ) {} - - epout[epnum].doepint = DOEPINT_EPDISD; - - // Allow other OUT endpoints to keep receiving. - dwc2->dctl |= DCTL_CGONAK; - } - } -} - -/** - * Close an endpoint. - */ -void dcd_edpt_close (uint8_t rhport, uint8_t ep_addr) -{ - dwc2_regs_t * dwc2 = DWC2_REG(rhport); - - uint8_t const epnum = tu_edpt_number(ep_addr); - uint8_t const dir = tu_edpt_dir(ep_addr); - - dcd_edpt_disable(rhport, ep_addr, false); - - // Update max_size - xfer_status[epnum][dir].max_size = 0; // max_size = 0 marks a disabled EP - required for changing FIFO allocation - - if (dir == TUSB_DIR_IN) - { - uint16_t const fifo_size = (dwc2->dieptxf[epnum - 1] & DIEPTXF_INEPTXFD_Msk) >> DIEPTXF_INEPTXFD_Pos; - uint16_t const fifo_start = (dwc2->dieptxf[epnum - 1] & DIEPTXF_INEPTXSA_Msk) >> DIEPTXF_INEPTXSA_Pos; - - // For now only the last opened endpoint can be closed without fuss. - TU_ASSERT(fifo_start == _dwc2_controller[rhport].ep_fifo_size/4 - _allocated_fifo_words_tx,); - _allocated_fifo_words_tx -= fifo_size; - } - else - { - _out_ep_closed = true; // Set flag such that RX FIFO gets reduced in size once RX FIFO is empty - } -} - -void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) -{ - dcd_edpt_disable(rhport, ep_addr, true); -} - -void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr) -{ - (void) rhport; - - dwc2_regs_t * dwc2 = DWC2_REG(rhport); - - uint8_t const epnum = tu_edpt_number(ep_addr); - uint8_t const dir = tu_edpt_dir(ep_addr); - - // Clear stall and reset data toggle - if ( dir == TUSB_DIR_IN ) - { - dwc2->epin[epnum].diepctl &= ~DIEPCTL_STALL; - dwc2->epin[epnum].diepctl |= DIEPCTL_SD0PID_SEVNFRM; - } - else - { - dwc2->epout[epnum].doepctl &= ~DOEPCTL_STALL; - dwc2->epout[epnum].doepctl |= DOEPCTL_SD0PID_SEVNFRM; - } -} - -/*------------------------------------------------------------------*/ - -// Read a single data packet from receive FIFO -static void read_fifo_packet(uint8_t rhport, uint8_t * dst, uint16_t len) -{ - (void) rhport; - - dwc2_regs_t * dwc2 = DWC2_REG(rhport); - volatile const uint32_t * rx_fifo = dwc2->fifo[0]; - - // Reading full available 32 bit words from fifo - uint16_t full_words = len >> 2; - while(full_words--) - { - tu_unaligned_write32(dst, *rx_fifo); - dst += 4; - } - - // Read the remaining 1-3 bytes from fifo - uint8_t const bytes_rem = len & 0x03; - if ( bytes_rem != 0 ) - { - uint32_t const tmp = *rx_fifo; - dst[0] = tu_u32_byte0(tmp); - if ( bytes_rem > 1 ) dst[1] = tu_u32_byte1(tmp); - if ( bytes_rem > 2 ) dst[2] = tu_u32_byte2(tmp); - } -} - -// Write a single data packet to EPIN FIFO -static void write_fifo_packet(uint8_t rhport, uint8_t fifo_num, uint8_t const * src, uint16_t len) -{ - (void) rhport; - - dwc2_regs_t * dwc2 = DWC2_REG(rhport); - volatile uint32_t * tx_fifo = dwc2->fifo[fifo_num]; - - // Pushing full available 32 bit words to fifo - uint16_t full_words = len >> 2; - while(full_words--) - { - *tx_fifo = tu_unaligned_read32(src); - src += 4; - } - - // Write the remaining 1-3 bytes into fifo - uint8_t const bytes_rem = len & 0x03; - if ( bytes_rem ) - { - uint32_t tmp_word = src[0]; - if ( bytes_rem > 1 ) tmp_word |= (src[1] << 8); - if ( bytes_rem > 2 ) tmp_word |= (src[2] << 16); - - *tx_fifo = tmp_word; - } -} - -static void handle_rxflvl_irq(uint8_t rhport) -{ - dwc2_regs_t * dwc2 = DWC2_REG(rhport); - volatile uint32_t const * rx_fifo = dwc2->fifo[0]; - - // Pop control word off FIFO - uint32_t const ctl_word = dwc2->grxstsp; - uint8_t const pktsts = (ctl_word & GRXSTSP_PKTSTS_Msk ) >> GRXSTSP_PKTSTS_Pos; - uint8_t const epnum = (ctl_word & GRXSTSP_EPNUM_Msk ) >> GRXSTSP_EPNUM_Pos; - uint16_t const bcnt = (ctl_word & GRXSTSP_BCNT_Msk ) >> GRXSTSP_BCNT_Pos; - - dwc2_epout_t* epout = &dwc2->epout[epnum]; - -//#if CFG_TUSB_DEBUG >= DWC2_DEBUG -// const char * pktsts_str[] = -// { -// "ASSERT", "Global NAK (ISR)", "Out Data Received", "Out Transfer Complete (ISR)", -// "Setup Complete (ISR)", "ASSERT", "Setup Data Received" -// }; -// TU_LOG_LOCATION(); -// TU_LOG(DWC2_DEBUG, " EP %02X, Byte Count %u, %s\r\n", epnum, bcnt, pktsts_str[pktsts]); -// TU_LOG(DWC2_DEBUG, " daint = %08lX, doepint = %04X\r\n", (unsigned long) dwc2->daint, (unsigned int) epout->doepint); -//#endif - - switch ( pktsts ) - { - // Global OUT NAK: do nothing - case GRXSTS_PKTSTS_GLOBALOUTNAK: break; - - case GRXSTS_PKTSTS_SETUPRX: - // Setup packet received - - // We can receive up to three setup packets in succession, but - // only the last one is valid. - _setup_packet[0] = (*rx_fifo); - _setup_packet[1] = (*rx_fifo); - break; - - case GRXSTS_PKTSTS_SETUPDONE: - // Setup packet done (Interrupt) - epout->doeptsiz |= (3 << DOEPTSIZ_STUPCNT_Pos); - break; - - case GRXSTS_PKTSTS_OUTRX: - { - // Out packet received - xfer_ctl_t *xfer = XFER_CTL_BASE(epnum, TUSB_DIR_OUT); - - // Read packet off RxFIFO - if ( xfer->ff ) - { - // Ring buffer - tu_fifo_write_n_const_addr_full_words(xfer->ff, (const void*) (uintptr_t) rx_fifo, bcnt); - } - else - { - // Linear buffer - read_fifo_packet(rhport, xfer->buffer, bcnt); - - // Increment pointer to xfer data - xfer->buffer += bcnt; - } - - // Truncate transfer length in case of short packet - if ( bcnt < xfer->max_size ) - { - xfer->total_len -= (epout->doeptsiz & DOEPTSIZ_XFRSIZ_Msk) >> DOEPTSIZ_XFRSIZ_Pos; - if ( epnum == 0 ) - { - xfer->total_len -= ep0_pending[TUSB_DIR_OUT]; - ep0_pending[TUSB_DIR_OUT] = 0; - } - } - } - break; - - // Out packet done (Interrupt) - case GRXSTS_PKTSTS_OUTDONE: - // Occurred on STM32L47 with dwc2 version 3.10a but not found on other version like 2.80a or 3.30a - // May (or not) be 3.10a specific feature/bug or depending on MCU configuration - // XFRC complete is additionally generated when - // - setup packet is received - // - complete the data stage of control write is complete - if ((epnum == 0) && (bcnt == 0) && (dwc2->gsnpsid >= DWC2_CORE_REV_3_00a)) - { - uint32_t doepint = epout->doepint; - - if (doepint & (DOEPINT_STPKTRX | DOEPINT_OTEPSPR)) - { - // skip this "no-data" transfer complete event - // Note: STPKTRX will be clear later by setup received handler - uint32_t clear_flags = DOEPINT_XFRC; - - if (doepint & DOEPINT_OTEPSPR) clear_flags |= DOEPINT_OTEPSPR; - - epout->doepint = clear_flags; - - // TU_LOG(DWC2_DEBUG, " FIX extra transfer complete on setup/data compete\r\n"); - } - } - break; - - default: // Invalid - TU_BREAKPOINT(); - break; - } -} - -static void handle_epout_irq (uint8_t rhport) -{ - dwc2_regs_t * dwc2 = DWC2_REG(rhport); - uint8_t const ep_count = _dwc2_controller[rhport].ep_count; - - // DAINT for a given EP clears when DOEPINTx is cleared. - // OEPINT will be cleared when DAINT's out bits are cleared. - for ( uint8_t n = 0; n < ep_count; n++ ) - { - if ( dwc2->daint & TU_BIT(DAINT_OEPINT_Pos + n) ) - { - dwc2_epout_t* epout = &dwc2->epout[n]; - - uint32_t const doepint = epout->doepint; - - // SETUP packet Setup Phase done. - if ( doepint & DOEPINT_STUP ) - { - uint32_t clear_flag = DOEPINT_STUP; - - // STPKTRX is only available for version from 3_00a - if ((doepint & DOEPINT_STPKTRX) && (dwc2->gsnpsid >= DWC2_CORE_REV_3_00a)) - { - clear_flag |= DOEPINT_STPKTRX; - } - - epout->doepint = clear_flag; - dcd_event_setup_received(rhport, (uint8_t*) _setup_packet, true); - } - - // OUT XFER complete - if ( epout->doepint & DOEPINT_XFRC ) - { - epout->doepint = DOEPINT_XFRC; - - xfer_ctl_t *xfer = XFER_CTL_BASE(n, TUSB_DIR_OUT); - - // EP0 can only handle one packet - if ( (n == 0) && ep0_pending[TUSB_DIR_OUT] ) - { - // Schedule another packet to be received. - edpt_schedule_packets(rhport, n, TUSB_DIR_OUT, 1, ep0_pending[TUSB_DIR_OUT]); - } - else - { - dcd_event_xfer_complete(rhport, n, xfer->total_len, XFER_RESULT_SUCCESS, true); - } - } - } - } -} - -static void handle_epin_irq (uint8_t rhport) -{ - dwc2_regs_t * dwc2 = DWC2_REG(rhport); - uint8_t const ep_count = _dwc2_controller[rhport].ep_count; - dwc2_epin_t* epin = dwc2->epin; - - // DAINT for a given EP clears when DIEPINTx is cleared. - // IEPINT will be cleared when DAINT's out bits are cleared. - for ( uint8_t n = 0; n < ep_count; n++ ) - { - if ( dwc2->daint & TU_BIT(DAINT_IEPINT_Pos + n) ) - { - // IN XFER complete (entire xfer). - xfer_ctl_t *xfer = XFER_CTL_BASE(n, TUSB_DIR_IN); - - if ( epin[n].diepint & DIEPINT_XFRC ) - { - epin[n].diepint = DIEPINT_XFRC; - - // EP0 can only handle one packet - if ( (n == 0) && ep0_pending[TUSB_DIR_IN] ) - { - // Schedule another packet to be transmitted. - edpt_schedule_packets(rhport, n, TUSB_DIR_IN, 1, ep0_pending[TUSB_DIR_IN]); - } - else - { - dcd_event_xfer_complete(rhport, n | TUSB_DIR_IN_MASK, xfer->total_len, XFER_RESULT_SUCCESS, true); - } - } - - // XFER FIFO empty - if ( (epin[n].diepint & DIEPINT_TXFE) && (dwc2->diepempmsk & (1 << n)) ) - { - // diepint's TXFE bit is read-only, software cannot clear it. - // It will only be cleared by hardware when written bytes is more than - // - 64 bytes or - // - Half of TX FIFO size (configured by DIEPTXF) - - uint16_t remaining_packets = (epin[n].dieptsiz & DIEPTSIZ_PKTCNT_Msk) >> DIEPTSIZ_PKTCNT_Pos; - - // Process every single packet (only whole packets can be written to fifo) - for ( uint16_t i = 0; i < remaining_packets; i++ ) - { - uint16_t const remaining_bytes = (epin[n].dieptsiz & DIEPTSIZ_XFRSIZ_Msk) >> DIEPTSIZ_XFRSIZ_Pos; - - // Packet can not be larger than ep max size - uint16_t const packet_size = tu_min16(remaining_bytes, xfer->max_size); - - // It's only possible to write full packets into FIFO. Therefore DTXFSTS register of current - // EP has to be checked if the buffer can take another WHOLE packet - if ( packet_size > ((epin[n].dtxfsts & DTXFSTS_INEPTFSAV_Msk) << 2) ) break; - - // Push packet to Tx-FIFO - if ( xfer->ff ) - { - volatile uint32_t *tx_fifo = dwc2->fifo[n]; - tu_fifo_read_n_const_addr_full_words(xfer->ff, (void*) (uintptr_t) tx_fifo, packet_size); - } - else - { - write_fifo_packet(rhport, n, xfer->buffer, packet_size); - - // Increment pointer to xfer data - xfer->buffer += packet_size; - } - } - - // Turn off TXFE if all bytes are written. - if ( ((epin[n].dieptsiz & DIEPTSIZ_XFRSIZ_Msk) >> DIEPTSIZ_XFRSIZ_Pos) == 0 ) - { - dwc2->diepempmsk &= ~(1 << n); - } - } - } - } -} - -void dcd_int_handler(uint8_t rhport) -{ - dwc2_regs_t *dwc2 = DWC2_REG(rhport); - - uint32_t const int_mask = dwc2->gintmsk; - uint32_t const int_status = dwc2->gintsts & int_mask; - - if(int_status & GINTSTS_USBRST) - { - // USBRST is start of reset. - dwc2->gintsts = GINTSTS_USBRST; -#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) - _allocated_fifos = 1; -#endif - bus_reset(rhport); - } - - if(int_status & GINTSTS_ENUMDNE) - { - // ENUMDNE is the end of reset where speed of the link is detected - - dwc2->gintsts = GINTSTS_ENUMDNE; - - tusb_speed_t speed; - switch ((dwc2->dsts & DSTS_ENUMSPD_Msk) >> DSTS_ENUMSPD_Pos) - { - case DSTS_ENUMSPD_HS: - speed = TUSB_SPEED_HIGH; - break; - - case DSTS_ENUMSPD_LS: - speed = TUSB_SPEED_LOW; - break; - - case DSTS_ENUMSPD_FS_HSPHY: - case DSTS_ENUMSPD_FS: - default: - speed = TUSB_SPEED_FULL; - break; - } - - dcd_event_bus_reset(rhport, speed, true); - } - - if(int_status & GINTSTS_USBSUSP) - { - dwc2->gintsts = GINTSTS_USBSUSP; - //dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true); - dcd_event_bus_signal(rhport, DCD_EVENT_UNPLUGGED, true); -#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) - _allocated_fifos = 1; -#endif - } - - if(int_status & GINTSTS_WKUINT) - { - dwc2->gintsts = GINTSTS_WKUINT; - dcd_event_bus_signal(rhport, DCD_EVENT_RESUME, true); - } - - // TODO check GINTSTS_DISCINT for disconnect detection - // if(int_status & GINTSTS_DISCINT) - - if(int_status & GINTSTS_OTGINT) - { - // OTG INT bit is read-only - uint32_t const otg_int = dwc2->gotgint; - - if (otg_int & GOTGINT_SEDET) - { - dcd_event_bus_signal(rhport, DCD_EVENT_UNPLUGGED, true); -#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) - _allocated_fifos = 1; -#endif - } - - dwc2->gotgint = otg_int; - } - - if(int_status & GINTSTS_SOF) - { - dwc2->gotgint = GINTSTS_SOF; - - if (_sof_en) - { - uint32_t frame = (dwc2->dsts & (DSTS_FNSOF)) >> 8; - dcd_event_sof(rhport, frame, true); - } - else - { - // Disable SOF interrupt if SOF was not explicitly enabled. SOF was used for remote wakeup detection - dwc2->gintmsk &= ~GINTMSK_SOFM; - } - - dcd_event_bus_signal(rhport, DCD_EVENT_SOF, true); - } - - // RxFIFO non-empty interrupt handling. - if(int_status & GINTSTS_RXFLVL) - { - // RXFLVL bit is read-only - - // Mask out RXFLVL while reading data from FIFO - dwc2->gintmsk &= ~GINTMSK_RXFLVLM; - - // Loop until all available packets were handled - do - { - handle_rxflvl_irq(rhport); - } while(dwc2->gotgint & GINTSTS_RXFLVL); - - // Manage RX FIFO size - if (_out_ep_closed) - { - update_grxfsiz(rhport); - - // Disable flag - _out_ep_closed = false; - } - - dwc2->gintmsk |= GINTMSK_RXFLVLM; - } - - // OUT endpoint interrupt handling. - if(int_status & GINTSTS_OEPINT) - { - // OEPINT is read-only, clear using DOEPINTn - handle_epout_irq(rhport); - } - - // IN endpoint interrupt handling. - if(int_status & GINTSTS_IEPINT) - { - // IEPINT bit read-only, clear using DIEPINTn - handle_epin_irq(rhport); - } - - // // Check for Incomplete isochronous IN transfer - // if(int_status & GINTSTS_IISOIXFR) { - // printf(" IISOIXFR!\r\n"); - //// TU_LOG(DWC2_DEBUG, " IISOIXFR!\r\n"); - // } -} - -#endif diff --git a/components/arduino_tinyusb/src/dcd_esp32sx.c b/components/arduino_tinyusb/src/dcd_esp32sx.c deleted file mode 100755 index cfccf95ae..000000000 --- a/components/arduino_tinyusb/src/dcd_esp32sx.c +++ /dev/null @@ -1,954 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2018 Scott Shawcroft, 2019 William D. Jones for Adafruit Industries - * Copyright (c) 2019 Ha Thach (tinyusb.org) - * Additions Copyright (c) 2020, Espressif Systems (Shanghai) Co. Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#include "tusb_option.h" - -#if (((CFG_TUSB_MCU == OPT_MCU_ESP32S2) || (CFG_TUSB_MCU == OPT_MCU_ESP32S3)) && CFG_TUD_ENABLED) - -// Espressif -#include "freertos/xtensa_api.h" -#include "esp_intr_alloc.h" -#include "esp_log.h" -#include "soc/dport_reg.h" -#include "soc/gpio_sig_map.h" -#include "soc/usb_periph.h" -#include "soc/periph_defs.h" // for interrupt source - -#include "device/dcd.h" - -// Max number of bi-directional endpoints including EP0 -// Note: ESP32S2 specs say there are only up to 5 IN active endpoints include EP0 -// We should probably prohibit enabling Endpoint IN > 4 (not done yet) -#define EP_MAX USB_OUT_EP_NUM - -// FIFO size in bytes -#define EP_FIFO_SIZE 1024 - -// Max number of IN EP FIFOs -#define EP_FIFO_NUM 5 - -typedef struct { - uint8_t *buffer; - // tu_fifo_t * ff; // TODO support dcd_edpt_xfer_fifo API - uint16_t total_len; - uint16_t queued_len; - uint16_t max_size; - bool short_packet; - uint8_t interval; -} xfer_ctl_t; - -static const char *TAG = "TUSB:DCD"; -static intr_handle_t usb_ih; - - -static uint32_t _setup_packet[2]; - -#define XFER_CTL_BASE(_ep, _dir) &xfer_status[_ep][_dir] -static xfer_ctl_t xfer_status[EP_MAX][2]; - -// Keep count of how many FIFOs are in use -static uint8_t _allocated_fifos = 1; //FIFO0 is always in use - -// Will either return an unused FIFO number, or 0 if all are used. -static uint8_t get_free_fifo(void) -{ - if (_allocated_fifos < EP_FIFO_NUM) return _allocated_fifos++; - return 0; -} - -// Setup the control endpoint 0. -static void bus_reset(void) -{ - for (int ep_num = 0; ep_num < USB_OUT_EP_NUM; ep_num++) { - USB0.out_ep_reg[ep_num].doepctl |= USB_DO_SNAK0_M; // DOEPCTL0_SNAK - } - - // clear device address - USB0.dcfg &= ~USB_DEVADDR_M; - - USB0.daintmsk = USB_OUTEPMSK0_M | USB_INEPMSK0_M; - USB0.doepmsk = USB_SETUPMSK_M | USB_XFERCOMPLMSK; - USB0.diepmsk = USB_TIMEOUTMSK_M | USB_DI_XFERCOMPLMSK_M /*| USB_INTKNTXFEMPMSK_M*/; - - // "USB Data FIFOs" section in reference manual - // Peripheral FIFO architecture - // - // --------------- 320 or 1024 ( 1280 or 4096 bytes ) - // | IN FIFO MAX | - // --------------- - // | ... | - // --------------- y + x + 16 + GRXFSIZ - // | IN FIFO 2 | - // --------------- x + 16 + GRXFSIZ - // | IN FIFO 1 | - // --------------- 16 + GRXFSIZ - // | IN FIFO 0 | - // --------------- GRXFSIZ - // | OUT FIFO | - // | ( Shared ) | - // --------------- 0 - // - // According to "FIFO RAM allocation" section in RM, FIFO RAM are allocated as follows (each word 32-bits): - // - Each EP IN needs at least max packet size, 16 words is sufficient for EP0 IN - // - // - All EP OUT shared a unique OUT FIFO which uses - // * 10 locations in hardware for setup packets + setup control words (up to 3 setup packets). - // * 2 locations for OUT endpoint control words. - // * 16 for largest packet size of 64 bytes. ( TODO Highspeed is 512 bytes) - // * 1 location for global NAK (not required/used here). - // * It is recommended to allocate 2 times the largest packet size, therefore - // Recommended value = 10 + 1 + 2 x (16+2) = 47 --> Let's make it 52 - USB0.grstctl |= 0x10 << USB_TXFNUM_S; // fifo 0x10, - USB0.grstctl |= USB_TXFFLSH_M; // Flush fifo - USB0.grxfsiz = 52; - - // Control IN uses FIFO 0 with 64 bytes ( 16 32-bit word ) - USB0.gnptxfsiz = (16 << USB_NPTXFDEP_S) | (USB0.grxfsiz & 0x0000ffffUL); - - // Ready to receive SETUP packet - USB0.out_ep_reg[0].doeptsiz |= USB_SUPCNT0_M; - - USB0.gintmsk |= USB_IEPINTMSK_M | USB_OEPINTMSK_M; -} - -static void enum_done_processing(void) -{ - ESP_EARLY_LOGV(TAG, "dcd_int_handler - Speed enumeration done! Sending DCD_EVENT_BUS_RESET then"); - // On current silicon on the Full Speed core, speed is fixed to Full Speed. - // However, keep for debugging and in case Low Speed is ever supported. - uint32_t enum_spd = (USB0.dsts >> USB_ENUMSPD_S) & (USB_ENUMSPD_V); - - // Maximum packet size for EP 0 is set for both directions by writing DIEPCTL - if (enum_spd == 0x03) { // Full-Speed (PHY on 48 MHz) - USB0.in_ep_reg[0].diepctl &= ~USB_D_MPS0_V; // 64 bytes - USB0.in_ep_reg[0].diepctl &= ~USB_D_STALL0_M; // clear Stall - xfer_status[0][TUSB_DIR_OUT].max_size = 64; - xfer_status[0][TUSB_DIR_IN].max_size = 64; - } else { - USB0.in_ep_reg[0].diepctl |= USB_D_MPS0_V; // 8 bytes - USB0.in_ep_reg[0].diepctl &= ~USB_D_STALL0_M; // clear Stall - xfer_status[0][TUSB_DIR_OUT].max_size = 8; - xfer_status[0][TUSB_DIR_IN].max_size = 8; - } -} - - -/*------------------------------------------------------------------*/ -/* Controller API - *------------------------------------------------------------------*/ -void dcd_init(uint8_t rhport) -{ - ESP_LOGV(TAG, "DCD init - Start"); - - bool did_persist = (USB_WRAP.date.val & (1 << 31)) != 0; - - if (did_persist) { - //Clear persistence of USB peripheral through reset - USB_WRAP.date.val = 0; - } else { - // A. Disconnect - ESP_LOGV(TAG, "DCD init - Soft DISCONNECT and Setting up"); - USB0.dctl |= USB_SFTDISCON_M; // Soft disconnect - - // B. Programming DCFG - /* If USB host misbehaves during status portion of control xfer - (non zero-length packet), send STALL back and discard. Full speed. */ - USB0.dcfg |= USB_NZSTSOUTHSHK_M | // NonZero .... STALL - (3 << 0); // dev speed: fullspeed 1.1 on 48 mhz // TODO no value in usb_reg.h (IDF-1476) - } - - USB0.gahbcfg |= USB_NPTXFEMPLVL_M | USB_GLBLLNTRMSK_M; // Global interruptions ON - USB0.gusbcfg |= USB_FORCEDEVMODE_M; // force devmode - USB0.gotgctl &= ~(USB_BVALIDOVVAL_M | USB_BVALIDOVEN_M | USB_VBVALIDOVVAL_M); //no overrides - - // C. Setting SNAKs, then connect - for (int n = 0; n < USB_OUT_EP_NUM; n++) { - USB0.out_ep_reg[n].doepctl |= USB_DO_SNAK0_M; // DOEPCTL0_SNAK - } - - if (!did_persist) { - // D. Interruption masking - USB0.gintmsk = 0; //mask all - USB0.gotgint = ~0U; //clear OTG ints - USB0.gintsts = ~0U; //clear pending ints - } - - USB0.gintmsk = USB_OTGINTMSK_M | - USB_MODEMISMSK_M | - USB_RXFLVIMSK_M | - USB_ERLYSUSPMSK_M | - USB_USBSUSPMSK_M | - USB_USBRSTMSK_M | - USB_ENUMDONEMSK_M | - USB_RESETDETMSK_M | - USB_DISCONNINTMSK_M; // host most only - if (did_persist) { - USB0.grstctl &= ~USB_TXFNUM_M; - USB0.grstctl |= 0x10 << USB_TXFNUM_S; - USB0.grstctl |= USB_TXFFLSH; - USB0.grxfsiz = 52; - - for (int n = 0; n < USB_IN_EP_NUM; n++) { - USB0.in_ep_reg[n].diepint = USB_D_XFERCOMPL0_M | USB_D_TXFEMP0_M; - USB0.in_ep_reg[n].diepctl &= ~USB_D_STALL0_M; // clear Stall - USB0.in_ep_reg[n].diepctl |= USB_D_CNAK0 | USB_D_EPENA0; // clear NAK - } - USB0.dtknqr4_fifoemptymsk &= ~(0x7F); - - USB0.gnptxfsiz = (16 << USB_NPTXFDEP_S) | (USB0.grxfsiz & 0x0000ffffUL); - - USB0.daintmsk |= USB_OUTEPMSK0_M | USB_INEPMSK0_M; - USB0.doepmsk |= USB_SETUP0 | USB_XFERCOMPLMSK; - USB0.diepmsk |= USB_TIMEOUTMSK_M | USB_DI_XFERCOMPLMSK_M;//USB_INEPNAKEFFMSK - - USB0.gintmsk |= USB_IEPINTMSK_M | USB_OEPINTMSK_M; - USB0.gotgint = ~0; //clear OTG ints - USB0.gintsts = ~0; //clear pending ints - enum_done_processing(); - dcd_event_bus_signal(0, DCD_EVENT_BUS_RESET, true); - tusb_control_request_t request = { - .bmRequestType_bit = { .recipient = TUSB_REQ_RCPT_DEVICE, .type = TUSB_REQ_TYPE_STANDARD, .direction = TUSB_DIR_OUT }, - .bRequest = TUSB_REQ_SET_CONFIGURATION, - .wValue = 1, - .wIndex = 0, - .wLength = 0 - }; - dcd_event_setup_received(0, (uint8_t *)&request, true); - } else { - dcd_connect(rhport); - } -} - -void dcd_set_address(uint8_t rhport, uint8_t dev_addr) -{ - (void)rhport; - ESP_LOGV(TAG, "DCD init - Set address : %u", dev_addr); - USB0.dcfg |= ((dev_addr & USB_DEVADDR_V) << USB_DEVADDR_S); - // Response with status after changing device address - dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0); -} - -void dcd_remote_wakeup(uint8_t rhport) -{ - (void)rhport; - - // set remote wakeup - USB0.dctl |= USB_RMTWKUPSIG_M; - - // enable SOF to detect bus resume - USB0.gintsts = USB_SOF_M; - USB0.gintmsk |= USB_SOFMSK_M; - - // Per specs: remote wakeup signal bit must be clear within 1-15ms - vTaskDelay(pdMS_TO_TICKS(1)); - - USB0.dctl &= ~USB_RMTWKUPSIG_M; -} - -// connect by enabling internal pull-up resistor on D+/D- -void dcd_connect(uint8_t rhport) -{ - (void) rhport; - USB0.dctl &= ~USB_SFTDISCON_M; -} - -// disconnect by disabling internal pull-up resistor on D+/D- -void dcd_disconnect(uint8_t rhport) -{ - (void) rhport; - USB0.dctl |= USB_SFTDISCON_M; -} - -void dcd_sof_enable(uint8_t rhport, bool en) -{ - (void) rhport; - (void) en; - - // TODO implement later -} - -/*------------------------------------------------------------------*/ -/* DCD Endpoint port - *------------------------------------------------------------------*/ - -bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const *desc_edpt) -{ - ESP_LOGV(TAG, "DCD endpoint opened"); - (void)rhport; - - usb_out_endpoint_t *out_ep = &(USB0.out_ep_reg[0]); - usb_in_endpoint_t *in_ep = &(USB0.in_ep_reg[0]); - - uint8_t const epnum = tu_edpt_number(desc_edpt->bEndpointAddress); - uint8_t const dir = tu_edpt_dir(desc_edpt->bEndpointAddress); - - TU_ASSERT(epnum < EP_MAX); - - xfer_ctl_t *xfer = XFER_CTL_BASE(epnum, dir); - xfer->max_size = tu_edpt_packet_size(desc_edpt); - xfer->interval = desc_edpt->bInterval; - - if (dir == TUSB_DIR_OUT) { - out_ep[epnum].doepctl &= ~(USB_D_EPTYPE0_M | USB_D_MPS0_M); - out_ep[epnum].doepctl |= USB_USBACTEP1_M | - desc_edpt->bmAttributes.xfer << USB_EPTYPE1_S | - (desc_edpt->bmAttributes.xfer != TUSB_XFER_ISOCHRONOUS ? USB_DO_SETD0PID1_M : 0) | - xfer->max_size << USB_MPS1_S; - USB0.daintmsk |= (1 << (16 + epnum)); - } else { - // "USB Data FIFOs" section in reference manual - // Peripheral FIFO architecture - // - // --------------- 320 or 1024 ( 1280 or 4096 bytes ) - // | IN FIFO MAX | - // --------------- - // | ... | - // --------------- y + x + 16 + GRXFSIZ - // | IN FIFO 2 | - // --------------- x + 16 + GRXFSIZ - // | IN FIFO 1 | - // --------------- 16 + GRXFSIZ - // | IN FIFO 0 | - // --------------- GRXFSIZ - // | OUT FIFO | - // | ( Shared ) | - // --------------- 0 - // - // Since OUT FIFO = GRXFSIZ, FIFO 0 = 16, for simplicity, we equally allocated for the rest of endpoints - // - Size : (FIFO_SIZE/4 - GRXFSIZ - 16) / (EP_MAX-1) - // - Offset: GRXFSIZ + 16 + Size*(epnum-1) - // - IN EP 1 gets FIFO 1, IN EP "n" gets FIFO "n". - - uint8_t fifo_num = 0; - // Special Case for EP5, which is used by CDC but not actually called by the driver - // we can give it a fake FIFO - if (epnum == 5) { - fifo_num = EP_FIFO_NUM; - } else { - fifo_num = get_free_fifo(); - } - TU_ASSERT(fifo_num != 0); - - in_ep[epnum].diepctl &= ~(USB_D_TXFNUM1_M | USB_D_EPTYPE1_M | USB_DI_SETD0PID1 | USB_D_MPS1_M); - in_ep[epnum].diepctl |= USB_D_USBACTEP1_M | - fifo_num << USB_D_TXFNUM1_S | - desc_edpt->bmAttributes.xfer << USB_D_EPTYPE1_S | - (desc_edpt->bmAttributes.xfer != TUSB_XFER_ISOCHRONOUS ? (1 << USB_DI_SETD0PID1_S) : 0) | - xfer->max_size << 0; - - USB0.daintmsk |= (1 << (0 + epnum)); - - // Both TXFD and TXSA are in unit of 32-bit words. - // IN FIFO 0 was configured during enumeration, hence the "+ 16". - uint16_t const allocated_size = (USB0.grxfsiz & 0x0000ffff) + 16; - uint16_t const fifo_size = (EP_FIFO_SIZE/4 - allocated_size) / (EP_FIFO_NUM-1); - uint32_t const fifo_offset = allocated_size + fifo_size*(fifo_num-1); - - // DIEPTXF starts at FIFO #1. - USB0.dieptxf[epnum - 1] = (fifo_size << USB_NPTXFDEP_S) | fifo_offset; - } - return true; -} - -void dcd_edpt_close_all(uint8_t rhport) -{ - (void) rhport; - - usb_out_endpoint_t *out_ep = &(USB0.out_ep_reg[0]); - usb_in_endpoint_t *in_ep = &(USB0.in_ep_reg[0]); - - // Disable non-control interrupt - USB0.daintmsk = USB_OUTEPMSK0_M | USB_INEPMSK0_M; - - for(uint8_t n = 1; n < EP_MAX; n++) - { - // disable OUT endpoint - out_ep[n].doepctl = 0; - xfer_status[n][TUSB_DIR_OUT].max_size = 0; - - // disable IN endpoint - in_ep[n].diepctl = 0; - xfer_status[n][TUSB_DIR_IN].max_size = 0; - } - - _allocated_fifos = 1; -} - -bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes) -{ - (void)rhport; - - uint8_t const epnum = tu_edpt_number(ep_addr); - uint8_t const dir = tu_edpt_dir(ep_addr); - - xfer_ctl_t * xfer = XFER_CTL_BASE(epnum, dir); - xfer->buffer = buffer; - // xfer->ff = NULL; // TODO support dcd_edpt_xfer_fifo API - xfer->total_len = total_bytes; - xfer->queued_len = 0; - xfer->short_packet = false; - - uint16_t num_packets = (total_bytes / xfer->max_size); - uint8_t short_packet_size = total_bytes % xfer->max_size; - - // Zero-size packet is special case. - if (short_packet_size > 0 || (total_bytes == 0)) { - num_packets++; - } - - ESP_LOGV(TAG, "Transfer <-> EP%i, %s, pkgs: %i, bytes: %i", - epnum, ((dir == TUSB_DIR_IN) ? "USB0.HOST (in)" : "HOST->DEV (out)"), - num_packets, total_bytes); - - // IN and OUT endpoint xfers are interrupt-driven, we just schedule them - // here. - if (dir == TUSB_DIR_IN) { - // A full IN transfer (multiple packets, possibly) triggers XFRC. - USB0.in_ep_reg[epnum].dieptsiz = (num_packets << USB_D_PKTCNT0_S) | total_bytes; - USB0.in_ep_reg[epnum].diepctl |= USB_D_EPENA1_M | USB_D_CNAK1_M; // Enable | CNAK - - // For ISO endpoint with interval=1 set correct DATA0/DATA1 bit for next frame - if ((USB0.in_ep_reg[epnum].diepctl & USB_D_EPTYPE0_M) == (1 << USB_D_EPTYPE1_S) && xfer->interval == 1) { - // Take odd/even bit from frame counter. - uint32_t const odd_frame_now = (USB0.dsts & (1u << USB_SOFFN_S)); - USB0.in_ep_reg[epnum].diepctl |= (odd_frame_now ? USB_DI_SETD0PID1 : USB_DI_SETD1PID1); - } - - // Enable fifo empty interrupt only if there are something to put in the fifo. - if(total_bytes != 0) { - USB0.dtknqr4_fifoemptymsk |= (1 << epnum); - } - } else { - // Each complete packet for OUT xfers triggers XFRC. - USB0.out_ep_reg[epnum].doeptsiz |= USB_PKTCNT0_M | ((xfer->max_size & USB_XFERSIZE0_V) << USB_XFERSIZE0_S); - USB0.out_ep_reg[epnum].doepctl |= USB_EPENA0_M | USB_CNAK0_M; - - // For ISO endpoint with interval=1 set correct DATA0/DATA1 bit for next frame - if ((USB0.out_ep_reg[epnum].doepctl & USB_D_EPTYPE0_M) == (1 << USB_D_EPTYPE1_S) && xfer->interval == 1) { - // Take odd/even bit from frame counter. - uint32_t const odd_frame_now = (USB0.dsts & (1u << USB_SOFFN_S)); - USB0.out_ep_reg[epnum].doepctl |= (odd_frame_now ? USB_DO_SETD0PID1 : USB_DO_SETD1PID1); - } - } - return true; -} - -#if 0 // TODO support dcd_edpt_xfer_fifo API -bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes) -{ - (void)rhport; -} -#endif - -void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr) -{ - (void)rhport; - - usb_out_endpoint_t *out_ep = &(USB0.out_ep_reg[0]); - usb_in_endpoint_t *in_ep = &(USB0.in_ep_reg[0]); - - uint8_t const epnum = tu_edpt_number(ep_addr); - uint8_t const dir = tu_edpt_dir(ep_addr); - - if (dir == TUSB_DIR_IN) { - // Only disable currently enabled non-control endpoint - if ((epnum == 0) || !(in_ep[epnum].diepctl & USB_D_EPENA1_M)) { - in_ep[epnum].diepctl |= (USB_DI_SNAK1_M | USB_D_STALL1_M); - } else { - // Stop transmitting packets and NAK IN xfers. - in_ep[epnum].diepctl |= USB_DI_SNAK1_M; - // while ((in_ep[epnum].diepint & USB_DI_SNAK1_M) == 0) ; - while ((in_ep[epnum].diepint & USB_D_INEPNAKEFF1_M) == 0) ; - - // Disable the endpoint. Note that both SNAK and STALL are set here. - in_ep[epnum].diepctl |= (USB_DI_SNAK1_M | USB_D_STALL1_M | USB_D_EPDIS1_M); - while ((in_ep[epnum].diepint & USB_D_EPDISBLD0_M) == 0) ; - in_ep[epnum].diepint = USB_D_EPDISBLD0_M; - } - - // Flush the FIFO, and wait until we have confirmed it cleared. - uint8_t const fifo_num = ((in_ep[epnum].diepctl >> USB_D_TXFNUM1_S) & USB_D_TXFNUM1_V); - // USB0.grstctl |= (fifo_num << USB_TXFNUM_S); - // USB0.grstctl |= USB_TXFFLSH_M; - // while ((USB0.grstctl & USB_TXFFLSH_M) != 0) ; - uint32_t rstctl_last = USB0.grstctl; - uint32_t rstctl = USB_TXFFLSH_M; - rstctl |= (fifo_num << USB_TXFNUM_S); - USB0.grstctl = rstctl; - while ((USB0.grstctl & USB_TXFFLSH_M) != 0) ; - USB0.grstctl = rstctl_last; - // TODO: Clear grstctl::fifo_num after fifo flsh - } else { - // Only disable currently enabled non-control endpoint - if ((epnum == 0) || !(out_ep[epnum].doepctl & USB_EPENA0_M)) { - out_ep[epnum].doepctl |= USB_STALL0_M; - } else { - // Asserting GONAK is required to STALL an OUT endpoint. - // Simpler to use polling here, we don't use the "B"OUTNAKEFF interrupt - // anyway, and it can't be cleared by user code. If this while loop never - // finishes, we have bigger problems than just the stack. - USB0.dctl |= USB_SGOUTNAK_M; - while ((USB0.gintsts & USB_GOUTNAKEFF_M) == 0) ; - - // Ditto here- disable the endpoint. Note that only STALL and not SNAK - // is set here. - out_ep[epnum].doepctl |= (USB_STALL0_M | USB_EPDIS0_M); - while ((out_ep[epnum].doepint & USB_EPDISBLD0_M) == 0) ; - out_ep[epnum].doepint = USB_EPDISBLD0_M; - - // Allow other OUT endpoints to keep receiving. - USB0.dctl |= USB_CGOUTNAK_M; - } - } -} - -void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) -{ - (void)rhport; - - usb_out_endpoint_t *out_ep = &(USB0.out_ep_reg[0]); - usb_in_endpoint_t *in_ep = &(USB0.in_ep_reg[0]); - - uint8_t const epnum = tu_edpt_number(ep_addr); - uint8_t const dir = tu_edpt_dir(ep_addr); - - if (dir == TUSB_DIR_IN) { - in_ep[epnum].diepctl &= ~USB_D_STALL1_M; - - uint8_t eptype = (in_ep[epnum].diepctl & USB_D_EPTYPE1_M) >> USB_D_EPTYPE1_S; - // Required by USB spec to reset DATA toggle bit to DATA0 on interrupt - // and bulk endpoints. - if (eptype == 2 || eptype == 3) { - in_ep[epnum].diepctl |= USB_DI_SETD0PID1_M; - } - } else { - out_ep[epnum].doepctl &= ~USB_STALL1_M; - - uint8_t eptype = (out_ep[epnum].doepctl & USB_EPTYPE1_M) >> USB_EPTYPE1_S; - // Required by USB spec to reset DATA toggle bit to DATA0 on interrupt - // and bulk endpoints. - if (eptype == 2 || eptype == 3) { - out_ep[epnum].doepctl |= USB_DO_SETD0PID1_M; - } - } -} - -/*------------------------------------------------------------------*/ - -static void receive_packet(xfer_ctl_t *xfer, /* usb_out_endpoint_t * out_ep, */ uint16_t xfer_size) -{ - ESP_EARLY_LOGV(TAG, "USB - receive_packet"); - volatile uint32_t *rx_fifo = USB0.fifo[0]; - - // See above TODO - // uint16_t remaining = (out_ep->DOEPTSIZ & UsbDOEPTSIZ_XFRSIZ_Msk) >> UsbDOEPTSIZ_XFRSIZ_Pos; - // xfer->queued_len = xfer->total_len - remaining; - - uint16_t remaining = xfer->total_len - xfer->queued_len; - uint16_t to_recv_size; - - if (remaining <= xfer->max_size) { - // Avoid buffer overflow. - to_recv_size = (xfer_size > remaining) ? remaining : xfer_size; - } else { - // Room for full packet, choose recv_size based on what the microcontroller - // claims. - to_recv_size = (xfer_size > xfer->max_size) ? xfer->max_size : xfer_size; - } - - // Common buffer read -#if 0 // TODO support dcd_edpt_xfer_fifo API - if (xfer->ff) - { - // Ring buffer - tu_fifo_write_n_const_addr_full_words(xfer->ff, (const void *) rx_fifo, to_recv_size); - } - else -#endif - { - uint8_t to_recv_rem = to_recv_size % 4; - uint16_t to_recv_size_aligned = to_recv_size - to_recv_rem; - - // Do not assume xfer buffer is aligned. - uint8_t *base = (xfer->buffer + xfer->queued_len); - - // This for loop always runs at least once- skip if less than 4 bytes - // to collect. - if (to_recv_size >= 4) { - for (uint16_t i = 0; i < to_recv_size_aligned; i += 4) { - uint32_t tmp = (*rx_fifo); - base[i] = tmp & 0x000000FF; - base[i + 1] = (tmp & 0x0000FF00) >> 8; - base[i + 2] = (tmp & 0x00FF0000) >> 16; - base[i + 3] = (tmp & 0xFF000000) >> 24; - } - } - - // Do not read invalid bytes from RX FIFO. - if (to_recv_rem != 0) { - uint32_t tmp = (*rx_fifo); - uint8_t *last_32b_bound = base + to_recv_size_aligned; - - last_32b_bound[0] = tmp & 0x000000FF; - if (to_recv_rem > 1) { - last_32b_bound[1] = (tmp & 0x0000FF00) >> 8; - } - if (to_recv_rem > 2) { - last_32b_bound[2] = (tmp & 0x00FF0000) >> 16; - } - } - } - - xfer->queued_len += xfer_size; - - // Per USB spec, a short OUT packet (including length 0) is always - // indicative of the end of a transfer (at least for ctl, bulk, int). - xfer->short_packet = (xfer_size < xfer->max_size); -} - -static void transmit_packet(xfer_ctl_t *xfer, volatile usb_in_endpoint_t *in_ep, uint8_t fifo_num) -{ - ESP_EARLY_LOGV(TAG, "USB - transmit_packet"); - volatile uint32_t *tx_fifo = USB0.fifo[fifo_num]; - - uint16_t remaining = (in_ep->dieptsiz & 0x7FFFFU) >> USB_D_XFERSIZE0_S; - xfer->queued_len = xfer->total_len - remaining; - - uint16_t to_xfer_size = (remaining > xfer->max_size) ? xfer->max_size : remaining; - -#if 0 // TODO support dcd_edpt_xfer_fifo API - if (xfer->ff) - { - tu_fifo_read_n_const_addr_full_words(xfer->ff, (void *) tx_fifo, to_xfer_size); - } - else -#endif - { - uint8_t to_xfer_rem = to_xfer_size % 4; - uint16_t to_xfer_size_aligned = to_xfer_size - to_xfer_rem; - - // Buffer might not be aligned to 32b, so we need to force alignment - // by copying to a temp var. - uint8_t *base = (xfer->buffer + xfer->queued_len); - - // This for loop always runs at least once- skip if less than 4 bytes - // to send off. - if (to_xfer_size >= 4) { - for (uint16_t i = 0; i < to_xfer_size_aligned; i += 4) { - uint32_t tmp = base[i] | (base[i + 1] << 8) | - (base[i + 2] << 16) | (base[i + 3] << 24); - (*tx_fifo) = tmp; - } - } - - // Do not read beyond end of buffer if not divisible by 4. - if (to_xfer_rem != 0) { - uint32_t tmp = 0; - uint8_t *last_32b_bound = base + to_xfer_size_aligned; - - tmp |= last_32b_bound[0]; - if (to_xfer_rem > 1) { - tmp |= (last_32b_bound[1] << 8); - } - if (to_xfer_rem > 2) { - tmp |= (last_32b_bound[2] << 16); - } - - (*tx_fifo) = tmp; - } - } -} - -static void read_rx_fifo(void) -{ - // Pop control word off FIFO (completed xfers will have 2 control words, - // we only pop one ctl word each interrupt). - uint32_t const ctl_word = USB0.grxstsp; - uint8_t const pktsts = (ctl_word & USB_PKTSTS_M) >> USB_PKTSTS_S; - uint8_t const epnum = (ctl_word & USB_CHNUM_M ) >> USB_CHNUM_S; - uint16_t const bcnt = (ctl_word & USB_BCNT_M ) >> USB_BCNT_S; - - switch (pktsts) { - case 0x01: // Global OUT NAK (Interrupt) - ESP_EARLY_LOGV(TAG, "TUSB IRQ - RX type : Global OUT NAK"); - break; - - case 0x02: { // Out packet recvd - ESP_EARLY_LOGV(TAG, "TUSB IRQ - RX type : Out packet"); - xfer_ctl_t *xfer = XFER_CTL_BASE(epnum, TUSB_DIR_OUT); - receive_packet(xfer, bcnt); - } - break; - - case 0x03: // Out packet done (Interrupt) - ESP_EARLY_LOGV(TAG, "TUSB IRQ - RX type : Out packet done"); - break; - - case 0x04: // Step 2: Setup transaction completed (Interrupt) - // After this event, OEPINT interrupt will occur with SETUP bit set - ESP_EARLY_LOGV(TAG, "TUSB IRQ - RX : Setup packet done"); - USB0.out_ep_reg[epnum].doeptsiz |= USB_SUPCNT0_M; - break; - - case 0x06: { // Step1: Setup data packet received - volatile uint32_t *rx_fifo = USB0.fifo[0]; - - // We can receive up to three setup packets in succession, but - // only the last one is valid. Therefore we just overwrite it - _setup_packet[0] = (*rx_fifo); - _setup_packet[1] = (*rx_fifo); - - ESP_EARLY_LOGV(TAG, "TUSB IRQ - RX : Setup packet : 0x%08x 0x%08x", _setup_packet[0], _setup_packet[1]); - } - break; - - default: // Invalid, do something here, like breakpoint? - TU_BREAKPOINT(); - break; - } -} - -static void handle_epout_ints(void) -{ - // GINTSTS will be cleared with DAINT == 0 - // DAINT for a given EP clears when DOEPINTx is cleared. - // DOEPINT will be cleared when DAINT's out bits are cleared. - for (int n = 0; n < USB_OUT_EP_NUM; n++) { - xfer_ctl_t *xfer = XFER_CTL_BASE(n, TUSB_DIR_OUT); - - if (USB0.daint & (1 << (16 + n))) { - // SETUP packet Setup Phase done. - if ((USB0.out_ep_reg[n].doepint & USB_SETUP0_M)) { - USB0.out_ep_reg[n].doepint = USB_STUPPKTRCVD0_M | USB_SETUP0_M; // clear - dcd_event_setup_received(0, (uint8_t *)&_setup_packet[0], true); - } - - // OUT XFER complete (single packet).q - if (USB0.out_ep_reg[n].doepint & USB_XFERCOMPL0_M) { - - ESP_EARLY_LOGV(TAG, "TUSB IRQ - EP OUT - XFER complete (single packet)"); - USB0.out_ep_reg[n].doepint = USB_XFERCOMPL0_M; - - // Transfer complete if short packet or total len is transferred - if (xfer->short_packet || (xfer->queued_len == xfer->total_len)) { - xfer->short_packet = false; - dcd_event_xfer_complete(0, n, xfer->queued_len, XFER_RESULT_SUCCESS, true); - } else { - // Schedule another packet to be received. - USB0.out_ep_reg[n].doeptsiz |= USB_PKTCNT0_M | ((xfer->max_size & USB_XFERSIZE0_V) << USB_XFERSIZE0_S); - USB0.out_ep_reg[n].doepctl |= USB_EPENA0_M | USB_CNAK0_M; - } - } - } - } -} - -static void handle_epin_ints(void) -{ - // GINTSTS will be cleared with DAINT == 0 - // DAINT for a given EP clears when DIEPINTx is cleared. - // IEPINT will be cleared when DAINT's out bits are cleared. - for (uint32_t n = 0; n < USB_IN_EP_NUM; n++) { - xfer_ctl_t *xfer = &xfer_status[n][TUSB_DIR_IN]; - - if (USB0.daint & (1 << (0 + n))) { - ESP_EARLY_LOGV(TAG, "TUSB IRQ - EP IN %u", n); - - if (USB0.in_ep_reg[n].diepint & BIT(15)) { - USB0.in_ep_reg[n].diepint = BIT(15); - ESP_EARLY_LOGE(TAG, "Unknown Condition");//todo: - bus_reset(); - } - - // IN XFER complete (entire xfer). - if (USB0.in_ep_reg[n].diepint & USB_D_XFERCOMPL0_M) { - ESP_EARLY_LOGV(TAG, "TUSB IRQ - IN XFER complete!"); - USB0.in_ep_reg[n].diepint = USB_D_XFERCOMPL0_M; - dcd_event_xfer_complete(0, n | TUSB_DIR_IN_MASK, xfer->total_len, XFER_RESULT_SUCCESS, true); - if (!(USB0.in_ep_reg[n].diepint & USB_D_TXFEMP0_M)) { - ESP_EARLY_LOGE(TAG, "Complete but not empty: %u/%u", xfer->queued_len, xfer->total_len);//todo: - } - } - - // XFER FIFO empty - if (USB0.in_ep_reg[n].diepint & USB_D_TXFEMP0_M) { - ESP_EARLY_LOGV(TAG, "TUSB IRQ - IN XFER FIFO empty!"); - USB0.in_ep_reg[n].diepint = USB_D_TXFEMP0_M; - transmit_packet(xfer, &USB0.in_ep_reg[n], n); - - // Turn off TXFE if all bytes are written. - if (xfer->queued_len == xfer->total_len) - { - USB0.dtknqr4_fifoemptymsk &= ~(1 << n); - } - } - - // XFER Timeout - if (USB0.in_ep_reg[n].diepint & USB_D_TIMEOUT0_M) { - // Clear interrupt or enpoint will hang. - USB0.in_ep_reg[n].diepint = USB_D_TIMEOUT0_M; - ESP_EARLY_LOGE(TAG, "XFER Timeout");//todo: - // Maybe retry? - } - } - } -} - - -static void _dcd_int_handler(void* arg) -{ - (void) arg; - uint8_t const rhport = 0; - - const uint32_t int_msk = USB0.gintmsk; - const uint32_t int_status = USB0.gintsts & int_msk; - - if (int_status & USB_USBRST_M) { - // start of reset - ESP_EARLY_LOGV(TAG, "dcd_int_handler - reset"); - USB0.gintsts = USB_USBRST_M; - // FIFOs will be reassigned when the endpoints are reopen - _allocated_fifos = 1; - bus_reset(); - } - - if (int_status & USB_RESETDET_M) { - ESP_EARLY_LOGV(TAG, "dcd_int_handler - reset while suspend"); - USB0.gintsts = USB_RESETDET_M; - // no need to double reset - if ((int_status & USB_USBRST_M) == 0) { - _allocated_fifos = 1; - bus_reset(); - } - } - - if (int_status & USB_ENUMDONE_M) { - // ENUMDNE detects speed of the link. For full-speed, we - // always expect the same value. This interrupt is considered - // the end of reset. - USB0.gintsts = USB_ENUMDONE_M; - enum_done_processing(); - dcd_event_bus_reset(rhport, TUSB_SPEED_FULL, true); - } - - if(int_status & USB_USBSUSP_M) - { - USB0.gintsts = USB_USBSUSP_M; - //dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true); - dcd_event_bus_signal(rhport, DCD_EVENT_UNPLUGGED, true); - _allocated_fifos = 1; - } - - if(int_status & USB_WKUPINT_M) - { - USB0.gintsts = USB_WKUPINT_M; - dcd_event_bus_signal(rhport, DCD_EVENT_RESUME, true); - } - - if (int_status & USB_OTGINT_M) - { - // OTG INT bit is read-only - ESP_EARLY_LOGV(TAG, "dcd_int_handler - disconnected"); - - uint32_t const otg_int = USB0.gotgint; - - if (otg_int & USB_SESENDDET_M) - { - dcd_event_bus_signal(rhport, DCD_EVENT_UNPLUGGED, true); - _allocated_fifos = 1; - } - - USB0.gotgint = otg_int; - } - - if (int_status & USB_SOF_M) { - USB0.gintsts = USB_SOF_M; - - // Disable SOF interrupt since currently only used for remote wakeup detection - USB0.gintmsk &= ~USB_SOFMSK_M; - - dcd_event_bus_signal(rhport, DCD_EVENT_SOF, true); - } - - - if (int_status & USB_RXFLVI_M) { - // RXFLVL bit is read-only - ESP_EARLY_LOGV(TAG, "dcd_int_handler - rx!"); - - // Mask out RXFLVL while reading data from FIFO - USB0.gintmsk &= ~USB_RXFLVIMSK_M; - read_rx_fifo(); - USB0.gintmsk |= USB_RXFLVIMSK_M; - } - - // OUT endpoint interrupt handling. - if (int_status & USB_OEPINT_M) { - // OEPINT is read-only - ESP_EARLY_LOGV(TAG, "dcd_int_handler - OUT endpoint!"); - handle_epout_ints(); - } - - // IN endpoint interrupt handling. - if (int_status & USB_IEPINT_M) { - // IEPINT bit read-only - ESP_EARLY_LOGV(TAG, "dcd_int_handler - IN endpoint!"); - handle_epin_ints(); - } - - // Without handling - USB0.gintsts |= USB_CURMOD_INT_M | - USB_MODEMIS_M | - USB_OTGINT_M | - USB_NPTXFEMP_M | - USB_GINNAKEFF_M | - USB_GOUTNAKEFF | - USB_ERLYSUSP_M | - USB_USBSUSP_M | - USB_ISOOUTDROP_M | - USB_EOPF_M | - USB_EPMIS_M | - USB_INCOMPISOIN_M | - USB_INCOMPIP_M | - USB_FETSUSP_M | - USB_PTXFEMP_M; -} - -void dcd_int_enable (uint8_t rhport) -{ - (void) rhport; - esp_intr_alloc(ETS_USB_INTR_SOURCE, ESP_INTR_FLAG_LOWMED, (intr_handler_t) _dcd_int_handler, NULL, &usb_ih); -} - -void dcd_int_disable (uint8_t rhport) -{ - (void) rhport; - esp_intr_free(usb_ih); -} - -#endif // #if OPT_MCU_ESP32S2 || OPT_MCU_ESP32S3 - From d4a3131e29909691cc97876acfa8c821e8a2ccfe Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:57:57 +0200 Subject: [PATCH 127/211] Delete tools/update-components.sh --- tools/update-components.sh | 42 -------------------------------------- 1 file changed, 42 deletions(-) delete mode 100755 tools/update-components.sh diff --git a/tools/update-components.sh b/tools/update-components.sh deleted file mode 100755 index a3bf4ac5f..000000000 --- a/tools/update-components.sh +++ /dev/null @@ -1,42 +0,0 @@ -#/bin/bash - -source ./tools/config.sh - -CAMERA_REPO_URL="https://github.com/espressif/esp32-camera.git" -TINYUSB_REPO_URL="https://github.com/hathach/tinyusb.git" -TINYUSB_REPO_DIR="$AR_COMPS/arduino_tinyusb/tinyusb" - -# -# CLONE/UPDATE ESP32-CAMERA -# -#echo "Updating ESP32 Camera..." -#if [ ! -d "$AR_COMPS/esp32-camera" ]; then -# git clone -b master --recursive --depth 1 --shallow-submodule $CAMERA_REPO_URL "$AR_COMPS/esp32-camera" -#else -# cd "$AR_COMPS/esp32-camera" -# git pull -# git submodule update --depth 1 -# # -ff is for cleaning untracked files as well as submodules -# git clean -ffdx -# cd - -#fi -#if [ $? -ne 0 ]; then exit 1; fi - -# -# Arduino needs cam_hal.h from esp32-camera in include folder -# -#cp "$AR_COMPS/esp32-camera/driver/private_include/cam_hal.h" "$AR_COMPS/esp32-camera/driver/include/" - -# -# CLONE/UPDATE TINYUSB -# -#echo "Updating TinyUSB..." -#if [ ! -d "$TINYUSB_REPO_DIR" ]; then -# git clone -b master --depth 1 "$TINYUSB_REPO_URL" "$TINYUSB_REPO_DIR" -#else -# cd $TINYUSB_REPO_DIR -# git pull -# # -ff is for cleaning untracked files as well as submodules -# git clean -ffdx -#fi -#if [ $? -ne 0 ]; then exit 1; fi From c04aafde9171bd7a0783a1adc3c4c3c48dfeaa8c Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:59:49 +0200 Subject: [PATCH 128/211] Update build.sh --- build.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 1f0375a7a..dbac1dac3 100755 --- a/build.sh +++ b/build.sh @@ -93,11 +93,7 @@ mkdir -p dist rm -rf dependencies.lock if [ $SKIP_ENV -eq 0 ]; then - echo "* Installing/Updating ESP-IDF and all components..." - # update components from git - ./tools/update-components.sh - if [ $? -ne 0 ]; then exit 1; fi - + echo "* Installing/Updating ESP-IDF / Arduino and all components..." # install arduino component ./tools/install-arduino.sh if [ $? -ne 0 ]; then exit 1; fi From 7a0f7ea2432fd9be70316358ec56caf83d71be7a Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 19 Apr 2024 16:03:56 +0200 Subject: [PATCH 129/211] rm -rf "$AR_COMPS/arduino/libraries/USB" --- tools/install-arduino.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index a098a61c7..75c34a575 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -85,6 +85,7 @@ rm -rf "$AR_COMPS/arduino/libraries/BluetoothSerial" rm -rf "$AR_COMPS/arduino/libraries/WiFiProv" rm -rf "$AR_COMPS/arduino/libraries/WiFiClientSecure" rm -rf "$AR_COMPS/arduino/libraries/NetworkClientSecure" +rm -rf "$AR_COMPS/arduino/libraries/USB" rm -rf "$AR_COMPS/arduino/libraries/ESP32" rm -rf "$AR_COMPS/arduino/libraries/ESP_SR" rm -rf "$AR_COMPS/arduino/libraries/ESP_NOW" From 5a439d3dcda1b0c13d76f96dc47633c0dbb0088d Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 19 Apr 2024 16:05:29 +0200 Subject: [PATCH 130/211] rm -rf arduino-esp32/libraries/USB --- tools/archive-build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index c3ba8be96..337495962 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -35,6 +35,7 @@ rm -rf arduino-esp32/libraries/BluetoothSerial rm -rf arduino-esp32/libraries/WiFiProv rm -rf arduino-esp32/libraries/WiFiClientSecure rm -rf arduino-esp32/libraries/NetworkClientSecure +rm -rf arduino-esp32/libraries/USB rm -rf arduino-esp32/libraries/ESP_SR rm -rf arduino-esp32/libraries/ESP_NOW rm -rf arduino-esp32/libraries/TFLiteMicro From 955be35e0e4207b8ffefc2619e09921aa45430fe Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 19 Apr 2024 16:16:19 +0200 Subject: [PATCH 131/211] Create Arduino_CMakeLists.diff --- patches/Arduino_CMakeLists.diff | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 patches/Arduino_CMakeLists.diff diff --git a/patches/Arduino_CMakeLists.diff b/patches/Arduino_CMakeLists.diff new file mode 100644 index 000000000..5992d1d1b --- /dev/null +++ b/patches/Arduino_CMakeLists.diff @@ -0,0 +1,40 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d3972bf06a..3813da3468 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -95,7 +95,6 @@ set(ARDUINO_ALL_LIBRARIES + SPI + Ticker + Update +- USB + WebServer + WiFi + Wire +@@ -149,17 +148,6 @@ set(ARDUINO_LIBRARY_Update_SRCS + libraries/Update/src/Updater.cpp + libraries/Update/src/HttpsOTAUpdate.cpp) + +-set(ARDUINO_LIBRARY_USB_SRCS +- libraries/USB/src/USBHID.cpp +- libraries/USB/src/USBMIDI.cpp +- libraries/USB/src/USBHIDMouse.cpp +- libraries/USB/src/USBHIDKeyboard.cpp +- libraries/USB/src/USBHIDGamepad.cpp +- libraries/USB/src/USBHIDConsumerControl.cpp +- libraries/USB/src/USBHIDSystemControl.cpp +- libraries/USB/src/USBHIDVendor.cpp +- libraries/USB/src/USBVendor.cpp) +- + set(ARDUINO_LIBRARY_WebServer_SRCS + libraries/WebServer/src/WebServer.cpp + libraries/WebServer/src/Parsing.cpp +@@ -247,9 +235,6 @@ function(maybe_add_component component_name) + endif() + endfunction() + +-if(IDF_TARGET MATCHES "esp32s2|esp32s3" AND CONFIG_TINYUSB_ENABLED) +- maybe_add_component(arduino_tinyusb) +-endif() + if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_ArduinoOTA) + maybe_add_component(esp_https_ota) + endif() From 6c90faf662a6e7a67211ca9327c1b84b422383ff Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 19 Apr 2024 16:32:22 +0200 Subject: [PATCH 132/211] Patch to remove USB --- tools/install-arduino.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index 75c34a575..f2363d300 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -90,3 +90,8 @@ rm -rf "$AR_COMPS/arduino/libraries/ESP32" rm -rf "$AR_COMPS/arduino/libraries/ESP_SR" rm -rf "$AR_COMPS/arduino/libraries/ESP_NOW" rm -rf "$AR_COMPS/arduino/libraries/TFLiteMicro" + +# Patch to remove USB from Arduino CMakeLists.txt +cd "$AR_COMPS/arduino" +patch -p1 -N -i "$IDF_PATH/../patches/Arduino_CMakeLists.diff" +cd - From 3c18a2ed544797d58ee3a5e9c541829cd43cb636 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 19 Apr 2024 16:37:49 +0200 Subject: [PATCH 133/211] Fix path --- tools/install-arduino.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index f2363d300..c9f6651a7 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -93,5 +93,5 @@ rm -rf "$AR_COMPS/arduino/libraries/TFLiteMicro" # Patch to remove USB from Arduino CMakeLists.txt cd "$AR_COMPS/arduino" -patch -p1 -N -i "$IDF_PATH/../patches/Arduino_CMakeLists.diff" +patch -p1 -N -i ../patches/Arduino_CMakeLists.diff cd - From 2e7542f90af81ae2081c8f151b36da3bebcecdf7 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 19 Apr 2024 16:42:09 +0200 Subject: [PATCH 134/211] Update install-arduino.sh --- tools/install-arduino.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index c9f6651a7..659cf5cb3 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -92,6 +92,7 @@ rm -rf "$AR_COMPS/arduino/libraries/ESP_NOW" rm -rf "$AR_COMPS/arduino/libraries/TFLiteMicro" # Patch to remove USB from Arduino CMakeLists.txt -cd "$AR_COMPS/arduino" +cd "$AR_COMPS/arduino" +ls patch -p1 -N -i ../patches/Arduino_CMakeLists.diff cd - From 9fd68fe057865265c2564ce283554d0008986ad4 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 19 Apr 2024 17:06:30 +0200 Subject: [PATCH 135/211] fix path --- patches/Arduino_CMakeLists.diff | 4 ++-- tools/install-arduino.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/Arduino_CMakeLists.diff b/patches/Arduino_CMakeLists.diff index 5992d1d1b..b5929e5b5 100644 --- a/patches/Arduino_CMakeLists.diff +++ b/patches/Arduino_CMakeLists.diff @@ -13,7 +13,7 @@ index d3972bf06a..3813da3468 100644 @@ -149,17 +148,6 @@ set(ARDUINO_LIBRARY_Update_SRCS libraries/Update/src/Updater.cpp libraries/Update/src/HttpsOTAUpdate.cpp) - + -set(ARDUINO_LIBRARY_USB_SRCS - libraries/USB/src/USBHID.cpp - libraries/USB/src/USBMIDI.cpp @@ -31,7 +31,7 @@ index d3972bf06a..3813da3468 100644 @@ -247,9 +235,6 @@ function(maybe_add_component component_name) endif() endfunction() - + -if(IDF_TARGET MATCHES "esp32s2|esp32s3" AND CONFIG_TINYUSB_ENABLED) - maybe_add_component(arduino_tinyusb) -endif() diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index 659cf5cb3..e8e230422 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -94,5 +94,5 @@ rm -rf "$AR_COMPS/arduino/libraries/TFLiteMicro" # Patch to remove USB from Arduino CMakeLists.txt cd "$AR_COMPS/arduino" ls -patch -p1 -N -i ../patches/Arduino_CMakeLists.diff +patch -p1 -N -i ../../patches/Arduino_CMakeLists.diff cd - From f7897f54211e9a4703735d5dbcebea4f4a5e3a1d Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 19 Apr 2024 17:13:28 +0200 Subject: [PATCH 136/211] shorter Text --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index dbac1dac3..6261bebdf 100755 --- a/build.sh +++ b/build.sh @@ -93,7 +93,7 @@ mkdir -p dist rm -rf dependencies.lock if [ $SKIP_ENV -eq 0 ]; then - echo "* Installing/Updating ESP-IDF / Arduino and all components..." + echo "* Installing ESP-IDF/Arduino and all components..." # install arduino component ./tools/install-arduino.sh if [ $? -ne 0 ]; then exit 1; fi From 0dbe5577e9723ad94f2b103fb11b704b705e4bab Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 19 Apr 2024 17:19:39 +0200 Subject: [PATCH 137/211] rm not needed folder from Arduino --- tools/install-arduino.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index e8e230422..db996dd8a 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -73,7 +73,10 @@ if [ $? -ne 0 ]; then exit 1; fi # # remove code and libraries not needed/wanted for Tasmota framework # -rm -rf "$AR_COMPS/arduino/cores/esp32/chip-debug-report.cpp" +rm -rf "$AR_COMPS/arduino/docs" +rm -rf "$AR_COMPS/arduino/idf_component_examples" +rm -rf "$AR_COMPS/arduino/package" +rm -rf "$AR_COMPS/arduino/tests" rm -rf "$AR_COMPS/arduino/cores/esp32/chip-debug-report.h" rm -rf "$AR_COMPS/arduino/libraries/RainMaker" rm -rf "$AR_COMPS/arduino/libraries/Insights" @@ -93,6 +96,5 @@ rm -rf "$AR_COMPS/arduino/libraries/TFLiteMicro" # Patch to remove USB from Arduino CMakeLists.txt cd "$AR_COMPS/arduino" -ls patch -p1 -N -i ../../patches/Arduino_CMakeLists.diff cd - From 6c25f5508f80957090f492ab253216c3be755c91 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 19 Apr 2024 17:21:44 +0200 Subject: [PATCH 138/211] Update install-arduino.sh --- tools/install-arduino.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index db996dd8a..ce47198a3 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -77,6 +77,7 @@ rm -rf "$AR_COMPS/arduino/docs" rm -rf "$AR_COMPS/arduino/idf_component_examples" rm -rf "$AR_COMPS/arduino/package" rm -rf "$AR_COMPS/arduino/tests" +rm -rf "$AR_COMPS/arduino/cores/esp32/chip-debug-report.cpp" rm -rf "$AR_COMPS/arduino/cores/esp32/chip-debug-report.h" rm -rf "$AR_COMPS/arduino/libraries/RainMaker" rm -rf "$AR_COMPS/arduino/libraries/Insights" From 2d34aebac5a4a9dc1543f613af663e244bd82e51 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 19 Apr 2024 18:50:01 +0200 Subject: [PATCH 139/211] remove "PPP" --- patches/Arduino_CMakeLists.diff | 36 +++++++++++++++++++++++++++++---- tools/archive-build.sh | 1 + tools/install-arduino.sh | 1 + 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/patches/Arduino_CMakeLists.diff b/patches/Arduino_CMakeLists.diff index b5929e5b5..999153c09 100644 --- a/patches/Arduino_CMakeLists.diff +++ b/patches/Arduino_CMakeLists.diff @@ -1,8 +1,15 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index d3972bf06a..3813da3468 100644 +index d3972bf06a..88c9910f76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -95,7 +95,6 @@ set(ARDUINO_ALL_LIBRARIES +@@ -88,14 +88,12 @@ set(ARDUINO_ALL_LIBRARIES + LittleFS + NetBIOS + Network +- PPP + Preferences + SD_MMC + SD SPI Ticker Update @@ -10,7 +17,18 @@ index d3972bf06a..3813da3468 100644 WebServer WiFi Wire -@@ -149,17 +148,6 @@ set(ARDUINO_LIBRARY_Update_SRCS +@@ -128,10 +126,6 @@ set(ARDUINO_LIBRARY_LittleFS_SRCS libraries/LittleFS/src/LittleFS.cpp) + + set(ARDUINO_LIBRARY_NetBIOS_SRCS libraries/NetBIOS/src/NetBIOS.cpp) + +-set(ARDUINO_LIBRARY_PPP_SRCS +- libraries/PPP/src/PPP.cpp +- libraries/PPP/src/ppp.c) +- + set(ARDUINO_LIBRARY_Preferences_SRCS libraries/Preferences/src/Preferences.cpp) + + set(ARDUINO_LIBRARY_SD_MMC_SRCS libraries/SD_MMC/src/SD_MMC.cpp) +@@ -149,17 +143,6 @@ set(ARDUINO_LIBRARY_Update_SRCS libraries/Update/src/Updater.cpp libraries/Update/src/HttpsOTAUpdate.cpp) @@ -28,7 +46,7 @@ index d3972bf06a..3813da3468 100644 set(ARDUINO_LIBRARY_WebServer_SRCS libraries/WebServer/src/WebServer.cpp libraries/WebServer/src/Parsing.cpp -@@ -247,9 +235,6 @@ function(maybe_add_component component_name) +@@ -247,9 +230,6 @@ function(maybe_add_component component_name) endif() endfunction() @@ -38,3 +56,13 @@ index d3972bf06a..3813da3468 100644 if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_ArduinoOTA) maybe_add_component(esp_https_ota) endif() +diff --git a/idf_component.yml b/idf_component.yml +index ae548c41d4..7a4e094050 100644 +--- a/idf_component.yml ++++ b/idf_component.yml +@@ -45,5 +45,4 @@ dependencies: + idf: ">=5.1" + # mdns 1.2.3 is necessary to build H2 with no WiFi + mdns: "^1.2.3" +- espressif/esp_modem: "^1.1.0" + joltwallet/littlefs: "^1.14.1" diff --git a/tools/archive-build.sh b/tools/archive-build.sh index 337495962..d5cc6e9cb 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -36,6 +36,7 @@ rm -rf arduino-esp32/libraries/WiFiProv rm -rf arduino-esp32/libraries/WiFiClientSecure rm -rf arduino-esp32/libraries/NetworkClientSecure rm -rf arduino-esp32/libraries/USB +rm -rf arduino-esp32/libraries/PPP rm -rf arduino-esp32/libraries/ESP_SR rm -rf arduino-esp32/libraries/ESP_NOW rm -rf arduino-esp32/libraries/TFLiteMicro diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index ce47198a3..31ba9a83e 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -90,6 +90,7 @@ rm -rf "$AR_COMPS/arduino/libraries/WiFiProv" rm -rf "$AR_COMPS/arduino/libraries/WiFiClientSecure" rm -rf "$AR_COMPS/arduino/libraries/NetworkClientSecure" rm -rf "$AR_COMPS/arduino/libraries/USB" +rm -rf "$AR_COMPS/arduino/libraries/PPP" rm -rf "$AR_COMPS/arduino/libraries/ESP32" rm -rf "$AR_COMPS/arduino/libraries/ESP_SR" rm -rf "$AR_COMPS/arduino/libraries/ESP_NOW" From 20eeb6e5921b9e5ea2e7561c2eb366a4be85f642 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 21 Apr 2024 13:35:10 +0200 Subject: [PATCH 140/211] rm tinyusb and Arduino json --- build.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/build.sh b/build.sh index 6261bebdf..ef0bd2474 100755 --- a/build.sh +++ b/build.sh @@ -255,9 +255,6 @@ for component in `ls "$AR_COMPS"`; do echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt" fi done -# TinyUSB version -component_version="tinyusb: "$(git -C "$AR_COMPS/arduino_tinyusb/tinyusb" symbolic-ref --short HEAD || git -C "$AR_COMPS/arduino_tinyusb/tinyusb" tag --points-at HEAD)" "$(git -C "$AR_COMPS/arduino_tinyusb/tinyusb" rev-parse --short HEAD) -echo $component_version >> "$AR_TOOLS/esp32-arduino-libs/versions.txt" # managed components version for component in `ls "$AR_MANAGED_COMPS"`; do if [ -d "$AR_MANAGED_COMPS/$component/.git" ]; then @@ -272,11 +269,11 @@ done export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD) # update package_esp32_index.template.json -if [ "$BUILD_TYPE" = "all" ]; then - python3 ./tools/gen_tools_json.py -i "$IDF_PATH" -j "$AR_COMPS/arduino/package/package_esp32_index.template.json" -o "$AR_OUT/" - python3 ./tools/gen_tools_json.py -i "$IDF_PATH" -o "$TOOLS_JSON_OUT/" - if [ $? -ne 0 ]; then exit 1; fi -fi +#if [ "$BUILD_TYPE" = "all" ]; then +# python3 ./tools/gen_tools_json.py -i "$IDF_PATH" -j "$AR_COMPS/arduino/package/package_esp32_index.template.json" -o "$AR_OUT/" +# python3 ./tools/gen_tools_json.py -i "$IDF_PATH" -o "$TOOLS_JSON_OUT/" +# if [ $? -ne 0 ]; then exit 1; fi +#fi # Generate PlatformIO library manifest file if [ "$BUILD_TYPE" = "all" ]; then From 365568133a3b22a1cc04c812e05bed33bb7ba034 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 21 Apr 2024 14:18:58 +0200 Subject: [PATCH 141/211] Delete tools/gen_tools_json.py --- tools/gen_tools_json.py | 166 ---------------------------------------- 1 file changed, 166 deletions(-) delete mode 100644 tools/gen_tools_json.py diff --git a/tools/gen_tools_json.py b/tools/gen_tools_json.py deleted file mode 100644 index 20d8f864b..000000000 --- a/tools/gen_tools_json.py +++ /dev/null @@ -1,166 +0,0 @@ -#!/usr/bin/env python -# python tools/gen_tools_json.py -i $IDF_PATH -j components/arduino/package/package_esp32_index.template.json -o out/ - -from __future__ import print_function - -__author__ = "Hristo Gochkov" -__version__ = "2023" - -import os -import shutil -import errno -import os.path -import json -import platform -import sys -import stat -import argparse - -if sys.version_info[0] == 3: - unicode = lambda s: str(s) - -if __name__ == '__main__': - - parser = argparse.ArgumentParser( - prog = 'gen_tools_json', - description = 'Update Arduino package index with the tolls found in ESP-IDF') - parser.add_argument('-i', '--esp-idf', dest='idf_path', required=True, help='Path to ESP-IDF') - parser.add_argument('-j', '--pkg-json', dest='arduino_json', required=False, help='path to Arduino package json') - parser.add_argument('-o', '--out-path', dest='out_path', required=True, help='Output path to store the update package json') - args = parser.parse_args() - - simple_output = False - if args.arduino_json == None: - print('Source was not selected') - simple_output = True - else: - print('Source {0}.'.format(args.arduino_json)) - - idf_path = args.idf_path; - arduino_json = args.arduino_json; - out_path = args.out_path; - - # settings - arduino_tools = ["xtensa-esp32-elf","xtensa-esp32s2-elf","xtensa-esp32s3-elf","xtensa-esp-elf-gdb","riscv32-esp-elf","riscv32-esp-elf-gdb","openocd-esp32"] - - # code start - farray = {"packages":[{"platforms":[{"toolsDependencies":[]}],"tools":[]}]} - if simple_output == False: - farray = json.load(open(arduino_json)) - - idf_tools = json.load(open(idf_path + '/tools/tools.json')) - for tool in idf_tools['tools']: - try: - tool_index = arduino_tools.index(tool['name']) - except: - continue - tool_name = tool['name'] - tool_version = tool['versions'][0]['name'] - if tool_name.endswith('-elf'): - tool_name += '-gcc' - print('Found {0}, version: {1}'.format(tool_name, tool_version)) - - if simple_output == False: - dep_found = False - dep_skip = False - for dep in farray['packages'][0]['platforms'][0]['toolsDependencies']: - if dep['name'] == tool_name: - if dep['version'] == tool_version: - print('Skipping {0}. Same version {1}'.format(tool_name, tool_version)) - dep_skip = True - break - print('Updating dependency version of {0} from {1} to {2}'.format(tool_name, dep['version'], tool_version)) - dep['version'] = tool_version - dep_found = True - if dep_skip == True: - continue - if dep_found == False: - print('Adding new dependency: {0} version {1}'.format(tool_name, tool_version)) - deps = { - "packager": "esp32", - "name": tool_name, - "version": tool_version - } - farray['packages'][0]['platforms'][0]['toolsDependencies'].append(deps) - else: - print('Adding dependency: {0} version {1}'.format(tool_name, tool_version)) - deps = { - "packager": "esp32", - "name": tool_name, - "version": tool_version - } - farray['packages'][0]['platforms'][0]['toolsDependencies'].append(deps) - - systems = [] - for arch in tool['versions'][0]: - if arch == 'name' or arch == 'status': - continue - tool_data = tool['versions'][0][arch] - - system = { - "host": '', - "url": tool_data['url'], - "archiveFileName": os.path.basename(tool_data['url']), - "checksum": "SHA-256:"+tool_data['sha256'], - "size": str(tool_data['size']) - } - - if arch == "win32": - system["host"] = "i686-mingw32"; - elif arch == "win64": - system["host"] = "x86_64-mingw32"; - elif arch == "macos-arm64": - system["host"] = "arm64-apple-darwin"; - elif arch == "macos": - system["host"] = "x86_64-apple-darwin"; - elif arch == "linux-amd64": - system["host"] = "x86_64-pc-linux-gnu"; - elif arch == "linux-i686": - system["host"] = "i686-pc-linux-gnu"; - elif arch == "linux-arm64": - system["host"] = "aarch64-linux-gnu"; - elif arch == "linux-armel": - system["host"] = "arm-linux-gnueabihf"; - elif arch == "linux-armhf": - # system["host"] = "arm-linux-gnueabihf"; - continue - else : - continue - - systems.append(system) - - if simple_output == False: - tool_found = False - for t in farray['packages'][0]['tools']: - if t['name'] == tool_name: - t['version'] = tool_version - t['systems'] = systems - tool_found = True - print('Updating binaries of {0} to version {1}'.format(tool_name, tool_version)) - if tool_found == False: - print('Adding new tool: {0} version {1}'.format(tool_name, tool_version)) - tools = { - "name": tool_name, - "version": tool_version, - "systems": systems - } - farray['packages'][0]['tools'].append(tools) - else: - print('Adding tool: {0} version {1}'.format(tool_name, tool_version)) - tools = { - "name": tool_name, - "version": tool_version, - "systems": systems - } - farray['packages'][0]['tools'].append(tools) - - json_str = json.dumps(farray, indent=2) - out_file = out_path + "tools.json" - if simple_output == False: - out_file = out_path + os.path.basename(arduino_json) - - with open(out_file, "w") as f: - f.write(json_str+"\n") - f.close() - # print(json_str) - print('{0} generated'.format(out_file)) From f136ba8890543fa73d9f199aa82025cbae61840b Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 21 Apr 2024 14:30:41 +0200 Subject: [PATCH 142/211] Delete tools/push-to-arduino.sh --- tools/push-to-arduino.sh | 158 --------------------------------------- 1 file changed, 158 deletions(-) delete mode 100755 tools/push-to-arduino.sh diff --git a/tools/push-to-arduino.sh b/tools/push-to-arduino.sh deleted file mode 100755 index f4d794d0c..000000000 --- a/tools/push-to-arduino.sh +++ /dev/null @@ -1,158 +0,0 @@ -#!/bin/bash -source ./tools/config.sh - -if [ -x $GITHUB_TOKEN ]; then - echo "ERROR: GITHUB_TOKEN was not defined" - exit 1 -fi - -if ! [ -d "$AR_COMPS/arduino" ]; then - echo "ERROR: Target arduino folder does not exist!" - exit 1 -fi - -# setup git for pushing -git config --global github.user "$GITHUB_ACTOR" -git config --global user.name "$GITHUB_ACTOR" -git config --global user.email "$GITHUB_ACTOR@github.com" - -# -# UPDATE FILES -# - -# -# esp32-arduino-libs -# - -if [ $LIBS_HAS_COMMIT == "0" ] || [ $AR_HAS_COMMIT == "0" ]; then - cd "$AR_ROOT" - # create branch if necessary - if [ "$LIBS_HAS_BRANCH" == "1" ]; then - echo "Branch '$AR_NEW_BRANCH_NAME' Already Exists" - echo "Switching to esp32-arduino-libs branch '$AR_NEW_BRANCH_NAME'..." - git -C "$IDF_LIBS_DIR" checkout $AR_NEW_BRANCH_NAME - else - echo "Creating esp32-arduino-libs branch '$AR_NEW_BRANCH_NAME'..." - git -C "$IDF_LIBS_DIR" checkout -b $AR_NEW_BRANCH_NAME - fi - if [ $? -ne 0 ]; then - echo "ERROR: Checkout of branch '$AR_NEW_BRANCH_NAME' failed" - exit 1 - fi - - # make changes to the files - echo "Patching files in esp32-arduino-libs branch '$AR_NEW_BRANCH_NAME'..." - rm -rf $IDF_LIBS_DIR/* && cp -Rf $AR_TOOLS/esp32-arduino-libs/* $IDF_LIBS_DIR/ - - cd $IDF_LIBS_DIR - if [ -f "README.md" ]; then - rm -rf "README.md" - fi - - # did any of the files change? - if [ -n "$(git status --porcelain)" ]; then - echo "Pushing changes to esp32-arduino-libs branch '$AR_NEW_BRANCH_NAME'..." - git add . && git commit --message "$AR_NEW_COMMIT_MESSAGE" && git push -u origin $AR_NEW_BRANCH_NAME - if [ $? -ne 0 ]; then - echo "ERROR: Pushing to branch '$AR_NEW_BRANCH_NAME' failed" - exit 1 - fi - IDF_LIBS_COMMIT=`git rev-parse --verify HEAD` - IDF_LIBS_DL_URL="https://codeload.github.com/espressif/esp32-arduino-libs/zip/$IDF_LIBS_COMMIT" - # ToDo: this URL needs to get into Arduino's package.json - - # Download the file - filename="esp32-arduino-libs-$IDF_LIBS_COMMIT.zip" - curl -s -o "$filename" "$IDF_LIBS_DL_URL" - - # Check if the download was successful - if [ $? -ne 0 ]; then - echo "Error downloading file from $IDF_LIBS_DL_URL" - exit 1 - fi - - # Calculate the size in bytes and SHA-256 sum - size=$(stat -c%s "$filename") - sha256sum=$(sha256sum "$filename" | awk '{print $1}') - - # Clean up the downloaded file - rm "$filename" - - # Print the results - echo "Tool: esp32-arduino-libs" - echo "Version: $LIBS_VERSION" - echo "URL: $IDF_LIBS_DL_URL" - echo "File: $filename" - echo "Size: $size bytes" - echo "SHA-256: $sha256sum" - echo "JSON: $AR_OUT/package_esp32_index.template.json" - cd "$AR_ROOT" - python3 tools/add_sdk_json.py -j "$AR_OUT/package_esp32_index.template.json" -n "esp32-arduino-libs" -v "$LIBS_VERSION" -u "$IDF_LIBS_DL_URL" -f "$filename" -s "$size" -c "$sha256sum" - if [ $? -ne 0 ]; then exit 1; fi - - else - echo "No changes in esp32-arduino-libs branch '$AR_NEW_BRANCH_NAME'" - if [ $LIBS_HAS_BRANCH == "0" ]; then - echo "Delete created branch '$AR_NEW_BRANCH_NAME'" - git branch -d $AR_NEW_BRANCH_NAME - fi - exit 0 - fi -fi - -# -# esp32-arduino -# - -if [ $AR_HAS_COMMIT == "0" ]; then - cd "$AR_ROOT" - # create or checkout the branch - if [ ! $AR_HAS_BRANCH == "0" ]; then - echo "Switching to arduino branch '$AR_NEW_BRANCH_NAME'..." - git -C "$AR_COMPS/arduino" checkout $AR_NEW_BRANCH_NAME - else - echo "Creating arduino branch '$AR_NEW_BRANCH_NAME'..." - git -C "$AR_COMPS/arduino" checkout -b $AR_NEW_BRANCH_NAME - fi - if [ $? -ne 0 ]; then - echo "ERROR: Checkout of branch '$AR_NEW_BRANCH_NAME' failed" - exit 1 - fi - - # make changes to the files - echo "Patching files in branch '$AR_NEW_BRANCH_NAME'..." - rm -rf "$AR_COMPS/arduino/package/package_esp32_index.template.json" && cp -f "$AR_OUT/package_esp32_index.template.json" "$AR_COMPS/arduino/package/package_esp32_index.template.json" - - cd $AR_COMPS/arduino - - # did any of the files change? - if [ -n "$(git status --porcelain)" ]; then - echo "Pushing changes to branch '$AR_NEW_BRANCH_NAME'..." - git add . && git commit --message "$AR_NEW_COMMIT_MESSAGE" && git push -u origin $AR_NEW_BRANCH_NAME - if [ $? -ne 0 ]; then - echo "ERROR: Pushing to branch '$AR_NEW_BRANCH_NAME' failed" - exit 1 - fi - else - echo "No changes in branch '$AR_NEW_BRANCH_NAME'" - if [ $AR_HAS_BRANCH == "0" ]; then - echo "Delete created branch '$AR_NEW_BRANCH_NAME'" - git branch -d $AR_NEW_BRANCH_NAME - fi - exit 0 - fi - - # CREATE PULL REQUEST - if [ "$AR_HAS_PR" == "0" ]; then - echo "Creating PR '$AR_NEW_PR_TITLE'..." - pr_created=`git_create_pr "$AR_NEW_BRANCH_NAME" "$AR_NEW_PR_TITLE" "$AR_PR_TARGET_BRANCH"` - if [ $pr_created == "0" ]; then - echo "ERROR: Failed to create PR '$AR_NEW_PR_TITLE': "`echo "$git_create_pr_res" | jq -r '.message'`": "`echo "$git_create_pr_res" | jq -r '.errors[].message'` - exit 1 - fi - else - echo "PR '$AR_NEW_PR_TITLE' Already Exists" - fi -fi - -exit 0 From 8ed192f6f6cb729431b86685c8fe7a477527eab2 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 21 Apr 2024 14:44:50 +0200 Subject: [PATCH 143/211] rm not needed --- build.sh | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/build.sh b/build.sh index ef0bd2474..e94d9e3c5 100755 --- a/build.sh +++ b/build.sh @@ -14,10 +14,8 @@ export TARGET="esp32" BUILD_TYPE="all" SKIP_ENV=0 COPY_OUT=0 -ARCHIVE_OUT=0 -if [ -z $DEPLOY_OUT ]; then - DEPLOY_OUT=0 -fi +ARCHIVE_OUT=1 +DEPLOY_OUT=0 function print_help() { echo "Usage: build.sh [-s] [-A <arduino_branch>] [-I <idf_branch>] [-i <idf_commit>] [-c <path>] [-t <target>] [-b <build|menuconfig|reconfigure|idf-libs|copy-bootloader|mem-variant>] [config ...]" @@ -26,8 +24,6 @@ function print_help() { echo " -I Set which branch of ESP-IDF to be used for compilation" echo " -i Set which commit of ESP-IDF to be used for compilation" echo " -e Archive the build to dist" - echo " -d Deploy the build to github arduino-esp32" - echo " -c Set the arduino-esp32 folder to copy the result to. ex. '$HOME/Arduino/hardware/espressif/esp32'" echo " -t Set the build target(chip) ex. 'esp32s3' or select multiple targets(chips) by separating them with comma ex. 'esp32,esp32s3,esp32c3'" echo " -b Set the build type. ex. 'build' to build the project and prepare for uploading to a board" echo " ... Specify additional configs to be applied. ex. 'qio 80m' to compile for QIO Flash@80MHz. Requires -b" @@ -39,16 +35,9 @@ while getopts ":A:I:i:c:t:b:sde" opt; do s ) SKIP_ENV=1 ;; - d ) - DEPLOY_OUT=1 - ;; e ) ARCHIVE_OUT=1 ;; - c ) - export ESP32_ARDUINO="$OPTARG" - COPY_OUT=1 - ;; A ) export AR_BRANCH="$OPTARG" ;; @@ -268,13 +257,6 @@ done export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD) -# update package_esp32_index.template.json -#if [ "$BUILD_TYPE" = "all" ]; then -# python3 ./tools/gen_tools_json.py -i "$IDF_PATH" -j "$AR_COMPS/arduino/package/package_esp32_index.template.json" -o "$AR_OUT/" -# python3 ./tools/gen_tools_json.py -i "$IDF_PATH" -o "$TOOLS_JSON_OUT/" -# if [ $? -ne 0 ]; then exit 1; fi -#fi - # Generate PlatformIO library manifest file if [ "$BUILD_TYPE" = "all" ]; then python3 ./tools/gen_pio_lib_manifest.py -o "$TOOLS_JSON_OUT/" -s "v$IDF_VERSION" -c "$IDF_COMMIT" @@ -298,20 +280,8 @@ echo "#define ARDUINO_ESP32_GIT_VER 0x$AR_Commit_short #define ARDUINO_ESP32_RELEASE_$AR_VERSION_UNDERSCORE #define ARDUINO_ESP32_RELEASE \"$AR_VERSION_UNDERSCORE\"" >> "$AR_ROOT/core_version.h" -# copy everything to arduino-esp32 installation -if [ $COPY_OUT -eq 1 ] && [ -d "$ESP32_ARDUINO" ]; then - ./tools/copy-to-arduino.sh - if [ $? -ne 0 ]; then exit 1; fi -fi - -# push changes to esp32-arduino-libs and create pull request into arduino-esp32 -if [ $DEPLOY_OUT -eq 1 ]; then - ./tools/push-to-arduino.sh - if [ $? -ne 0 ]; then exit 1; fi -fi - # archive the build -if [ "$BUILD_TYPE" = "all" ]; then - ./tools/archive-build.sh +if [ $ARCHIVE_OUT -eq 1 ]; then + ./tools/archive-build.sh "$TARGET" if [ $? -ne 0 ]; then exit 1; fi fi From 0588e3c5f6fa86eeffcb0cad6d191183fffce286 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 21 Apr 2024 15:27:59 +0200 Subject: [PATCH 144/211] Update build.sh --- build.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/build.sh b/build.sh index e94d9e3c5..2b630d34b 100755 --- a/build.sh +++ b/build.sh @@ -52,11 +52,11 @@ while getopts ":A:I:i:c:t:b:sde" opt; do ;; b ) b=$OPTARG - if [ "$b" != "build" ] && - [ "$b" != "menuconfig" ] && - [ "$b" != "reconfigure" ] && - [ "$b" != "idf-libs" ] && - [ "$b" != "copy-bootloader" ] && + if [ "$b" != "build" ] && + [ "$b" != "menuconfig" ] && + [ "$b" != "reconfigure" ] && + [ "$b" != "idf-libs" ] && + [ "$b" != "copy-bootloader" ] && [ "$b" != "mem-variant" ]; then print_help fi @@ -119,7 +119,7 @@ if [ "$BUILD_TYPE" != "all" ]; then # Skip building for targets that are not in the $TARGET array continue fi - + configs="configs/defconfig.common;configs/defconfig.$target" for defconf in `echo "$target_json" | jq -c '.features[]' | tr -d '"'`; do configs="$configs;configs/defconfig.$defconf" @@ -173,7 +173,7 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do continue fi fi - + # Skip chips that should not be a part of the final libs # WARNING!!! this logic needs to be updated when cron builds are split into jobs if [ "$TARGET" = "all" ] && [ $target_skip -eq 1 ]; then From d76d1a1745fa49fab2b9953dc132bbbac434c4bb Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 21 Apr 2024 15:33:54 +0200 Subject: [PATCH 145/211] Delete tools/add_sdk_json.py --- tools/add_sdk_json.py | 121 ------------------------------------------ 1 file changed, 121 deletions(-) delete mode 100644 tools/add_sdk_json.py diff --git a/tools/add_sdk_json.py b/tools/add_sdk_json.py deleted file mode 100644 index d2deb4a87..000000000 --- a/tools/add_sdk_json.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/env python - -from __future__ import print_function - -__author__ = "Hristo Gochkov" -__version__ = "2023" - -import os -import shutil -import errno -import os.path -import json -import platform -import sys -import stat -import argparse - -if sys.version_info[0] == 3: - unicode = lambda s: str(s) - -def add_system(systems, host, url, filename, sha, size): - system = { - "host": host, - "url": url, - "archiveFileName": filename, - "checksum": "SHA-256:"+sha, - "size": str(size) - } - systems.append(system) - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - prog = 'add_sdk_json', - description = 'Update SDK in Arduino package index') - parser.add_argument('-j', '--pkg-json', dest='arduino_json', required=True, help='path to package json') - parser.add_argument('-n', '--name', dest='tool_name', required=True, help='name of the SDK package') - parser.add_argument('-v', '--version', dest='tool_version', required=True, help='version of the new SDK') - parser.add_argument('-u', '--url', dest='tool_url', required=True, help='url to the zip of the new SDK') - parser.add_argument('-f', '--filename', dest='tool_filename', required=True, help='filename of the zip of the new SDK') - parser.add_argument('-s', '--size', dest='tool_size', required=True, help='size of the zip of the new SDK') - parser.add_argument('-c', '--sha', dest='tool_sha', required=True, help='sha256 of the zip of the new SDK') - args = parser.parse_args() - - print('Destination : {0}.'.format(args.arduino_json)) - print('Tool Name : {0}.'.format(args.tool_name)) - print('Tool Version : {0}.'.format(args.tool_version)) - print('Tool URL : {0}.'.format(args.tool_url)) - print('Tool File Name: {0}.'.format(args.tool_filename)) - print('Tool Size : {0}.'.format(args.tool_size)) - print('Tool SHA256 : {0}.'.format(args.tool_sha)) - - arduino_json = args.arduino_json; - tool_name = args.tool_name; - tool_version = args.tool_version; - tool_url = args.tool_url; - tool_filename = args.tool_filename; - tool_size = args.tool_size; - tool_sha = args.tool_sha; - - # code start - farray = {"packages":[{"platforms":[{"toolsDependencies":[]}],"tools":[]}]} - if os.path.isfile(arduino_json) == True: - farray = json.load(open(arduino_json)) - - dep_found = False - dep_skip = False - for dep in farray['packages'][0]['platforms'][0]['toolsDependencies']: - if dep['name'] == tool_name: - if dep['version'] == tool_version: - print('Skipping {0}. Same version {1}'.format(tool_name, tool_version)) - dep_skip = True - break - print('Updating dependency version of {0} from {1} to {2}'.format(tool_name, dep['version'], tool_version)) - dep['version'] = tool_version - dep_found = True - break - - if dep_skip == False: - if dep_found == False: - print('Adding new dependency: {0} version {1}'.format(tool_name, tool_version)) - deps = { - "packager": "esp32", - "name": tool_name, - "version": tool_version - } - farray['packages'][0]['platforms'][0]['toolsDependencies'].append(deps) - - systems = [] - add_system(systems, "i686-mingw32", tool_url, tool_filename, tool_sha, tool_size) - add_system(systems, "x86_64-mingw32", tool_url, tool_filename, tool_sha, tool_size) - add_system(systems, "arm64-apple-darwin", tool_url, tool_filename, tool_sha, tool_size) - add_system(systems, "x86_64-apple-darwin", tool_url, tool_filename, tool_sha, tool_size) - add_system(systems, "x86_64-pc-linux-gnu", tool_url, tool_filename, tool_sha, tool_size) - add_system(systems, "i686-pc-linux-gnu", tool_url, tool_filename, tool_sha, tool_size) - add_system(systems, "aarch64-linux-gnu", tool_url, tool_filename, tool_sha, tool_size) - add_system(systems, "arm-linux-gnueabihf", tool_url, tool_filename, tool_sha, tool_size) - - tool_found = False - for t in farray['packages'][0]['tools']: - if t['name'] == tool_name: - t['version'] = tool_version - t['systems'] = systems - tool_found = True - print('Updating systems of {0} to version {1}'.format(tool_name, tool_version)) - break - - if tool_found == False: - print('Adding new tool: {0} version {1}'.format(tool_name, tool_version)) - tools = { - "name": tool_name, - "version": tool_version, - "systems": systems - } - farray['packages'][0]['tools'].append(tools) - - json_str = json.dumps(farray, indent=2) - with open(arduino_json, "w") as f: - f.write(json_str+"\n") - f.close() - # print(json_str) - print('{0} generated'.format(arduino_json)) From 37eb31b1277111608b88006f3b6531834a889421 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 21 Apr 2024 15:34:18 +0200 Subject: [PATCH 146/211] Delete tools/copy-to-arduino.sh --- tools/copy-to-arduino.sh | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100755 tools/copy-to-arduino.sh diff --git a/tools/copy-to-arduino.sh b/tools/copy-to-arduino.sh deleted file mode 100755 index 96092e068..000000000 --- a/tools/copy-to-arduino.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -source ./tools/config.sh - -if [ -z $ESP32_ARDUINO ]; then - if [[ "$AR_OS" == "macos" ]]; then - ESP32_ARDUINO="$HOME/Documents/Arduino/hardware/espressif/esp32" - else - ESP32_ARDUINO="$HOME/Arduino/hardware/espressif/esp32" - fi -fi - -if ! [ -d "$ESP32_ARDUINO" ]; then - echo "ERROR: Target arduino folder does not exist!" - exit 1 -fi - -echo "Installing new libraries to $ESP32_ARDUINO" - -rm -rf $ESP32_ARDUINO/package/package_esp32_index.template.json && \ -cp -f $AR_OUT/package_esp32_index.template.json $ESP32_ARDUINO/package/package_esp32_index.template.json - -rm -rf $ESP32_ARDUINO/tools/esp32-arduino-libs && \ -cp -Rf $AR_TOOLS/esp32-arduino-libs $ESP32_ARDUINO/tools/ From c04b782055c203eb6ab867d8325d86b000c1bdfa Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 23 Apr 2024 15:36:25 +0200 Subject: [PATCH 147/211] rm components --- tools/install-esp-idf.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index 57150e7c7..febb6f94d 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -69,11 +69,24 @@ if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then patch -p1 -N -i ../patches/esp32s2_i2c_ll_master_init.diff cd - - # Get the exact IDF version from file "version.txt" + # remove code and component(s) not needed/wanted for Tasmota framework solo1 + cd $IDF_PATH + rm -rf components/usb + rm -rf components/esp-gdbstub + rm -rf components/openthread + rm -rf components/espcoredump + rm -rf components/esp_lcd + rm -rf components/touch_element + rm -rf components/perfmon + rm -rf components/riscv + rm -rf components/app_trace + cd - + + # Get the exact IDF version from file "version.txt" cd $IDF_PATH export IDF_VERSION=$(<version.txt) echo "IDF version: $IDF_VERSION" - cd - + cd - fi # From e6eaf028052c38a13870473e64e0ffcf31e32338 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 2 May 2024 15:56:17 +0200 Subject: [PATCH 148/211] CONFIG_LWIP_DHCP_RESTORE_LAST_IP=n --- configs/defconfig.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index 4a2be049d..0aaf81cb3 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -89,7 +89,7 @@ CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0=y CONFIG_LWIP_IPV6_AUTOCONFIG=y CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS=2 CONFIG_LWIP_MAX_SOCKETS=16 -CONFIG_LWIP_DHCP_RESTORE_LAST_IP=y +CONFIG_LWIP_DHCP_RESTORE_LAST_IP=n CONFIG_LWIP_DHCP_OPTIONS_LEN=128 CONFIG_LWIP_SNTP_MAX_SERVERS=1 # CONFIG_LWIP_DHCP_GET_NTP_SRV is not set From 762df3736adb15e671dee5bb2f29fe8484293bfd Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 3 May 2024 18:50:06 +0200 Subject: [PATCH 149/211] Update Arduino_CMakeLists.diff --- patches/Arduino_CMakeLists.diff | 36 ++++----------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/patches/Arduino_CMakeLists.diff b/patches/Arduino_CMakeLists.diff index 999153c09..b5929e5b5 100644 --- a/patches/Arduino_CMakeLists.diff +++ b/patches/Arduino_CMakeLists.diff @@ -1,15 +1,8 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index d3972bf06a..88c9910f76 100644 +index d3972bf06a..3813da3468 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -88,14 +88,12 @@ set(ARDUINO_ALL_LIBRARIES - LittleFS - NetBIOS - Network -- PPP - Preferences - SD_MMC - SD +@@ -95,7 +95,6 @@ set(ARDUINO_ALL_LIBRARIES SPI Ticker Update @@ -17,18 +10,7 @@ index d3972bf06a..88c9910f76 100644 WebServer WiFi Wire -@@ -128,10 +126,6 @@ set(ARDUINO_LIBRARY_LittleFS_SRCS libraries/LittleFS/src/LittleFS.cpp) - - set(ARDUINO_LIBRARY_NetBIOS_SRCS libraries/NetBIOS/src/NetBIOS.cpp) - --set(ARDUINO_LIBRARY_PPP_SRCS -- libraries/PPP/src/PPP.cpp -- libraries/PPP/src/ppp.c) -- - set(ARDUINO_LIBRARY_Preferences_SRCS libraries/Preferences/src/Preferences.cpp) - - set(ARDUINO_LIBRARY_SD_MMC_SRCS libraries/SD_MMC/src/SD_MMC.cpp) -@@ -149,17 +143,6 @@ set(ARDUINO_LIBRARY_Update_SRCS +@@ -149,17 +148,6 @@ set(ARDUINO_LIBRARY_Update_SRCS libraries/Update/src/Updater.cpp libraries/Update/src/HttpsOTAUpdate.cpp) @@ -46,7 +28,7 @@ index d3972bf06a..88c9910f76 100644 set(ARDUINO_LIBRARY_WebServer_SRCS libraries/WebServer/src/WebServer.cpp libraries/WebServer/src/Parsing.cpp -@@ -247,9 +230,6 @@ function(maybe_add_component component_name) +@@ -247,9 +235,6 @@ function(maybe_add_component component_name) endif() endfunction() @@ -56,13 +38,3 @@ index d3972bf06a..88c9910f76 100644 if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_ArduinoOTA) maybe_add_component(esp_https_ota) endif() -diff --git a/idf_component.yml b/idf_component.yml -index ae548c41d4..7a4e094050 100644 ---- a/idf_component.yml -+++ b/idf_component.yml -@@ -45,5 +45,4 @@ dependencies: - idf: ">=5.1" - # mdns 1.2.3 is necessary to build H2 with no WiFi - mdns: "^1.2.3" -- espressif/esp_modem: "^1.1.0" - joltwallet/littlefs: "^1.14.1" From fbc849b45e2df5efa4ae8251b14d2833be7ec0a2 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 3 May 2024 18:56:25 +0200 Subject: [PATCH 150/211] Update archive-build.sh --- tools/archive-build.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index d5cc6e9cb..337495962 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -36,7 +36,6 @@ rm -rf arduino-esp32/libraries/WiFiProv rm -rf arduino-esp32/libraries/WiFiClientSecure rm -rf arduino-esp32/libraries/NetworkClientSecure rm -rf arduino-esp32/libraries/USB -rm -rf arduino-esp32/libraries/PPP rm -rf arduino-esp32/libraries/ESP_SR rm -rf arduino-esp32/libraries/ESP_NOW rm -rf arduino-esp32/libraries/TFLiteMicro From 22278df2a6787f20f5da7e0688c0e79dedfa71f9 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 3 May 2024 18:57:14 +0200 Subject: [PATCH 151/211] activate PPP --- tools/install-arduino.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index 31ba9a83e..ce47198a3 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -90,7 +90,6 @@ rm -rf "$AR_COMPS/arduino/libraries/WiFiProv" rm -rf "$AR_COMPS/arduino/libraries/WiFiClientSecure" rm -rf "$AR_COMPS/arduino/libraries/NetworkClientSecure" rm -rf "$AR_COMPS/arduino/libraries/USB" -rm -rf "$AR_COMPS/arduino/libraries/PPP" rm -rf "$AR_COMPS/arduino/libraries/ESP32" rm -rf "$AR_COMPS/arduino/libraries/ESP_SR" rm -rf "$AR_COMPS/arduino/libraries/ESP_NOW" From 1cb53c8ae0760a2f85f8cd6efcc104a757440894 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 3 May 2024 19:00:14 +0200 Subject: [PATCH 152/211] CONFIG_HEAP_POISONING_DISABLED --- configs/defconfig.common | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index 0aaf81cb3..cfc942a5a 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -23,7 +23,7 @@ CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y CONFIG_COMPILER_SAVE_RESTORE_LIBCALLS=y # CONFIG_ESP_HTTPS_SERVER_ENABLE is not set # CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS is not set -CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y +# CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH is not set CONFIG_ESP_SYSTEM_ESP32_SRAM1_REGION_AS_IRAM=y CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH=y CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 @@ -65,10 +65,10 @@ CONFIG_FREERTOS_HZ=1000 # CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT is not set CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=2304 # CONFIG_FREERTOS_FPU_IN_ISR is not set -CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y -CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y +# CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set +# CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH is not set CONFIG_HAL_ASSERTION_DISABLE=y -CONFIG_HEAP_POISONING_LIGHT=y +CONFIG_HEAP_POISONING_DISABLED=y CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024 CONFIG_HTTPD_WS_SUPPORT=y CONFIG_LOG_DEFAULT_LEVEL_NONE=y @@ -97,6 +97,7 @@ CONFIG_LWIP_SNTP_UPDATE_DELAY=10800000 CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=48 CONFIG_LWIP_TCP_RECVMBOX_SIZE=16 CONFIG_LWIP_UDP_RECVMBOX_SIZE=64 +# CONFIG_IEEE802154_ENABLED is not set CONFIG_NEWLIB_NANO_FORMAT=y # CONFIG_DAC_DMA_AUTO_16BIT_ALIGN is not set @@ -203,8 +204,6 @@ CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=4096 # CONFIG_VFS_SUPPORT_TERMIOS is not set # CONFIG_SPI_MASTER_ISR_IN_IRAM is not set # CONFIG_SPI_SLAVE_ISR_IN_IRAM is not set -CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096 -CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=0 CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=1 CONFIG_DSP_MAX_FFT_SIZE_1024=y @@ -212,16 +211,3 @@ CONFIG_DSP_MAX_FFT_SIZE_1024=y CONFIG_LITTLEFS_MAX_PARTITIONS=2 CONFIG_LITTLEFS_MULTIVERSION=y CONFIG_LITTLEFS_DISK_VERSION_2_0=y - -# -# Disable Cameras not used -# -# CONFIG_OV7670_SUPPORT is not set -# CONFIG_OV7725_SUPPORT is not set -# CONFIG_NT99141_SUPPORT is not set -# CONFIG_GC2145_SUPPORT is not set -# CONFIG_GC032A_SUPPORT is not set -# CONFIG_GC0308_SUPPORT is not set -# CONFIG_BF3005_SUPPORT is not set -# CONFIG_BF20A6_SUPPORT is not set -# CONFIG_SC030IOT_SUPPORT is not set From a706d25eb80e77896668a141a9bdd95fca06f6ab Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 3 May 2024 19:01:49 +0200 Subject: [PATCH 153/211] add PPP support --- configs/defconfig.esp32 | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/configs/defconfig.esp32 b/configs/defconfig.esp32 index f8068a560..a836a2804 100644 --- a/configs/defconfig.esp32 +++ b/configs/defconfig.esp32 @@ -29,7 +29,6 @@ CONFIG_ETH_PHY_INTERFACE_RMII=y CONFIG_ETH_USE_SPI_ETHERNET=y # CONFIG_SPIRAM is not set -# CONFIG_SPIRAM_OCCUPY_HSPI_HOST is not set CONFIG_ULP_COPROC_ENABLED=y # CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1 is not set # CONFIG_UNITY_ENABLE_FLOAT is not set @@ -40,8 +39,20 @@ CONFIG_ULP_COPROC_ENABLED=y # CONFIG_VFS_SUPPORT_SELECT is not set # CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT is not set # CONFIG_VFS_SUPPORT_TERMIOS is not set -CONFIG_TWAI_ERRATA_FIX_BUS_OFF_REC=y -CONFIG_TWAI_ERRATA_FIX_TX_INTR_LOST=y -CONFIG_TWAI_ERRATA_FIX_RX_FRAME_INVALID=y -CONFIG_TWAI_ERRATA_FIX_RX_FIFO_CORRUPT=y + CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y + +# We dont use TWAI so disable the fixes which adds dead code +# CONFIG_TWAI_ERRATA_FIX_BUS_OFF_REC is not set +# CONFIG_TWAI_ERRATA_FIX_TX_INTR_LOST is not set +# CONFIG_TWAI_ERRATA_FIX_RX_FRAME_INVALID is not set +# CONFIG_TWAI_ERRATA_FIX_RX_FIFO_CORRUPT is not set +# CONFIG_TWAI_ERRATA_FIX_LISTEN_ONLY_DOM is not set + +# +# PPP +# +CONFIG_LWIP_PPP_SUPPORT=y +CONFIG_LWIP_PPP_NOTIFY_PHASE_SUPPORT=y +CONFIG_LWIP_PPP_PAP_SUPPORT=y +CONFIG_LWIP_PPP_ENABLE_IPV6=n From d396ac5c2506d7d30dbd4de3ead2adb2ac676d78 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 3 May 2024 19:03:52 +0200 Subject: [PATCH 154/211] rm components --- tools/install-esp-idf.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index febb6f94d..e1f0585f4 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -80,6 +80,8 @@ if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then rm -rf components/perfmon rm -rf components/riscv rm -rf components/app_trace + rm -rf components/ieee802154 + rm -rf components/driver/test_apps cd - # Get the exact IDF version from file "version.txt" From 48e76af0f2836a349c2762f779f287a0e710580e Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 10 May 2024 14:35:13 +0200 Subject: [PATCH 155/211] Update defconfig.common --- configs/defconfig.common | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index cfc942a5a..27b425e84 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -16,6 +16,7 @@ CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y +CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y # CONFIG_COMPILER_WARN_WRITE_STRINGS is not set # CONFIG_ESP_ERR_TO_NAME_LOOKUP is not set @@ -23,9 +24,9 @@ CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y CONFIG_COMPILER_SAVE_RESTORE_LIBCALLS=y # CONFIG_ESP_HTTPS_SERVER_ENABLE is not set # CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS is not set +# CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set # CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH is not set CONFIG_ESP_SYSTEM_ESP32_SRAM1_REGION_AS_IRAM=y -CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH=y CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096 @@ -97,7 +98,6 @@ CONFIG_LWIP_SNTP_UPDATE_DELAY=10800000 CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=48 CONFIG_LWIP_TCP_RECVMBOX_SIZE=16 CONFIG_LWIP_UDP_RECVMBOX_SIZE=64 -# CONFIG_IEEE802154_ENABLED is not set CONFIG_NEWLIB_NANO_FORMAT=y # CONFIG_DAC_DMA_AUTO_16BIT_ALIGN is not set @@ -190,6 +190,7 @@ CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y CONFIG_OPENSSL_ASSERT_DO_NOTHING=y CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=2048 CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED=y +# CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE is not set CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=10 CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=2 From bfae75960932eec0161d0f6e9de40a045962a7c2 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 11 May 2024 21:43:26 +0200 Subject: [PATCH 156/211] # CONFIG_MBEDTLS_ERROR_STRINGS is not set --- configs/defconfig.common | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/defconfig.common b/configs/defconfig.common index 27b425e84..17e6f96aa 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -108,6 +108,7 @@ CONFIG_MBEDTLS_TLS_DISABLED=y CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=10 # CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE is not set # CONFIG_MBEDTLS_PKCS7_C is not set +# CONFIG_MBEDTLS_ERROR_STRINGS is not set # # Symmetric Ciphers From 6db3028cb5dfb56952724f58549002ef66d8b0cc Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 15 May 2024 14:40:32 +0200 Subject: [PATCH 157/211] Update install-esp-idf.sh --- tools/install-esp-idf.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index e1f0585f4..5b53d7e24 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -71,7 +71,6 @@ if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then # remove code and component(s) not needed/wanted for Tasmota framework solo1 cd $IDF_PATH - rm -rf components/usb rm -rf components/esp-gdbstub rm -rf components/openthread rm -rf components/espcoredump From 9fbb72a8c52f89a7673f919e5768229d53997be5 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 15 May 2024 20:37:25 +0200 Subject: [PATCH 158/211] AR_BRANCH="main_new" --- tools/config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/config.sh b/tools/config.sh index a5cdfe840..4d96ea40b 100755 --- a/tools/config.sh +++ b/tools/config.sh @@ -11,7 +11,7 @@ fi # Arduino branch to use if [ -z $AR_BRANCH ]; then - AR_BRANCH="main" + AR_BRANCH="main_new" fi if [ -z $IDF_TARGET ]; then From 1e727b179b3265fc0f7806cfa1b4c77121ab4014 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 15 May 2024 21:10:28 +0200 Subject: [PATCH 159/211] AR_BRANCH="main" --- tools/config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/config.sh b/tools/config.sh index 4d96ea40b..a5cdfe840 100755 --- a/tools/config.sh +++ b/tools/config.sh @@ -11,7 +11,7 @@ fi # Arduino branch to use if [ -z $AR_BRANCH ]; then - AR_BRANCH="main_new" + AR_BRANCH="main" fi if [ -z $IDF_TARGET ]; then From 1f77d42afdc1dced09afbc4aba9ecfbfa612e896 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 16 May 2024 18:41:46 +0200 Subject: [PATCH 160/211] Update Arduino_CMakeLists.diff --- patches/Arduino_CMakeLists.diff | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/patches/Arduino_CMakeLists.diff b/patches/Arduino_CMakeLists.diff index b5929e5b5..cb9790a98 100644 --- a/patches/Arduino_CMakeLists.diff +++ b/patches/Arduino_CMakeLists.diff @@ -1,5 +1,5 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index d3972bf06a..3813da3468 100644 +index 9bccd54051..3475a75dd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,7 +95,6 @@ set(ARDUINO_ALL_LIBRARIES @@ -28,6 +28,15 @@ index d3972bf06a..3813da3468 100644 set(ARDUINO_LIBRARY_WebServer_SRCS libraries/WebServer/src/WebServer.cpp libraries/WebServer/src/Parsing.cpp +@@ -206,7 +194,7 @@ set(includedirs variants/${CONFIG_ARDUINO_VARIANT}/ cores/esp32/ ${ARDUINO_LIBRA + set(srcs ${CORE_SRCS} ${ARDUINO_LIBRARIES_SRCS}) + set(priv_includes cores/esp32/libb64) + 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 usb ${ARDUINO_LIBRARIES_REQUIRES}) ++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}) + @@ -247,9 +235,6 @@ function(maybe_add_component component_name) endif() endfunction() From 7550ba1b73b51f79a7ad66f3f06132ee622aa78b Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 16 May 2024 18:44:01 +0200 Subject: [PATCH 161/211] Update install-esp-idf.sh --- tools/install-esp-idf.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index 5b53d7e24..e4a8ff4ad 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -71,7 +71,8 @@ if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then # remove code and component(s) not needed/wanted for Tasmota framework solo1 cd $IDF_PATH - rm -rf components/esp-gdbstub + rm -rf components/usb + rm -rf components/esp-gdbstub rm -rf components/openthread rm -rf components/espcoredump rm -rf components/esp_lcd From 86a5c4a04f96cc73ddd738b8fa975bafd48eb17c Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 16 May 2024 18:55:49 +0200 Subject: [PATCH 162/211] Delete patches/esp32s2_i2c_ll_master_init.diff --- patches/esp32s2_i2c_ll_master_init.diff | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 patches/esp32s2_i2c_ll_master_init.diff diff --git a/patches/esp32s2_i2c_ll_master_init.diff b/patches/esp32s2_i2c_ll_master_init.diff deleted file mode 100644 index 2a129c695..000000000 --- a/patches/esp32s2_i2c_ll_master_init.diff +++ /dev/null @@ -1,17 +0,0 @@ -diff --git a/components/hal/esp32s2/include/hal/i2c_ll.h b/components/hal/esp32s2/include/hal/i2c_ll.h -index f9a66b61d6..2f669b68c0 100644 ---- a/components/hal/esp32s2/include/hal/i2c_ll.h -+++ b/components/hal/esp32s2/include/hal/i2c_ll.h -@@ -653,10 +653,12 @@ static inline void i2c_ll_enable_controller_clock(i2c_dev_t *hw, bool en) - static inline void i2c_ll_master_init(i2c_dev_t *hw) - { - typeof(hw->ctr) ctrl_reg; -+ uint32_t ref_always_on = hw->ctr.ref_always_on; - ctrl_reg.val = 0; - ctrl_reg.ms_mode = 1; - ctrl_reg.sda_force_out = 1; - ctrl_reg.scl_force_out = 1; -+ ctrl_reg.ref_always_on = ref_always_on; - hw->ctr.val = ctrl_reg.val; - } - From 3e0f7de6dad27986655407bb74306fd0ddb825e3 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 16 May 2024 18:56:28 +0200 Subject: [PATCH 163/211] Update install-esp-idf.sh --- tools/install-esp-idf.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index e4a8ff4ad..bbd2b55b8 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -64,11 +64,6 @@ if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then git submodule update --recursive $IDF_PATH/install.sh - # Temporarily patch the ESP32-S2 I2C LL driver to keep the clock source - cd $IDF_PATH - patch -p1 -N -i ../patches/esp32s2_i2c_ll_master_init.diff - cd - - # remove code and component(s) not needed/wanted for Tasmota framework solo1 cd $IDF_PATH rm -rf components/usb From aa3c03bdb4d127ac0cbc5a778833addd5de65486 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 29 May 2024 23:26:32 +0200 Subject: [PATCH 164/211] sort --- main/Kconfig.projbuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index 248e93d94..d5c62deaf 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -10,8 +10,8 @@ config LIB_BUILDER_FLASHFREQ string default "120m" if ESPTOOLPY_FLASHFREQ_120M default "80m" if ESPTOOLPY_FLASHFREQ_80M - default "60m" if ESPTOOLPY_FLASHFREQ_60M default "64m" if ESPTOOLPY_FLASHFREQ_64M + default "60m" if ESPTOOLPY_FLASHFREQ_60M default "40m" if ESPTOOLPY_FLASHFREQ_40M default "32m" if ESPTOOLPY_FLASHFREQ_32M default "30m" if ESPTOOLPY_FLASHFREQ_30M From 1daa36b783f558060575bbc9b2c9d7d02f6309a1 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 1 Jun 2024 21:46:48 +0200 Subject: [PATCH 165/211] strip libs --- tools/copy-libs.sh | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/tools/copy-libs.sh b/tools/copy-libs.sh index 2de6dbbbd..0bf3511c5 100755 --- a/tools/copy-libs.sh +++ b/tools/copy-libs.sh @@ -71,6 +71,13 @@ PIO_LD_FLAGS="" PIO_LD_FUNCS="" PIO_LD_SCRIPTS="" +TOOLCHAIN_PREFIX="" +if [ "$IS_XTENSA" = "y" ]; then + TOOLCHAIN="xtensa-$IDF_TARGET-elf" +else + TOOLCHAIN="riscv32-esp-elf" +fi + #collect includes, defines and c-flags str=`cat build/compile_commands.json | grep arduino-lib-builder-gcc.c | grep command | cut -d':' -f2 | cut -d',' -f1` str="${str:2:${#str}-1}" #remove leading space and quotes @@ -402,13 +409,13 @@ for item; do mkdir -p "$out_cpath$rel_p" cp -n $f "$out_cpath$rel_p/" done - for f in `find "$item" -name '*.inc'`; do + for f in `find "$item" -name '*.inc'`; do rel_f=${f#*$item} rel_p=${rel_f%/*} mkdir -p "$out_cpath$rel_p" cp -n $f "$out_cpath$rel_p/" done - # Temporary measure to fix issues caused by https://github.com/espressif/esp-idf/commit/dc4731101dd567cc74bbe4d0f03afe52b7db9afb#diff-1d2ce0d3989a80830fdf230bcaafb3117f32046d16cf46616ac3d55b4df2a988R17 + # Temporary measure to fix issues caused by https://github.com/espressif/esp-idf/commit/dc4731101dd567cc74bbe4d0f03afe52b7db9afb#diff-1d2ce0d3989a80830fdf230bcaafb3117f32046d16cf46616ac3d55b4df2a988R17 if [[ "$fname" == "bt" && "$out_sub" == "/include/$IDF_TARGET/include" && -f "$ipath/controller/$IDF_TARGET/esp_bt_cfg.h" ]]; then mkdir -p "$AR_SDK/include/$fname/controller/$IDF_TARGET" cp -n "$ipath/controller/$IDF_TARGET/esp_bt_cfg.h" "$AR_SDK/include/$fname/controller/$IDF_TARGET/esp_bt_cfg.h" @@ -434,6 +441,8 @@ done set -- $LD_LIB_FILES for item; do + #echo "***** Stripping $item" + "$TOOLCHAIN-strip" -g "$item" cp "$item" "$AR_SDK/lib/" done @@ -484,6 +493,15 @@ echo -n "$LD_FLAGS" > "$FLAGS_DIR/ld_flags" echo -n "$LD_SCRIPTS" > "$FLAGS_DIR/ld_scripts" echo -n "$AR_LIBS" > "$FLAGS_DIR/ld_libs" +# copy zigbee + zboss lib +if [ -d "managed_components/espressif__esp-zigbee-lib/lib/$IDF_TARGET/" ]; then + cp -r "managed_components/espressif__esp-zigbee-lib/lib/$IDF_TARGET"/* "$AR_SDK/lib/" +fi + +if [ -d "managed_components/espressif__esp-zboss-lib/lib/$IDF_TARGET/" ]; then + cp -r "managed_components/espressif__esp-zboss-lib/lib/$IDF_TARGET"/* "$AR_SDK/lib/" +fi + # sdkconfig cp -f "sdkconfig" "$AR_SDK/sdkconfig" @@ -498,6 +516,7 @@ function copy_precompiled_lib(){ lib_file="$1" lib_name="$(basename $lib_file)" if [[ $LD_LIBS_SEARCH == *"$lib_name"* ]]; then + "$TOOLCHAIN-strip" -g "$lib_file" cp "$lib_file" "$AR_SDK/ld/" fi } @@ -514,6 +533,13 @@ for item; do done done +for lib in "openthread" "espressif__esp-tflite-micro" "bt" "espressif__esp_modem" "espressif__esp-zboss-lib" "espressif__esp-zigbee-lib" "espressif__mdns" "espressif__esp-dsp" "joltwallet__littlefs"; do + if [ -f "$AR_SDK/lib/lib$lib.a" ]; then + echo "Stripping $AR_SDK/lib/lib$lib.a" + "$TOOLCHAIN-strip" -g "$AR_SDK/lib/lib$lib.a" + fi +done + # Handle Mem Variants mkdir -p "$AR_SDK/$MEMCONF/include" mv "$PWD/build/config/sdkconfig.h" "$AR_SDK/$MEMCONF/include/sdkconfig.h" @@ -529,6 +555,7 @@ for mem_variant in `jq -c '.mem_variants_files[]' configs/builds.json`; do file=$(echo "$mem_variant" | jq -c '.file' | tr -d '"') out=$(echo "$mem_variant" | jq -c '.out' | tr -d '"') mv "$AR_SDK/$out" "$AR_SDK/$MEMCONF/$file" + "$TOOLCHAIN-strip" -g "$AR_SDK/$MEMCONF/$file" fi done; From 0d4b91819f43d834a4b03bb1e1289930359d2aec Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 3 Jun 2024 14:11:41 +0200 Subject: [PATCH 166/211] Update Arduino_CMakeLists.diff --- patches/Arduino_CMakeLists.diff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/Arduino_CMakeLists.diff b/patches/Arduino_CMakeLists.diff index cb9790a98..9acd2e226 100644 --- a/patches/Arduino_CMakeLists.diff +++ b/patches/Arduino_CMakeLists.diff @@ -31,7 +31,7 @@ index 9bccd54051..3475a75dd3 100644 @@ -206,7 +194,7 @@ set(includedirs variants/${CONFIG_ARDUINO_VARIANT}/ cores/esp32/ ${ARDUINO_LIBRA set(srcs ${CORE_SRCS} ${ARDUINO_LIBRARIES_SRCS}) set(priv_includes cores/esp32/libb64) - set(requires spi_flash esp_partition mbedtls wpa_supplicant esp_adc esp_eth http_parser) + set(requires spi_flash esp_partition mbedtls wpa_supplicant esp_adc esp_eth http_parser esp_psram) -set(priv_requires fatfs nvs_flash app_update bootloader_support bt esp_hid usb ${ARDUINO_LIBRARIES_REQUIRES}) +set(priv_requires fatfs nvs_flash app_update bootloader_support bt esp_hid ${ARDUINO_LIBRARIES_REQUIRES}) From 7be90d03ddb8a9f34eae98f7a18a213fd8b4bfe4 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 3 Jun 2024 18:07:39 +0200 Subject: [PATCH 167/211] Update Arduino_CMakeLists.diff --- patches/Arduino_CMakeLists.diff | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/Arduino_CMakeLists.diff b/patches/Arduino_CMakeLists.diff index 9acd2e226..b5e688cd4 100644 --- a/patches/Arduino_CMakeLists.diff +++ b/patches/Arduino_CMakeLists.diff @@ -31,9 +31,9 @@ index 9bccd54051..3475a75dd3 100644 @@ -206,7 +194,7 @@ set(includedirs variants/${CONFIG_ARDUINO_VARIANT}/ cores/esp32/ ${ARDUINO_LIBRA set(srcs ${CORE_SRCS} ${ARDUINO_LIBRARIES_SRCS}) set(priv_includes cores/esp32/libb64) - set(requires spi_flash esp_partition mbedtls wpa_supplicant esp_adc esp_eth http_parser esp_psram) --set(priv_requires fatfs nvs_flash app_update bootloader_support bt esp_hid usb ${ARDUINO_LIBRARIES_REQUIRES}) -+set(priv_requires fatfs nvs_flash app_update 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 usb esp_psram ${ARDUINO_LIBRARIES_REQUIRES}) ++set(priv_requires fatfs nvs_flash app_update bootloader_support bt esp_hid esp_psram ${ARDUINO_LIBRARIES_REQUIRES}) idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires}) From cbb63f38269b030c76d844069ec5fbfd1739ec42 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 3 Jun 2024 18:29:29 +0200 Subject: [PATCH 168/211] Update install-esp-idf.sh --- tools/install-esp-idf.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index bbd2b55b8..43ff8d6dc 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -66,7 +66,6 @@ if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then # remove code and component(s) not needed/wanted for Tasmota framework solo1 cd $IDF_PATH - rm -rf components/usb rm -rf components/esp-gdbstub rm -rf components/openthread rm -rf components/espcoredump From 83a60161359d6626c395fa99fe2aca9f4571c108 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 3 Jun 2024 18:33:43 +0200 Subject: [PATCH 169/211] Update install-arduino.sh --- tools/install-arduino.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index ce47198a3..9991750eb 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -89,13 +89,7 @@ rm -rf "$AR_COMPS/arduino/libraries/BluetoothSerial" rm -rf "$AR_COMPS/arduino/libraries/WiFiProv" rm -rf "$AR_COMPS/arduino/libraries/WiFiClientSecure" rm -rf "$AR_COMPS/arduino/libraries/NetworkClientSecure" -rm -rf "$AR_COMPS/arduino/libraries/USB" rm -rf "$AR_COMPS/arduino/libraries/ESP32" rm -rf "$AR_COMPS/arduino/libraries/ESP_SR" rm -rf "$AR_COMPS/arduino/libraries/ESP_NOW" rm -rf "$AR_COMPS/arduino/libraries/TFLiteMicro" - -# Patch to remove USB from Arduino CMakeLists.txt -cd "$AR_COMPS/arduino" -patch -p1 -N -i ../../patches/Arduino_CMakeLists.diff -cd - From 8b16e27e8d5499f7a99a48b24c64aea68462c40f Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 3 Jun 2024 18:34:03 +0200 Subject: [PATCH 170/211] Delete patches/Arduino_CMakeLists.diff --- patches/Arduino_CMakeLists.diff | 49 --------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 patches/Arduino_CMakeLists.diff diff --git a/patches/Arduino_CMakeLists.diff b/patches/Arduino_CMakeLists.diff deleted file mode 100644 index b5e688cd4..000000000 --- a/patches/Arduino_CMakeLists.diff +++ /dev/null @@ -1,49 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 9bccd54051..3475a75dd3 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -95,7 +95,6 @@ set(ARDUINO_ALL_LIBRARIES - SPI - Ticker - Update -- USB - WebServer - WiFi - Wire -@@ -149,17 +148,6 @@ set(ARDUINO_LIBRARY_Update_SRCS - libraries/Update/src/Updater.cpp - libraries/Update/src/HttpsOTAUpdate.cpp) - --set(ARDUINO_LIBRARY_USB_SRCS -- libraries/USB/src/USBHID.cpp -- libraries/USB/src/USBMIDI.cpp -- libraries/USB/src/USBHIDMouse.cpp -- libraries/USB/src/USBHIDKeyboard.cpp -- libraries/USB/src/USBHIDGamepad.cpp -- libraries/USB/src/USBHIDConsumerControl.cpp -- libraries/USB/src/USBHIDSystemControl.cpp -- libraries/USB/src/USBHIDVendor.cpp -- libraries/USB/src/USBVendor.cpp) -- - set(ARDUINO_LIBRARY_WebServer_SRCS - libraries/WebServer/src/WebServer.cpp - libraries/WebServer/src/Parsing.cpp -@@ -206,7 +194,7 @@ set(includedirs variants/${CONFIG_ARDUINO_VARIANT}/ cores/esp32/ ${ARDUINO_LIBRA - set(srcs ${CORE_SRCS} ${ARDUINO_LIBRARIES_SRCS}) - set(priv_includes cores/esp32/libb64) - 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 usb esp_psram ${ARDUINO_LIBRARIES_REQUIRES}) -+set(priv_requires fatfs nvs_flash app_update bootloader_support bt esp_hid esp_psram ${ARDUINO_LIBRARIES_REQUIRES}) - - idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires}) - -@@ -247,9 +235,6 @@ function(maybe_add_component component_name) - endif() - endfunction() - --if(IDF_TARGET MATCHES "esp32s2|esp32s3" AND CONFIG_TINYUSB_ENABLED) -- maybe_add_component(arduino_tinyusb) --endif() - if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_ArduinoOTA) - maybe_add_component(esp_https_ota) - endif() From e9684a5eb2a9af95fec76d9e4fc016deca4e6533 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 10 Jun 2024 23:18:54 +0200 Subject: [PATCH 171/211] Update idf_component.yml --- main/idf_component.yml | 51 +++++------------------------------------- 1 file changed, 6 insertions(+), 45 deletions(-) diff --git a/main/idf_component.yml b/main/idf_component.yml index b119e44da..3f1b3fabd 100644 --- a/main/idf_component.yml +++ b/main/idf_component.yml @@ -1,48 +1,9 @@ dependencies: # Required IDF version idf: ">=5.1" - - # espressif/esp32-camera: - # version: "master" - # git: https://github.com/espressif/esp32-camera.git - # require: public - # esp-sr: "^1.3.1" - # esp32-camera: "^2.0.4" - # esp-dl: - # git: https://github.com/espressif/esp-dl.git - # espressif/esp_rainmaker: - # path: components/esp_rainmaker - # git: https://github.com/espressif/esp-rainmaker.git - - # # Defining a dependency from the registry: - # # https://components.espressif.com/component/example/cmp - # example/cmp: "^3.3.3" # Automatically update minor releases - # - # # Other ways to define dependencies - # - # # For components maintained by Espressif only name can be used. - # # Same as `espressif/cmp` - # component: "~1.0.0" # Automatically update bugfix releases - # - # # Or in a longer form with extra parameters - # component2: - # version: ">=2.0.0" - # - # # For transient dependencies `public` flag can be set. - # # `public` flag doesn't have an effect for the `main` component. - # # All dependencies of `main` are public by default. - # public: true - # - # # For components hosted on non-default registry: - # service_url: "https://componentregistry.company.com" - # - # # For components in git repository: - # test_component: - # path: test_component - # git: ssh://git@gitlab.com/user/components.git - # - # # For test projects during component development - # # components can be used from a local directory - # # with relative or absolute path - # some_local_component: - # path: ../../projects/component + espressif/esp32-camera: + version: "master" + git: https://github.com/espressif/esp32-camera.git + require: public + rules: + - if: "target in [esp32, esp32s2, esp32s3]" From 848cef354a19da813c186cb60720dddbaf0dce1a Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 10 Jun 2024 23:25:40 +0200 Subject: [PATCH 172/211] Update copy-libs.sh --- tools/copy-libs.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/copy-libs.sh b/tools/copy-libs.sh index 0bf3511c5..88c1b5400 100755 --- a/tools/copy-libs.sh +++ b/tools/copy-libs.sh @@ -502,6 +502,10 @@ if [ -d "managed_components/espressif__esp-zboss-lib/lib/$IDF_TARGET/" ]; then cp -r "managed_components/espressif__esp-zboss-lib/lib/$IDF_TARGET"/* "$AR_SDK/lib/" fi +if [ -d "managed_components/espressif__esp32-camera/driver/private_include/" ]; then + cp -r "managed_components/espressif__esp32-camera/driver/private_include/cam_hal.h" "$AR_SDK/include/espressif__esp32-camera/driver/include/" +fi + # sdkconfig cp -f "sdkconfig" "$AR_SDK/sdkconfig" @@ -533,7 +537,7 @@ for item; do done done -for lib in "openthread" "espressif__esp-tflite-micro" "bt" "espressif__esp_modem" "espressif__esp-zboss-lib" "espressif__esp-zigbee-lib" "espressif__mdns" "espressif__esp-dsp" "joltwallet__littlefs"; do +for lib in "openthread" "espressif__esp-tflite-micro" "bt" "espressif__esp_modem" "espressif__esp-zboss-lib" "espressif__esp-zigbee-lib" "espressif__mdns" "espressif__esp-dsp" "espressif__esp32-camera" "joltwallet__littlefs"; do if [ -f "$AR_SDK/lib/lib$lib.a" ]; then echo "Stripping $AR_SDK/lib/lib$lib.a" "$TOOLCHAIN-strip" -g "$AR_SDK/lib/lib$lib.a" From 491176556a948270e0a05aa8cd368a84443502e0 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 19 Jun 2024 11:49:59 +0200 Subject: [PATCH 173/211] CONFIG_ESP_PHY_REDUCE_TX_POWER=y --- configs/defconfig.common | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/defconfig.common b/configs/defconfig.common index 17e6f96aa..8432c8bda 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -50,6 +50,7 @@ CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=0 # CONFIG_ESP_WIFI_MBEDTLS_CRYPTO is not set # CONFIG_ESP_WIFI_IRAM_OPT is not set # CONFIG_ESP_WIFI_RX_IRAM_OPT is not set +CONFIG_ESP_PHY_REDUCE_TX_POWER=y CONFIG_ETH_TRANSMIT_MUTEX=y CONFIG_ETH_SPI_ETHERNET_DM9051=y CONFIG_ETH_SPI_ETHERNET_W5500=y From 87f773667c183732e35dcd909aa49e6d299ac388 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 24 Jun 2024 21:51:37 +0200 Subject: [PATCH 174/211] rm -rf arduino-esp32/libraries/OpenThread --- tools/archive-build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index 337495962..9cb03411f 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -39,6 +39,7 @@ rm -rf arduino-esp32/libraries/USB rm -rf arduino-esp32/libraries/ESP_SR rm -rf arduino-esp32/libraries/ESP_NOW rm -rf arduino-esp32/libraries/TFLiteMicro +rm -rf arduino-esp32/libraries/OpenThread rm -rf arduino-esp32/libraries/ESP32 rm -rf arduino-esp32/package rm -rf arduino-esp32/tools/esp32-arduino-libs From 47b920d52f43ecef4672387d878e5a717ddd3637 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 24 Jun 2024 21:53:46 +0200 Subject: [PATCH 175/211] rm -rf "$AR_COMPS/arduino/libraries/OpenThread --- tools/install-arduino.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index 9991750eb..c8785b9e2 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -93,3 +93,4 @@ rm -rf "$AR_COMPS/arduino/libraries/ESP32" rm -rf "$AR_COMPS/arduino/libraries/ESP_SR" rm -rf "$AR_COMPS/arduino/libraries/ESP_NOW" rm -rf "$AR_COMPS/arduino/libraries/TFLiteMicro" +rm -rf "$AR_COMPS/arduino/libraries/OpenThread From 668e229232bd5454724ac19d88f2e585ac027ef2 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 24 Jun 2024 21:54:13 +0200 Subject: [PATCH 176/211] Update install-arduino.sh --- tools/install-arduino.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index c8785b9e2..07b947634 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -93,4 +93,4 @@ rm -rf "$AR_COMPS/arduino/libraries/ESP32" rm -rf "$AR_COMPS/arduino/libraries/ESP_SR" rm -rf "$AR_COMPS/arduino/libraries/ESP_NOW" rm -rf "$AR_COMPS/arduino/libraries/TFLiteMicro" -rm -rf "$AR_COMPS/arduino/libraries/OpenThread +rm -rf "$AR_COMPS/arduino/libraries/OpenThread" From 2163609dff1213e2706ecc476d6d9f8576e687f9 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 2 Jul 2024 14:16:15 +0200 Subject: [PATCH 177/211] explicit disable `# CONFIG_COMPILER_CXX_EXCEPTIONS` --- configs/defconfig.common | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/defconfig.common b/configs/defconfig.common index 8432c8bda..2d61f43b8 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -18,6 +18,7 @@ CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y +# CONFIG_COMPILER_CXX_EXCEPTIONS is not set # CONFIG_COMPILER_WARN_WRITE_STRINGS is not set # CONFIG_ESP_ERR_TO_NAME_LOOKUP is not set # CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR is not set From b4f08271c69115717cba4926f1b8dc10dbf39b24 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 3 Jul 2024 16:40:43 +0200 Subject: [PATCH 178/211] Update push.yml --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 0a1aef29e..4adeff997 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,4 +1,4 @@ -name: Arduino IDF 5.1 solo1 +name: Arduino IDF 5.2 solo1 on: workflow_dispatch: # Manually start a workflow From e64bbd32f0c7843d9380168b407539d5a6d10f45 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 3 Jul 2024 16:42:25 +0200 Subject: [PATCH 179/211] Update defconfig.120m --- configs/defconfig.120m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configs/defconfig.120m b/configs/defconfig.120m index 11d11177f..1dce09930 100644 --- a/configs/defconfig.120m +++ b/configs/defconfig.120m @@ -1,3 +1,5 @@ +CONFIG_IDF_EXPERIMENTAL_FEATURES=y CONFIG_ESPTOOLPY_FLASHFREQ_120M=y CONFIG_SPIRAM_SPEED_120M=y -CONFIG_SPI_FLASH_HPM_ENA=y +# CONFIG_SPI_FLASH_HPM_ENA=y +CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y From f62a1626d6a514e847813f30339c42f67a21dc46 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 3 Jul 2024 16:43:55 +0200 Subject: [PATCH 180/211] Update defconfig.80m --- configs/defconfig.80m | 1 - 1 file changed, 1 deletion(-) diff --git a/configs/defconfig.80m b/configs/defconfig.80m index 38980b0d9..7014fa954 100644 --- a/configs/defconfig.80m +++ b/configs/defconfig.80m @@ -1,2 +1 @@ CONFIG_ESPTOOLPY_FLASHFREQ_80M=y -CONFIG_SPIRAM_SPEED_80M=y \ No newline at end of file From d6b870e19e376ed96044c81db0bd7d3d00ce674c Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 3 Jul 2024 16:44:16 +0200 Subject: [PATCH 181/211] Update defconfig.40m --- configs/defconfig.40m | 1 - 1 file changed, 1 deletion(-) diff --git a/configs/defconfig.40m b/configs/defconfig.40m index 079a0336a..ffc4b5c1c 100644 --- a/configs/defconfig.40m +++ b/configs/defconfig.40m @@ -1,2 +1 @@ CONFIG_ESPTOOLPY_FLASHFREQ_40M=y -CONFIG_SPIRAM_SPEED_40M=y \ No newline at end of file From ffce92672b82e2f2b66563d0623c1219ae86c1cf Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 3 Jul 2024 16:46:44 +0200 Subject: [PATCH 182/211] IDF 5.2 --- tools/config.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/config.sh b/tools/config.sh index a5cdfe840..3476d8dda 100755 --- a/tools/config.sh +++ b/tools/config.sh @@ -6,12 +6,12 @@ if [ -z $IDF_PATH ]; then fi if [ -z $IDF_BRANCH ]; then - export IDF_BRANCH="release/v5.1" + export IDF_BRANCH="release/v5.2" fi # Arduino branch to use if [ -z $AR_BRANCH ]; then - AR_BRANCH="main" + AR_BRANCH="release/v5.2" fi if [ -z $IDF_TARGET ]; then From 73b3272996abbfa18eaf67e3b002e847d7ec78fd Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 10 Jul 2024 16:47:15 +0200 Subject: [PATCH 183/211] Create lwip_max_tcp_pcb.diff --- patches/lwip_max_tcp_pcb.diff | 118 ++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 patches/lwip_max_tcp_pcb.diff diff --git a/patches/lwip_max_tcp_pcb.diff b/patches/lwip_max_tcp_pcb.diff new file mode 100644 index 000000000..6b9e73cb6 --- /dev/null +++ b/patches/lwip_max_tcp_pcb.diff @@ -0,0 +1,118 @@ +diff --git a/components/lwip/lwip/src/core/memp.c b/components/lwip/lwip/src/core/memp.c +index 352ce5a55127a658b6b3c9d8541298c42df332ff..39433cf476b3456b046e337e9b1f016299964a84 100644 +--- a/components/lwip/lwip/src/core/memp.c ++++ b/components/lwip/lwip/src/core/memp.c +@@ -240,6 +240,10 @@ memp_init(void) + #endif /* MEMP_OVERFLOW_CHECK >= 2 */ + } + ++#if MEMP_MEM_MALLOC && ESP_LWIP && LWIP_TCP ++static u32_t num_tcp_pcb = 0; ++#endif ++ + static void * + #if !MEMP_OVERFLOW_CHECK + do_memp_malloc_pool(const struct memp_desc *desc) +@@ -251,6 +255,16 @@ do_memp_malloc_pool_fn(const struct memp_desc *desc, const char *file, const int + SYS_ARCH_DECL_PROTECT(old_level); + + #if MEMP_MEM_MALLOC ++#if ESP_LWIP ++#if LWIP_TCP ++ if(desc == memp_pools[MEMP_TCP_PCB]){ ++ if(num_tcp_pcb >= MEMP_NUM_TCP_PCB){ ++ return NULL; ++ } ++ } ++#endif ++#endif ++ + memp = (struct memp *)mem_malloc(MEMP_SIZE + MEMP_ALIGN_SIZE(desc->size)); + SYS_ARCH_PROTECT(old_level); + #else /* MEMP_MEM_MALLOC */ +@@ -260,6 +274,12 @@ do_memp_malloc_pool_fn(const struct memp_desc *desc, const char *file, const int + #endif /* MEMP_MEM_MALLOC */ + + if (memp != NULL) { ++#if MEMP_MEM_MALLOC && ESP_LWIP && LWIP_TCP ++ if (desc == memp_pools[MEMP_TCP_PCB]) { ++ num_tcp_pcb++; ++ } ++#endif ++ + #if !MEMP_MEM_MALLOC + #if MEMP_OVERFLOW_CHECK == 1 + memp_overflow_check_element(memp, desc); +@@ -369,6 +389,12 @@ do_memp_free_pool(const struct memp_desc *desc, void *mem) + + SYS_ARCH_PROTECT(old_level); + ++#if MEMP_MEM_MALLOC && ESP_LWIP && LWIP_TCP ++ if (desc == memp_pools[MEMP_TCP_PCB]) { ++ num_tcp_pcb--; ++ } ++#endif ++ + #if MEMP_OVERFLOW_CHECK == 1 + memp_overflow_check_element(memp, desc); + #endif /* MEMP_OVERFLOW_CHECK */ +diff --git a/components/lwip/lwip/src/core/tcp.c b/components/lwip/lwip/src/core/tcp.c +index 3fbdd89ae07807208ff7466abb50f90b5e7727e4..fe6baaf250927cb4b89f8d1dbd41c73def88692b 100644 +--- a/components/lwip/lwip/src/core/tcp.c ++++ b/components/lwip/lwip/src/core/tcp.c +@@ -1765,7 +1765,9 @@ tcp_kill_state(enum tcp_state state) + struct tcp_pcb *pcb, *inactive; + u32_t inactivity; + ++#if !ESP_LWIP + LWIP_ASSERT("invalid state", (state == CLOSING) || (state == LAST_ACK)); ++#endif + + inactivity = 0; + inactive = NULL; +@@ -1870,17 +1872,41 @@ tcp_alloc(u8_t prio) + tcp_kill_state(CLOSING); + /* Try to allocate a tcp_pcb again. */ + pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB); ++#if ESP_LWIP + if (pcb == NULL) { +- /* Try killing oldest active connection with lower priority than the new one. */ +- LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: killing oldest connection with prio lower than %d\n", prio)); +- tcp_kill_prio(prio); +- /* Try to allocate a tcp_pcb again. */ ++ /* Try killing oldest connection in FIN_WAIT_2. */ ++ LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: killing off oldest FIN_WAIT_2 connection\n")); ++ tcp_kill_state(FIN_WAIT_2); + pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB); ++ if (pcb == NULL) { ++ /* Try killing oldest connection in FIN_WAIT_1. */ ++ LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: killing off oldest FIN_WAIT_1 connection\n")); ++ tcp_kill_state(FIN_WAIT_1); ++ pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB); ++#endif ++ if (pcb == NULL) { ++ /* Try killing oldest active connection with lower priority than the new one. */ ++ LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: killing oldest connection with prio lower than %d\n", prio)); ++ tcp_kill_prio(prio); ++ /* Try to allocate a tcp_pcb again. */ ++ pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB); ++ if (pcb != NULL) { ++ /* adjust err stats: memp_malloc failed multiple times before */ ++ MEMP_STATS_DEC(err, MEMP_TCP_PCB); ++ } ++ } ++#if ESP_LWIP ++ if (pcb != NULL) { ++ /* adjust err stats: memp_malloc failed multiple times before */ ++ MEMP_STATS_DEC(err, MEMP_TCP_PCB); ++ } ++ } + if (pcb != NULL) { + /* adjust err stats: memp_malloc failed multiple times before */ + MEMP_STATS_DEC(err, MEMP_TCP_PCB); + } + } ++#endif + if (pcb != NULL) { + /* adjust err stats: memp_malloc failed multiple times before */ + MEMP_STATS_DEC(err, MEMP_TCP_PCB); From a651d8f5360db0fa75ed0254123532b7f40641c3 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 10 Jul 2024 16:55:09 +0200 Subject: [PATCH 184/211] Update install-esp-idf.sh --- tools/install-esp-idf.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index 43ff8d6dc..2c4a43f75 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -64,6 +64,10 @@ if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then git submodule update --recursive $IDF_PATH/install.sh + cd $IDF_PATH + patch -p1 -N -i ../patches/lwip_max_tcp_pcb.diff + cd - + # remove code and component(s) not needed/wanted for Tasmota framework solo1 cd $IDF_PATH rm -rf components/esp-gdbstub From 8783f3fe3331be782a4d8d8119d1fff9da94d1e4 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 12 Jul 2024 19:48:07 +0200 Subject: [PATCH 185/211] Update defconfig.common --- configs/defconfig.common | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index 2d61f43b8..672edb7f4 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -11,6 +11,7 @@ CONFIG_BOOT_ROM_LOG_ALWAYS_OFF=y CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS=y CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_NONE=y CONFIG_I2S_SUPPRESS_DEPRECATE_WARN=y +CONFIG_I2S_ISR_IRAM_SAFE=y CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y @@ -26,7 +27,7 @@ CONFIG_COMPILER_SAVE_RESTORE_LIBCALLS=y # CONFIG_ESP_HTTPS_SERVER_ENABLE is not set # CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS is not set # CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set -# CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH is not set +CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y CONFIG_ESP_SYSTEM_ESP32_SRAM1_REGION_AS_IRAM=y CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 @@ -68,8 +69,8 @@ CONFIG_FREERTOS_HZ=1000 # CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT is not set CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=2304 # CONFIG_FREERTOS_FPU_IN_ISR is not set -# CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set -# CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH is not set +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y +CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y CONFIG_HAL_ASSERTION_DISABLE=y CONFIG_HEAP_POISONING_DISABLED=y CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024 @@ -208,6 +209,8 @@ CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=4096 # CONFIG_VFS_SUPPORT_TERMIOS is not set # CONFIG_SPI_MASTER_ISR_IN_IRAM is not set # CONFIG_SPI_SLAVE_ISR_IN_IRAM is not set +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096 +CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=0 CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=1 CONFIG_DSP_MAX_FFT_SIZE_1024=y @@ -215,3 +218,16 @@ CONFIG_DSP_MAX_FFT_SIZE_1024=y CONFIG_LITTLEFS_MAX_PARTITIONS=2 CONFIG_LITTLEFS_MULTIVERSION=y CONFIG_LITTLEFS_DISK_VERSION_2_0=y + +# +# Disable Cameras not used +# +# CONFIG_OV7670_SUPPORT is not set +# CONFIG_OV7725_SUPPORT is not set +# CONFIG_NT99141_SUPPORT is not set +# CONFIG_GC2145_SUPPORT is not set +# CONFIG_GC032A_SUPPORT is not set +# CONFIG_GC0308_SUPPORT is not set +# CONFIG_BF3005_SUPPORT is not set +# CONFIG_BF20A6_SUPPORT is not set +# CONFIG_SC030IOT_SUPPORT is not set From 8b3831ea414bec1e5f55c2b7a258923f90f0114f Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 13 Jul 2024 21:15:23 +0200 Subject: [PATCH 186/211] Update defconfig.esp32 --- configs/defconfig.esp32 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configs/defconfig.esp32 b/configs/defconfig.esp32 index a836a2804..f6f14db17 100644 --- a/configs/defconfig.esp32 +++ b/configs/defconfig.esp32 @@ -21,6 +21,11 @@ CONFIG_BT_NIMBLE_MAX_CONNECTIONS=1 CONFIG_BT_STACK_NO_LOG=y CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY=y +# Enable ULP +CONFIG_ULP_COPROC_ENABLED=y +CONFIG_ULP_COPROC_TYPE_FSM=y +CONFIG_ULP_COPROC_RESERVE_MEM=4096 + CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR=y CONFIG_ETH_ENABLED=y From 842a6cfda0daaf976620fcb6df2ee6948bf0eb82 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 19 Jul 2024 18:11:08 +0200 Subject: [PATCH 187/211] # CONFIG_ESP_WIFI_GMAC_SUPPORT is not set --- configs/defconfig.common | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/defconfig.common b/configs/defconfig.common index 672edb7f4..687c3ef5a 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -38,6 +38,7 @@ CONFIG_ESP_TIMER_TASK_STACK_SIZE=4096 CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y # CONFIG_ESP_WIFI_FTM_ENABLE is not set +# CONFIG_ESP_WIFI_GMAC_SUPPORT is not set CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=8 CONFIG_ESP_WIFI_STATIC_TX_BUFFER_NUM=8 CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM=16 From 8df1a900ecf706191fdd0b9e38abf178447535bb Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 31 Jul 2024 13:37:30 +0200 Subject: [PATCH 188/211] Update config.sh --- tools/config.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/config.sh b/tools/config.sh index 3476d8dda..94ed2afaf 100755 --- a/tools/config.sh +++ b/tools/config.sh @@ -52,6 +52,7 @@ AR_COMPS="$AR_ROOT/components" AR_MANAGED_COMPS="$AR_ROOT/managed_components" AR_OUT="$AR_ROOT/out" AR_TOOLS="$AR_OUT/tools" +AR_PATCHES="$AR_ROOT/patches" AR_PLATFORM_TXT="$AR_OUT/platform.txt" AR_GEN_PART_PY="$AR_TOOLS/gen_esp32part.py" AR_SDK="$AR_TOOLS/esp32-arduino-libs/$IDF_TARGET" From d36ceece5a6f5860ca1be8e152b00c2b5848b3e3 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 31 Jul 2024 13:42:42 +0200 Subject: [PATCH 189/211] Update install-esp-idf.sh --- tools/install-esp-idf.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index 2c4a43f75..9c8692a4e 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -65,7 +65,7 @@ if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then $IDF_PATH/install.sh cd $IDF_PATH - patch -p1 -N -i ../patches/lwip_max_tcp_pcb.diff + patch -p1 -N -i $AR_PATCHES/lwip_max_tcp_pcb.diff cd - # remove code and component(s) not needed/wanted for Tasmota framework solo1 From eda6faceef57398d534c3acf47d3d7959fb460b7 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 10 Aug 2024 19:18:38 +0200 Subject: [PATCH 190/211] Update build.sh --- build.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build.sh b/build.sh index 2b630d34b..8af90811f 100755 --- a/build.sh +++ b/build.sh @@ -197,6 +197,9 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do echo "* Build IDF-Libs: $idf_libs_configs" rm -rf build sdkconfig + pushd $AR_MANAGED_COMPS + rm -- **/.component_hash + popd idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$idf_libs_configs" idf-libs if [ $? -ne 0 ]; then exit 1; fi @@ -209,6 +212,9 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do echo "* Build BootLoader: $bootloader_configs" rm -rf build sdkconfig + pushd $AR_MANAGED_COMPS + rm -- **/.component_hash + popd idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$bootloader_configs" copy-bootloader if [ $? -ne 0 ]; then exit 1; fi done @@ -222,6 +228,9 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do echo "* Build Memory Variant: $mem_configs" rm -rf build sdkconfig + pushd $AR_MANAGED_COMPS + rm -- **/.component_hash + popd idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$mem_configs" mem-variant if [ $? -ne 0 ]; then exit 1; fi done From 759d8aab5da340a9c85218ce888389b027eb80f9 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 15 Aug 2024 21:07:32 +0200 Subject: [PATCH 191/211] Update pio_start.txt --- configs/pio_start.txt | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/configs/pio_start.txt b/configs/pio_start.txt index 87972813a..b14b5752e 100644 --- a/configs/pio_start.txt +++ b/configs/pio_start.txt @@ -35,4 +35,39 @@ FRAMEWORK_SDK_DIR = join(FRAMEWORK_DIR, "tools", "esp32-arduino-libs") board_config = env.BoardConfig() +flatten_cppdefines = env.Flatten(env['CPPDEFINES']) + +# +# zigbee libs +# +if "ZIGBEE_MODE_ZCZR" in flatten_cppdefines: + env.Append( + LIBS=[ + "-lesp_zb_api_zczr", + "-lesp_zb_cli_command", + "-lzboss_stack.zczr.trace", + "-lzboss_stack.zczr", + "-lzboss_port" + ] + ) +if "ZIGBEE_MODE_ED" in flatten_cppdefines: + env.Append( + LIBS=[ + "-lesp_zb_api_ed", + "-lesp_zb_cli_command", + "-lzboss_stack.ed.trace", + "-lzboss_stack.ed", + "-lzboss_port" + ] + ) +if "ZIGBEE_MODE_RCP" in flatten_cppdefines: + env.Append( + LIBS=[ + "-lesp_zb_api_rcp", + "-lesp_zb_cli_command", + "-lzboss_stack.rcp", + "-lzboss_port" + ] + ) + env.Append( From e9516fcc0c10fe89f62acbc4a0a36cb124c74d70 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 15 Aug 2024 22:36:34 +0200 Subject: [PATCH 192/211] Update build.sh --- build.sh | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/build.sh b/build.sh index 8af90811f..07adef025 100755 --- a/build.sh +++ b/build.sh @@ -10,6 +10,9 @@ if ! [ -x "$(command -v git)" ]; then exit 1 fi +# Fixes building some components. See https://github.com/espressif/arduino-esp32/issues/10167 +export IDF_COMPONENT_OVERWRITE_MANAGED_COMPONENTS=1 + export TARGET="esp32" BUILD_TYPE="all" SKIP_ENV=0 @@ -197,9 +200,6 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do echo "* Build IDF-Libs: $idf_libs_configs" rm -rf build sdkconfig - pushd $AR_MANAGED_COMPS - rm -- **/.component_hash - popd idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$idf_libs_configs" idf-libs if [ $? -ne 0 ]; then exit 1; fi @@ -212,9 +212,6 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do echo "* Build BootLoader: $bootloader_configs" rm -rf build sdkconfig - pushd $AR_MANAGED_COMPS - rm -- **/.component_hash - popd idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$bootloader_configs" copy-bootloader if [ $? -ne 0 ]; then exit 1; fi done @@ -228,9 +225,6 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do echo "* Build Memory Variant: $mem_configs" rm -rf build sdkconfig - pushd $AR_MANAGED_COMPS - rm -- **/.component_hash - popd idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$mem_configs" mem-variant if [ $? -ne 0 ]; then exit 1; fi done From 77f8ff0e23de6827e7947800b23c4004413bcc5b Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 19 Aug 2024 23:15:59 +0200 Subject: [PATCH 193/211] Update builds.json --- configs/builds.json | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/configs/builds.json b/configs/builds.json index 02695519c..7c4611553 100644 --- a/configs/builds.json +++ b/configs/builds.json @@ -4,7 +4,7 @@ "file":"libspi_flash.a", "src":"build/esp-idf/spi_flash/libspi_flash.a", "out":"lib/libspi_flash.a", - "targets":["esp32","esp32c3","esp32s2","esp32s3","esp32c6","esp32h2","esp32c2"] + "targets":["esp32","esp32c2","esp32c3","esp32s2","esp32s3","esp32c6","esp32h2"] }, { "file":"libesp_psram.a", @@ -131,25 +131,17 @@ { "target": "esp32s3", "features":[], - "idf_libs":["qio","80m","opi_ram"], + "idf_libs":["qio","80m","qio_ram"], "bootloaders":[ ["qio","120m","qio_ram"], - ["qio","120m","opi_ram"], ["qio","80m","qio_ram"], - ["qio","80m","opi_ram"], - ["opi","120m","qio_ram"], - ["opi","120m","opi_ram"], - ["opi","80m","qio_ram"], + ["dio","80m","qio_ram"], ["opi","80m","opi_ram"] ], "mem_variants":[ - ["qio","120m","qio_ram"], - ["qio","120m","opi_ram"], - ["qio","80m","qio_ram"], - ["qio","80m","opi_ram"], - ["opi","120m","qio_ram"], - ["opi","120m","opi_ram"], - ["opi","80m","qio_ram"], + ["qio","80m","opi_ram"], + ["dio","80m","qio_ram"], + ["dio","80m","opi_ram"], ["opi","80m","opi_ram"] ] } From 7df9b6f75d70c74247b2e6baae8c3d32d122d38b Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 19 Aug 2024 23:19:07 +0200 Subject: [PATCH 194/211] use IDF 5.3 --- tools/config.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/config.sh b/tools/config.sh index 94ed2afaf..17b5c13ae 100755 --- a/tools/config.sh +++ b/tools/config.sh @@ -6,12 +6,12 @@ if [ -z $IDF_PATH ]; then fi if [ -z $IDF_BRANCH ]; then - export IDF_BRANCH="release/v5.2" + export IDF_BRANCH="release/v5.3" fi # Arduino branch to use if [ -z $AR_BRANCH ]; then - AR_BRANCH="release/v5.2" + AR_BRANCH="release/v3.1.x" fi if [ -z $IDF_TARGET ]; then From 6bb10c088684def5759695d989f3e7b861442596 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 19 Aug 2024 23:19:29 +0200 Subject: [PATCH 195/211] Update push.yml --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 4adeff997..ef4d4b02d 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,4 +1,4 @@ -name: Arduino IDF 5.2 solo1 +name: Arduino IDF 5.3 solo1 on: workflow_dispatch: # Manually start a workflow From 9a4592636270e055f230dc31b5c15044a5dbc29e Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 28 Aug 2024 21:47:35 +0200 Subject: [PATCH 196/211] Update pio_start.txt --- configs/pio_start.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/configs/pio_start.txt b/configs/pio_start.txt index b14b5752e..1686d2326 100644 --- a/configs/pio_start.txt +++ b/configs/pio_start.txt @@ -45,7 +45,6 @@ if "ZIGBEE_MODE_ZCZR" in flatten_cppdefines: LIBS=[ "-lesp_zb_api_zczr", "-lesp_zb_cli_command", - "-lzboss_stack.zczr.trace", "-lzboss_stack.zczr", "-lzboss_port" ] @@ -55,7 +54,6 @@ if "ZIGBEE_MODE_ED" in flatten_cppdefines: LIBS=[ "-lesp_zb_api_ed", "-lesp_zb_cli_command", - "-lzboss_stack.ed.trace", "-lzboss_stack.ed", "-lzboss_port" ] From 1252d83e02f7c3d5f36b40becc3dc02b3a14cf4d Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 31 Aug 2024 15:50:28 +0200 Subject: [PATCH 197/211] Update pio_end.txt --- configs/pio_end.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/pio_end.txt b/configs/pio_end.txt index e7544f1dd..f942d442d 100644 --- a/configs/pio_end.txt +++ b/configs/pio_end.txt @@ -1,5 +1,5 @@ "ARDUINO_ARCH_ESP32", - "ESP32", + ("ESP32", "ESP32"), ("F_CPU", "$BOARD_F_CPU"), ("ARDUINO", 10812), ("ARDUINO_VARIANT", '\\"%s\\"' % board_config.get("build.variant").replace('"', "")), From bb07e06a9cc13afb02cda878ae59ab5009eb458e Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 6 Sep 2024 22:05:21 +0200 Subject: [PATCH 198/211] Update defconfig.common --- configs/defconfig.common | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index 687c3ef5a..a14765f70 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -37,22 +37,22 @@ CONFIG_ESP_TASK_WDT_PANIC=y CONFIG_ESP_TIMER_TASK_STACK_SIZE=4096 CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y +# CONFIG_ESP_WIFI_MBEDTLS_CRYPTO is not set # CONFIG_ESP_WIFI_FTM_ENABLE is not set # CONFIG_ESP_WIFI_GMAC_SUPPORT is not set -CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=8 -CONFIG_ESP_WIFI_STATIC_TX_BUFFER_NUM=8 -CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM=16 # CONFIG_ESP_WIFI_CSI_ENABLED is not set -CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=y -CONFIG_ESP_WIFI_ENABLE_SAE_PK=y +# CONFIG_ESP_WIFI_ENABLE_WPA3_SAE is not set +# CONFIG_ESP_WIFI_ENABLE_SAE_PK is not set # CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT is not set CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT=y # CONFIG_ESP_WIFI_SOFTAP_SAE_SUPPORT is not set # CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA is not set CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=0 -# CONFIG_ESP_WIFI_MBEDTLS_CRYPTO is not set # CONFIG_ESP_WIFI_IRAM_OPT is not set # CONFIG_ESP_WIFI_RX_IRAM_OPT is not set +CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=8 +CONFIG_ESP_WIFI_STATIC_TX_BUFFER_NUM=8 +CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM=16 CONFIG_ESP_PHY_REDUCE_TX_POWER=y CONFIG_ETH_TRANSMIT_MUTEX=y CONFIG_ETH_SPI_ETHERNET_DM9051=y @@ -108,6 +108,7 @@ CONFIG_NEWLIB_NANO_FORMAT=y CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y CONFIG_MBEDTLS_TLS_DISABLED=y +# CONFIG_MBEDTLS_TLS_ENABLED is not set # CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN is not set CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=10 # CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE is not set @@ -171,7 +172,7 @@ CONFIG_MBEDTLS_HARDWARE_SHA=y CONFIG_MBEDTLS_ECP_C=y CONFIG_MBEDTLS_ECDH_C=y CONFIG_MBEDTLS_ECDSA_C=y -CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLE=y # CONFIG_MBEDTLS_DHM_C is not set # CONFIG_MBEDTLS_ECJPAKE_C is not set # CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS is not set From bab6141fd9549e5b10e7f7c853e1de7377d07169 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:23:21 +0200 Subject: [PATCH 199/211] Update defconfig.common --- configs/defconfig.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index a14765f70..cd594618f 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -172,7 +172,7 @@ CONFIG_MBEDTLS_HARDWARE_SHA=y CONFIG_MBEDTLS_ECP_C=y CONFIG_MBEDTLS_ECDH_C=y CONFIG_MBEDTLS_ECDSA_C=y -CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLE=y +CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y # CONFIG_MBEDTLS_DHM_C is not set # CONFIG_MBEDTLS_ECJPAKE_C is not set # CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS is not set From 98527d9a3d08807f3be493c5aa6fe9b6cbb3ed8f Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:00:20 +0200 Subject: [PATCH 200/211] Update defconfig.common --- configs/defconfig.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index cd594618f..d48dd954f 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -44,7 +44,7 @@ CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y # CONFIG_ESP_WIFI_ENABLE_WPA3_SAE is not set # CONFIG_ESP_WIFI_ENABLE_SAE_PK is not set # CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT is not set -CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT=y +# CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT is not set # CONFIG_ESP_WIFI_SOFTAP_SAE_SUPPORT is not set # CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA is not set CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=0 From 004309f88dc17c693bd2776389794e3fb4dabb03 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 22 Sep 2024 16:06:25 +0200 Subject: [PATCH 201/211] Update defconfig.common --- configs/defconfig.common | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configs/defconfig.common b/configs/defconfig.common index d48dd954f..2b35af805 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -16,6 +16,10 @@ CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_SIZE=y +CONFIG_COMPILER_DISABLE_DEFAULT_ERRORS=y +CONFIG_COMPILER_DISABLE_GCC12_WARNINGS=y +CONFIG_COMPILER_DISABLE_GCC13_WARNINGS=y +CONFIG_COMPILER_DISABLE_GCC14_WARNINGS=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y From b664a628c33917f7c6cb4a919194cb1822d275ef Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 27 Sep 2024 13:20:12 +0200 Subject: [PATCH 202/211] Fix remove Arduino defines --- tools/copy-libs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/copy-libs.sh b/tools/copy-libs.sh index 88c1b5400..896effc0e 100755 --- a/tools/copy-libs.sh +++ b/tools/copy-libs.sh @@ -102,7 +102,7 @@ for item in "${@:2:${#@}-5}"; do INCLUDES+="$item " fi elif [ "$prefix" = "-D" ]; then - if [[ "${item:2:7}" != "ARDUINO" ]] && [[ "$item" != "-DESP32" ]]; then #skip ARDUINO defines + if [[ "${item:2:7}" != "ARDUINO" ]] && [[ "$item" != "-DESP32=ESP32" ]]; then #skip ARDUINO defines DEFINES+="$item " fi elif [ "$prefix" = "-O" ]; then From 54dbca3364f252beb380b6175c8041329191b665 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 28 Sep 2024 21:58:52 +0200 Subject: [PATCH 203/211] enable LTO as default --- tools/copy-libs.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/copy-libs.sh b/tools/copy-libs.sh index 896effc0e..76457e8ee 100755 --- a/tools/copy-libs.sh +++ b/tools/copy-libs.sh @@ -65,9 +65,9 @@ LD_SCRIPT_DIRS="" PIO_CC_FLAGS="" PIO_C_FLAGS="" -PIO_CXX_FLAGS="" +PIO_CXX_FLAGS="-flto=auto " PIO_AS_FLAGS="" -PIO_LD_FLAGS="" +PIO_LD_FLAGS="-flto " PIO_LD_FUNCS="" PIO_LD_SCRIPTS="" @@ -121,7 +121,7 @@ str=`printf '%b' "$str"` #unescape the string set -- $str for item in "${@:2:${#@}-5}"; do prefix="${item:0:2}" - if [[ "$prefix" != "-I" && "$prefix" != "-D" && "$item" != "-Wall" && "$item" != "-Werror=all" && "$item" != "-Wextra" && "$prefix" != "-O" ]]; then + if [[ "$prefix" != "-I" && "$prefix" != "-D" && "$item" != "-Wall" && "$item" != "-Werror=all" && "$item" != "-Wextra" && "$item" != "-fno-lto" && "$prefix" != "-O" ]]; then if [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:20}" != "-fdiagnostics-color=" && "${item:0:19}" != "-fdebug-prefix-map=" ]]; then AS_FLAGS+="$item " if [[ $C_FLAGS == *"$item"* ]]; then @@ -140,7 +140,7 @@ str=`printf '%b' "$str"` #unescape the string set -- $str for item in "${@:2:${#@}-5}"; do prefix="${item:0:2}" - if [[ "$prefix" != "-I" && "$prefix" != "-D" && "$item" != "-Wall" && "$item" != "-Werror=all" && "$item" != "-Wextra" && "$prefix" != "-O" ]]; then + if [[ "$prefix" != "-I" && "$prefix" != "-D" && "$item" != "-Wall" && "$item" != "-Werror=all" && "$item" != "-Wextra" && "$item" != "-fno-lto" && "$prefix" != "-O" ]]; then if [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:20}" != "-fdiagnostics-color=" && "${item:0:19}" != "-fdebug-prefix-map=" ]]; then CPP_FLAGS+="$item " if [[ $PIO_CC_FLAGS != *"$item"* ]]; then @@ -211,7 +211,7 @@ for item; do add_next=0 is_script=0 is_dir=0 - elif [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:19}" != "-fdebug-prefix-map=" && "${item:0:17}" != "-Wl,--start-group" && "${item:0:15}" != "-Wl,--end-group" ]]; then + elif [[ "${item:0:23}" != "-mfix-esp32-psram-cache" && "${item:0:18}" != "-fmacro-prefix-map" && "${item:0:19}" != "-fdebug-prefix-map=" && "${item:0:8}" != "-fno-lto" && "${item:0:17}" != "-Wl,--start-group" && "${item:0:15}" != "-Wl,--end-group" ]]; then LD_FLAGS+="$item " PIO_LD_FLAGS+="$item " fi From 3b2771f7275121ab808ce0f614f0c6b7de8bfb86 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 29 Sep 2024 13:04:23 +0200 Subject: [PATCH 204/211] add to cc flag lto --- tools/copy-libs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/copy-libs.sh b/tools/copy-libs.sh index 76457e8ee..b0b7bb190 100755 --- a/tools/copy-libs.sh +++ b/tools/copy-libs.sh @@ -63,7 +63,7 @@ LD_LIBS_SEARCH="" LD_SCRIPTS="" LD_SCRIPT_DIRS="" -PIO_CC_FLAGS="" +PIO_CC_FLAGS="-flto=auto " PIO_C_FLAGS="" PIO_CXX_FLAGS="-flto=auto " PIO_AS_FLAGS="" From 776537bcbc8319abea37d188db457e8f41594c8b Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 3 Oct 2024 15:16:53 +0200 Subject: [PATCH 205/211] Update idf_component.yml --- main/idf_component.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/idf_component.yml b/main/idf_component.yml index 3f1b3fabd..702a6ad9b 100644 --- a/main/idf_component.yml +++ b/main/idf_component.yml @@ -6,4 +6,5 @@ dependencies: git: https://github.com/espressif/esp32-camera.git require: public rules: - - if: "target in [esp32, esp32s2, esp32s3]" + - if: "target in [esp32, esp32s2, esp32s3, esp32p4]" + - if: "$COMPONENTS_SUBSET in [full, all]" From c449c00fc1a064d3a7a9fc7c437fda607c394f8e Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 3 Oct 2024 15:22:21 +0200 Subject: [PATCH 206/211] add COMPONENTS_SUBSET --- build.sh | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/build.sh b/build.sh index 07adef025..5fc473d41 100755 --- a/build.sh +++ b/build.sh @@ -1,18 +1,25 @@ #!/bin/bash if ! [ -x "$(command -v python3)" ]; then - echo "ERROR: python is not installed! Please install python first." + echo "ERROR: python is not installed or not in PATH! Please install python first." exit 1 fi if ! [ -x "$(command -v git)" ]; then - echo "ERROR: git is not installed! Please install git first." + echo "ERROR: git is not installed or not in PATH! Please install git first." + exit 1 +fi + +if ! [ -x "$(command -v ninja)" ]; then + echo "ERROR: ninja is not installed or not in PATH! Please install ninja first." exit 1 fi # Fixes building some components. See https://github.com/espressif/arduino-esp32/issues/10167 export IDF_COMPONENT_OVERWRITE_MANAGED_COMPONENTS=1 +CCACHE_ENABLE=1 + export TARGET="esp32" BUILD_TYPE="all" SKIP_ENV=0 @@ -21,8 +28,9 @@ ARCHIVE_OUT=1 DEPLOY_OUT=0 function print_help() { - echo "Usage: build.sh [-s] [-A <arduino_branch>] [-I <idf_branch>] [-i <idf_commit>] [-c <path>] [-t <target>] [-b <build|menuconfig|reconfigure|idf-libs|copy-bootloader|mem-variant>] [config ...]" + echo "Usage: build.sh [-s] [-n] [-A <arduino_branch>] [-I <idf_branch>] [-i <idf_commit>] [-c <path>] [-t <target>] [-b <build|menuconfig|reconfigure|idf-libs|copy-bootloader|mem-variant>] [config ...]" echo " -s Skip installing/updating of ESP-IDF and all components" + echo " -n Disable ccache" echo " -A Set which branch of arduino-esp32 to be used for compilation" echo " -I Set which branch of ESP-IDF to be used for compilation" echo " -i Set which commit of ESP-IDF to be used for compilation" @@ -38,6 +46,9 @@ while getopts ":A:I:i:c:t:b:sde" opt; do s ) SKIP_ENV=1 ;; + n ) + CCACHE_ENABLE=0 + ;; e ) ARCHIVE_OUT=1 ;; @@ -78,6 +89,8 @@ done shift $((OPTIND -1)) CONFIGS=$@ +export IDF_CCACHE_ENABLE=$CCACHE_ENABLE + # Output the TARGET array echo "TARGET(s): ${TARGET[@]}" @@ -85,7 +98,8 @@ mkdir -p dist rm -rf dependencies.lock if [ $SKIP_ENV -eq 0 ]; then - echo "* Installing ESP-IDF/Arduino and all components..." + echo "* Installing/Updating Arduino and ESP-IDF." + # install arduino component ./tools/install-arduino.sh if [ $? -ne 0 ]; then exit 1; fi @@ -137,7 +151,7 @@ if [ "$BUILD_TYPE" != "all" ]; then echo "idf.py -DIDF_TARGET=\"$target\" -DSDKCONFIG_DEFAULTS=\"$configs\" $BUILD_TYPE" rm -rf build sdkconfig - idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$configs" $BUILD_TYPE + COMPONENTS_SUBSET=full idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$configs" $BUILD_TYPE if [ $? -ne 0 ]; then exit 1; fi done exit 0 @@ -200,7 +214,7 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do echo "* Build IDF-Libs: $idf_libs_configs" rm -rf build sdkconfig - idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$idf_libs_configs" idf-libs + COMPONENTS_SUBSET=full idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$idf_libs_configs" idf-libs if [ $? -ne 0 ]; then exit 1; fi # Build Bootloaders @@ -212,7 +226,7 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do echo "* Build BootLoader: $bootloader_configs" rm -rf build sdkconfig - idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$bootloader_configs" copy-bootloader + COMPONENTS_SUBSET=none idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$bootloader_configs" copy-bootloader if [ $? -ne 0 ]; then exit 1; fi done @@ -225,7 +239,7 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do echo "* Build Memory Variant: $mem_configs" rm -rf build sdkconfig - idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$mem_configs" mem-variant + COMPONENTS_SUBSET=none idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$mem_configs" mem-variant if [ $? -ne 0 ]; then exit 1; fi done done From 1254d4d4926c2c3be4387c25b0f274a9e34b6dfe Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 14 Oct 2024 11:14:30 +0200 Subject: [PATCH 207/211] remove lib `zigbee` --- tools/install-arduino.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index 07b947634..14629fdc0 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -94,3 +94,4 @@ rm -rf "$AR_COMPS/arduino/libraries/ESP_SR" rm -rf "$AR_COMPS/arduino/libraries/ESP_NOW" rm -rf "$AR_COMPS/arduino/libraries/TFLiteMicro" rm -rf "$AR_COMPS/arduino/libraries/OpenThread" +rm -rf "$AR_COMPS/arduino/libraries/Zigbee" From 09c80ceacceb166e2e129ea01ec4d780b6714ae3 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 14 Oct 2024 11:18:16 +0200 Subject: [PATCH 208/211] remove lib zigbee --- tools/archive-build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index 9cb03411f..56479a9c8 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -40,6 +40,7 @@ rm -rf arduino-esp32/libraries/ESP_SR rm -rf arduino-esp32/libraries/ESP_NOW rm -rf arduino-esp32/libraries/TFLiteMicro rm -rf arduino-esp32/libraries/OpenThread +rm -rf arduino-esp32/libraries/Zigbee rm -rf arduino-esp32/libraries/ESP32 rm -rf arduino-esp32/package rm -rf arduino-esp32/tools/esp32-arduino-libs From d8cde71b936be8238104337d6c647768442b5adb Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 14 Oct 2024 11:50:41 +0200 Subject: [PATCH 209/211] remove `io_pin_remap` --- tools/install-arduino.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index 14629fdc0..e36546277 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -79,6 +79,7 @@ rm -rf "$AR_COMPS/arduino/package" rm -rf "$AR_COMPS/arduino/tests" rm -rf "$AR_COMPS/arduino/cores/esp32/chip-debug-report.cpp" rm -rf "$AR_COMPS/arduino/cores/esp32/chip-debug-report.h" +rm -rf "$AR_COMPS/arduino/cores/esp32/io_pin_remap.h" rm -rf "$AR_COMPS/arduino/libraries/RainMaker" rm -rf "$AR_COMPS/arduino/libraries/Insights" rm -rf "$AR_COMPS/arduino/libraries/ESP_I2S" From 47d14fc7c47f82774f998144f3fdb98c6adcbd65 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 14 Oct 2024 12:48:07 +0200 Subject: [PATCH 210/211] Update install-arduino.sh --- tools/install-arduino.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index e36546277..14629fdc0 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -79,7 +79,6 @@ rm -rf "$AR_COMPS/arduino/package" rm -rf "$AR_COMPS/arduino/tests" rm -rf "$AR_COMPS/arduino/cores/esp32/chip-debug-report.cpp" rm -rf "$AR_COMPS/arduino/cores/esp32/chip-debug-report.h" -rm -rf "$AR_COMPS/arduino/cores/esp32/io_pin_remap.h" rm -rf "$AR_COMPS/arduino/libraries/RainMaker" rm -rf "$AR_COMPS/arduino/libraries/Insights" rm -rf "$AR_COMPS/arduino/libraries/ESP_I2S" From 0fa78a53dbec2c1ba8f2ee386b51a7c12006cb82 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 14 Oct 2024 14:27:45 +0200 Subject: [PATCH 211/211] remove USB support source code --- tools/archive-build.sh | 10 ++++++++++ tools/install-arduino.sh | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index 56479a9c8..605e13fd8 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -25,6 +25,16 @@ rm -rf arduino-esp32/idf_component_examples rm -rf arduino-esp32/docs rm -rf arduino-esp32/tests rm -rf arduino-esp32/idf_component_examples +rm -rf arduino-esp32/cores/esp32/chip-debug-report.cpp +rm -rf arduino-esp32/cores/esp32/chip-debug-report.h +rm -rf arduino-esp32/cores/esp32/esp32-hal-tinyusb.c +rm -rf arduino-esp32/cores/esp32/esp32-hal-tinyusb.h +rm -rf arduino-esp32/cores/esp32/USB.cpp +rm -rf arduino-esp32/cores/esp32/USB.h +rm -rf arduino-esp32/cores/esp32/USBCDC.cpp +rm -rf arduino-esp32/cores/esp32/USBCDC.h +rm -rf arduino-esp32/cores/esp32/USBMSC.cpp +rm -rf arduino-esp32/cores/esp32/USBMSC.h rm -rf arduino-esp32/libraries/RainMaker rm -rf arduino-esp32/libraries/Insights rm -rf arduino-esp32/libraries/ESP_I2S diff --git a/tools/install-arduino.sh b/tools/install-arduino.sh index 14629fdc0..8f7111980 100755 --- a/tools/install-arduino.sh +++ b/tools/install-arduino.sh @@ -79,6 +79,14 @@ rm -rf "$AR_COMPS/arduino/package" rm -rf "$AR_COMPS/arduino/tests" rm -rf "$AR_COMPS/arduino/cores/esp32/chip-debug-report.cpp" rm -rf "$AR_COMPS/arduino/cores/esp32/chip-debug-report.h" +rm -rf "$AR_COMPS/arduino/cores/esp32/esp32-hal-tinyusb.c" +rm -rf "$AR_COMPS/arduino/cores/esp32/esp32-hal-tinyusb.h" +rm -rf "$AR_COMPS/arduino/cores/esp32/USB.cpp" +rm -rf "$AR_COMPS/arduino/cores/esp32/USB.h" +rm -rf "$AR_COMPS/arduino/cores/esp32/USBCDC.cpp" +rm -rf "$AR_COMPS/arduino/cores/esp32/USBCDC.h" +rm -rf "$AR_COMPS/arduino/cores/esp32/USBMSC.cpp" +rm -rf "$AR_COMPS/arduino/cores/esp32/USBMSC.h" rm -rf "$AR_COMPS/arduino/libraries/RainMaker" rm -rf "$AR_COMPS/arduino/libraries/Insights" rm -rf "$AR_COMPS/arduino/libraries/ESP_I2S" @@ -89,6 +97,7 @@ rm -rf "$AR_COMPS/arduino/libraries/BluetoothSerial" rm -rf "$AR_COMPS/arduino/libraries/WiFiProv" rm -rf "$AR_COMPS/arduino/libraries/WiFiClientSecure" rm -rf "$AR_COMPS/arduino/libraries/NetworkClientSecure" +rm -rf "$AR_COMPS/arduino/libraries/USB" rm -rf "$AR_COMPS/arduino/libraries/ESP32" rm -rf "$AR_COMPS/arduino/libraries/ESP_SR" rm -rf "$AR_COMPS/arduino/libraries/ESP_NOW"