From b3552317214467fbd31e0262b4e4bf7d2e7a123b Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Wed, 31 Aug 2022 10:09:22 +0200 Subject: [PATCH 1/2] Fix unstable ETH on Olimex POE --- .../xdrv_82_esp32_ethernet.ino | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_82_esp32_ethernet.ino b/tasmota/tasmota_xdrv_driver/xdrv_82_esp32_ethernet.ino index b7cfada24..264cd8f3c 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_82_esp32_ethernet.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_82_esp32_ethernet.ino @@ -154,6 +154,31 @@ void EthernetInit(void) { int eth_power = Pin(GPIO_ETH_PHY_POWER); int eth_mdc = Pin(GPIO_ETH_PHY_MDC); int eth_mdio = Pin(GPIO_ETH_PHY_MDIO); +#ifdef ESP32 + // fix an disconnection issue after rebooting Olimex POE - this forces a clean state for all GPIO involved in RMII + gpio_reset_pin((gpio_num_t)GPIO_ETH_PHY_POWER); + gpio_reset_pin((gpio_num_t)GPIO_ETH_PHY_MDC); + gpio_reset_pin((gpio_num_t)GPIO_ETH_PHY_MDIO); + gpio_reset_pin(GPIO_NUM_19); // EMAC_TXD0 - hardcoded + gpio_reset_pin(GPIO_NUM_21); // EMAC_TX_EN - hardcoded + gpio_reset_pin(GPIO_NUM_22); // EMAC_TXD1 - hardcoded + gpio_reset_pin(GPIO_NUM_25); // EMAC_RXD0 - hardcoded + gpio_reset_pin(GPIO_NUM_26); // EMAC_RXD1 - hardcoded + gpio_reset_pin(GPIO_NUM_27); // EMAC_RX_CRS_DV - hardcoded + switch (Settings->eth_clk_mode) { + case 0: // ETH_CLOCK_GPIO0_IN + case 1: // ETH_CLOCK_GPIO0_OUT + gpio_reset_pin(GPIO_NUM_0); + break; + case 2: // ETH_CLOCK_GPIO16_OUT + gpio_reset_pin(GPIO_NUM_16); + break; + case 3: // ETH_CLOCK_GPIO17_OUT + gpio_reset_pin(GPIO_NUM_17); + break; + } + delay(1); +#endif if (!ETH.begin(Settings->eth_address, eth_power, eth_mdc, eth_mdio, (eth_phy_type_t)Settings->eth_type, (eth_clock_mode_t)Settings->eth_clk_mode)) { AddLog(LOG_LEVEL_DEBUG, PSTR("ETH: Bad PHY type or init error")); return; From 74cbc47614f7fd5d0b6287ad480a76322803bd64 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Wed, 31 Aug 2022 10:12:25 +0200 Subject: [PATCH 2/2] Be more specific to target ESP32 --- tasmota/tasmota_xdrv_driver/xdrv_82_esp32_ethernet.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_82_esp32_ethernet.ino b/tasmota/tasmota_xdrv_driver/xdrv_82_esp32_ethernet.ino index 264cd8f3c..525e878cc 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_82_esp32_ethernet.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_82_esp32_ethernet.ino @@ -154,7 +154,7 @@ void EthernetInit(void) { int eth_power = Pin(GPIO_ETH_PHY_POWER); int eth_mdc = Pin(GPIO_ETH_PHY_MDC); int eth_mdio = Pin(GPIO_ETH_PHY_MDIO); -#ifdef ESP32 +#if CONFIG_IDF_TARGET_ESP32 // fix an disconnection issue after rebooting Olimex POE - this forces a clean state for all GPIO involved in RMII gpio_reset_pin((gpio_num_t)GPIO_ETH_PHY_POWER); gpio_reset_pin((gpio_num_t)GPIO_ETH_PHY_MDC); @@ -178,7 +178,7 @@ void EthernetInit(void) { break; } delay(1); -#endif +#endif // CONFIG_IDF_TARGET_ESP32 if (!ETH.begin(Settings->eth_address, eth_power, eth_mdc, eth_mdio, (eth_phy_type_t)Settings->eth_type, (eth_clock_mode_t)Settings->eth_clk_mode)) { AddLog(LOG_LEVEL_DEBUG, PSTR("ETH: Bad PHY type or init error")); return;