mirror of
https://github.com/esphome/esphome.git
synced 2026-06-01 09:25:09 +08:00
[esp32] Enable execute_from_psram for P4 (#14329)
This commit is contained in:
@@ -890,10 +890,10 @@ def final_validate(config):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
if advanced[CONF_EXECUTE_FROM_PSRAM]:
|
if advanced[CONF_EXECUTE_FROM_PSRAM]:
|
||||||
if config[CONF_VARIANT] != VARIANT_ESP32S3:
|
if config[CONF_VARIANT] not in {VARIANT_ESP32S3, VARIANT_ESP32P4}:
|
||||||
errs.append(
|
errs.append(
|
||||||
cv.Invalid(
|
cv.Invalid(
|
||||||
f"'{CONF_EXECUTE_FROM_PSRAM}' is only supported on {VARIANT_ESP32S3} variant",
|
f"'{CONF_EXECUTE_FROM_PSRAM}' is not available on this esp32 variant",
|
||||||
path=[CONF_FRAMEWORK, CONF_ADVANCED, CONF_EXECUTE_FROM_PSRAM],
|
path=[CONF_FRAMEWORK, CONF_ADVANCED, CONF_EXECUTE_FROM_PSRAM],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -1627,8 +1627,13 @@ async def to_code(config):
|
|||||||
_configure_lwip_max_sockets(conf)
|
_configure_lwip_max_sockets(conf)
|
||||||
|
|
||||||
if advanced[CONF_EXECUTE_FROM_PSRAM]:
|
if advanced[CONF_EXECUTE_FROM_PSRAM]:
|
||||||
add_idf_sdkconfig_option("CONFIG_SPIRAM_FETCH_INSTRUCTIONS", True)
|
if variant == VARIANT_ESP32S3:
|
||||||
add_idf_sdkconfig_option("CONFIG_SPIRAM_RODATA", True)
|
add_idf_sdkconfig_option("CONFIG_SPIRAM_FETCH_INSTRUCTIONS", True)
|
||||||
|
add_idf_sdkconfig_option("CONFIG_SPIRAM_RODATA", True)
|
||||||
|
elif variant == VARIANT_ESP32P4:
|
||||||
|
add_idf_sdkconfig_option("CONFIG_SPIRAM_XIP_FROM_PSRAM", True)
|
||||||
|
else:
|
||||||
|
raise ValueError("Unhandled ESP32 variant")
|
||||||
|
|
||||||
# Apply LWIP core locking for better socket performance
|
# Apply LWIP core locking for better socket performance
|
||||||
# This is already enabled by default in Arduino framework, where it provides
|
# This is already enabled by default in Arduino framework, where it provides
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
esphome:
|
||||||
|
name: test
|
||||||
|
|
||||||
|
esp32:
|
||||||
|
variant: esp32s3
|
||||||
|
framework:
|
||||||
|
type: esp-idf
|
||||||
|
|
||||||
|
psram:
|
||||||
|
mode: octal
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
esphome:
|
||||||
|
name: test
|
||||||
|
|
||||||
|
esp32:
|
||||||
|
variant: esp32p4
|
||||||
|
framework:
|
||||||
|
type: esp-idf
|
||||||
|
advanced:
|
||||||
|
execute_from_psram: true
|
||||||
|
|
||||||
|
psram:
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
esphome:
|
||||||
|
name: test
|
||||||
|
|
||||||
|
esp32:
|
||||||
|
variant: esp32s3
|
||||||
|
framework:
|
||||||
|
type: esp-idf
|
||||||
|
advanced:
|
||||||
|
execute_from_psram: true
|
||||||
|
|
||||||
|
psram:
|
||||||
|
mode: octal
|
||||||
@@ -2,13 +2,17 @@
|
|||||||
Test ESP32 configuration
|
Test ESP32 configuration
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from collections.abc import Callable
|
||||||
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from esphome.components.esp32 import VARIANTS
|
from esphome.components.esp32 import VARIANTS
|
||||||
|
from esphome.components.esp32.const import KEY_ESP32, KEY_SDKCONFIG_OPTIONS
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.const import CONF_ESPHOME, PlatformFramework
|
from esphome.const import CONF_ESPHOME, PlatformFramework
|
||||||
|
from esphome.core import CORE
|
||||||
from tests.component_tests.types import SetCoreConfigCallable
|
from tests.component_tests.types import SetCoreConfigCallable
|
||||||
|
|
||||||
|
|
||||||
@@ -70,7 +74,7 @@ def test_esp32_config(
|
|||||||
"advanced": {"execute_from_psram": True},
|
"advanced": {"execute_from_psram": True},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
r"'execute_from_psram' is only supported on ESP32S3 variant @ data\['framework'\]\['advanced'\]\['execute_from_psram'\]",
|
r"'execute_from_psram' is not available on this esp32 variant @ data\['framework'\]\['advanced'\]\['execute_from_psram'\]",
|
||||||
id="execute_from_psram_invalid_for_variant_config",
|
id="execute_from_psram_invalid_for_variant_config",
|
||||||
),
|
),
|
||||||
pytest.param(
|
pytest.param(
|
||||||
@@ -82,7 +86,18 @@ def test_esp32_config(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
r"'execute_from_psram' requires PSRAM to be configured @ data\['framework'\]\['advanced'\]\['execute_from_psram'\]",
|
r"'execute_from_psram' requires PSRAM to be configured @ data\['framework'\]\['advanced'\]\['execute_from_psram'\]",
|
||||||
id="execute_from_psram_requires_psram_config",
|
id="execute_from_psram_requires_psram_s3_config",
|
||||||
|
),
|
||||||
|
pytest.param(
|
||||||
|
{
|
||||||
|
"variant": "esp32p4",
|
||||||
|
"framework": {
|
||||||
|
"type": "esp-idf",
|
||||||
|
"advanced": {"execute_from_psram": True},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
r"'execute_from_psram' requires PSRAM to be configured @ data\['framework'\]\['advanced'\]\['execute_from_psram'\]",
|
||||||
|
id="execute_from_psram_requires_psram_p4_config",
|
||||||
),
|
),
|
||||||
pytest.param(
|
pytest.param(
|
||||||
{
|
{
|
||||||
@@ -108,3 +123,39 @@ def test_esp32_configuration_errors(
|
|||||||
|
|
||||||
with pytest.raises(cv.Invalid, match=error_match):
|
with pytest.raises(cv.Invalid, match=error_match):
|
||||||
FINAL_VALIDATE_SCHEMA(CONFIG_SCHEMA(config))
|
FINAL_VALIDATE_SCHEMA(CONFIG_SCHEMA(config))
|
||||||
|
|
||||||
|
|
||||||
|
def test_execute_from_psram_s3_sdkconfig(
|
||||||
|
generate_main: Callable[[str | Path], str],
|
||||||
|
component_config_path: Callable[[str], Path],
|
||||||
|
) -> None:
|
||||||
|
"""Test that execute_from_psram on ESP32-S3 sets the correct sdkconfig options."""
|
||||||
|
generate_main(component_config_path("execute_from_psram_s3.yaml"))
|
||||||
|
sdkconfig = CORE.data[KEY_ESP32][KEY_SDKCONFIG_OPTIONS]
|
||||||
|
assert sdkconfig.get("CONFIG_SPIRAM_FETCH_INSTRUCTIONS") is True
|
||||||
|
assert sdkconfig.get("CONFIG_SPIRAM_RODATA") is True
|
||||||
|
assert "CONFIG_SPIRAM_XIP_FROM_PSRAM" not in sdkconfig
|
||||||
|
|
||||||
|
|
||||||
|
def test_execute_from_psram_p4_sdkconfig(
|
||||||
|
generate_main: Callable[[str | Path], str],
|
||||||
|
component_config_path: Callable[[str], Path],
|
||||||
|
) -> None:
|
||||||
|
"""Test that execute_from_psram on ESP32-P4 sets the correct sdkconfig options."""
|
||||||
|
generate_main(component_config_path("execute_from_psram_p4.yaml"))
|
||||||
|
sdkconfig = CORE.data[KEY_ESP32][KEY_SDKCONFIG_OPTIONS]
|
||||||
|
assert sdkconfig.get("CONFIG_SPIRAM_XIP_FROM_PSRAM") is True
|
||||||
|
assert "CONFIG_SPIRAM_FETCH_INSTRUCTIONS" not in sdkconfig
|
||||||
|
assert "CONFIG_SPIRAM_RODATA" not in sdkconfig
|
||||||
|
|
||||||
|
|
||||||
|
def test_execute_from_psram_disabled_sdkconfig(
|
||||||
|
generate_main: Callable[[str | Path], str],
|
||||||
|
component_config_path: Callable[[str], Path],
|
||||||
|
) -> None:
|
||||||
|
"""Test that without execute_from_psram, no XIP sdkconfig options are set."""
|
||||||
|
generate_main(component_config_path("execute_from_psram_disabled.yaml"))
|
||||||
|
sdkconfig = CORE.data[KEY_ESP32][KEY_SDKCONFIG_OPTIONS]
|
||||||
|
assert "CONFIG_SPIRAM_FETCH_INSTRUCTIONS" not in sdkconfig
|
||||||
|
assert "CONFIG_SPIRAM_RODATA" not in sdkconfig
|
||||||
|
assert "CONFIG_SPIRAM_XIP_FROM_PSRAM" not in sdkconfig
|
||||||
|
|||||||
Reference in New Issue
Block a user