Skip to content

Commit a225749

Browse files
committed
Merge branch 'feat/enable_wakeup_tests_for_more_chips' into 'master'
feat(esp_hw_support): enable wakeup tests for more chips Closes PM-337 See merge request espressif/esp-idf!39675
2 parents 916f701 + 96c6c0d commit a225749

File tree

6 files changed

+107
-14
lines changed

6 files changed

+107
-14
lines changed

components/esp_hw_support/test_apps/.build-test-rules.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,9 @@ components/esp_hw_support/test_apps/vad_wakeup:
5050
- if: SOC_LP_VAD_SUPPORTED != 1
5151

5252
components/esp_hw_support/test_apps/wakeup_tests:
53-
disable:
54-
- if: IDF_TARGET in ["esp32c5", "esp32p4", "linux", "esp32c61", "esp32h21", "esp32h4"] # TODO: PM-337
53+
enable:
54+
- if: SOC_DEEP_SLEEP_SUPPORTED == 1 and SOC_LIGHT_SLEEP_SUPPORTED == 1
55+
disable_test:
56+
- if: IDF_TARGET in ["esp32c61", "esp32h21", "esp32h4"]
57+
temporary: true
58+
reason: lack of runners
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
2-
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |
1+
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
2+
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- | -------- | -------- |

components/esp_hw_support/test_apps/wakeup_tests/main/src/io_wakeup_cmd.c

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "esp_sleep.h"
1111
#include "driver/rtc_io.h"
1212
#include "driver/gpio.h"
13+
#include "hal/gpio_ll.h"
1314
#include "esp_console.h"
1415
#include "linenoise/linenoise.h"
1516
#include "argtable3/argtable3.h"
@@ -251,13 +252,14 @@ static int process_gpio_wakeup(int argc, char **argv)
251252

