Electronics -- USB-FX2: FX2Pipe High Speed IO ProgramFX2Pipe 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. News
Theory of OperationFX2Pipe 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 FeaturesTry 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!)
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: 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 FX2PipeFX2Pipe's full source code including the 8051 firmware source and pre-built firmware IHX is available for download under the GPL.
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). TroubleshootingIf 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).
|