cancel
Showing results for 
Search instead for 
Did you mean: 

How to connect several USB devices to STM32 as host?

Pavel A.
Evangelist III
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
1 ACCEPTED SOLUTION

Accepted Solutions
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

View solution in original post

9 REPLIES 9
Pavel A.
Evangelist III
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

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
Up vote any posts that you find helpful, it shows what's working..
Posted on November 28, 2017 at 22:07

1. Actually, the embedded PHY in the F4 series is only capable of FS (and LS in host mode) communication for both OTG_FS and OTG_HS. In any case, by specification the USB HS is required to be backward compatible with the lower speed (FS/LS) devices, so unless the Ref Man or Datasheet says otherwise, you shouldn't worry.

2. I have no experience with USB host implementation myself, so I'm not aware of any limitation against connecting a USB hub to it as a host, but I wouldn't expect an out-of-the-box operation for sure...

Posted on November 29, 2017 at 18:19

Thank you for the reply.

The embedded FS PHY is enough for me.

Meanwhile I've found the USB examples doc UM1021.  It says that STM32F44x have _two_ so called 'cores', one FS and one HS. The UM1021 doc calls this 'dual core' or even 'multi core' and there's an example of simultaneous use of a storage device on HS connector, and HID device on FS connector.

It also hints that in host mode, FS core supports a 'generic root hub' (without any further explanation or example).

However, the datasheet for 

STM32F446xC/E

 does not confirm this. In its USB section, all use cases show only one connection (actually, group of pins).  Maybe using both alternate groups of pins PA9-12 and PB12-15 can make two 'connections' working simultaneously? Confusing...

-- pa

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

Posted on November 30, 2017 at 00:04

Thank you, Jan

 -- pa

Posted on November 30, 2017 at 13:59

ST response regarding USB Host support: Unfortunately ,ST do not provide any firmware support for USB HUB class for now. There is plan to start developement this year, but we can't commit on any date for the moment.

Fahad Siddiqui
Associate II
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.

Posted on April 20, 2018 at 18:08

Thank you, Fahad.