AnsweredAssumed Answered

STM32F4 and USB FS/HS with ULPI

Question asked by radev.christo on Dec 2, 2015
Latest reply on Jul 20, 2016 by zhang.haihong
Hi to All,

I would like to share my experience to create test application and measure the USB performance for both FS and HS with external ULPI PHY (USB3300) on STM32F4 MCU series.

To do that Olimex STM32-H405 board and USB3300 module was used as hardware. Because of high speed the connection between them was made with very short wires and using default pin connection case with USB3300 reset pin connected to PA6. In addition to use default USB FS Device pin-out USB_P was re-wired from PC4 to PA9. For debugging USART2 (PA2 Tx only) is used. The pins for USART1/6 and SDIO ware reserved for future use. Additional hardware used is ST-LINK V2 (for FW uploading and debugging) and FT4232-HUB module for inter connectivity. Windows 7 PC (i7) and a20-Lime2-SOM with Linux 3.4.79+ are used as hosts for terminating of USB connections.

STM32F4 application was created from the scratch using STM32CubeMX and STM32Cube FW (for STM32F4 ver. 1.8.0) including both USB FS and HS with external ULPI PHY interfaces set as CDC devices and FreeRTOS. Development was made in Eclipse IDE as Makefile project thanks to Makefile framework. In addition library standard input and output was redirected to UART2 thanks to newlib staff added.

USB FS/HS devices info was verified with UVCView on Windows and ‘lsusb’ command and ‘usb-devices’ script on Linux. It was assured of full / high speed of USB FS/HS devises respectively.

Performance measurement was planned to be done on both device and host sides. On STM32F4 FW side two FreeRTOS threads sending data continuously at maximal speed using long buffers with built-in throughput measurement ware added. In the loop of the default startup thread the results are printed to stdout.

The first tests ware done without host measurement of the throughput and Linux ‘cat’ command (with stdin redirected from /dev/ttyACM devices) was used to terminate USB connections. To eliminate the print to screen time stdout was redirected to /dev/null. The results measured for USB FS/HS throughput and data memory usage at different sizes of USB FS/HS transmit buffers ware presented on the following diagram.

There were problems to use terminal utilities like screen for example in Linux and PuTTY in Windows simultaneously connected to both USB FS and HS devices. The main problem is that USB FS connection stopped either immediately or after some time to respond on some unknown reason.

As a next step a simple Python script was developed to measure simultaneously the throughput on host side. For connecting to USB devices both Python Sys and Serial libraries were used. The best result was reached with PySerial based scripts running after USB FS on Linux and USB HS on Windows simultaneously with internal measurement printed via USART2 on PyTTY on Windows. There was a problem to run the script on the same host simultaneously after both USB FS and HS devices (USB HS throughput degraded down to FS one). The results in case of the best performance reached at the first test (using 2 and 38.5 kB transmit buffers for USB FS and HS respectively) are shown on the following picture.

It is visible that USB HS throughput is 2.5 times lower (15 vs. 38 MBps) while USB FS one is almost the same (972 v. 1018 kBps). The main reason for lower throughput measured at USB HS could be Python limitation – much slower if Sys library is used (2 MBps measured for USB HS).

The maximal USB HS throughput cannot be verified using Python (or other script language) so other application has to be developed – most probably C for Linux.

Preliminary measurement results for USB HS with external UPLI PHY (120 Mbps verified on both sides and 310 Mbps verified on device side only vs. 75 Mbps measured over Ethernet with STM32-E407 board) make believe that much better than 100 Mbps LAN communication performances can be expected in this case on STM32F4 MCUs.

Unfortunately, it is under a question the connection reliability and compatibility with different host HW and SW. Other not solved problem is Ethernet over USB support in STM32Cube SW even there are some projects in that way like

Best regards