Discussion:
EZ-USB FX2LP with libusb bulktransfer
Sven Duscha
2005-09-01 15:18:29 UTC
Permalink
Hello,

I'm using a Cypress FX2LP EZ-USB development board to design software
for an USB2 Cy7c68013a-128 FX2LP chip.

I got the device to work with the usbcore-driver and am now
experimenting with bulk transfers. The easiest approach seemed to use
functions provided in libusb-0.1.10a (http://libusb.sourceforge.net/)
to do bulk transfers with usb_bulk_read and usb_bulk_write.

The problem is that in doing so I only get a maximum transfer rate of
ca. 3000k/sec. That is beyond the limitations of USB1.1 and therefore
the device seems to work in USB2.0 mode, but still far below the
limitations of USB2-High speed specifications.

I did tests with different firmwares that were provided with KEIL
development tools (bulksrc, bulkloop) and ezconsole and none provides
any higher transfer speeds.

My only guess is that going through generic usbcore-support could be
the bottle neck. But I'm a bit reluctant to delve into development of
a device driver for the Cypress FX2LP module.

On the other hand there is hardly any information on the linux support
for the FX2LP available on the net, even the less from Cypress
itself. Most drivers and sample applications are for the
FX-USB1.1-version only.

Best regards,
--
Sven Duscha
Max-Planck-Institute for Extraterrestrial Physics
(MPE)
Email: ***@mpe.mpg.de


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
David Brownell
2005-09-01 18:33:50 UTC
Permalink
Date: Thu, 1 Sep 2005 17:18:29 +0200
I got the device to work with the usbcore-driver and am now
experimenting with bulk transfers. The easiest approach seemed to use
functions provided in libusb-0.1.10a (http://libusb.sourceforge.net/)
to do bulk transfers with usb_bulk_read and usb_bulk_write.
So you synchronously write N bytes, wait T for that to complete so your
task can be rescheduled and return to userspace, and then repeat.

The problem with that model is that the time to write N bytes
is probably going to be a LOT less than T.

There are two basic fixes: (a) make N big enough to dwarf T, or
(b) stop waiting after every write, and use asynchronous APIs.
(I don't know if libusb has async APIs, but usbfs certainly does,
and libusb uses usbfs.)

If you look inside the kernel you'll see a usb_sg_wait() routine that
basically lets drivers write N1, N2, N3, N4, etc all at once and then
just wait a single time. The "usbnet" driver framework does much the
same kind of thing, but without waiting: queued asynchronous writes.

Back when I first did that stuff, I sustained transfer rates of about
36 MByte/sec with an FX2, using bulk transfers. That's without any
data copying to userspace.
The problem is that in doing so I only get a maximum transfer rate of
ca. 3000k/sec. ...
My only guess is that going through generic usbcore-support could be
the bottle neck. But I'm a bit reluctant to delve into development of
a device driver for the Cypress FX2LP module.
You mean, do that in kernel mode? You're already doing it
in user mode...
On the other hand there is hardly any information on the linux support
for the FX2LP available on the net, even the less from Cypress
itself. Most drivers and sample applications are for the
FX-USB1.1-version only.
Well there's "fxload" which has handled the FX2 (and presumably FX2LP)
for some time now. Anything else would necessarily be specific to
the 8051 firmware you write for that chip.

- Dave



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Alan Stern
2005-09-01 17:51:10 UTC
Permalink
Post by Sven Duscha
Hello,
I'm using a Cypress FX2LP EZ-USB development board to design software
for an USB2 Cy7c68013a-128 FX2LP chip.
I got the device to work with the usbcore-driver and am now
experimenting with bulk transfers. The easiest approach seemed to use
functions provided in libusb-0.1.10a (http://libusb.sourceforge.net/)
to do bulk transfers with usb_bulk_read and usb_bulk_write.
The problem is that in doing so I only get a maximum transfer rate of
ca. 3000k/sec. That is beyond the limitations of USB1.1 and therefore
the device seems to work in USB2.0 mode, but still far below the
limitations of USB2-High speed specifications.
I did tests with different firmwares that were provided with KEIL
development tools (bulksrc, bulkloop) and ezconsole and none provides
any higher transfer speeds.
My only guess is that going through generic usbcore-support could be
the bottle neck. But I'm a bit reluctant to delve into development of
a device driver for the Cypress FX2LP module.
On the other hand there is hardly any information on the linux support
for the FX2LP available on the net, even the less from Cypress
itself. Most drivers and sample applications are for the
FX-USB1.1-version only.
The bottleneck isn't usbcore, it's libusb. However you don't need to
write your own device driver. It's possible to do what you want using
ioctl and usbfs. You could even hack the libusb source code to support
it, if you want.

What you need is to make asynchronous submissions -- that is, don't wait
for an URB to complete before submitting the next one. You should queue
enough data to fill the bulk pipe for 20 ms or more; thereafter each time
one URB completes you submit a new URB. Remember that usbfs has a limit
of 16 KB per URB. High-speed bulk transfers are capable of handling up to
52 KB/ms, which means you will need to keep at least 1 MB of data (or 64
URBs) in flight.

Alan Stern



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Axel Waggershauser
2005-09-02 08:11:32 UTC
Permalink
Hello,
Post by Alan Stern
Post by Sven Duscha
Hello,
I'm using a Cypress FX2LP EZ-USB development board to design software
for an USB2 Cy7c68013a-128 FX2LP chip.
I got the device to work with the usbcore-driver and am now
experimenting with bulk transfers. The easiest approach seemed to use
functions provided in libusb-0.1.10a (http://libusb.sourceforge.net/)
to do bulk transfers with usb_bulk_read and usb_bulk_write.
The problem is that in doing so I only get a maximum transfer rate of
ca. 3000k/sec. That is beyond the limitations of USB1.1 and therefore
the device seems to work in USB2.0 mode, but still far below the
limitations of USB2-High speed specifications.
I did tests with different firmwares that were provided with KEIL
development tools (bulksrc, bulkloop) and ezconsole and none provides
any higher transfer speeds.
My only guess is that going through generic usbcore-support could be
the bottle neck. But I'm a bit reluctant to delve into development of
a device driver for the Cypress FX2LP module.
On the other hand there is hardly any information on the linux support
for the FX2LP available on the net, even the less from Cypress
itself. Most drivers and sample applications are for the
FX-USB1.1-version only.
The bottleneck isn't usbcore, it's libusb. However you don't need to
write your own device driver. It's possible to do what you want using
ioctl and usbfs. You could even hack the libusb source code to support
it, if you want.
What you need is to make asynchronous submissions -- that is, don't wait
for an URB to complete before submitting the next one. You should queue
enough data to fill the bulk pipe for 20 ms or more; thereafter each time
one URB completes you submit a new URB. Remember that usbfs has a limit
of 16 KB per URB. High-speed bulk transfers are capable of handling up to
52 KB/ms, which means you will need to keep at least 1 MB of data (or 64
URBs) in flight.
I had the same problem (not enough throughput from an FX2 with libusb).
Eric Blossom pointed me
(http://marc.theaimsgroup.com/?l=linux-usb-devel&m=109899814018128&w=2)
to the usrp lib from the gnu software radio project:
ftp://ftp.gnu.org/gnu/gnuradio/usrp-0.8.tar.gz

I was able to get something like 42 MB/sec bulk transfers from my FX2.
But it was dependent on the host controller, some nec chip based
hardware only got me 32 MB/sec.

There was some discussion whether this could go into libusb or whether
the usbfs interface could be extended to support some
scatter-gather-list based high-throughput zero-copy mechanism. There
seemed to be some issues with proper error handling, memory
boundaries, etc. I think there was no real agreement on how, or even
if this could go into usbfs/libusb. Maybe this has changed, meanwhile?

I'd still be interested in some usrp/fusb like functionality in
libusb. I'm afraid my knowledge of dma / sg / memory-boundary related
topics is insufficient to help extending usbfs, but I'd be happy to
help with implementing and testing some kind of a port of the fusb
stuff to libusb.

Cheers,
Axel


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Loading...