feat(esp_hw_support): update edge wakeup CI test cases

This commit is contained in:
wuzhenghui
2026-05-12 10:29:57 +08:00
parent e491855cc6
commit 2f845ec76d
4 changed files with 54 additions and 32 deletions

View File

@@ -118,6 +118,6 @@ components/esp_hw_support/test_apps/wakeup_tests:
- esp_hw_support
- soc
disable_test:
- if: IDF_TARGET in ["esp32h21", "esp32h4"]
- if: IDF_TARGET in ["esp32h21"]
temporary: true
reason: lack of runners

View File

@@ -8,6 +8,7 @@
#include "unity_test_utils.h"
#include "test_utils.h"
#include "esp_sleep.h"
#include "soc/soc_caps.h"
#include "driver/gpio.h"
#include "hal/gpio_ll.h"
#include "esp_console.h"
@@ -84,7 +85,7 @@ static struct {
static int process_ext1_wakeup(int argc, char **argv)
{
int nerrors = arg_parse(argc, argv, (void **) &ext1_wakeup_args);
int io_wakeup_num = 0, io_wakeup_level = 0;
int io_wakeup_num = 0, io_wakeup_type = 0;
if (nerrors != 0) {
arg_print_errors(stderr, ext1_wakeup_args.end, argv[0]);
return 1;
@@ -100,21 +101,21 @@ static int process_ext1_wakeup(int argc, char **argv)
if (ext1_wakeup_args.mode->count) {
if (ext1_wakeup_args.mode->count == 1) {
io_wakeup_level = ext1_wakeup_args.mode->ival[0];
io_wakeup_type = ext1_wakeup_args.mode->ival[0];
} else {
ESP_LOGE(TAG, "no valid arguments");
return 1;
}
}
ESP_LOGI(TAG, "io_wakeup_level = %d\n", io_wakeup_level);
ESP_LOGI(TAG, "io_wakeup_type = %d\n", io_wakeup_type);
if (ext1_wakeup_args.disable->count) {
ESP_ERROR_CHECK(esp_sleep_disable_ext1_wakeup_io(1ULL << io_wakeup_num));
} else {
#if CONFIG_IDF_TARGET_ESP32
ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup_io(1ULL << io_wakeup_num, io_wakeup_level == 0 ? ESP_EXT1_WAKEUP_ALL_LOW : ESP_EXT1_WAKEUP_ANY_HIGH));
ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup_io(1ULL << io_wakeup_num, io_wakeup_type == 0 ? ESP_EXT1_WAKEUP_ALL_LOW : ESP_EXT1_WAKEUP_ANY_HIGH));
#else
ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup_io(1ULL << io_wakeup_num, io_wakeup_level == 0 ? ESP_EXT1_WAKEUP_ANY_LOW : ESP_EXT1_WAKEUP_ANY_HIGH));
ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup_io(1ULL << io_wakeup_num, io_wakeup_type == 0 ? ESP_EXT1_WAKEUP_ANY_LOW : ESP_EXT1_WAKEUP_ANY_HIGH));
#endif
}
return 0;
@@ -151,7 +152,7 @@ static struct {
static int process_rtcio_wakeup(int argc, char **argv)
{
int nerrors = arg_parse(argc, argv, (void **) &rtcio_wakeup_args);
int io_wakeup_num = 0, io_wakeup_level = 0;
int io_wakeup_num = 0, io_wakeup_type = 0;
if (nerrors != 0) {
arg_print_errors(stderr, rtcio_wakeup_args.end, argv[0]);
return 1;
@@ -167,13 +168,13 @@ static int process_rtcio_wakeup(int argc, char **argv)
if (rtcio_wakeup_args.level->count) {
if (rtcio_wakeup_args.level->count == 1) {
io_wakeup_level = rtcio_wakeup_args.level->ival[0];
io_wakeup_type = rtcio_wakeup_args.level->ival[0];
} else {
ESP_LOGE(TAG, "no valid arguments");
return 1;
}
}
ESP_LOGI(TAG, "io_wakeup_level = %d\n", io_wakeup_level);
ESP_LOGI(TAG, "io_wakeup_type = %d\n", io_wakeup_type);
if (rtcio_wakeup_args.disable->count) {
ESP_ERROR_CHECK(gpio_wakeup_disable_on_hp_periph_powerdown_sleep(io_wakeup_num));
@@ -187,8 +188,8 @@ static int process_rtcio_wakeup(int argc, char **argv)
};
ESP_ERROR_CHECK(gpio_config(&config));
/* Enable wake up from GPIO */
ESP_ERROR_CHECK(esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown(BIT64(io_wakeup_num), io_wakeup_level));
esp_sleep_gpio_wake_up_mode_t mode = (esp_sleep_gpio_wake_up_mode_t)io_wakeup_type;
ESP_ERROR_CHECK(esp_sleep_enable_gpio_wakeup_on_hp_periph_powerdown(BIT64(io_wakeup_num), mode));
}
return 0;
@@ -199,7 +200,12 @@ static void register_rtcio_wakeup(void)
rtcio_wakeup_args.pin =
arg_int0("p", "pin", "<pin>", "configure the rtcio wakeup pin num");
rtcio_wakeup_args.level =
arg_int0("l", "level", "<level>", "configure the rtcio wakeup level");
arg_int0("l", "level", "<mode>",
"esp_sleep_gpio_wake_up_mode_t: 0=LOW, 1=HIGH"
#if SOC_RTC_GPIO_EDGE_WAKEUP_SUPPORTED
", 2=POSEDGE, 3=NEGEDGE, 4=ANYEDGE"
#endif
);
rtcio_wakeup_args.disable =
arg_lit0("d", "disable", "disable the rtcio wakeup on certain pin");
rtcio_wakeup_args.end = arg_end(4);
@@ -225,7 +231,7 @@ static struct {
static int process_gpio_wakeup(int argc, char **argv)
{
int nerrors = arg_parse(argc, argv, (void **) &gpio_wakeup_args);
int io_wakeup_num = 0, io_wakeup_level = 0;
int io_wakeup_num = 0, io_wakeup_type = 0;
if (nerrors != 0) {
arg_print_errors(stderr, gpio_wakeup_args.end, argv[0]);
return 1;
@@ -241,13 +247,13 @@ static int process_gpio_wakeup(int argc, char **argv)
if (gpio_wakeup_args.level->count) {
if (gpio_wakeup_args.level->count == 1) {
io_wakeup_level = gpio_wakeup_args.level->ival[0];
io_wakeup_type = gpio_wakeup_args.level->ival[0];
} else {
ESP_LOGE(TAG, "no valid arguments");
return 1;
}
}
ESP_LOGI(TAG, "io_wakeup_level = %d\n", io_wakeup_level);
ESP_LOGI(TAG, "io_wakeup_type = %d\n", io_wakeup_type);
if (gpio_wakeup_args.disable->count) {
ESP_ERROR_CHECK(gpio_wakeup_disable(io_wakeup_num));
@@ -258,12 +264,12 @@ static int process_gpio_wakeup(int argc, char **argv)
.mode = GPIO_MODE_INPUT,
.pull_down_en = GPIO_PULLDOWN_DISABLE,
.pull_up_en = GPIO_PULLUP_DISABLE,
.intr_type = (io_wakeup_level == 0) ? GPIO_INTR_LOW_LEVEL : GPIO_INTR_HIGH_LEVEL
.intr_type = (io_wakeup_type == 0) ? GPIO_INTR_LOW_LEVEL : GPIO_INTR_HIGH_LEVEL
};
ESP_ERROR_CHECK(gpio_config(&config));
/* Enable wake up from GPIO */
ESP_ERROR_CHECK(gpio_wakeup_enable(io_wakeup_num, io_wakeup_level == 0 ? GPIO_INTR_LOW_LEVEL : GPIO_INTR_HIGH_LEVEL));
ESP_ERROR_CHECK(gpio_wakeup_enable(io_wakeup_num, io_wakeup_type == 0 ? GPIO_INTR_LOW_LEVEL : GPIO_INTR_HIGH_LEVEL));
ESP_ERROR_CHECK(esp_sleep_enable_gpio_wakeup());
}

View File

@@ -24,8 +24,14 @@ available_gpio_nums = {
+ [28, 29, 30, 31, 32, 33, 36, 49, 50, 51, 52, 53, 54],
'esp32c5': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 14, 23, 24, 25, 26],
'esp32c61': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 13, 22, 23, 24, 25, 26, 27, 28, 29],
'esp32h4': [0, 1, 2, 3, 4, 5, 15, 16, 18, 19, 20, 21, 22, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 38, 39],
'esp32s31': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
+ [42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57],
}
# Matches SOC_RTC_GPIO_EDGE_WAKEUP_SUPPORTED in soc_caps.h (HP-periph PD GPIO wakeup edge)
RTC_GPIO_EDGE_HP_PD_TARGETS = frozenset({'esp32c5', 'esp32c6', 'esp32c61', 'esp32p4', 'esp32h4'})
available_rtcio_nums = {
'esp32': [36, 37, 38, 39, 34, 35, 25, 26, 33, 32, 4, 0, 2, 15, 13, 12, 14, 27],
'esp32s2': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],
@@ -37,6 +43,8 @@ available_rtcio_nums = {
'esp32p4': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
'esp32c5': [0, 1, 2, 3, 4, 5, 6],
'esp32c61': [0, 1, 2, 3, 4, 5, 6],
'esp32h4': [0, 1, 2, 3, 4, 5],
'esp32s31': [0, 1, 2, 3, 4, 5, 6, 7],
}
@@ -48,7 +56,6 @@ available_rtcio_nums = {
soc_filtered_targets('SOC_PM_SUPPORT_EXT1_WAKEUP == 1 and SOC_DEEP_SLEEP_SUPPORTED == 1'),
indirect=['target'],
)
@pytest.mark.temp_skip_ci(targets=['esp32h4'], reason='lack of multi-device runners') # TODO: IDFCI-10702
def test_ext1_deepsleep(dut: tuple[IdfDut, IdfDut]) -> None:
wakee = dut[0]
waker = dut[1]
@@ -67,7 +74,7 @@ def test_ext1_deepsleep(dut: tuple[IdfDut, IdfDut]) -> None:
wakee.expect('io_wakeup_test>', timeout=10)
wakee.write(f'ext1 -p {gpio_num} -m {wakeup_level}')
wakee.expect(f'io_wakeup_num = {gpio_num}', timeout=10)
wakee.expect(f'io_wakeup_level = {wakeup_level}', timeout=10)
wakee.expect(f'io_wakeup_type = {wakeup_level}', timeout=10)
waker.expect('io_wakeup_test>', timeout=10)
sleep_level = 1 - wakeup_level
@@ -100,7 +107,6 @@ def test_ext1_deepsleep(dut: tuple[IdfDut, IdfDut]) -> None:
@pytest.mark.parametrize('count', [2], indirect=True)
@pytest.mark.parametrize('config', TEST_CONFIGS, indirect=True)
@idf_parametrize('target', soc_filtered_targets('SOC_GPIO_SUPPORT_HP_PERIPH_PD_SLEEP_WAKEUP == 1'), indirect=['target'])
@pytest.mark.temp_skip_ci(targets=['esp32h4'], reason='lack of multi-device runners') # TODO: IDFCI-10702
def test_rtcio_deepsleep(dut: tuple[IdfDut, IdfDut]) -> None:
wakee = dut[0]
waker = dut[1]
@@ -109,7 +115,21 @@ def test_rtcio_deepsleep(dut: tuple[IdfDut, IdfDut]) -> None:
gpio_nums = available_gpio_nums.get(chip_type, [])
rtcio_nums = available_rtcio_nums.get(chip_type, [])
for wakeup_level in [0, 1]:
# Modes: 0=LOW, 1=HIGH, 2=POSEDGE, 3=NEGEDGE, 4=ANYEDGE
# Tuple: (esp_sleep_gpio_wake_up_mode_t as int, waker_level_before_sleep, waker_level_to_wake)
dslp_io_wakeup_cases = [
(0, 1, 0), # low level: hold high, then pull low
(1, 0, 1), # high level: hold low, then drive high
]
if chip_type in RTC_GPIO_EDGE_HP_PD_TARGETS:
dslp_io_wakeup_cases += [
(2, 0, 1), # posedge: low then rising edge
(3, 1, 0), # negedge: high then falling edge
(4, 0, 1), # anyedge: rising edge from low
(4, 1, 0), # anyedge: falling edge from high
]
for wakeup_mode, prep_level, wake_level in dslp_io_wakeup_cases:
for gpio_num in rtcio_nums:
if gpio_num not in gpio_nums:
continue
@@ -117,23 +137,22 @@ def test_rtcio_deepsleep(dut: tuple[IdfDut, IdfDut]) -> None:
wakee.write('\r\n')
sleep(0.1)
wakee.expect('io_wakeup_test>', timeout=10)
wakee.write(f'rtcio -p {gpio_num} -l {wakeup_level}')
wakee.write(f'rtcio -p {gpio_num} -l {wakeup_mode}')
wakee.expect(f'io_wakeup_num = {gpio_num}', timeout=10)
wakee.expect(f'io_wakeup_level = {wakeup_level}', timeout=10)
wakee.expect(f'io_wakeup_type = {wakeup_mode}', timeout=10)
waker.expect('io_wakeup_test>', timeout=10)
sleep_level = 1 - wakeup_level
waker.write(f'gpio_control -p {gpio_num} -l {sleep_level}')
waker.write(f'gpio_control -p {gpio_num} -l {prep_level}')
waker.expect(f'io_num = {gpio_num}', timeout=10)
waker.expect(f'io_level = {sleep_level}', timeout=10)
waker.expect(f'io_level = {prep_level}', timeout=10)
wakee.write('sleep -m 1')
wakee.expect('enter deep sleep', timeout=10)
sleep(2)
waker.write(f'gpio_control -p {gpio_num} -l {wakeup_level}')
waker.write(f'gpio_control -p {gpio_num} -l {wake_level}')
waker.expect(f'io_num = {gpio_num}', timeout=10)
waker.expect(f'io_level = {wakeup_level}', timeout=10)
waker.expect(f'io_level = {wake_level}', timeout=10)
wakee.expect('io_wakeup_test>', timeout=10)
wakee.write('cause')
@@ -146,8 +165,6 @@ def test_rtcio_deepsleep(dut: tuple[IdfDut, IdfDut]) -> None:
@pytest.mark.parametrize('count', [2], indirect=True)
@pytest.mark.parametrize('config', TEST_CONFIGS, indirect=True)
@idf_parametrize('target', ['supported_targets'], indirect=['target'])
@pytest.mark.temp_skip_ci(targets=['esp32s31'], reason='bringup on this module is not done')
@pytest.mark.temp_skip_ci(targets=['esp32h4'], reason='lack of multi-device runners') # TODO: IDFCI-10702
def test_gpio_wakeup_enable_lightsleep(dut: tuple[IdfDut, IdfDut]) -> None:
wakee = dut[0]
waker = dut[1]
@@ -161,7 +178,7 @@ def test_gpio_wakeup_enable_lightsleep(dut: tuple[IdfDut, IdfDut]) -> None:
wakee.expect('io_wakeup_test>', timeout=10)
wakee.write(f'gpio -p {gpio_num} -l {wakeup_level}')
wakee.expect(f'io_wakeup_num = {gpio_num}', timeout=10)
wakee.expect(f'io_wakeup_level = {wakeup_level}', timeout=10)
wakee.expect(f'io_wakeup_type = {wakeup_level}', timeout=10)
waker.expect('io_wakeup_test>', timeout=10)
sleep_level = 1 - wakeup_level

View File

@@ -28,4 +28,3 @@ no_runner_tags:
- esp32p4,jtag
- esp32s2,usb_host_flash_disk
- esp32s31,usb_host_flash_disk
- esp32s31_2,generic_multi_device,rev_default