Commit 310d1be1 authored by Jens Korinth's avatar Jens Korinth

Closes #5 - VC709: Support multiple FPGAs in JTAG chain

* scanning all targets and devices, programming the first VX690T
* improved the bit_reload.sh scripts:
   - normal option parsing
   - enabled verbose output w/o driver reload
   - disabled 'default' bitstream (I mean, WTF?)
* moved bit_reload in VC709 into standard location in module
parent 5cec7aba
......@@ -26,8 +26,8 @@ if args.verbose:
print 'Reload Driver: {0}'.format(str(args.reload_driver))
print 'Platform: {0}'.format(os.environ['TAPASCO_PLATFORM'])
path = 'module/hotplug_stuff/' if os.environ['TAPASCO_PLATFORM'] is 'vc709' else 'module/'
reld = 'drv_reload' if args.reload_driver else ''
verb = 'verbose' if args.reload_driver and args.verbose else ''
cmd = '$TAPASCO_HOME/platform/$TAPASCO_PLATFORM/{0}bit_reload.sh {1} {2} {3}'.format(path, args.bitstream, reld, verb)
path = 'module/'
reld = '-d' if args.reload_driver else ''
verb = '-v' if args.verbose else ''
cmd = '$TAPASCO_HOME/platform/$TAPASCO_PLATFORM/{0}bit_reload.sh {1} {2} {3}'.format(path, verb, reld, args.bitstream)
subprocess.call([cmd], shell=True)
#!/bin/bash
#
# Copyright (C) 2014 David de la Chevallerie, TU Darmstadt
# Copyright (C) 2017 Jens Korinth, TU Darmstadt
#
# This file is part of Tapasco (TPC).
#
......@@ -23,64 +23,100 @@
# Script usage e.g. ./bit_reload 'path_to_bitstream' drv_reload verbose
# Pathes '*_path' have to be adapted to specific location
# Source vivado scripts for programming
source /opt/cad/xilinx/vivado/Vivado/2015.2/settings64.sh
# init paths
DRIVER=ffLink
BITLOAD_SCRIPT="$TAPASCO_HOME/platform/vc709/module/program_vc709.tcl"
LOG_ID=$DRIVER"|""pci"
# save current user name
calling_user=`echo $USER`
show_usage() {
cat << EOF
Usage: ${0##*/} [-v|--verbose] [--d|--drv-reload] BITSTREAM
Program first VC709 found in JTAG chain with BITSTREAM.
# Pathes to needed files
driver_name="ffLink"
driver_path="$TAPASCO_HOME/platform/vc709/module/"
-v enable verbose output
-d reload device driver
EOF
}
hotplug_script_name="hotplug.sh"
hotplug_script_path="$driver_path/hotplug_stuff/"
hotplug() {
VENDOR=10EE
DEVICE=7038
PCIEDEVICE=`lspci -d $VENDOR:$DEVICE | sed -e "s/ .*//"`
echo "hotplugging devive: $PCIEDEVICE"
# remove device, if it exists
if [ -n "$PCIEDEVICE" ]; then
sudo sh -c "echo 1 >/sys/bus/pci/devices/0000:$PCIEDEVICE/remove"
fi
bitload_script_name="program_vc709.tcl"
bitload_script_path="$hotplug_script_path"
# Scan for new hotplugable device, like the one may deleted before
sudo sh -c "echo 1 >/sys/bus/pci/rescan"
echo "hotplugging finished"
}
log_id=$driver_name"|""pci"
# init vars
BITSTREAM=""
VERBOSE=0
RELOADD=1
# Use first paramter from user, if it's a bit file
bitstream_file="sobel-memloc.bd.bit"
if [ "$#" -ge 1 ] && [[ $1 == *.bit ]]
then
bitstream_file=$1
echo "Using user given bitstream:" $bitstream_file
else
echo "Using default bitstream:" $bitstream_file
fi
OPTIND=1
while getopts vd opt; do
case $opt in
v)
VERBOSE=1
;;
d)
RELOADD=1
;;
*)
echo "unknown option: $opt"
show_usage
exit 1
;;
esac
done
shift "$((OPTIND-1))"
# Unload the driver if desired by user
if [ "$#" -ge 2 ] && [[ $2 == drv_reload ]]
BITSTREAM="$1"
if [ -n $BITSTREAM ] && [[ $BITSTREAM == *.bit ]]
then
sudo rmmod $driver_name
fi
echo "bitstream = $BITSTREAM"
# Program device
if [ "$#" -ge 3 ] && [ $3 == verbose ]
then
vivado -nolog -nojournal -mode tcl -notrace -source $bitload_script_path$bitload_script_name -tclargs $bitstream_file
else
echo "Programming bitstream silently, this could take while"
vivado -nolog -nojournal -mode tcl -notrace -source $bitload_script_path$bitload_script_name -tclargs $bitstream_file > /dev/null
echo "Programming bitstream finished"
fi
# unload driver, if second arg is "drv_reload"
if [ -n "$2" ] && [[ "$2" == drv_reload ]]; then
sudo rmmod $DRIVER
fi
# Hotplug pcie-bus
sudo sh $hotplug_script_path$hotplug_script_name
echo "Hotplugging finished"
# program the device
if [ $VERBOSE -gt 0 ]; then
vivado -nolog -nojournal -notrace -mode tcl -source $BITLOAD_SCRIPT -tclargs $BITSTREAM
VIVADORET=$?
else
echo "programming bitstream silently, this could take while ..."
vivado -nolog -nojournal -notrace -mode batch -source $BITLOAD_SCRIPT -tclargs $BITSTREAM > /dev/null
VIVADORET=$?
fi
# Reload driver if desired by user
if [ "$#" -ge 2 ] && [[ $2 == drv_reload || $2 == drv_load ]]
then
sudo insmod $driver_path$driver_name".ko"
sudo chown $calling_user /dev/FFLINK*
fi
# check return code
if [ $VIVADORET -ne 0 ]; then
echo "programming failed, Vivado returned non-zero exit code $VIVADORET"
exit $VIVADORET
fi
echo "bitstream programmed successfully!"
# hotplug the bus
hotplug
# End
# Output last kernel messages regarding fflink and hotplug, if second parameter is verbose
if [ "$#" -ge 3 ] && [ $3 == verbose ]
then
dmesg | tail -7 | grep -iE $log_id
# reload driver?
if [ $RELOADD -gt 0 ]; then
sudo insmod $driver_path$driver_name".ko"
sudo chown $USER /dev/FFLINK*
fi
# output tail of dmesg in verbose mode
if [ $VERBOSE -gt 0 ]; then
dmesg | tail -7 | grep -iE $LOG_ID
fi
else
show_usage
exit 1
fi
#!/bin/bash
#
# Copyright (C) 2014 David de la Chevallerie, TU Darmstadt
#
# This file is part of Tapasco (TPC).
#
# Tapasco is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Tapasco is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Tapasco. If not, see <http://www.gnu.org/licenses/>.
#
#set -x
#PATH=$PATH:/sbin
VENDOR=10EE
DEVICE=7038
PCIEDEVICE=`lspci -d $VENDOR:$DEVICE | sed -e "s/ .*//"`
# Look for device, if it exists and remove it (cause its from previous run)
if [ "$PCIEDEVICE" != "" ]; then
sh -c "echo 1 >/sys/bus/pci/devices/0000:$PCIEDEVICE/remove"
#sh -c "echo 1 >/sys/bus/pci/devices/0000:02:00.0/remove"
fi
# Scan for new hotplugable device, like the one may deleted before
sh -c "echo 1 >/sys/bus/pci/rescan"
#
# Copyright (C) 2014 David de la Chevallerie, TU Darmstadt
# Copyright (C) 2017 Jens Korinth, TU Darmstadt
#
# This file is part of Tapasco (TPC).
#
......@@ -19,50 +19,77 @@
## Download a bit file to the FPGA on the VC709
#set default values
set dev_sel 0
set wait_intv 1000
set wait 1000
set dev {xc7vx690t_0}
set probes_file {}
set program_file {design_1_wrapper.bit}
set program_file {}
set devid -1
set target {}
# override default values from tclargs
if { $argc == 1 } {
set program_file [lindex $argv 0]
puts "Using $program_file as bitstream"
} else { if { $argc == 2 } {
set program_file [lindex $argv 0]
set probes_file [lindex $argv 1]
puts "Using $program_file as bitstream"
puts "Using $probe_file for probes"
if { $argc > 0 } {
set program_file [lindex $argv 0]
puts "using $program_file as bitstream"
if { $argc > 1 } {
set probes_file [lindex $argv 1]
puts "using $probe_file for probes"
}
} else {
puts "Using default values for bitstream and no probes"
} }
puts "no bitstream file given, aborting"
exit 1
}
## Opening hardware and refresh to actual status (ignoring probes)
open_hw
connect_hw_server
proc init {} {
open_hw
connect_hw_server
}
current_hw_target [lindex [get_hw_targets -of_objects [get_hw_servers localhost]] $dev_sel]
set_property PARAM.FREQUENCY 30000000 [current_hw_target]
open_hw_target [current_hw_target]
proc deinit {{retcode 0}} {
disconnect_hw_server
close_hw
exit $retcode
}
current_hw_device [lindex [get_hw_devices] $dev_sel]
refresh_hw_device -update_hw_probes false [current_hw_device]
# open server
init
## Set download a bit file
set_property PROBES.FILE $probes_file [current_hw_device]
set_property PROGRAM.FILE $program_file [current_hw_device]
foreach t [get_hw_targets] {
puts "opening target $t ..."
open_hw_target $t
set devid [lsearch [get_hw_devices] $dev]
close_hw_target $t
if {$devid >= 0} {
set target $t
puts "found VX690T @ $target:$devid"
break;
}
}
## Program device and refresh after short delay to allow ILA-Core to be seen
program_hw_devices [current_hw_device]
# check if device was found
if { $devid >= 0 } {
puts "programming $target:$devid ..."
current_hw_target $target
set_property PARAM.FREQUENCY 30000000 [current_hw_target]
open_hw_target [current_hw_target]
current_hw_device $dev
after $wait_intv
refresh_hw_device [current_hw_device]
# set bitstream file
set_property PROGRAM.FILE $program_file [current_hw_device]
# set probes file (if any)
set_property PROBES.FILE $probes_file [current_hw_device]
## Close everything
close_hw_target
disconnect_hw_server
close_hw
## program device
program_hw_devices [current_hw_device]
exit
if { $probes_file != {} } {
puts "waiting for ILA core to appear ..."
after $wait
refresh_hw_device [current_hw_device]
}
## close everything
close_hw_target
deinit
} else {
puts "could not find xc7vx690t_0 device, aborting."
deinit 1
}
......@@ -17,24 +17,55 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Tapasco. If not, see <http://www.gnu.org/licenses/>.
#
BITSTREAM=$1
if [[ "$BITSTREAM" != /* ]]; then
BITSTREAM=$PWD/$BITSTREAM
fi
if [[ -e $BITSTREAM ]]; then
pushd $TAPASCO_HOME/platform/zynq/module
if [[ `lsmod | grep tapasco | wc -l` -eq 1 ]]; then
sudo ./unload.sh
fi
echo "Loading bitstream $BITSTREAM ..."
sudo sh -c "cat $BITSTREAM > /dev/xdevcfg"
echo "Done!"
echo "Loading kernel module ..."
sudo ./load.sh
popd
echo "Done."
show_usage() {
cat << EOF
Usage: ${0##*/} [-v|--verbose] [--d|--drv-reload] BITSTREAM
Program FPGA via /dev/xdevcfg.
-v enable verbose output
-d reload device driver
EOF
}
# init vars
BITSTREAM=""
VERBOSE=0
RELOADD=1
OPTIND=1
while getopts vd opt; do
case $opt in
v)
VERBOSE=1
;;
d)
RELOADD=1
;;
*)
echo "unknown option: $opt"
show_usage
exit 1
;;
esac
done
shift "$((OPTIND-1))"
BITSTREAM="$1"
if [ -n $BITSTREAM ] && [[ $BITSTREAM == *.bit ]] && [[ -e $BITSTREAM ]]
then
pushd $TAPASCO_HOME/platform/zynq/module
if [[ `lsmod | grep tapasco | wc -l` -eq 1 ]]; then
sudo ./unload.sh
fi
echo "Loading bitstream $BITSTREAM ..."
sudo sh -c "cat $BITSTREAM > /dev/xdevcfg"
echo "Done!"
echo "Loading kernel module ..."
sudo ./load.sh
popd
echo "Done."
else
echo "ERROR: $BITSTREAM does not exist"
show_usage
exit 1
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment