From 1ae337e82d841b4ddcb1e594adcb3ece81c2fd1c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 17 Sep 2026 12:10:32 -0500 Subject: [PATCH] Limit the PSRAM input path to dual wifi + ethernet builds An ethernet-only build has internal RAM to spare (135 KB free idle on a CAST-1 built without wifi), so keep stock behaviour there. --- .../ethernet/ethernet_component_esp32.cpp | 8 +++++--- .../ethernet/test-w5500-psram.esp32-s3-idf.yaml | 6 ------ .../test-w5500-wifi-psram.esp32-s3-idf.yaml | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 9 deletions(-) delete mode 100644 tests/components/ethernet/test-w5500-psram.esp32-s3-idf.yaml create mode 100644 tests/components/ethernet/test-w5500-wifi-psram.esp32-s3-idf.yaml diff --git a/esphome/components/ethernet/ethernet_component_esp32.cpp b/esphome/components/ethernet/ethernet_component_esp32.cpp index 70a7d5a84c7..734a2aad850 100644 --- a/esphome/components/ethernet/ethernet_component_esp32.cpp +++ b/esphome/components/ethernet/ethernet_component_esp32.cpp @@ -74,9 +74,11 @@ static const char *const TAG = "ethernet"; // PHY register size for hex logging static constexpr size_t PHY_REG_SIZE = 2; -// SPI MACs only: the bus is the bottleneck there, the extra copy is unmeasured on the 100 Mbit EMAC. -// Replacing the glue's input path would bypass its L2 TAP filter, so leave it alone when that is on. -#if defined(USE_PSRAM) && defined(USE_ETHERNET_SPI) && !CONFIG_ESP_NETIF_L2_TAP +// Dual wifi + ethernet builds only: wifi's fixed costs leave little internal RAM and its buffers are +// already in PSRAM, while an ethernet-only build has room to spare. SPI MACs only: the bus is the +// bottleneck there, the extra copy is unmeasured on the 100 Mbit EMAC. Not with L2 TAP, whose filter +// lives in the glue's input path. +#if defined(USE_PSRAM) && defined(USE_ETHERNET_SPI) && defined(USE_WIFI) && !CONFIG_ESP_NETIF_L2_TAP #define USE_ETHERNET_RX_PSRAM // ESP-IDF ethernet drivers malloc() every received frame in internal RAM, where it stays until lwIP // hands it to the application. Move it to PSRAM; if that fails the frame is passed on where it is. diff --git a/tests/components/ethernet/test-w5500-psram.esp32-s3-idf.yaml b/tests/components/ethernet/test-w5500-psram.esp32-s3-idf.yaml deleted file mode 100644 index e7e6875d714..00000000000 --- a/tests/components/ethernet/test-w5500-psram.esp32-s3-idf.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# W5500 with PSRAM: compiles the input path that moves received frames to PSRAM -packages: - ethernet: !include common-w5500.yaml - -psram: - mode: quad diff --git a/tests/components/ethernet/test-w5500-wifi-psram.esp32-s3-idf.yaml b/tests/components/ethernet/test-w5500-wifi-psram.esp32-s3-idf.yaml new file mode 100644 index 00000000000..d454dbadc39 --- /dev/null +++ b/tests/components/ethernet/test-w5500-wifi-psram.esp32-s3-idf.yaml @@ -0,0 +1,15 @@ +# W5500 next to wifi with PSRAM: compiles the input path that moves received frames to PSRAM +packages: + ethernet: !include common-w5500.yaml + +psram: + mode: quad + +wifi: + ssid: MySSID + password: password1 + +network: + priority: + - ethernet + - wifi