Skip to content

Conversation

@HiFiPhile
Copy link
Collaborator

@HiFiPhile HiFiPhile commented Nov 28, 2025

@roma-jam Hi, I've added deinit support to dwc2.

A dynamic switch example is added and tested on:

  • ESP32-S3-DevKitC
  • NUCLEO-H7S3L8
  • Nucleo-U5A5ZJ-Q
  • STM32F407-DISCO
  • STM32F723E-DISCO (FS/HS)
  • J-Link V9 (STM32F205 FS)

Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Copilot AI review requested due to automatic review settings November 28, 2025 14:44
Copilot finished reviewing on behalf of HiFiPhile November 28, 2025 14:48
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 adds deinitialization support for the Synopsys DWC2 USB controller, enabling dynamic start/stop of USB host and device modes. The implementation mirrors the initialization sequence in reverse, disabling interrupts, disconnecting from the bus, and resetting the core. This was tested on STM32H7S3 with device mode toggling via button press.

Key Changes

  • Implements hcd_deinit() and dcd_deinit() functions for DWC2 host and device controllers
  • Adds common dwc2_core_deinit() function shared between host and device modes
  • Updates error handling in tuh_deinit() and tud_deinit() to use TU_ASSERT consistently
  • Fixes button active state configuration for STM32H7S3 Nucleo board

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/portable/synopsys/dwc2/hcd_dwc2.c Adds host controller deinit implementation with interrupt disable
src/portable/synopsys/dwc2/dwc2_common.h Declares dwc2_core_deinit() for shared deinitialization logic
src/portable/synopsys/dwc2/dwc2_common.c Implements common core deinit with soft disconnect and core reset
src/portable/synopsys/dwc2/dcd_dwc2.c Adds device controller deinit with disconnect and cleanup
src/host/usbh.c Changes hcd_deinit() call to use TU_ASSERT for error checking
src/device/usbd.c Changes dcd_deinit() call to use TU_ASSERT for consistency
hw/bsp/stm32h7rs/boards/stm32h7s3nucleo/board.h Corrects button active state from 1 to 0 (active-low with pullup)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@HiFiPhile HiFiPhile mentioned this pull request Nov 28, 2025
1 task
@HiFiPhile HiFiPhile force-pushed the dwc2_deinit branch 2 times, most recently from 9461753 to e214976 Compare November 29, 2025 12:31
@HiFiPhile HiFiPhile requested a review from Copilot November 29, 2025 12:40
Copilot finished reviewing on behalf of HiFiPhile November 29, 2025 12:44
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

Copilot reviewed 22 out of 22 changed files in this pull request and generated 9 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 3, 2025

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.

2 participants