Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dcd_dwc2): Changed OTG Bvalid override configuration for ESP32 #19

Merged

Conversation

roma-jam
Copy link
Collaborator

@roma-jam roma-jam commented Jan 29, 2024

Closes espressif/esp-idf#12360

Changes

  • Disabled overriding Bvalid signal by software.

Additional context
When tinyUSB driver installed with self_powered and vbus_monitor_io configuration, during usb_phy_new() initialization the IO multiplexer combining a GPIO input (value from vbus_monitor_io) with a peripheral signal bvalid_io_num.

According to that configuration, after deasserting the VBUS (and GPIO input is low), Bvalid signal controlled by phy's utmiotg_bvalid signal and the session end detect flag appears in GOTGINT register, which in its own triggers the IRQ.

During the IRQ handler in DCD, the DCD_EVENT_UNPLUGGED is triggered to inform the usbd layer about device disconnection from the Host.

UPD:

  1. Changes also verified without self_powered and vbus_monitor_io configuration. The working status does not affected.
  2. The changes doesn't keep the cleaning the Avalid overriding signal, which is applicable only for Host devices.

Test for the changes: espressif/esp-usb#10

@roma-jam roma-jam marked this pull request as ready for review January 29, 2024 15:55
@tore-espressif
Copy link
Collaborator

@roma-jam thank you for the update!

(just for completeness: we override many signals on the SoC level. That means that the avalid, bvalid etc signals are hardwired to 0 or 1 in the GPIO matrix https://github.com/espressif/esp-idf/blob/master/components/usb/usb_phy.c#L132)

@roma-jam
Copy link
Collaborator Author

@tore-espressif Yes, but there are options to override them by software and select which value to use for this overriding.

For tusb_msc example be able correctly attach/detach the storage on esp32s2/3 we don't need software overriding neither for Bvalid nor for Avalid.

Copy link
Collaborator

@tore-espressif tore-espressif left a comment

Choose a reason for hiding this comment

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

LGTM! Let's wait for the proper tests from espressif/esp-usb#10 (review)

@roma-jam
Copy link
Collaborator Author

Decided to make disconnection testing with ongoing transfer in separate PR.

@roma-jam roma-jam merged commit ecc8c70 into espressif:release/v0.15 Feb 12, 2024
@roma-jam roma-jam deleted the fix/dcd_dwc2_bvalid_override branch February 12, 2024 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants