rp2 hcd rework: epx for non-interrupt and ping-pong double buffered#3561
rp2 hcd rework: epx for non-interrupt and ping-pong double buffered#3561
Conversation
Size Difference ReportBecause TinyUSB code size varies by port and configuration, the metrics below represent the averaged totals across all example builds. Note: If there is no change, only one value is shown. Changes >1% in size
Changes <1% in size
No changes
|
|
| target | .text | .rodata | .data | .bss | total | % diff |
|---|---|---|---|---|---|---|
| frdm_kl25z/msc_file_explorer | 34,072 → 35,028 (+956) | — | — | 7,492 → 11,076 (+3,584) | 43,800 → 48,340 (+4,540) | +10.4% |
| ea4357/msc_file_explorer | 35,076 → 35,956 (+880) | — | — | 15,684 → 19,780 (+4,096) | 51,206 → 56,182 (+4,976) | +9.7% |
| ch32v203c_r0_1v0/msc_file_explorer | 38,784 → 39,880 (+1,096) | — | — | 7,272 → 10,856 (+3,584) | 48,548 → 53,228 (+4,680) | +9.6% |
| stm32g0b1nucleo/msc_file_explorer | 36,092 → 36,776 (+684) | 3,068 → 3,340 (+272) | — | 7,296 → 10,880 (+3,584) | 48,380 → 52,920 (+4,540) | +9.4% |
| stm32c071nucleo/msc_file_explorer | 34,052 → 34,736 (+684) | 3,072 → 3,344 (+272) | — | 7,296 → 10,880 (+3,584) | 48,388 → 52,928 (+4,540) | +9.4% |
| feather_stm32f405/msc_file_explorer | 35,984 → 36,596 (+612) | 3,040 → 3,312 (+272) | — | 7,244 → 10,828 (+3,584) | 48,576 → 53,044 (+4,468) | +9.2% |
| metro_m7_1011/msc_file_explorer | 36,460 → 37,344 (+884) | — | — | 15,712 → 19,808 (+4,096) | 54,412 → 59,392 (+4,980) | +9.2% |
| double_m33_express/msc_file_explorer | 36,632 → 37,516 (+884) | — | — | 9,888 → 13,472 (+3,584) | 49,784 → 54,252 (+4,468) | +9.0% |
| stlinkv3mini/msc_file_explorer | 37,008 → 37,620 (+612) | 3,040 → 3,312 (+272) | — | 7,240 → 10,824 (+3,584) | 49,816 → 54,284 (+4,468) | +9.0% |
| portenta_c33/msc_file_explorer | 34,505 → 35,389 (+884) | — | — | 7,060 → 10,644 (+3,584) | 49,973 → 54,441 (+4,468) | +8.9% |
There was a problem hiding this comment.
Pull request overview
This PR refactors the RP2040 USB portable layer to make endpoint transfers operate on explicit DPRAM register pointers (EP/BUF ctrl), and reworks the host HCD to manage a pool of endpoint state structures while continuing to use the shared EPX hardware for non-interrupt transfers.
Changes:
- Updates
hw_endpoint_*APIs to take explicitep_reg/buf_regpointers, and renames/clarifies endpoint fields (max_packet_size,dpram_buf,pending). - Refactors RP2040 host HCD endpoint allocation/tracking (interrupt endpoints + shared EPX) and adjusts IRQ buffer-status handling accordingly.
- Moves device-mode DPRAM register helper inlines out of the shared header and into
dcd_rp2040.c.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/portable/raspberrypi/rp2040/rp2040_usb.h | Updates endpoint struct fields and changes hw endpoint transfer API signatures to pass explicit regs. |
| src/portable/raspberrypi/rp2040/rp2040_usb.c | Implements the new reg-parameterized endpoint/buffer helpers and updates buffer prep/sync logic to use renamed fields. |
| src/portable/raspberrypi/rp2040/hcd_rp2040.c | Reworks host endpoint allocation/state and IRQ buffer-status routing for EPX + interrupt endpoints. |
| src/portable/raspberrypi/rp2040/dcd_rp2040.c | Adds device-mode helper inlines for DPRAM register selection and updates calls to new hw endpoint APIs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
…ng, adjust CLI configuration and HIL tests
…300 us to prevent xfer is ack while stopping.
…lows us to sync/move half data payload instead of waiting for pair complete. Refactor endpoint control and buffer handling functions for clarity and efficiency.
…ulk rx/tx ping-pong double buffered all working well
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ab63ef436d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Wow. Wow. Wow. This is 10X faster on MSC-BOT!
I used AI to apply many fixes to support my enhanced MSC driver. Here's what I'm overriding: |
Thanks for testing, would you mind making a pr, that would be easier to review |
hathach
left a comment
There was a problem hiding this comment.
hil failed on imxrt and stm32f7 due to updated host cdc (more stress). It is not caused by this PR. probably an bug on those ports. We will fix it later.
Summary
Major rework for rp2 hcd (mostly) driver. Implement ping-pong double-buffered USB transfers for both device and host mode on RP2040/RP2350, with round-robin EPX scheduling for host. This significantly improves throughput.
device read/write ~ 620.1 kB/s, host read/write ~1100 kB/s
Key Changes
Ping-pong double-buffered transfers (rp2040_usb.c, rp2040_usb.h)
Host double-buffered EPX (hcd_rp2040.c)
EPX round-robin scheduling (hcd_rp2040.c)
Instead:
a. First SOF with pending EP: set epx_switch_request flag
b. Any packet completion: clear flag ? data is flowing, switch happens naturally at transfer completion via xfer_complete_isr
c. Second SOF with flag still set: endpoint is NAK-retrying, STOP_TRANS is safe ? save context and switch
EPX context save/restore for preemption (hcd_rp2040.c: epx_save_context)
Critical section for EPX access (hcd_rp2040.c, rp2040_usb.h)
Common refactoring (rp2040_usb.c, rp2040_usb.h)