Nav:  [home][elec][periph][usb-fx2][software] > [fx2pipe]
Go:  [local_examples] [io_examples] [fx2pipe]
← [What are these? Why?]

Electronics -- USB-FX2: FX2Pipe High Speed IO Program

FX2Pipe is a small high speed USB transfer program which can pipe stdin into the FX2 FIFO or back from the FIFO to stdout. The transfer engine is not based upon libusb and outperforms libusb considerably.


Nov 2011: Version 0.8
Added option -d=VID:PID[:N] to address FX2 devices with non-standard vendor and product IDs (VID and PID); minor changes.
Apr 2009: Version 0.7
Added support for CY7C68013 without A suffix which has less SRAM, added new option -cko to control internal clock and CLKOUT pin. Tested unter native 64bit Linux.
Jun 2008: Version 0.6
Maintenance and bugfix update to version 0.6.
Aug 2006: Initial release (version 0.5)
Initial public release of fx2pipe (version 0.5).

Theory of Operation

FX2Pipe has a build-in firmware for the 8051 controller integrated in the FX2 chip. Upon startup, FX2Pipe will download that firmware onto the controller and also pass additional information (like the direction of the transfer, the FIFO width, etc.), then take the FX2 out of reset and begin the transfer.

The transfer works by submitting a number of URBs (normally 16) which are then enqueued and processed by the kernel as soon as possible. Once an URB is processed, it is returned back to the program which will in turn submit another URB hence having always a couple of URBs enqueued in the kernel.

Usage and Features

Try calling FX2Pipe with the option --help:

USAGE: fx2pipe [option|assignment]...
Long options:
  --help       print this
  --version    print version information
Short options: (Can be compined into single option)
  -i           run in IN direction, i.e. read data from USB EP6 (default)
  -o           run in OUT direction, i.e. write data to USB EP2
  -0           no stdio; send NULs / throw away read data (for timing)
  -8,-w        use 8bit / 16bit (default) wide fifo bus on FX2 side
  -2,-3,-4     use double, triple or quad (default) buffered FX2 fifo
  -s,-a        run in sync (default) / async slave fifo mode
  -O,-I        shortcut for -o0, -i0, respectively
Assignments: (Leading '-' can be left away)
  -d=NN        use n-th (unconfigured) FX2 device (start with NN=0, default)
  -d=VID:PID[:N] use N-th device with specified VID and PID
  -n=NNN       stop after NNN bytes; suffix k,M,G for mult. with 2^10,20,30
  -bs=NNN      set IO block size to NNN, max 16384 (default 16384)
  -ps=NN       set pipeline size (number of URBs; default 16)
  -sched=P[,N] set scheduling policy P ("fifo" or "rr") and prio N
  -fw=PATH     use specified firmware IHX file instead of built-in one
               omit path to not download any firmware (just reset device)
  -ifclk=[x|30[o]|48[o]][i] specify interface clock:
               x -> external; 30,48 -> internal clock 30/48MHz, suffix 'o'
               to enable output to IFCLK pin, 'i' to invert IFCLK
  -cko=[12|24|48][o|z][i] specify 8051 frequency in MHz (default: 48) and
               CLKOUT pin: output 'o' (default), tristate 'z', invert 'i'

fx2pipe - pipe data in or out of an Cypress FX2 device (CY7C6801x[A])
          Copyright (c) 2006--2011 by Wolfgang Wieser; License: GPL

Examples: To make a benchmark for reading from an FX2, simply call (as root, of course!)
fx2pipe -I

If there are several devices attached, and you want to bench writing to the one and reading from the other, take two shells and execute:
fx2pipe -I d=0
fx2pipe -O d=1

Warning: Be careful with changing the scheduler (sched=), you can lock up your system... Also don't use custom firmware (fw=) unless you know what you're doing.

Download FX2Pipe

FX2Pipe's full source code including the 8051 firmware source and pre-built firmware IHX is available for download under the GPL.

Source: fx2pipe-0.8.tar.gz   [163kb gzipped source tarball]
Version:0.8   (2011-11-10)
Author:Wolfgang Wieser   (report bugs here)
License:GNU GPL (Version 2)

Build and Install: The usual configure and make steps should build a binary called fx2pipe. It is completely self-contained (i.e. the default 8051 firmware is built into the binary) and can hence be installed by copying it somewhere (without the need for any additional files).


If FX2Pipe does not work, first make sure that the simple libusb-based examples work.

If you see something like this...

Submitting max. 16 URBs to fill pipeline... 16 submitted
URB (just reaped) status=-71 (Unknown error 4294967225), cancelled=0
HMM: URB(1): blen=0/16384, status=-71, error count=0, cancelled=0
URB (just reaped) status=-71 (Unknown error 4294967225), cancelled=0
HMM: URB(1): blen=0/16384, status=-71, error count=0, cancelled=0

...then this may have multiple reasons from bad board design to wrong USB cables. It also shows up when using an old FX2 chip instead of the newer FX2LP ones which have twice as much SRAM. Current versions of FX2Pipe were written for FX2LP chips but they will work for plain FX2s as well when changing the address 0x3000 to a smaller value like 0x1000: For that, you need to change FirmwareConfigAdr in fx2pipe.h and cfg_data in fx2pipe.c. Thanks to Rene van Leuken for the feedback.

NOTE also that FX2Pipe requires the CY7C68013A (FX2-LP) chip which has 16kb SRAM. It will not work with the smaller variant without the "A" suffix which has just 8kb of SRAM. However, you may get it working by changing the address of the config memory from 0x3000 to e.g. 0x1600 (both in the firmware and the driver program).

[home] [site map]
Valid HTML 4.01!
Copyright © 2006-2011 by Wolfgang Wieser
Last modified: 2011-11-10 21:51:29