Page 9 of 12
Re: example interfacing a STM32F4 with libusb
Posted: Mon Aug 13, 2012 7:38 pm
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).
Re: example interfacing a STM32F4 with libusb
Posted: Tue Aug 14, 2012 8:07 am
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
Re: example interfacing a STM32F4 with libusb
Posted: Tue Aug 14, 2012 8:51 am
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
Re: example interfacing a STM32F4 with libusb
Posted: Tue Aug 14, 2012 8:56 am
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
Re: example interfacing a STM32F4 with libusb
Posted: Tue Aug 14, 2012 9:09 am
by kjellhar
What was the fix? Was it only the TxFIFO half empty interrupt?
Kjell
Re: example interfacing a STM32F4 with libusb
Posted: Tue Aug 14, 2012 9:37 am
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?
Re: example interfacing a STM32F4 with libusb
Posted: Tue Aug 14, 2012 9:47 am
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.
Re: example interfacing a STM32F4 with libusb
Posted: Tue Aug 14, 2012 10:32 am
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
Re: example interfacing a STM32F4 with libusb
Posted: Tue Aug 14, 2012 10:45 am
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
Re: example interfacing a STM32F4 with libusb
Posted: Tue Aug 14, 2012 11:46 am
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?