From 3abeee00d04b6e5e1d800bd959a50fe916520d14 Mon Sep 17 00:00:00 2001 From: Tomas Rezucha Date: Tue, 15 Feb 2022 13:01:30 +0100 Subject: [PATCH] usb_host: Pin test task to core 0 When we try to uninstall usb_host library on multi-core SoC (ESP32S3) the USB interrupt can be triggered even after it was disabled on one CPU --- .../cdc_acm_host/test/test_cdc_acm_host.c | 4 ++-- .../cdc/common/cdc_acm_host/test/usb_device.c | 4 ++-- .../host/msc/components/msc/test/test_common.h | 4 ++-- .../host/msc/components/msc/test/test_msc.c | 4 ++-- .../peripherals/usb/sdkconfig.defaults | 18 ++++++------------ 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/examples/peripherals/usb/host/cdc/common/cdc_acm_host/test/test_cdc_acm_host.c b/examples/peripherals/usb/host/cdc/common/cdc_acm_host/test/test_cdc_acm_host.c index 9d2582c8eb..a340ac8158 100644 --- a/examples/peripherals/usb/host/cdc/common/cdc_acm_host/test/test_cdc_acm_host.c +++ b/examples/peripherals/usb/host/cdc/common/cdc_acm_host/test/test_cdc_acm_host.c @@ -1,7 +1,7 @@ /* * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD * - * SPDX-License-Identifier: Apache-2.0 + * SPDX-License-Identifier: CC0-1.0 */ #include "soc/soc_caps.h" @@ -88,7 +88,7 @@ void usb_lib_task(void *arg) void test_install_cdc_driver(void) { // Create a task that will handle USB library events - TEST_ASSERT_EQUAL(pdTRUE, xTaskCreate(usb_lib_task, "usb_lib", 4*4096, xTaskGetCurrentTaskHandle(), 10, NULL)); + TEST_ASSERT_EQUAL(pdTRUE, xTaskCreatePinnedToCore(usb_lib_task, "usb_lib", 4*4096, xTaskGetCurrentTaskHandle(), 10, NULL, 0)); ulTaskNotifyTake(false, 1000); printf("Installing CDC-ACM driver\n"); diff --git a/examples/peripherals/usb/host/cdc/common/cdc_acm_host/test/usb_device.c b/examples/peripherals/usb/host/cdc/common/cdc_acm_host/test/usb_device.c index a2714112af..d6605eb875 100644 --- a/examples/peripherals/usb/host/cdc/common/cdc_acm_host/test/usb_device.c +++ b/examples/peripherals/usb/host/cdc/common/cdc_acm_host/test/usb_device.c @@ -1,7 +1,7 @@ /* * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD * - * SPDX-License-Identifier: Apache-2.0 + * SPDX-License-Identifier: CC0-1.0 */ #include @@ -55,7 +55,7 @@ void run_usb_dual_cdc_device(void) .usb_dev = TINYUSB_USBDEV_0, .cdc_port = TINYUSB_CDC_ACM_0, .rx_unread_buf_sz = 64, - .callback_rx = &tinyusb_cdc_rx_callback, // the first way to register a callback + .callback_rx = &tinyusb_cdc_rx_callback, .callback_rx_wanted_char = NULL, .callback_line_state_changed = NULL, .callback_line_coding_changed = NULL diff --git a/examples/peripherals/usb/host/msc/components/msc/test/test_common.h b/examples/peripherals/usb/host/msc/components/msc/test/test_common.h index b9acfaa9c9..63eb63df34 100644 --- a/examples/peripherals/usb/host/msc/components/msc/test/test_common.h +++ b/examples/peripherals/usb/host/msc/components/msc/test/test_common.h @@ -1,7 +1,7 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * - * SPDX-License-Identifier: Apache-2.0 + * SPDX-License-Identifier: CC0-1.0 */ #pragma once diff --git a/examples/peripherals/usb/host/msc/components/msc/test/test_msc.c b/examples/peripherals/usb/host/msc/components/msc/test/test_msc.c index 951dafe9e4..1c595b8176 100644 --- a/examples/peripherals/usb/host/msc/components/msc/test/test_msc.c +++ b/examples/peripherals/usb/host/msc/components/msc/test/test_msc.c @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD * - * SPDX-License-Identifier: Apache-2.0 + * SPDX-License-Identifier: CC0-1.0 */ #include "unity.h" @@ -198,7 +198,7 @@ static void msc_setup(void) }; ESP_OK_ASSERT( usb_host_install(&host_config) ); - task_created = xTaskCreate(handle_usb_events, "usb_events", 2048, NULL, 2, NULL); + task_created = xTaskCreatePinnedToCore(handle_usb_events, "usb_events", 2048, NULL, 2, NULL, 0); TEST_ASSERT(task_created); const msc_host_driver_config_t msc_config = { diff --git a/tools/test_apps/peripherals/usb/sdkconfig.defaults b/tools/test_apps/peripherals/usb/sdkconfig.defaults index 09016e1710..bab404d696 100644 --- a/tools/test_apps/peripherals/usb/sdkconfig.defaults +++ b/tools/test_apps/peripherals/usb/sdkconfig.defaults @@ -1,22 +1,16 @@ +# Configure TinyUSB, it will be used to mock USB devices CONFIG_TINYUSB=y CONFIG_TINYUSB_MSC_ENABLED=y CONFIG_TINYUSB_CDC_ENABLED=y CONFIG_TINYUSB_CDC_COUNT=2 + +# Disable watchdogs, they'd get triggered during unity interactive menu CONFIG_ESP_INT_WDT=n CONFIG_ESP_TASK_WDT=n -CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y -CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y -CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=n -CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y -CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=3 -CONFIG_FREERTOS_USE_TRACE_FACILITY=y -CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=3000 -CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=7 + +# Run-time checks of Heap and Stack CONFIG_HEAP_POISONING_COMPREHENSIVE=y -CONFIG_SPI_FLASH_ENABLE_COUNTERS=y -CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS=y CONFIG_COMPILER_STACK_CHECK_MODE_STRONG=y CONFIG_COMPILER_STACK_CHECK=y -CONFIG_COMPILER_WARN_WRITE_STRINGS=y -CONFIG_ESP_TIMER_PROFILING=y + CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL=y