Skip to content

refactor fsdev#3555

Merged
hathach merged 5 commits intomasterfrom
refactor-fsdev
Mar 17, 2026
Merged

refactor fsdev#3555
hathach merged 5 commits intomasterfrom
refactor-fsdev

Conversation

@hathach
Copy link
Copy Markdown
Owner

@hathach hathach commented Mar 16, 2026

No description provided.

hathach added 2 commits March 16, 2026 15:15
…microcontrollers. Replace vendor-specific macros with unified `U_`-prefixed equivalents, ensuring consistency and reducing duplication across all platforms.
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: 9b2f6f4f0c

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

Comment on lines +91 to +93
#ifdef FSDEV_BUS_32BIT
#define U_EPREG_MASK U_EPREG_MASK_32
#else
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Select endpoint register mask after bus width is known

U_EPREG_MASK is chosen via #ifdef FSDEV_BUS_32BIT here before the vendor headers are included, but FSDEV_BUS_32BIT is defined later (in fsdev_stm32.h and the PMA-size block), so this path resolves to the 16-bit mask. On DRD MCUs (e.g. C0/G0/H5/U0/U3/U5), host paths such as channel_xfer_start() then mask channel registers with U_EPREG_MASK, which drops upper CHEP fields like device address/LSEP/error bits and breaks host transfers once the device address is non-zero.

Useful? React with 👍 / 👎.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 16, 2026

TinyUSB Average Code Size Metrics

