[ethernet] Add explicit PHY/MAC includes and exclude JL1101 driver when unused

- Add explicit includes for per-chip PHY/MAC headers (required on IDF 6.0
  where they are no longer pulled in via esp_eth.h, also works on IDF 5.x)
- Exclude esp_eth_phy_jl1101.c from compilation on IDF >= 6.0 (uses
  generic PHY) and IDF >= 5.4.2 with PlatformIO (uses builtin driver)
This commit is contained in:
J. Nick Koston
2026-03-15 17:01:29 -10:00
parent b636f2613d
commit d27b3e8c0f
2 changed files with 46 additions and 1 deletions
+23 -1
View File
@@ -600,11 +600,33 @@ async def final_step():
cg.add_define("ESPHOME_ETHERNET_IP_STATE_LISTENERS", ip_state_count)
FILTER_SOURCE_FILES = filter_source_files_from_platform(
_platform_filter = filter_source_files_from_platform(
{
"ethernet_component_esp32.cpp": {
PlatformFramework.ESP32_IDF,
PlatformFramework.ESP32_ARDUINO,
},
"esp_eth_phy_jl1101.c": {
PlatformFramework.ESP32_IDF,
PlatformFramework.ESP32_ARDUINO,
},
}
)
def _filter_source_files() -> list[str]:
excluded = _platform_filter()
if not CORE.is_esp32:
return excluded
from esphome.components.esp32 import idf_version
# Custom JL1101 driver not needed on IDF >= 6.0 (uses generic PHY)
# or IDF >= 5.4.2 with PlatformIO (uses builtin driver)
if idf_version() >= cv.Version(6, 0, 0) or (
idf_version() >= cv.Version(5, 4, 2) and CORE.using_platformio
):
excluded.append("esp_eth_phy_jl1101.c")
return excluded
FILTER_SOURCE_FILES = _filter_source_files
@@ -10,9 +10,32 @@
#include <cinttypes>
#include "esp_event.h"
#ifdef USE_ETHERNET_LAN8720
#include "esp_eth_phy_lan87xx.h"
#endif
#ifdef USE_ETHERNET_RTL8201
#include "esp_eth_phy_rtl8201.h"
#endif
#ifdef USE_ETHERNET_DP83848
#include "esp_eth_phy_dp83848.h"
#endif
#ifdef USE_ETHERNET_IP101
#include "esp_eth_phy_ip101.h"
#endif
#ifdef USE_ETHERNET_KSZ8081
#include "esp_eth_phy_ksz80xx.h"
#endif
#ifdef USE_ETHERNET_LAN8670
#include "esp_eth_phy_lan867x.h"
#endif
#ifdef USE_ETHERNET_W5500
#include "esp_eth_mac_w5500.h"
#include "esp_eth_phy_w5500.h"
#endif
#ifdef USE_ETHERNET_DM9051
#include "esp_eth_mac_dm9051.h"
#include "esp_eth_phy_dm9051.h"
#endif
#ifdef USE_ETHERNET_SPI
#include <driver/gpio.h>