hathach / tinyusb

An open source cross-platform USB stack for embedded system
https://www.tinyusb.org
MIT License
4.85k stars 1.03k forks source link

Wrong data toggle and missing handshake #2741

Open moc32 opened 1 month ago

moc32 commented 1 month ago

Operating System

Others

Board

PIC0 RP2040

Firmware

examples/host_bare_api ex_host_bare_api.zip

What happened ?

On pico rp2040 host, control endpoint get blocked after a random period of time. The status stage is missing and no more control_xfer is possible.

On a specific roline mouse, enumeration fails with wrong data toggle from the device. The USB_INTS_ERROR_DATA_SEQ_BITS is not handled in the current version of the sdk. The driver just panics.

How to reproduce ?

Compile the attached modified firmware and connect a keyboad. The scrolllock and capslock LED will blink (250ms). After a random period of time the blinking stops and the control endpoint is blocked. For the data toggling issue, connect a roline mouse and enumeration will fail.

image

Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)

protocol=00, interface=00, report=00 [0:1] Class Request: 21 09 00 02 00 00 01 00 hw_endpoint_init dev 1 ep 0 out xfer 0 dev 1 ep 0 out setup buffer @ 0x50100180 endpoint control (0x50100100) <- 0xa0000180 Transfer complete Sent setup packet on EP 00 with 8 bytes hcd_edpt_xfer dev_addr 1, ep_addr 0x0, len 1 Prepare BufCtrl: [0] = 0xf401 [1] = 0x0000 Buffer complete buf_status 0x00000001 Single Buffered: ep_ctrl = A0000180 Sync BufCtrl: [0] = 0x6001 [1] = 0x0000 Short packet on buffer 0 with 1 bytes Completed transfer of 1 bytes on ep 0 out Transfer complete on EP 00 with 1 bytes [0:1] Control data: 0000: 00 |.| hcd_edpt_xfer dev_addr 1, ep_addr 0x80, len 0 hw_endpoint_init dev 1 ep 0 in xfer 0 dev 1 ep 0 in setup buffer @ 0x50100180 endpoint control (0x50100100) <- 0xa0000180 Prepare BufCtrl: [0] = 0x7400 [1] = 0x0000 protocol=00, interface=00, report=06 Failed to set report protocol=00, interface=00, report=00 Failed to set report protocol=00, interface=00, report=06 Failed to set report protocol=00, interface=00, report=00 Failed to set report protocol=00, interface=00, report=06 Failed to set report protocol=00, interface=00, report=00

Screenshots

image

Ellisys output on control endpoint transfer failure

I have checked existing issues, dicussion and documentation

moc32 commented 1 month ago

@kilograham this might be an issue with the rp2040 usb host controller. TinyUSB host does not handle the wrong data toggle error but when I connect the same device to other host controllers including Windows, I don't get such an error.