Skip to content

rp2 disable hwfifo#3560

Merged
hathach merged 1 commit intomasterfrom
rp2-disable-hwifo
Mar 19, 2026
Merged

rp2 disable hwfifo#3560
hathach merged 1 commit intomasterfrom
rp2-disable-hwifo

Conversation

@hathach
Copy link
Copy Markdown
Owner

@hathach hathach commented Mar 18, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 18, 2026 17:03
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 868ad07127

ℹ️ 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".


#if (CFG_TUSB_MCU == OPT_MCU_RP2040) && !CFG_TUD_RPI_PIO_USB
#define CFG_TUD_EDPT_DEDICATED_HWFIFO 1
#define CFG_TUD_EDPT_DEDICATED_HWFIFO 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Disable RP2040 dcd_edpt_xfer_fifo() when hwfifo support is off

If an RP2040 build still uses the driver-level dcd_edpt_xfer_fifo() entry point (it remains exported in src/portable/raspberrypi/rp2040/dcd_rp2040.c:508-513), setting CFG_TUD_EDPT_DEDICATED_HWFIFO to 0 makes prepare_ep_buffer()/sync_ep_buffer() skip the only ep->is_xfer_fifo handling. hw_endpoint_xfer_start() stores the FIFO pointer in the user_buf/user_fifo union (rp2040_usb.h:85-88), so the fallback unaligned_memcpy() now reads from or writes into the tu_fifo_t struct itself instead of the FIFO payload. That turns any FIFO transfer into immediate memory corruption rather than a cleanly disabled feature.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR disables the RP2040 device “dedicated hardware FIFO” transfer path by default and gates RP2040-specific hwfifo helpers/logic behind the corresponding compile-time option.

Changes:

  • Set CFG_TUD_EDPT_DEDICATED_HWFIFO to 0 for RP2040 (non PIO-USB device).
  • Compile tu_hwfifo_write() / tu_hwfifo_read() only when CFG_TUD_EDPT_DEDICATED_HWFIFO is enabled.
  • Wrap FIFO-based buffer copy paths in rp2040_usb.c with #if CFG_TUD_EDPT_DEDICATED_HWFIFO.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/tusb_option.h Disables RP2040 dedicated endpoint hwfifo by default (non PIO-USB device).
src/portable/raspberrypi/rp2040/rp2040_usb.c Gates hwfifo helpers and FIFO transfer branches behind CFG_TUD_EDPT_DEDICATED_HWFIFO.

💡 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.

