STM32F407 + USB + ULPI Interface

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F407 + USB + ULPI Interface

Post by Giovanni »

Hi,

I found that the HW FIFO multiplier greatly affects performance, in structure USBEndpointConfig it is usually 2, you should try 4 or even 8. For CDC applications it is not a problem because there is plenty FIFO RAM available.

Giovanni
chradev
Posts: 48
Joined: Sun Apr 28, 2013 6:52 am

Re: STM32F407 + USB + ULPI Interface

Post by chradev »

I try it increasing USBEndpointConfig.in_multiplier for USB FS/HS data endpoints only from 2 (default) to 4 and 8.
In both cases (4 and 8) USB HS throughput increases from ~5 to ~7.4 MBps when connected to Linux on a20-Lime2-SOM.
When USB HS was connected to i7 PC with Windows 7 throughput increases from ~2 to ~2.5 MBps (or ~25%).

Unfortunately, connection for both USB FS and HS become unstable and even Linux on a20-Lime2-SOM hangs (no such behavior till now).
Regarding STM32F405/7 Data Sheet: Combined Rx and Tx FIFO size is 320 × 35 bits / 1 Kbit × 35 for OTG-FS/HS respectively.
Can this strange behavior be explained by having 2 CDC devices (on USB FS and HS) and 512 bytes USB HS packet size in my case?

Chris
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F407 + USB + ULPI Interface

Post by Giovanni »

You can't have a queue of x4 or x8 if your packet size is 512, there is not enough RAM. You should get an assertion because that. Could you try with smaller packets and longer FIFOs? 64x4 is working for me.

I fixed a regression that could cause instability, it caused SV#8 errors because a change in ST header files, make sure to updated to the latest revision.

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F407 + USB + ULPI Interface

Post by Giovanni »

Using the linear API (the new synchronous variant of it) I am seeing 16MB/s+ by transmitting blocks of 1KB, the rate really improves using even larger blocks.

See the demo \testhal\STM32\STM32F7xx\USB_RAW

It is still work in progress, it is still buggy and not optimized.

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F407 + USB + ULPI Interface

Post by Giovanni »

It is stable now, there was a problem on USB reconnection.

Giovanni
User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Has thanked: 3 times
Been thanked: 3 times

Re: STM32F407 + USB + ULPI Interface

Post by DeusExMachina »

chradev wrote:I try it increasing USBEndpointConfig.in_multiplier for USB FS/HS data endpoints only from 2 (default) to 4 and 8.
In both cases (4 and 8) USB HS throughput increases from ~5 to ~7.4 MBps when connected to Linux on a20-Lime2-SOM.
When USB HS was connected to i7 PC with Windows 7 throughput increases from ~2 to ~2.5 MBps (or ~25%).

Unfortunately, connection for both USB FS and HS become unstable and even Linux on a20-Lime2-SOM hangs (no such behavior till now).
Regarding STM32F405/7 Data Sheet: Combined Rx and Tx FIFO size is 320 × 35 bits / 1 Kbit × 35 for OTG-FS/HS respectively.
Can this strange behavior be explained by having 2 CDC devices (on USB FS and HS) and 512 bytes USB HS packet size in my case?

Chris

chradev, could you please share your project for 405? I failed with porting F7 demo to F407. Maybe it's a board issue, and I need to check it.
chradev
Posts: 48
Joined: Sun Apr 28, 2013 6:52 am

Re: STM32F407 + USB + ULPI Interface

Post by chradev »

I have already do that in my previous post. You can download it following the link:
http://forum.chibios.org/phpbb/download/file.php?id=933

Regards
Chris
User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Has thanked: 3 times
Been thanked: 3 times

Re: STM32F407 + USB + ULPI Interface

Post by DeusExMachina »

Thanks.
User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Has thanked: 3 times
Been thanked: 3 times

Re: STM32F407 + USB + ULPI Interface

Post by DeusExMachina »

I use ulpi and Chibios 16.1.1 stable
I was able to run several USB examples on my board, including testhal demo. But I have a problem - periodically (but really often) I have a trouble

Code: Select all

  osalDbgAssert(!usbGetTransmitStatusI(usbp, ep), "already transmitting");

this is called from endpoint setup usb.c 765 (_usb_ep0setup)
previously in _usb_isr_invoke_setup_cb() usb.c 410 (otg_epout_handler)
otg_epout_handler() usb_ldd.c 609 (usb_lld_serve_interrupt)

My hardware setup is similar, the only difference that I run MCU on 48 MHz. What could go wrong?
User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Has thanked: 3 times
Been thanked: 3 times

Re: STM32F407 + USB + ULPI Interface

Post by DeusExMachina »

Maybe someone can share a basic example of HID device using HS ULPI? (Sounds ridiculous, but I really need it) :)
Post Reply