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.
kjellhar
Posts: 39
Joined: Sun Jul 08, 2012 10:44 pm

Re: example interfacing a STM32F4 with libusb

Post by kjellhar »

Ok,
I'll probably read some more documentation as I'm slightly better at that than I am at coding (I'm an IC designer, not a programmer).
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 committed the fix, now the shell command "write" achieves rates of 1.1MB/sec writing buffers of 1024 bytes with a multiplier of just x2. Apparently now higher multipliers are not required unless running with much slower clocks.

There is still one small problem, after writing the 1024 bytes buffers a spurious \0x00 is transmitted, not sure about the cause of this problem.

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

Re: example interfacing a STM32F4 with libusb

Post by kjellhar »

This is great!!

I just compiled Mathias code again, and immediately got approx 250MBytes/sec. I'll try it out later with my own application to see how fast I can make it work. Oh, by the way, I'm connecting it to a Mac (Lion).

As for the 0\00 you get at the end of each buffer. I remember seeing somewhere that when the last packet to be send is equal to the max packet size, the transaction must be terminated with a zero length packet. This is not done automatically. I'm not sure if you do this, but if not, the problem may be related to that. If the last packet is smaller than max size, it is not necessary to send the zero length packet. It would be easy to check if the problem persist if you change the buffer to something that does not divide by 64 (ie 1023 byte). If that makes the problem go away, I would say we have a suspect.

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 »

Hi,

It is OK now, the 0x00 problem was an error in sending the buffer, I was sending the final 0x00 too...

The driver now appears to be able to achieve 1.1MB/sec even sending repeated small writes in the queue, the performance is close to the theoretical maximum.

Now I will look into implementing a worker thread for data copy, moving 1.1MB/sec from within an ISR does not look like the best idea.

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

Re: example interfacing a STM32F4 with libusb

Post by kjellhar »

What was the fix? Was it only the TxFIFO half empty interrupt?

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

Re: example interfacing a STM32F4 with libusb

Post by Mathias »

Hmm, for me it tops out at ~500kb/s but I think this has something to do with my setup. When I connect the F4 directly, I only get 1000 packets per second, when connected through a hub I get the 500kb/s. It still looks good, I will try it later on the workstation.

What did the trick Giovanni? Was it the half-empty interrupt not being properly enabled?
kjellhar
Posts: 39
Joined: Sun Jul 08, 2012 10:44 pm

Re: example interfacing a STM32F4 with libusb

Post by kjellhar »

Mathias wrote:Hmm, for me it tops out at ~500kb/s but I think this has something to do with my setup. When I connect the F4 directly, I only get 1000 packets per second, when connected through a hub I get the 500kb/s. It still looks good, I will try it later on the workstation.


Strange, I also get good performance through a hub, but not when I connect it directly to the computer.
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 also tested through a cheap HUB on a very low end PC (Core2 duo at 1.2GHz).

About the problem, it was just the interrupt not correctly enabled.

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: example interfacing a STM32F4 with libusb

Post by Giovanni »

Re-tested without hub, I get the same performance: 1.1MB/sec.

Could it be host-related? I am testing on Ubuntu 11.04.

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

Re: example interfacing a STM32F4 with libusb

Post by Mathias »

I tested with Fedora17 & Windows, the Desktop is also much slower directly connected compared to a hub inbetween.

Do you plan to make the threaded FIFO fill interrupt-less?
Also: Is there a way or is it planned to support UBS-host/OTG modes?
Post Reply