Skip to content

Fix(host) enumeration with 8bitdo devices #3007

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

Merged
merged 2 commits into from
Mar 4, 2025
Merged

Fix(host) enumeration with 8bitdo devices #3007

merged 2 commits into from
Mar 4, 2025

Conversation

hathach
Copy link
Owner

@hathach hathach commented Mar 3, 2025

Describe the PR

  • fix(hcd_rp2040) assert/panic endpoint already active: when a device reset while having on-going control transfer
  • featuer(host) always get language id, manufacturer, product and serial string. Which is required by some device such as 8bitdo. Should fix HID host issues with RetroFlag Classic USB Gamepad #2163
  • add tuh_descriptor_get_string_langid() API

@tannewt please try to see if this works with your 8bitdo gamepad

PS: IAR build failed due to server maintanence

- host enumeration always get language id, manufacturer, product and serial string. Which is required by some device such as 8bitdo
@HiFiPhile
Copy link
Collaborator

Since you are working on usbh, I found at least on NUCLEO-H7S3L8 speed detection is more stable by putting tusb_time_delay_ms_api(ENUM_DEBOUNCING_DELAY_MS); at the start of enum_new_device().

@hathach
Copy link
Owner Author

hathach commented Mar 4, 2025

Since you are working on usbh, I found at least on NUCLEO-H7S3L8 speed detection is more stable by putting tusb_time_delay_ms_api(ENUM_DEBOUNCING_DELAY_MS); at the start of enum_new_device().

hmm that is weird, delay before port_reset() shouldn't make a difference since port got reset anyway, and the delay afterwards is rather generous ~450ms. Thank you for the hint, I will check this out next time I test with h7rs.

@hathach hathach merged commit 51cfae6 into master Mar 4, 2025
172 of 181 checks passed
@hathach hathach deleted the fix-8bitdo-enum branch March 4, 2025 03:47
@HiFiPhile
Copy link
Collaborator

If I remember correctly dwc2 does speed detection at the end of reset. If DEBOUNCING_DELAY_MS is placed after the end of reset then it won't help speed detection since it's already done.

@hathach
Copy link
Owner Author

hathach commented Mar 5, 2025

@HiFiPhile it is weird, there is ENUM_RESET_DELAY_MS which is 50ms per USB specs, it should be enough for dwc2 to detect the link speed, the ENUM_DEBOUNCING_DELAY_MS is mostly waiting for device to bootup/clock init before we start talking to it iirc. I will check again later.

    hcd_port_reset(_dev0.rhport);

    // Since we are in middle of rhport reset, frame number is not available yet.
    // need to depend on tusb_time_millis_api()
    tusb_time_delay_ms_api(ENUM_RESET_DELAY_MS);

    hcd_port_reset_end(_dev0.rhport);

    // wait until device connection is stable TODO non blocking
    tusb_time_delay_ms_api(ENUM_DEBOUNCING_DELAY_MS);

@HiFiPhile
Copy link
Collaborator

HiFiPhile commented Mar 5, 2025

it is weird, there is ENUM_RESET_DELAY_MS which is 50ms per USB specs,

I think some devices need extra time to power on (DP is pulled high but not ready to communicate), in which case ENUM_RESET_DELAY_MS is not enough. Speed detection is done once hcd_port_reset_end(_dev0.rhport); is called but the device is not ready yet. Then we wait for ENUM_DEBOUNCING_DELAY_MS but since the detection is already done it's not very useful.

image

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.

HID host issues with RetroFlag Classic USB Gamepad
2 participants