Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds USB Host Controller Driver (HCD) support for STM32 FSDEV peripheral, enabling host mode functionality on STM32 C0, G0, H5, and U5 MCU families. The implementation refactors common code from the existing device controller driver (DCD) into shared files to support both device and host modes.
Key changes:
- Implements a new HCD driver with static buffer allocation (64 bytes per channel), dynamic channel allocation, and NAK retry mechanism
- Refactors packet memory access and buffer table functions into
fsdev_common.c/hfor reuse between DCD and HCD - Updates all STM32 BSP build files to include the new common source file
Reviewed changes
Copilot reviewed 52 out of 52 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/portable/st/stm32_fsdev/hcd_stm32_fsdev.c | New HCD driver implementation for STM32 FSDEV peripheral |
| src/portable/st/stm32_fsdev/fsdev_common.c | Extracted common PMA access and buffer table functions |
| src/portable/st/stm32_fsdev/fsdev_common.h | Common header with helper functions for both DCD and HCD |
| src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c | Updated to use refactored common functions |
| src/portable/st/stm32_fsdev/fsdev_stm32.h | Converted DCD-specific functions to generic inline helpers |
| src/portable/st/stm32_fsdev/fsdev_ch32.h | Updated function names and added volatile qualifiers |
| src/portable/st/stm32_fsdev/fsdev_at32.h | Updated function names and improved volatile pointer usage |
| hw/bsp/stm32c0/family.c | Updated interrupt handler to support both device and host modes |
| hw/bsp/stm32c0/boards/stm32c071nucleo/board.h | Changed clock source from HSI48 to external HSE |
| hw/bsp/stm32*/family.mk, family.cmake | Added fsdev_common.c and hcd_stm32_fsdev.c to build |
| tools/iar_template.ipcf | Added new HCD and common files to IAR template |
| examples/host/*/only.txt | Enabled host examples for STM32C0 |
| README.rst | Updated support matrix to indicate host mode support on C0, G0, H5 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
26f130e to
5963b1d
Compare
|
brilliant as usual, unfortunately, I got an sore throat and running nose. I will test this out later on when getting better. |
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: Zixun LI <admin@hifiphile.com>
Signed-off-by: Zixun LI <admin@hifiphile.com>
Signed-off-by: Zixun LI <admin@hifiphile.com>
Signed-off-by: Zixun LI <admin@hifiphile.com>
Signed-off-by: Zixun LI <admin@hifiphile.com>
Signed-off-by: Zixun LI <admin@hifiphile.com>
Signed-off-by: Zixun LI <admin@hifiphile.com>
Signed-off-by: Zixun LI <admin@hifiphile.com>
Signed-off-by: Zixun LI <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
31a987f to
cbab765
Compare
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
|
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
|
hathach
left a comment
There was a problem hiding this comment.
tested on my h563 nucleo and it works perfectly. Thank you very much for this brilliant work



Describe the PR
Add stm32_fsdev HCD mode support, host mode works pretty like device mode with 8 bidirectional channels.
Tested on Nucleo-C071RB (put on both STLINK and USB power jumper):
config_test_unit_ready_completeand hub stop workingAlso tested on STM32H573I-DK