Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

High Bandwidth USB transfers

57 views
Skip to first unread message

Guenther Sohler

unread,
Dec 9, 2006, 10:07:07 AM12/9/06
to
Dear Group,

I still try getting happy with libusb-0.1.12
My goal is to achieve a datarate of 12 MB/s using usb_reads,
but i dont get it done so far,( Using threads!!!) all of them doing
usb_bulk_read i get about 4 MB/s.
I read something about usb-1.0 and that it has asynchronous usb_reads.
I really want to test asynchronous usb read .
on the libusb homepage i managed to check out v1.0 of libusb, but
it does neither seem to completely compile, nor does its documentation
show me that asynchrounous transfers are supported.
I even read about libusb-1.0.7 but i did not manage to actually find it on
the net.

Can anybody give me detailled instructions, how to get, compile
and use asynchronous usb read transfers ?

thanks in advance

John Reiser

unread,
Dec 9, 2006, 10:56:56 AM12/9/06
to
> I still try getting happy with libusb-0.1.12
> My goal is to achieve a datarate of 12 MB/s using usb_reads,
> but i dont get it done so far,( Using threads!!!) all of them doing
> usb_bulk_read i get about 4 MB/s.

Plug in a USB-2.0 flash storage device ("key" drive, "thumb" drive, etc.)
and do "time dd if=/dev/sda1 of=/dev/null bs=32k count=10000" which
reads 320MB in 32KB chunks. I get between 6MB/s and 10MB/s using
consumer-grade devices purchased at stores selling office supplies.
This gives a practical upper limit. If the buffer size is smaller
then the average data rate will be lower.

--

Guenther Sohler

unread,
Dec 9, 2006, 11:43:09 AM12/9/06
to
On Sat, 09 Dec 2006 07:56:56 -0800, John Reiser wrote:

> time dd if=/dev/sda1 of=/dev/null bs=32k count=10000

Thank you for your reply.

I tested it. Using this command i get 22 MB/s but this value
is th result of kernel-side usb.
I am using user-side-usb (libusb) and want to use a quite big data rate
n my useer-level C program.

rds

Tim Roberts

unread,
Dec 10, 2006, 12:23:28 AM12/10/06
to
Guenther Sohler <gi...@pc.localdomain> wrote:

To get high USB bandwidth, you must ensure that you always have buffers
queued up for the host controller. One of the problems with libusb 0.x is
that it does not support asynchronous transfers: you submit one request,
you wait until it is complete, then you submit another. The problem with
that is that, the whole time you are preparing to submit another request,
you have no buffers queued, so nothing is being scheduled for transfer.

If you use large buffers, you can get the bandwidth up a bit higher, but
the only way to "kick it up a notch" is to use asynchronous transfers, and
that means abandoning libusb.

We were able to achieve 30MB/s over a Linux bulk pipe by using the usbfs
ioctls directly. This is the same driver interface that libusb uses; we
just skipped the thin libusb layer so we could submit asynchronous URBs on
our own.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

Guenther Sohler

unread,
Dec 10, 2006, 12:28:34 PM12/10/06
to
Dear Tim, thank you very much for your valuable reply.

I spend most of the day trying to get rid of libusb.

First I flattened libusb into my program, second optimize it ;
remove unneeded code which helped my understand it better
Then I implemented another approch for usb_bulk read.

It is called usb_bulk_read1 and and uses an approch of 10 simultaniuos
usb_urb requests.

But i am still not happy with the solution.
just using 1 thread, i still cannot get data fast enough.
Just using multiple threads fixes the solution, but I cannot find a reason,
why 1 thread is not good enough using the new approcah.

I would be very glad, if you could look at this:


http://194.208.18.155/package.tar.gz

myusb.c: modified duplicate of libusb
myusb.h: its headers
datarate.c : testprogram to measure the received datarate


thank you in advance

0 new messages