Skip to content

tests(cpu): Add deep sleep and misc tests for CPU #10112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix
  • Loading branch information
lucasssvaz committed Sep 29, 2024
commit 105bddfe3ebd5da86b191b831f59bc94f31735ec
3 changes: 2 additions & 1 deletion tests/validation/sleep/ci.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"platforms": {
"qemu": false
"qemu": false,
"wokwi": false
}
}
18 changes: 13 additions & 5 deletions tests/validation/sleep/sleep.ino
Original file line number Diff line number Diff line change
@@ -22,11 +22,14 @@

#if CONFIG_IDF_TARGET_ESP32H2
#define WAKEUP_GPIO GPIO_NUM_7 // Only RTC IO are allowed
#define TARGET_FREQ 32
#else
#define WAKEUP_GPIO GPIO_NUM_4 // Only RTC IO are allowed
#define TARGET_FREQ 40
#endif

RTC_DATA_ATTR int bootCount = 0;
RTC_DATA_ATTR int boot_count = 0;
uint32_t orig_freq = 0;

void print_wakeup_reason() {
esp_sleep_wakeup_cause_t wakeup_reason;
@@ -86,17 +89,17 @@ void setup_uart() {
esp_sleep_enable_uart_wakeup(UART_NUM_0);
}



void setup() {
Serial.begin(115200);
while (!Serial) {
delay(10);
}

orig_freq = getCpuFrequencyMhz();

//Increment boot number and print it every reboot
++bootCount;
Serial.println("Boot number: " + String(bootCount));
boot_count++;
Serial.println("Boot number: " + String(boot_count));

//Print the wakeup reason for ESP32
print_wakeup_reason();
@@ -138,6 +141,10 @@ void loop() {
} else if (command == "timer_light") {
// Test timer wakeup from light sleep
setup_timer();
} else if (command == "timer_freq_light") {
// Test timer wakeup from light sleep while changing CPU frequency
setCpuFrequencyMhz(TARGET_FREQ);
setup_timer();
} else if (command == "touchpad_light") {
// Test touchpad wakeup from light sleep
setup_touchpad();
@@ -163,5 +170,6 @@ void loop() {
print_wakeup_reason();
Serial.flush();
gpio_hold_dis(WAKEUP_GPIO);
setCpuFrequencyMhz(orig_freq);
}
}
8 changes: 4 additions & 4 deletions tests/validation/sleep/test_sleep.py
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ def test_sleep(dut):
dut.write("aaa") # Send 9 positive edges
dut.expect_exact("Woke up from light sleep")
dut.expect_exact("Wakeup reason: {}".format(capability))




if capability == "timer":
dut.write("timer_freq_light")
dut.expect_exact("Woke up from light sleep")
dut.expect_exact("Wakeup reason: timer")