Skip to content

fix compile issue with enabled both device and host stack for dwc2#3333

Merged
hathach merged 4 commits intomasterfrom
espressif-dual-mode
Nov 6, 2025
Merged

fix compile issue with enabled both device and host stack for dwc2#3333
hathach merged 4 commits intomasterfrom
espressif-dual-mode

Conversation

@hathach
Copy link
Owner

@hathach hathach commented Nov 6, 2025

supercede and close #3330

Copilot AI review requested due to automatic review settings November 6, 2025 12:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'USBH_STACK_SZE' to 'USBH_STACK_SIZE'.

Suggested change
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);

Copilot uses AI. Check for mistakes.
#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);
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'MAIN_STACK_SZIE' to 'MAIN_STACK_SIZE'.

Suggested change
xTaskCreate(main_task, "main", MAIN_STACK_SZIE, NULL, configMAX_PRIORITIES - 2, NULL);
xTaskCreate(main_task, "main", MAIN_STACK_SIZE, NULL, configMAX_PRIORITIES - 2, NULL);

Copilot uses AI. Check for mistakes.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines 403 to 405
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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 6, 2025

@hathach hathach merged commit 6641550 into master Nov 6, 2025
193 of 194 checks passed
@hathach hathach deleted the espressif-dual-mode branch November 6, 2025 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant