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

  1. Optimization: remove two if checks for interrupts in main loop and handle them directly in the interrupts
  2. Optimization: remove another if in main loop.
  3. 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.

CyStream for SDCC and fx2lib

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.