Showing results for 
Search instead for 
Did you mean: 

STM32H7 USB Dual Role: have Cube act as both host and device

Associate II


I am trying to use an H7 with USB OTG as host/device. Only 1 will be enabled at any given time. The issue is that with Cube, if I set the FS PHY to OTG/Dual_Role_Device, I get nothing but the IO set. Which is, obviously, the opposite of what I want. Ideally when I setup dual role I want dual role not 0 role. The HAL doesn't generate PCD or HCD files, instead of generating both. The NVIC tab doesn't allow me to manually enable the USB IRQ, let alone have it automatically enabled. Middleware is also completely disabled.

This is what I would like to have seen when I set the PHY for OTG:

  1. Parameter settings for Host and Device
  2. IO for host and device (meaning include the ID pin)
  3. NVIC capability
  4. USB_HOST and USB_DEVICE middlewares able to be used

As of right now it is impossible to use the functionality of the FS OTG PHY as truly OTG while also using the IOC configuration, as manually changing the HAL config gets overwritten on code generation.

Thank you

Associate II


I have the same issue on STM32U5. Is there any way to get it working? Or is writing the whole code manually the only solution?


Senior III

I´ve also been asking this questions, and all I get is useless, hopeless responses, and ST staff trying to tell me it's now obligatory to use Microsoft RTOS to get USB support, and then their only part-time (not to mention names) dev guy send me a totally incomplete sample!

Using MX to add OTG support and as mentioned, only IO headers are installed, without any code.

This makes it necessary to install USB as a device, copy the folders, then install host, copy the folders, manually add both back in, and then somehow patch up the code without any useful documentation, to support dual mode.  For a $16 billion dollar company this is a deplorable situation.

The USB support seems to have collapsed at ST.

Sorry if mentioning that I communicated with a Russian employee at ST is hate speech in your opinion.

At least I didn't mention his name!!