Showing results for 
Search instead for 
Did you mean: 

usb otg dual role selection from cube mx

Hardik P


I am using STM32L4 series controller. I want to use USB OTG in dual mode where I want to run USB device and Host on same application. facing an issue when I select USB_OTG_FS as OTG/Dual_Role_device using cubemx tool then in middleware USB_HOST and USB_DEVICE options become disable. if I am choosing USB_OTG_FS as host only selection then it works (enable USB_HOST in middleware selection) and same working for device only selection. I have attached snapshot as reference.

Even I have check with F4 series, still not working.

In case CubeIDE does not support to generate usb dual mode middleware then could you provide any alternatives way where I can integrate at my end. 

Senior III

Sorry to see that you're another ST client waiting for support on USB problems, there are others still waiting since 2014, so unless people start to make a very large noise, ST will continue to ignore the fact that their USB support is extremely basic and next to useless for any serious projects.
Several of us are pushing ST to get their USB driver completed, but ST are trying to support only USB fully on AzRTOS, a Microsoft software, which many of us do not want to use.

Principal III

since 10 years (i use this products) i havent seen a working OTG from STM. 

only one way is working (and i use): having device booloader at startup (boot0 hi) , 

and in running software (only) host mode (cdc or msc i did) . 

but not in software switching from one to another mode, what OTG could/should do. 

ask STM about the eyewash in promotion, having OTG USB here - but to use it, write your own software - is the real thing.


If you feel a post has answered your question, please click "Accept as Solution".

We have USB working on the F407, also with the ability to switch to host mode for an HID keyboard or mouse, but ST seem to have gotten into a mess with USB in the current IDE and MX, they are working on it, but only have one guy on the code work so it may take a while.