Merge branch 'feat/enable_wakeup_tests_for_more_chips_v5.2' into 'release/v5.2'

feat(esp_hw_support): enable wakeup tests for more chips (v5.2)

See merge request espressif/esp-idf!40309
This commit is contained in:
Jiang Jiang Jian
2025-07-11 13:40:03 +08:00
4 changed files with 71 additions and 12 deletions

View File

@@ -43,5 +43,7 @@ components/esp_hw_support/test_apps/rtc_power_modes:
reason: the other targets are not tested yet
components/esp_hw_support/test_apps/wakeup_tests:
enable:
- if: SOC_DEEP_SLEEP_SUPPORTED == 1 and SOC_LIGHT_SLEEP_SUPPORTED == 1
disable:
- if: IDF_TARGET in ["esp32c5", "esp32p4", "linux"]

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@@ -10,6 +10,7 @@
#include "esp_sleep.h"
#include "driver/rtc_io.h"
#include "driver/gpio.h"
#include "hal/gpio_ll.h"
#include "esp_console.h"
#include "linenoise/linenoise.h"
#include "argtable3/argtable3.h"
@@ -128,7 +129,7 @@ static void register_ext1_wakeup(void)
const esp_console_cmd_t cmd = {
.command = "ext1",
.help = "configue ext1 wakeup",
.help = "configure ext1 wakeup",
.hint = NULL,
.func = &process_ext1_wakeup,
.argtable = &ext1_wakeup_args
@@ -202,7 +203,7 @@ static void register_rtcio_wakeup(void)
const esp_console_cmd_t cmd = {
.command = "rtcio",
.help = "configue rtcio wakeup",
.help = "configure rtcio wakeup",
.hint = NULL,
.func = &process_rtcio_wakeup,
.argtable = &rtcio_wakeup_args
@@ -247,13 +248,14 @@ static int process_gpio_wakeup(int argc, char **argv)
if (gpio_wakeup_args.disable->count) {
ESP_ERROR_CHECK(gpio_wakeup_disable(io_wakeup_num));
ESP_ERROR_CHECK(gpio_intr_disable(io_wakeup_num));
} else {
gpio_config_t config = {
.pin_bit_mask = BIT64(io_wakeup_num),
.mode = GPIO_MODE_INPUT,
.pull_down_en = false,
.pull_up_en = false,
.intr_type = GPIO_INTR_DISABLE
.intr_type = (io_wakeup_level == 0) ? GPIO_INTR_LOW_LEVEL : GPIO_INTR_HIGH_LEVEL
};
ESP_ERROR_CHECK(gpio_config(&config));
@@ -277,7 +279,7 @@ static void register_gpio_wakeup(void)
const esp_console_cmd_t cmd = {
.command = "gpio",
.help = "configue gpio wakeup",
.help = "configure gpio wakeup",
.hint = NULL,
.func = &process_gpio_wakeup,
.argtable = &gpio_wakeup_args
@@ -336,7 +338,7 @@ static void register_gpio_control(void)
const esp_console_cmd_t cmd = {
.command = "gpio_control",
.help = "configue gpio control",
.help = "configure gpio control",
.hint = NULL,
.func = &process_gpio_control,
.argtable = &gpio_control_args
@@ -358,11 +360,51 @@ static int process_get_wakeup_cause(int argc, char **argv)
switch (esp_sleep_get_wakeup_cause()) {
case ESP_SLEEP_WAKEUP_EXT1: {
printf("Wake up from EXT1\n");
#if SOC_PM_SUPPORT_EXT1_WAKEUP && SOC_RTCIO_PIN_COUNT > 0
uint64_t wakeup_pin_mask = esp_sleep_get_ext1_wakeup_status();
if (wakeup_pin_mask != 0) {
int pin = __builtin_ffsll(wakeup_pin_mask) - 1;
printf("Wake up from EXT1 at IO%d\n", pin);
} else
#endif
{
printf("Wake up from EXT1 triggered, but unknown wake-up IO\n");
}
break;
}
case ESP_SLEEP_WAKEUP_GPIO: {
printf("Wake up from GPIO\n");
if (esp_reset_reason() == ESP_RST_DEEPSLEEP) {
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
uint64_t wakeup_pin_mask = esp_sleep_get_gpio_wakeup_status();
if (wakeup_pin_mask != 0) {
int pin = __builtin_ffsll(wakeup_pin_mask) - 1;
printf("Wake up from GPIO at IO%d\n", pin);
} else {
printf("Wake up from GPIO triggered, but unknown wake-up IO\n");
}
#endif
} else {
struct {
union {
struct
{
uint32_t status_l;
uint32_t status_h;
};
uint64_t val;
};
} gpio_intr_status;
gpio_ll_get_intr_status(&GPIO, 0, &gpio_intr_status.status_l);
gpio_ll_get_intr_status_high(&GPIO, 0, &gpio_intr_status.status_h);
if (gpio_intr_status.val) {
printf("Wake up from GPIO at IO%d\n", __builtin_ffsll(gpio_intr_status.val) - 1);
} else {
printf("Wake up from GPIO triggered, but unknown wake-up IO\n");
}
gpio_ll_clear_intr_status(&GPIO, 0xFFFFFFFF);
gpio_ll_clear_intr_status_high(&GPIO, 0xFFFFFFFF);
}
break;
}
default: {

View File

@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
from time import sleep
from typing import Tuple
@@ -76,7 +76,12 @@ def test_ext1_deepsleep(dut: Tuple[IdfDut, IdfDut]) -> None:
sleep(2)
wakee.write('cause')
# esp32 ext1 all low wakeup mode can not detect wakeup pin.
if (dut[0].target == 'esp32') and (wakeup_level == 0):
wakee.expect('Wake up from EXT1', timeout=10)
else:
wakee.expect(f'Wake up from EXT1 at IO{gpio_num}', timeout=10)
wakee.write(f'ext1 -p {gpio_num} -d')
wakee.expect(f'io_wakeup_num = {gpio_num}', timeout=10)
@@ -84,6 +89,7 @@ def test_ext1_deepsleep(dut: Tuple[IdfDut, IdfDut]) -> None:
@pytest.mark.esp32c2
@pytest.mark.esp32c3
@pytest.mark.esp32c6
@pytest.mark.esp32p4
@pytest.mark.generic_multi_device
@pytest.mark.parametrize('count', [2], indirect=True)
@pytest.mark.parametrize('config', TEST_CONFIGS, indirect=True)
@@ -124,7 +130,7 @@ def test_rtcio_deepsleep(dut: Tuple[IdfDut, IdfDut]) -> None:
sleep(2)
wakee.write('cause')
wakee.expect('Wake up from GPIO', timeout=10)
wakee.expect(f'Wake up from GPIO at IO{gpio_num}', timeout=10)
wakee.write(f'rtcio -p {gpio_num} -d')
wakee.expect(f'io_wakeup_num = {gpio_num}', timeout=10)
@@ -136,6 +142,7 @@ def test_rtcio_deepsleep(dut: Tuple[IdfDut, IdfDut]) -> None:
@pytest.mark.esp32s3
@pytest.mark.esp32c6
@pytest.mark.esp32h2
@pytest.mark.esp32p4
@pytest.mark.generic_multi_device
@pytest.mark.parametrize('count', [2], indirect=True)
@pytest.mark.parametrize('config', TEST_CONFIGS, indirect=True)
@@ -170,7 +177,7 @@ def test_gpio_wakeup_enable_lightsleep(dut: Tuple[IdfDut, IdfDut]) -> None:
wakee.expect('esp_light_sleep_start', timeout=10)
wakee.write('cause')
wakee.expect('Wake up from GPIO', timeout=10)
wakee.expect(f'Wake up from GPIO at IO{gpio_num}', timeout=10)
wakee.write(f'gpio -p {gpio_num} -d')
wakee.expect(f'io_wakeup_num = {gpio_num}', timeout=10)

View File

@@ -306,6 +306,14 @@ static inline void rtcio_ll_wakeup_enable(int rtcio_num, rtcio_ll_wake_type_t ty
{
LP_IO.pin[rtcio_num].wakeup_enable = 0x1;
LP_IO.pin[rtcio_num].int_type = type;
/* Work around for HW issue,
need to also enable this clk, otherwise it will
not trigger a wake-up on the ULP. This is not needed
for triggering a wakeup on HP CPU, but always setting this
has no side-effects.
*/
LP_IO.date.clk_en = 1;
}
/**