diff --git a/components/esp_system/test_apps/.build-test-rules.yml b/components/esp_system/test_apps/.build-test-rules.yml index e0343c14e3..76aa754ff1 100644 --- a/components/esp_system/test_apps/.build-test-rules.yml +++ b/components/esp_system/test_apps/.build-test-rules.yml @@ -7,6 +7,7 @@ components/esp_system/test_apps/console: components/esp_system/test_apps/esp_system_unity_tests: disable: - if: IDF_TARGET == "esp32c5" or (CONFIG_NAME == "psram" and SOC_SPIRAM_SUPPORTED != 1) + - if: IDF_TARGET == "esp32c5" or (CONFIG_NAME == "psram_with_pd_top" and (SOC_SPIRAM_SUPPORTED != 1 or SOC_PM_SUPPORT_TOP_PD != 1)) components/esp_system/test_apps/linux_apis: enable: diff --git a/components/esp_system/test_apps/esp_system_unity_tests/main/CMakeLists.txt b/components/esp_system/test_apps/esp_system_unity_tests/main/CMakeLists.txt index 5550342e15..0f33f8666d 100644 --- a/components/esp_system/test_apps/esp_system_unity_tests/main/CMakeLists.txt +++ b/components/esp_system/test_apps/esp_system_unity_tests/main/CMakeLists.txt @@ -16,7 +16,7 @@ set(SRC "test_app_main.c" "test_system_time.c" "test_task_wdt.c") -if(CONFIG_SOC_LIGHT_SLEEP_SUPPORTED || CONFIG_SOC_DEEP_SLEEP_SUPPORTED) +if(CONFIG_SOC_LIGHT_SLEEP_SUPPORTED OR CONFIG_SOC_DEEP_SLEEP_SUPPORTED) list(APPEND SRC "test_sleep.c") endif() diff --git a/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c b/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c index 13d840c22f..10ac4c2f2c 100644 --- a/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c +++ b/components/esp_system/test_apps/esp_system_unity_tests/main/test_sleep.c @@ -8,6 +8,7 @@ #include #include #include "esp_sleep.h" +#include "esp_private/esp_sleep_internal.h" #include "driver/rtc_io.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" @@ -31,6 +32,14 @@ #include "nvs_flash.h" #include "nvs.h" +#if CONFIG_SPIRAM +#include "esp_private/esp_psram_extram.h" +#endif + +#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP +#include "esp_private/sleep_cpu.h" +#endif + #if SOC_PMU_SUPPORTED #include "esp_private/esp_pmu.h" #else @@ -46,7 +55,6 @@ __attribute__((unused)) static struct timeval tv_start, tv_stop; TEST_CASE("wake up from light sleep using timer", "[lightsleep]") { esp_sleep_enable_timer_wakeup(2000000); - struct timeval tv_start, tv_stop; gettimeofday(&tv_start, NULL); esp_light_sleep_start(); gettimeofday(&tv_stop, NULL); @@ -292,6 +300,43 @@ TEST_CASE("disable source trigger behavior", "[lightsleep]") } #endif // !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S2, ESP32S3) #endif //SOC_RTCIO_INPUT_OUTPUT_SUPPORTED + +#if CONFIG_SPIRAM +static void test_psram_accessible_after_lightsleep(void) +{ + esp_sleep_context_t sleep_ctx; + esp_sleep_set_sleep_context(&sleep_ctx); + +#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP + TEST_ESP_OK(sleep_cpu_configure(true)); +#endif + + esp_sleep_enable_timer_wakeup(100 * 1000); + esp_light_sleep_start(); + TEST_ASSERT_EQUAL(0, sleep_ctx.sleep_request_result); + +#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP + TEST_ASSERT_EQUAL(PMU_SLEEP_PD_TOP, sleep_ctx.sleep_flags & PMU_SLEEP_PD_TOP); + TEST_ESP_OK(sleep_cpu_configure(false)); +#endif + + TEST_ASSERT_EQUAL(true, esp_psram_extram_test()); + + esp_sleep_set_sleep_context(NULL); + esp_restart(); +} + +static void restart_for_reinit_psram(void) +{ + TEST_ASSERT_EQUAL(ESP_RST_SW, esp_reset_reason()); + printf("PSRAM survives after lightsleep test - OK\n"); +} + +TEST_CASE_MULTIPLE_STAGES("Test PSRAM survives after lightsleep", "[lightsleep]", + test_psram_accessible_after_lightsleep, + restart_for_reinit_psram); +#endif + #endif // SOC_LIGHT_SLEEP_SUPPORTED /////////////////////////// Deep Sleep Test Cases //////////////////////////////////// diff --git a/components/esp_system/test_apps/esp_system_unity_tests/pytest_esp_system_unity_tests.py b/components/esp_system/test_apps/esp_system_unity_tests/pytest_esp_system_unity_tests.py index 93d73937ce..03c3ba980b 100644 --- a/components/esp_system/test_apps/esp_system_unity_tests/pytest_esp_system_unity_tests.py +++ b/components/esp_system/test_apps/esp_system_unity_tests/pytest_esp_system_unity_tests.py @@ -11,6 +11,7 @@ from pytest_embedded import Dut pytest.param('default', marks=[pytest.mark.supported_targets]), pytest.param('pd_vddsdio', marks=[pytest.mark.supported_targets]), pytest.param('psram', marks=[pytest.mark.esp32, pytest.mark.esp32s2, pytest.mark.esp32s3, pytest.mark.esp32p4]), + pytest.param('psram_with_pd_top', marks=[pytest.mark.esp32p4]), pytest.param('single_core_esp32', marks=[pytest.mark.esp32]), ] ) diff --git a/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.default b/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.default index fcbda27d40..e8104032cf 100644 --- a/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.default +++ b/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.default @@ -1,5 +1,4 @@ # Default configuration # Used for testing stack smashing protection CONFIG_COMPILER_STACK_CHECK=y -CONFIG_ESP_SLEEP_DEBUG=y CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP=y diff --git a/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.psram_with_pd_top b/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.psram_with_pd_top new file mode 100644 index 0000000000..440009beb1 --- /dev/null +++ b/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.psram_with_pd_top @@ -0,0 +1,4 @@ +CONFIG_SPIRAM=y +CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y +CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y +CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP=y diff --git a/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.defaults b/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.defaults index 55604ff94b..c381fad085 100644 --- a/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.defaults +++ b/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.defaults @@ -4,3 +4,4 @@ CONFIG_ESP_TASK_WDT_INIT=n # esp_sleep_enable_gpio_switch() has the change to break UART RX during light sleep stress tests # Remove this when IDF-4897 is fixed CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND=n +CONFIG_ESP_SLEEP_DEBUG=y