artiq-zynq/remote_run.sh

57 lines
1.4 KiB
Bash
Raw Normal View History

2020-04-11 21:12:16 +08:00
#!/usr/bin/env bash
set -e
target_host="rpi-4.m-labs.hk"
impure=0
pure_dir="result"
impure_dir="build"
sshopts=""
load_bitstream=1
2020-09-01 09:41:02 +08:00
board_host="192.168.1.52"
2020-04-11 21:12:16 +08:00
while getopts "h:id:o:l" opt; do
case "$opt" in
\?) exit 1
;;
h) target_host=$OPTARG
;;
i) impure=1
;;
d) pure_dir=$OPTARG;
impure_dir=$OPTARG;
;;
o) sshopts=$OPTARG
;;
l) load_bitstream=0
;;
2020-09-01 09:41:02 +08:00
b) board_host=$OPTARG
;;
esac
done
2020-04-11 21:12:16 +08:00
2020-07-04 23:53:17 +08:00
target_folder="/tmp/zynq-$USER"
load_bitstream_cmd=""
2020-07-04 17:44:58 +08:00
echo "Creating $target_folder..."
ssh $sshopts $target_host "mkdir -p $target_folder"
2020-07-04 17:44:58 +08:00
echo "Copying files..."
rsync -e "ssh $sshopts" openocd/* $target_host:$target_folder
if [ $impure -eq 1 ]; then
if [ $load_bitstream -eq 1 ]; then
2020-09-01 09:41:02 +08:00
load_bitstream_cmd="-g build/gateware/top.bit"
fi
2020-09-01 09:41:02 +08:00
firmware="build/runtime.bin"
rsync -e "ssh $sshopts" $impure_dir/firmware/armv7-none-eabihf/debug/szl $target_host:$target_folder/szl.elf
else
if [ $load_bitstream -eq 1 ]; then
2020-09-01 09:41:02 +08:00
load_bitstream_cmd="-g result/top.bit"
fi
2020-09-01 09:41:02 +08:00
firmware="result/runtime.bin"
rsync -e "ssh $sshopts" -Lc $pure_dir/szl.elf $target_host:$target_folder
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