example interfacing a STM32F4 with libusb

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
Post Reply
Mathias
Posts: 43
Joined: Thu Jun 28, 2012 6:19 pm

Re: example interfacing a STM32F4 with libusb

Post by Mathias »

Random info on the side: (64/4+1)*2=34 words == 136 bytes. Setting STM32_USB_OTG1_RX_FIFO_SIZE to 136 doesn't work, one additional word is needed, 140 does work...

*edit* Found this bit from the OTG_FS_DIEPTSIZx description:
XFRSIZ: Transfer size
This field contains the transfer size in bytes for the current endpoint. The core only interrupts
the application after it has exhausted the transfer size amount of data. The transfer size can
be set to the maximum packet size of the endpoint, to be interrupted at the end of each
packet.

I'm not sure if I tried that along the way...
Mathias
Posts: 43
Joined: Thu Jun 28, 2012 6:19 pm

Re: example interfacing a STM32F4 with libusb

Post by Mathias »

Using something similar to this I am able to push around 5250 packets per second with a txFifo of 128 (which is in words, so its 512 bytes). Decreasing the buffer to 64 still gives 3900 pps, 32 results in ~2000 pps.
While this is more then I ever was able to push, its still only 28% of what is possible. Also I'm not sure how it affects overall system performance/responsiveness.
The reference manual refers to a polling and an interrupt mode. I think I'm doing something of both. Maybe a true polling mode is what Giovanni means with a double buffered approach?
I'm not sure where to go from here. So I guess I'll leave it to the more skilled people to improve the speed.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: example interfacing a STM32F4 with libusb

Post by Giovanni »

Nope, double buffering is an HW feature specific to the USB peripheral of the F103, the OTG peripheral does not have it.

I mistakenly mentioned that because I believed we were talking about the F103 USB implementation initially.

Giovanni
kjellhar
Posts: 39
Joined: Sun Jul 08, 2012 10:44 pm

Re: example interfacing a STM32F4 with libusb

Post by kjellhar »

It seems like I'm getting nowhere with this problem either. I'm giving it a rest until someone smarter than me comes along.

Giovanni: Do you have any idea if or when you are able to look into this problem. It is a bit important to me. It's only a hobby project, but it would still be nice to know if I can hope for a solution in the near future. If you (or someone else with more USB knowledge than me) look into this, I will be more than happy to participate in any discussions or testing.

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

Re: example interfacing a STM32F4 with libusb

Post by Giovanni »

I can't promise a "when" but it is the next thing on the list after I am done with the configuration tool.

Giovanni
kjellhar
Posts: 39
Joined: Sun Jul 08, 2012 10:44 pm

Re: example interfacing a STM32F4 with libusb

Post by kjellhar »

Thanks, that's more than good enough estimate for me.
Mathias
Posts: 43
Joined: Thu Jun 28, 2012 6:19 pm

Re: example interfacing a STM32F4 with libusb

Post by Mathias »

Do you have a rough idea on what needs to be done? Or how it needs to be done? I may spend a little more time on this, but currently I have no idea what could help.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: example interfacing a STM32F4 with libusb

Post by Giovanni »

Hi Mathias,

I thing you are in the right direction, it is about the TX queue etc. I still have to try so I don't know all the details. I hope to be able to work on it during my vacations in August, then I will need all the help possible with testing, I don't have an analyzer.

Giovanni
Mathias
Posts: 43
Joined: Thu Jun 28, 2012 6:19 pm

Re: example interfacing a STM32F4 with libusb

Post by Mathias »

So if you need someone to try something in coding or just benchmarking, ping me. I don't know what you mean with the analyzer, I pushed a benchmarking client to the repository, maybe thats what you want? It compiles with: gcc benchmark.c -o bench -lusb-1.0 -lrt
kjellhar
Posts: 39
Joined: Sun Jul 08, 2012 10:44 pm

Re: example interfacing a STM32F4 with libusb

Post by kjellhar »

Giovanni wrote:Hi Mathias,
I don't have an analyzer.
Giovanni


I have access to a software based USB analyzer at work. Works pretty well. Not as good as a hardware analyzer, but it still helps a lot.
Post Reply