raspberrypi / pico-sdk

BSD 3-Clause "New" or "Revised" License
3.26k stars 838 forks source link

TinyUSB Toggle between HID_PROTOCOL_BOOT and HID_PROTOCOL_REPORT #1632

Open moc32 opened 5 months ago

moc32 commented 5 months ago

Toggling mouse interface protocol between boot and report on Logitech K270/M185 blocks the ongoing interrupt endpoint transfer. This works for several KM devices. The only difference between those device and the Logitech K270/M185 or K220/M150 is the the wMaxPacketSize parameter. On the Logitech combo devices the value is 20 bytes for mouse endpoint and 8 bytes for keyboard endpoint. For the other devices the wMaxPacketSize is less than or equal to 8 bytes.

I have modified the tinyusb bare api example to add the protocol toggling. ex_host_bare_api.zip

moc32 commented 5 months ago

This issue might look trivial but It looks like an issue with the hardware controller. After toggling the report protocol, the keyboard endpoint get blocked. The host sends request to the keyboard endpoint and the keyboard is replying the IN request but the host is not sending the ACK and restart the IN transfer without firing any interrupt.

peterharperuk commented 5 months ago

@P33M does this make any sense to you?

moc32 commented 4 months ago

Hello @peterharperuk, @P33M @hathach, Do you have any idea of what is going on here? You can easily reproduce the issue by building the attached example project. After building the project, you can load the UF2 file on the pico board then connect a Logitech wireless KM (ex. K270/M185 or K220/M150) and click "R" to switch mouse to report mode or "B" to switch it to boot mode. You can also connect a wired keyboard using a hub since the PICO has only one USB port and in this case the switching works. The switching works also with combo devices from microsoft. The only difference between the logitech combo devices and other tested devices is that the the mouse interface wMaxPacketSize is 20 bytes where it is 8bytes or less for other devices.

peterharperuk commented 4 months ago

No. You might have to do better to convince me this is a Pico issue and not just a tinyusb problem

kilograham commented 1 month ago

moving to none until we know this is an SDK issue