From 43f3904304c3761cebb6e145645b7a3c7371a871 Mon Sep 17 00:00:00 2001 From: Ondrej Kosta Date: Fri, 13 May 2022 12:03:56 +0200 Subject: [PATCH 1/2] esp_eth: IEEE 802.3 PHY MII Management Interface functionality grouped to one common file --- components/esp_eth/CMakeLists.txt | 2 +- components/esp_eth/include/esp_eth_com.h | 13 - .../esp_eth/include/esp_eth_phy_802_3.h | 134 ++++++ ...phy_regs_struct.h => eth_phy_802_3_regs.h} | 24 +- components/esp_eth/src/esp_eth_phy_802_3.c | 430 ++++++++++++++++++ components/esp_eth/src/esp_eth_phy_dm9051.c | 362 ++------------- components/esp_eth/src/esp_eth_phy_dp83848.c | 360 ++------------- components/esp_eth/src/esp_eth_phy_ip101.c | 366 ++------------- components/esp_eth/src/esp_eth_phy_ksz80xx.c | 359 ++------------- components/esp_eth/src/esp_eth_phy_lan87xx.c | 363 ++------------- components/esp_eth/src/esp_eth_phy_rtl8201.c | 365 ++------------- components/esp_eth/src/esp_eth_phy_w5500.c | 2 +- docs/doxygen/Doxyfile | 2 + docs/en/api-reference/network/esp_eth.rst | 42 +- docs/en/migration-guides/ethernet.rst | 3 + docs/zh_CN/api-reference/network/esp_eth.rst | 2 +- .../eth_enc28j60/esp_eth_phy_enc28j60.c | 2 +- tools/ci/check_copyright_ignore.txt | 1 - 18 files changed, 839 insertions(+), 1993 deletions(-) create mode 100644 components/esp_eth/include/esp_eth_phy_802_3.h rename components/esp_eth/include/{eth_phy_regs_struct.h => eth_phy_802_3_regs.h} (90%) create mode 100644 components/esp_eth/src/esp_eth_phy_802_3.c diff --git a/components/esp_eth/CMakeLists.txt b/components/esp_eth/CMakeLists.txt index 5f2f506045..b5c0b9dcac 100644 --- a/components/esp_eth/CMakeLists.txt +++ b/components/esp_eth/CMakeLists.txt @@ -9,7 +9,7 @@ set(priv_requires driver log esp_timer) # If Ethernet disabled in Kconfig, this is a config-only component if(CONFIG_ETH_ENABLED) - set(srcs "src/esp_eth.c" "src/esp_eth_phy.c") + set(srcs "src/esp_eth.c" "src/esp_eth_phy_802_3.c") set(include "include") if(NOT CMAKE_BUILD_EARLY_EXPANSION) diff --git a/components/esp_eth/include/esp_eth_com.h b/components/esp_eth/include/esp_eth_com.h index bfbc197463..a81ac058fb 100644 --- a/components/esp_eth/include/esp_eth_com.h +++ b/components/esp_eth/include/esp_eth_com.h @@ -113,19 +113,6 @@ typedef enum { */ ESP_EVENT_DECLARE_BASE(ETH_EVENT); -/** -* @brief Detect PHY address -* -* @param[in] eth: mediator of Ethernet driver -* @param[out] detected_addr: a valid address after detection -* @return -* - ESP_OK: detect phy address successfully -* - ESP_ERR_INVALID_ARG: invalid parameter -* - ESP_ERR_NOT_FOUND: can't detect any PHY device -* - ESP_FAIL: detect phy address failed because some error occurred -*/ -esp_err_t esp_eth_detect_phy_addr(esp_eth_mediator_t *eth, int *detected_addr); - #ifdef __cplusplus } #endif diff --git a/components/esp_eth/include/esp_eth_phy_802_3.h b/components/esp_eth/include/esp_eth_phy_802_3.h new file mode 100644 index 0000000000..9b808044c8 --- /dev/null +++ b/components/esp_eth/include/esp_eth_phy_802_3.h @@ -0,0 +1,134 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#include +#include "esp_eth.h" +#include "sdkconfig.h" +#include "eth_phy_802_3_regs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief IEEE 802.3 PHY object infostructure + * + */ +typedef struct { + esp_eth_phy_t parent; /*!< Parent Ethernet PHY instance */ + esp_eth_mediator_t *eth; /*!< Mediator of Ethernet driver */ + int addr; /*!< PHY address */ + uint32_t reset_timeout_ms; /*!< Reset timeout value (Unit: ms) */ + uint32_t autonego_timeout_ms; /*!< Auto-negotiation timeout value (Unit: ms) */ + eth_link_t link_status; /*!< Current Link status */ + int reset_gpio_num; /*!< Reset GPIO number, -1 means no hardware reset */ +} phy_802_3_t; + +/** + * @brief Performs hardware reset with specific reset pin assertion time + * + * @param phy_802_3 IEEE 802.3 PHY object infostructure + * @param reset_assert_us Hardware reset pin assertion time + * @return + * - ESP_OK: reset Ethernet PHY successfully + */ +esp_err_t esp_eth_phy_802_3_reset_hw(phy_802_3_t *phy_802_3, uint32_t reset_assert_us); + +/** + * @brief Detect PHY address + * + * @param eth Mediator of Ethernet driver + * @param[out] detected_addr: a valid address after detection + * @return + * - ESP_OK: detect phy address successfully + * - ESP_ERR_INVALID_ARG: invalid parameter + * - ESP_ERR_NOT_FOUND: can't detect any PHY device + * - ESP_FAIL: detect phy address failed because some error occurred + */ +esp_err_t esp_eth_phy_802_3_detect_phy_addr(esp_eth_mediator_t *eth, int *detected_addr); + +/** + * @brief Performs basic PHY chip initialization + * + * @note It should be called as the first function in PHY specific driver instance + * + * @param phy_802_3 IEEE 802.3 PHY object infostructure + * @return + * - ESP_OK: initialized Ethernet PHY successfully + * - ESP_FAIL: initialization of Ethernet PHY failed because some error occurred + * - ESP_ERR_INVALID_ARG: invalid argument + * - ESP_ERR_NOT_FOUND: PHY device not detected + * - ESP_ERR_TIMEOUT: MII Management read/write operation timeout + * - ESP_ERR_INVALID_STATE: PHY is in invalid state to perform requested operation + */ +esp_err_t esp_eth_phy_802_3_basic_phy_init(phy_802_3_t *phy_802_3); + +/** + * @brief Performs basic PHY chip de-initialization + * + * @note It should be called as the last function in PHY specific driver instance + * + * @param phy_802_3 IEEE 802.3 PHY object infostructure + * @return + * - ESP_OK: de-initialized Ethernet PHY successfully + * - ESP_FAIL: de-initialization of Ethernet PHY failed because some error occurred + * - ESP_ERR_TIMEOUT: MII Management read/write operation timeout + * - ESP_ERR_INVALID_STATE: PHY is in invalid state to perform requested operation + */ +esp_err_t esp_eth_phy_802_3_basic_phy_deinit(phy_802_3_t *phy_802_3); + +/** + * @brief Reads raw content of OUI field + * + * @param phy_802_3 IEEE 802.3 PHY object infostructure + * @param[out] oui OUI value + * @return + * - ESP_OK: OUI field read successfully + * - ESP_FAIL: OUI field read failed because some error occurred + * - ESP_ERR_INVALID_ARG: invalid @c oui argument + * - ESP_ERR_TIMEOUT: MII Management read/write operation timeout + * - ESP_ERR_INVALID_STATE: PHY is in invalid state to perform requested operation + */ +esp_err_t esp_eth_phy_802_3_read_oui(phy_802_3_t *phy_802_3, uint32_t *oui); + +/** + * @brief Reads manufacturer’s model and revision number + * + * @param phy_802_3 IEEE 802.3 PHY object infostructure + * @param[out] model Manufacturer’s model number (can be NULL when not required) + * @param[out] rev Manufacturer’s revision number (can be NULL when not required) + * @return + * - ESP_OK: Manufacturer’s info read successfully + * - ESP_FAIL: Manufacturer’s info read failed because some error occurred + * - ESP_ERR_TIMEOUT: MII Management read/write operation timeout + * - ESP_ERR_INVALID_STATE: PHY is in invalid state to perform requested operation + */ +esp_err_t esp_eth_phy_802_3_read_manufac_info(phy_802_3_t *phy_802_3, uint8_t *model, uint8_t *rev); + +/** + * @brief Returns address to parent IEEE 802.3 PHY object infostructure + * + * @param phy Ethernet PHY instance + * @return phy_802_3_t* + * - address to parent IEEE 802.3 PHY object infostructure + */ +phy_802_3_t *esp_eth_phy_into_phy_802_3(esp_eth_phy_t *phy); + +/** + * @brief Initializes configuration of parent IEEE 802.3 PHY object infostructure + * + * @param phy_802_3 Address to IEEE 802.3 PHY object infostructure + * @param config Configuration of the IEEE 802.3 PHY object + * @return + * - ESP_OK: configuration initialized successfully + * - ESP_ERR_INVALID_ARG: invalid @c config argument + */ +esp_err_t esp_eth_phy_802_3_obj_config_init(phy_802_3_t *phy_802_3, const eth_phy_config_t *config); + +#ifdef __cplusplus +} +#endif diff --git a/components/esp_eth/include/eth_phy_regs_struct.h b/components/esp_eth/include/eth_phy_802_3_regs.h similarity index 90% rename from components/esp_eth/include/eth_phy_regs_struct.h rename to components/esp_eth/include/eth_phy_802_3_regs.h index e725333e52..d953ea09d0 100644 --- a/components/esp_eth/include/eth_phy_regs_struct.h +++ b/components/esp_eth/include/eth_phy_802_3_regs.h @@ -1,16 +1,8 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once #include @@ -19,7 +11,11 @@ extern "C" { #endif -/******************Basic PHY Registers*******************/ +/** + * + * This file defines basic PHY registers in compliance to IEEE 802.3, 22.2.4 Management functions section. + * + */ /** * @brief BMCR(Basic Mode Control Register) diff --git a/components/esp_eth/src/esp_eth_phy_802_3.c b/components/esp_eth/src/esp_eth_phy_802_3.c new file mode 100644 index 0000000000..5a315451f4 --- /dev/null +++ b/components/esp_eth/src/esp_eth_phy_802_3.c @@ -0,0 +1,430 @@ +/* + * SPDX-FileCopyrightText: 2022 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.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "driver/gpio.h" +#include "esp_rom_gpio.h" +#include "esp_rom_sys.h" +#include "esp_eth_phy_802_3.h" + +static const char *TAG = "eth_phy_802_3"; + +static esp_err_t eth_phy_802_3_set_mediator(esp_eth_phy_t *phy, esp_eth_mediator_t *eth) +{ + esp_err_t ret = ESP_OK; + phy_802_3_t *phy_802_3 = __containerof(phy, phy_802_3_t, parent); + ESP_GOTO_ON_FALSE(eth, ESP_ERR_INVALID_ARG, err, TAG, "mediator can't be null"); + phy_802_3->eth = eth; + return ESP_OK; +err: + return ret; +} + +static esp_err_t eth_phy_802_3_reset(esp_eth_phy_t *phy) +{ + esp_err_t ret = ESP_OK; + phy_802_3_t *phy_802_3 = __containerof(phy, phy_802_3_t, parent); + phy_802_3->link_status = ETH_LINK_DOWN; + esp_eth_mediator_t *eth = phy_802_3->eth; + bmcr_reg_t bmcr = {.reset = 1}; + ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, phy_802_3->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); + /* wait for reset complete */ + uint32_t to = 0; + for (to = 0; to < phy_802_3->reset_timeout_ms / 10; to++) { + vTaskDelay(pdMS_TO_TICKS(10)); + 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"); + if (!bmcr.reset) { + break; + } + } + ESP_GOTO_ON_FALSE(to < phy_802_3->reset_timeout_ms / 10, ESP_FAIL, err, TAG, "reset timeout"); + return ESP_OK; +err: + return ret; +} + +/** + * @brief PHY hardware reset with default assert time + * + * @note Default reset assertion time is selected to be 100us as it is most commonly used value among PHY chips. + * If your PHY chip requires different value, redefine the `reset_hw` function in derived PHY specific driver structure. + * + * @param phy Ethernet PHY instance + * @return + * - ESP_OK on success + */ +static esp_err_t eth_phy_802_3_reset_hw_default(esp_eth_phy_t *phy) +{ + phy_802_3_t *phy_802_3 = __containerof(phy, phy_802_3_t, parent); + return esp_eth_phy_802_3_reset_hw(phy_802_3, 100); +} + +static esp_err_t eth_phy_802_3_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 = __containerof(phy, phy_802_3_t, parent); + esp_eth_mediator_t *eth = phy_802_3->eth; + + 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"); + + switch (cmd) { + case ESP_ETH_PHY_AUTONEGO_RESTART: + ESP_GOTO_ON_FALSE(bmcr.en_auto_nego, ESP_ERR_INVALID_STATE, err, TAG, "auto negotiation is disabled"); + /* in case any link status has changed, let's assume we're in link down status */ + phy_802_3->link_status = ETH_LINK_DOWN; + + bmcr.restart_auto_nego = 1; /* Restart Auto Negotiation */ + + ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, phy_802_3->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); + /* Wait for auto negotiation complete */ + bmsr_reg_t bmsr; + uint32_t to = 0; + for (to = 0; to < phy_802_3->autonego_timeout_ms / 100; to++) { + vTaskDelay(pdMS_TO_TICKS(100)); + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, phy_802_3->addr, ETH_PHY_BMSR_REG_ADDR, &(bmsr.val)), err, TAG, "read BMSR failed"); + if (bmsr.auto_nego_complete) { + break; + } + } + if ((to >= phy_802_3->autonego_timeout_ms / 100) && (phy_802_3->link_status == ETH_LINK_UP)) { + ESP_LOGW(TAG, "auto negotiation timeout"); + } + break; + case ESP_ETH_PHY_AUTONEGO_DIS: + if (bmcr.en_auto_nego == 1) { + bmcr.en_auto_nego = 0; /* Disable Auto Negotiation */ + ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, phy_802_3->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); + /* read configuration back */ + 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_auto_nego == 0, ESP_FAIL, err, TAG, "disable auto-negotiation failed"); + } + break; + case ESP_ETH_PHY_AUTONEGO_EN: + if (bmcr.en_auto_nego == 0) { + bmcr.en_auto_nego = 1; /* Enable Auto Negotiation */ + ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, phy_802_3->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); + /* read configuration back */ + 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_auto_nego == 1, ESP_FAIL, err, TAG, "enable auto-negotiation failed"); + } + break; + case ESP_ETH_PHY_AUTONEGO_G_STAT: + /* do nothing autonego_en_stat is set at the function end */ + break; + default: + return ESP_ERR_INVALID_ARG; + } + + *autonego_en_stat = bmcr.en_auto_nego; + return ESP_OK; +err: + return ret; +} + +static esp_err_t eth_phy_802_3_pwrctl(esp_eth_phy_t *phy, bool enable) +{ + esp_err_t ret = ESP_OK; + phy_802_3_t *phy_802_3 = __containerof(phy, phy_802_3_t, parent); + esp_eth_mediator_t *eth = phy_802_3->eth; + 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"); + if (!enable) { + /* Enable IEEE Power Down Mode */ + bmcr.power_down = 1; + } else { + /* Disable IEEE Power Down Mode */ + bmcr.power_down = 0; + } + ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, phy_802_3->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); + if (!enable) { + 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.power_down == 1, ESP_FAIL, err, TAG, "power down failed"); + } else { + /* wait for power up complete */ + uint32_t to = 0; + for (to = 0; to < phy_802_3->reset_timeout_ms / 10; to++) { + vTaskDelay(pdMS_TO_TICKS(10)); + 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"); + if (bmcr.power_down == 0) { + break; + } + } + ESP_GOTO_ON_FALSE(to < phy_802_3->reset_timeout_ms / 10, ESP_FAIL, err, TAG, "power up timeout"); + } + return ESP_OK; +err: + return ret; +} + +static esp_err_t eth_phy_802_3_set_addr(esp_eth_phy_t *phy, uint32_t addr) +{ + phy_802_3_t *phy_802_3 = __containerof(phy, phy_802_3_t, parent); + phy_802_3->addr = addr; + return ESP_OK; +} + +static esp_err_t eth_phy_802_3_get_addr(esp_eth_phy_t *phy, uint32_t *addr) +{ + esp_err_t ret = ESP_OK; + phy_802_3_t *phy_802_3 = __containerof(phy, phy_802_3_t, parent); + ESP_GOTO_ON_FALSE(addr, ESP_ERR_INVALID_ARG, err, TAG, "addr can't be null"); + *addr = phy_802_3->addr; + return ESP_OK; +err: + return ret; +} + +static esp_err_t eth_phy_802_3_advertise_pause_ability(esp_eth_phy_t *phy, uint32_t ability) +{ + esp_err_t ret = ESP_OK; + phy_802_3_t *phy_802_3 = __containerof(phy, phy_802_3_t, parent); + esp_eth_mediator_t *eth = phy_802_3->eth; + /* Set PAUSE function ability */ + anar_reg_t anar; + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, phy_802_3->addr, ETH_PHY_ANAR_REG_ADDR, &(anar.val)), err, TAG, "read ANAR failed"); + if (ability) { + anar.asymmetric_pause = 1; + anar.symmetric_pause = 1; + } else { + anar.asymmetric_pause = 0; + anar.symmetric_pause = 0; + } + ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, phy_802_3->addr, ETH_PHY_ANAR_REG_ADDR, anar.val), err, TAG, "write ANAR failed"); + return ESP_OK; +err: + return ret; +} + +static esp_err_t eth_phy_802_3_loopback(esp_eth_phy_t *phy, bool enable) +{ + esp_err_t ret = ESP_OK; + phy_802_3_t *phy_802_3 = __containerof(phy, phy_802_3_t, parent); + esp_eth_mediator_t *eth = phy_802_3->eth; + /* Set Loopback function */ + 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"); + if (enable) { + bmcr.en_loopback = 1; + } else { + bmcr.en_loopback = 0; + } + ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, phy_802_3->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); + return ESP_OK; +err: + return ret; +} + +static esp_err_t eth_phy_802_3_set_speed(esp_eth_phy_t *phy, eth_speed_t speed) +{ + esp_err_t ret = ESP_OK; + phy_802_3_t *phy_802_3 = __containerof(phy, phy_802_3_t, parent); + esp_eth_mediator_t *eth = phy_802_3->eth; + + if (phy_802_3->link_status == ETH_LINK_UP) { + /* Since the link is going to be reconfigured, consider it down for a while */ + phy_802_3->link_status = ETH_LINK_DOWN; + /* Indicate to upper stream apps the link is cosidered down */ + ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_LINK, (void *)phy_802_3->link_status), err, TAG, "change link failed"); + } + /* Set speed */ + 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"); + bmcr.speed_select = speed == ETH_SPEED_100M ? 1 : 0; + ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, phy_802_3->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); + + return ESP_OK; +err: + return ret; +} + +static esp_err_t eth_phy_802_3_set_duplex(esp_eth_phy_t *phy, eth_duplex_t duplex) +{ + esp_err_t ret = ESP_OK; + phy_802_3_t *phy_802_3 = __containerof(phy, phy_802_3_t, parent); + esp_eth_mediator_t *eth = phy_802_3->eth; + + if (phy_802_3->link_status == ETH_LINK_UP) { + /* Since the link is going to be reconfigured, consider it down for a while */ + phy_802_3->link_status = ETH_LINK_DOWN; + /* Indicate to upper stream apps the link is cosidered down */ + ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_LINK, (void *)phy_802_3->link_status), err, TAG, "change link failed"); + } + /* Set duplex mode */ + 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"); + bmcr.duplex_mode = duplex; + ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, phy_802_3->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); + + return ESP_OK; +err: + return ret; +} + +static esp_err_t eth_phy_802_3_init(esp_eth_phy_t *phy) +{ + phy_802_3_t *phy_802_3 = __containerof(phy, phy_802_3_t, parent); + return esp_eth_phy_802_3_basic_phy_init(phy_802_3); +} + +static esp_err_t eth_phy_802_3_deinit(esp_eth_phy_t *phy) +{ + phy_802_3_t *phy_802_3 = __containerof(phy, phy_802_3_t, parent); + return esp_eth_phy_802_3_basic_phy_deinit(phy_802_3); +} + +static esp_err_t eth_phy_802_3_del(esp_eth_phy_t *phy) +{ + free(phy); + return ESP_OK; +} + +esp_err_t esp_eth_phy_802_3_reset_hw(phy_802_3_t *phy_802_3, uint32_t reset_assert_us) +{ + if (phy_802_3->reset_gpio_num >= 0) { + esp_rom_gpio_pad_select_gpio(phy_802_3->reset_gpio_num); + gpio_set_direction(phy_802_3->reset_gpio_num, GPIO_MODE_OUTPUT); + gpio_set_level(phy_802_3->reset_gpio_num, 0); + esp_rom_delay_us(reset_assert_us); + gpio_set_level(phy_802_3->reset_gpio_num, 1); + } + return ESP_OK; +} + +esp_err_t esp_eth_phy_802_3_detect_phy_addr(esp_eth_mediator_t *eth, int *detected_addr) +{ + if (!eth || !detected_addr) { + ESP_LOGE(TAG, "eth and detected_addr can't be null"); + return ESP_ERR_INVALID_ARG; + } + 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; + } + } + 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; +} + +esp_err_t esp_eth_phy_802_3_basic_phy_init(phy_802_3_t *phy_802_3) +{ + esp_err_t ret = ESP_OK; + + // Detect PHY address + if (phy_802_3->addr == ESP_ETH_PHY_ADDR_AUTO) { + ESP_GOTO_ON_ERROR(esp_eth_phy_802_3_detect_phy_addr(phy_802_3->eth, &phy_802_3->addr), err, TAG, "Detect PHY address failed"); + } + /* Power on Ethernet PHY */ + ESP_GOTO_ON_ERROR(eth_phy_802_3_pwrctl(&phy_802_3->parent, true), err, TAG, "power control failed"); + /* Reset Ethernet PHY */ + ESP_GOTO_ON_ERROR(eth_phy_802_3_reset(&phy_802_3->parent), err, TAG, "reset failed"); + + return ESP_OK; +err: + return ret; +} + +esp_err_t esp_eth_phy_802_3_basic_phy_deinit(phy_802_3_t *phy_802_3) +{ + esp_err_t ret = ESP_OK; + /* Power off Ethernet PHY */ + ESP_GOTO_ON_ERROR(eth_phy_802_3_pwrctl(&phy_802_3->parent, false), err, TAG, "power control failed"); + return ESP_OK; +err: + return ret; +} + +esp_err_t esp_eth_phy_802_3_read_oui(phy_802_3_t *phy_802_3, uint32_t *oui) +{ + esp_err_t ret = ESP_OK; + esp_eth_mediator_t *eth = phy_802_3->eth; + phyidr1_reg_t id1; + phyidr2_reg_t id2; + + ESP_GOTO_ON_FALSE(oui != NULL, ESP_ERR_INVALID_ARG, err, TAG, "oui can't be null"); + + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, phy_802_3->addr, ETH_PHY_IDR1_REG_ADDR, &(id1.val)), err, TAG, "read ID1 failed"); + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, phy_802_3->addr, ETH_PHY_IDR2_REG_ADDR, &(id2.val)), err, TAG, "read ID2 failed"); + + *oui = (id1.oui_msb << 6) | id2.oui_lsb; + + return ESP_OK; +err: + return ret; +} + +esp_err_t esp_eth_phy_802_3_read_manufac_info(phy_802_3_t *phy_802_3, uint8_t *model, uint8_t *rev) +{ + esp_err_t ret = ESP_OK; + esp_eth_mediator_t *eth = phy_802_3->eth; + + phyidr2_reg_t id2; + + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, phy_802_3->addr, ETH_PHY_IDR2_REG_ADDR, &(id2.val)), err, TAG, "read ID2 failed"); + + if (model != NULL) { + *model = id2.vendor_model; + } + if (rev != NULL) { + *rev = id2.model_revision; + } + + return ESP_OK; +err: + return ret; +} + +phy_802_3_t *esp_eth_phy_into_phy_802_3(esp_eth_phy_t *phy) +{ + return __containerof(phy, phy_802_3_t, parent); +} + +esp_err_t esp_eth_phy_802_3_obj_config_init(phy_802_3_t *phy_802_3, const eth_phy_config_t *config) +{ + esp_err_t ret = ESP_OK; + + ESP_GOTO_ON_FALSE(config, ESP_ERR_INVALID_ARG, err, TAG, "can't set phy config to null"); + + phy_802_3->link_status = ETH_LINK_DOWN; + phy_802_3->addr = config->phy_addr; + phy_802_3->reset_timeout_ms = config->reset_timeout_ms; + phy_802_3->reset_gpio_num = config->reset_gpio_num; + phy_802_3->autonego_timeout_ms = config->autonego_timeout_ms; + + phy_802_3->parent.reset = eth_phy_802_3_reset; + phy_802_3->parent.reset_hw = eth_phy_802_3_reset_hw_default; + phy_802_3->parent.init = eth_phy_802_3_init; + phy_802_3->parent.deinit = eth_phy_802_3_deinit; + phy_802_3->parent.set_mediator = eth_phy_802_3_set_mediator; + phy_802_3->parent.autonego_ctrl = eth_phy_802_3_autonego_ctrl; + phy_802_3->parent.pwrctl = eth_phy_802_3_pwrctl; + phy_802_3->parent.get_addr = eth_phy_802_3_get_addr; + phy_802_3->parent.set_addr = eth_phy_802_3_set_addr; + phy_802_3->parent.advertise_pause_ability = eth_phy_802_3_advertise_pause_ability; + phy_802_3->parent.loopback = eth_phy_802_3_loopback; + phy_802_3->parent.set_speed = eth_phy_802_3_set_speed; + phy_802_3->parent.set_duplex = eth_phy_802_3_set_duplex; + phy_802_3->parent.del = eth_phy_802_3_del; + phy_802_3->parent.get_link = NULL; + phy_802_3->parent.custom_ioctl = NULL; + +err: + return ret; +} diff --git a/components/esp_eth/src/esp_eth_phy_dm9051.c b/components/esp_eth/src/esp_eth_phy_dm9051.c index 5d30d65520..3f711854e8 100644 --- a/components/esp_eth/src/esp_eth_phy_dm9051.c +++ b/components/esp_eth/src/esp_eth_phy_dm9051.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,13 +8,9 @@ #include #include "esp_log.h" #include "esp_check.h" -#include "esp_eth_driver.h" -#include "eth_phy_regs_struct.h" +#include "esp_eth_phy_802_3.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" -#include "driver/gpio.h" -#include "esp_rom_gpio.h" -#include "esp_rom_sys.h" static const char *TAG = "dm9051.phy"; @@ -64,19 +60,14 @@ typedef union { #define ETH_PHY_DSCSR_REG_ADDR (0x11) typedef struct { - esp_eth_phy_t parent; - esp_eth_mediator_t *eth; - int addr; - uint32_t reset_timeout_ms; - uint32_t autonego_timeout_ms; - eth_link_t link_status; - int reset_gpio_num; + phy_802_3_t phy_802_3; } phy_dm9051_t; static esp_err_t dm9051_update_link_duplex_speed(phy_dm9051_t *dm9051) { esp_err_t ret = ESP_OK; - esp_eth_mediator_t *eth = dm9051->eth; + esp_eth_mediator_t *eth = dm9051->phy_802_3.eth; + uint32_t addr = dm9051->phy_802_3.addr; eth_speed_t speed = ETH_SPEED_10M; eth_duplex_t duplex = ETH_DUPLEX_HALF; uint32_t peer_pause_ability = false; @@ -86,15 +77,15 @@ static esp_err_t dm9051_update_link_duplex_speed(phy_dm9051_t *dm9051) // BMSR is a latch low register // after power up, the first latched value must be 0, which means down // to speed up power up link speed, double read this register as a workaround - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_BMSR_REG_ADDR, &(bmsr.val)), err, TAG, "read BMSR failed"); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_BMSR_REG_ADDR, &(bmsr.val)), err, TAG, "read BMSR failed"); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_ANLPAR_REG_ADDR, &(anlpar.val)), err, TAG, "read ANLPAR 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_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 (dm9051->link_status != link) { + 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, dm9051->addr, ETH_PHY_DSCSR_REG_ADDR, &(dscsr.val)), err, TAG, "read DSCSR failed"); + 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 { @@ -116,28 +107,17 @@ static esp_err_t dm9051_update_link_duplex_speed(phy_dm9051_t *dm9051) 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"); - dm9051->link_status = link; + dm9051->phy_802_3.link_status = link; } return ESP_OK; err: return ret; } -static esp_err_t dm9051_set_mediator(esp_eth_phy_t *phy, esp_eth_mediator_t *eth) -{ - esp_err_t ret = ESP_OK; - ESP_GOTO_ON_FALSE(eth, ESP_ERR_INVALID_ARG, err, TAG, "can't set mediator to null"); - phy_dm9051_t *dm9051 = __containerof(phy, phy_dm9051_t, parent); - dm9051->eth = eth; - return ESP_OK; -err: - return ret; -} - static esp_err_t dm9051_get_link(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; - phy_dm9051_t *dm9051 = __containerof(phy, phy_dm9051_t, parent); + phy_dm9051_t *dm9051 = __containerof(esp_eth_phy_into_phy_802_3(phy), phy_dm9051_t, phy_802_3); /* Update information about link, speed, duplex */ ESP_GOTO_ON_ERROR(dm9051_update_link_duplex_speed(dm9051), err, TAG, "update link duplex speed failed"); return ESP_OK; @@ -148,253 +128,27 @@ err: static esp_err_t dm9051_reset(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; - phy_dm9051_t *dm9051 = __containerof(phy, phy_dm9051_t, parent); - dm9051->link_status = ETH_LINK_DOWN; - esp_eth_mediator_t *eth = dm9051->eth; + phy_dm9051_t *dm9051 = __containerof(esp_eth_phy_into_phy_802_3(phy), phy_dm9051_t, phy_802_3); + uint32_t addr = dm9051->phy_802_3.addr; + dm9051->phy_802_3.link_status = ETH_LINK_DOWN; + esp_eth_mediator_t *eth = dm9051->phy_802_3.eth; dscr_reg_t dscr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_DSCR_REG_ADDR, &(dscr.val)), err, TAG, "read DSCR failed"); + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ETH_PHY_DSCR_REG_ADDR, &(dscr.val)), err, TAG, "read DSCR failed"); dscr.smrst = 1; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dm9051->addr, ETH_PHY_DSCR_REG_ADDR, dscr.val), err, TAG, "write DSCR failed"); + ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, addr, ETH_PHY_DSCR_REG_ADDR, dscr.val), err, TAG, "write DSCR failed"); bmcr_reg_t bmcr = {.reset = 1}; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dm9051->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); + ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); /* Wait for reset complete */ uint32_t to = 0; - for (to = 0; to < dm9051->reset_timeout_ms / 10; to++) { + for (to = 0; to < dm9051->phy_802_3.reset_timeout_ms / 10; to++) { vTaskDelay(pdMS_TO_TICKS(10)); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_DSCR_REG_ADDR, &(dscr.val)), err, TAG, "read DSCR failed"); + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ETH_PHY_DSCR_REG_ADDR, &(dscr.val)), err, TAG, "read DSCR failed"); if (!bmcr.reset && !dscr.smrst) { break; } } - ESP_GOTO_ON_FALSE(to < dm9051->reset_timeout_ms / 10, ESP_FAIL, err, TAG, "PHY reset timeout"); - return ESP_OK; -err: - return ret; -} - -static esp_err_t dm9051_reset_hw(esp_eth_phy_t *phy) -{ - phy_dm9051_t *dm9051 = __containerof(phy, phy_dm9051_t, parent); - // set reset_gpio_num minus zero can skip hardware reset phy chip - if (dm9051->reset_gpio_num >= 0) { - esp_rom_gpio_pad_select_gpio(dm9051->reset_gpio_num); - gpio_set_direction(dm9051->reset_gpio_num, GPIO_MODE_OUTPUT); - gpio_set_level(dm9051->reset_gpio_num, 0); - esp_rom_delay_us(100); // insert min input assert time - gpio_set_level(dm9051->reset_gpio_num, 1); - } - return ESP_OK; -} - -/** - * @note This function is responsible for restarting a new auto-negotiation, - * the result of negotiation won't be relected to uppler layers. - * Instead, the negotiation result is fetched by linker timer, see `dm9051_get_link()` - */ -static esp_err_t dm9051_autonego_ctrl(esp_eth_phy_t *phy, eth_phy_autoneg_cmd_t cmd, bool *autonego_en_stat) -{ - esp_err_t ret = ESP_OK; - phy_dm9051_t *dm9051 = __containerof(phy, phy_dm9051_t, parent); - esp_eth_mediator_t *eth = dm9051->eth; - - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - - switch (cmd) { - case ESP_ETH_PHY_AUTONEGO_RESTART: - ESP_GOTO_ON_FALSE(bmcr.en_auto_nego, ESP_ERR_INVALID_STATE, err, TAG, "auto negotiation is disabled"); - /* in case any link status has changed, let's assume we're in link down status */ - dm9051->link_status = ETH_LINK_DOWN; - - bmcr.restart_auto_nego = 1; /* Restart Auto Negotiation */ - - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dm9051->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* Wait for auto negotiation complete */ - bmsr_reg_t bmsr; - uint32_t to = 0; - for (to = 0; to < dm9051->autonego_timeout_ms / 100; to++) { - vTaskDelay(pdMS_TO_TICKS(100)); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_BMSR_REG_ADDR, &(bmsr.val)), err, TAG, "read BMSR failed"); - if (bmsr.auto_nego_complete) { - break; - } - } - if ((to >= dm9051->autonego_timeout_ms / 100) && (dm9051->link_status == ETH_LINK_UP)) { - ESP_LOGW(TAG, "auto negotiation timeout"); - } - break; - case ESP_ETH_PHY_AUTONEGO_DIS: - if (bmcr.en_auto_nego == 1) { - bmcr.en_auto_nego = 0; /* Disable Auto Negotiation */ - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dm9051->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* read configuration back */ - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_FALSE(bmcr.en_auto_nego == 0, ESP_FAIL, err, TAG, "disable auto-negotiation failed"); - } - break; - case ESP_ETH_PHY_AUTONEGO_EN: - if (bmcr.en_auto_nego == 0) { - bmcr.en_auto_nego = 1; /* Enable Auto Negotiation */ - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dm9051->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* read configuration back */ - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_FALSE(bmcr.en_auto_nego == 1, ESP_FAIL, err, TAG, "enable auto-negotiation failed"); - } - break; - case ESP_ETH_PHY_AUTONEGO_G_STAT: - /* do nothing autonego_en_stat is set at the function end */ - break; - default: - return ESP_ERR_INVALID_ARG; - } - - *autonego_en_stat = bmcr.en_auto_nego; - return ESP_OK; -err: - return ret; -} - -static esp_err_t dm9051_pwrctl(esp_eth_phy_t *phy, bool enable) -{ - esp_err_t ret = ESP_OK; - phy_dm9051_t *dm9051 = __containerof(phy, phy_dm9051_t, parent); - esp_eth_mediator_t *eth = dm9051->eth; - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (!enable) { - /* Enable IEEE Power Down Mode */ - bmcr.power_down = 1; - } else { - /* Disable IEEE Power Down Mode */ - bmcr.power_down = 0; - } - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dm9051->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - if (!enable) { - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_FALSE(bmcr.power_down == 1, ESP_FAIL, err, TAG, "power down failed"); - } else { - /* wait for power up complete */ - uint32_t to = 0; - for (to = 0; to < dm9051->reset_timeout_ms / 10; to++) { - vTaskDelay(pdMS_TO_TICKS(10)); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (bmcr.power_down == 0) { - break; - } - } - ESP_GOTO_ON_FALSE(to < dm9051->reset_timeout_ms / 10, ESP_FAIL, err, TAG, "power up timeout"); - } - return ESP_OK; -err: - return ret; -} - -static esp_err_t dm9051_set_addr(esp_eth_phy_t *phy, uint32_t addr) -{ - phy_dm9051_t *dm9051 = __containerof(phy, phy_dm9051_t, parent); - dm9051->addr = addr; - return ESP_OK; -} - -static esp_err_t dm9051_get_addr(esp_eth_phy_t *phy, uint32_t *addr) -{ - esp_err_t ret = ESP_OK; - ESP_GOTO_ON_FALSE(addr, ESP_ERR_INVALID_ARG, err, TAG, "addr can't be null"); - phy_dm9051_t *dm9051 = __containerof(phy, phy_dm9051_t, parent); - *addr = dm9051->addr; - return ESP_OK; -err: - return ret; -} - -static esp_err_t dm9051_del(esp_eth_phy_t *phy) -{ - phy_dm9051_t *dm9051 = __containerof(phy, phy_dm9051_t, parent); - free(dm9051); - return ESP_OK; -} - -static esp_err_t dm9051_advertise_pause_ability(esp_eth_phy_t *phy, uint32_t ability) -{ - esp_err_t ret = ESP_OK; - phy_dm9051_t *dm9051 = __containerof(phy, phy_dm9051_t, parent); - esp_eth_mediator_t *eth = dm9051->eth; - /* Set PAUSE function ability */ - anar_reg_t anar; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_ANAR_REG_ADDR, &(anar.val)), err, TAG, "read ANAR failed"); - if (ability) { - anar.asymmetric_pause = 1; - anar.symmetric_pause = 1; - } else { - anar.asymmetric_pause = 0; - anar.symmetric_pause = 0; - } - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dm9051->addr, ETH_PHY_ANAR_REG_ADDR, anar.val), err, TAG, "write ANAR failed"); - return ESP_OK; -err: - return ret; -} - -static esp_err_t dm9051_loopback(esp_eth_phy_t *phy, bool enable) -{ - esp_err_t ret = ESP_OK; - phy_dm9051_t *dm9051 = __containerof(phy, phy_dm9051_t, parent); - esp_eth_mediator_t *eth = dm9051->eth; - /* Set Loopback function */ - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (enable) { - bmcr.en_loopback = 1; - } else { - bmcr.en_loopback = 0; - } - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dm9051->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - return ESP_OK; -err: - return ret; -} - -static esp_err_t dm9051_set_speed(esp_eth_phy_t *phy, eth_speed_t speed) -{ - esp_err_t ret = ESP_OK; - phy_dm9051_t *dm9051 = __containerof(phy, phy_dm9051_t, parent); - esp_eth_mediator_t *eth = dm9051->eth; - if (dm9051->link_status == ETH_LINK_UP) { - /* Since the link is going to be reconfigured, consider it down for a while */ - dm9051->link_status = ETH_LINK_DOWN; - /* Indicate to upper stream apps the link is cosidered down */ - ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_LINK, (void *)dm9051->link_status), err, TAG, "change link failed"); - } - /* Set speed */ - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - bmcr.speed_select = speed; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dm9051->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - - return ESP_OK; -err: - return ret; -} - -static esp_err_t dm9051_set_duplex(esp_eth_phy_t *phy, eth_duplex_t duplex) -{ - esp_err_t ret = ESP_OK; - phy_dm9051_t *dm9051 = __containerof(phy, phy_dm9051_t, parent); - esp_eth_mediator_t *eth = dm9051->eth; - - if (dm9051->link_status == ETH_LINK_UP) { - /* Since the link is going to be reconfigured, consider it down for a while */ - dm9051->link_status = ETH_LINK_DOWN; - /* Indicate to upper stream apps the link is cosidered down */ - ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_LINK, (void *)dm9051->link_status), err, TAG, "change link failed"); - } - /* Set duplex mode */ - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - bmcr.duplex_mode = duplex; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dm9051->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - + ESP_GOTO_ON_FALSE(to < dm9051->phy_802_3.reset_timeout_ms / 10, ESP_FAIL, err, TAG, "PHY reset timeout"); return ESP_OK; err: return ret; @@ -403,32 +157,18 @@ err: static esp_err_t dm9051_init(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; - phy_dm9051_t *dm9051 = __containerof(phy, phy_dm9051_t, parent); - esp_eth_mediator_t *eth = dm9051->eth; - // Detect PHY address - if (dm9051->addr == ESP_ETH_PHY_ADDR_AUTO) { - ESP_GOTO_ON_ERROR(esp_eth_detect_phy_addr(eth, &dm9051->addr), err, TAG, "Detect PHY address failed"); - } - /* Power on Ethernet PHY */ - ESP_GOTO_ON_ERROR(dm9051_pwrctl(phy, true), err, TAG, "power control failed"); - /* Reset Ethernet PHY */ - ESP_GOTO_ON_ERROR(dm9051_reset(phy), err, TAG, "reset failed"); - /* Check PHY ID */ - phyidr1_reg_t id1; - phyidr2_reg_t id2; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_IDR1_REG_ADDR, &(id1.val)), err, TAG, "read ID1 failed"); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dm9051->addr, ETH_PHY_IDR2_REG_ADDR, &(id2.val)), err, TAG, "read ID2 failed"); - ESP_GOTO_ON_FALSE(id1.oui_msb == 0x0181 && id2.oui_lsb == 0x2E && id2.vendor_model == 0x0A, ESP_FAIL, err, TAG, "wrong chip ID"); - return ESP_OK; -err: - return ret; -} + 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 == 0x606E && model == 0x0A, ESP_FAIL, err, TAG, "wrong chip ID"); -static esp_err_t dm9051_deinit(esp_eth_phy_t *phy) -{ - esp_err_t ret = ESP_OK; - /* Power off Ethernet PHY */ - ESP_GOTO_ON_ERROR(dm9051_pwrctl(phy, false), err, TAG, "power control failed"); return ESP_OK; err: return ret; @@ -437,30 +177,20 @@ err: esp_eth_phy_t *esp_eth_phy_new_dm9051(const eth_phy_config_t *config) { esp_eth_phy_t *ret = NULL; - ESP_GOTO_ON_FALSE(config, NULL, err, TAG, "can't set phy config to null"); phy_dm9051_t *dm9051 = calloc(1, sizeof(phy_dm9051_t)); ESP_GOTO_ON_FALSE(dm9051, NULL, err, TAG, "calloc dm9051 failed"); - dm9051->addr = config->phy_addr; - dm9051->reset_timeout_ms = config->reset_timeout_ms; - dm9051->reset_gpio_num = config->reset_gpio_num; - dm9051->link_status = ETH_LINK_DOWN; - dm9051->autonego_timeout_ms = config->autonego_timeout_ms; - dm9051->parent.reset = dm9051_reset; - dm9051->parent.reset_hw = dm9051_reset_hw; - dm9051->parent.init = dm9051_init; - dm9051->parent.deinit = dm9051_deinit; - dm9051->parent.set_mediator = dm9051_set_mediator; - dm9051->parent.autonego_ctrl = dm9051_autonego_ctrl; - dm9051->parent.get_link = dm9051_get_link; - dm9051->parent.pwrctl = dm9051_pwrctl; - dm9051->parent.get_addr = dm9051_get_addr; - dm9051->parent.set_addr = dm9051_set_addr; - dm9051->parent.advertise_pause_ability = dm9051_advertise_pause_ability; - dm9051->parent.loopback = dm9051_loopback; - dm9051->parent.set_speed = dm9051_set_speed; - dm9051->parent.set_duplex = dm9051_set_duplex; - dm9051->parent.del = dm9051_del; - return &(dm9051->parent); + ESP_GOTO_ON_FALSE(esp_eth_phy_802_3_obj_config_init(&dm9051->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 dm9051 + dm9051->phy_802_3.parent.init = dm9051_init; + dm9051->phy_802_3.parent.reset = dm9051_reset; + dm9051->phy_802_3.parent.get_link = dm9051_get_link; + + return &dm9051->phy_802_3.parent; err: + if (dm9051 != NULL) { + free(dm9051); + } return ret; } diff --git a/components/esp_eth/src/esp_eth_phy_dp83848.c b/components/esp_eth/src/esp_eth_phy_dp83848.c index c6b5a05076..e494a2221c 100644 --- a/components/esp_eth/src/esp_eth_phy_dp83848.c +++ b/components/esp_eth/src/esp_eth_phy_dp83848.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,13 +8,7 @@ #include #include "esp_log.h" #include "esp_check.h" -#include "esp_eth_driver.h" -#include "eth_phy_regs_struct.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "driver/gpio.h" -#include "esp_rom_gpio.h" -#include "esp_rom_sys.h" +#include "esp_eth_phy_802_3.h" static const char *TAG = "dp83848"; @@ -70,29 +64,24 @@ typedef union { #define ETH_PHY_CR_REG_ADDR (0x19) typedef struct { - esp_eth_phy_t parent; - esp_eth_mediator_t *eth; - int addr; - uint32_t reset_timeout_ms; - uint32_t autonego_timeout_ms; - eth_link_t link_status; - int reset_gpio_num; + phy_802_3_t phy_802_3; } phy_dp83848_t; static esp_err_t dp83848_update_link_duplex_speed(phy_dp83848_t *dp83848) { esp_err_t ret = ESP_OK; - esp_eth_mediator_t *eth = dp83848->eth; + esp_eth_mediator_t *eth = dp83848->phy_802_3.eth; + uint32_t addr = dp83848->phy_802_3.addr; eth_speed_t speed = ETH_SPEED_10M; eth_duplex_t duplex = ETH_DUPLEX_HALF; uint32_t peer_pause_ability = false; anlpar_reg_t anlpar; physts_reg_t physts; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dp83848->addr, ETH_PHY_ANLPAR_REG_ADDR, &(anlpar.val)), err, TAG, "read ANLPAR failed"); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dp83848->addr, ETH_PHY_STS_REG_ADDR, &(physts.val)), err, TAG, "read PHYSTS failed"); + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ETH_PHY_ANLPAR_REG_ADDR, &(anlpar.val)), err, TAG, "read ANLPAR failed"); + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ETH_PHY_STS_REG_ADDR, &(physts.val)), err, TAG, "read PHYSTS failed"); eth_link_t link = physts.link_status ? ETH_LINK_UP : ETH_LINK_DOWN; /* check if link status changed */ - if (dp83848->link_status != link) { + if (dp83848->phy_802_3.link_status != link) { /* when link up, read negotiation result */ if (link == ETH_LINK_UP) { if (physts.speed_status) { @@ -116,28 +105,17 @@ static esp_err_t dp83848_update_link_duplex_speed(phy_dp83848_t *dp83848) 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"); - dp83848->link_status = link; + dp83848->phy_802_3.link_status = link; } return ESP_OK; err: return ret; } -static esp_err_t dp83848_set_mediator(esp_eth_phy_t *phy, esp_eth_mediator_t *eth) -{ - esp_err_t ret = ESP_OK; - ESP_GOTO_ON_FALSE(eth, ESP_ERR_INVALID_ARG, err, TAG, "can't set mediator to null"); - phy_dp83848_t *dp83848 = __containerof(phy, phy_dp83848_t, parent); - dp83848->eth = eth; - return ESP_OK; -err: - return ret; -} - static esp_err_t dp83848_get_link(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; - phy_dp83848_t *dp83848 = __containerof(phy, phy_dp83848_t, parent); + phy_dp83848_t *dp83848 = __containerof(esp_eth_phy_into_phy_802_3(phy), phy_dp83848_t, phy_802_3); /* Update information about link, speed, duplex */ ESP_GOTO_ON_ERROR(dp83848_update_link_duplex_speed(dp83848), err, TAG, "update link duplex speed failed"); return ESP_OK; @@ -145,284 +123,21 @@ err: return ret; } -static esp_err_t dp83848_reset(esp_eth_phy_t *phy) -{ - esp_err_t ret = ESP_OK; - phy_dp83848_t *dp83848 = __containerof(phy, phy_dp83848_t, parent); - dp83848->link_status = ETH_LINK_DOWN; - esp_eth_mediator_t *eth = dp83848->eth; - bmcr_reg_t bmcr = {.reset = 1}; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dp83848->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* Wait for reset complete */ - uint32_t to = 0; - for (to = 0; to < dp83848->reset_timeout_ms / 10; to++) { - vTaskDelay(pdMS_TO_TICKS(10)); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dp83848->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (!bmcr.reset) { - break; - } - } - ESP_GOTO_ON_FALSE(to < dp83848->reset_timeout_ms / 10, ESP_FAIL, err, TAG, "reset timeout"); - return ESP_OK; -err: - return ret; -} - -static esp_err_t dp83848_reset_hw(esp_eth_phy_t *phy) -{ - phy_dp83848_t *dp83848 = __containerof(phy, phy_dp83848_t, parent); - if (dp83848->reset_gpio_num >= 0) { - esp_rom_gpio_pad_select_gpio(dp83848->reset_gpio_num); - gpio_set_direction(dp83848->reset_gpio_num, GPIO_MODE_OUTPUT); - gpio_set_level(dp83848->reset_gpio_num, 0); - esp_rom_delay_us(100); // insert min input assert time - gpio_set_level(dp83848->reset_gpio_num, 1); - } - return ESP_OK; -} - -/** - * @note This function is responsible for restarting a new auto-negotiation, - * the result of negotiation won't be relected to uppler layers. - * Instead, the negotiation result is fetched by linker timer, see `dp83848_get_link()` - */ -static esp_err_t dp83848_autonego_ctrl(esp_eth_phy_t *phy, eth_phy_autoneg_cmd_t cmd, bool *autonego_en_stat) -{ - esp_err_t ret = ESP_OK; - phy_dp83848_t *dp83848 = __containerof(phy, phy_dp83848_t, parent); - esp_eth_mediator_t *eth = dp83848->eth; - - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dp83848->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - - switch (cmd) { - case ESP_ETH_PHY_AUTONEGO_RESTART: - ESP_GOTO_ON_FALSE(bmcr.en_auto_nego, ESP_ERR_INVALID_STATE, err, TAG, "auto negotiation is disabled"); - /* in case any link status has changed, let's assume we're in link down status */ - dp83848->link_status = ETH_LINK_DOWN; - - bmcr.restart_auto_nego = 1; /* Restart Auto Negotiation */ - - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dp83848->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* Wait for auto negotiation complete */ - bmsr_reg_t bmsr; - uint32_t to = 0; - for (to = 0; to < dp83848->autonego_timeout_ms / 100; to++) { - vTaskDelay(pdMS_TO_TICKS(100)); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dp83848->addr, ETH_PHY_BMSR_REG_ADDR, &(bmsr.val)), err, TAG, "read BMSR failed"); - if (bmsr.auto_nego_complete) { - break; - } - } - if ((to >= dp83848->autonego_timeout_ms / 100) && (dp83848->link_status == ETH_LINK_UP)) { - ESP_LOGW(TAG, "auto negotiation timeout"); - } - break; - case ESP_ETH_PHY_AUTONEGO_DIS: - if (bmcr.en_auto_nego == 1) { - bmcr.en_auto_nego = 0; /* Disable Auto Negotiation */ - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dp83848->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* read configuration back */ - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dp83848->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_FALSE(bmcr.en_auto_nego == 0, ESP_FAIL, err, TAG, "disable auto-negotiation failed"); - } - break; - case ESP_ETH_PHY_AUTONEGO_EN: - if (bmcr.en_auto_nego == 0) { - bmcr.en_auto_nego = 1; /* Enable Auto Negotiation */ - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dp83848->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* read configuration back */ - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dp83848->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_FALSE(bmcr.en_auto_nego == 1, ESP_FAIL, err, TAG, "enable auto-negotiation failed"); - } - break; - case ESP_ETH_PHY_AUTONEGO_G_STAT: - /* do nothing autonego_en_stat is set at the function end */ - break; - default: - return ESP_ERR_INVALID_ARG; - } - - *autonego_en_stat = bmcr.en_auto_nego; - return ESP_OK; -err: - return ret; -} - -static esp_err_t dp83848_pwrctl(esp_eth_phy_t *phy, bool enable) -{ - esp_err_t ret = ESP_OK; - phy_dp83848_t *dp83848 = __containerof(phy, phy_dp83848_t, parent); - esp_eth_mediator_t *eth = dp83848->eth; - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dp83848->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (!enable) { - /* Enable IEEE Power Down Mode */ - bmcr.power_down = 1; - } else { - /* Disable IEEE Power Down Mode */ - bmcr.power_down = 0; - } - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dp83848->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - if (!enable) { - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dp83848->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_FALSE(bmcr.power_down == 1, ESP_FAIL, err, TAG, "power down failed"); - } else { - /* wait for power up complete */ - uint32_t to = 0; - for (to = 0; to < dp83848->reset_timeout_ms / 10; to++) { - vTaskDelay(pdMS_TO_TICKS(10)); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dp83848->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (bmcr.power_down == 0) { - break; - } - } - ESP_GOTO_ON_FALSE(to < dp83848->reset_timeout_ms / 10, ESP_FAIL, err, TAG, "power up timeout"); - } - return ESP_OK; -err: - return ret; -} - -static esp_err_t dp83848_set_addr(esp_eth_phy_t *phy, uint32_t addr) -{ - phy_dp83848_t *dp83848 = __containerof(phy, phy_dp83848_t, parent); - dp83848->addr = addr; - return ESP_OK; -} - -static esp_err_t dp83848_get_addr(esp_eth_phy_t *phy, uint32_t *addr) -{ - esp_err_t ret = ESP_OK; - ESP_GOTO_ON_FALSE(addr, ESP_ERR_INVALID_ARG, err, TAG, "addr can't be null"); - phy_dp83848_t *dp83848 = __containerof(phy, phy_dp83848_t, parent); - *addr = dp83848->addr; - return ESP_OK; -err: - return ret; -} - -static esp_err_t dp83848_del(esp_eth_phy_t *phy) -{ - phy_dp83848_t *dp83848 = __containerof(phy, phy_dp83848_t, parent); - free(dp83848); - return ESP_OK; -} - -static esp_err_t dp83848_advertise_pause_ability(esp_eth_phy_t *phy, uint32_t ability) -{ - esp_err_t ret = ESP_OK; - phy_dp83848_t *dp83848 = __containerof(phy, phy_dp83848_t, parent); - esp_eth_mediator_t *eth = dp83848->eth; - /* Set PAUSE function ability */ - anar_reg_t anar; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dp83848->addr, ETH_PHY_ANAR_REG_ADDR, &(anar.val)), err, TAG, "read ANAR failed"); - if (ability) { - anar.asymmetric_pause = 1; - anar.symmetric_pause = 1; - } else { - anar.asymmetric_pause = 0; - anar.symmetric_pause = 0; - } - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dp83848->addr, ETH_PHY_ANAR_REG_ADDR, anar.val), err, TAG, "write ANAR failed"); - return ESP_OK; -err: - return ret; -} - -static esp_err_t dp83848_loopback(esp_eth_phy_t *phy, bool enable) -{ - esp_err_t ret = ESP_OK; - phy_dp83848_t *dp83848 = __containerof(phy, phy_dp83848_t, parent); - esp_eth_mediator_t *eth = dp83848->eth; - /* Set Loopback function */ - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dp83848->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (enable) { - bmcr.en_loopback = 1; - } else { - bmcr.en_loopback = 0; - } - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dp83848->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - return ESP_OK; -err: - return ret; -} - -static esp_err_t dp83848_set_speed(esp_eth_phy_t *phy, eth_speed_t speed) -{ - esp_err_t ret = ESP_OK; - phy_dp83848_t *dp83848 = __containerof(phy, phy_dp83848_t, parent); - esp_eth_mediator_t *eth = dp83848->eth; - if (dp83848->link_status == ETH_LINK_UP) { - /* Since the link is going to be reconfigured, consider it down for a while */ - dp83848->link_status = ETH_LINK_DOWN; - /* Indicate to upper stream apps the link is cosidered down */ - ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_LINK, (void *)dp83848->link_status), err, TAG, "change link failed"); - } - /* Set speed */ - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dp83848->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - bmcr.speed_select = speed; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dp83848->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - - return ESP_OK; -err: - return ret; -} - -static esp_err_t dp83848_set_duplex(esp_eth_phy_t *phy, eth_duplex_t duplex) -{ - esp_err_t ret = ESP_OK; - phy_dp83848_t *dp83848 = __containerof(phy, phy_dp83848_t, parent); - esp_eth_mediator_t *eth = dp83848->eth; - - if (dp83848->link_status == ETH_LINK_UP) { - /* Since the link is going to be reconfigured, consider it down for a while */ - dp83848->link_status = ETH_LINK_DOWN; - /* Indicate to upper stream apps the link is cosidered down */ - ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_LINK, (void *)dp83848->link_status), err, TAG, "change link failed"); - } - /* Set duplex mode */ - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dp83848->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - bmcr.duplex_mode = duplex; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, dp83848->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - - return ESP_OK; -err: - return ret; -} - static esp_err_t dp83848_init(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; - phy_dp83848_t *dp83848 = __containerof(phy, phy_dp83848_t, parent); - esp_eth_mediator_t *eth = dp83848->eth; - // Detect PHY address - if (dp83848->addr == ESP_ETH_PHY_ADDR_AUTO) { - ESP_GOTO_ON_ERROR(esp_eth_detect_phy_addr(eth, &dp83848->addr), err, TAG, "Detect PHY address failed"); - } - /* Power on Ethernet PHY */ - ESP_GOTO_ON_ERROR(dp83848_pwrctl(phy, true), err, TAG, "power control failed"); - /* Reset Ethernet PHY */ - ESP_GOTO_ON_ERROR(dp83848_reset(phy), err, TAG, "reset failed"); - /* Check PHY ID */ - phyidr1_reg_t id1; - phyidr2_reg_t id2; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dp83848->addr, ETH_PHY_IDR1_REG_ADDR, &(id1.val)), err, TAG, "read ID1 failed"); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, dp83848->addr, ETH_PHY_IDR2_REG_ADDR, &(id2.val)), err, TAG, "read ID2 failed"); - ESP_GOTO_ON_FALSE(id1.oui_msb == 0x2000 && id2.oui_lsb == 0x17 && id2.vendor_model == 0x09, ESP_FAIL, err, TAG, "wrong chip ID"); - return ESP_OK; -err: - return ret; -} + 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 == 0x80017 && model == 0x09, ESP_FAIL, err, TAG, "wrong chip ID"); -static esp_err_t dp83848_deinit(esp_eth_phy_t *phy) -{ - esp_err_t ret = ESP_OK; - /* Power off Ethernet PHY */ - ESP_GOTO_ON_ERROR(dp83848_pwrctl(phy, false), err, TAG, "power control failed"); return ESP_OK; err: return ret; @@ -431,30 +146,19 @@ err: esp_eth_phy_t *esp_eth_phy_new_dp83848(const eth_phy_config_t *config) { esp_eth_phy_t *ret = NULL; - ESP_GOTO_ON_FALSE(config, NULL, err, TAG, "can't set phy config to null"); phy_dp83848_t *dp83848 = calloc(1, sizeof(phy_dp83848_t)); ESP_GOTO_ON_FALSE(dp83848, NULL, err, TAG, "calloc dp83848 failed"); - dp83848->addr = config->phy_addr; - dp83848->reset_timeout_ms = config->reset_timeout_ms; - dp83848->link_status = ETH_LINK_DOWN; - dp83848->reset_gpio_num = config->reset_gpio_num; - dp83848->autonego_timeout_ms = config->autonego_timeout_ms; - dp83848->parent.reset = dp83848_reset; - dp83848->parent.reset_hw = dp83848_reset_hw; - dp83848->parent.init = dp83848_init; - dp83848->parent.deinit = dp83848_deinit; - dp83848->parent.set_mediator = dp83848_set_mediator; - dp83848->parent.autonego_ctrl = dp83848_autonego_ctrl; - dp83848->parent.get_link = dp83848_get_link; - dp83848->parent.pwrctl = dp83848_pwrctl; - dp83848->parent.get_addr = dp83848_get_addr; - dp83848->parent.set_addr = dp83848_set_addr; - dp83848->parent.advertise_pause_ability = dp83848_advertise_pause_ability; - dp83848->parent.loopback = dp83848_loopback; - dp83848->parent.set_speed = dp83848_set_speed; - dp83848->parent.set_duplex = dp83848_set_duplex; - dp83848->parent.del = dp83848_del; - return &(dp83848->parent); + ESP_GOTO_ON_FALSE(esp_eth_phy_802_3_obj_config_init(&dp83848->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 dp83848 + dp83848->phy_802_3.parent.init = dp83848_init; + dp83848->phy_802_3.parent.get_link = dp83848_get_link; + + return &dp83848->phy_802_3.parent; err: + if (dp83848 != NULL) { + free(dp83848); + } return ret; } diff --git a/components/esp_eth/src/esp_eth_phy_ip101.c b/components/esp_eth/src/esp_eth_phy_ip101.c index a17bbb915d..903ca066d6 100644 --- a/components/esp_eth/src/esp_eth_phy_ip101.c +++ b/components/esp_eth/src/esp_eth_phy_ip101.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,13 +8,7 @@ #include #include "esp_log.h" #include "esp_check.h" -#include "esp_eth_driver.h" -#include "eth_phy_regs_struct.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "driver/gpio.h" -#include "esp_rom_gpio.h" -#include "esp_rom_sys.h" +#include "esp_eth_phy_802_3.h" static const char *TAG = "ip101"; @@ -87,23 +81,17 @@ typedef union { #define ETH_PHY_PSCR_REG_ADDR (0x11) typedef struct { - esp_eth_phy_t parent; - esp_eth_mediator_t *eth; - int addr; - uint32_t reset_timeout_ms; - uint32_t autonego_timeout_ms; - eth_link_t link_status; - int reset_gpio_num; + phy_802_3_t phy_802_3; } phy_ip101_t; static esp_err_t ip101_page_select(phy_ip101_t *ip101, uint32_t page) { esp_err_t ret = ESP_OK; - esp_eth_mediator_t *eth = ip101->eth; + esp_eth_mediator_t *eth = ip101->phy_802_3.eth; pcr_reg_t pcr = { .register_page_select = page }; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ip101->addr, ETH_PHY_PCR_REG_ADDR, pcr.val), err, TAG, "write PCR failed"); + ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ip101->phy_802_3.addr, ETH_PHY_PCR_REG_ADDR, pcr.val), err, TAG, "write PCR failed"); return ESP_OK; err: return ret; @@ -112,18 +100,20 @@ err: static esp_err_t ip101_update_link_duplex_speed(phy_ip101_t *ip101) { esp_err_t ret = ESP_OK; - esp_eth_mediator_t *eth = ip101->eth; + esp_eth_mediator_t *eth = ip101->phy_802_3.eth; + uint32_t addr = ip101->phy_802_3.addr; eth_speed_t speed = ETH_SPEED_10M; eth_duplex_t duplex = ETH_DUPLEX_HALF; uint32_t peer_pause_ability = false; cssr_reg_t cssr; anlpar_reg_t anlpar; + ESP_GOTO_ON_ERROR(ip101_page_select(ip101, 16), err, TAG, "select page 16 failed"); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ip101->addr, ETH_PHY_CSSR_REG_ADDR, &(cssr.val)), err, TAG, "read CSSR failed"); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ip101->addr, ETH_PHY_ANLPAR_REG_ADDR, &(anlpar.val)), err, TAG, "read ANLPAR failed"); + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ETH_PHY_CSSR_REG_ADDR, &(cssr.val)), err, TAG, "read CSSR 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 = cssr.link_up ? ETH_LINK_UP : ETH_LINK_DOWN; /* check if link status changed */ - if (ip101->link_status != link) { + if (ip101->phy_802_3.link_status != link) { /* when link up, read negotiation result */ if (link == ETH_LINK_UP) { switch (cssr.op_mode) { @@ -157,28 +147,18 @@ static esp_err_t ip101_update_link_duplex_speed(phy_ip101_t *ip101) 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"); - ip101->link_status = link; + ip101->phy_802_3.link_status = link; } return ESP_OK; err: return ret; } -static esp_err_t ip101_set_mediator(esp_eth_phy_t *phy, esp_eth_mediator_t *eth) -{ - esp_err_t ret = ESP_OK; - ESP_GOTO_ON_FALSE(eth, ESP_ERR_INVALID_ARG, err, TAG, "can't set mediator to null"); - phy_ip101_t *ip101 = __containerof(phy, phy_ip101_t, parent); - ip101->eth = eth; - return ESP_OK; -err: - return ret; -} - static esp_err_t ip101_get_link(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; - phy_ip101_t *ip101 = __containerof(phy, phy_ip101_t, parent); + phy_ip101_t *ip101 = __containerof(esp_eth_phy_into_phy_802_3(phy), phy_ip101_t, phy_802_3); + /* Update information about link, speed, duplex */ ESP_GOTO_ON_ERROR(ip101_update_link_duplex_speed(ip101), err, TAG, "update link duplex speed failed"); return ESP_OK; @@ -186,285 +166,21 @@ err: return ret; } -static esp_err_t ip101_reset(esp_eth_phy_t *phy) -{ - esp_err_t ret = ESP_OK; - phy_ip101_t *ip101 = __containerof(phy, phy_ip101_t, parent); - ip101->link_status = ETH_LINK_DOWN; - esp_eth_mediator_t *eth = ip101->eth; - bmcr_reg_t bmcr = {.reset = 1}; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ip101->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* wait for reset complete */ - uint32_t to = 0; - for (to = 0; to < ip101->reset_timeout_ms / 10; to++) { - vTaskDelay(pdMS_TO_TICKS(10)); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ip101->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (!bmcr.reset) { - break; - } - } - ESP_GOTO_ON_FALSE(to < ip101->reset_timeout_ms / 10, ESP_FAIL, err, TAG, "reset timeout"); - return ESP_OK; -err: - return ret; -} - -static esp_err_t ip101_reset_hw(esp_eth_phy_t *phy) -{ - phy_ip101_t *ip101 = __containerof(phy, phy_ip101_t, parent); - if (ip101->reset_gpio_num >= 0) { - esp_rom_gpio_pad_select_gpio(ip101->reset_gpio_num); - gpio_set_direction(ip101->reset_gpio_num, GPIO_MODE_OUTPUT); - gpio_set_level(ip101->reset_gpio_num, 0); - esp_rom_delay_us(100); // insert min input assert time - gpio_set_level(ip101->reset_gpio_num, 1); - } - return ESP_OK; -} - -/** - * @note This function is responsible for restarting a new auto-negotiation, - * the result of negotiation won't be relected to uppler layers. - * Instead, the negotiation result is fetched by linker timer, see `ip101_get_link()` - */ -static esp_err_t ip101_autonego_ctrl(esp_eth_phy_t *phy, eth_phy_autoneg_cmd_t cmd, bool *autonego_en_stat) -{ - esp_err_t ret = ESP_OK; - phy_ip101_t *ip101 = __containerof(phy, phy_ip101_t, parent); - esp_eth_mediator_t *eth = ip101->eth; - - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ip101->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - - switch (cmd) { - case ESP_ETH_PHY_AUTONEGO_RESTART: - ESP_GOTO_ON_FALSE(bmcr.en_auto_nego, ESP_ERR_INVALID_STATE, err, TAG, "auto negotiation is disabled"); - /* in case any link status has changed, let's assume we're in link down status */ - ip101->link_status = ETH_LINK_DOWN; - - bmcr.restart_auto_nego = 1; /* Restart Auto Negotiation */ - - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ip101->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* Wait for auto negotiation complete */ - bmsr_reg_t bmsr; - uint32_t to = 0; - for (to = 0; to < ip101->autonego_timeout_ms / 100; to++) { - vTaskDelay(pdMS_TO_TICKS(100)); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ip101->addr, ETH_PHY_BMSR_REG_ADDR, &(bmsr.val)), err, TAG, "read BMSR failed"); - if (bmsr.auto_nego_complete) { - break; - } - } - if ((to >= ip101->autonego_timeout_ms / 100) && (ip101->link_status == ETH_LINK_UP)) { - ESP_LOGW(TAG, "auto negotiation timeout"); - } - break; - case ESP_ETH_PHY_AUTONEGO_DIS: - if (bmcr.en_auto_nego == 1) { - bmcr.en_auto_nego = 0; /* Disable Auto Negotiation */ - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ip101->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* read configuration back */ - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ip101->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_FALSE(bmcr.en_auto_nego == 0, ESP_FAIL, err, TAG, "disable auto-negotiation failed"); - } - break; - case ESP_ETH_PHY_AUTONEGO_EN: - if (bmcr.en_auto_nego == 0) { - bmcr.en_auto_nego = 1; /* Enable Auto Negotiation */ - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ip101->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* read configuration back */ - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ip101->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_FALSE(bmcr.en_auto_nego == 1, ESP_FAIL, err, TAG, "enable auto-negotiation failed"); - } - break; - case ESP_ETH_PHY_AUTONEGO_G_STAT: - /* do nothing autonego_en_stat is set at the function end */ - break; - default: - return ESP_ERR_INVALID_ARG; - } - - *autonego_en_stat = bmcr.en_auto_nego; - return ESP_OK; -err: - return ret; -} - -static esp_err_t ip101_pwrctl(esp_eth_phy_t *phy, bool enable) -{ - esp_err_t ret = ESP_OK; - phy_ip101_t *ip101 = __containerof(phy, phy_ip101_t, parent); - esp_eth_mediator_t *eth = ip101->eth; - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ip101->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (!enable) { - /* Enable IEEE Power Down Mode */ - bmcr.power_down = 1; - } else { - /* Disable IEEE Power Down Mode */ - bmcr.power_down = 0; - } - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ip101->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - if (!enable) { - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ip101->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_FALSE(bmcr.power_down == 1, ESP_FAIL, err, TAG, "power down failed"); - } else { - /* wait for power up complete */ - uint32_t to = 0; - for (to = 0; to < ip101->reset_timeout_ms / 10; to++) { - vTaskDelay(pdMS_TO_TICKS(10)); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ip101->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (bmcr.power_down == 0) { - break; - } - } - ESP_GOTO_ON_FALSE(to < ip101->reset_timeout_ms / 10, ESP_FAIL, err, TAG, "power up timeout"); - } - return ESP_OK; -err: - return ret; -} - -static esp_err_t ip101_set_addr(esp_eth_phy_t *phy, uint32_t addr) -{ - phy_ip101_t *ip101 = __containerof(phy, phy_ip101_t, parent); - ip101->addr = addr; - return ESP_OK; -} - -static esp_err_t ip101_get_addr(esp_eth_phy_t *phy, uint32_t *addr) -{ - esp_err_t ret = ESP_OK; - ESP_GOTO_ON_FALSE(addr, ESP_ERR_INVALID_ARG, err, TAG, "addr can't be null"); - phy_ip101_t *ip101 = __containerof(phy, phy_ip101_t, parent); - *addr = ip101->addr; - return ESP_OK; -err: - return ret; -} - -static esp_err_t ip101_del(esp_eth_phy_t *phy) -{ - phy_ip101_t *ip101 = __containerof(phy, phy_ip101_t, parent); - free(ip101); - return ESP_OK; -} - -static esp_err_t ip101_advertise_pause_ability(esp_eth_phy_t *phy, uint32_t ability) -{ - esp_err_t ret = ESP_OK; - phy_ip101_t *ip101 = __containerof(phy, phy_ip101_t, parent); - esp_eth_mediator_t *eth = ip101->eth; - /* Set PAUSE function ability */ - anar_reg_t anar; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ip101->addr, ETH_PHY_ANAR_REG_ADDR, &(anar.val)), err, TAG, "read ANAR failed"); - if (ability) { - anar.asymmetric_pause = 1; - anar.symmetric_pause = 1; - } else { - anar.asymmetric_pause = 0; - anar.symmetric_pause = 0; - } - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ip101->addr, ETH_PHY_ANAR_REG_ADDR, anar.val), err, TAG, "write ANAR failed"); - return ESP_OK; -err: - return ret; -} - -static esp_err_t ip101_loopback(esp_eth_phy_t *phy, bool enable) -{ - esp_err_t ret = ESP_OK; - phy_ip101_t *ip101 = __containerof(phy, phy_ip101_t, parent); - esp_eth_mediator_t *eth = ip101->eth; - /* Set Loopback function */ - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ip101->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (enable) { - bmcr.en_loopback = 1; - } else { - bmcr.en_loopback = 0; - } - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ip101->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - return ESP_OK; -err: - return ret; -} - -static esp_err_t ip101_set_speed(esp_eth_phy_t *phy, eth_speed_t speed) -{ - esp_err_t ret = ESP_OK; - phy_ip101_t *ip101 = __containerof(phy, phy_ip101_t, parent); - esp_eth_mediator_t *eth = ip101->eth; - - if (ip101->link_status == ETH_LINK_UP) { - /* Since the link is going to be reconfigured, consider it down for a while */ - ip101->link_status = ETH_LINK_DOWN; - /* Indicate to upper stream apps the link is cosidered down */ - ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_LINK, (void *)ip101->link_status), err, TAG, "change link failed"); - } - /* Set speed */ - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ip101->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - bmcr.speed_select = speed; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ip101->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - - return ESP_OK; -err: - return ret; -} - -static esp_err_t ip101_set_duplex(esp_eth_phy_t *phy, eth_duplex_t duplex) -{ - esp_err_t ret = ESP_OK; - phy_ip101_t *ip101 = __containerof(phy, phy_ip101_t, parent); - esp_eth_mediator_t *eth = ip101->eth; - - if (ip101->link_status == ETH_LINK_UP) { - /* Since the link is going to be reconfigured, consider it down for a while */ - ip101->link_status = ETH_LINK_DOWN; - /* Indicate to upper stream apps the link is cosidered down */ - ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_LINK, (void *)ip101->link_status), err, TAG, "change link failed"); - } - /* Set duplex mode */ - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ip101->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - bmcr.duplex_mode = duplex; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ip101->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - - return ESP_OK; -err: - return ret; -} - static esp_err_t ip101_init(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; - phy_ip101_t *ip101 = __containerof(phy, phy_ip101_t, parent); - esp_eth_mediator_t *eth = ip101->eth; - // Detect PHY address - if (ip101->addr == ESP_ETH_PHY_ADDR_AUTO) { - ESP_GOTO_ON_ERROR(esp_eth_detect_phy_addr(eth, &ip101->addr), err, TAG, "Detect PHY address failed"); - } - /* Power on Ethernet PHY */ - ESP_GOTO_ON_ERROR(ip101_pwrctl(phy, true), err, TAG, "power control failed"); - /* Reset Ethernet PHY */ - ESP_GOTO_ON_ERROR(ip101_reset(phy), err, TAG, "reset failed"); - /* Check PHY ID */ - phyidr1_reg_t id1; - phyidr2_reg_t id2; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ip101->addr, ETH_PHY_IDR1_REG_ADDR, &(id1.val)), err, TAG, "read ID1 failed"); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ip101->addr, ETH_PHY_IDR2_REG_ADDR, &(id2.val)), err, TAG, "read ID2 failed"); - ESP_GOTO_ON_FALSE(id1.oui_msb == 0x243 && id2.oui_lsb == 0x3 && id2.vendor_model == 0x5, ESP_FAIL, err, TAG, "wrong chip ID"); - return ESP_OK; -err: - return ret; -} + 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 == 0x90C3 && model == 0x5, ESP_FAIL, err, TAG, "wrong chip ID"); -static esp_err_t ip101_deinit(esp_eth_phy_t *phy) -{ - esp_err_t ret = ESP_OK; - /* Power off Ethernet PHY */ - ESP_GOTO_ON_ERROR(ip101_pwrctl(phy, false), err, TAG, "power control failed"); return ESP_OK; err: return ret; @@ -473,31 +189,19 @@ err: esp_eth_phy_t *esp_eth_phy_new_ip101(const eth_phy_config_t *config) { esp_eth_phy_t *ret = NULL; - ESP_GOTO_ON_FALSE(config, NULL, err, TAG, "can't set phy config to null"); phy_ip101_t *ip101 = calloc(1, sizeof(phy_ip101_t)); ESP_GOTO_ON_FALSE(ip101, NULL, err, TAG, "calloc ip101 failed"); - ip101->addr = config->phy_addr; - ip101->reset_timeout_ms = config->reset_timeout_ms; - ip101->reset_gpio_num = config->reset_gpio_num; - ip101->link_status = ETH_LINK_DOWN; - ip101->autonego_timeout_ms = config->autonego_timeout_ms; - ip101->parent.reset = ip101_reset; - ip101->parent.reset_hw = ip101_reset_hw; - ip101->parent.init = ip101_init; - ip101->parent.deinit = ip101_deinit; - ip101->parent.set_mediator = ip101_set_mediator; - ip101->parent.autonego_ctrl = ip101_autonego_ctrl; - ip101->parent.get_link = ip101_get_link; - ip101->parent.pwrctl = ip101_pwrctl; - ip101->parent.get_addr = ip101_get_addr; - ip101->parent.set_addr = ip101_set_addr; - ip101->parent.advertise_pause_ability = ip101_advertise_pause_ability; - ip101->parent.loopback = ip101_loopback; - ip101->parent.set_speed = ip101_set_speed; - ip101->parent.set_duplex = ip101_set_duplex; - ip101->parent.del = ip101_del; + ESP_GOTO_ON_FALSE(esp_eth_phy_802_3_obj_config_init(&ip101->phy_802_3, config) == ESP_OK, + NULL, err, TAG, "configuration initialization of PHY 802.3 failed"); - return &(ip101->parent); + // redefine functions which need to be customized for sake of IP101 + ip101->phy_802_3.parent.init = ip101_init; + ip101->phy_802_3.parent.get_link = ip101_get_link; + + return &ip101->phy_802_3.parent; err: + if (ip101 != NULL) { + free(ip101); + } return ret; } diff --git a/components/esp_eth/src/esp_eth_phy_ksz80xx.c b/components/esp_eth/src/esp_eth_phy_ksz80xx.c index c2329d23b2..8e27e780cd 100644 --- a/components/esp_eth/src/esp_eth_phy_ksz80xx.c +++ b/components/esp_eth/src/esp_eth_phy_ksz80xx.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,16 +8,11 @@ #include #include "esp_log.h" #include "esp_check.h" -#include "esp_eth_driver.h" -#include "eth_phy_regs_struct.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "driver/gpio.h" -#include "esp_rom_gpio.h" -#include "esp_rom_sys.h" +#include "esp_eth_phy_802_3.h" #define KSZ80XX_PHY_ID_MSB (0x22) #define KSZ80XX_PHY_ID_LSB (0x05) +#define KSZ80XX_PHY_OUI (KSZ80XX_PHY_ID_MSB << 6 | KSZ80XX_PHY_ID_LSB) #define KSZ80XX_PC1R_REG_ADDR (0x1E) #define KSZ80XX_PC2R_REG_ADDR (0x1F) @@ -33,13 +28,7 @@ typedef enum typedef struct { - esp_eth_phy_t parent; - esp_eth_mediator_t *eth; - int addr; - uint32_t reset_timeout_ms; - uint32_t autonego_timeout_ms; - eth_link_t link_status; - int reset_gpio_num; + phy_802_3_t phy_802_3; uint8_t model_number; uint32_t op_mode_reg; uint32_t op_mode_offset; @@ -67,21 +56,22 @@ static const char *TAG = "ksz80xx"; static esp_err_t ksz80xx_update_link_duplex_speed(phy_ksz80xx_t * ksz80xx) { esp_err_t ret = ESP_OK; - esp_eth_mediator_t *eth = ksz80xx->eth; + esp_eth_mediator_t *eth = ksz80xx->phy_802_3.eth; + uint32_t addr = ksz80xx->phy_802_3.addr; eth_speed_t speed = ETH_SPEED_10M; eth_duplex_t duplex = ETH_DUPLEX_HALF; uint32_t peer_pause_ability = false; anlpar_reg_t anlpar; bmsr_reg_t bmsr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ksz80xx->addr, ETH_PHY_ANLPAR_REG_ADDR, &(anlpar.val)), err, TAG, "read ANLPAR failed"); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ksz80xx->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"); + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ETH_PHY_BMSR_REG_ADDR, &(bmsr.val)), err, TAG, "read BMSR failed"); eth_link_t link = bmsr.link_status ? ETH_LINK_UP : ETH_LINK_DOWN; /* check if link status changed */ - if (ksz80xx->link_status != link) { + if (ksz80xx->phy_802_3.link_status != link) { /* when link up, read negotiation result */ if (link == ETH_LINK_UP) { uint32_t reg_value = 0; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ksz80xx->addr, ksz80xx->op_mode_reg, ®_value), err, TAG, "read %#04x failed", ksz80xx->op_mode_reg); + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ksz80xx->op_mode_reg, ®_value), err, TAG, "read %#04x failed", ksz80xx->op_mode_reg); uint8_t op_mode = (reg_value >> ksz80xx->op_mode_offset) & 0x07; switch (op_mode) { case 1: //10Base-T half-duplex @@ -114,28 +104,17 @@ static esp_err_t ksz80xx_update_link_duplex_speed(phy_ksz80xx_t * ksz80xx) 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"); - ksz80xx->link_status = link; + ksz80xx->phy_802_3.link_status = link; } return ESP_OK; err: return ret; } -static esp_err_t ksz80xx_set_mediator(esp_eth_phy_t *phy, esp_eth_mediator_t *eth) -{ - esp_err_t ret = ESP_OK; - ESP_GOTO_ON_FALSE(eth, ESP_ERR_INVALID_ARG, err, TAG, "can't set mediator to null"); - phy_ksz80xx_t *ksz80xx = __containerof(phy, phy_ksz80xx_t, parent); - ksz80xx->eth = eth; - return ESP_OK; -err: - return ret; -} - static esp_err_t ksz80xx_get_link(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; - phy_ksz80xx_t *ksz80xx = __containerof(phy, phy_ksz80xx_t, parent); + phy_ksz80xx_t *ksz80xx = __containerof(esp_eth_phy_into_phy_802_3(phy), phy_ksz80xx_t, phy_802_3); /* Update information about link, speed, duplex */ ESP_GOTO_ON_ERROR(ksz80xx_update_link_duplex_speed(ksz80xx), err, TAG, "update link duplex speed failed"); return ESP_OK; @@ -143,255 +122,6 @@ err: return ret; } -static esp_err_t ksz80xx_reset(esp_eth_phy_t *phy) -{ - esp_err_t ret = ESP_OK; - phy_ksz80xx_t *ksz80xx = __containerof(phy, phy_ksz80xx_t, parent); - ksz80xx->link_status = ETH_LINK_DOWN; - esp_eth_mediator_t *eth = ksz80xx->eth; - bmcr_reg_t bmcr = {.reset = 1}; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ksz80xx->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* wait for reset complete */ - uint32_t to = 0; - for (to = 0; to < ksz80xx->reset_timeout_ms / 10; to++) { - vTaskDelay(pdMS_TO_TICKS(10)); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ksz80xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (!bmcr.reset) { - break; - } - } - ESP_GOTO_ON_FALSE(to < ksz80xx->reset_timeout_ms / 10, ESP_FAIL, err, TAG, "reset timeout"); - return ESP_OK; -err: - return ret; -} - -static esp_err_t ksz80xx_reset_hw(esp_eth_phy_t *phy) -{ - phy_ksz80xx_t *ksz80xx = __containerof(phy, phy_ksz80xx_t, parent); - if (ksz80xx->reset_gpio_num >= 0) { - esp_rom_gpio_pad_select_gpio(ksz80xx->reset_gpio_num); - gpio_set_direction(ksz80xx->reset_gpio_num, GPIO_MODE_OUTPUT); - gpio_set_level(ksz80xx->reset_gpio_num, 0); - esp_rom_delay_us(100); // insert min input assert time - gpio_set_level(ksz80xx->reset_gpio_num, 1); - } - return ESP_OK; -} - -/** - * @note This function is responsible for restarting a new auto-negotiation, - * the result of negotiation won't be relected to uppler layers. - * Instead, the negotiation result is fetched by linker timer, see `ksz80xx_get_link()` - */ -static esp_err_t ksz80xx_autonego_ctrl(esp_eth_phy_t *phy, eth_phy_autoneg_cmd_t cmd, bool *autonego_en_stat) -{ - esp_err_t ret = ESP_OK; - phy_ksz80xx_t *ksz80xx = __containerof(phy, phy_ksz80xx_t, parent); - esp_eth_mediator_t *eth = ksz80xx->eth; - - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ksz80xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - - switch (cmd) { - case ESP_ETH_PHY_AUTONEGO_RESTART: - ESP_GOTO_ON_FALSE(bmcr.en_auto_nego, ESP_ERR_INVALID_STATE, err, TAG, "auto negotiation is disabled"); - /* in case any link status has changed, let's assume we're in link down status */ - ksz80xx->link_status = ETH_LINK_DOWN; - - bmcr.restart_auto_nego = 1; /* Restart Auto Negotiation */ - - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ksz80xx->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* Wait for auto negotiation complete */ - bmsr_reg_t bmsr; - uint32_t to = 0; - for (to = 0; to < ksz80xx->autonego_timeout_ms / 100; to++) { - vTaskDelay(pdMS_TO_TICKS(100)); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ksz80xx->addr, ETH_PHY_BMSR_REG_ADDR, &(bmsr.val)), err, TAG, "read BMSR failed"); - if (bmsr.auto_nego_complete) { - break; - } - } - if ((to >= ksz80xx->autonego_timeout_ms / 100) && (ksz80xx->link_status == ETH_LINK_UP)) { - ESP_LOGW(TAG, "auto negotiation timeout"); - } - break; - case ESP_ETH_PHY_AUTONEGO_DIS: - if (bmcr.en_auto_nego == 1) { - bmcr.en_auto_nego = 0; /* Disable Auto Negotiation */ - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ksz80xx->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* read configuration back */ - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ksz80xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_FALSE(bmcr.en_auto_nego == 0, ESP_FAIL, err, TAG, "disable auto-negotiation failed"); - } - break; - case ESP_ETH_PHY_AUTONEGO_EN: - if (bmcr.en_auto_nego == 0) { - bmcr.en_auto_nego = 1; /* Enable Auto Negotiation */ - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ksz80xx->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* read configuration back */ - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ksz80xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_FALSE(bmcr.en_auto_nego == 1, ESP_FAIL, err, TAG, "enable auto-negotiation failed"); - } - break; - case ESP_ETH_PHY_AUTONEGO_G_STAT: - /* do nothing autonego_en_stat is set at the function end */ - break; - default: - return ESP_ERR_INVALID_ARG; - } - - *autonego_en_stat = bmcr.en_auto_nego; - return ESP_OK; -err: - return ret; -} - -static esp_err_t ksz80xx_pwrctl(esp_eth_phy_t *phy, bool enable) -{ - esp_err_t ret = ESP_OK; - phy_ksz80xx_t *ksz80xx = __containerof(phy, phy_ksz80xx_t, parent); - esp_eth_mediator_t *eth = ksz80xx->eth; - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ksz80xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (!enable) { - /* General Power Down Mode */ - bmcr.power_down = 1; - } else { - /* Normal operation Mode */ - bmcr.power_down = 0; - } - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ksz80xx->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - if (!enable) { - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ksz80xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_FALSE(bmcr.power_down == 1, ESP_FAIL, err, TAG, "power down failed"); - } else { - /* wait for power up complete */ - uint32_t to = 0; - for (to = 0; to < ksz80xx->reset_timeout_ms / 10; to++) { - vTaskDelay(pdMS_TO_TICKS(10)); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ksz80xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (bmcr.power_down == 0) { - break; - } - } - ESP_GOTO_ON_FALSE(to < ksz80xx->reset_timeout_ms / 10, ESP_FAIL, err, TAG, "power up timeout"); - } - return ESP_OK; -err: - return ret; -} - -static esp_err_t ksz80xx_set_addr(esp_eth_phy_t *phy, uint32_t addr) -{ - phy_ksz80xx_t *ksz80xx = __containerof(phy, phy_ksz80xx_t, parent); - ksz80xx->addr = addr; - return ESP_OK; -} - -static esp_err_t ksz80xx_get_addr(esp_eth_phy_t *phy, uint32_t *addr) -{ - esp_err_t ret = ESP_OK; - ESP_GOTO_ON_FALSE(addr, ESP_ERR_INVALID_ARG, err, TAG, "addr can't be null"); - phy_ksz80xx_t *ksz80xx = __containerof(phy, phy_ksz80xx_t, parent); - *addr = ksz80xx->addr; - return ESP_OK; -err: - return ret; -} - -static esp_err_t ksz80xx_del(esp_eth_phy_t *phy) -{ - phy_ksz80xx_t *ksz80xx = __containerof(phy, phy_ksz80xx_t, parent); - free(ksz80xx); - return ESP_OK; -} - -static esp_err_t ksz80xx_advertise_pause_ability(esp_eth_phy_t *phy, uint32_t ability) -{ - esp_err_t ret = ESP_OK; - phy_ksz80xx_t *ksz80xx = __containerof(phy, phy_ksz80xx_t, parent); - esp_eth_mediator_t *eth = ksz80xx->eth; - /* Set PAUSE function ability */ - anar_reg_t anar; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ksz80xx->addr, ETH_PHY_ANAR_REG_ADDR, &(anar.val)), err, TAG, "read ANAR failed"); - if (ability) { - anar.asymmetric_pause = 1; - anar.symmetric_pause = 1; - } else { - anar.asymmetric_pause = 0; - anar.symmetric_pause = 0; - } - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ksz80xx->addr, ETH_PHY_ANAR_REG_ADDR, anar.val), err, TAG, "write ANAR failed"); - return ESP_OK; -err: - return ret; -} - -static esp_err_t ksz80xx_loopback(esp_eth_phy_t *phy, bool enable) -{ - esp_err_t ret = ESP_OK; - phy_ksz80xx_t *ksz80xx = __containerof(phy, phy_ksz80xx_t, parent); - esp_eth_mediator_t *eth = ksz80xx->eth; - /* Set Loopback function */ - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ksz80xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (enable) { - bmcr.en_loopback = 1; - } else { - bmcr.en_loopback = 0; - } - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ksz80xx->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - return ESP_OK; -err: - return ret; -} - -static esp_err_t ksz80xx_set_speed(esp_eth_phy_t *phy, eth_speed_t speed) -{ - esp_err_t ret = ESP_OK; - phy_ksz80xx_t *ksz80xx = __containerof(phy, phy_ksz80xx_t, parent); - esp_eth_mediator_t *eth = ksz80xx->eth; - if (ksz80xx->link_status == ETH_LINK_UP) { - /* Since the link is going to be reconfigured, consider it down for a while */ - ksz80xx->link_status = ETH_LINK_DOWN; - /* Indicate to upper stream apps the link is cosidered down */ - ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_LINK, (void *)ksz80xx->link_status), err, TAG, "change link failed"); - } - /* Set speed */ - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ksz80xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - bmcr.speed_select = speed; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ksz80xx->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - - return ESP_OK; -err: - return ret; -} - -static esp_err_t ksz80xx_set_duplex(esp_eth_phy_t *phy, eth_duplex_t duplex) -{ - esp_err_t ret = ESP_OK; - phy_ksz80xx_t *ksz80xx = __containerof(phy, phy_ksz80xx_t, parent); - esp_eth_mediator_t *eth = ksz80xx->eth; - - if (ksz80xx->link_status == ETH_LINK_UP) { - /* Since the link is going to be reconfigured, consider it down for a while */ - ksz80xx->link_status = ETH_LINK_DOWN; - /* Indicate to upper stream apps the link is cosidered down */ - ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_LINK, (void *)ksz80xx->link_status), err, TAG, "change link failed"); - } - /* Set duplex mode */ - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ksz80xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - bmcr.duplex_mode = duplex; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, ksz80xx->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - - return ESP_OK; -err: - return ret; -} - static bool ksz80xx_init_model(phy_ksz80xx_t *ksz80xx) { // set variables for op_mode access @@ -418,20 +148,18 @@ static bool ksz80xx_init_model(phy_ksz80xx_t *ksz80xx) static esp_err_t ksz80xx_init(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; - phy_ksz80xx_t *ksz80xx = __containerof(phy, phy_ksz80xx_t, parent); - esp_eth_mediator_t *eth = ksz80xx->eth; - /* Power on Ethernet PHY */ - ESP_GOTO_ON_ERROR(ksz80xx_pwrctl(phy, true), err, TAG, "power control failed"); - /* Reset Ethernet PHY */ - ESP_GOTO_ON_ERROR(ksz80xx_reset(phy), err, TAG, "reset failed"); + phy_802_3_t *phy_802_3 = esp_eth_phy_into_phy_802_3(phy); + phy_ksz80xx_t *ksz80xx = __containerof(phy_802_3, phy_ksz80xx_t, phy_802_3); + /* 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 */ - phyidr1_reg_t id1; - phyidr2_reg_t id2; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ksz80xx->addr, ETH_PHY_IDR1_REG_ADDR, &(id1.val)), err, TAG, "read ID1 failed"); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, ksz80xx->addr, ETH_PHY_IDR2_REG_ADDR, &(id2.val)), err, TAG, "read ID2 failed"); - ESP_GOTO_ON_FALSE(id1.oui_msb == KSZ80XX_PHY_ID_MSB && id2.oui_lsb == KSZ80XX_PHY_ID_LSB, ESP_FAIL, err, TAG, "wrong chip ID"); + uint32_t oui; + 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, &ksz80xx->model_number, NULL), err, TAG, "read manufacturer's info failed"); + ESP_GOTO_ON_FALSE(oui == KSZ80XX_PHY_OUI, ESP_FAIL, err, TAG, "wrong chip ID"); + const char* supported_model_name = NULL; - ksz80xx->model_number = id2.vendor_model; for (size_t i = 0; i < sizeof(supported_model_numbers); i++) { if (ksz80xx->model_number == supported_model_numbers[i]) { supported_model_name = model_names[i]; @@ -445,43 +173,22 @@ err: return ret; } -static esp_err_t ksz80xx_deinit(esp_eth_phy_t *phy) -{ - esp_err_t ret = ESP_OK; - /* Power off Ethernet PHY */ - ESP_GOTO_ON_ERROR(ksz80xx_pwrctl(phy, false), err, TAG, "power control failed"); - return ESP_OK; -err: - return ret; -} - esp_eth_phy_t *esp_eth_phy_new_ksz80xx(const eth_phy_config_t *config) { esp_eth_phy_t *ret = NULL; - ESP_GOTO_ON_FALSE(config, NULL, err, TAG, "can't set phy config to null"); phy_ksz80xx_t *ksz80xx = calloc(1, sizeof(phy_ksz80xx_t)); ESP_GOTO_ON_FALSE(ksz80xx, NULL, err, TAG, "calloc ksz80xx failed"); - ksz80xx->addr = config->phy_addr; - ksz80xx->reset_gpio_num = config->reset_gpio_num; - ksz80xx->reset_timeout_ms = config->reset_timeout_ms; - ksz80xx->link_status = ETH_LINK_DOWN; - ksz80xx->autonego_timeout_ms = config->autonego_timeout_ms; - ksz80xx->parent.reset = ksz80xx_reset; - ksz80xx->parent.reset_hw = ksz80xx_reset_hw; - ksz80xx->parent.init = ksz80xx_init; - ksz80xx->parent.deinit = ksz80xx_deinit; - ksz80xx->parent.set_mediator = ksz80xx_set_mediator; - ksz80xx->parent.autonego_ctrl = ksz80xx_autonego_ctrl; - ksz80xx->parent.get_link = ksz80xx_get_link; - ksz80xx->parent.pwrctl = ksz80xx_pwrctl; - ksz80xx->parent.get_addr = ksz80xx_get_addr; - ksz80xx->parent.set_addr = ksz80xx_set_addr; - ksz80xx->parent.advertise_pause_ability = ksz80xx_advertise_pause_ability; - ksz80xx->parent.loopback = ksz80xx_loopback; - ksz80xx->parent.set_speed = ksz80xx_set_speed; - ksz80xx->parent.set_duplex = ksz80xx_set_duplex; - ksz80xx->parent.del = ksz80xx_del; - return &(ksz80xx->parent); + ESP_GOTO_ON_FALSE(esp_eth_phy_802_3_obj_config_init(&ksz80xx->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 ksz80xx + ksz80xx->phy_802_3.parent.init = ksz80xx_init; + ksz80xx->phy_802_3.parent.get_link = ksz80xx_get_link; + + return &ksz80xx->phy_802_3.parent; err: + if (ksz80xx != NULL) { + free(ksz80xx); + } return ret; } diff --git a/components/esp_eth/src/esp_eth_phy_lan87xx.c b/components/esp_eth/src/esp_eth_phy_lan87xx.c index 3396e924be..031265b384 100644 --- a/components/esp_eth/src/esp_eth_phy_lan87xx.c +++ b/components/esp_eth/src/esp_eth_phy_lan87xx.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,13 +8,7 @@ #include #include "esp_log.h" #include "esp_check.h" -#include "esp_eth_driver.h" -#include "eth_phy_regs_struct.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "driver/gpio.h" -#include "esp_rom_gpio.h" -#include "esp_rom_sys.h" +#include "esp_eth_phy_802_3.h" static const char *TAG = "lan87xx"; @@ -212,33 +206,28 @@ typedef union { #define ETH_PHY_PSCSR_REG_ADDR (0x1F) typedef struct { - esp_eth_phy_t parent; - esp_eth_mediator_t *eth; - int addr; - uint32_t reset_timeout_ms; - uint32_t autonego_timeout_ms; - eth_link_t link_status; - int reset_gpio_num; + phy_802_3_t phy_802_3; } phy_lan87xx_t; static esp_err_t lan87xx_update_link_duplex_speed(phy_lan87xx_t *lan87xx) { esp_err_t ret = ESP_OK; - esp_eth_mediator_t *eth = lan87xx->eth; + esp_eth_mediator_t *eth = lan87xx->phy_802_3.eth; + uint32_t addr = lan87xx->phy_802_3.addr; eth_speed_t speed = ETH_SPEED_10M; eth_duplex_t duplex = ETH_DUPLEX_HALF; bmsr_reg_t bmsr; pscsr_reg_t pscsr; uint32_t peer_pause_ability = false; anlpar_reg_t anlpar; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, lan87xx->addr, ETH_PHY_ANLPAR_REG_ADDR, &(anlpar.val)), err, TAG, "read ANLPAR failed"); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, lan87xx->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"); + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ETH_PHY_BMSR_REG_ADDR, &(bmsr.val)), err, TAG, "read BMSR failed"); eth_link_t link = bmsr.link_status ? ETH_LINK_UP : ETH_LINK_DOWN; /* check if link status changed */ - if (lan87xx->link_status != link) { + if (lan87xx->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, lan87xx->addr, ETH_PHY_PSCSR_REG_ADDR, &(pscsr.val)), err, TAG, "read PSCSR failed"); + ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, addr, ETH_PHY_PSCSR_REG_ADDR, &(pscsr.val)), err, TAG, "read PSCSR failed"); switch (pscsr.speed_indication) { case 1: //10Base-T half-duplex speed = ETH_SPEED_10M; @@ -270,28 +259,17 @@ static esp_err_t lan87xx_update_link_duplex_speed(phy_lan87xx_t *lan87xx) 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"); - lan87xx->link_status = link; + lan87xx->phy_802_3.link_status = link; } return ESP_OK; err: return ret; } -static esp_err_t lan87xx_set_mediator(esp_eth_phy_t *phy, esp_eth_mediator_t *eth) -{ - esp_err_t ret = ESP_OK; - ESP_GOTO_ON_FALSE(eth, ESP_ERR_INVALID_ARG, err, TAG, "can't set mediator to null"); - phy_lan87xx_t *lan87xx = __containerof(phy, phy_lan87xx_t, parent); - lan87xx->eth = eth; - return ESP_OK; -err: - return ret; -} - static esp_err_t lan87xx_get_link(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; - phy_lan87xx_t *lan87xx = __containerof(phy, phy_lan87xx_t, parent); + phy_lan87xx_t *lan87xx = __containerof(esp_eth_phy_into_phy_802_3(phy), phy_lan87xx_t, phy_802_3); /* Updata information about link, speed, duplex */ ESP_GOTO_ON_ERROR(lan87xx_update_link_duplex_speed(lan87xx), err, TAG, "update link duplex speed failed"); return ESP_OK; @@ -299,278 +277,30 @@ err: return ret; } -static esp_err_t lan87xx_reset(esp_eth_phy_t *phy) -{ - esp_err_t ret = ESP_OK; - phy_lan87xx_t *lan87xx = __containerof(phy, phy_lan87xx_t, parent); - lan87xx->link_status = ETH_LINK_DOWN; - esp_eth_mediator_t *eth = lan87xx->eth; - bmcr_reg_t bmcr = {.reset = 1}; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, lan87xx->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* wait for reset complete */ - uint32_t to = 0; - for (to = 0; to < lan87xx->reset_timeout_ms / 10; to++) { - vTaskDelay(pdMS_TO_TICKS(10)); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, lan87xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (!bmcr.reset) { - break; - } - } - ESP_GOTO_ON_FALSE(to < lan87xx->reset_timeout_ms / 10, ESP_FAIL, err, TAG, "reset timeout"); - return ESP_OK; -err: - return ret; -} - static esp_err_t lan87xx_reset_hw(esp_eth_phy_t *phy) { - phy_lan87xx_t *lan87xx = __containerof(phy, phy_lan87xx_t, parent); - if (lan87xx->reset_gpio_num >= 0) { - esp_rom_gpio_pad_select_gpio(lan87xx->reset_gpio_num); - gpio_set_direction(lan87xx->reset_gpio_num, GPIO_MODE_OUTPUT); - gpio_set_level(lan87xx->reset_gpio_num, 0); - /* assert nRST signal on LAN87xx a little longer than the minimum specified in datasheet */ - esp_rom_delay_us(150); - gpio_set_level(lan87xx->reset_gpio_num, 1); - } - return ESP_OK; -} - -/** - * @note This function is responsible for restarting a new auto-negotiation, - * the result of negotiation won't be relected to uppler layers. - * Instead, the negotiation result is fetched by linker timer, see `lan87xx_get_link()` - */ -static esp_err_t lan87xx_autonego_ctrl(esp_eth_phy_t *phy, eth_phy_autoneg_cmd_t cmd, bool *autonego_en_stat) -{ - esp_err_t ret = ESP_OK; - phy_lan87xx_t *lan87xx = __containerof(phy, phy_lan87xx_t, parent); - esp_eth_mediator_t *eth = lan87xx->eth; - - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, lan87xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - - switch (cmd) { - case ESP_ETH_PHY_AUTONEGO_RESTART: - ESP_GOTO_ON_FALSE(bmcr.en_auto_nego, ESP_ERR_INVALID_STATE, err, TAG, "auto negotiation is disabled"); - /* in case any link status has changed, let's assume we're in link down status */ - lan87xx->link_status = ETH_LINK_DOWN; - - bmcr.restart_auto_nego = 1; /* Restart Auto Negotiation */ - - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, lan87xx->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* Wait for auto negotiation complete */ - bmsr_reg_t bmsr; - uint32_t to = 0; - for (to = 0; to < lan87xx->autonego_timeout_ms / 100; to++) { - vTaskDelay(pdMS_TO_TICKS(100)); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, lan87xx->addr, ETH_PHY_BMSR_REG_ADDR, &(bmsr.val)), err, TAG, "read BMSR failed"); - if (bmsr.auto_nego_complete) { - break; - } - } - if ((to >= lan87xx->autonego_timeout_ms / 100) && (lan87xx->link_status == ETH_LINK_UP)) { - ESP_LOGW(TAG, "auto negotiation timeout"); - } - break; - case ESP_ETH_PHY_AUTONEGO_DIS: - if (bmcr.en_auto_nego == 1) { - bmcr.en_auto_nego = 0; /* Disable Auto Negotiation */ - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, lan87xx->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* read configuration back */ - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, lan87xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_FALSE(bmcr.en_auto_nego == 0, ESP_FAIL, err, TAG, "disable auto-negotiation failed"); - } - break; - case ESP_ETH_PHY_AUTONEGO_EN: - if (bmcr.en_auto_nego == 0) { - bmcr.en_auto_nego = 1; /* Enable Auto Negotiation */ - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, lan87xx->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* read configuration back */ - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, lan87xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_FALSE(bmcr.en_auto_nego == 1, ESP_FAIL, err, TAG, "enable auto-negotiation failed"); - } - break; - case ESP_ETH_PHY_AUTONEGO_G_STAT: - /* do nothing autonego_en_stat is set at the function end */ - break; - default: - return ESP_ERR_INVALID_ARG; - } - - *autonego_en_stat = bmcr.en_auto_nego; - return ESP_OK; -err: - return ret; -} - -static esp_err_t lan87xx_pwrctl(esp_eth_phy_t *phy, bool enable) -{ - esp_err_t ret = ESP_OK; - phy_lan87xx_t *lan87xx = __containerof(phy, phy_lan87xx_t, parent); - esp_eth_mediator_t *eth = lan87xx->eth; - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, lan87xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (!enable) { - /* General Power Down Mode */ - bmcr.power_down = 1; - } else { - /* Normal operation Mode */ - bmcr.power_down = 0; - } - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, lan87xx->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - if (!enable) { - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, lan87xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_FALSE(bmcr.power_down == 1, ESP_FAIL, err, TAG, "power down failed"); - } else { - /* wait for power up complete */ - uint32_t to = 0; - for (to = 0; to < lan87xx->reset_timeout_ms / 10; to++) { - vTaskDelay(pdMS_TO_TICKS(10)); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, lan87xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (bmcr.power_down == 0) { - break; - } - } - ESP_GOTO_ON_FALSE(to < lan87xx->reset_timeout_ms / 10, ESP_FAIL, err, TAG, "power up timeout"); - } - return ESP_OK; -err: - return ret; -} - -static esp_err_t lan87xx_set_addr(esp_eth_phy_t *phy, uint32_t addr) -{ - phy_lan87xx_t *lan87xx = __containerof(phy, phy_lan87xx_t, parent); - lan87xx->addr = addr; - return ESP_OK; -} - -static esp_err_t lan87xx_get_addr(esp_eth_phy_t *phy, uint32_t *addr) -{ - esp_err_t ret = ESP_OK; - ESP_GOTO_ON_FALSE(addr, ESP_ERR_INVALID_ARG, err, TAG, "addr can't be null"); - phy_lan87xx_t *lan87xx = __containerof(phy, phy_lan87xx_t, parent); - *addr = lan87xx->addr; - return ESP_OK; -err: - return ret; -} - -static esp_err_t lan87xx_del(esp_eth_phy_t *phy) -{ - phy_lan87xx_t *lan87xx = __containerof(phy, phy_lan87xx_t, parent); - free(lan87xx); - return ESP_OK; -} - -static esp_err_t lan87xx_advertise_pause_ability(esp_eth_phy_t *phy, uint32_t ability) -{ - esp_err_t ret = ESP_OK; - phy_lan87xx_t *lan87xx = __containerof(phy, phy_lan87xx_t, parent); - esp_eth_mediator_t *eth = lan87xx->eth; - /* Set PAUSE function ability */ - anar_reg_t anar; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, lan87xx->addr, ETH_PHY_ANAR_REG_ADDR, &(anar.val)), err, TAG, "read ANAR failed"); - if (ability) { - anar.asymmetric_pause = 1; - anar.symmetric_pause = 1; - } else { - anar.asymmetric_pause = 0; - anar.symmetric_pause = 0; - } - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, lan87xx->addr, ETH_PHY_ANAR_REG_ADDR, anar.val), err, TAG, "write ANAR failed"); - return ESP_OK; -err: - return ret; -} - -static esp_err_t lan87xx_loopback(esp_eth_phy_t *phy, bool enable) -{ - esp_err_t ret = ESP_OK; - phy_lan87xx_t *lan87xx = __containerof(phy, phy_lan87xx_t, parent); - esp_eth_mediator_t *eth = lan87xx->eth; - /* Set Loopback function */ - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, lan87xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (enable) { - bmcr.en_loopback = 1; - } else { - bmcr.en_loopback = 0; - } - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, lan87xx->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - return ESP_OK; -err: - return ret; -} - -static esp_err_t lan87xx_set_speed(esp_eth_phy_t *phy, eth_speed_t speed) -{ - esp_err_t ret = ESP_OK; - phy_lan87xx_t *lan87xx = __containerof(phy, phy_lan87xx_t, parent); - esp_eth_mediator_t *eth = lan87xx->eth; - if (lan87xx->link_status == ETH_LINK_UP) { - /* Since the link is going to be reconfigured, consider it down for a while */ - lan87xx->link_status = ETH_LINK_DOWN; - /* Indicate to upper stream apps the link is cosidered down */ - ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_LINK, (void *)lan87xx->link_status), err, TAG, "change link failed"); - } - /* Set speed */ - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, lan87xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - bmcr.speed_select = speed; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, lan87xx->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - - return ESP_OK; -err: - return ret; -} - -static esp_err_t lan87xx_set_duplex(esp_eth_phy_t *phy, eth_duplex_t duplex) -{ - esp_err_t ret = ESP_OK; - phy_lan87xx_t *lan87xx = __containerof(phy, phy_lan87xx_t, parent); - esp_eth_mediator_t *eth = lan87xx->eth; - - if (lan87xx->link_status == ETH_LINK_UP) { - /* Since the link is going to be reconfigured, consider it down for a while */ - lan87xx->link_status = ETH_LINK_DOWN; - /* Indicate to upper stream apps the link is cosidered down */ - ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_LINK, (void *)lan87xx->link_status), err, TAG, "change link failed"); - } - /* Set duplex mode */ - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, lan87xx->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - bmcr.duplex_mode = duplex; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, lan87xx->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - - return ESP_OK; -err: - return ret; + /* It was observed that assert nRST signal on LAN87xx needs to be a little longer than the minimum specified in datasheet */ + return esp_eth_phy_802_3_reset_hw(esp_eth_phy_into_phy_802_3(phy), 150); } static esp_err_t lan87xx_init(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; - phy_lan87xx_t *lan87xx = __containerof(phy, phy_lan87xx_t, parent); - esp_eth_mediator_t *eth = lan87xx->eth; - // Detect PHY address - if (lan87xx->addr == ESP_ETH_PHY_ADDR_AUTO) { - ESP_GOTO_ON_ERROR(esp_eth_detect_phy_addr(eth, &lan87xx->addr), err, TAG, "Detect PHY address failed"); - } - /* Power on Ethernet PHY */ - ESP_GOTO_ON_ERROR(lan87xx_pwrctl(phy, true), err, TAG, "power control failed"); - /* Reset Ethernet PHY */ - ESP_GOTO_ON_ERROR(lan87xx_reset(phy), err, TAG, "reset failed"); + 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 */ - phyidr1_reg_t id1; - phyidr2_reg_t id2; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, lan87xx->addr, ETH_PHY_IDR1_REG_ADDR, &(id1.val)), err, TAG, "read ID1 failed"); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, lan87xx->addr, ETH_PHY_IDR2_REG_ADDR, &(id2.val)), err, TAG, "read ID2 failed"); - ESP_GOTO_ON_FALSE(id1.oui_msb == 0x7 && id2.oui_lsb == 0x30, ESP_FAIL, err, TAG, "wrong chip 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 == 0x1F0, ESP_FAIL, err, TAG, "wrong chip OUI"); + bool supported_model = false; for (unsigned int i = 0; i < sizeof(supported_models); i++) { - if (id2.vendor_model == supported_models[i]) { + if (model == supported_models[i]) { supported_model = true; break; } @@ -581,44 +311,23 @@ err: return ret; } -static esp_err_t lan87xx_deinit(esp_eth_phy_t *phy) -{ - esp_err_t ret = ESP_OK; - /* Power off Ethernet PHY */ - ESP_GOTO_ON_ERROR(lan87xx_pwrctl(phy, false), err, TAG, "power control failed"); - return ESP_OK; -err: - return ret; -} - esp_eth_phy_t *esp_eth_phy_new_lan87xx(const eth_phy_config_t *config) { esp_eth_phy_t *ret = NULL; - ESP_GOTO_ON_FALSE(config, NULL, err, TAG, "can't set phy config to null"); phy_lan87xx_t *lan87xx = calloc(1, sizeof(phy_lan87xx_t)); ESP_GOTO_ON_FALSE(lan87xx, NULL, err, TAG, "calloc lan87xx failed"); - lan87xx->addr = config->phy_addr; - lan87xx->reset_gpio_num = config->reset_gpio_num; - lan87xx->reset_timeout_ms = config->reset_timeout_ms; - lan87xx->link_status = ETH_LINK_DOWN; - lan87xx->autonego_timeout_ms = config->autonego_timeout_ms; - lan87xx->parent.reset = lan87xx_reset; - lan87xx->parent.reset_hw = lan87xx_reset_hw; - lan87xx->parent.init = lan87xx_init; - lan87xx->parent.deinit = lan87xx_deinit; - lan87xx->parent.set_mediator = lan87xx_set_mediator; - lan87xx->parent.autonego_ctrl = lan87xx_autonego_ctrl; - lan87xx->parent.get_link = lan87xx_get_link; - lan87xx->parent.pwrctl = lan87xx_pwrctl; - lan87xx->parent.get_addr = lan87xx_get_addr; - lan87xx->parent.set_addr = lan87xx_set_addr; - lan87xx->parent.loopback = lan87xx_loopback; - lan87xx->parent.set_speed = lan87xx_set_speed; - lan87xx->parent.set_duplex = lan87xx_set_duplex; - lan87xx->parent.advertise_pause_ability = lan87xx_advertise_pause_ability; - lan87xx->parent.del = lan87xx_del; + ESP_GOTO_ON_FALSE(esp_eth_phy_802_3_obj_config_init(&lan87xx->phy_802_3, config) == ESP_OK, + NULL, err, TAG, "configuration initialization of PHY 802.3 failed"); - return &(lan87xx->parent); + // redefine functions which need to be customized for sake of LAN87xx + lan87xx->phy_802_3.parent.reset_hw = lan87xx_reset_hw; + lan87xx->phy_802_3.parent.init = lan87xx_init; + lan87xx->phy_802_3.parent.get_link = lan87xx_get_link; + + return &lan87xx->phy_802_3.parent; err: + if (lan87xx != NULL) { + free(lan87xx); + } return ret; } diff --git a/components/esp_eth/src/esp_eth_phy_rtl8201.c b/components/esp_eth/src/esp_eth_phy_rtl8201.c index b0a1f2493d..2cc42753ba 100644 --- a/components/esp_eth/src/esp_eth_phy_rtl8201.c +++ b/components/esp_eth/src/esp_eth_phy_rtl8201.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -9,13 +9,7 @@ #include #include "esp_log.h" #include "esp_check.h" -#include "esp_eth_driver.h" -#include "eth_phy_regs_struct.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "driver/gpio.h" -#include "esp_rom_gpio.h" -#include "esp_rom_sys.h" +#include "esp_eth_phy_802_3.h" static const char *TAG = "rtl8201"; @@ -48,23 +42,17 @@ typedef union { #define ETH_PHY_PSR_REG_ADDR (0x1F) typedef struct { - esp_eth_phy_t parent; - esp_eth_mediator_t *eth; - int addr; - uint32_t reset_timeout_ms; - uint32_t autonego_timeout_ms; - eth_link_t link_status; - int reset_gpio_num; + phy_802_3_t phy_802_3; } phy_rtl8201_t; static esp_err_t rtl8201_page_select(phy_rtl8201_t *rtl8201, uint32_t page) { esp_err_t ret = ESP_OK; - esp_eth_mediator_t *eth = rtl8201->eth; + esp_eth_mediator_t *eth = rtl8201->phy_802_3.eth; psr_reg_t psr = { .page_select = page }; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, rtl8201->addr, ETH_PHY_PSR_REG_ADDR, psr.val), err, TAG, "write PSR failed"); + ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, rtl8201->phy_802_3.addr, ETH_PHY_PSR_REG_ADDR, psr.val), err, TAG, "write PSR failed"); return ESP_OK; err: return ret; @@ -73,7 +61,8 @@ err: static esp_err_t rtl8201_update_link_duplex_speed(phy_rtl8201_t *rtl8201) { esp_err_t ret = ESP_OK; - esp_eth_mediator_t *eth = rtl8201->eth; + esp_eth_mediator_t *eth = rtl8201->phy_802_3.eth; + uint32_t addr = rtl8201->phy_802_3.addr; eth_speed_t speed = ETH_SPEED_10M; eth_duplex_t duplex = ETH_DUPLEX_HALF; bmcr_reg_t bmcr; @@ -81,14 +70,14 @@ static esp_err_t rtl8201_update_link_duplex_speed(phy_rtl8201_t *rtl8201) uint32_t peer_pause_ability = false; anlpar_reg_t anlpar; ESP_GOTO_ON_ERROR(rtl8201_page_select(rtl8201, 0), err, TAG, "select page 0 failed"); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, rtl8201->addr, ETH_PHY_BMSR_REG_ADDR, &(bmsr.val)), err, TAG, "read BMSR failed"); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, rtl8201->addr, ETH_PHY_ANLPAR_REG_ADDR, &(anlpar.val)), err, TAG, "read ANLPAR 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 (rtl8201->link_status != link) { + if (rtl8201->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, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); + 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 { @@ -110,28 +99,17 @@ static esp_err_t rtl8201_update_link_duplex_speed(phy_rtl8201_t *rtl8201) 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"); - rtl8201->link_status = link; + rtl8201->phy_802_3.link_status = link; } return ESP_OK; err: return ret; } -static esp_err_t rtl8201_set_mediator(esp_eth_phy_t *phy, esp_eth_mediator_t *eth) -{ - esp_err_t ret = ESP_OK; - ESP_GOTO_ON_FALSE(eth, ESP_ERR_INVALID_ARG, err, TAG, "can't set mediator to null"); - phy_rtl8201_t *rtl8201 = __containerof(phy, phy_rtl8201_t, parent); - rtl8201->eth = eth; - return ESP_OK; -err: - return ret; -} - static esp_err_t rtl8201_get_link(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; - phy_rtl8201_t *rtl8201 = __containerof(phy, phy_rtl8201_t, parent); + phy_rtl8201_t *rtl8201 = __containerof(esp_eth_phy_into_phy_802_3(phy), phy_rtl8201_t, phy_802_3); /* Updata information about link, speed, duplex */ ESP_GOTO_ON_ERROR(rtl8201_update_link_duplex_speed(rtl8201), err, TAG, "update link duplex speed failed"); return ESP_OK; @@ -139,284 +117,21 @@ err: return ret; } -static esp_err_t rtl8201_reset(esp_eth_phy_t *phy) -{ - esp_err_t ret = ESP_OK; - phy_rtl8201_t *rtl8201 = __containerof(phy, phy_rtl8201_t, parent); - rtl8201->link_status = ETH_LINK_DOWN; - esp_eth_mediator_t *eth = rtl8201->eth; - bmcr_reg_t bmcr = {.reset = 1}; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* Wait for reset complete */ - uint32_t to = 0; - for (to = 0; to < rtl8201->reset_timeout_ms / 10; to++) { - vTaskDelay(pdMS_TO_TICKS(10)); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (!bmcr.reset) { - break; - } - } - ESP_GOTO_ON_FALSE(to < rtl8201->reset_timeout_ms / 10, ESP_FAIL, err, TAG, "reset timeout"); - return ESP_OK; -err: - return ret; -} - -static esp_err_t rtl8201_reset_hw(esp_eth_phy_t *phy) -{ - phy_rtl8201_t *rtl8201 = __containerof(phy, phy_rtl8201_t, parent); - if (rtl8201->reset_gpio_num >= 0) { - esp_rom_gpio_pad_select_gpio(rtl8201->reset_gpio_num); - gpio_set_direction(rtl8201->reset_gpio_num, GPIO_MODE_OUTPUT); - gpio_set_level(rtl8201->reset_gpio_num, 0); - esp_rom_delay_us(100); // insert min input assert time - gpio_set_level(rtl8201->reset_gpio_num, 1); - } - return ESP_OK; -} - -/** - * @note This function is responsible for restarting a new auto-negotiation, - * the result of negotiation won't be relected to uppler layers. - * Instead, the negotiation result is fetched by linker timer, see `rtl8201_get_link()` - */ -static esp_err_t rtl8201_autonego_ctrl(esp_eth_phy_t *phy, eth_phy_autoneg_cmd_t cmd, bool *autonego_en_stat) -{ - esp_err_t ret = ESP_OK; - phy_rtl8201_t *rtl8201 = __containerof(phy, phy_rtl8201_t, parent); - esp_eth_mediator_t *eth = rtl8201->eth; - - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - - switch (cmd) { - case ESP_ETH_PHY_AUTONEGO_RESTART: - ESP_GOTO_ON_FALSE(bmcr.en_auto_nego, ESP_ERR_INVALID_STATE, err, TAG, "auto negotiation is disabled"); - /* in case any link status has changed, let's assume we're in link down status */ - rtl8201->link_status = ETH_LINK_DOWN; - - bmcr.restart_auto_nego = 1; /* Restart Auto Negotiation */ - - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* Wait for auto negotiation complete */ - bmsr_reg_t bmsr; - uint32_t to = 0; - for (to = 0; to < rtl8201->autonego_timeout_ms / 100; to++) { - vTaskDelay(pdMS_TO_TICKS(100)); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, rtl8201->addr, ETH_PHY_BMSR_REG_ADDR, &(bmsr.val)), err, TAG, "read BMSR failed"); - if (bmsr.auto_nego_complete) { - break; - } - } - if ((to >= rtl8201->autonego_timeout_ms / 100) && (rtl8201->link_status == ETH_LINK_UP)) { - ESP_LOGW(TAG, "auto negotiation timeout"); - } - break; - case ESP_ETH_PHY_AUTONEGO_DIS: - if (bmcr.en_auto_nego == 1) { - bmcr.en_auto_nego = 0; /* Disable Auto Negotiation */ - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* read configuration back */ - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_FALSE(bmcr.en_auto_nego == 0, ESP_FAIL, err, TAG, "disable auto-negotiation failed"); - } - break; - case ESP_ETH_PHY_AUTONEGO_EN: - if (bmcr.en_auto_nego == 0) { - bmcr.en_auto_nego = 1; /* Enable Auto Negotiation */ - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - /* read configuration back */ - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_FALSE(bmcr.en_auto_nego == 1, ESP_FAIL, err, TAG, "enable auto-negotiation failed"); - } - break; - case ESP_ETH_PHY_AUTONEGO_G_STAT: - /* do nothing autonego_en_stat is set at the function end */ - break; - default: - return ESP_ERR_INVALID_ARG; - } - - *autonego_en_stat = bmcr.en_auto_nego; - return ESP_OK; -err: - return ret; -} - -static esp_err_t rtl8201_pwrctl(esp_eth_phy_t *phy, bool enable) -{ - esp_err_t ret = ESP_OK; - phy_rtl8201_t *rtl8201 = __containerof(phy, phy_rtl8201_t, parent); - esp_eth_mediator_t *eth = rtl8201->eth; - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (!enable) { - /* Enable IEEE Power Down Mode */ - bmcr.power_down = 1; - } else { - /* Disable IEEE Power Down Mode */ - bmcr.power_down = 0; - } - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - if (!enable) { - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - ESP_GOTO_ON_FALSE(bmcr.power_down == 1, ESP_FAIL, err, TAG, "power down failed"); - } else { - /* wait for power up complete */ - uint32_t to = 0; - for (to = 0; to < rtl8201->reset_timeout_ms / 10; to++) { - vTaskDelay(pdMS_TO_TICKS(10)); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (bmcr.power_down == 0) { - break; - } - } - ESP_GOTO_ON_FALSE(to < rtl8201->reset_timeout_ms / 10, ESP_FAIL, err, TAG, "power up timeout"); - } - return ESP_OK; -err: - return ret; -} - -static esp_err_t rtl8201_set_addr(esp_eth_phy_t *phy, uint32_t addr) -{ - phy_rtl8201_t *rtl8201 = __containerof(phy, phy_rtl8201_t, parent); - rtl8201->addr = addr; - return ESP_OK; -} - -static esp_err_t rtl8201_get_addr(esp_eth_phy_t *phy, uint32_t *addr) -{ - esp_err_t ret = ESP_OK; - ESP_GOTO_ON_FALSE(addr, ESP_ERR_INVALID_ARG, err, TAG, "addr can't be null"); - phy_rtl8201_t *rtl8201 = __containerof(phy, phy_rtl8201_t, parent); - *addr = rtl8201->addr; - return ESP_OK; -err: - return ret; -} - -static esp_err_t rtl8201_del(esp_eth_phy_t *phy) -{ - phy_rtl8201_t *rtl8201 = __containerof(phy, phy_rtl8201_t, parent); - free(rtl8201); - return ESP_OK; -} - -static esp_err_t rtl8201_advertise_pause_ability(esp_eth_phy_t *phy, uint32_t ability) -{ - esp_err_t ret = ESP_OK; - phy_rtl8201_t *rtl8201 = __containerof(phy, phy_rtl8201_t, parent); - esp_eth_mediator_t *eth = rtl8201->eth; - /* Set PAUSE function ability */ - anar_reg_t anar; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, rtl8201->addr, ETH_PHY_ANAR_REG_ADDR, &(anar.val)), err, TAG, "read ANAR failed"); - if (ability) { - anar.asymmetric_pause = 1; - anar.symmetric_pause = 1; - } else { - anar.asymmetric_pause = 0; - anar.symmetric_pause = 0; - } - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, rtl8201->addr, ETH_PHY_ANAR_REG_ADDR, anar.val), err, TAG, "write ANAR failed"); - return ESP_OK; -err: - return ret; -} - -static esp_err_t rtl8201_loopback(esp_eth_phy_t *phy, bool enable) -{ - esp_err_t ret = ESP_OK; - phy_rtl8201_t *rtl8201 = __containerof(phy, phy_rtl8201_t, parent); - esp_eth_mediator_t *eth = rtl8201->eth; - /* Set Loopback function */ - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - if (enable) { - bmcr.en_loopback = 1; - } else { - bmcr.en_loopback = 0; - } - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - return ESP_OK; -err: - return ret; -} - -static esp_err_t rtl8201_set_speed(esp_eth_phy_t *phy, eth_speed_t speed) -{ - esp_err_t ret = ESP_OK; - phy_rtl8201_t *rtl8201 = __containerof(phy, phy_rtl8201_t, parent); - esp_eth_mediator_t *eth = rtl8201->eth; - if (rtl8201->link_status == ETH_LINK_UP) { - /* Since the link is going to be reconfigured, consider it down for a while */ - rtl8201->link_status = ETH_LINK_DOWN; - /* Indicate to upper stream apps the link is cosidered down */ - ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_LINK, (void *)rtl8201->link_status), err, TAG, "change link failed"); - } - /* Set speed */ - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - bmcr.speed_select = speed; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - - return ESP_OK; -err: - return ret; -} - -static esp_err_t rtl8201_set_duplex(esp_eth_phy_t *phy, eth_duplex_t duplex) -{ - esp_err_t ret = ESP_OK; - phy_rtl8201_t *rtl8201 = __containerof(phy, phy_rtl8201_t, parent); - esp_eth_mediator_t *eth = rtl8201->eth; - - if (rtl8201->link_status == ETH_LINK_UP) { - /* Since the link is going to be reconfigured, consider it down for a while */ - rtl8201->link_status = ETH_LINK_DOWN; - /* Indicate to upper stream apps the link is cosidered down */ - ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_LINK, (void *)rtl8201->link_status), err, TAG, "change link failed"); - } - /* Set duplex mode */ - bmcr_reg_t bmcr; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, &(bmcr.val)), err, TAG, "read BMCR failed"); - bmcr.duplex_mode = duplex; - ESP_GOTO_ON_ERROR(eth->phy_reg_write(eth, rtl8201->addr, ETH_PHY_BMCR_REG_ADDR, bmcr.val), err, TAG, "write BMCR failed"); - - return ESP_OK; -err: - return ret; -} - static esp_err_t rtl8201_init(esp_eth_phy_t *phy) { esp_err_t ret = ESP_OK; - phy_rtl8201_t *rtl8201 = __containerof(phy, phy_rtl8201_t, parent); - esp_eth_mediator_t *eth = rtl8201->eth; - // Detect PHY address - if (rtl8201->addr == ESP_ETH_PHY_ADDR_AUTO) { - ESP_GOTO_ON_ERROR(esp_eth_detect_phy_addr(eth, &rtl8201->addr), err, TAG, "Detect PHY address failed"); - } - /* Power on Ethernet PHY */ - ESP_GOTO_ON_ERROR(rtl8201_pwrctl(phy, true), err, TAG, "power control failed"); - /* Reset Ethernet PHY */ - ESP_GOTO_ON_ERROR(rtl8201_reset(phy), err, TAG, "reset failed"); - /* Check PHY ID */ - phyidr1_reg_t id1; - phyidr2_reg_t id2; - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, rtl8201->addr, ETH_PHY_IDR1_REG_ADDR, &(id1.val)), err, TAG, "read ID1 failed"); - ESP_GOTO_ON_ERROR(eth->phy_reg_read(eth, rtl8201->addr, ETH_PHY_IDR2_REG_ADDR, &(id2.val)), err, TAG, "read ID2 failed"); - ESP_GOTO_ON_FALSE(id1.oui_msb == 0x1C && id2.oui_lsb == 0x32 && id2.vendor_model == 0x1, ESP_FAIL, err, TAG, "wrong chip ID"); - return ESP_OK; -err: - return ret; -} + 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 == 0x732 && model == 0x1, ESP_FAIL, err, TAG, "wrong chip ID"); -static esp_err_t rtl8201_deinit(esp_eth_phy_t *phy) -{ - esp_err_t ret = ESP_OK; - /* Power off Ethernet PHY */ - ESP_GOTO_ON_ERROR(rtl8201_pwrctl(phy, false), err, TAG, "power control failed"); return ESP_OK; err: return ret; @@ -425,31 +140,19 @@ err: esp_eth_phy_t *esp_eth_phy_new_rtl8201(const eth_phy_config_t *config) { esp_eth_phy_t *ret = NULL; - ESP_GOTO_ON_FALSE(config, NULL, err, TAG, "can't set phy config to null"); phy_rtl8201_t *rtl8201 = calloc(1, sizeof(phy_rtl8201_t)); ESP_GOTO_ON_FALSE(rtl8201, NULL, err, TAG, "calloc rtl8201 failed"); - rtl8201->addr = config->phy_addr; - rtl8201->reset_gpio_num = config->reset_gpio_num; - rtl8201->reset_timeout_ms = config->reset_timeout_ms; - rtl8201->link_status = ETH_LINK_DOWN; - rtl8201->autonego_timeout_ms = config->autonego_timeout_ms; - rtl8201->parent.reset = rtl8201_reset; - rtl8201->parent.reset_hw = rtl8201_reset_hw; - rtl8201->parent.init = rtl8201_init; - rtl8201->parent.deinit = rtl8201_deinit; - rtl8201->parent.set_mediator = rtl8201_set_mediator; - rtl8201->parent.autonego_ctrl = rtl8201_autonego_ctrl; - rtl8201->parent.get_link = rtl8201_get_link; - rtl8201->parent.pwrctl = rtl8201_pwrctl; - rtl8201->parent.get_addr = rtl8201_get_addr; - rtl8201->parent.set_addr = rtl8201_set_addr; - rtl8201->parent.advertise_pause_ability = rtl8201_advertise_pause_ability; - rtl8201->parent.loopback = rtl8201_loopback; - rtl8201->parent.set_speed = rtl8201_set_speed; - rtl8201->parent.set_duplex = rtl8201_set_duplex; - rtl8201->parent.del = rtl8201_del; + ESP_GOTO_ON_FALSE(esp_eth_phy_802_3_obj_config_init(&rtl8201->phy_802_3, config) == ESP_OK, + NULL, err, TAG, "configuration initialization of PHY 802.3 failed"); - return &(rtl8201->parent); + // redefine functions which need to be customized for sake of RTL8201 + rtl8201->phy_802_3.parent.init = rtl8201_init; + rtl8201->phy_802_3.parent.get_link = rtl8201_get_link; + + return &rtl8201->phy_802_3.parent; err: + if (rtl8201 != NULL) { + free(rtl8201); + } return ret; } diff --git a/components/esp_eth/src/esp_eth_phy_w5500.c b/components/esp_eth/src/esp_eth_phy_w5500.c index f298fdb1d4..79a4c951ce 100644 --- a/components/esp_eth/src/esp_eth_phy_w5500.c +++ b/components/esp_eth/src/esp_eth_phy_w5500.c @@ -96,7 +96,7 @@ err: static esp_err_t w5500_set_mediator(esp_eth_phy_t *phy, esp_eth_mediator_t *eth) { esp_err_t ret = ESP_OK; - ESP_GOTO_ON_FALSE(eth, ESP_ERR_INVALID_ARG, err, TAG, "can't set mediator to null"); + ESP_GOTO_ON_FALSE(eth, ESP_ERR_INVALID_ARG, err, TAG, "mediator can't be null"); phy_w5500_t *w5500 = __containerof(phy, phy_w5500_t, parent); w5500->eth = eth; return ESP_OK; diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index e781826428..7d8f8671da 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -88,10 +88,12 @@ INPUT = \ $(PROJECT_PATH)/components/esp_common/include/esp_err.h \ $(PROJECT_PATH)/components/esp_common/include/esp_idf_version.h \ $(PROJECT_PATH)/components/esp_eth/include/esp_eth.h \ + $(PROJECT_PATH)/components/esp_eth/include/esp_eth_driver.h \ $(PROJECT_PATH)/components/esp_eth/include/esp_eth_com.h \ $(PROJECT_PATH)/components/esp_eth/include/esp_eth_mac.h \ $(PROJECT_PATH)/components/esp_eth/include/esp_eth_netif_glue.h \ $(PROJECT_PATH)/components/esp_eth/include/esp_eth_phy.h \ + $(PROJECT_PATH)/components/esp_eth/include/esp_eth_phy_802_3.h \ $(PROJECT_PATH)/components/esp_event/include/esp_event.h \ $(PROJECT_PATH)/components/esp_event/include/esp_event_base.h \ $(PROJECT_PATH)/components/esp_http_client/include/esp_http_client.h \ diff --git a/docs/en/api-reference/network/esp_eth.rst b/docs/en/api-reference/network/esp_eth.rst index da1392bb0a..56bec1fff3 100644 --- a/docs/en/api-reference/network/esp_eth.rst +++ b/docs/en/api-reference/network/esp_eth.rst @@ -441,21 +441,59 @@ One thing should be kept in mind, is that the pause frame ability will be advert .. -------------------------------- Examples ----------------------------------- -Application Example -------------------- +Application Examples +-------------------- * Ethernet basic example: :example:`ethernet/basic`. * Ethernet iperf example: :example:`ethernet/iperf`. * Ethernet to Wi-Fi AP "router": :example:`ethernet/eth2ap`. * Most of protocol examples should also work for Ethernet: :example:`protocols`. +.. ------------------------------ Advanced Topics ------------------------------- + +.. _advanced-topics: + +Advanced Topics +--------------- + +Custom PHY Driver +^^^^^^^^^^^^^^^^^ + +There are multiple PHY manufactures with their wide portfolios of chips available. The ESP-IDF already supports several PHY chips however one can easily get to a point where none of them satisfies user's actual needs due to either price, features, stock availability etc. + +Luckily, a management interface between EMAC and PHY is standardized by IEEE 802.3 in 22.2.4 Management functions section. It defines provisions of so called “MII Management Interface” for the purposes of controlling the PHY and gathering status from the PHY. A set of management registers is defined to control chip behavior, link properties, auto-negotiation configuration etc. This basic management functionality is addressed by :component_file:`esp_eth/src/esp_eth_phy_802_3.c` in ESP-IDF and so it makes a creation of new custom PHY chip driver quite a simple task. + +.. note:: + Always consult with PHY datasheet since some PHY chips may not comply with IEEE 802.3, Section 22.2.4. It does not mean you are not able to create a custom PHY driver, it will just require more effort. You will have to define all PHY management functions. + +Majority of PHY management functionality required by the ESP-IDF Ethernet driver is covered by the :component_file:`esp_eth/src/esp_eth_phy_802_3.c` however, the following may require developing chip specific management functions: + + * link status which is almost always chip specific, + * chip initialization, even though it is not strictly required, should be customized to at least ensure that expected chip is used and + * chip specific features configuration. + +**Steps to create custom PHY driver:** + +1. Define vendor specific registry layout based on PHY datasheet. See :component_file:`esp_eth/src/esp_eth_phy_ip101.c` as an example. +2. Prepare derived PHY management object infostructure which + + * must contain at least parent IEEE 802.3 :cpp:class:`phy_802_3_t` object and + * optionally contain additional variables needed to support non-IEEE 802.3 or customized functionality. See :component_file:`esp_eth/src/esp_eth_phy_ksz80xx.c` as an example. + +3. Define chip specific management call-back functions. +4. Initialize parent IEEE 802.3 object and re-assign chip specific management call-back functions. + +Once you finish the new custom PHY driver implementation, consider sharing it among with other users via `IDF Component Registry `_. + .. ---------------------------- API Reference ---------------------------------- API Reference ------------- .. include-build-file:: inc/esp_eth.inc +.. include-build-file:: inc/esp_eth_driver.inc .. include-build-file:: inc/esp_eth_com.inc .. include-build-file:: inc/esp_eth_mac.inc .. include-build-file:: inc/esp_eth_phy.inc +.. include-build-file:: inc/esp_eth_phy_802_3.inc .. include-build-file:: inc/esp_eth_netif_glue.inc diff --git a/docs/en/migration-guides/ethernet.rst b/docs/en/migration-guides/ethernet.rst index e773e46bea..15b3cd05d7 100644 --- a/docs/en/migration-guides/ethernet.rst +++ b/docs/en/migration-guides/ethernet.rst @@ -47,3 +47,6 @@ ESP NETIF Glue Event Handlers ----------------------------- ``esp_eth_set_default_handlers()`` and ``esp_eth_clear_default_handlers()`` functions were removed. Registration of the default IP layer handlers for Ethernet is now handled automatically. If users have already followed the recommendation to fully initialize the Ethernet driver and network interface prior to registering their Ethernet/IP event handlers, then no action is required (except for deleting the affected functions). Otherwise, users should ensure that they register the user event handlers as the last thing prior to starting the Ethernet driver. +PHY Address Auto-detect +----------------------- +Ethernet PHY address auto-detect function ``esp_eth_detect_phy_addr`` was renamed to :cpp:func:`esp_eth_phy_802_3_detect_phy_addr` and its header declaration was moved to :component_file:`esp_eth/include/esp_eth_phy_802_3.h`. \ No newline at end of file diff --git a/docs/zh_CN/api-reference/network/esp_eth.rst b/docs/zh_CN/api-reference/network/esp_eth.rst index 977a7377e3..dd6eeb269d 100644 --- a/docs/zh_CN/api-reference/network/esp_eth.rst +++ b/docs/zh_CN/api-reference/network/esp_eth.rst @@ -32,7 +32,7 @@ 以太网 PHY 公共寄存器 ----------------------------- - * :component_file:`esp_eth/include/eth_phy_regs_struct.h` + * :component_file:`esp_eth/include/eth_phy_802_3_regs.h` API 参考 -- 驱动程序模型 ---------------------------- diff --git a/examples/ethernet/enc28j60/components/eth_enc28j60/esp_eth_phy_enc28j60.c b/examples/ethernet/enc28j60/components/eth_enc28j60/esp_eth_phy_enc28j60.c index da3ba23b66..d6b30046ca 100644 --- a/examples/ethernet/enc28j60/components/eth_enc28j60/esp_eth_phy_enc28j60.c +++ b/examples/ethernet/enc28j60/components/eth_enc28j60/esp_eth_phy_enc28j60.c @@ -8,7 +8,7 @@ #include #include "esp_log.h" #include "esp_eth.h" -#include "eth_phy_regs_struct.h" +#include "eth_phy_802_3_regs.h" #include "esp_eth_enc28j60.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index fbff6c06ae..1e2184f832 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -417,7 +417,6 @@ components/esp32/include/rom/spi_flash.h components/esp32/include/rom/tbconsole.h components/esp32/include/rom/tjpgd.h components/esp32/include/rom/uart.h -components/esp_eth/include/eth_phy_regs_struct.h components/esp_eth/src/dm9051.h components/esp_eth/src/ksz8851.h components/esp_eth/src/openeth.h From dfa33dc853b0d80c23ebf8ad435b661a8236da2c Mon Sep 17 00:00:00 2001 From: Ondrej Kosta Date: Wed, 22 Jun 2022 11:05:18 +0200 Subject: [PATCH 2/2] Ethernet basic example: removed sdkconfig_GW_issue which was configured by a mistake --- examples/ethernet/basic/sdkconfig_GW_issue | 1568 -------------------- 1 file changed, 1568 deletions(-) delete mode 100644 examples/ethernet/basic/sdkconfig_GW_issue diff --git a/examples/ethernet/basic/sdkconfig_GW_issue b/examples/ethernet/basic/sdkconfig_GW_issue deleted file mode 100644 index 721e606e33..0000000000 --- a/examples/ethernet/basic/sdkconfig_GW_issue +++ /dev/null @@ -1,1568 +0,0 @@ -# -# Automatically generated file. DO NOT EDIT. -# Espressif IoT Development Framework (ESP-IDF) Project Configuration -# -CONFIG_SOC_BROWNOUT_RESET_SUPPORTED="Not determined" -CONFIG_SOC_TWAI_BRP_DIV_SUPPORTED="Not determined" -CONFIG_SOC_CAPS_ECO_VER_MAX=3 -CONFIG_SOC_ADC_SUPPORTED=y -CONFIG_SOC_DAC_SUPPORTED=y -CONFIG_SOC_MCPWM_SUPPORTED=y -CONFIG_SOC_SDMMC_HOST_SUPPORTED=y -CONFIG_SOC_BT_SUPPORTED=y -CONFIG_SOC_BLUEDROID_SUPPORTED=y -CONFIG_SOC_CLASSIC_BT_SUPPORTED=y -CONFIG_SOC_PCNT_SUPPORTED=y -CONFIG_SOC_WIFI_SUPPORTED=y -CONFIG_SOC_SDIO_SLAVE_SUPPORTED=y -CONFIG_SOC_TWAI_SUPPORTED=y -CONFIG_SOC_EMAC_SUPPORTED=y -CONFIG_SOC_CPU_CORES_NUM=2 -CONFIG_SOC_ULP_SUPPORTED=y -CONFIG_SOC_CCOMP_TIMER_SUPPORTED=y -CONFIG_SOC_RTC_FAST_MEM_SUPPORTED=y -CONFIG_SOC_RTC_SLOW_MEM_SUPPORTED=y -CONFIG_SOC_I2S_SUPPORTED=y -CONFIG_SOC_RMT_SUPPORTED=y -CONFIG_SOC_SIGMADELTA_SUPPORTED=y -CONFIG_SOC_SUPPORT_COEXISTENCE=y -CONFIG_SOC_AES_SUPPORTED=y -CONFIG_SOC_MPI_SUPPORTED=y -CONFIG_SOC_SHA_SUPPORTED=y -CONFIG_SOC_FLASH_ENC_SUPPORTED=y -CONFIG_SOC_SECURE_BOOT_SUPPORTED=y -CONFIG_SOC_ADC_RTC_CTRL_SUPPORTED=y -CONFIG_SOC_ADC_DIG_CTRL_SUPPORTED=y -CONFIG_SOC_ADC_PERIPH_NUM=2 -CONFIG_SOC_ADC_MAX_CHANNEL_NUM=10 -CONFIG_SOC_ADC_ATTEN_NUM=4 -CONFIG_SOC_ADC_DIGI_CONTROLLER_NUM=2 -CONFIG_SOC_ADC_PATT_LEN_MAX=16 -CONFIG_SOC_ADC_DIGI_MIN_BITWIDTH=9 -CONFIG_SOC_ADC_DIGI_MAX_BITWIDTH=12 -CONFIG_SOC_ADC_SAMPLE_FREQ_THRES_HIGH=2 -CONFIG_SOC_ADC_SAMPLE_FREQ_THRES_LOW=2000 -CONFIG_SOC_ADC_RTC_MIN_BITWIDTH=9 -CONFIG_SOC_ADC_RTC_MAX_BITWIDTH=12 -CONFIG_SOC_RTC_SLOW_CLOCK_SUPPORT_8MD256=y -CONFIG_SOC_SHARED_IDCACHE_SUPPORTED=y -CONFIG_SOC_CPU_BREAKPOINTS_NUM=2 -CONFIG_SOC_CPU_WATCHPOINTS_NUM=2 -CONFIG_SOC_CPU_WATCHPOINT_SIZE=64 -CONFIG_SOC_CPU_HAS_FPU=y -CONFIG_SOC_DAC_PERIPH_NUM=2 -CONFIG_SOC_DAC_RESOLUTION=8 -CONFIG_SOC_GPIO_PORT=1 -CONFIG_SOC_GPIO_PIN_COUNT=40 -CONFIG_SOC_GPIO_VALID_GPIO_MASK=0xFFFFFFFFFF -CONFIG_SOC_GPIO_SUPPORT_SLP_SWITCH=y -CONFIG_SOC_I2C_NUM=2 -CONFIG_SOC_I2C_FIFO_LEN=32 -CONFIG_SOC_I2C_SUPPORT_SLAVE=y -CONFIG_SOC_I2C_SUPPORT_APB=y -CONFIG_SOC_CLK_APLL_SUPPORTED=y -CONFIG_SOC_APLL_MULTIPLIER_OUT_MIN_HZ=350000000 -CONFIG_SOC_APLL_MULTIPLIER_OUT_MAX_HZ=500000000 -CONFIG_SOC_APLL_MIN_HZ=5303031 -CONFIG_SOC_APLL_MAX_HZ=125000000 -CONFIG_SOC_I2S_NUM=2 -CONFIG_SOC_I2S_HW_VERSION_1=y -CONFIG_SOC_I2S_SUPPORTS_APLL=y -CONFIG_SOC_I2S_SUPPORTS_PDM=y -CONFIG_SOC_I2S_SUPPORTS_PDM_TX=y -CONFIG_SOC_I2S_SUPPORTS_PDM_RX=y -CONFIG_SOC_I2S_SUPPORTS_ADC_DAC=y -CONFIG_SOC_I2S_SUPPORTS_ADC=y -CONFIG_SOC_I2S_SUPPORTS_DAC=y -CONFIG_SOC_I2S_SUPPORTS_LCD_CAMERA=y -CONFIG_SOC_I2S_TRANS_SIZE_ALIGN_WORD=y -CONFIG_SOC_I2S_LCD_I80_VARIANT=y -CONFIG_SOC_LCD_I80_SUPPORTED=y -CONFIG_SOC_LCD_I80_BUSES=2 -CONFIG_SOC_LCD_I80_BUS_WIDTH=24 -CONFIG_SOC_LEDC_HAS_TIMER_SPECIFIC_MUX=y -CONFIG_SOC_LEDC_SUPPORT_APB_CLOCK=y -CONFIG_SOC_LEDC_SUPPORT_REF_TICK=y -CONFIG_SOC_LEDC_SUPPORT_HS_MODE=y -CONFIG_SOC_LEDC_CHANNEL_NUM=8 -CONFIG_SOC_LEDC_TIMER_BIT_WIDE_NUM=20 -CONFIG_SOC_MCPWM_GROUPS=2 -CONFIG_SOC_MCPWM_TIMERS_PER_GROUP=3 -CONFIG_SOC_MCPWM_OPERATORS_PER_GROUP=3 -CONFIG_SOC_MCPWM_COMPARATORS_PER_OPERATOR=2 -CONFIG_SOC_MCPWM_GENERATORS_PER_OPERATOR=2 -CONFIG_SOC_MCPWM_TRIGGERS_PER_OPERATOR=2 -CONFIG_SOC_MCPWM_GPIO_FAULTS_PER_GROUP=3 -CONFIG_SOC_MCPWM_CAPTURE_TIMERS_PER_GROUP=y -CONFIG_SOC_MCPWM_CAPTURE_CHANNELS_PER_TIMER=3 -CONFIG_SOC_MCPWM_GPIO_SYNCHROS_PER_GROUP=3 -CONFIG_SOC_MCPWM_BASE_CLK_HZ=160000000 -CONFIG_SOC_MPU_MIN_REGION_SIZE=0x20000000 -CONFIG_SOC_MPU_REGIONS_MAX_NUM=8 -CONFIG_SOC_PCNT_GROUPS=1 -CONFIG_SOC_PCNT_UNITS_PER_GROUP=8 -CONFIG_SOC_PCNT_CHANNELS_PER_UNIT=2 -CONFIG_SOC_PCNT_THRES_POINT_PER_UNIT=2 -CONFIG_SOC_RMT_GROUPS=1 -CONFIG_SOC_RMT_TX_CANDIDATES_PER_GROUP=8 -CONFIG_SOC_RMT_RX_CANDIDATES_PER_GROUP=8 -CONFIG_SOC_RMT_CHANNELS_PER_GROUP=8 -CONFIG_SOC_RMT_MEM_WORDS_PER_CHANNEL=64 -CONFIG_SOC_RMT_SUPPORT_REF_TICK=y -CONFIG_SOC_RMT_SUPPORT_APB=y -CONFIG_SOC_RMT_CHANNEL_CLK_INDEPENDENT=y -CONFIG_SOC_RTCIO_PIN_COUNT=18 -CONFIG_SOC_RTCIO_INPUT_OUTPUT_SUPPORTED=y -CONFIG_SOC_RTCIO_HOLD_SUPPORTED=y -CONFIG_SOC_RTCIO_WAKE_SUPPORTED=y -CONFIG_SOC_SIGMADELTA_NUM=1 -CONFIG_SOC_SIGMADELTA_CHANNEL_NUM=8 -CONFIG_SOC_SPI_HD_BOTH_INOUT_SUPPORTED=y -CONFIG_SOC_SPI_AS_CS_SUPPORTED=y -CONFIG_SOC_SPI_PERIPH_NUM=3 -CONFIG_SOC_SPI_DMA_CHAN_NUM=2 -CONFIG_SOC_SPI_MAXIMUM_BUFFER_SIZE=64 -CONFIG_SOC_SPI_MAX_PRE_DIVIDER=8192 -CONFIG_SOC_MEMSPI_SRC_FREQ_80M_SUPPORTED=y -CONFIG_SOC_MEMSPI_SRC_FREQ_40M_SUPPORTED=y -CONFIG_SOC_MEMSPI_SRC_FREQ_26M_SUPPORTED=y -CONFIG_SOC_MEMSPI_SRC_FREQ_20M_SUPPORTED=y -CONFIG_SOC_TIMER_GROUPS=2 -CONFIG_SOC_TIMER_GROUP_TIMERS_PER_GROUP=2 -CONFIG_SOC_TIMER_GROUP_COUNTER_BIT_WIDTH=64 -CONFIG_SOC_TIMER_GROUP_TOTAL_TIMERS=4 -CONFIG_SOC_TIMER_GROUP_SUPPORT_APB=y -CONFIG_SOC_TOUCH_VERSION_1=y -CONFIG_SOC_TOUCH_SENSOR_NUM=10 -CONFIG_SOC_TOUCH_PAD_MEASURE_WAIT_MAX=0xFF -CONFIG_SOC_TWAI_BRP_MIN=2 -CONFIG_SOC_TWAI_SUPPORT_MULTI_ADDRESS_LAYOUT=y -CONFIG_SOC_UART_NUM=3 -CONFIG_SOC_UART_SUPPORT_REF_TICK=y -CONFIG_SOC_UART_FIFO_LEN=128 -CONFIG_SOC_UART_BITRATE_MAX=5000000 -CONFIG_SOC_SPIRAM_SUPPORTED=y -CONFIG_SOC_SHA_SUPPORT_PARALLEL_ENG=y -CONFIG_SOC_SHA_SUPPORT_SHA1=y -CONFIG_SOC_SHA_SUPPORT_SHA256=y -CONFIG_SOC_SHA_SUPPORT_SHA384=y -CONFIG_SOC_SHA_SUPPORT_SHA512=y -CONFIG_SOC_RSA_MAX_BIT_LEN=4096 -CONFIG_SOC_AES_SUPPORT_AES_128=y -CONFIG_SOC_AES_SUPPORT_AES_192=y -CONFIG_SOC_AES_SUPPORT_AES_256=y -CONFIG_SOC_SECURE_BOOT_V1=y -CONFIG_SOC_EFUSE_SECURE_BOOT_KEY_DIGESTS=y -CONFIG_SOC_FLASH_ENCRYPTED_XTS_AES_BLOCK_MAX=32 -CONFIG_SOC_PHY_DIG_REGS_MEM_SIZE=21 -CONFIG_SOC_PM_SUPPORT_EXT_WAKEUP=y -CONFIG_SOC_PM_SUPPORT_TOUCH_SENSOR_WAKEUP=y -CONFIG_SOC_PM_SUPPORT_RTC_PERIPH_PD=y -CONFIG_SOC_SDMMC_USE_IOMUX=y -CONFIG_SOC_SDMMC_NUM_SLOTS=2 -CONFIG_SOC_BLE_DONT_UPDATE_OWN_RPA=y -CONFIG_IDF_CMAKE=y -CONFIG_IDF_TARGET_ARCH_XTENSA=y -CONFIG_IDF_TARGET_ARCH="xtensa" -CONFIG_IDF_TARGET="esp32" -CONFIG_IDF_TARGET_ESP32=y -CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000 - -# -# Build type -# -CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y -# CONFIG_APP_BUILD_TYPE_ELF_RAM is not set -CONFIG_APP_BUILD_GENERATE_BINARIES=y -CONFIG_APP_BUILD_BOOTLOADER=y -CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y -# CONFIG_APP_REPRODUCIBLE_BUILD is not set -# CONFIG_APP_NO_BLOBS is not set -# end of Build type - -# -# Application manager -# -CONFIG_APP_COMPILE_TIME_DATE=y -# CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set -# CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set -# CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set -CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 -# end of Application manager - -# -# Bootloader config -# -CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x1000 -CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y -# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set -# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set -# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set -# CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set -# CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set -# CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set -CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y -# CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set -# CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set -CONFIG_BOOTLOADER_LOG_LEVEL=3 -# CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_8V is not set -CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V=y -# CONFIG_BOOTLOADER_FACTORY_RESET is not set -# CONFIG_BOOTLOADER_APP_TEST is not set -CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE=y -CONFIG_BOOTLOADER_WDT_ENABLE=y -# CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set -CONFIG_BOOTLOADER_WDT_TIME_MS=9000 -# CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set -# CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP is not set -# CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON is not set -# CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set -CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 -# CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set -CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT=y -# end of Bootloader config - -# -# Security features -# -CONFIG_SECURE_BOOT_V1_SUPPORTED=y -# CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set -# CONFIG_SECURE_BOOT is not set -# CONFIG_SECURE_FLASH_ENC_ENABLED is not set -# end of Security features - -CONFIG_ESP_ROM_HAS_CRC_LE=y -CONFIG_ESP_ROM_HAS_CRC_BE=y -CONFIG_ESP_ROM_HAS_JPEG_DECODE=y -CONFIG_ESP_ROM_SUPPORT_MULTIPLE_UART=y - -# -# Serial flasher config -# -# CONFIG_ESPTOOLPY_NO_STUB is not set -# CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set -# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set -CONFIG_ESPTOOLPY_FLASHMODE_DIO=y -# CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set -CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y -CONFIG_ESPTOOLPY_FLASHMODE="dio" -# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set -CONFIG_ESPTOOLPY_FLASHFREQ_40M=y -# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set -CONFIG_ESPTOOLPY_FLASHFREQ="40m" -# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set -CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y -# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set -# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set -# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set -# CONFIG_ESPTOOLPY_FLASHSIZE_32MB is not set -# CONFIG_ESPTOOLPY_FLASHSIZE_64MB is not set -# CONFIG_ESPTOOLPY_FLASHSIZE_128MB is not set -CONFIG_ESPTOOLPY_FLASHSIZE="2MB" -CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y -CONFIG_ESPTOOLPY_BEFORE_RESET=y -# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set -CONFIG_ESPTOOLPY_BEFORE="default_reset" -CONFIG_ESPTOOLPY_AFTER_RESET=y -# CONFIG_ESPTOOLPY_AFTER_NORESET is not set -CONFIG_ESPTOOLPY_AFTER="hard_reset" -CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 -# end of Serial flasher config - -# -# Partition Table -# -CONFIG_PARTITION_TABLE_SINGLE_APP=y -# CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE is not set -# CONFIG_PARTITION_TABLE_TWO_OTA is not set -# CONFIG_PARTITION_TABLE_CUSTOM is not set -CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" -CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv" -CONFIG_PARTITION_TABLE_OFFSET=0x8000 -CONFIG_PARTITION_TABLE_MD5=y -# end of Partition Table - -# -# Example Configuration -# -CONFIG_ENV_GPIO_RANGE_MIN=0 -CONFIG_ENV_GPIO_RANGE_MAX=39 -CONFIG_ENV_GPIO_IN_RANGE_MAX=39 -CONFIG_ENV_GPIO_OUT_RANGE_MAX=33 -CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=y -CONFIG_EXAMPLE_ETH_PHY_IP101=y -# CONFIG_EXAMPLE_ETH_PHY_RTL8201 is not set -# CONFIG_EXAMPLE_ETH_PHY_LAN87XX is not set -# CONFIG_EXAMPLE_ETH_PHY_DP83848 is not set -# CONFIG_EXAMPLE_ETH_PHY_KSZ80XX is not set -CONFIG_EXAMPLE_ETH_MDC_GPIO=23 -CONFIG_EXAMPLE_ETH_MDIO_GPIO=18 -CONFIG_EXAMPLE_ETH_PHY_RST_GPIO=5 -CONFIG_EXAMPLE_ETH_PHY_ADDR=1 -# CONFIG_EXAMPLE_USE_SPI_ETHERNET is not set -# end of Example Configuration - -# -# Compiler options -# -CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y -# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set -# CONFIG_COMPILER_OPTIMIZATION_PERF is not set -# CONFIG_COMPILER_OPTIMIZATION_NONE is not set -CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y -# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set -# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set -CONFIG_COMPILER_FLOAT_LIB_FROM_GCCLIB=y -CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=2 -# CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT is not set -CONFIG_COMPILER_HIDE_PATHS_MACROS=y -# CONFIG_COMPILER_CXX_EXCEPTIONS is not set -# CONFIG_COMPILER_CXX_RTTI is not set -CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y -# CONFIG_COMPILER_STACK_CHECK_MODE_NORM is not set -# CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set -# CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set -# CONFIG_COMPILER_WARN_WRITE_STRINGS is not set -# CONFIG_COMPILER_DISABLE_GCC8_WARNINGS is not set -# CONFIG_COMPILER_DUMP_RTL_FILES is not set -# end of Compiler options - -# -# Component config -# - -# -# Application Level Tracing -# -# CONFIG_APPTRACE_DEST_JTAG is not set -CONFIG_APPTRACE_DEST_NONE=y -# CONFIG_APPTRACE_DEST_UART1 is not set -# CONFIG_APPTRACE_DEST_UART2 is not set -CONFIG_APPTRACE_DEST_UART_NONE=y -CONFIG_APPTRACE_UART_TASK_PRIO=1 -CONFIG_APPTRACE_LOCK_ENABLE=y -# end of Application Level Tracing - -# -# ESP-ASIO -# -# CONFIG_ASIO_SSL_SUPPORT is not set -# end of ESP-ASIO - -# -# Bluetooth -# -# CONFIG_BT_ENABLED is not set -# end of Bluetooth - -# -# Driver configurations -# - -# -# ADC configuration -# -# CONFIG_ADC_FORCE_XPD_FSM is not set -CONFIG_ADC_DISABLE_DAC=y -# end of ADC configuration - -# -# MCPWM configuration -# -# CONFIG_MCPWM_ISR_IN_IRAM is not set -# end of MCPWM configuration - -# -# SPI configuration -# -# CONFIG_SPI_MASTER_IN_IRAM is not set -CONFIG_SPI_MASTER_ISR_IN_IRAM=y -# CONFIG_SPI_SLAVE_IN_IRAM is not set -CONFIG_SPI_SLAVE_ISR_IN_IRAM=y -# end of SPI configuration - -# -# TWAI configuration -# -# CONFIG_TWAI_ISR_IN_IRAM 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 -# end of TWAI configuration - -# -# UART configuration -# -# CONFIG_UART_ISR_IN_IRAM is not set -# end of UART configuration - -# -# GPIO Configuration -# -# CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL is not set -# CONFIG_GPIO_CTRL_FUNC_IN_IRAM is not set -# end of GPIO Configuration - -# -# GPTimer Configuration -# -# CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM is not set -# CONFIG_GPTIMER_ISR_IRAM_SAFE is not set -# CONFIG_GPTIMER_SUPPRESS_DEPRECATE_WARN is not set -# CONFIG_GPTIMER_ENABLE_DEBUG_LOG is not set -# end of GPTimer Configuration - -# -# PCNT Configuration -# -# CONFIG_PCNT_CTRL_FUNC_IN_IRAM is not set -# CONFIG_PCNT_ISR_IRAM_SAFE is not set -# CONFIG_PCNT_SUPPRESS_DEPRECATE_WARN is not set -# CONFIG_PCNT_ENABLE_DEBUG_LOG is not set -# end of PCNT Configuration - -# -# RMT Configuration -# -# CONFIG_RMT_ISR_IRAM_SAFE is not set -# CONFIG_RMT_SUPPRESS_DEPRECATE_WARN is not set -# CONFIG_RMT_ENABLE_DEBUG_LOG is not set -# end of RMT Configuration -# end of Driver configurations - -# -# eFuse Bit Manager -# -# CONFIG_EFUSE_CUSTOM_TABLE is not set -# CONFIG_EFUSE_VIRTUAL is not set -# CONFIG_EFUSE_CODE_SCHEME_COMPAT_NONE is not set -CONFIG_EFUSE_CODE_SCHEME_COMPAT_3_4=y -# CONFIG_EFUSE_CODE_SCHEME_COMPAT_REPEAT is not set -CONFIG_EFUSE_MAX_BLK_LEN=192 -# end of eFuse Bit Manager - -# -# ESP-TLS -# -CONFIG_ESP_TLS_USING_MBEDTLS=y -# CONFIG_ESP_TLS_USE_SECURE_ELEMENT is not set -# CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set -# CONFIG_ESP_TLS_SERVER is not set -# CONFIG_ESP_TLS_PSK_VERIFICATION is not set -# CONFIG_ESP_TLS_INSECURE is not set -# end of ESP-TLS - -# -# ESP32-specific -# -CONFIG_ESP32_DPORT_WORKAROUND=y -# CONFIG_ESP32_SPIRAM_SUPPORT is not set -# CONFIG_ESP32_TRAX is not set -CONFIG_ESP32_TRACEMEM_RESERVE_DRAM=0x0 -CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=2000 -CONFIG_ESP32_XTAL_FREQ_40=y -# CONFIG_ESP32_XTAL_FREQ_26 is not set -# CONFIG_ESP32_XTAL_FREQ_AUTO is not set -CONFIG_ESP32_XTAL_FREQ=40 -# CONFIG_ESP32_DISABLE_BASIC_ROM_CONSOLE is not set -# CONFIG_ESP32_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set -# CONFIG_ESP32_COMPATIBLE_PRE_V3_1_BOOTLOADERS is not set -# CONFIG_ESP32_USE_FIXED_STATIC_RAM_SIZE is not set -CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL=5 -# end of ESP32-specific - -# -# ADC-Calibration -# -CONFIG_ADC_CAL_EFUSE_TP_ENABLE=y -CONFIG_ADC_CAL_EFUSE_VREF_ENABLE=y -CONFIG_ADC_CAL_LUT_ENABLE=y -# end of ADC-Calibration - -# -# Common ESP-related -# -CONFIG_ESP_ERR_TO_NAME_LOOKUP=y -# end of Common ESP-related - -# -# Ethernet -# -CONFIG_ETH_ENABLED=y -CONFIG_ETH_USE_ESP32_EMAC=y -CONFIG_ETH_PHY_INTERFACE_RMII=y -CONFIG_ETH_RMII_CLK_INPUT=y -# CONFIG_ETH_RMII_CLK_OUTPUT is not set -CONFIG_ETH_RMII_CLK_IN_GPIO=0 -CONFIG_ETH_DMA_BUFFER_SIZE=512 -CONFIG_ETH_DMA_RX_BUFFER_NUM=10 -CONFIG_ETH_DMA_TX_BUFFER_NUM=10 -CONFIG_ETH_USE_SPI_ETHERNET=y -# CONFIG_ETH_SPI_ETHERNET_DM9051 is not set -CONFIG_ETH_SPI_ETHERNET_W5500=y -# CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL is not set -# CONFIG_ETH_USE_OPENETH is not set -# CONFIG_ETH_TRANSMIT_MUTEX is not set -# end of Ethernet - -# -# Event Loop Library -# -# CONFIG_ESP_EVENT_LOOP_PROFILING is not set -CONFIG_ESP_EVENT_POST_FROM_ISR=y -CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y -# end of Event Loop Library - -# -# GDB Stub -# -# end of GDB Stub - -# -# ESP HTTP client -# -CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y -# CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set -# CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH is not set -# end of ESP HTTP client - -# -# HTTP Server -# -CONFIG_HTTPD_MAX_REQ_HDR_LEN=512 -CONFIG_HTTPD_MAX_URI_LEN=512 -CONFIG_HTTPD_ERR_RESP_NO_DELAY=y -CONFIG_HTTPD_PURGE_BUF_LEN=32 -# CONFIG_HTTPD_LOG_PURGE_DATA is not set -# CONFIG_HTTPD_WS_SUPPORT is not set -# CONFIG_HTTPD_QUEUE_WORK_BLOCKING is not set -# end of HTTP Server - -# -# ESP HTTPS OTA -# -# CONFIG_ESP_HTTPS_OTA_DECRYPT_CB is not set -# CONFIG_ESP_HTTPS_OTA_ALLOW_HTTP is not set -# end of ESP HTTPS OTA - -# -# ESP HTTPS server -# -# CONFIG_ESP_HTTPS_SERVER_ENABLE is not set -# end of ESP HTTPS server - -# -# Hardware Settings -# - -# -# MAC Config -# -CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y -CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y -CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y -CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y -# CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_TWO is not set -CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR=y -CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4 -# end of MAC Config - -# -# Sleep Config -# -CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y -CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y -# CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND is not set -# CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND is not set -# end of Sleep Config - -# -# RTC Clock Config -# -CONFIG_RTC_CLK_SRC_INT_RC=y -# CONFIG_RTC_CLK_SRC_EXT_CRYS is not set -# CONFIG_RTC_CLK_SRC_EXT_OSC is not set -# CONFIG_RTC_CLK_SRC_INT_8MD256 is not set -CONFIG_RTC_CLK_CAL_CYCLES=1024 -# end of RTC Clock Config - -# -# Peripheral Control -# -# CONFIG_PERIPH_CTRL_FUNC_IN_IRAM is not set -# end of Peripheral Control - -CONFIG_ESP32_REV_MIN_0=y -# CONFIG_ESP32_REV_MIN_1 is not set -# CONFIG_ESP32_REV_MIN_2 is not set -# CONFIG_ESP32_REV_MIN_3 is not set -CONFIG_ESP32_REV_MIN=0 -# end of Hardware Settings - -# -# LCD and Touch Panel -# - -# -# LCD Peripheral Configuration -# -CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE=32 -# CONFIG_LCD_ENABLE_DEBUG_LOG is not set -# end of LCD Peripheral Configuration -# end of LCD and Touch Panel - -# -# ESP NETIF Adapter -# -CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120 -CONFIG_ESP_NETIF_TCPIP_LWIP=y -# CONFIG_ESP_NETIF_LOOPBACK is not set -# CONFIG_ESP_NETIF_L2_TAP is not set -# end of ESP NETIF Adapter - -# -# PHY -# -CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y -# CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set -CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20 -CONFIG_ESP_PHY_MAX_TX_POWER=20 -CONFIG_ESP_PHY_REDUCE_TX_POWER=y -# end of PHY - -# -# Power Management -# -# CONFIG_PM_ENABLE is not set -# end of Power Management - -# -# ESP System Settings -# -# CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_80 is not set -CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_160=y -# CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240 is not set -CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=160 -# CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set -CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y -# CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set -# CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set -# CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set - -# -# Memory protection -# -# end of Memory protection - -CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32 -CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2304 -CONFIG_ESP_MAIN_TASK_STACK_SIZE=3584 -CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y -# CONFIG_ESP_MAIN_TASK_AFFINITY_CPU1 is not set -# CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set -CONFIG_ESP_MAIN_TASK_AFFINITY=0x0 -CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048 -CONFIG_ESP_CONSOLE_UART_DEFAULT=y -# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set -# CONFIG_ESP_CONSOLE_NONE is not set -CONFIG_ESP_CONSOLE_UART=y -CONFIG_ESP_CONSOLE_MULTIPLE_UART=y -CONFIG_ESP_CONSOLE_UART_NUM=0 -CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 -CONFIG_ESP_INT_WDT=y -CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 -CONFIG_ESP_INT_WDT_CHECK_CPU1=y -CONFIG_ESP_TASK_WDT=y -# CONFIG_ESP_TASK_WDT_PANIC is not set -CONFIG_ESP_TASK_WDT_TIMEOUT_S=5 -CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y -CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y -# CONFIG_ESP_PANIC_HANDLER_IRAM is not set -# CONFIG_ESP_DEBUG_STUBS_ENABLE is not set -CONFIG_ESP_DEBUG_OCDAWARE=y -# CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_5 is not set -CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4=y - -# -# Brownout Detector -# -CONFIG_ESP_BROWNOUT_DET=y -CONFIG_ESP_BROWNOUT_DET_LVL_SEL_0=y -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_1 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_2 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_3 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_4 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_5 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_6 is not set -# CONFIG_ESP_BROWNOUT_DET_LVL_SEL_7 is not set -CONFIG_ESP_BROWNOUT_DET_LVL=0 -# end of Brownout Detector -# end of ESP System Settings - -# -# IPC (Inter-Processor Call) -# -CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 -CONFIG_ESP_IPC_USES_CALLERS_PRIORITY=y -CONFIG_ESP_IPC_ISR_ENABLE=y -# end of IPC (Inter-Processor Call) - -# -# High resolution timer (esp_timer) -# -# CONFIG_ESP_TIMER_PROFILING is not set -CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER=y -CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER=y -CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584 -CONFIG_ESP_TIMER_INTERRUPT_LEVEL=1 -# CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is not set -CONFIG_ESP_TIMER_IMPL_TG0_LAC=y -# end of High resolution timer (esp_timer) - -# -# Wi-Fi -# -CONFIG_ESP32_WIFI_ENABLED=y -CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 -CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 -# CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set -CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y -CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 -CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 -# CONFIG_ESP32_WIFI_CSI_ENABLED is not set -CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y -CONFIG_ESP32_WIFI_TX_BA_WIN=6 -CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y -CONFIG_ESP32_WIFI_RX_BA_WIN=6 -CONFIG_ESP32_WIFI_NVS_ENABLED=y -CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y -# CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set -CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 -CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 -CONFIG_ESP32_WIFI_IRAM_OPT=y -CONFIG_ESP32_WIFI_RX_IRAM_OPT=y -CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y -# CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set -# CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is not set -# CONFIG_ESP_WIFI_GMAC_SUPPORT is not set -CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y -# end of Wi-Fi - -# -# Core dump -# -# CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH is not set -# CONFIG_ESP_COREDUMP_ENABLE_TO_UART is not set -CONFIG_ESP_COREDUMP_ENABLE_TO_NONE=y -# end of Core dump - -# -# FAT Filesystem support -# -CONFIG_FATFS_VOLUME_COUNT=2 -# CONFIG_FATFS_SECTOR_512 is not set -# CONFIG_FATFS_SECTOR_1024 is not set -# CONFIG_FATFS_SECTOR_2048 is not set -CONFIG_FATFS_SECTOR_4096=y -CONFIG_FATFS_SECTORS_PER_CLUSTER_1=y -# CONFIG_FATFS_SECTORS_PER_CLUSTER_2 is not set -# CONFIG_FATFS_SECTORS_PER_CLUSTER_4 is not set -# CONFIG_FATFS_SECTORS_PER_CLUSTER_8 is not set -# CONFIG_FATFS_SECTORS_PER_CLUSTER_16 is not set -# CONFIG_FATFS_SECTORS_PER_CLUSTER_32 is not set -# CONFIG_FATFS_SECTORS_PER_CLUSTER_64 is not set -# CONFIG_FATFS_SECTORS_PER_CLUSTER_128 is not set -# CONFIG_FATFS_CODEPAGE_DYNAMIC is not set -CONFIG_FATFS_CODEPAGE_437=y -# CONFIG_FATFS_CODEPAGE_720 is not set -# CONFIG_FATFS_CODEPAGE_737 is not set -# CONFIG_FATFS_CODEPAGE_771 is not set -# CONFIG_FATFS_CODEPAGE_775 is not set -# CONFIG_FATFS_CODEPAGE_850 is not set -# CONFIG_FATFS_CODEPAGE_852 is not set -# CONFIG_FATFS_CODEPAGE_855 is not set -# CONFIG_FATFS_CODEPAGE_857 is not set -# CONFIG_FATFS_CODEPAGE_860 is not set -# CONFIG_FATFS_CODEPAGE_861 is not set -# CONFIG_FATFS_CODEPAGE_862 is not set -# CONFIG_FATFS_CODEPAGE_863 is not set -# CONFIG_FATFS_CODEPAGE_864 is not set -# CONFIG_FATFS_CODEPAGE_865 is not set -# CONFIG_FATFS_CODEPAGE_866 is not set -# CONFIG_FATFS_CODEPAGE_869 is not set -# CONFIG_FATFS_CODEPAGE_932 is not set -# CONFIG_FATFS_CODEPAGE_936 is not set -# CONFIG_FATFS_CODEPAGE_949 is not set -# CONFIG_FATFS_CODEPAGE_950 is not set -CONFIG_FATFS_AUTO_TYPE=y -# CONFIG_FATFS_FAT12 is not set -# CONFIG_FATFS_FAT16 is not set -CONFIG_FATFS_CODEPAGE=437 -CONFIG_FATFS_LFN_NONE=y -# CONFIG_FATFS_LFN_HEAP is not set -# CONFIG_FATFS_LFN_STACK is not set -CONFIG_FATFS_FS_LOCK=0 -CONFIG_FATFS_TIMEOUT_MS=10000 -CONFIG_FATFS_PER_FILE_CACHE=y -# CONFIG_FATFS_USE_FASTSEEK is not set -# end of FAT Filesystem support - -# -# FreeRTOS -# - -# -# Kernel -# -# CONFIG_FREERTOS_SMP is not set -# CONFIG_FREERTOS_UNICORE is not set -CONFIG_FREERTOS_HZ=100 -# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set -# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL is not set -CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y -CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1 -CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536 -# CONFIG_FREERTOS_USE_IDLE_HOOK is not set -# CONFIG_FREERTOS_USE_TICK_HOOK is not set -CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 -# CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY is not set -CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1 -CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048 -CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10 -CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0 -# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set -# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set -# end of Kernel - -# -# Port -# -CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y -# CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set -# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set -CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y -CONFIG_FREERTOS_ISR_STACKSIZE=1536 -CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y -# CONFIG_FREERTOS_FPU_IN_ISR is not set -CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER=y -CONFIG_FREERTOS_CORETIMER_0=y -# CONFIG_FREERTOS_CORETIMER_1 is not set -CONFIG_FREERTOS_SYSTICK_USES_CCOUNT=y -# CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set -# CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH is not set -# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set -CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y -CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y -# end of Port - -CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF -CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y -CONFIG_FREERTOS_DEBUG_OCDAWARE=y -# end of FreeRTOS - -# -# Hardware Abstraction Layer (HAL) and Low Level (LL) -# -CONFIG_HAL_ASSERTION_EQUALS_SYSTEM=y -# CONFIG_HAL_ASSERTION_DISABLE is not set -# CONFIG_HAL_ASSERTION_SILIENT is not set -# CONFIG_HAL_ASSERTION_ENABLE is not set -CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=2 -# end of Hardware Abstraction Layer (HAL) and Low Level (LL) - -# -# Heap memory debugging -# -CONFIG_HEAP_POISONING_DISABLED=y -# CONFIG_HEAP_POISONING_LIGHT is not set -# CONFIG_HEAP_POISONING_COMPREHENSIVE is not set -CONFIG_HEAP_TRACING_OFF=y -# CONFIG_HEAP_TRACING_STANDALONE is not set -# CONFIG_HEAP_TRACING_TOHOST is not set -# CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS is not set -# end of Heap memory debugging - -# -# Log output -# -# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set -# CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set -# CONFIG_LOG_DEFAULT_LEVEL_WARN is not set -CONFIG_LOG_DEFAULT_LEVEL_INFO=y -# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set -# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set -CONFIG_LOG_DEFAULT_LEVEL=3 -CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y -# CONFIG_LOG_MAXIMUM_LEVEL_DEBUG is not set -# CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE is not set -CONFIG_LOG_MAXIMUM_LEVEL=3 -CONFIG_LOG_COLORS=y -CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y -# CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set -# end of Log output - -# -# LWIP -# -CONFIG_LWIP_LOCAL_HOSTNAME="espressif" -# CONFIG_LWIP_NETIF_API is not set -# CONFIG_LWIP_TCPIP_CORE_LOCKING is not set -CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y -# CONFIG_LWIP_L2_TO_L3_COPY is not set -# CONFIG_LWIP_IRAM_OPTIMIZATION is not set -CONFIG_LWIP_TIMERS_ONDEMAND=y -CONFIG_LWIP_MAX_SOCKETS=10 -# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set -# CONFIG_LWIP_SO_LINGER is not set -CONFIG_LWIP_SO_REUSE=y -CONFIG_LWIP_SO_REUSE_RXTOALL=y -# CONFIG_LWIP_SO_RCVBUF is not set -# CONFIG_LWIP_NETBUF_RECVINFO is not set -CONFIG_LWIP_IP4_FRAG=y -CONFIG_LWIP_IP6_FRAG=y -# CONFIG_LWIP_IP4_REASSEMBLY is not set -# CONFIG_LWIP_IP6_REASSEMBLY is not set -# CONFIG_LWIP_IP_FORWARD is not set -# CONFIG_LWIP_STATS is not set -CONFIG_LWIP_ESP_GRATUITOUS_ARP=y -CONFIG_LWIP_GARP_TMR_INTERVAL=60 -CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32 -CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y -# CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set -CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID=y -# CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set -CONFIG_LWIP_DHCP_OPTIONS_LEN=68 - -# -# DHCP server -# -CONFIG_LWIP_DHCPS=y -CONFIG_LWIP_DHCPS_LEASE_UNIT=60 -CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 -# end of DHCP server - -# CONFIG_LWIP_AUTOIP is not set -CONFIG_LWIP_IPV6=y -# CONFIG_LWIP_IPV6_AUTOCONFIG is not set -CONFIG_LWIP_IPV6_NUM_ADDRESSES=3 -# CONFIG_LWIP_IPV6_FORWARD is not set -# CONFIG_LWIP_NETIF_STATUS_CALLBACK is not set -CONFIG_LWIP_NETIF_LOOPBACK=y -CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 - -# -# TCP -# -CONFIG_LWIP_MAX_ACTIVE_TCP=16 -CONFIG_LWIP_MAX_LISTENING_TCP=16 -CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION=y -CONFIG_LWIP_TCP_MAXRTX=12 -CONFIG_LWIP_TCP_SYNMAXRTX=12 -CONFIG_LWIP_TCP_MSS=1440 -CONFIG_LWIP_TCP_TMR_INTERVAL=250 -CONFIG_LWIP_TCP_MSL=60000 -CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5744 -CONFIG_LWIP_TCP_WND_DEFAULT=5744 -CONFIG_LWIP_TCP_RECVMBOX_SIZE=6 -CONFIG_LWIP_TCP_QUEUE_OOSEQ=y -# CONFIG_LWIP_TCP_SACK_OUT is not set -CONFIG_LWIP_TCP_OVERSIZE_MSS=y -# CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS is not set -# CONFIG_LWIP_TCP_OVERSIZE_DISABLE is not set -CONFIG_LWIP_TCP_RTO_TIME=1500 -# end of TCP - -# -# UDP -# -CONFIG_LWIP_MAX_UDP_PCBS=16 -CONFIG_LWIP_UDP_RECVMBOX_SIZE=6 -# end of UDP - -# -# Checksums -# -# CONFIG_LWIP_CHECKSUM_CHECK_IP is not set -# CONFIG_LWIP_CHECKSUM_CHECK_UDP is not set -CONFIG_LWIP_CHECKSUM_CHECK_ICMP=y -# end of Checksums - -CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072 -CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y -# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set -# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU1 is not set -CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF -# CONFIG_LWIP_PPP_SUPPORT is not set -CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3 -CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5 -# CONFIG_LWIP_SLIP_SUPPORT is not set - -# -# ICMP -# -CONFIG_LWIP_ICMP=y -# CONFIG_LWIP_MULTICAST_PING is not set -# CONFIG_LWIP_BROADCAST_PING is not set -# end of ICMP - -# -# LWIP RAW API -# -CONFIG_LWIP_MAX_RAW_PCBS=16 -# end of LWIP RAW API - -# -# SNTP -# -CONFIG_LWIP_SNTP_MAX_SERVERS=1 -# CONFIG_LWIP_DHCP_GET_NTP_SRV is not set -CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000 -# end of SNTP - -CONFIG_LWIP_ESP_LWIP_ASSERT=y - -# -# Hooks -# -# CONFIG_LWIP_HOOK_TCP_ISN_NONE is not set -CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT=y -# CONFIG_LWIP_HOOK_TCP_ISN_CUSTOM is not set -CONFIG_LWIP_HOOK_IP6_ROUTE_NONE=y -# CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT is not set -# CONFIG_LWIP_HOOK_IP6_ROUTE_CUSTOM is not set -CONFIG_LWIP_HOOK_ND6_GET_GW_NONE=y -# CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT is not set -# CONFIG_LWIP_HOOK_ND6_GET_GW_CUSTOM is not set -CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y -# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT is not set -# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set -CONFIG_LWIP_HOOK_IP6_INPUT_NONE=y -# CONFIG_LWIP_HOOK_IP6_INPUT_DEFAULT is not set -# CONFIG_LWIP_HOOK_IP6_INPUT_CUSTOM is not set -# end of Hooks - -# CONFIG_LWIP_DEBUG is not set -# end of LWIP - -# -# mbedTLS -# -CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y -# CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set -# CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set -CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y -CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 -CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096 -# CONFIG_MBEDTLS_DYNAMIC_BUFFER is not set -# CONFIG_MBEDTLS_DEBUG is not set - -# -# mbedTLS v3.x related -# -# CONFIG_MBEDTLS_SSL_PROTO_TLS1_3 is not set -# CONFIG_MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH is not set -# CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK is not set -# CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION is not set -CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=y -# end of mbedTLS v3.x related - -# -# Certificate Bundle -# -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y -# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set -# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set -# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200 -# end of Certificate Bundle - -# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set -# CONFIG_MBEDTLS_CMAC_C is not set -CONFIG_MBEDTLS_HARDWARE_AES=y -CONFIG_MBEDTLS_HARDWARE_MPI=y -CONFIG_MBEDTLS_HARDWARE_SHA=y -CONFIG_MBEDTLS_ROM_MD5=y -# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set -# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set -CONFIG_MBEDTLS_HAVE_TIME=y -# CONFIG_MBEDTLS_PLATFORM_TIME_ALT is not set -# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set -CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y -CONFIG_MBEDTLS_SHA512_C=y -CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y -# CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set -# CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set -# CONFIG_MBEDTLS_TLS_DISABLED is not set -CONFIG_MBEDTLS_TLS_SERVER=y -CONFIG_MBEDTLS_TLS_CLIENT=y -CONFIG_MBEDTLS_TLS_ENABLED=y - -# -# TLS Key Exchange Methods -# -# CONFIG_MBEDTLS_PSK_MODES is not set -CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y -CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y -# end of TLS Key Exchange Methods - -CONFIG_MBEDTLS_SSL_RENEGOTIATION=y -CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y -# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set -# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set -CONFIG_MBEDTLS_SSL_ALPN=y -CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y -CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y - -# -# Symmetric Ciphers -# -CONFIG_MBEDTLS_AES_C=y -# CONFIG_MBEDTLS_CAMELLIA_C is not set -# CONFIG_MBEDTLS_DES_C is not set -CONFIG_MBEDTLS_RC4_DISABLED=y -# CONFIG_MBEDTLS_RC4_ENABLED_NO_DEFAULT is not set -# CONFIG_MBEDTLS_RC4_ENABLED is not set -# CONFIG_MBEDTLS_BLOWFISH_C is not set -# CONFIG_MBEDTLS_XTEA_C is not set -CONFIG_MBEDTLS_CCM_C=y -CONFIG_MBEDTLS_GCM_C=y -# CONFIG_MBEDTLS_NIST_KW_C is not set -# end of Symmetric Ciphers - -# CONFIG_MBEDTLS_RIPEMD160_C is not set - -# -# Certificates -# -CONFIG_MBEDTLS_PEM_PARSE_C=y -CONFIG_MBEDTLS_PEM_WRITE_C=y -CONFIG_MBEDTLS_X509_CRL_PARSE_C=y -CONFIG_MBEDTLS_X509_CSR_PARSE_C=y -# end of Certificates - -CONFIG_MBEDTLS_ECP_C=y -# CONFIG_MBEDTLS_DHM_C is not set -CONFIG_MBEDTLS_ECDH_C=y -CONFIG_MBEDTLS_ECDSA_C=y -# CONFIG_MBEDTLS_ECJPAKE_C is not set -CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y -CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y -CONFIG_MBEDTLS_ECP_NIST_OPTIM=y -# CONFIG_MBEDTLS_POLY1305_C is not set -# CONFIG_MBEDTLS_CHACHA20_C is not set -# CONFIG_MBEDTLS_HKDF_C is not set -# CONFIG_MBEDTLS_THREADING_C is not set -# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set -# CONFIG_MBEDTLS_SECURITY_RISKS is not set -# end of mbedTLS - -# -# mDNS -# -CONFIG_MDNS_MAX_INTERFACES=3 -CONFIG_MDNS_MAX_SERVICES=10 -CONFIG_MDNS_TASK_PRIORITY=1 -CONFIG_MDNS_TASK_STACK_SIZE=4096 -# CONFIG_MDNS_TASK_AFFINITY_NO_AFFINITY is not set -CONFIG_MDNS_TASK_AFFINITY_CPU0=y -# CONFIG_MDNS_TASK_AFFINITY_CPU1 is not set -CONFIG_MDNS_TASK_AFFINITY=0x0 -CONFIG_MDNS_SERVICE_ADD_TIMEOUT_MS=2000 -# CONFIG_MDNS_STRICT_MODE is not set -CONFIG_MDNS_TIMER_PERIOD_MS=100 -# CONFIG_MDNS_NETWORKING_SOCKET is not set -CONFIG_MDNS_MULTIPLE_INSTANCE=y - -# -# MDNS Predefined interfaces -# -CONFIG_MDNS_PREDEF_NETIF_STA=y -CONFIG_MDNS_PREDEF_NETIF_AP=y -CONFIG_MDNS_PREDEF_NETIF_ETH=y -# end of MDNS Predefined interfaces -# end of mDNS - -# -# ESP-MQTT Configurations -# -CONFIG_MQTT_PROTOCOL_311=y -CONFIG_MQTT_TRANSPORT_SSL=y -CONFIG_MQTT_TRANSPORT_WEBSOCKET=y -CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y -# CONFIG_MQTT_MSG_ID_INCREMENTAL is not set -# CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED is not set -# CONFIG_MQTT_REPORT_DELETED_MESSAGES is not set -# CONFIG_MQTT_USE_CUSTOM_CONFIG is not set -# CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED is not set -# CONFIG_MQTT_CUSTOM_OUTBOX is not set -# end of ESP-MQTT Configurations - -# -# Newlib -# -CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y -# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set -# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set -# CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set -# CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set -CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y -# CONFIG_NEWLIB_NANO_FORMAT is not set -CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y -# CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC is not set -# CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT is not set -# CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE is not set -# end of Newlib - -# -# NVS -# -# end of NVS - -# -# OpenThread -# -# CONFIG_OPENTHREAD_ENABLED is not set -# end of OpenThread - -# -# PThreads -# -CONFIG_PTHREAD_TASK_PRIO_DEFAULT=5 -CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 -CONFIG_PTHREAD_STACK_MIN=768 -CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY=y -# CONFIG_PTHREAD_DEFAULT_CORE_0 is not set -# CONFIG_PTHREAD_DEFAULT_CORE_1 is not set -CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1 -CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" -# end of PThreads - -# -# SPI Flash driver -# -# CONFIG_SPI_FLASH_VERIFY_WRITE is not set -# CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set -CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y -CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y -# CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS is not set -# CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is not set -# CONFIG_SPI_FLASH_USE_LEGACY_IMPL is not set -# CONFIG_SPI_FLASH_SHARE_SPI1_BUS is not set -# CONFIG_SPI_FLASH_BYPASS_BLOCK_ERASE is not set -CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y -CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=20 -CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=1 -CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=8192 -# CONFIG_SPI_FLASH_SIZE_OVERRIDE is not set -# CONFIG_SPI_FLASH_CHECK_ERASE_TIMEOUT_DISABLED is not set -# CONFIG_SPI_FLASH_OVERRIDE_CHIP_DRIVER_LIST is not set - -# -# Auto-detect flash chips -# -CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP=y -CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP=y -CONFIG_SPI_FLASH_SUPPORT_GD_CHIP=y -CONFIG_SPI_FLASH_SUPPORT_WINBOND_CHIP=y -# CONFIG_SPI_FLASH_SUPPORT_BOYA_CHIP is not set -# CONFIG_SPI_FLASH_SUPPORT_TH_CHIP is not set -# end of Auto-detect flash chips - -CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=y -# end of SPI Flash driver - -# -# SPIFFS Configuration -# -CONFIG_SPIFFS_MAX_PARTITIONS=3 - -# -# SPIFFS Cache Configuration -# -CONFIG_SPIFFS_CACHE=y -CONFIG_SPIFFS_CACHE_WR=y -# CONFIG_SPIFFS_CACHE_STATS is not set -# end of SPIFFS Cache Configuration - -CONFIG_SPIFFS_PAGE_CHECK=y -CONFIG_SPIFFS_GC_MAX_RUNS=10 -# CONFIG_SPIFFS_GC_STATS is not set -CONFIG_SPIFFS_PAGE_SIZE=256 -CONFIG_SPIFFS_OBJ_NAME_LEN=32 -# CONFIG_SPIFFS_FOLLOW_SYMLINKS is not set -CONFIG_SPIFFS_USE_MAGIC=y -CONFIG_SPIFFS_USE_MAGIC_LENGTH=y -CONFIG_SPIFFS_META_LENGTH=4 -CONFIG_SPIFFS_USE_MTIME=y - -# -# Debug Configuration -# -# CONFIG_SPIFFS_DBG is not set -# CONFIG_SPIFFS_API_DBG is not set -# CONFIG_SPIFFS_GC_DBG is not set -# CONFIG_SPIFFS_CACHE_DBG is not set -# CONFIG_SPIFFS_CHECK_DBG is not set -# CONFIG_SPIFFS_TEST_VISUALISATION is not set -# end of Debug Configuration -# end of SPIFFS Configuration - -# -# TCP Transport -# - -# -# Websocket -# -CONFIG_WS_TRANSPORT=y -CONFIG_WS_BUFFER_SIZE=1024 -# end of Websocket -# end of TCP Transport - -# -# Ultra Low Power (ULP) Co-processor -# -# CONFIG_ULP_COPROC_ENABLED is not set -# end of Ultra Low Power (ULP) Co-processor - -# -# Unity unit testing library -# -CONFIG_UNITY_ENABLE_FLOAT=y -CONFIG_UNITY_ENABLE_DOUBLE=y -# CONFIG_UNITY_ENABLE_64BIT is not set -# CONFIG_UNITY_ENABLE_COLOR is not set -CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y -# CONFIG_UNITY_ENABLE_FIXTURE is not set -# CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL is not set -# end of Unity unit testing library - -# -# Virtual file system -# -CONFIG_VFS_SUPPORT_IO=y -CONFIG_VFS_SUPPORT_DIR=y -CONFIG_VFS_SUPPORT_SELECT=y -CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y -CONFIG_VFS_SUPPORT_TERMIOS=y - -# -# Host File System I/O (Semihosting) -# -CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 -# end of Host File System I/O (Semihosting) -# end of Virtual file system - -# -# Wear Levelling -# -# CONFIG_WL_SECTOR_SIZE_512 is not set -CONFIG_WL_SECTOR_SIZE_4096=y -CONFIG_WL_SECTOR_SIZE=4096 -# end of Wear Levelling - -# -# Wi-Fi Provisioning Manager -# -CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16 -CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30 -# end of Wi-Fi Provisioning Manager - -# -# Supplicant -# -CONFIG_WPA_MBEDTLS_CRYPTO=y -CONFIG_WPA_MBEDTLS_TLS_CLIENT=y -# CONFIG_WPA_WAPI_PSK is not set -# CONFIG_WPA_SUITE_B_192 is not set -# CONFIG_WPA_DEBUG_PRINT is not set -# CONFIG_WPA_TESTING_OPTIONS is not set -# CONFIG_WPA_WPS_STRICT is not set -# CONFIG_WPA_11KV_SUPPORT is not set -# CONFIG_WPA_MBO_SUPPORT is not set -# CONFIG_WPA_DPP_SUPPORT is not set -# CONFIG_WPA_11R_SUPPORT is not set -# end of Supplicant -# end of Component config - -# Deprecated options for backward compatibility -# CONFIG_NO_BLOBS is not set -# CONFIG_ESP32_NO_BLOBS is not set -# CONFIG_LOG_BOOTLOADER_LEVEL_NONE is not set -# CONFIG_LOG_BOOTLOADER_LEVEL_ERROR is not set -# CONFIG_LOG_BOOTLOADER_LEVEL_WARN is not set -CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y -# CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set -# CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set -CONFIG_LOG_BOOTLOADER_LEVEL=3 -# CONFIG_APP_ROLLBACK_ENABLE is not set -# CONFIG_FLASH_ENCRYPTION_ENABLED is not set -# CONFIG_FLASHMODE_QIO is not set -# CONFIG_FLASHMODE_QOUT is not set -CONFIG_FLASHMODE_DIO=y -# CONFIG_FLASHMODE_DOUT is not set -CONFIG_MONITOR_BAUD=115200 -CONFIG_OPTIMIZATION_LEVEL_DEBUG=y -CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y -# CONFIG_OPTIMIZATION_LEVEL_RELEASE is not set -# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set -CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y -# CONFIG_OPTIMIZATION_ASSERTIONS_SILENT is not set -# CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED is not set -CONFIG_OPTIMIZATION_ASSERTION_LEVEL=2 -# CONFIG_CXX_EXCEPTIONS is not set -CONFIG_STACK_CHECK_NONE=y -# CONFIG_STACK_CHECK_NORM is not set -# CONFIG_STACK_CHECK_STRONG is not set -# CONFIG_STACK_CHECK_ALL is not set -# CONFIG_WARN_WRITE_STRINGS is not set -# CONFIG_DISABLE_GCC8_WARNINGS is not set -# CONFIG_ESP32_APPTRACE_DEST_TRAX is not set -CONFIG_ESP32_APPTRACE_DEST_NONE=y -CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y -CONFIG_ADC2_DISABLE_DAC=y -# CONFIG_SPIRAM_SUPPORT is not set -CONFIG_TRACEMEM_RESERVE_DRAM=0x0 -# CONFIG_DISABLE_BASIC_ROM_CONSOLE is not set -# CONFIG_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set -# CONFIG_EVENT_LOOP_PROFILING is not set -CONFIG_POST_EVENTS_FROM_ISR=y -CONFIG_POST_EVENTS_FROM_IRAM_ISR=y -# CONFIG_OTA_ALLOW_HTTP is not set -# CONFIG_TWO_UNIVERSAL_MAC_ADDRESS is not set -CONFIG_FOUR_UNIVERSAL_MAC_ADDRESS=y -CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS=4 -CONFIG_ESP_SYSTEM_PD_FLASH=y -CONFIG_ESP32_RTC_CLK_SRC_INT_RC=y -CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC=y -# CONFIG_ESP32_RTC_CLK_SRC_EXT_CRYS is not set -# CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL is not set -# CONFIG_ESP32_RTC_CLK_SRC_EXT_OSC is not set -# CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_OSC is not set -# CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256 is not set -# CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_8MD256 is not set -CONFIG_ESP32_RTC_CLK_CAL_CYCLES=1024 -CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y -# CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set -CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 -CONFIG_ESP32_PHY_MAX_TX_POWER=20 -CONFIG_REDUCE_PHY_TX_POWER=y -CONFIG_ESP32_REDUCE_PHY_TX_POWER=y -# CONFIG_ESP32_DEFAULT_CPU_FREQ_80 is not set -CONFIG_ESP32_DEFAULT_CPU_FREQ_160=y -# CONFIG_ESP32_DEFAULT_CPU_FREQ_240 is not set -CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=160 -# CONFIG_ESP32_PANIC_PRINT_HALT is not set -CONFIG_ESP32_PANIC_PRINT_REBOOT=y -# CONFIG_ESP32_PANIC_SILENT_REBOOT is not set -# CONFIG_ESP32_PANIC_GDBSTUB is not set -CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 -CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304 -CONFIG_MAIN_TASK_STACK_SIZE=3584 -CONFIG_CONSOLE_UART_DEFAULT=y -# CONFIG_CONSOLE_UART_CUSTOM is not set -# CONFIG_CONSOLE_UART_NONE is not set -# CONFIG_ESP_CONSOLE_UART_NONE is not set -CONFIG_CONSOLE_UART=y -CONFIG_CONSOLE_UART_NUM=0 -CONFIG_CONSOLE_UART_BAUDRATE=115200 -CONFIG_INT_WDT=y -CONFIG_INT_WDT_TIMEOUT_MS=300 -CONFIG_INT_WDT_CHECK_CPU1=y -CONFIG_TASK_WDT=y -# CONFIG_TASK_WDT_PANIC is not set -CONFIG_TASK_WDT_TIMEOUT_S=5 -CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y -CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=y -# CONFIG_ESP32_DEBUG_STUBS_ENABLE is not set -CONFIG_ESP32_DEBUG_OCDAWARE=y -CONFIG_BROWNOUT_DET=y -CONFIG_ESP32_BROWNOUT_DET=y -CONFIG_BROWNOUT_DET_LVL_SEL_0=y -CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_0=y -# CONFIG_BROWNOUT_DET_LVL_SEL_1 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_1 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_2 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_2 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_3 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_3 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_4 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_4 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_5 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_5 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_6 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_6 is not set -# CONFIG_BROWNOUT_DET_LVL_SEL_7 is not set -# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_7 is not set -CONFIG_BROWNOUT_DET_LVL=0 -CONFIG_ESP32_BROWNOUT_DET_LVL=0 -CONFIG_IPC_TASK_STACK_SIZE=1024 -CONFIG_TIMER_TASK_STACK_SIZE=3584 -# CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set -# CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set -CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y -CONFIG_TIMER_TASK_PRIORITY=1 -CONFIG_TIMER_TASK_STACK_DEPTH=2048 -CONFIG_TIMER_QUEUE_LENGTH=10 -# CONFIG_ENABLE_STATIC_TASK_CLEAN_UP_HOOK is not set -# CONFIG_L2_TO_L3_COPY is not set -CONFIG_ESP_GRATUITOUS_ARP=y -CONFIG_GARP_TMR_INTERVAL=60 -CONFIG_TCPIP_RECVMBOX_SIZE=32 -CONFIG_TCP_MAXRTX=12 -CONFIG_TCP_SYNMAXRTX=12 -CONFIG_TCP_MSS=1440 -CONFIG_TCP_MSL=60000 -CONFIG_TCP_SND_BUF_DEFAULT=5744 -CONFIG_TCP_WND_DEFAULT=5744 -CONFIG_TCP_RECVMBOX_SIZE=6 -CONFIG_TCP_QUEUE_OOSEQ=y -CONFIG_TCP_OVERSIZE_MSS=y -# CONFIG_TCP_OVERSIZE_QUARTER_MSS is not set -# CONFIG_TCP_OVERSIZE_DISABLE is not set -CONFIG_UDP_RECVMBOX_SIZE=6 -CONFIG_TCPIP_TASK_STACK_SIZE=3072 -CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y -# CONFIG_TCPIP_TASK_AFFINITY_CPU0 is not set -# CONFIG_TCPIP_TASK_AFFINITY_CPU1 is not set -CONFIG_TCPIP_TASK_AFFINITY=0x7FFFFFFF -# CONFIG_PPP_SUPPORT is not set -CONFIG_ESP32_TIME_SYSCALL_USE_RTC_HRT=y -CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y -# CONFIG_ESP32_TIME_SYSCALL_USE_RTC is not set -# CONFIG_ESP32_TIME_SYSCALL_USE_HRT is not set -# CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 is not set -# CONFIG_ESP32_TIME_SYSCALL_USE_NONE is not set -CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 -CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 -CONFIG_ESP32_PTHREAD_STACK_MIN=768 -CONFIG_ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY=y -# CONFIG_ESP32_DEFAULT_PTHREAD_CORE_0 is not set -# CONFIG_ESP32_DEFAULT_PTHREAD_CORE_1 is not set -CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT=-1 -CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread" -CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y -# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS is not set -# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED is not set -# CONFIG_ESP32_ULP_COPROC_ENABLED is not set -CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y -CONFIG_SUPPORT_TERMIOS=y -CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS=1 -# End of deprecated options