252253
if (gpio_wakeup_args.disable->count) {
253254
ESP_ERROR_CHECK(gpio_wakeup_disable(io_wakeup_num));
255+
ESP_ERROR_CHECK(gpio_intr_disable(io_wakeup_num));
254256
} else {
255257
gpio_config_t config = {
256258
.pin_bit_mask = BIT64(io_wakeup_num),
257259
.mode = GPIO_MODE_INPUT,
258260
.pull_down_en = false,
259261
.pull_up_en = false,
260-
.intr_type = GPIO_INTR_DISABLE
262+
.intr_type = (io_wakeup_level == 0) ? GPIO_INTR_LOW_LEVEL : GPIO_INTR_HIGH_LEVEL
261263
};
262264
ESP_ERROR_CHECK(gpio_config(&config));
263265

@@ -362,11 +364,51 @@ static int process_get_wakeup_cause(int argc, char **argv)
362364

363365
switch (esp_sleep_get_wakeup_cause()) {
364366
case ESP_SLEEP_WAKEUP_EXT1: {
365-
printf("Wake up from EXT1\n");
367+
#if SOC_PM_SUPPORT_EXT1_WAKEUP && SOC_RTCIO_PIN_COUNT > 0
368+
uint64_t wakeup_pin_mask = esp_sleep_get_ext1_wakeup_status();
369+
if (wakeup_pin_mask != 0) {
370+
int pin = __builtin_ffsll(wakeup_pin_mask) - 1;
371+
printf("Wake up from EXT1 at IO%d\n", pin);
372+
} else
373+
#endif
374+
{
375+
printf("Wake up from EXT1 triggered, but unknown wake-up IO\n");
376+
}
366377
break;
367378
}
368379
case ESP_SLEEP_WAKEUP_GPIO: {
369-
printf("Wake up from GPIO\n");
380+
if (esp_reset_reason() == ESP_RST_DEEPSLEEP) {
381+
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
382+
uint64_t wakeup_pin_mask = esp_sleep_get_gpio_wakeup_status();
383+
if (wakeup_pin_mask != 0) {
384+
int pin = __builtin_ffsll(wakeup_pin_mask) - 1;
385+
printf("Wake up from GPIO at IO%d\n", pin);
386+
} else {
387+
printf("Wake up from GPIO triggered, but unknown wake-up IO\n");
388+
}
389+
#endif
390+
} else {
391+
struct {
392+
union {
393+
struct
394+
{
395+
uint32_t status_l;
396+
uint32_t status_h;
397+
};
398+
uint64_t val;
399+
};
400+
} gpio_intr_status;
401+
gpio_ll_get_intr_status(&GPIO, 0, &gpio_intr_status.status_l);
402+
gpio_ll_get_intr_status_high(&GPIO, 0, &gpio_intr_status.status_h);
403+
404+
if (gpio_intr_status.val) {
405+
printf("Wake up from GPIO at IO%d\n", __builtin_ffsll(gpio_intr_status.val) - 1);
406+
} else {
407+
printf("Wake up from GPIO triggered, but unknown wake-up IO\n");
408+
}
409+
gpio_ll_clear_intr_status(&GPIO, 0xFFFFFFFF);
410+
gpio_ll_clear_intr_status_high(&GPIO, 0xFFFFFFFF);
411+
}
370412
break;
371413
}
372414
default: {

components/esp_hw_support/test_apps/wakeup_tests/pytest_wakeup_tests.py

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,40 @@
2323
'esp32c3': [0, 1, 2, 3, 4, 5, 6, 7, 10, 18, 19],
2424
'esp32c6': [0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 15, 18, 19, 20, 21, 22, 23],
2525
'esp32h2': [0, 1, 2, 3, 4, 5, 10, 11, 12, 22, 25, 26, 27],
26+
'esp32p4': [
27+
0,
28+
1,
29+
2,
30+
3,
31+
4,
32+
5,
33+
6,
34+
7,
35+
8,
36+
9,
37+
10,
38+
11,
39+
12,
40+
13,
41+
14,
42+
15,
43+
16,
44+
17,
45+
28,
46+
29,
47+
30,
48+
31,
49+
32,
50+
33,
51+
36,
52+
49,
53+
50,
54+
51,
55+
52,
56+
53,
57+
54,
58+
],
59+
'esp32c5': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 14, 23, 24, 25, 26],
2660
}
2761

2862
available_rtcio_nums = {
@@ -33,13 +67,19 @@
3367
'esp32c3': [0, 1, 2, 3, 4, 5],
3468
'esp32c6': [0, 1, 2, 3, 4, 5, 6, 7],
3569
'esp32h2': [7, 8, 9, 10, 11, 12, 13, 14],
70+
'esp32p4': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
71+
'esp32c5': [0, 1, 2, 3, 4, 5, 6],
3672
}
3773

3874

3975
@pytest.mark.generic_multi_device
4076
@pytest.mark.parametrize('count', [2], indirect=True)
4177
@pytest.mark.parametrize('config', TEST_CONFIGS, indirect=True)
42-
@idf_parametrize('target', ['esp32', 'esp32s2', 'esp32s3', 'esp32c6', 'esp32h2'], indirect=['target'])
78+
@idf_parametrize(
79+
'target',
80+
['esp32', 'esp32s2', 'esp32s3', 'esp32c6', 'esp32h2', 'esp32p4', 'esp32c5'],
81+
indirect=['target'],
82+
)
4383
def test_ext1_deepsleep(dut: Tuple[IdfDut, IdfDut]) -> None:
4484
wakee = dut[0]
4585
waker = dut[1]
@@ -77,15 +117,20 @@ def test_ext1_deepsleep(dut: Tuple[IdfDut, IdfDut]) -> None:
77117
sleep(2)
78118

79119
wakee.write('cause')
80-
wakee.expect('Wake up from EXT1', timeout=10)
120+
# esp32 ext1 all low wakeup mode can not detect wakeup pin.
121+
if (dut[0].target == 'esp32') and (wakeup_level == 0):
122+
wakee.expect('Wake up from EXT1', timeout=10)
123+
else:
124+
wakee.expect(f'Wake up from EXT1 at IO{gpio_num}', timeout=10)
125+
81126
wakee.write(f'ext1 -p {gpio_num} -d')
82127
wakee.expect(f'io_wakeup_num = {gpio_num}', timeout=10)
83128

84129

85130
@pytest.mark.generic_multi_device
86131
@pytest.mark.parametrize('count', [2], indirect=True)
87132
@pytest.mark.parametrize('config', TEST_CONFIGS, indirect=True)
88-
@idf_parametrize('target', ['esp32c2', 'esp32c3', 'esp32c6'], indirect=['target'])
133+
@idf_parametrize('target', ['esp32c2', 'esp32c3', 'esp32c6', 'esp32p4', 'esp32c5'], indirect=['target'])
89134
def test_rtcio_deepsleep(dut: Tuple[IdfDut, IdfDut]) -> None:
90135
wakee = dut[0]
91136
waker = dut[1]
@@ -122,7 +167,7 @@ def test_rtcio_deepsleep(dut: Tuple[IdfDut, IdfDut]) -> None:
122167
wakee.expect('io_wakeup_test>', timeout=10)
123168

124169
wakee.write('cause')
125-
wakee.expect('Wake up from GPIO', timeout=10)
170+
wakee.expect(f'Wake up from GPIO at IO{gpio_num}', timeout=10)
126171
wakee.write(f'rtcio -p {gpio_num} -d')
127172
wakee.expect(f'io_wakeup_num = {gpio_num}', timeout=10)
128173

@@ -131,7 +176,9 @@ def test_rtcio_deepsleep(dut: Tuple[IdfDut, IdfDut]) -> None:
131176
@pytest.mark.parametrize('count', [2], indirect=True)
132177
@pytest.mark.parametrize('config', TEST_CONFIGS, indirect=True)
133178
@idf_parametrize(
134-
'target', ['esp32', 'esp32c2', 'esp32c3', 'esp32s2', 'esp32s3', 'esp32c6', 'esp32h2'], indirect=['target']
179+
'target',
180+
['esp32', 'esp32c2', 'esp32c3', 'esp32s2', 'esp32s3', 'esp32c6', 'esp32h2', 'esp32p4', 'esp32c5'],
181+
indirect=['target'],
135182
)
136183
def test_gpio_wakeup_enable_lightsleep(dut: Tuple[IdfDut, IdfDut]) -> None:
137184
wakee = dut[0]
@@ -164,7 +211,7 @@ def test_gpio_wakeup_enable_lightsleep(dut: Tuple[IdfDut, IdfDut]) -> None:
164211
wakee.expect('wakeup from lightsleep', timeout=10)
165212

166213
wakee.write('cause')
167-
wakee.expect('Wake up from GPIO', timeout=10)
214+
wakee.expect(f'Wake up from GPIO at IO{gpio_num}', timeout=10)
168215

169216
wakee.write(f'gpio -p {gpio_num} -d')
170217
wakee.expect(f'io_wakeup_num = {gpio_num}', timeout=10)

components/hal/esp32p4/include/hal/pmu_ll.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ static inline uint32_t pmu_ll_ext1_get_wakeup_status(void)
702702
static inline void pmu_ll_ext1_clear_wakeup_status(void)
703703
{
704704
REG_SET_BIT(PMU_EXT_WAKEUP_CNTL_REG, PMU_EXT_WAKEUP_STATUS_CLR);
705+
REG_CLR_BIT(PMU_EXT_WAKEUP_CNTL_REG, PMU_EXT_WAKEUP_STATUS_CLR);
705706
}
706707

707708
/**

tools/ci/dynamic_pipelines/templates/known_generate_test_child_pipeline_warnings.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ no_runner_tags:
1616
- esp32c3,sdcard_sdmode
1717
- esp32c5,adc
1818
- esp32c5,jtag
19-
- esp32c5_2,generic_multi_device
2019
- esp32c6,jtag
2120
- esp32c61,generic
2221
- esp32c61,jtag

0 commit comments

Comments
 (0)