change(esp_hw_support): add case to test PSRAM survives after lightsleep

This commit is contained in:
wuzhenghui
2024-07-24 22:01:59 +08:00
parent 6e307d5408
commit e38462456c
7 changed files with 54 additions and 3 deletions

View File

@ -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:

View File

@ -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()

View File

@ -8,6 +8,7 @@
#include <sys/time.h>
#include <sys/param.h>
#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 ////////////////////////////////////

View File

@ -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]),
]
)

View File

@ -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

View File

@ -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

View File

@ -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