FX2 CyStream throughput test with SDCC and fx2lib
I've been optimizing my firmware for throughput and I thought a good benchmark would be to test it against the CyStream example provided by Cypress. I modified their CyStream.c file to be compatible with the latest firmware file provided by fx2lib.
Here is a summary of the changes needed:
- Include the appropriate header files
- Change the functions for vendor commands to match the fx2lib functions.
- Change the interrupt handlers
- Probably the most work of the whole process, rewrite the dscr.a51 file to be in asx8051 format.
Anyhow, The attached zip files contains the sources for the modified CyStream. Here are some of my benchmark results:
| Firmware/Test | Speed |
|---|---|
| CyStream Application on Windows with Keil firmware | ~41 MBps |
| Keil firmware, Linux Host with included speed.py | ~40 MBps |
| SDCC firmware, unchanged, speed.py | ~35.6 MBps |
| SDCC firmware, optimization 1, speed.py | ~40.9 MBps |
| SDCC firmware, optimization 2, speed.py | ~41.9 MBps |
| SDCC firmware, optimization 3, speed,py | ~42.9 MBps |
| SDCC firmware, optimization 3, CyStream App on Windows | ~43.8 |
- Optimization: remove two if checks for interrupts in main loop and handle them directly in the interrupts
- Optimization: remove another if in main loop.
- Optimization: completely remove everything in main loop, commit packets directly in main loop, don't write to ep buffer before committing data. Note that the fastest I could get this to go was 42.9 (or 43.8 on Windows). Further removing things didn't make it go any faster so I think I hit my Host PC limits.
You'll need to download fetch the latest fx2lib from github and then modify the Makefile to compile the attached firmware. You'll need to install the fx2load package for Python from fx2lib in order to run the speed test.
Enjoy. I hope fx2lib helps someone out. Check out my other posts on fx2lib to find our mailing list and more SDCC examples for the Cypress FX2.
7 users commented in " FX2 CyStream throughput test with SDCC and fx2lib "
Follow-up comment rss or Leave a TrackbackDennis:
Do you have any samples of your host application side
code?
Regards,
bali
The fx2load package has some example of talking to the device with libusb-1.0. You can see sending vendor commands and doing bulk reads. I use that in the speed.py file too. Really though, everyone’s device is different so I haven’t found much utility in adding a host side example. Perhaps I’ll add a CyStream C++ equivalent that uses libusb0 one of these days.
Hi, first of all great job !
Just a question… I built your cystream using the latest FX2Lib, I programmed the binary into the EPROM of my custom EZ-USB board. Everything worked well at the first trial. Now the question… when I use your firmware in conjunction with the Streamer.exe delivered by Cypress I only get up tu a maximum of 36 MB/s in bulk mode which is quite far from the results you got. I’ve a IHC9 as host controller which should guarantee the maximum bandwidth… Where do you think is the problem? did you ever tried to use Streamer.exe of Cypress? with which results ?
Thanks Joebre
Been a while since I tried. Is there much different about streamer.exe and CyStream? I got it to go faster by eliminating any work the firmware was doing that wasn’t involved with committing the packets. Did you make those changes?
It’s a good learning activity to see how fast you can get it to go, but in the end, you’ll probably use slave fifo or gpif to transfer data from a peripheral directly through the buffers to the PC. We do this at 43MB/s which seems about as fast as the host will handle it.
Lastly, have you tried more than one machine to see if you get different results? You can post messages and firmware bits to the fx2lib mailing list too by the way: http://bit.ly/9xj8M5
Hi, thanks for your rapid answer.
I used your code as it comes from your web site, which I suppose has already the changes you’re speaking about (correct?). Yes I tried on several machines both Vista and XP and the throughput seems kind of hardwired to a maximum of 35/36 MB/S. You are right at the end I’ll use a synchronous slave fifo approach. At this stage of the project I need just to get a list of requirements for the host and to validate the throughput for Bulk unidirectional transfers (IN). 36 MB/s is good but it gives me a really small margin.
Sorry, I did a mistake… in the EProm image I got the old version of fw.c, this explains what I was seeing. Using your fw.c the throughput goes immediately and stably up to 43 MB/s. Thanks again for your support.
Job
Glad it’s working. If you haven’t already, you’ll probably want to download fx2lib from the latest github master as opposed to 0.1 There are quite a few fixes, new samples, better build system and other things. I’m about ready to tag it 0.2 but I’ve been waiting on giving it a new website/home.
Leave A Reply