Skip to content

libFPGALink

Carl Karsten edited this page Mar 30, 2015 · 13 revisions

Build libFPGAlink

# Install prerequisites:
sudo apt-get install \
  build-essential libreadline-dev libusb-1.0-0-dev python-yaml
wget -qO- http://tiny.cc/msbil | tar zxf -

# Fetch flcli/fx2loader
cd makestuff
# ./scripts/msgit.sh makestuff/common  ---  'msgit' is for developers, need ssh keys.  'get' is for people
./scripts/msget.sh makestuff/common
cd apps
../scripts/msget.sh makestuff/flcli
../scripts/msget.sh makestuff/fx2loader

# Build flcli/fx2loader
cd flcli
make deps
cd ..

cd fx2loader
make deps
cd ..

Set up udev

As root

cat > /etc/udev/rules.d/52-hdmi2usb.rules <<EOF
# Grant permission to makestuff usb devices.
ATTR{idVendor}=="1d50", MODE:="666"

# Grant permissions to hdmi2usb usb devices.
ATTR{idVendor}=="fb9a", MODE:="666"

# Grant permissions to unconfigured cypress chips.
ATTR{idVendor}=="04b4", MODE:="666"

# Grant permissions to Digilent Development board JTAG
ATTR{idVendor}=="1443", MODE:="666"
EOF

udevadm control --reload-rules

Load the firmware

git clone https://github.com/timvideos/HDMI2USB-firmware-prebuilt

First Time

flcli=makestuff/apps/flcli/lin.x64/rel/flcli
fx2loader=makestuff/apps/fx2loader/lin.x64/rel/fx2loader

$flcli -v 1d50:602b:9994 -i 1443:0007
$flcli -v 1d50:602b:9994 -p J:D0D2D3D4:HDMI2USB-firmware-prebuilt/unstable/hdmi2usb.xsvf
$fx2loader -v 1d50:602b HDMI2USB-firmware-prebuilt/unstable/hdmi2usb.hex ram

Second time

This requires the patch at https://github.com/makestuff/libusbwrap/pull/1

You may need to do sudo modprobe -r uvcvideo.

flcli=makestuff/apps/flcli/lin.x64/rel/flcli
fx2loader=makestuff/apps/fx2loader/lin.x64/rel/fx2loader

$flcli -v 1d50:602b:9994 -i fb9a:fb9a
$flcli -v 1d50:602b:9994 -p J:D0D2D3D4:HDMI2USB-firmware-prebuilt/hdmi2usb.xsvf
$fx2loader -v 1d50:602b HDMI2USB-firmware-prebuilt/hdmi2usb.hex ram



Creating xsvf files

flcli needs a .xsvf and not a .bit file to program a device. You can create a xsvf file from a .bit file using the Xilinx iMPACT tool as described below;

Create following in a file replacing the output.xvsf and input.bit files with your own names.

impact.batch

setPreference -pref KeepSVF:True
setMode -bs
setCable -port xsvf -file output.xsvf
addDevice -p 1 -file input.bit
program -p 1
quit

Then run impact -batch impact.batch. Output should look like follows;

$ impact -batch impact.batch
Release 14.7 - iMPACT P.20131013 (lin64)
Copyright (c) 1995-2013 Xilinx, Inc.  All rights reserved.
Preference Table
Name                 Setting             
StartupClock         Auto_Correction     
AutoSignature        False               
KeepSVF              False               
ConcurrentMode       False               
UseHighz             False               
ConfigOnFailure      Stop                
UserLevel            Novice              
MessageLevel         Detailed            
SpiByteSwap          Auto_Correction     
AutoInfer            false               
SvfPlayDisplayComments false               
'1': Loading file 'work/dvid_serdes.bit' ...
done.
INFO:iMPACT:1777 - 
   Reading /opt/Xilinx/14.7/ISE_DS/ISE/spartan6/data/xc6slx45.bsd...
INFO:iMPACT:2257 - Startup Clock has been changed to 'JtagClk' in the bitstream
   stored in memory,
   but the original bitstream file remains unchanged.
UserID read from the bitstream file = 0xFFFFFFFF.
Data width read from the bitstream file = 1.
INFO:iMPACT:501 - '1': Added Device xc6slx45 successfully.
----------------------------------------------------------------------
----------------------------------------------------------------------


'1': Programming device...
 LCK_cycle = NoWait.
LCK cycle: NoWait
done.
INFO:iMPACT:579 - '1': Completed downloading bit file to device.
INFO:iMPACT:188 - '1': Programming completed successfully.

 LCK_cycle = NoWait.
LCK cycle: NoWait
INFO:iMPACT - '1': Checking done pin....done.
'1': Programmed successfully.
Elapsed time =      7 sec.