Skip to content

Instantly share code, notes, and snippets.

@makestuff
Last active April 24, 2020 13:12
Show Gist options
  • Save makestuff/76d6f27f39394629dbda7d09961eef32 to your computer and use it in GitHub Desktop.
Save makestuff/76d6f27f39394629dbda7d09961eef32 to your computer and use it in GitHub Desktop.
Build FPGALink and VHDL examples for the EP2C5+Minimus in sync-serial configuration
$ # Make sure you have udev rules for 1d50:602b and 03eb:2ffa, using a group you're a member of (I use "users"):
$ groups
users ...
$ cat /etc/udev/rules.d/10-local.rules
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="1d50", ATTR{idProduct}=="602b", GROUP="users", MODE="0660"
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2ffa", GROUP="users", MODE="0660"
$
# You'll need some stuff before we begin:
sudo apt-get install build-essential libreadline-dev libusb-1.0-0-dev python-yaml
# If you want to build the AVR firmware from source you'll also need these:
#gcc-avr avr-libc dfu-programmer
# I installed Altera Quartus version 13.0sp1 at /opt/altera
export ALTERA=/opt/altera/13.0sp1/quartus
export PATH=$ALTERA/bin:$PATH
# Fetch build infrastructure:
mkdir $HOME/20151220
cd $HOME/20151220
wget -qO- http://tiny.cc/msbil | tar zxf -
cd makestuff
mkdir bin
cd apps/
# Fetch and build flcli (the FPGALink CLI tool):
../scripts/msget.sh makestuff/flcli/20151220
cd flcli
make deps
cp -p lin.x64/rel/*.so lin.x64/rel/flcli ../../bin/
cd ..
# Fetch and build "gordon" (the flash programmer tool):
../scripts/msget.sh makestuff/gordon
cd gordon/usb
make deps
cp -p lin.x64/rel/*.so ../../../bin/
cp -p lin.x64/rel/usb ../../../bin/gordon
cd ../../..
# Maybe build & install AVR firmware:
#cd libs/libfpgalink/firmware/avr
#lsusb | grep 03eb:2ffa # check that AVR is in HWB mode
#make BSP=minimus
#make BSP=minimus dfu # disconnect and reconnect after this
#lsusb | grep 1d50:602b # verify FPGALink AVR firmware running
#cd ../../..
# Setup PATH, then fetch blinky, swled and spi-talk HDL examples
cd ..
scripts/msget.sh makestuff/hdlmake
cd hdlmake/apps
export PATH=$HOME/20151220/makestuff/bin:$HOME/20151220/makestuff/hdlmake/bin:$PATH
hdlmake.py -g makestuff/blinky
hdlmake.py -g makestuff/swled
hdlmake.py -g makestuff/spi-talk
# Build and JTAG-program blinky example:
cd makestuff/blinky/vhdl
hdlmake.py -t ../templates/null -b ep2c5 -p fpga
flcli -v 1d50:602b -p J:B3B2B0B1:top_level.svf # EP2C5's LEDs should start blinking
# Build and JTAG-program cksum example:
cd ../../swled/cksum/vhdl
hdlmake.py -t ../../templates/ss/vhdl -b ep2c5 -p prom fpga
flcli -v 1d50:602b -p J:B3B2B0B1:top_level.svf
flcli -v 1d50:602b -c 2 -a 'w0 55' # write 0x55 to channel 0 using conduit 2 (sync-serial)
flcli -v 1d50:602b -c 2 -a 'w0 aa' # write 0xAA to channel 0 using conduit 2 (sync-serial)
# Build and JTAG-program spi-talk example:
cd ../../../spi-talk/vhdl
hdlmake.py -t ../templates/ssa/vhdl -b ep2c5
flcli -v 1d50:602b -p J:B3B2B0B1:top_level.svf
# Now we can use gordon to make a backup of the FPGA's config-flash chip:
gordon -v 1d50:602b -t indirect:2 -s -r backup.rbf:0:0x80000
# Now we can write the cksum example to the FPGA's config-flash chip:
gordon -v 1d50:602b -t indirect:2 -s -w ../../swled/cksum/vhdl/top_level.rbf:0
# After power-cycling the FPGA, it will boot the cksum example, so we can immediately interact with it:
flcli -v 1d50:602b -c 2 -a 'w0 55' # write 0x55 to channel 0 using conduit 2 (sync-serial)
flcli -v 1d50:602b -c 2 -a 'w0 aa' # write 0xAA to channel 0 using conduit 2 (sync-serial)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment