zynq: lock board for HITL tests

This commit is contained in:
Sebastien Bourdeauducq 2021-08-04 10:37:16 +08:00
parent ca6111d0f5
commit f773b5abeb
1 changed files with 38 additions and 20 deletions

View File

@ -36,6 +36,24 @@ in
buildPhase = buildPhase =
'' ''
export NIX_SSHOPTS="-F /dev/null -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR -i /opt/hydra_id_rsa"
LOCKCTL=$(mktemp -d)
mkfifo $LOCKCTL/lockctl
cat $LOCKCTL/lockctl | ${pkgs.openssh}/bin/ssh \
$NIX_SSHOPTS \
rpi-4 \
'mkdir -p /tmp/board_lock && flock /tmp/board_lock/zc706-1 -c "echo Ok; cat"' \
| (
# End remote flock via FIFO
atexit_unlock() {
echo > $LOCKCTL/lockctl
}
trap atexit_unlock EXIT
# Read "Ok" line when remote successfully locked
read LOCK_OK
echo Power cycling board... echo Power cycling board...
(echo b; sleep 5; echo B; sleep 5) | nc -N -w6 192.168.1.31 3131 (echo b; sleep 5; echo B; sleep 5) | nc -N -w6 192.168.1.31 3131
echo Power cycle done. echo Power cycle done.
@ -44,7 +62,6 @@ in
export OPENOCD_ZYNQ=${artiq-zynq.zynq-rs}/openocd export OPENOCD_ZYNQ=${artiq-zynq.zynq-rs}/openocd
export SZL=${szlEnv} export SZL=${szlEnv}
pushd ${<artiq-zynq>} pushd ${<artiq-zynq>}
export NIX_SSHOPTS="-F /dev/null -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR -i /opt/hydra_id_rsa"
bash ${<artiq-zynq>}/remote_run.sh -h rpi-4 -o "$NIX_SSHOPTS" -d ${artiq-zynq.zc706-nist_qc2-jtag} bash ${<artiq-zynq>}/remote_run.sh -h rpi-4 -o "$NIX_SSHOPTS" -d ${artiq-zynq.zc706-nist_qc2-jtag}
popd popd
@ -63,6 +80,7 @@ in
(echo b; sleep 5) | nc -N -w6 192.168.1.31 3131 (echo b; sleep 5) | nc -N -w6 192.168.1.31 3131
echo Board powered off echo Board powered off
)
''; '';
}); });
} }