File .text .rodata .data .bss size %
cdc_host.c 6617 487 15 1498 8327 5.0%
ehci.c 2763 0 0 6043 7597 4.6%
ncm_device.c 1538 28 718 5843 7395 4.4%
usbh.c 4649 55 99 961 5731 3.4%
hcd_dwc2.c 4994 33 1 513 5540 3.3%
midi_host.c 1358 7 7 3635 4996 3.0%
video_device.c 4443 5 1235 479 4914 2.9%
audio_device.c 2896 0 1260 1623 4514 2.7%
dcd_dwc2.c 4176 25 0 265 4465 2.7%
ohci.c 1940 0 0 2414 4353 2.6%
dcd_ch32_usbfs.c 1473 0 0 2444 3917 2.3%
ecm_rndis_device.c 1037 0 1 2858 3896 2.3%
hcd_stm32_fsdev.c 3287 0 1 420 3708 2.2%
usbd.c 3225 57 88 275 3565 2.1%
dcd_ft9xx.c 3276 0 0 172 3448 2.1%
dcd_khci.c 1953 0 0 1290 3243 1.9%
hcd_musb.c 3073 0 0 157 3230 1.9%
dcd_ci_fs.c 1925 0 0 1290 3215 1.9%
dcd_da146xx.c 3067 0 0 144 3211 1.9%
dcd_nrf5x.c 2918 0 0 292 3210 1.9%
hcd_rusb2.c 2923 0 0 245 3168 1.9%
dcd_rusb2.c 2919 0 0 156 3075 1.8%
msc_device.c 2525 108 2286 547 3071 1.8%
hcd_ch32_usbfs.c 2484 0 0 498 2982 1.8%
hcd_khci.c 2442 0 0 449 2891 1.7%
dcd_stm32_fsdev.c 2558 0 0 291 2849 1.7%
dcd_mm32f327x_otg.c 1478 0 0 1290 2768 1.7%
dcd_musb.c 2445 0 0 160 2605 1.6%
usbtmc_device.c 2196 24 68 316 2544 1.5%
hcd_samd.c 2220 0 0 324 2544 1.5%
dcd_ci_hs.c 1759 0 0 1344 2538 1.5%
dcd_eptri.c 2271 0 0 259 2530 1.5%
hid_host.c 1206 0 0 1251 2457 1.5%
mtp_device.c 1696 22 735 588 2292 1.4%
dcd_rp2040.c 858 20 604 655 2137 1.3%
msc_host.c 1587 0 0 394 1982 1.2%
dcd_msp430x5xx.c 1798 0 0 176 1974 1.2%
cdc_device.c 1252 16 1106 682 1932 1.2%
dcd_ch32_usbhs.c 1469 0 0 448 1917 1.1%
hcd_rp2040.c 976 73 416 384 1849 1.1%
dcd_lpc17_40.c 1474 0 0 648 1798 1.1%
midi_device.c 1150 0 1007 621 1770 1.1%
dcd_nuc505.c 0 0 1531 157 1688 1.0%
dcd_lpc_ip3511.c 1463 0 0 264 1683 1.0%
hub.c 1384 8 8 30 1418 0.8%
printer_device.c 830 0 706 564 1392 0.8%
dcd_samg.c 1320 0 0 72 1392 0.8%
dcd_samd.c 1034 0 0 266 1300 0.8%
dcd_nuc121.c 1168 0 0 101 1269 0.8%
hid_device.c 1125 44 997 119 1244 0.7%
vendor_device.c 641 0 534 563 1202 0.7%
dcd_nuc120.c 1094 0 0 78 1172 0.7%
rp2040_usb.c 172 75 717 4 968 0.6%
dfu_device.c 777 28 712 140 916 0.5%
typec_stm32.c 820 8 2 12 842 0.5%
tusb_fifo.c 842 0 480 0 837 0.5%
dwc2_common.c 602 30 0 0 618 0.4%
usbd_control.c 538 0 484 79 616 0.4%
usbc.c 420 2 20 166 608 0.4%
hcd_pio_usb.c 262 0 240 0 502 0.3%
tusb.c 451 0 383 3 453 0.3%
hcd_ci_hs.c 184 0 0 0 184 0.1%
fsdev_common.c 180 0 0 0 180 0.1%
rusb2_common.c 160 0 16 0 176 0.1%
dfu_rt_device.c 157 0 134 0 157 0.1%
TOTAL 117918 1155 16611 46960 166965 100.0%
Input files
  • cmake-build/cmake-build-adafruit_clue/metrics.json
  • cmake-build/cmake-build-apard32690/metrics.json
  • cmake-build/cmake-build-at32f403a_weact_blackpill/metrics.json
  • cmake-build/cmake-build-at_start_f402/metrics.json
  • cmake-build/cmake-build-at_start_f413/metrics.json
  • cmake-build/cmake-build-at_start_f415/metrics.json
  • cmake-build/cmake-build-at_start_f423/metrics.json
  • cmake-build/cmake-build-at_start_f425/metrics.json
  • cmake-build/cmake-build-at_start_f435/metrics.json
  • cmake-build/cmake-build-at_start_f455/metrics.json
  • cmake-build/cmake-build-b_g474e_dpow1/metrics.json
  • cmake-build/cmake-build-b_u585i_iot2a/metrics.json
  • cmake-build/cmake-build-ch32f205r-r0/metrics.json
  • cmake-build/cmake-build-ch32v103r_r1_1v0/metrics.json
  • cmake-build/cmake-build-ch32v203c_r0_1v0/metrics.json
  • cmake-build/cmake-build-ch32v307v_r1_1v0/metrics.json
  • cmake-build/cmake-build-cynthion_d11/metrics.json
  • cmake-build/cmake-build-da14695_dk_usb/metrics.json
  • cmake-build/cmake-build-double_m33_express/metrics.json
  • cmake-build/cmake-build-ea4088_quickstart/metrics.json
  • cmake-build/cmake-build-ea4357/metrics.json
  • cmake-build/cmake-build-ek_tm4c123gxl/metrics.json
  • cmake-build/cmake-build-feather_stm32f405/metrics.json
  • cmake-build/cmake-build-fomu/metrics.json
  • cmake-build/cmake-build-frdm_k32l2a4s/metrics.json
  • cmake-build/cmake-build-frdm_k64f/metrics.json
  • cmake-build/cmake-build-frdm_kl25z/metrics.json
  • cmake-build/cmake-build-frdm_mcxa153/metrics.json
  • cmake-build/cmake-build-frdm_rw612/metrics.json
  • cmake-build/cmake-build-hpm6750evk2/metrics.json
  • cmake-build/cmake-build-lpcxpresso11u37/metrics.json
  • cmake-build/cmake-build-lpcxpresso1347/metrics.json
  • cmake-build/cmake-build-lpcxpresso1549/metrics.json
  • cmake-build/cmake-build-lpcxpresso1769/metrics.json
  • cmake-build/cmake-build-lpcxpresso18s37/metrics.json
  • cmake-build/cmake-build-lpcxpresso51u68/metrics.json
  • cmake-build/cmake-build-lpcxpresso54114/metrics.json
  • cmake-build/cmake-build-metro_m0_express/metrics.json
  • cmake-build/cmake-build-metro_m4_express/metrics.json
  • cmake-build/cmake-build-metro_m7_1011/metrics.json
  • cmake-build/cmake-build-mm32f327x_mb39/metrics.json
  • cmake-build/cmake-build-mm900evxb/metrics.json
  • cmake-build/cmake-build-msp_exp430f5529lp/metrics.json
  • cmake-build/cmake-build-msp_exp432e401y/metrics.json
  • cmake-build/cmake-build-nutiny_nuc126v/metrics.json
  • cmake-build/cmake-build-nutiny_sdk_nuc120/metrics.json
  • cmake-build/cmake-build-nutiny_sdk_nuc121/metrics.json
  • cmake-build/cmake-build-nutiny_sdk_nuc505/metrics.json
  • cmake-build/cmake-build-portenta_c33/metrics.json
  • cmake-build/cmake-build-raspberry_pi_pico/metrics.json
  • cmake-build/cmake-build-raspberrypi_cm4/metrics.json
  • cmake-build/cmake-build-raspberrypi_zero/metrics.json
  • cmake-build/cmake-build-samg55_xplained/metrics.json
  • cmake-build/cmake-build-sipeed_longan_nano/metrics.json
  • cmake-build/cmake-build-stlinkv3mini/metrics.json
  • cmake-build/cmake-build-stm32c071nucleo/metrics.json
  • cmake-build/cmake-build-stm32f070rbnucleo/metrics.json
  • cmake-build/cmake-build-stm32f103_bluepill/metrics.json
  • cmake-build/cmake-build-stm32f207nucleo/metrics.json
  • cmake-build/cmake-build-stm32f303disco/metrics.json
  • cmake-build/cmake-build-stm32g0b1nucleo/metrics.json
  • cmake-build/cmake-build-stm32h503nucleo/metrics.json
  • cmake-build/cmake-build-stm32h743eval/metrics.json
  • cmake-build/cmake-build-stm32h7s3nucleo/metrics.json
  • cmake-build/cmake-build-stm32l052dap52/metrics.json
  • cmake-build/cmake-build-stm32l412nucleo/metrics.json
  • cmake-build/cmake-build-stm32n6570dk/metrics.json
  • cmake-build/cmake-build-stm32u083cdk/metrics.json
  • cmake-build/cmake-build-stm32wb55nucleo/metrics.json
  • cmake-build/cmake-build-stm32wba_nucleo/metrics.json
  • cmake-build/cmake-build-xmc4500_relax/metrics.json

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 16, 2026

