mirror of
https://github.com/esphome/esphome.git
synced 2026-10-01 00:40:21 +00:00
[network] Keep lwip off the PSRAM tier when Ethernet is configured (#19367)
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
"""Shared helpers for the network component tests."""
|
||||
|
||||
from esphome.components.esp32.const import KEY_ESP32, KEY_SDKCONFIG_OPTIONS
|
||||
from esphome.core import CORE
|
||||
|
||||
|
||||
def sdkconfig_option(name: str) -> int | bool | None:
|
||||
"""Return a generated sdkconfig value, or None when unset or not ESP32."""
|
||||
if KEY_ESP32 not in CORE.data:
|
||||
return None
|
||||
return CORE.data[KEY_ESP32][KEY_SDKCONFIG_OPTIONS].get(name)
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
esphome:
|
||||
name: test
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: esp-idf
|
||||
|
||||
ethernet:
|
||||
type: LAN8720
|
||||
mdc_pin: 23
|
||||
mdio_pin: 32
|
||||
clk:
|
||||
pin: 0
|
||||
mode: CLK_EXT_IN
|
||||
phy_addr: 0
|
||||
power_pin: 33
|
||||
|
||||
network:
|
||||
enable_high_performance: true
|
||||
@@ -0,0 +1,23 @@
|
||||
esphome:
|
||||
name: test
|
||||
|
||||
esp32:
|
||||
variant: esp32s3
|
||||
framework:
|
||||
type: esp-idf
|
||||
|
||||
psram:
|
||||
mode: octal
|
||||
ignore_not_found: false
|
||||
|
||||
ethernet:
|
||||
type: W5500
|
||||
clk_pin: GPIO12
|
||||
mosi_pin: GPIO11
|
||||
miso_pin: GPIO13
|
||||
cs_pin: GPIO10
|
||||
interrupt_pin: GPIO14
|
||||
reset_pin: GPIO9
|
||||
|
||||
network:
|
||||
enable_high_performance: true
|
||||
@@ -0,0 +1,30 @@
|
||||
esphome:
|
||||
name: test
|
||||
|
||||
esp32:
|
||||
variant: esp32s3
|
||||
framework:
|
||||
type: esp-idf
|
||||
|
||||
psram:
|
||||
mode: octal
|
||||
ignore_not_found: false
|
||||
|
||||
wifi:
|
||||
ssid: "test_ssid"
|
||||
password: "test_password"
|
||||
|
||||
ethernet:
|
||||
type: W5500
|
||||
clk_pin: GPIO12
|
||||
mosi_pin: GPIO11
|
||||
miso_pin: GPIO13
|
||||
cs_pin: GPIO10
|
||||
interrupt_pin: GPIO14
|
||||
reset_pin: GPIO9
|
||||
|
||||
network:
|
||||
priority:
|
||||
- wifi
|
||||
- ethernet
|
||||
enable_high_performance: true
|
||||
@@ -0,0 +1,14 @@
|
||||
esphome:
|
||||
name: test
|
||||
|
||||
esp32:
|
||||
board: esp32dev
|
||||
framework:
|
||||
type: esp-idf
|
||||
|
||||
wifi:
|
||||
ssid: "test_ssid"
|
||||
password: "test_password"
|
||||
|
||||
network:
|
||||
enable_high_performance: true
|
||||
@@ -0,0 +1,18 @@
|
||||
esphome:
|
||||
name: test
|
||||
|
||||
esp32:
|
||||
variant: esp32s3
|
||||
framework:
|
||||
type: esp-idf
|
||||
|
||||
psram:
|
||||
mode: octal
|
||||
ignore_not_found: false
|
||||
|
||||
wifi:
|
||||
ssid: "test_ssid"
|
||||
password: "test_password"
|
||||
|
||||
network:
|
||||
enable_high_performance: true
|
||||
@@ -0,0 +1,54 @@
|
||||
"""Tests for the ``network: enable_high_performance:`` lwip tier selection.
|
||||
|
||||
Ethernet drivers keep received frames in internal RAM, so an ethernet-only
|
||||
build must keep lwip off the PSRAM tier even when PSRAM is guaranteed.
|
||||
"""
|
||||
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from esphome.components.network import require_high_performance_networking
|
||||
from tests.component_tests.network import sdkconfig_option
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
(
|
||||
"fixture",
|
||||
"window",
|
||||
"tcp_mailbox",
|
||||
"tcpip_mailbox",
|
||||
"window_scale",
|
||||
"wifi_rx_buffers",
|
||||
),
|
||||
[
|
||||
("high_perf_wifi_psram.yaml", 512000, 512, 512, True, 512),
|
||||
("high_perf_wifi_no_psram.yaml", 65534, 64, 64, None, 64),
|
||||
# dual builds keep wifi's sizes; the ethernet component moves frames to PSRAM
|
||||
("high_perf_wifi_ethernet_psram.yaml", 512000, 512, 512, True, 512),
|
||||
("high_perf_ethernet_no_psram.yaml", 16384, 64, 32, None, None),
|
||||
# ethernet only with PSRAM guaranteed: the cell the guard exists for
|
||||
("high_perf_ethernet_psram.yaml", 16384, 64, 32, None, None),
|
||||
],
|
||||
)
|
||||
def test_lwip_tier(
|
||||
generate_main: Callable[[str | Path], str],
|
||||
component_config_path: Callable[[str], Path],
|
||||
fixture: str,
|
||||
window: int,
|
||||
tcp_mailbox: int,
|
||||
tcpip_mailbox: int,
|
||||
window_scale: bool | None,
|
||||
wifi_rx_buffers: int | None,
|
||||
) -> None:
|
||||
# The wifi component only reacts to a component request, so request it the
|
||||
# way sendspin does; the config key alone decides the lwip tier.
|
||||
require_high_performance_networking()
|
||||
generate_main(component_config_path(fixture))
|
||||
assert sdkconfig_option("CONFIG_LWIP_TCP_WND_DEFAULT") == window
|
||||
assert sdkconfig_option("CONFIG_LWIP_TCP_RECVMBOX_SIZE") == tcp_mailbox
|
||||
assert sdkconfig_option("CONFIG_LWIP_TCPIP_RECVMBOX_SIZE") == tcpip_mailbox
|
||||
assert sdkconfig_option("CONFIG_LWIP_WND_SCALE") is window_scale
|
||||
# Wifi RX buffers really go to PSRAM, so the wifi tier is never downgraded
|
||||
assert sdkconfig_option("CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM") == wifi_rx_buffers
|
||||
@@ -19,6 +19,7 @@ from esphome.components.network import (
|
||||
from esphome.const import CONF_PRIORITY, PlatformFramework
|
||||
from esphome.core import CORE
|
||||
import esphome.final_validate as fv
|
||||
from tests.component_tests.network import sdkconfig_option
|
||||
from tests.component_tests.types import SetCoreConfigCallable
|
||||
|
||||
|
||||
@@ -217,13 +218,7 @@ def test_no_primary_interface_define_without_priority(
|
||||
|
||||
|
||||
def _dns_per_default_netif_option() -> bool | None:
|
||||
from esphome.components.esp32.const import KEY_ESP32, KEY_SDKCONFIG_OPTIONS
|
||||
|
||||
if KEY_ESP32 not in CORE.data: # non-ESP32 configs have no sdkconfig at all
|
||||
return None
|
||||
return CORE.data[KEY_ESP32][KEY_SDKCONFIG_OPTIONS].get(
|
||||
"CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF"
|
||||
)
|
||||
return sdkconfig_option("CONFIG_ESP_NETIF_SET_DNS_PER_DEFAULT_NETIF")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
@@ -14,32 +14,24 @@ import pytest
|
||||
from voluptuous import Invalid
|
||||
|
||||
from esphome import config_validation as cv
|
||||
from esphome.components.esp32.const import (
|
||||
KEY_SDKCONFIG_OPTIONS,
|
||||
KEY_VARIANT,
|
||||
VARIANT_ESP32,
|
||||
)
|
||||
from esphome.components.esp32.const import KEY_VARIANT, VARIANT_ESP32
|
||||
from esphome.components.network import (
|
||||
CONF_TCP_SEND_BUFFER,
|
||||
CONFIG_SCHEMA,
|
||||
TCP_SEND_BUFFER_MAX,
|
||||
TCP_SEND_BUFFER_MIN,
|
||||
)
|
||||
from esphome.const import KEY_ESP32, KEY_FRAMEWORK_VERSION, PlatformFramework
|
||||
from esphome.core import CORE
|
||||
from esphome.const import KEY_FRAMEWORK_VERSION, PlatformFramework
|
||||
from tests.component_tests.network import sdkconfig_option
|
||||
from tests.component_tests.types import SetCoreConfigCallable
|
||||
|
||||
|
||||
def _sdkconfig_option(name: str) -> int | None:
|
||||
return CORE.data[KEY_ESP32][KEY_SDKCONFIG_OPTIONS].get(name)
|
||||
|
||||
|
||||
def test_tcp_send_buffer_sets_sdkconfig(
|
||||
generate_main: Callable[[str | Path], str],
|
||||
component_config_path: Callable[[str], Path],
|
||||
) -> None:
|
||||
generate_main(component_config_path("tcp_send_buffer.yaml"))
|
||||
assert _sdkconfig_option("CONFIG_LWIP_TCP_SND_BUF_DEFAULT") == 32000
|
||||
assert sdkconfig_option("CONFIG_LWIP_TCP_SND_BUF_DEFAULT") == 32000
|
||||
|
||||
|
||||
def test_tcp_send_buffer_overrides_high_performance(
|
||||
@@ -48,7 +40,7 @@ def test_tcp_send_buffer_overrides_high_performance(
|
||||
) -> None:
|
||||
"""An explicit size wins over the high performance bundle's 65534."""
|
||||
generate_main(component_config_path("tcp_send_buffer_high_perf.yaml"))
|
||||
assert _sdkconfig_option("CONFIG_LWIP_TCP_SND_BUF_DEFAULT") == 16384
|
||||
assert sdkconfig_option("CONFIG_LWIP_TCP_SND_BUF_DEFAULT") == 16384
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [TCP_SEND_BUFFER_MIN, TCP_SEND_BUFFER_MAX])
|
||||
|
||||
Reference in New Issue
Block a user