Skip to content

Conversation

@hathach
Copy link
Owner

@hathach hathach commented Dec 29, 2025

  • tusb_fifo now stores raw bytes (item_size removed), with ripple updates across audio, OSAL backends, DWC2, and unit tests.
  • “Fixed address” FIFO access was rebranded to stride mode and generalized with CFG_TUSB_FIFO_HWFIFO_DATA_STRIDE + CFG_TUSB_FIFO_HWFIFO_ADDR_STRIDE;
    multiple data stride widths (16/32) are supported.
  • New HWFIFO API shape: tu_hwfifo_access_t, hwfifo-first signatures, and default access-mode helpers; added tu_hwfifo_write_from_fifo /
    tu_hwfifo_read_to_fifo.
  • FSDEV PMA packet helpers were removed in favor of the shared HWFIFO path; FSDEV PMA size/stride handling updated for 16/32-bit address increments.
  • RUSB2 HCD/DCD refactored to use the shared HWFIFO read/write path; custom write/read support added and tu_hwfifo_write() moved into rusb2_common.
  • MUSB dedicated HWFIFO enabled with odd access (8/16-bit).
  • Host stack fix: RUSB2 port connect status uses line state; added post-root-reset delay for stable speed detection.
  • DWC2 build fixes and cleanup around the new HWFIFO signatures.
  • Tests/config: unit-test YAML and test_fifo.c updated for stride/data-width changes; HIL config enabled for RA4M1.

@hathach hathach changed the title make fifo access mode fixed addr work with 16 bit also rework tusb fifo Dec 30, 2025
@github-actions
Copy link

github-actions bot commented Jan 1, 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
cdc_device.c 1333 ➙ 1331 (-2) 16 20 692 ➙ 670 (-22) 2024 ➙ 2000 (-24) -1.2%
dcd_musb.c 2228 ➙ 2079 (-149) 0 0 160 2388 ➙ 2239 (-149) -6.2%
dcd_rusb2.c 3076 ➙ 2917 (-159) 0 0 156 3232 ➙ 3073 (-159) -4.9%
dcd_stm32_fsdev.c 2494 ➙ 2556 (+62) 0 0 291 2785 ➙ 2847 (+62) +2.2%
dwc2_common.c 781 ➙ 594 (-187) 29 0 0 797 ➙ 610 (-187) -23.5%
fsdev_common.c 622 ➙ 180 (-442) 0 0 0 622 ➙ 180 (-442) -71.1%
hcd_rusb2.c 2965 ➙ 2923 (-42) 0 0 246 ➙ 245 (-1) 3211 ➙ 3168 (-43) -1.3%
midi_device.c 1130 ➙ 1129 (-1) 0 991 615 ➙ 596 (-19) 1743 ➙ 1723 (-20) -1.1%
rusb2_common.c 0 ➙ 160 (+160) 0 16 0 16 ➙ 176 (+160) +1000.0%
tusb_fifo.c 890 ➙ 844 (-46) 0 525 ➙ 477 (-48) 0 884 ➙ 839 (-45) -5.1%
usbc.c 408 ➙ 420 (+12) 2 16 ➙ 20 (+4) 166 592 ➙ 608 (+16) +2.7%
TOTAL 15927 ➙ 15133 (-794) 47 1568 ➙ 1524 (-44) 2326 ➙ 2284 (-42) 18294 ➙ 17463 (-831) -4.5%

Changes <1% in size

