summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBoris Dolgov <[email protected]>2026-05-15 21:28:21 +0200
committerBoris Dolgov <[email protected]>2026-05-15 21:28:21 +0200
commit72e09788e46a8ffaaae8009a316915838927af90 (patch)
treefe386a6dc4b227a7e72411068fd07fa96537d9a6 /src
parent7f146c9ff6e3aa6b19887b2b64161ae93f543888 (diff)
rp2040: fix host SET_REPORT (and any OUT-data control xfer) sending DATA0 instead of DATA1
hcd_edpt_xfer() previously reset ep->next_pid to 1 only when the control endpoint direction changed between stages. That handled IN-data control transfers (e.g. GET_REPORT, GET_DESCRIPTOR) where SETUP is OUT and DATA is IN, but not OUT-data class requests like SET_REPORT, where SETUP and DATA are both OUT and the direction-change check is false. ep->next_pid was left at 0 from hcd_edpt_open(), so the DATA stage went on the wire as DATA0 when the device expected DATA1. Strict devices (observed: Elgato Stream Deck) treat this as a protocol violation and disconnect. Key off "endpoint 0" instead of "direction changed", restoring the previous behavior. Interrupt/bulk endpoints take the ep->interrupt_num > 0 branch above and never reach this code, so they are unaffected.
Diffstat (limited to 'src')
-rw-r--r--src/portable/raspberrypi/rp2040/hcd_rp2040.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/portable/raspberrypi/rp2040/hcd_rp2040.c b/src/portable/raspberrypi/rp2040/hcd_rp2040.c
index 02a4e055e..064834efb 100644
--- a/src/portable/raspberrypi/rp2040/hcd_rp2040.c
+++ b/src/portable/raspberrypi/rp2040/hcd_rp2040.c
@@ -617,10 +617,16 @@ bool hcd_edpt_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr, uint8_t *b
io_rw_32 *buf_reg = dpram_int_ep_buffer_ctrl(ep->interrupt_num);
rp2usb_xfer_start(ep, ep_reg, buf_reg, buffer, NULL, buflen);
} else {
- // Control endpoint can change direction 0x00 <-> 0x80 when changing stages
- if (ep_addr != ep->ep_addr) {
+ // Control transfer data and status stages always start with DATA1, regardless of
+ // whether the direction changed since the previous stage. SET_REPORT (and any other
+ // host-to-device class request with an OUT data stage) keeps the same direction
+ // across SETUP -> DATA, so we cannot key off "direction changed" -- we must reset
+ // next_pid every time hcd_edpt_xfer is invoked on ep 0. Without this, the data stage
+ // of SET_REPORT goes out as DATA0 because ep->next_pid is still 0 from hcd_edpt_open(),
+ // which strict devices treat as a protocol violation and disconnect.
+ if (tu_edpt_number(ep_addr) == 0) {
ep->ep_addr = ep_addr;
- ep->next_pid = 1; // data and status stage start with DATA1
+ ep->next_pid = 1;
}
// If EPX is busy with another transfer, mark as pending