From 47e5beba7725188adea9d5228a65bc3dda4de0fb Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 10 Jul 2024 23:13:41 +0200 Subject: [PATCH 01/11] Platformio needs (#181) * Update install.sh * Create package.json * Create version.txt * Update version.txt * Update package.json * Update package.json * Update version.txt * Update package.json * Update version.txt * Update version.txt * Update package.json * Update release_zips.yml * 5.1.3.240229 * version 3.50103 * Update package.json * Update version.txt * Update version.txt * Update package.json --- .github/workflows/release_zips.yml | 4 ++-- install.sh | 4 ++-- package.json | 23 +++++++++++++++++++++++ version.txt | 1 + 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 package.json create mode 100644 version.txt diff --git a/.github/workflows/release_zips.yml b/.github/workflows/release_zips.yml index a88dd90128e8..ccce907041e8 100644 --- a/.github/workflows/release_zips.yml +++ b/.github/workflows/release_zips.yml @@ -10,8 +10,8 @@ jobs: name: Create release zip file runs-on: ubuntu-20.04 steps: - - name: Create a recursive clone source zip - uses: espressif/github-actions/release_zips@master + - name: Create a recursive clone source and stripped zip + uses: Jason2866/github-actions/release_zips@release_idf env: RELEASE_PROJECT_NAME: ESP-IDF GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/install.sh b/install.sh index 868665c527d5..46badce82a64 100755 --- a/install.sh +++ b/install.sh @@ -26,12 +26,12 @@ done TARGETS=$("${ESP_PYTHON}" "${IDF_PATH}/tools/install_util.py" extract targets "$@") echo "Installing ESP-IDF tools" -"${ESP_PYTHON}" "${IDF_PATH}/tools/idf_tools.py" install --targets="${TARGETS}" +"${ESP_PYTHON}" "${IDF_PATH}/tools/idf_tools.py" --non-interactive install --targets="${TARGETS}" FEATURES=$("${ESP_PYTHON}" "${IDF_PATH}/tools/install_util.py" extract features "$@") echo "Installing Python environment and packages" -"${ESP_PYTHON}" "${IDF_PATH}/tools/idf_tools.py" install-python-env --features="${FEATURES}" +"${ESP_PYTHON}" "${IDF_PATH}/tools/idf_tools.py" --non-interactive install-python-env --features="${FEATURES}" echo "All done! You can now run:" echo "" diff --git a/package.json b/package.json new file mode 100644 index 000000000000..ae0c9a2453db --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "framework-espidf", + "version": "3.50400", + "description": "Espressif IoT Development Framework. Tasmota development framework for ESP32 chip", + "keywords": [ + "framework", + "esp32", + "esp32s2", + "esp32s3", + "esp32c2", + "esp32c3", + "esp32c6", + "esp32h2", + "esp32p4", + "espressif" + ], + "homepage": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32/", + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "https://github.com/tasmota/esp-idf" + } +} diff --git a/version.txt b/version.txt new file mode 100644 index 000000000000..8a30e8f94a39 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +5.4.0 From 9b672a14213d28c78d8a020f8f381a9925e7826e Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 15 Sep 2024 17:08:27 +0200 Subject: [PATCH 02/11] Update package.json --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index ae0c9a2453db..7ace0df15b75 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "framework-espidf", "version": "3.50400", - "description": "Espressif IoT Development Framework. Tasmota development framework for ESP32 chip", + "description": "Espressif IoT Development Framework. Tasmota framework for ESP32 chip", "keywords": [ "framework", "esp32", @@ -9,7 +9,9 @@ "esp32s3", "esp32c2", "esp32c3", + "esp32c5", "esp32c6", + "esp32c61", "esp32h2", "esp32p4", "espressif" From 6e93f2a41d7af024ec6927fbbb6c748b19ef2f75 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 15 Sep 2024 17:10:09 +0200 Subject: [PATCH 03/11] Update version.txt --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 8a30e8f94a39..34e2d2b7129f 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -5.4.0 +5.4.0.240914 From 7b38ad34e02ce097b6b9a4b69211f2e4de14caf4 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 19 Sep 2024 22:52:05 +0200 Subject: [PATCH 04/11] Update version.txt --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 34e2d2b7129f..b5f1f55c1cd1 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -5.4.0.240914 +5.4.0.240918 From 188b30e0da7ba657965f2bc3fb45dfd2181d0890 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 19 Sep 2024 22:56:37 +0200 Subject: [PATCH 05/11] jl1101 --- components/esp_eth/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/esp_eth/CMakeLists.txt b/components/esp_eth/CMakeLists.txt index 132f01a30110..b432f557810f 100644 --- a/components/esp_eth/CMakeLists.txt +++ b/components/esp_eth/CMakeLists.txt @@ -34,7 +34,8 @@ if(CONFIG_ETH_ENABLED) "src/phy/esp_eth_phy_ip101.c" "src/phy/esp_eth_phy_ksz80xx.c" "src/phy/esp_eth_phy_lan87xx.c" - "src/phy/esp_eth_phy_rtl8201.c") + "src/phy/esp_eth_phy_rtl8201.c" + "src/phy/esp_eth_phy_jl1101.c") endif() if(CONFIG_ETH_SPI_ETHERNET_DM9051) From 9e0035356ea339858fe09ee6571f9a5fa08f4c7d Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 19 Sep 2024 22:59:06 +0200 Subject: [PATCH 06/11] add jl1101 --- components/esp_eth/include/esp_eth_phy.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/esp_eth/include/esp_eth_phy.h b/components/esp_eth/include/esp_eth_phy.h index 82c16aef41d0..5613b8749744 100644 --- a/components/esp_eth/include/esp_eth_phy.h +++ b/components/esp_eth/include/esp_eth_phy.h @@ -352,6 +352,17 @@ esp_eth_phy_t *esp_eth_phy_new_dp83848(const eth_phy_config_t *config); */ esp_eth_phy_t *esp_eth_phy_new_ksz80xx(const eth_phy_config_t *config); +/** +* @brief Create a PHY instance of JL1101 +* +* @param[in] config: configuration of PHY +* +* @return +* - instance: create PHY instance successfully +* - NULL: create PHY instance failed because some error occurred +*/ +esp_eth_phy_t *esp_eth_phy_new_jl1101(const eth_phy_config_t *config); + #if CONFIG_ETH_SPI_ETHERNET_DM9051 /** * @brief Create a PHY instance of DM9051 From 1e0893192340842bb6fabd8954196f26f2348b09 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 19 Sep 2024 23:01:05 +0200 Subject: [PATCH 07/11] Create esp_eth_phy_jl1101.c --- .../esp_eth/src/phy/esp_eth_phy_jl1101.c | 186 ++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 components/esp_eth/src/phy/esp_eth_phy_jl1101.c diff --git a/components/esp_eth/src/phy/esp_eth_phy_jl1101.c b/components/esp_eth/src/phy/esp_eth_phy_jl1101.c new file mode 100644 index 000000000000..512e5fe024f5 --- /dev/null +++ b/components/esp_eth/src/phy/esp_eth_phy_jl1101.c @@ -0,0 +1,186 @@ +/* + * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include "esp_log.h" +#include "esp_check.h" +#include "esp_eth_phy_802_3.h" + +static const char *TAG = "jl1101"; + +/***************Vendor Specific Register***************/ + +/** + * @brief PSMR(Power Saving Mode Register) + * + */ +typedef union { + struct { + uint16_t reserved : 15; /* Reserved */ + uint16_t en_pwr_save : 1; /* Enable power saving mode */ + }; + uint16_t val; +} psmr_reg_t; + +/** + * @brief PSR(Page Select Register) + * + */ +typedef union { + struct { + uint16_t page_select : 8; /* Select register page, default is 0 */ + uint16_t reserved : 8; /* Reserved */ + }; + uint16_t val; +} psr_reg_t; +#define ETH_PHY_PSR_REG_ADDR (0x1F) + +typedef struct { + phy_802_3_t phy_802_3; +} phy_jl1101_t; + +static esp_err_t jl1101_page_select(phy_jl1101_t *jl1101, uint32_t page) +{ + esp_err_t ret = ESP_OK; + esp_eth_mediator_t *eth = jl1101->phy_802_3.eth; + psr_reg_t psr = { + .page_select = page + }; + ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, jl1101->phy_802_3.addr, ETH_PHY_PSR_REG_ADDR, psr.val), err, TAG, "write PSR failed"); + return ESP_OK; +err: + return ret; +} + +static esp_err_t jl1101_update_link_duplex_speed(phy_jl1101_t *jl1101) +{ + esp_err_t ret = ESP_OK; + esp_eth_mediator_t *eth = jl1101->phy_802_3.eth; + uint32_t addr = jl1101->phy_802_3.addr; + eth_speed_t speed = ETH_SPEED_10M; + eth_duplex_t duplex = ETH_DUPLEX_HALF; + bmcr_reg_t bmcr; + bmsr_reg_t bmsr; + uint32_t peer_pause_ability = false; + anlpar_reg_t anlpar; + ESP_GOTO_ON_ERROR(jl1101_page_select(jl1101, 0), err, TAG, "select page 0 failed"); + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ETH_PHY_BMSR_REG_ADDR, &(bmsr.val)), err, TAG, "read BMSR failed"); + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ETH_PHY_ANLPAR_REG_ADDR, &(anlpar.val)), err, TAG, "read ANLPAR failed"); + eth_link_t link = bmsr.link_status ? ETH_LINK_UP : ETH_LINK_DOWN; + /* check if link status changed */ + if (jl1101->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_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); + if (bmcr.speed_select) { + speed = ETH_SPEED_100M; + } else { + speed = ETH_SPEED_10M; + } + if (bmcr.duplex_mode) { + duplex = ETH_DUPLEX_FULL; + } else { + duplex = 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 */ + if (duplex == ETH_DUPLEX_FULL && anlpar.symmetric_pause) { + peer_pause_ability = 1; + } else { + peer_pause_ability = 0; + } + ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_PAUSE, (void *)peer_pause_ability), err, TAG, "change pause ability failed"); + } + ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_LINK, (void *)link), err, TAG, "change link failed"); + jl1101->phy_802_3.link_status = link; + } + return ESP_OK; +err: + return ret; +} + +static esp_err_t jl1101_get_link(esp_eth_phy_t *phy) +{ + esp_err_t ret = ESP_OK; + phy_jl1101_t *jl1101 = __containerof(esp_eth_phy_into_phy_802_3(phy), phy_jl1101_t, phy_802_3); + /* Updata information about link, speed, duplex */ + ESP_GOTO_ON_ERROR(jl1101_update_link_duplex_speed(jl1101), err, TAG, "update link duplex speed failed"); + return ESP_OK; +err: + return ret; +} + +static esp_err_t jl1101_autonego_ctrl(esp_eth_phy_t *phy, eth_phy_autoneg_cmd_t cmd, bool *autonego_en_stat) +{ + esp_err_t ret = ESP_OK; + phy_802_3_t *phy_802_3 = esp_eth_phy_into_phy_802_3(phy); + esp_eth_mediator_t *eth = phy_802_3->eth; + if (cmd == ESP_ETH_PHY_AUTONEGO_EN) { + bmcr_reg_t bmcr; + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, phy_802_3->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); + ESP_GOTO_ON_FALSE(bmcr.en_loopback == 0, ESP_ERR_INVALID_STATE, err, TAG, "Autonegotiation can't be enabled while in loopback operation"); + } + return esp_eth_phy_802_3_autonego_ctrl(phy_802_3, cmd, autonego_en_stat); +err: + return ret; +} + +static esp_err_t jl1101_loopback(esp_eth_phy_t *phy, bool enable) +{ + esp_err_t ret = ESP_OK; + phy_802_3_t *phy_802_3 = esp_eth_phy_into_phy_802_3(phy); + bool auto_nego_en; + ESP_GOTO_ON_ERROR(jl1101_autonego_ctrl(phy, ESP_ETH_PHY_AUTONEGO_G_STAT, &auto_nego_en), err, TAG, "get status of autonegotiation failed"); + ESP_GOTO_ON_FALSE(!(auto_nego_en && enable), ESP_ERR_INVALID_STATE, err, TAG, "Unable to set loopback while autonegotiation is enabled. Disable it to use loopback"); + return esp_eth_phy_802_3_loopback(phy_802_3, enable); +err: + return ret; +} + +static esp_err_t jl1101_init(esp_eth_phy_t *phy) +{ + esp_err_t ret = ESP_OK; + phy_802_3_t *phy_802_3 = esp_eth_phy_into_phy_802_3(phy); + + /* Basic PHY init */ + ESP_GOTO_ON_ERROR(esp_eth_phy_802_3_basic_phy_init(phy_802_3), err, TAG, "failed to init PHY"); + + /* Check PHY ID */ + uint32_t oui; + uint8_t model; + ESP_GOTO_ON_ERROR(esp_eth_phy_802_3_read_oui(phy_802_3, &oui), err, TAG, "read OUI failed"); + ESP_GOTO_ON_ERROR(esp_eth_phy_802_3_read_manufac_info(phy_802_3, &model, NULL), err, TAG, "read manufacturer's info failed"); + ESP_GOTO_ON_FALSE(oui == 0x24DF10 && model == 0x2, ESP_FAIL, err, TAG, "wrong chip ID"); + + return ESP_OK; +err: + return ret; +} + +esp_eth_phy_t *esp_eth_phy_new_jl1101(const eth_phy_config_t *config) +{ + esp_eth_phy_t *ret = NULL; + phy_jl1101_t *jl1101 = calloc(1, sizeof(phy_jl1101_t)); + ESP_GOTO_ON_FALSE(jl1101, NULL, err, TAG, "calloc jl1101 failed"); + ESP_GOTO_ON_FALSE(esp_eth_phy_802_3_obj_config_init(&jl1101->phy_802_3, config) == ESP_OK, + NULL, err, TAG, "configuration initialization of PHY 802.3 failed"); + + // redefine functions which need to be customized for sake of jl1101 + jl1101->phy_802_3.parent.init = jl1101_init; + jl1101->phy_802_3.parent.get_link = jl1101_get_link; + jl1101->phy_802_3.parent.autonego_ctrl = jl1101_autonego_ctrl; + jl1101->phy_802_3.parent.loopback = jl1101_loopback; + + return &jl1101->phy_802_3.parent; +err: + if (jl1101 != NULL) { + free(jl1101); + } + return ret; +} From d548a6aa84dbcec10b2ff7a54e92c8769ea87f20 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 21 Sep 2024 18:00:42 +0200 Subject: [PATCH 08/11] align Warning settings with Arduino --- tools/cmake/build.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/cmake/build.cmake b/tools/cmake/build.cmake index e753f805902b..2ddc408ab5e4 100644 --- a/tools/cmake/build.cmake +++ b/tools/cmake/build.cmake @@ -129,13 +129,13 @@ function(__build_set_default_build_specifications) list(APPEND compile_options "-ffunction-sections" "-fdata-sections" # warning-related flags - "-Wall" - "-Werror" + # "-Wall" + # "-Werror" "-Wno-error=unused-function" "-Wno-error=unused-variable" "-Wno-error=unused-but-set-variable" "-Wno-error=deprecated-declarations" - "-Wextra" + # "-Wextra" "-Wno-error=extra" "-Wno-unused-parameter" "-Wno-sign-compare" From 2649838388dfca75ea73bbcdf2307bca68049c6d Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 21 Sep 2024 19:12:09 +0200 Subject: [PATCH 09/11] add option for LTO --- CMakeLists.txt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 20ef5b96896c..b3828bff0ce3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,6 +179,20 @@ if(CONFIG_COMPILER_DISABLE_GCC14_WARNINGS) list(APPEND compile_options "-Wno-calloc-transposed-args") endif() +if(CONFIG_COMPILER_ENABLE_LTO) + set(CMAKE_AR ${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar) + set(CMAKE_RANLIB ${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib) + list(APPEND compile_options "-flto=auto" + "-ffat-lto-objects" + "-flto-compression-level=9") + list(APPEND link_options "-flto" + "-fuse-linker-plugin" + "-ffat-lto-objects" + "-flto-partition=max") +else() + list(APPEND link_options "-fno-lto") +endif() + if(CONFIG_COMPILER_DISABLE_DEFAULT_ERRORS) if(NOT CMAKE_C_COMPILER_ID MATCHES "Clang") idf_build_replace_option_from_property(COMPILE_OPTIONS "-Werror" "-Werror=all") @@ -198,8 +212,6 @@ if(CONFIG_ESP_SYSTEM_USE_EH_FRAME) list(APPEND link_options "-Wl,--eh-frame-hdr") endif() -list(APPEND link_options "-fno-lto") - if(CONFIG_IDF_TARGET_LINUX AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") # Not all versions of the MacOS linker support the -warn_commons flag. # ld version 1053.12 (and above) have been tested to support it. From 65c0dc260db69bcdc5e2453da9b0b3d7679472ac Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 22 Sep 2024 15:45:17 +0200 Subject: [PATCH 10/11] Update version.txt --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index b5f1f55c1cd1..a4a2cb054b81 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -5.4.0.240918 +5.4.0.240921 From d70ed13f3adfa2bdc5958f6dad5e9539d3763253 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 1 Oct 2024 11:20:08 +0200 Subject: [PATCH 11/11] make sure no LTO is set --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b3828bff0ce3..6dcd0531efed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,7 +182,7 @@ endif() if(CONFIG_COMPILER_ENABLE_LTO) set(CMAKE_AR ${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar) set(CMAKE_RANLIB ${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib) - list(APPEND compile_options "-flto=auto" + list(APPEND compile_options "-flto=auto" "-ffat-lto-objects" "-flto-compression-level=9") list(APPEND link_options "-flto" @@ -190,6 +190,7 @@ if(CONFIG_COMPILER_ENABLE_LTO) "-ffat-lto-objects" "-flto-partition=max") else() + list(APPEND compile_options "-fno-lto") list(APPEND link_options "-fno-lto") endif()