2020-04-11 21:12:16 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2021-06-25 17:03:55 +08:00
|
|
|
# Only ZC706 supported for now.
|
|
|
|
|
2020-04-11 21:12:16 +08:00
|
|
|
set -e
|
|
|
|
|
2020-09-09 18:44:12 +08:00
|
|
|
if [ -z "$OPENOCD_ZYNQ" ]; then
|
|
|
|
echo "OPENOCD_ZYNQ environment variable must be set"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "$SZL" ]; then
|
|
|
|
echo "SZL environment variable must be set"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-05-01 10:07:38 +08:00
|
|
|
target_host="rpi-4.m-labs.hk"
|
|
|
|
impure=0
|
2020-07-04 17:27:21 +08:00
|
|
|
pure_dir="result"
|
|
|
|
impure_dir="build"
|
2020-07-04 23:41:28 +08:00
|
|
|
sshopts=""
|
2020-07-06 11:06:18 +08:00
|
|
|
load_bitstream=1
|
2020-09-01 09:41:02 +08:00
|
|
|
board_host="192.168.1.52"
|
2021-10-05 15:53:07 +08:00
|
|
|
fw_type="runtime"
|
2020-04-11 21:12:16 +08:00
|
|
|
|
2021-10-05 15:53:07 +08:00
|
|
|
while getopts "h:id:o:lt:" opt; do
|
2020-05-01 10:07:38 +08:00
|
|
|
case "$opt" in
|
2020-07-04 17:54:03 +08:00
|
|
|
\?) exit 1
|
2020-05-01 10:07:38 +08:00
|
|
|
;;
|
|
|
|
h) target_host=$OPTARG
|
|
|
|
;;
|
|
|
|
i) impure=1
|
|
|
|
;;
|
2020-07-04 17:27:21 +08:00
|
|
|
d) pure_dir=$OPTARG;
|
|
|
|
impure_dir=$OPTARG;
|
|
|
|
;;
|
2020-07-04 23:41:28 +08:00
|
|
|
o) sshopts=$OPTARG
|
|
|
|
;;
|
2020-07-06 11:06:18 +08:00
|
|
|
l) load_bitstream=0
|
|
|
|
;;
|
2020-09-01 09:41:02 +08:00
|
|
|
b) board_host=$OPTARG
|
|
|
|
;;
|
2021-10-05 15:53:07 +08:00
|
|
|
t) fw_type=$OPTARG
|
|
|
|
;;
|
2020-05-01 10:07:38 +08:00
|
|
|
esac
|
|
|
|
done
|
2020-04-11 21:12:16 +08:00
|
|
|
|
2020-07-04 23:53:17 +08:00
|
|
|
target_folder="/tmp/zynq-$USER"
|
2020-07-06 11:06:18 +08:00
|
|
|
load_bitstream_cmd=""
|
2020-05-01 10:07:38 +08:00
|
|
|
|
2020-07-04 17:44:58 +08:00
|
|
|
echo "Creating $target_folder..."
|
2020-07-04 23:41:28 +08:00
|
|
|
ssh $sshopts $target_host "mkdir -p $target_folder"
|
2020-07-04 17:44:58 +08:00
|
|
|
echo "Copying files..."
|
2020-09-09 18:44:12 +08:00
|
|
|
rsync -e "ssh $sshopts" -Lc $OPENOCD_ZYNQ/* $target_host:$target_folder
|
2021-06-25 17:03:55 +08:00
|
|
|
rsync -e "ssh $sshopts" -Lc $SZL/szl-zc706.elf $target_host:$target_folder/szl.elf
|
2020-05-01 10:07:38 +08:00
|
|
|
if [ $impure -eq 1 ]; then
|
2020-07-06 11:06:18 +08:00
|
|
|
if [ $load_bitstream -eq 1 ]; then
|
2020-09-01 09:41:02 +08:00
|
|
|
load_bitstream_cmd="-g build/gateware/top.bit"
|
2020-07-06 11:06:18 +08:00
|
|
|
fi
|
2021-10-05 15:53:07 +08:00
|
|
|
firmware="build/$fw_type.bin"
|
2020-05-01 10:07:38 +08:00
|
|
|
else
|
2020-07-06 11:06:18 +08:00
|
|
|
if [ $load_bitstream -eq 1 ]; then
|
2020-09-01 17:27:29 +08:00
|
|
|
load_bitstream_cmd="-g $pure_dir/top.bit"
|
2020-07-06 11:06:18 +08:00
|
|
|
fi
|
2021-10-05 15:53:07 +08:00
|
|
|
firmware="$pure_dir/$fw_type.bin"
|
2020-05-01 10:07:38 +08:00
|
|
|
fi
|
2020-07-04 17:44:58 +08:00
|
|
|
echo "Programming board..."
|
2020-09-01 09:41:02 +08:00
|
|
|
ssh $sshopts $target_host "cd $target_folder; openocd -f zc706.cfg -c'load_image szl.elf; resume 0; exit'"
|
|
|
|
sleep 5
|
|
|
|
artiq_netboot $load_bitstream_cmd -f $firmware -b $board_host
|