MemBrowse Memory Report

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

target .text .rodata .data .bss total % diff
stm32f303disco/hid_composite_freertos 19,080 → 19,096 (+16) 19,960 → 19,976 (+16) +0.1%
at32f403a_weact_blackpill/hid_composite_freertos 20,236 → 20,252 (+16) 21,144 → 21,160 (+16) +0.1%
at_start_f413/audio_test_freertos 21,468 → 21,452 (-16) 22,212 → 22,196 (-16) -0.1%
at32f403a_weact_blackpill/audio_test_freertos 21,468 → 21,452 (-16) 22,232 → 22,216 (-16) -0.1%
stm32l412nucleo/hid_composite_freertos 21,344 → 21,360 (+16) 22,256 → 22,272 (+16) +0.1%
stm32u083cdk/audio_test_freertos 22,956 → 22,940 (-16) 23,544 → 23,528 (-16) -0.1%
stm32f303disco/cdc_msc_freertos 23,104 → 23,120 (+16) 23,900 → 23,916 (+16) +0.1%
stm32u083cdk/cdc_msc_freertos 25,640 → 25,624 (-16) 26,284 → 26,268 (-16) -0.1%
stm32f303disco/hid_generic_inout 12,520 → 12,528 (+8) 13,160 → 13,168 (+8) +0.1%
stm32wb55nucleo/cdc_msc_freertos 26,152 → 26,168 (+16) 27,044 → 27,060 (+16) +0.1%

