espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.7k stars 7.3k forks source link

[ESP32-S3] Interrupt IN endpoints get stuck in device mode (IDFGH-7838) #9367

Closed Huckies closed 1 year ago

Huckies commented 2 years ago

Environment

Problem Description

In device mode, some interrupt IN endpoints can get stuck if multiple endpoints are fed simultaneously.

Expected Behavior

Multiple HID endpoints works independently, they can be loaded by separate tasks and data is fetched according to the host.

Actual Behavior

If multiple (each endpoint is confirmed "ready" using tud_hid_n_ready()) endpoints are loaded in a single task, some of them can get "unready" forever.

Information that might help

The OTG peripheral is initialized by calling

    usb_phy_config_t phy_conf = {
        .controller = USB_PHY_CTRL_OTG,
        .otg_mode = USB_OTG_MODE_DEVICE,
        .target = USB_PHY_TARGET_INT,
    };
    usb_phy_handle_t phy_hdl;
    usb_new_phy(&phy_conf, &phy_hdl);

I've also refer to the TinyUSB example that set the task invoking tud_task() with a higher priority than the one loading endpoints. Due to the ESP32-S3 TRM describes the OTG peripheral in one stroke and inexpertness on usb registers, I'm unable to check the dcd_esp32sx.c.

I leave a log below, seems that there is some "crosstalk" between endpoints.

It's a definite issue, please reply if more information is needed. I'm looking forward to the solution

log.txt .

tore-espressif commented 2 years ago

Hello @Huckies than you for the bug report.

I couldn't reproduce this issue, so I need some more information in order to help you debug this. Could you please provide the following?:

  1. USB traffic capture from Wireshark (it contains more information than the log you provided)
  2. Full device descriptor of your device (you can find it with USB Device Tree Viewer )
  3. Log from TinyUSB: run idf.py menconfig and set Component config->TinyUSB Stack->TinyUSB log level to 3. Then run idf.py flash monitor
  4. A function that feeds the endpoint with new data (calls tud_hid_n_report())

Thanks! And just an FYI: with tud_hid_n_ready() you check readiness of an interface rather than an endpoint.

tore-espressif commented 1 year ago

Closing due to lack of feedback. Please feel free to reopen