Skip to main content
Pavel A.
November 27, 2017
Solved

How to connect several USB devices to STM32 as host?

  • November 27, 2017
  • 9 replies
  • 4863 views
Posted on November 27, 2017 at 18:18

I have a design with a STM32F446ZC acting as USB host only, and need to attach at least two low speed HID devices (kbd, mouse). 

On the schema, one HID device is connected to PA9, 11, 12. The Cube agrees to this.

Another device is wired to B13,14,15. Cube says these pins work in High Speed mode. 

Will a low or full speed device work with STM32 in HS host mode?  If the controller is set into HS mode, will it support two low/full speed devices?

What if I'll need three devices, or a hub - is this supported?

Thanks in advance,

-- pa

#stm32f446 #usb-fs #usb-hid #usb-host
This topic has been closed for replies.
Best answer by waclawek.jan
Posted on November 29, 2017 at 23:14

There are two OTG modules in the mid-to-high-end 'F4s, one is called OTG_HS other OTG_FS. OTG implies that they can act as Device or as Host (and there are mechanisms to switch between these 'on the go' - that's why OTG; but software can simply set a fixed Device or a fixed Host). Think of two USB adapter cards in your PC, one outside-facing USB connector each. Both have a FS PHY integrated on-chip, connected to the physical pins (those are those pin sets in AF tables, mainly DP/DM - those are equivalent of those outside-facing USB connectors). if you want High-Speed USB, you need connect an external HS-PHY chip to the OTG_HS (that's why it has much more pins in the AF table); thus you can have only one HS, the OTG_FS module is not HS capable.

When sticking only to the on-chip PHY, you can thus have two FS hosts, they both can connect to one FS or LS device. From the basic architecture of USB it follows that you cannot connect more than one device to one host; you need to insert a hub to be able to branch. The host firmware has to support the hub.

The last time I checked there was no Host firmware in CubeF4; there's an older firmware including Host, with MSC and HID classes implemented, based on SPL. AFAIK, there was no public hub-supporting host firmware. The OTG modules are IPs from Synopsys, so in theory firmware from other Synopsys-based USB implementations should be portable (e.g. the SoC on the RPi contain such); but it's far, far from being trivial.

JW

9 replies

Pavel A.
Pavel A.Author
November 28, 2017
Posted on November 28, 2017 at 17:24

Hmm, this is a hard question!  Or maybe too stupid?

:(

Let's put it simpler:

1. Two low-speed USB devices (kbd, mouse) connected to STM32F446: possible or not?

2. USB hub (low speed) 

connected to STM32F446: possible or not?

The question is not about drivers, 'middlewares' and so on - just about hardware capabilities of F446.

Thanks....

-- pa

Tesla DeLorean
Guru
November 28, 2017
Posted on November 28, 2017 at 17:37

Or there's not many USB experts with 5 mins to spare on the forum?

The STM32 USB implementation is rather limited in capabilities, inflexible, supports few/fixed end-points.

Might need a hub, likely want a better controller with a deeper stack implementation. Stuff I'm not keen to own, usually look to embedded Linux with inherent support on board.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Fahad Siddiqui
Associate
April 20, 2018
Posted on April 20, 2018 at 06:34

Hi

pavel_a

,

There's an open source project available of USB HUB for Stm32F4 discovery kit.

https://github.com/mori-br/STM32F4HUB

Check it out.

Pavel A.
Pavel A.Author
April 20, 2018
Posted on April 20, 2018 at 18:08

Thank you, Fahad.