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

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: ...@@ -26,8 +26,8 @@ if args.verbose:
print 'Reload Driver: {0}'.format(str(args.reload_driver)) print 'Reload Driver: {0}'.format(str(args.reload_driver))
print 'Platform: {0}'.format(os.environ['TAPASCO_PLATFORM']) print 'Platform: {0}'.format(os.environ['TAPASCO_PLATFORM'])
path = 'module/hotplug_stuff/' if os.environ['TAPASCO_PLATFORM'] is 'vc709' else 'module/' path = 'module/'
reld = 'drv_reload' if args.reload_driver else '' reld = '-d' if args.reload_driver else ''
verb = 'verbose' if args.reload_driver and args.verbose else '' verb = '-v' if args.verbose else ''
cmd = '$TAPASCO_HOME/platform/$TAPASCO_PLATFORM/{0}bit_reload.sh {1} {2} {3}'.format(path, args.bitstream, reld, verb) cmd = '$TAPASCO_HOME/platform/$TAPASCO_PLATFORM/{0}bit_reload.sh {1} {2} {3}'.format(path, verb, reld, args.bitstream)
subprocess.call([cmd], shell=True) subprocess.call([cmd], shell=True)
#!/bin/bash #!/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). # This file is part of Tapasco (TPC).
# #
...@@ -23,64 +23,100 @@ ...@@ -23,64 +23,100 @@
# Script usage e.g. ./bit_reload 'path_to_bitstream' drv_reload verbose # Script usage e.g. ./bit_reload 'path_to_bitstream' drv_reload verbose
# Pathes '*_path' have to be adapted to specific location # Pathes '*_path' have to be adapted to specific location
# Source vivado scripts for programming # init paths
source /opt/cad/xilinx/vivado/Vivado/2015.2/settings64.sh DRIVER=ffLink
BITLOAD_SCRIPT="$TAPASCO_HOME/platform/vc709/module/program_vc709.tcl"
LOG_ID=$DRIVER"|""pci"
# save current user name show_usage() {
calling_user=`echo $USER` cat << EOF
Usage: ${0##*/} [-v|--verbose] [--d|--drv-reload] BITSTREAM
Program first VC709 found in JTAG chain with BITSTREAM.
# Pathes to needed files -v enable verbose output
driver_name="ffLink" -d reload device driver
driver_path="$TAPASCO_HOME/platform/vc709/module/" EOF
}
hotplug_script_name="hotplug.sh" hotplug() {
hotplug_script_path="$driver_path/hotplug_stuff/" 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" # Scan for new hotplugable device, like the one may deleted before
bitload_script_path="$hotplug_script_path" 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 OPTIND=1
bitstream_file="sobel-memloc.bd.bit" while getopts vd opt; do
if [ "$#" -ge 1 ] && [[ $1 == *.bit ]] case $opt in
then v)
bitstream_file=$1 VERBOSE=1
echo "Using user given bitstream:" $bitstream_file ;;
else d)
echo "Using default bitstream:" $bitstream_file RELOADD=1
fi ;;
*)
echo "unknown option: $opt"
show_usage
exit 1
;;
esac
done
shift "$((OPTIND-1))"
# Unload the driver if desired by user BITSTREAM="$1"
if [ "$#" -ge 2 ] && [[ $2 == drv_reload ]] if [ -n $BITSTREAM ] && [[ $BITSTREAM == *.bit ]]
then then
sudo rmmod $driver_name echo "bitstream = $BITSTREAM"
fi
# Program device # unload driver, if second arg is "drv_reload"
if [ "$#" -ge 3 ] && [ $3 == verbose ] if [ -n "$2" ] && [[ "$2" == drv_reload ]]; then
then sudo rmmod $DRIVER
vivado -nolog -nojournal -mode tcl -notrace -source $bitload_script_path$bitload_script_name -tclargs $bitstream_file fi
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
# Hotplug pcie-bus # program the device
sudo sh $hotplug_script_path$hotplug_script_name if [ $VERBOSE -gt 0 ]; then
echo "Hotplugging finished" 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 # check return code
if [ "$#" -ge 2 ] && [[ $2 == drv_reload || $2 == drv_load ]] if [ $VIVADORET -ne 0 ]; then
then echo "programming failed, Vivado returned non-zero exit code $VIVADORET"
sudo insmod $driver_path$driver_name".ko" exit $VIVADORET
sudo chown $calling_user /dev/FFLINK* fi
fi echo "bitstream programmed successfully!"
# hotplug the bus
hotplug
# End # reload driver?
# Output last kernel messages regarding fflink and hotplug, if second parameter is verbose if [ $RELOADD -gt 0 ]; then
if [ "$#" -ge 3 ] && [ $3 == verbose ] sudo insmod $driver_path$driver_name".ko"
then sudo chown $USER /dev/FFLINK*
dmesg | tail -7 | grep -iE $log_id 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 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). # This file is part of Tapasco (TPC).
# #
...@@ -19,50 +19,77 @@ ...@@ -19,50 +19,77 @@
## Download a bit file to the FPGA on the VC709 ## Download a bit file to the FPGA on the VC709
#set default values #set default values
set dev_sel 0 set wait 1000
set wait_intv 1000 set dev {xc7vx690t_0}
set probes_file {} 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 > 0 } {
if { $argc == 1 } { set program_file [lindex $argv 0]
set program_file [lindex $argv 0] puts "using $program_file as bitstream"
puts "Using $program_file as bitstream" if { $argc > 1 } {
set probes_file [lindex $argv 1]
} else { if { $argc == 2 } { puts "using $probe_file for probes"
set program_file [lindex $argv 0] }
set probes_file [lindex $argv 1]
puts "Using $program_file as bitstream"
puts "Using $probe_file for probes"
} else { } 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) proc init {} {
open_hw open_hw
connect_hw_server connect_hw_server
}
current_hw_target [lindex [get_hw_targets -of_objects [get_hw_servers localhost]] $dev_sel] proc deinit {{retcode 0}} {
set_property PARAM.FREQUENCY 30000000 [current_hw_target] disconnect_hw_server
open_hw_target [current_hw_target] close_hw
exit $retcode
}
current_hw_device [lindex [get_hw_devices] $dev_sel] # open server
refresh_hw_device -update_hw_probes false [current_hw_device] init
## Set download a bit file foreach t [get_hw_targets] {
set_property PROBES.FILE $probes_file [current_hw_device] puts "opening target $t ..."
set_property PROGRAM.FILE $program_file [current_hw_device] 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 # check if device was found
program_hw_devices [current_hw_device] 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 # set bitstream file
refresh_hw_device [current_hw_device] 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 ## program device
close_hw_target program_hw_devices [current_hw_device]
disconnect_hw_server
close_hw
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 @@ ...@@ -17,24 +17,55 @@
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with Tapasco. If not, see <http://www.gnu.org/licenses/>. # along with Tapasco. If not, see <http://www.gnu.org/licenses/>.
# #
BITSTREAM=$1
if [[ "$BITSTREAM" != /* ]]; then
BITSTREAM=$PWD/$BITSTREAM
fi
if [[ -e $BITSTREAM ]]; then show_usage() {
pushd $TAPASCO_HOME/platform/zynq/module cat << EOF
if [[ `lsmod | grep tapasco | wc -l` -eq 1 ]]; then Usage: ${0##*/} [-v|--verbose] [--d|--drv-reload] BITSTREAM
sudo ./unload.sh Program FPGA via /dev/xdevcfg.
fi
echo "Loading bitstream $BITSTREAM ..." -v enable verbose output
sudo sh -c "cat $BITSTREAM > /dev/xdevcfg" -d reload device driver
echo "Done!" EOF
echo "Loading kernel module ..." }
sudo ./load.sh
popd # init vars
echo "Done." 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 else
echo "ERROR: $BITSTREAM does not exist" show_usage
exit 1
fi 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