file .text .rodata .data .bss size % diff
audio_device.c 2860 ➙ 2855 (-5) 0 1250 ➙ 1248 (-2) 1688 ➙ 1679 (-9) 4543 ➙ 4529 (-14) -0.3%
dcd_dwc2.c 4188 ➙ 4160 (-28) 25 0 263 4474 ➙ 4447 (-27) -0.6%
hcd_dwc2.c 4880 ➙ 4893 (+13) 30 0 512 5422 ➙ 5434 (+12) +0.2%
hcd_stm32_fsdev.c 3258 ➙ 3282 (+24) 0 1 420 3679 ➙ 3703 (+24) +0.7%
tusb.c 420 ➙ 418 (-2) 0 361 ➙ 359 (-2) 3 421 ➙ 420 (-1) -0.2%
usbd.c 3155 ➙ 3179 (+24) 57 86 ➙ 90 (+4) 276 3492 ➙ 3519 (+27) +0.8%
usbh.c 4367 ➙ 4374 (+7) 60 60 ➙ 63 (+3) 954 5405 ➙ 5415 (+10) +0.2%
vendor_device.c 636 0 538 476 ➙ 470 (-6) 1111 ➙ 1105 (-6) -0.5%
TOTAL 23764 ➙ 23797 (+33) 172 2296 ➙ 2299 (+3) 4592 ➙ 4577 (-15) 28547 ➙ 28572 (+25) +0.1%
No changes
file .text .rodata .data .bss size % diff
cdc_host.c 6596 487 15 1539 8357 +0.0%
dcd_ch32_usbfs.c 1472 0 0 2444 3916 +0.0%
dcd_ch32_usbhs.c 1648 0 0 448 2096 +0.0%
dcd_ci_fs.c 1925 0 0 1290 3215 +0.0%
dcd_ci_hs.c 1762 0 0 1280 2530 +0.0%
dcd_da146xx.c 3067 0 0 144 3211 +0.0%
dcd_eptri.c 2270 0 0 259 2529 +0.0%
dcd_khci.c 1953 0 0 1290 3243 +0.0%
dcd_lpc17_40.c 1470 0 0 648 1794 +0.0%
dcd_lpc_ip3511.c 1463 0 0 264 1639 +0.0%
dcd_mm32f327x_otg.c 1478 0 0 1290 2768 +0.0%
dcd_msp430x5xx.c 1796 0 0 176 1972 +0.0%
dcd_nrf5x.c 2919 0 0 292 3211 +0.0%
dcd_nuc120.c 1093 0 0 78 1171 +0.0%
dcd_nuc121.c 1167 0 0 101 1268 +0.0%
dcd_nuc505.c 0 0 1529 157 1686 +0.0%
dcd_rp2040.c 736 20 580 1029 2365 +0.0%
dcd_samd.c 1032 0 0 266 1298 +0.0%
dcd_samg.c 1319 0 0 72 1391 +0.0%
dfu_device.c 744 28 712 184 929 +0.0%
dfu_rt_device.c 157 0 134 0 156 +0.0%
ecm_rndis_device.c 1037 0 1 2272 3310 +0.0%
ehci.c 2761 0 0 5970 7537 +0.0%
hcd_ch32_usbfs.c 2484 0 0 498 2982 +0.0%
hcd_ci_hs.c 190 0 0 0 190 +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 936 73 420 512 1941 +0.0%
hcd_samd.c 2220 0 0 324 2544 +0.0%
hid_device.c 1120 44 997 115 1235 +0.0%
hid_host.c 1206 0 0 1250 2456 +0.0%
hub.c 1235 8 8 29 1268 +0.0%
midi_host.c 1353 7 7 3740 5097 +0.0%
msc_device.c 2506 108 2274 538 3044 +0.0%
msc_host.c 1589 0 0 394 1984 +0.0%
mtp_device.c 1622 22 1385 578 2208 +0.0%
ncm_device.c 1517 28 1408 5824 7354 +0.0%
ohci.c 1942 0 0 2414 4356 +0.0%
rp2040_usb.c 124 70 574 4 772 +0.0%
typec_stm32.c 820 8 2 12 842 +0.0%
usbd_control.c 524 0 474 78 601 +0.0%
usbtmc_device.c 2178 24 70 294 2504 +0.0%
video_device.c 4402 6 1851 471 4865 +0.0%
TOTAL 73610 933 12681 39174 114458 +0.0%

rusb use custom write
enable all hil test for ra4m1
@hathach hathach changed the title rework tusb fifo HWFIFO access-mode refactor and stride-aware FIFO fixes across FSDEV/RUSB2/MUSB Jan 5, 2026
@hathach hathach marked this pull request as ready for review January 5, 2026 17:45
Copilot AI review requested due to automatic review settings January 5, 2026 17:45
Copy link
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 refactors the HWFIFO access layer across multiple USB controllers (FSDEV, RUSB2, MUSB, DWC2) by removing the item_size concept from tu_fifo and moving to raw byte storage. The key changes include:

  • Replaced fixed-address FIFO access enum with stride-aware access mode supporting configurable data and address strides
  • Updated HWFIFO API with new tu_hwfifo_access_t structure and dedicated helper functions
  • Removed FSDEV PMA packet helpers in favor of shared HWFIFO path
  • Refactored RUSB2 and MUSB to use shared HWFIFO read/write functions
  • Updated OSAL backends to track item_size separately from FIFO
  • Added ENUM_RESET_ROOT_POST_DELAY_MS for stable speed detection in host stack

Reviewed changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
test/unit-test/test/test_fifo.c Removed test_item_size test, updated TU_FIFO_INIT calls, added 16-bit stride tests
test/unit-test/project.yml Updated test defines for new HWFIFO configuration
test/unit-test/CMakeLists.txt Removed CFG_TUSB_FIFO_ACCESS_FIXED_ADDR_RW32 define
test/hil/tinyusb.json Enabled RA4M1 device tests (removed skip list)
src/tusb_option.h Added stride configuration for DWC2, FSDEV, MUSB, RUSB2
src/tusb.c Updated tu_fifo_config call to remove item_size parameter
src/portable/synopsys/dwc2/*.c Replaced dfifo_read/write_packet with tu_hwfifo_read/write
src/portable/st/stm32_fsdev/*.c Replaced fsdev packet memory functions with tu_hwfifo API
src/portable/st/stm32_fsdev/*.h Removed FSDEV_PMA_SIZE macros, reorganized MCU definitions
src/portable/renesas/rusb2/*.c Refactored to use shared HWFIFO, added custom write support
src/portable/mentor/musb/dcd_musb.c Replaced pipe_read/write_packet with tu_hwfifo functions
src/osal/osal_pico.h, osal_none.h Added item_size tracking for queues, updated to use tu_fifo_read/write_n
src/host/usbh.c Added post-reset delay for root port enumeration
src/common/tusb_fifo.h Removed item_size from tu_fifo_t, added tu_hwfifo_access_t
src/common/tusb_fifo.c Refactored stride-aware read/write, removed item_size logic
src/common/tusb_mcu.h Moved FSDEV_PMA_SIZE definitions to mcu.h
src/class/audio/audio_device.c Updated tu_fifo_config calls
README.rst Updated table descriptions for USB RAM terminology

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@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: 20d009daa1

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

hathach and others added 3 commits January 6, 2026 00:58
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@hathach hathach merged commit 593dce2 into master Jan 6, 2026
156 checks passed
@hathach hathach deleted the fifo-access-mode branch January 6, 2026 02:42
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