rust-pitaya/remote_run.sh

65 lines
1.5 KiB
Bash
Raw Normal View History

2020-10-14 15:56:10 +08:00
#!/usr/bin/env bash
set -e
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
2022-08-30 18:59:53 +08:00
target_host="rpi-3.m-labs.hk"
2020-10-14 15:56:10 +08:00
impure=0
pure_dir="result"
impure_dir="build"
sshopts=""
load_bitstream=1
2020-10-14 21:34:49 +08:00
board_host="192.168.1.55"
2020-10-14 15:56:10 +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
;;
b) board_host=$OPTARG
;;
esac
done
target_folder="/tmp/zynq-$USER"
load_bitstream_cmd=""
echo "Creating $target_folder..."
ssh $sshopts $target_host "mkdir -p $target_folder"
echo "Copying files..."
rsync -e "ssh $sshopts" -Lc $OPENOCD_ZYNQ/* $target_host:$target_folder
2022-08-29 22:14:58 +08:00
rsync -e "ssh $sshopts" -Lc $SZL/szl-redpitaya.elf $target_host:$target_folder
2020-10-14 15:56:10 +08:00
if [ $impure -eq 1 ]; then
if [ $load_bitstream -eq 1 ]; then
load_bitstream_cmd="-g build/gateware/top.bit"
fi
2020-10-14 21:34:49 +08:00
firmware="build/firmware.bin"
2020-10-14 15:56:10 +08:00
else
if [ $load_bitstream -eq 1 ]; then
load_bitstream_cmd="-g $pure_dir/top.bit"
fi
2020-10-14 21:34:49 +08:00
firmware="$pure_dir/firmware.bin"
2020-10-14 15:56:10 +08:00
fi
echo "Programming board..."
2022-08-29 22:14:58 +08:00
ssh $sshopts $target_host "cd $target_folder; openocd -f redpitaya.cfg -c'load_image szl-redpitaya.elf; resume 0; exit'"
2020-10-14 15:56:10 +08:00
sleep 5
artiq_netboot $load_bitstream_cmd -f $firmware -b $board_host