forked from espressif/esp-idf
deep sleep example: Extend test coverage to ESP32-S2
* Modify the example on ESP32-S2 to print same output pattern as ESP32 * Add example test verification that "fast booting" (skipping of verification) is working
This commit is contained in:
@@ -318,6 +318,7 @@ test_app_test_003:
|
|||||||
|
|
||||||
test_app_test_004:
|
test_app_test_004:
|
||||||
extends: .test_app_esp32s2_template
|
extends: .test_app_esp32s2_template
|
||||||
|
parallel: 2
|
||||||
tags:
|
tags:
|
||||||
- ESP32S2
|
- ESP32S2
|
||||||
- Example_GENERIC
|
- Example_GENERIC
|
||||||
|
@@ -1,25 +1,35 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import time
|
||||||
|
|
||||||
import ttfw_idf
|
import ttfw_idf
|
||||||
|
|
||||||
touch_wake_up_support = ['esp32']
|
touch_wake_up_support = ['esp32', 'esp32s2']
|
||||||
|
|
||||||
|
|
||||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32c3'])
|
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32s2', 'esp32c3'])
|
||||||
def test_examples_deep_sleep(env, extra_data):
|
def test_examples_deep_sleep(env, extra_data):
|
||||||
|
|
||||||
dut = env.get_dut('deep_sleep', 'examples/system/deep_sleep')
|
dut = env.get_dut('deep_sleep', 'examples/system/deep_sleep')
|
||||||
dut.start_app()
|
dut.start_app()
|
||||||
|
|
||||||
def expect_enable_deep_sleep_touch():
|
def expect_enable_deep_sleep_touch():
|
||||||
dut.expect_all('Enabling timer wakeup, 20s',
|
# different targets configure different wake pin(s)
|
||||||
re.compile(r'Touch pad #8 average: \d+, wakeup threshold set to \d+.'),
|
wake_pads = {
|
||||||
re.compile(r'Touch pad #9 average: \d+, wakeup threshold set to \d+.'),
|
'esp32': [8,9],
|
||||||
'Enabling touch pad wakeup',
|
'esp32s2': [9],
|
||||||
'Entering deep sleep',
|
}[dut.TARGET]
|
||||||
timeout=10)
|
|
||||||
|
print('Expecting to see wakeup configured on pad(s): {}'.format(wake_pads))
|
||||||
|
|
||||||
|
expect_items = ['Enabling timer wakeup, 20s']
|
||||||
|
for pad in wake_pads:
|
||||||
|
expect_items += [re.compile(r'Touch pad #{} average: \d+, wakeup threshold set to \d+.'.format(pad))]
|
||||||
|
expect_items += ['Enabling touch pad wakeup',
|
||||||
|
'Entering deep sleep']
|
||||||
|
|
||||||
|
dut.expect_all(*expect_items, timeout=10)
|
||||||
|
|
||||||
def expect_enable_deep_sleep_no_touch():
|
def expect_enable_deep_sleep_no_touch():
|
||||||
dut.expect_all('Enabling timer wakeup, 20s',
|
dut.expect_all('Enabling timer wakeup, 20s',
|
||||||
@@ -34,8 +44,20 @@ def test_examples_deep_sleep(env, extra_data):
|
|||||||
dut.expect('Not a deep sleep reset', timeout=30)
|
dut.expect('Not a deep sleep reset', timeout=30)
|
||||||
expect_enable_deep_sleep()
|
expect_enable_deep_sleep()
|
||||||
|
|
||||||
# Check that it spent 2xxxxms in deep sleep, i.e at least 20 seconds:
|
start_sleep = time.time()
|
||||||
dut.expect(re.compile(r'Wake up from timer. Time spent in deep sleep: 2\d{4}ms'), timeout=30)
|
print('Waiting for wakeup...')
|
||||||
|
dut.expect('boot: ESP-IDF', timeout=30) # first output that's the same on all chips
|
||||||
|
|
||||||
|
sleep_time = time.time() - start_sleep
|
||||||
|
print('Host measured sleep time at {:.2f}s'.format(sleep_time))
|
||||||
|
assert 19 < sleep_time < 22 # note: high tolerance as measuring time on the host may have some timing skew
|
||||||
|
|
||||||
|
# This line indicates that the CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP option set in sdkconfig.defaults
|
||||||
|
# has correctly allowed skipping verification on wakeup
|
||||||
|
dut.expect('boot: Fast booting app from partition', timeout=2)
|
||||||
|
|
||||||
|
# Check that it measured 2xxxxms in deep sleep, i.e at least 20 seconds:
|
||||||
|
dut.expect(re.compile(r'Wake up from timer. Time spent in deep sleep: 2\d{4}ms'), timeout=2)
|
||||||
expect_enable_deep_sleep()
|
expect_enable_deep_sleep()
|
||||||
|
|
||||||
|
|
||||||
|
@@ -245,11 +245,13 @@ void app_main(void)
|
|||||||
touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER);
|
touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER);
|
||||||
touch_pad_fsm_start();
|
touch_pad_fsm_start();
|
||||||
vTaskDelay(100 / portTICK_RATE_MS);
|
vTaskDelay(100 / portTICK_RATE_MS);
|
||||||
/* read sleep touch pad value */
|
|
||||||
uint32_t touch_value;
|
/* set touchpad wakeup threshold */
|
||||||
|
uint32_t touch_value, wake_threshold;
|
||||||
touch_pad_sleep_channel_read_smooth(TOUCH_PAD_NUM9, &touch_value);
|
touch_pad_sleep_channel_read_smooth(TOUCH_PAD_NUM9, &touch_value);
|
||||||
touch_pad_sleep_set_threshold(TOUCH_PAD_NUM9, touch_value * 0.1); //10%
|
wake_threshold = touch_value * 0.1; // wakeup when touch sensor crosses 10% of background level
|
||||||
printf("test init: touch pad [%d] slp %d, thresh %d\n",
|
touch_pad_sleep_set_threshold(TOUCH_PAD_NUM9, wake_threshold);
|
||||||
|
printf("Touch pad #%d average: %d, wakeup threshold set to %d\n",
|
||||||
TOUCH_PAD_NUM9, touch_value, (uint32_t)(touch_value * 0.1));
|
TOUCH_PAD_NUM9, touch_value, (uint32_t)(touch_value * 0.1));
|
||||||
#endif
|
#endif
|
||||||
printf("Enabling touch pad wakeup\n");
|
printf("Enabling touch pad wakeup\n");
|
||||||
|
Reference in New Issue
Block a user