hathach and others added 2 commits March 16, 2026 22:30
The board.cmake, board.mk, and board.h were created but not
included in the previous commit, causing CI cmake failure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…eplace `FSDEV_BUS_32BIT` with `CFG_TUSB_FSDEV_32BIT`, adjust data/address stride macros, and refactor register/PMU access for consistency across platforms.
Copilot AI review requested due to automatic review settings March 16, 2026 15:33
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 refactors the STM32 FSDEV USB driver to use vendor-independent register bit definitions with a U_ prefix, replacing the previously duplicated and inconsistent USB_* defines that varied across STM32, CH32, and AT32 vendor headers. It also adds BSP support for the STM32U083 Nucleo board.

Changes:

  • Introduced unified U_ prefixed register bit definitions in fsdev_common.h and removed duplicated USB_* defines from fsdev_stm32.h, fsdev_ch32.h, and fsdev_at32.h
  • Replaced FSDEV_BUS_32BIT with CFG_TUSB_FSDEV_32BIT (defined in tusb_option.h) and reorganized struct/typedef ordering in fsdev_common.h
  • Added STM32U083 Nucleo board BSP (board.h, board.mk, board.cmake, linker scripts, CubeMX config) and consolidated U0 family linker/clock configuration

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/portable/st/stm32_fsdev/fsdev_common.h New U_ prefix register definitions, reordered typedefs and vendor includes
src/portable/st/stm32_fsdev/fsdev_stm32.h Removed USB_* alias macros for DRD MCUs, updated connect/disconnect to use FSDEV_REG and U_ defines
src/portable/st/stm32_fsdev/fsdev_ch32.h Removed duplicated USB_* register bit definitions
src/portable/st/stm32_fsdev/fsdev_at32.h Removed duplicated USB_* register bit definitions
src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c Migrated all USB_* references to U_* equivalents
src/portable/st/stm32_fsdev/hcd_stm32_fsdev.c Migrated all USB_* references to U_* equivalents
src/portable/st/stm32_fsdev/fsdev_common.c Migrated USB_* to U_*, FSDEV_BUS_32BIT to CFG_TUSB_FSDEV_32BIT
src/tusb_option.h Added CFG_TUSB_FSDEV_32BIT define and access scheme comments
hw/bsp/stm32u0/boards/stm32u083nucleo/* New Nucleo-U083RC board support
hw/bsp/stm32u0/boards/stm32u083cdk/* Clock config fixes, removed board-specific linker paths
hw/bsp/stm32u0/family.* Generalized linker file resolution, renamed clock init function
test/hil/tinyusb.json Added USB SRAM comments for test boards
hw/bsp/stm32u0/linker/* New/updated linker scripts for STM32U083xx

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

@hathach hathach merged commit 608bbdd into master Mar 17, 2026
310 checks passed
@hathach hathach deleted the refactor-fsdev branch March 17, 2026 02:48
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