mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/compile_usj_fail_c6' into 'master'
ci(usb_serial_jtag): Add a pytest for usb_serial_jtag print. Closes IDF-3201 See merge request espressif/esp-idf!26231
This commit is contained in:
commit
b2d7f4d0cd
@ -853,6 +853,14 @@ pytest_components_esp32s3_mspi_f8r8:
|
|||||||
- build_pytest_components_esp32s3
|
- build_pytest_components_esp32s3
|
||||||
tags: [ esp32s3, MSPI_F8R8 ]
|
tags: [ esp32s3, MSPI_F8R8 ]
|
||||||
|
|
||||||
|
pytest_components_esp32s3_usb_serial_jtag:
|
||||||
|
extends:
|
||||||
|
- .pytest_components_dir_template
|
||||||
|
- .rules:test:component_ut-esp32s3
|
||||||
|
needs:
|
||||||
|
- build_pytest_components_esp32s3
|
||||||
|
tags: [ esp32s3, usb_serial_jtag ]
|
||||||
|
|
||||||
pytest_components_esp32c2_generic:
|
pytest_components_esp32c2_generic:
|
||||||
extends:
|
extends:
|
||||||
- .pytest_components_dir_template
|
- .pytest_components_dir_template
|
||||||
@ -919,6 +927,14 @@ pytest_components_esp32c3_wifi_two_dut:
|
|||||||
- build_pytest_components_esp32c3
|
- build_pytest_components_esp32c3
|
||||||
tags: [ esp32c3, wifi_two_dut ]
|
tags: [ esp32c3, wifi_two_dut ]
|
||||||
|
|
||||||
|
pytest_components_esp32c3_usb_serial_jtag:
|
||||||
|
extends:
|
||||||
|
- .pytest_components_dir_template
|
||||||
|
- .rules:test:component_ut-esp32c3
|
||||||
|
needs:
|
||||||
|
- build_pytest_components_esp32c3
|
||||||
|
tags: [ esp32c3, usb_serial_jtag ]
|
||||||
|
|
||||||
pytest_components_esp32s3_wifi_two_dut:
|
pytest_components_esp32s3_wifi_two_dut:
|
||||||
extends:
|
extends:
|
||||||
- .pytest_components_dir_template
|
- .pytest_components_dir_template
|
||||||
@ -1008,6 +1024,14 @@ pytest_components_esp32c6_generic:
|
|||||||
tags: [ esp32c6, generic ]
|
tags: [ esp32c6, generic ]
|
||||||
parallel: 2
|
parallel: 2
|
||||||
|
|
||||||
|
pytest_components_esp32c6_usb_serial_jtag:
|
||||||
|
extends:
|
||||||
|
- .pytest_components_dir_template
|
||||||
|
- .rules:test:component_ut-esp32c6
|
||||||
|
needs:
|
||||||
|
- build_pytest_components_esp32c6
|
||||||
|
tags: [ esp32c6, usb_serial_jtag ]
|
||||||
|
|
||||||
pytest_components_esp32h2_generic:
|
pytest_components_esp32h2_generic:
|
||||||
extends:
|
extends:
|
||||||
- .pytest_components_dir_template
|
- .pytest_components_dir_template
|
||||||
@ -1041,6 +1065,14 @@ component_ut_pytest_esp32h2_ecdsa:
|
|||||||
- build_pytest_components_esp32h2
|
- build_pytest_components_esp32h2
|
||||||
tags: [ esp32h2, ecdsa_efuse ]
|
tags: [ esp32h2, ecdsa_efuse ]
|
||||||
|
|
||||||
|
pytest_components_esp32h2_usb_serial_jtag:
|
||||||
|
extends:
|
||||||
|
- .pytest_components_dir_template
|
||||||
|
- .rules:test:component_ut-esp32h2
|
||||||
|
needs:
|
||||||
|
- build_pytest_components_esp32h2
|
||||||
|
tags: [ esp32h2, usb_serial_jtag ]
|
||||||
|
|
||||||
pytest_components_esp32c6_generic_multi_device:
|
pytest_components_esp32c6_generic_multi_device:
|
||||||
extends:
|
extends:
|
||||||
- .pytest_components_dir_template
|
- .pytest_components_dir_template
|
||||||
|
@ -184,3 +184,14 @@ components/driver/test_apps/uart:
|
|||||||
- if: IDF_TARGET in ["esp32p4"]
|
- if: IDF_TARGET in ["esp32p4"]
|
||||||
temporary: true
|
temporary: true
|
||||||
reason: target(s) is not supported yet # TODO: IDF-6511
|
reason: target(s) is not supported yet # TODO: IDF-6511
|
||||||
|
|
||||||
|
components/driver/test_apps/usb_serial_jtag:
|
||||||
|
disable:
|
||||||
|
- if: SOC_USB_SERIAL_JTAG_SUPPORTED != 1
|
||||||
|
depends_filepatterns:
|
||||||
|
- components/driver/gpio/**/*
|
||||||
|
- components/driver/usb_serial_jtag/**/*
|
||||||
|
depends_components:
|
||||||
|
- hal
|
||||||
|
- esp_hw_support # for clock
|
||||||
|
- vfs
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
# This is the project CMakeLists.txt file for the test subproject
|
||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
|
||||||
|
set(COMPONENTS main)
|
||||||
|
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(usb_serial_test)
|
2
components/driver/test_apps/usb_serial_jtag/README.md
Normal file
2
components/driver/test_apps/usb_serial_jtag/README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
| Supported Targets | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S3 |
|
||||||
|
| ----------------- | -------- | -------- | -------- | -------- |
|
@ -0,0 +1,7 @@
|
|||||||
|
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||||
|
# the component can be registered as WHOLE_ARCHIVE
|
||||||
|
idf_component_register(
|
||||||
|
SRCS "test_app_main.c" "test_usb_serial_jtag.c"
|
||||||
|
REQUIRES driver unity vfs
|
||||||
|
WHOLE_ARCHIVE
|
||||||
|
)
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "unity.h"
|
||||||
|
#include "unity_test_utils.h"
|
||||||
|
#include "esp_heap_caps.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
|
||||||
|
#define TEST_MEMORY_LEAK_THRESHOLD (200)
|
||||||
|
|
||||||
|
static size_t before_free_8bit;
|
||||||
|
static size_t before_free_32bit;
|
||||||
|
|
||||||
|
void setUp(void)
|
||||||
|
{
|
||||||
|
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||||
|
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tearDown(void)
|
||||||
|
{
|
||||||
|
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||||
|
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||||
|
printf("\n");
|
||||||
|
unity_utils_check_leak(before_free_8bit, after_free_8bit, "8BIT", TEST_MEMORY_LEAK_THRESHOLD);
|
||||||
|
unity_utils_check_leak(before_free_32bit, after_free_32bit, "32BIT", TEST_MEMORY_LEAK_THRESHOLD);
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
// _ _ _____ ____ _____ ______ _____ _____ _
|
||||||
|
// | | | |/ ____| _ \ / ____| ____| __ \|_ _| /\ | |
|
||||||
|
// | | | | (___ | |_) || (___ | |__ | |__) | | | / \ | |
|
||||||
|
// | | | |\___ \| _ < \___ \| __| | _ / | | / /\ \ | |
|
||||||
|
// | |__| |____) | |_) | ____) | |____| | \ \ _| |_ / ____ \| |____
|
||||||
|
// \____/|_____/|____/ |_____/|______|_| \_\_____/_/ \_\______|
|
||||||
|
printf("\n");
|
||||||
|
printf(" _ _ _____ ____ _____ ______ _____ _____ _ \n");
|
||||||
|
printf("| | | |/ ____| _ \\ / ____| ____| __ \\|_ _| /\\ | | \n");
|
||||||
|
printf("| | | | (___ | |_) || (___ | |__ | |__) | | | / \\ | | \n");
|
||||||
|
printf("| | | |\\___ \\| _ < \\___ \\| __| | _ / | | / /\\ \\ | | \n");
|
||||||
|
printf("| |__| |____) | |_) | ____) | |____| | \\ \\ _| |_ / ____ \\| |____ \n");
|
||||||
|
printf(" \\____/|_____/|____/ |_____/|______|_| \\_\\_____/_/ \\_\\______|\n");
|
||||||
|
|
||||||
|
unity_run_menu();
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include "unity.h"
|
||||||
|
#include "driver/usb_serial_jtag.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "esp_vfs_dev.h"
|
||||||
|
#include "esp_vfs_usb_serial_jtag.h"
|
||||||
|
#include "driver/usb_serial_jtag.h"
|
||||||
|
#include <freertos/FreeRTOS.h>
|
||||||
|
#include <freertos/semphr.h>
|
||||||
|
#include <freertos/task.h>
|
||||||
|
|
||||||
|
#define PRINT_TIMES (300)
|
||||||
|
static const char TAG[] = "usb_serial_test";
|
||||||
|
|
||||||
|
static void test_task_driver1(void *pvParameters)
|
||||||
|
{
|
||||||
|
SemaphoreHandle_t sem = (SemaphoreHandle_t)pvParameters;
|
||||||
|
for (int i = 0; i < PRINT_TIMES; i++) {
|
||||||
|
ESP_LOGI(TAG, "Oh, hello world 1, this test is for testing message and parse in python, time %d", i);
|
||||||
|
vTaskDelay(11);
|
||||||
|
}
|
||||||
|
xSemaphoreGive(sem);
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_task_driver2(void *pvParameters)
|
||||||
|
{
|
||||||
|
SemaphoreHandle_t sem = (SemaphoreHandle_t)pvParameters;
|
||||||
|
for (int i = 0; i < PRINT_TIMES; i++) {
|
||||||
|
ESP_LOGI(TAG, "Oh, hello world 2, this test is for testing message and parse in python, time %d", i);
|
||||||
|
vTaskDelay(10);
|
||||||
|
}
|
||||||
|
xSemaphoreGive(sem);
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST_CASE("test print via usb_serial_jtag driver multiple times in different tasks", "[usb_serial_jtag]")
|
||||||
|
{
|
||||||
|
usb_serial_jtag_driver_config_t cfg = USB_SERIAL_JTAG_DRIVER_CONFIG_DEFAULT();
|
||||||
|
SemaphoreHandle_t sem = xSemaphoreCreateCounting(2, 0);
|
||||||
|
|
||||||
|
TEST_ESP_OK(usb_serial_jtag_driver_install(&cfg));
|
||||||
|
|
||||||
|
// Tell vfs to use usb-serial-jtag driver
|
||||||
|
esp_vfs_usb_serial_jtag_use_driver();
|
||||||
|
|
||||||
|
xTaskCreate(test_task_driver2, "usj_print_1", 4096, sem, 10, NULL);
|
||||||
|
xTaskCreate(test_task_driver1, "usj_print_2", 4096, sem, 10, NULL);
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
xSemaphoreTake(sem, portMAX_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
vSemaphoreDelete(sem);
|
||||||
|
vTaskDelay(5);
|
||||||
|
|
||||||
|
esp_vfs_usb_serial_jtag_use_nonblocking();
|
||||||
|
usb_serial_jtag_driver_uninstall();
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.esp32s3
|
||||||
|
@pytest.mark.esp32c3
|
||||||
|
@pytest.mark.esp32c6
|
||||||
|
@pytest.mark.esp32h2
|
||||||
|
@pytest.mark.usb_serial_jtag
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
'port, config',
|
||||||
|
[
|
||||||
|
('/dev/ttyACM0', 'release'),
|
||||||
|
],
|
||||||
|
indirect=True,
|
||||||
|
)
|
||||||
|
def test_usb_serial_jtag_dev(dut: Dut) -> None: # type: ignore
|
||||||
|
dut.expect_exact('Press ENTER to see the list of tests')
|
||||||
|
dut.write('\"test print via usb_serial_jtag driver multiple times in different tasks\"')
|
||||||
|
for i in range(300 * 2):
|
||||||
|
dut.expect(r'Oh, hello world (\d), this test is for testing message and parse in python, time (\d+)', timeout=10)
|
@ -0,0 +1,6 @@
|
|||||||
|
CONFIG_PM_ENABLE=y
|
||||||
|
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
|
||||||
|
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
|
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||||
|
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
|
||||||
|
CONFIG_COMPILER_OPTIMIZATION_NONE=y
|
@ -0,0 +1,3 @@
|
|||||||
|
CONFIG_FREERTOS_HZ=1000
|
||||||
|
CONFIG_ESP_TASK_WDT_INIT=n
|
||||||
|
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
|
@ -1 +0,0 @@
|
|||||||
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
|
|
Loading…
Reference in New Issue
Block a user