Skip to content

arch/arm/src/stm32h5: Add support for USB host#18748

Merged
xiaoxiang781216 merged 2 commits intoapache:masterfrom
dlizewski:feature/dl.stm32h5_justHost
Apr 17, 2026
Merged

arch/arm/src/stm32h5: Add support for USB host#18748
xiaoxiang781216 merged 2 commits intoapache:masterfrom
dlizewski:feature/dl.stm32h5_justHost

Conversation

@dlizewski
Copy link
Copy Markdown

Added stm32_usbdrdhost.c which adds USB FS host mode support using the embedded PHY. Added Kconfig to select Device or Host.

Example config nucleo-h563zi:usbmsc added to test functionality

Note: Please adhere to Contributing Guidelines.

Summary

  • Adds STM32H5 drivers for USB host mode. The USB host peripheral is different to any existing supported host mode drivers in Nuttx. I believe a few other new STM32 chips use this architecture so it could be applied to a few other chips, but I dont have those to test.

Impact

  • Only adds support for new functionality. No impact on any existing users. Users may now use USB host mode.

Testing

I have provided a test config nucleo-h563zi:usbmsc which enables the USB host with the mass storage class.
The attached logs shows a Nucleo-h563zi with a USB thumb drive connected and full USB_INFO prints.

In the logs I loaded NSH, mounted the drive, and printed a file. Commands run:

mount -t vfat /dev/sda /mnt/flash
ls /mnt/flash
cat /mnt/flash/TEST_F~1.TXT

The example correctly prints the contents of the file.
stm32h5_usblogs.txt

I have also tested on a custom board connected to a USB CDC-ECM device.
I am splitting the USB CDC-ECM to another ticket.

@github-actions github-actions Bot added Arch: arm Issues related to ARM (32-bit) architecture Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. Board: arm labels Apr 16, 2026
@dlizewski dlizewski force-pushed the feature/dl.stm32h5_justHost branch from 81aa990 to 22199fe Compare April 16, 2026 14:56
@simbit18
Copy link
Copy Markdown
Contributor

Hi @dlizewski, please align the CMake with the Make file.

if(CONFIG_STM32H5_USBFS_HOST)
  list(APPEND SRCS stm32_usbdrdhost.c)
endif()

https://github.com/dlizewski/nuttx/blob/22199fe42257d5fce71ce4b48fa337a9e90bd082/arch/arm/src/stm32h5/CMakeLists.txt#L98

@dlizewski
Copy link
Copy Markdown
Author

Updated to include missing Cmake

Comment thread arch/arm/src/stm32h5/Kconfig Outdated
Comment thread arch/arm/src/stm32h5/Kconfig Outdated
Copy link
Copy Markdown
Contributor

@acassis acassis left a comment

Choose a reason for hiding this comment

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

@dlizewski Amazing work! Kudos!!! Please update the Documentation to include info about USBHost support: https://nuttx.apache.org/docs/latest/platforms/arm/stm32u5/index.html

Suggestion: please copy the Peripheral Support table from https://nuttx.apache.org/docs/latest/platforms/arm/stm32f7/index.html to use as reference

Added stm32_usbdrdhost.c which adds USB FS host mode support using the
embedded PHY. Added Kconfig to select Device or Host.

Example config nucleo-h563zi:usbmsc added to test functionality

Signed-off-by: daniellizewski <daniellizewski@geotab.com>
@dlizewski dlizewski force-pushed the feature/dl.stm32h5_justHost branch from 627f18f to 9aac578 Compare April 16, 2026 18:30
@github-actions github-actions Bot added the Area: Documentation Improvements or additions to documentation label Apr 16, 2026
Added missing #ifdef to avoid compiler warning when DMA is not used.

Signed-off-by: daniellizewski <daniellizewski@geotab.com>
@dlizewski dlizewski force-pushed the feature/dl.stm32h5_justHost branch from 9aac578 to b394769 Compare April 16, 2026 18:34
@dlizewski
Copy link
Copy Markdown
Author

@acassis updated to include doc. I updated the peripheral table and added a small section on the prerequisites of using USB HOST.

I also added another commit adding an ifdef around "stm32serial_dmarxcallback" in stm32_serial.c
Without it my build was failing because of a warning that stm32serial_dmarxcallback is defined but not used.

@xiaoxiang781216 xiaoxiang781216 merged commit c205505 into apache:master Apr 17, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Area: Documentation Improvements or additions to documentation Board: arm Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants