From 4b9001a84ca8474edbbf98930c49d9a3aa0a6eca Mon Sep 17 00:00:00 2001 From: Li Shuai Date: Fri, 25 Apr 2025 15:56:20 +0800 Subject: [PATCH] change(esp_driver_uart): change ci test to improve the pass rate for hp uart wakeup --- .../test_apps/uart/main/test_hp_uart_wakeup.c | 13 +++++++++---- .../esp_driver_uart/test_apps/uart/pytest_uart.py | 8 ++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/components/esp_driver_uart/test_apps/uart/main/test_hp_uart_wakeup.c b/components/esp_driver_uart/test_apps/uart/main/test_hp_uart_wakeup.c index 6b35b76d97..fefe3b907c 100644 --- a/components/esp_driver_uart/test_apps/uart/main/test_hp_uart_wakeup.c +++ b/components/esp_driver_uart/test_apps/uart/main/test_hp_uart_wakeup.c @@ -61,7 +61,7 @@ #define SLAVE_UART_RX_IO_NUM DEFAULT_UART1_TX_IO_NUM #define UART_BAUD_RATE (115200) #define BUF_SIZE (1024) -#define TIMER_WAKEUP_TIME_US (5 * 100 * 1000) +#define TIMER_WAKEUP_TIME_US (1 * 100 * 1000) static void force_stdout(void) { @@ -139,14 +139,16 @@ void send_and_verify_recived_data(const char* message, uint8_t length, bool shou uart_flush_input(MASTER_UART_NUM); uart_write_bytes(MASTER_UART_NUM, message, length); - - char *data = (char *) malloc(BUF_SIZE); - int len = uart_read_bytes(MASTER_UART_NUM, data, (BUF_SIZE - 1), 1000 / portTICK_PERIOD_MS); + /* Wait for uart write finish */ + uart_wait_tx_idle_polling(MASTER_UART_NUM); bool wake_up_detected = false; const char *target = "Wakeup OK!"; int target_len = 11; bool match = true; + char *data = (char *) malloc(BUF_SIZE); + int len = uart_read_bytes(MASTER_UART_NUM, data, target_len, 5000 / portTICK_PERIOD_MS); + if (len > 0) { if (len != target_len) { match = false; @@ -207,8 +209,11 @@ static void enter_sleep_and_send_respond(void) /* Get timestamp after waking up from sleep */ int64_t t_after_us = esp_timer_get_time(); + /* Clear uart input buffer */ uart_flush_input(SLAVE_UART_NUM); printf("sleep duration: %lld\n", t_after_us - t_before_us); + + /* Determine the reason for uart wakeup */ switch (esp_sleep_get_wakeup_cause()) { case ESP_SLEEP_WAKEUP_UART: /* Hang-up for a while to switch and execute the uart task diff --git a/components/esp_driver_uart/test_apps/uart/pytest_uart.py b/components/esp_driver_uart/test_apps/uart/pytest_uart.py index d25191962c..5db9c9b075 100644 --- a/components/esp_driver_uart/test_apps/uart/pytest_uart.py +++ b/components/esp_driver_uart/test_apps/uart/pytest_uart.py @@ -37,7 +37,11 @@ def test_uart_single_dev(case_tester) -> None: # type: ignore assert uart_ports, f"Error: Chip type '{chip_type}' is not defined in input_argv. Aborting..." for case in case_tester.test_menu: - if 'hp-uart-only' not in case.groups and 'wakeup' not in case.groups: + if 'wakeup' in case.groups: + # multi-dev cases, skip on generic runner + continue + + if 'hp-uart-only' not in case.groups: for uart_port in uart_ports: dut.serial.hard_reset() dut._get_ready() @@ -46,7 +50,7 @@ def test_uart_single_dev(case_tester) -> None: # type: ignore dut.expect("select to test 'uart' or 'lp_uart' port", timeout=10) dut.write(f'{uart_port}') dut.expect_unity_test_output() - elif 'wakeup' not in case.groups: + else: dut._run_normal_case(case, reset=True)