Comment on lines +143 to +149
#if CFG_TUD_EDPT_DEDICATED_HWFIFO
if (ep->is_xfer_fifo) {
// not in sram, may mess up timing with E15 workaround
tu_hwfifo_write_from_fifo(hw_buf, ep->user_fifo, buflen, NULL);
} else {
} else
#endif
{
Comment on lines +292 to +298
#if CFG_TUD_EDPT_DEDICATED_HWFIFO
if (ep->is_xfer_fifo) {
// not in sram, may mess up timing with E15 workaround
tu_hwfifo_read_to_fifo(hw_buf, ep->user_fifo, xferred_bytes, NULL);
} else {
} else
#endif
{
Comment on lines 56 to +66
@@ -62,6 +63,7 @@ void tu_hwfifo_read(const volatile void *hwfifo, uint8_t *dest, uint16_t len, co
(void)access_mode;
unaligned_memcpy(dest, (const uint8_t *)(uintptr_t)hwfifo, len);
}
#endif
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 18, 2026

Size Difference Report

Because 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

file .text .rodata .data .bss size % diff
dcd_rp2040.c 858 ➙ 836 (-22) 20 604 655 2137 ➙ 2115 (-22) -1.0%
rp2040_usb.c 172 ➙ 120 (-52) 75 717 ➙ 669 (-48) 4 968 ➙ 868 (-100) -10.3%
TOTAL 1030 ➙ 956 (-74) 95 1321 ➙ 1273 (-48) 659 3105 ➙ 2983 (-122) -3.9%

Changes <1% in size

file .text .rodata .data .bss size % diff
audio_device.c 2896 ➙ 2897 (+1) 0 1260 1623 ➙ 1627 (+4) 4514 ➙ 4518 (+4) +0.1%
cdc_device.c 1252 16 1106 682 ➙ 684 (+2) 1932 ➙ 1935 (+3) +0.2%
midi_device.c 1150 ➙ 1151 (+1) 0 1007 621 ➙ 623 (+2) 1770 ➙ 1772 (+2) +0.1%
printer_device.c 830 0 706 564 ➙ 566 (+2) 1392 ➙ 1394 (+2) +0.1%
tusb_fifo.c 842 ➙ 841 (-1) 0 480 0 837 ➙ 836 (-1) -0.1%
usbd.c 3225 57 88 275 3565 ➙ 3564 (-1) -0.0%
vendor_device.c 641 0 534 563 ➙ 565 (+2) 1202 ➙ 1204 (+2) +0.2%
TOTAL 10836 ➙ 10837 (+1) 73 5181 4328 ➙ 4340 (+12) 15212 ➙ 15223 (+11) +0.1%
No changes
file .text .rodata .data .bss size % diff
cdc_host.c 6617 487 15 1498 8327 +0.0%
dcd_ch32_usbfs.c 1473 0 0 2444 3917 +0.0%
dcd_ch32_usbhs.c 1469 0 0 448 1917 +0.0%
dcd_ci_fs.c 1925 0 0 1290 3215 +0.0%
dcd_ci_hs.c 1759 0 0 1344 2538 +0.0%
dcd_da146xx.c 3067 0 0 144 3211 +0.0%
dcd_dwc2.c 4176 25 0 265 4465 +0.0%
dcd_eptri.c 2271 0 0 259 2530 +0.0%
dcd_ft9xx.c 3276 0 0 172 3448 +0.0%
dcd_khci.c 1953 0 0 1290 3243 +0.0%
dcd_lpc17_40.c 1474 0 0 648 1798 +0.0%
dcd_lpc_ip3511.c 1463 0 0 264 1683 +0.0%
dcd_mm32f327x_otg.c 1478 0 0 1290 2768 +0.0%
dcd_msp430x5xx.c 1798 0 0 176 1974 +0.0%
dcd_musb.c 2445 0 0 160 2605 +0.0%
dcd_nrf5x.c 2918 0 0 292 3210 +0.0%
dcd_nuc120.c 1094 0 0 78 1172 +0.0%
dcd_nuc121.c 1168 0 0 101 1269 +0.0%
dcd_nuc505.c 0 0 1531 157 1688 +0.0%
dcd_rusb2.c 2919 0 0 156 3075 +0.0%
dcd_samd.c 1034 0 0 266 1300 +0.0%
dcd_samg.c 1320 0 0 72 1392 +0.0%
dcd_stm32_fsdev.c 2558 0 0 291 2849 +0.0%
dfu_device.c 777 28 712 140 916 +0.0%
dfu_rt_device.c 157 0 134 0 157 +0.0%
dwc2_common.c 602 30 0 0 618 +0.0%
ecm_rndis_device.c 1037 0 1 2858 3896 +0.0%
ehci.c 2763 0 0 6043 7597 +0.0%
fsdev_common.c 180 0 0 0 180 +0.0%
hcd_ch32_usbfs.c 2484 0 0 498 2982 +0.0%
hcd_ci_hs.c 184 0 0 0 184 +0.0%
hcd_dwc2.c 4994 33 1 513 5540 +0.0%
hcd_khci.c 2442 0 0 449 2891 +0.0%
hcd_musb.c 3073 0 0 157 3230 +0.0%
hcd_pio_usb.c 262 0 240 0 502 +0.0%
hcd_rp2040.c 976 73 416 384 1849 +0.0%
hcd_rusb2.c 2923 0 0 245 3168 +0.0%
hcd_samd.c 2220 0 0 324 2544 +0.0%
hcd_stm32_fsdev.c 3287 0 1 420 3708 +0.0%
hid_device.c 1125 44 997 119 1244 +0.0%
hid_host.c 1240 0 0 1251 2491 +0.0%
hub.c 1384 8 8 30 1418 +0.0%
midi_host.c 1341 7 7 3635 4979 +0.0%
msc_device.c 2525 108 2286 547 3071 +0.0%
msc_host.c 1587 0 0 394 1982 +0.0%
mtp_device.c 1696 22 735 588 2292 +0.0%
ncm_device.c 1538 28 718 5843 7395 +0.0%
ohci.c 1940 0 0 2414 4353 +0.0%
rusb2_common.c 160 0 16 0 176 +0.0%
tusb.c 451 0 383 3 453 +0.0%
typec_stm32.c 820 8 2 12 842 +0.0%
usbc.c 420 2 20 166 608 +0.0%
usbd_control.c 538 0 484 79 616 +0.0%
usbh.c 4649 55 99 961 5731 +0.0%
usbtmc_device.c 2196 24 68 316 2544 +0.0%
video_device.c 4443 5 1235 479 4914 +0.0%
TOTAL 106069 987 10109 41973 148665 +0.0%

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 18, 2026

MemBrowse Memory Report

Top 10 targets by memory change (%) (out of 2156 targets) View Project Dashboard →

target .text .rodata .data .bss total % diff
raspberry_pi_pico/dfu_runtime 13,584 → 13,456 (-128) 2,920 → 2,840 (-80) 22,572 → 22,364 (-208) -0.9%
raspberry_pi_pico/audio_test 16,760 → 16,496 (-264) 2,936 → 2,856 (-80) 3,404 → 3,508 (+104) 26,224 → 25,984 (-240) -0.9%
raspberry_pi_pico/hid_generic_inout 14,440 → 14,312 (-128) 2,936 → 2,856 (-80) 23,484 → 23,276 (-208) -0.9%
raspberry_pi_pico/dfu 14,320 → 14,192 (-128) 2,920 → 2,840 (-80) 23,508 → 23,300 (-208) -0.9%
raspberry_pi_pico/hid_multiple_interface 15,064 → 14,936 (-128) 3,000 → 2,920 (-80) 24,216 → 24,008 (-208) -0.9%
raspberry_pi_pico/hid_boot_interface 15,120 → 14,992 (-128) 3,000 → 2,920 (-80) 24,228 → 24,020 (-208) -0.9%
raspberry_pi_pico/hid_composite 15,176 → 15,048 (-128) 3,016 → 2,936 (-80) 24,420 → 24,212 (-208) -0.9%
raspberry_pi_pico/cdc_uac2 19,576 → 19,392 (-184) 2,952 → 2,872 (-80) 5,472 → 6,000 (+528) 31,580 → 31,844 (+264) +0.8%
raspberry_pi_pico/usbtmc 17,416 → 17,280 (-136) 3,300 → 3,220 (-80) 27,664 → 27,448 (-216) -0.8%
raspberry_pi_pico/midi_test 15,656 → 15,416 (-240) 2,920 → 2,840 (-80) 3,052 → 3,180 (+128) 24,792 → 24,600 (-192) -0.8%

@hathach hathach force-pushed the rp2-disable-hwifo branch from 868ad07 to 9b17d55 Compare March 19, 2026 02:59
@hathach hathach merged commit 8a9f44b into master Mar 19, 2026
311 checks passed
@hathach hathach deleted the rp2-disable-hwifo branch March 19, 2026 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants