diff --git a/esphome/components/ethernet/ethernet_component.cpp b/esphome/components/ethernet/ethernet_component.cpp index 7027035cd1..ff51848d32 100644 --- a/esphome/components/ethernet/ethernet_component.cpp +++ b/esphome/components/ethernet/ethernet_component.cpp @@ -127,14 +127,34 @@ void EthernetComponent::setup() { phy_config.reset_gpio_num = this->power_pin_; #if ESP_IDF_VERSION_MAJOR >= 5 +#if ESP_IDF_VERSION_MINOR >= 3 && ESP_IDF_VERSION_PATCH < 2 + // fix https://github.com/espressif/esp-idf/commit/e9df36a2dfe9ee074f421aedaff8952a348b339d + // for v5.3.0 and v5.3.1 + eth_esp32_emac_config_t esp32_emac_config = { + .smi_gpio = {.mdc_num = this->mdc_pin_, .mdio_num = this->mdio_pin_}, + .interface = EMAC_DATA_INTERFACE_RMII, + .clock_config = {.rmii = + { + .clock_mode = this->clk_mode_, + .clock_gpio = this->clk_gpio_, + }}, + .dma_burst_len = ETH_DMA_BURST_LEN_32, + .intr_priority = 0, + }; +#else // ESP_IDF_VERSION_MINOR >= 3 && ESP_IDF_VERSION_PATCH > 2 eth_esp32_emac_config_t esp32_emac_config = ETH_ESP32_EMAC_DEFAULT_CONFIG(); +#if ESP_IDF_VERSION_MINOR >= 3 + esp32_emac_config.smi_gpio = {.mdc_num = this->mdc_pin_, .mdio_num = this->mdio_pin_}; +#else // ESP_IDF_VERSION_MINOR < 3 esp32_emac_config.smi_mdc_gpio_num = this->mdc_pin_; esp32_emac_config.smi_mdio_gpio_num = this->mdio_pin_; +#endif esp32_emac_config.clock_config.rmii.clock_mode = this->clk_mode_; esp32_emac_config.clock_config.rmii.clock_gpio = this->clk_gpio_; +#endif esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&esp32_emac_config, &mac_config); -#else +#else // ESP_IDF_VERSION_MAJOR < 5 mac_config.smi_mdc_gpio_num = this->mdc_pin_; mac_config.smi_mdio_gpio_num = this->mdio_pin_; mac_config.clock_config.rmii.clock_mode = this->clk_mode_;