Commit 3ebb1fd0 authored by Jaco Hofmann's avatar Jaco Hofmann
Browse files

Add mode flag to load bitstream script

    - 'program' to only program without hotplug (not used on zynq)
    - 'hotplug' to only hotplug without program
    - 'normal' which issues both
    - Closes #108
parent 09c2d74c
Pipeline #653 passed with stage
in 8 minutes and 44 seconds
......@@ -9,6 +9,7 @@ parser = argparse.ArgumentParser()
parser.add_argument('bitstream', help='.bit file to load')
parser.add_argument('--reload-driver', help='reload driver, if loaded (default: %(default)s)', action='store_true')
parser.add_argument('--verbose', help='verbose output (default: %(default)s)', action='store_true')
parser.add_argument('--mode', help='select the operation to be performed (default: %(default)s)', default='normal', choices=['normal', 'program', 'hotplug'])
args = parser.parse_args()
if not os.path.exists(args.bitstream):
......@@ -29,5 +30,7 @@ if args.verbose:
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)
program = '-h' if args.mode == 'normal' or args.mode == 'program' else ''
hotplug = '-p' if args.mode == 'normal' or args.mode == 'hotplug' else ''
cmd = '$TAPASCO_HOME/platform/$TAPASCO_PLATFORM/{0}bit_reload.sh {1} {2} {3} {4} {5} {6}'.format(path, verb, reld, hotplug, program, args.bitstream)
subprocess.call([cmd], shell=True)
......@@ -36,6 +36,8 @@ Program first supported PCIe based FPGA found in JTAG chain with BITSTREAM.
-v enable verbose output
-d reload device driver
-p program the device
-h hotplug the device
EOF
}
......@@ -69,6 +71,8 @@ hotplug() {
BITSTREAM=""
VERBOSE=0
RELOADD=0
HOTPLUG=0
PROGRAM=0
OPTIND=1
while getopts vd opt; do
......@@ -79,6 +83,12 @@ while getopts vd opt; do
d)
RELOADD=1
;;
h)
HOTPLUG=1
;;
p)
PROGRAM=1
;;
*)
echo "unknown option: $opt"
show_usage
......@@ -99,24 +109,30 @@ then
fi
# 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 a while ..."
vivado -nolog -nojournal -notrace -mode batch -source $BITLOAD_SCRIPT -tclargs $BITSTREAM > /dev/null
VIVADORET=$?
fi
if [ $PROGRAM -gt 0 ]; then
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 a while ..."
vivado -nolog -nojournal -notrace -mode batch -source $BITLOAD_SCRIPT -tclargs $BITSTREAM > /dev/null
VIVADORET=$?
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!"
# 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
if [ $HOTPLUG -gt 0 ]; then
# hotplug the bus
hotplug
fi
# reload driver?
if [ $RELOADD -gt 0 ]; then
......
......@@ -41,6 +41,8 @@ EOF
BITSTREAM=""
VERBOSE=0
RELOADD=0
HOTPLUG=0
PROGRAM=0
OPTIND=1
while getopts vd opt; do
......@@ -51,6 +53,12 @@ while getopts vd opt; do
d)
RELOADD=1
;;
h)
HOTPLUG=1
;;
p)
PROGRAM=1
;;
*)
echo "unknown option: $opt"
show_usage
......@@ -65,7 +73,9 @@ if [ -n $BITSTREAM ] && [[ $BITSTREAM == *.bit ]]
then
echo "bitstream = $BITSTREAM"
(lsmod | grep $DRIVER > /dev/null) && sudo rmmod $DRIVER 2> /dev/null
if [ $RELOADD -gt 0 ]; then
(lsmod | grep $DRIVER > /dev/null) && sudo rmmod $DRIVER 2> /dev/null
fi
# program the device
cat $BITSTREAM > /dev/xdevcfg
......@@ -78,8 +88,10 @@ then
fi
echo "bitstream programmed successfully!"
# load driver
sudo insmod $DRIVERPATH/${DRIVER}.ko
if [ $RELOADD -gt 0 ]; then
# load driver
sudo insmod $DRIVERPATH/${DRIVER}.ko
fi
else
show_usage
exit 1
......
Supports Markdown
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