fix compile issue with enabled both device and host stack for dwc2#3333
fix compile issue with enabled both device and host stack for dwc2#3333
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the CMake build system to improve modularity and adds FreeRTOS support for the ESP32P4 platform. The main changes extract TinyUSB source file lists into a reusable function and enable the host_info_to_device_cdc dual-role example to work with FreeRTOS-based systems like ESP32P4.
Key changes:
- Extracted TinyUSB source listing into
tinyusb_sources_get()function for better reusability - Added FreeRTOS task management to host_info_to_device_cdc example
- Enabled ESP32P4 support for dual-role and host examples by updating build filters
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/CMakeLists.txt | Refactored to extract source file list into reusable tinyusb_sources_get() function |
| hw/bsp/family_support.cmake | Changed from add_subdirectory to include for TinyUSB CMakeLists; updated comment to mention ENV{CC} |
| hw/bsp/espressif/components/tinyusb_src/CMakeLists.txt | Refactored to use new tinyusb_sources_get() function, removing duplicate source list; added CMakePrintHelpers include; removed unused compile option |
| src/portable/synopsys/dwc2/dwc2_common.h | Moved conditional includes for device/dcd.h and host/hcd.h from .c to .h file |
| src/portable/synopsys/dwc2/dwc2_common.c | Removed includes that were moved to header; removed host/usbh.h include |
| src/portable/synopsys/dwc2/dcd_dwc2.c | Removed PVS-Studio suppression comment (moved to config file) |
| .PVS-Studio/.pvsconfig | Added global suppression for dwc2 gintsts warning; added exclusions for esp-idf and espressif components |
| examples/dual/host_info_to_device_cdc/src/main.c | Added FreeRTOS support with task creation, refactored init functions, changed to static functions, replaced board_delay with tusb_time_delay_ms_api |
| examples/dual/host_info_to_device_cdc/src/CMakeLists.txt | Added ESP-IDF component registration |
| examples/dual/host_info_to_device_cdc/CMakeLists.txt | Added early return for espressif family; changed RTOS parameter from hardcoded "noos" to variable |
| examples/dual/host_info_to_device_cdc/only.txt | Added ESP32P4 MCU support |
| examples/host/device_info/only.txt | Replaced individual ESP32 MCU entries with family:espressif filter |
| examples/host/cdc_msc_hid_freertos/only.txt | Replaced ESP32P4 MCU entry with family:espressif filter |
| examples/device/video_capture/src/main.c | Renamed freertos_init_task to freertos_init; reformatted return statements |
| examples/device/video_capture_2ch/src/main.c | Renamed freertos_init_task to freertos_init |
| xTaskCreateStatic(main_task, "main", MAIN_STACK_SIZE, NULL, configMAX_PRIORITIES - 2, main_stack, &main_taskdef); | ||
| #else | ||
| xTaskCreate(usb_device_task, "usbd", USBD_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL); | ||
| xTaskCreate(usb_host_task, "usbh", USBH_STACK_SZE, NULL, configMAX_PRIORITIES - 1, NULL); |
There was a problem hiding this comment.
Corrected spelling of 'USBH_STACK_SZE' to 'USBH_STACK_SIZE'.
| xTaskCreate(usb_host_task, "usbh", USBH_STACK_SZE, NULL, configMAX_PRIORITIES - 1, NULL); | |
| xTaskCreate(usb_host_task, "usbh", USBH_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL); |
| #else | ||
| xTaskCreate(usb_device_task, "usbd", USBD_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL); | ||
| xTaskCreate(usb_host_task, "usbh", USBH_STACK_SZE, NULL, configMAX_PRIORITIES - 1, NULL); | ||
| xTaskCreate(main_task, "main", MAIN_STACK_SZIE, NULL, configMAX_PRIORITIES - 2, NULL); |
There was a problem hiding this comment.
Corrected spelling of 'MAIN_STACK_SZIE' to 'MAIN_STACK_SIZE'.
| xTaskCreate(main_task, "main", MAIN_STACK_SZIE, NULL, configMAX_PRIORITIES - 2, NULL); | |
| xTaskCreate(main_task, "main", MAIN_STACK_SIZE, NULL, configMAX_PRIORITIES - 2, NULL); |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| xTaskCreate(usb_device_task, "usbd", USBD_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL); | ||
| xTaskCreate(usb_host_task, "usbh", USBH_STACK_SZE, NULL, configMAX_PRIORITIES - 1, NULL); | ||
| xTaskCreate(main_task, "main", MAIN_STACK_SZIE, NULL, configMAX_PRIORITIES - 2, NULL); |
There was a problem hiding this comment.
Fix typoed stack size macros in FreeRTOS path
When configSUPPORT_STATIC_ALLOCATION is disabled the FreeRTOS setup uses xTaskCreate with USBH_STACK_SZE and MAIN_STACK_SZIE. Both identifiers are misspelled and undefined, so any build that relies on dynamic task allocation will fail to compile. These lines should use the existing USBH_STACK_SIZE and MAIN_STACK_SIZE macros.
Useful? React with 👍 / 👎.
|



supercede and close #3330