nix-scripts/artiq-zynq.nix

85 lines
2.7 KiB
Nix
Raw Permalink Normal View History

2020-05-03 07:45:54 +08:00
let
pkgs = import <nixpkgs> { overlays = [ (import ./artiq-fast/mozilla-overlay.nix) ]; };
artiq-zynq = import <artiq-zynq>;
2020-07-04 23:56:57 +08:00
artiq-fast = import <artiq-fast> { inherit pkgs; };
2020-05-03 07:45:54 +08:00
in
2020-05-03 09:46:28 +08:00
(
builtins.mapAttrs (key: value: pkgs.lib.hydraJob value) artiq-zynq
2020-07-04 17:27:42 +08:00
) // {
2020-07-13 19:05:50 +08:00
gateware-sim = pkgs.lib.hydraJob (pkgs.stdenv.mkDerivation {
name = "gateware-sim";
buildInputs = [ artiq-fast.migen artiq-fast.migen-axi artiq-fast.artiq ];
phases = [ "buildPhase" ];
buildPhase =
''
python -m unittest discover ${<artiq-zynq>}/src/gateware -v
touch $out
'';
});
zc706-hitl-tests = pkgs.lib.hydraJob (pkgs.stdenv.mkDerivation {
2020-07-04 17:27:42 +08:00
name = "zc706-hitl-tests";
__networked = true; # compatibility with old patched Nix
2022-06-04 13:30:38 +08:00
# breaks hydra, https://github.com/NixOS/hydra/issues/1216
#__impure = true; # Nix 2.8+
2020-07-04 17:27:42 +08:00
buildInputs = [
pkgs.netcat pkgs.openssh pkgs.rsync artiq-fast.artiq artiq-fast.artiq-netboot
2020-07-04 17:27:42 +08:00
];
phases = [ "buildPhase" ];
2021-07-07 18:13:40 +08:00
buildPhase =
2020-07-04 17:27:42 +08:00
''
2021-12-03 18:36:41 +08:00
export NIX_SSHOPTS="-F /dev/null -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR -i /opt/hydra_id_ed25519"
2021-08-04 10:37:16 +08:00
LOCKCTL=$(mktemp -d)
mkfifo $LOCKCTL/lockctl
2020-07-04 17:27:42 +08:00
2021-08-04 10:37:16 +08:00
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
2020-07-04 23:56:57 +08:00
2021-08-04 10:37:16 +08:00
# Read "Ok" line when remote successfully locked
read LOCK_OK
2020-07-04 23:56:57 +08:00
2021-08-04 10:37:16 +08:00
echo Power cycling board...
(echo b; sleep 5; echo B; sleep 5) | nc -N -w6 192.168.1.31 3131
echo Power cycle done.
2020-09-01 17:53:07 +08:00
2021-08-04 10:37:16 +08:00
export USER=hydra
export OPENOCD_ZYNQ=${artiq-zynq.zynq-rs}/openocd
2022-03-05 18:46:40 +08:00
export SZL=${(import artiq-zynq.zynq-rs).zc706-szl}/szl.elf
2021-08-04 10:37:16 +08:00
pushd ${<artiq-zynq>}
bash ${<artiq-zynq>}/remote_run.sh -h rpi-4 -o "$NIX_SSHOPTS" -d ${artiq-zynq.zc706-nist_qc2-jtag}
popd
echo Waiting for the firmware to boot...
sleep 15
echo Running test kernel...
artiq_run --device-db ${<artiq-zynq>}/examples/device_db.py ${<artiq-zynq>}/examples/mandelbrot.py
echo Running ARTIQ unit tests...
2021-08-04 10:40:37 +08:00
export ARTIQ_ROOT=${<artiq-zynq>}/examples
export ARTIQ_LOW_LATENCY=1
python -m unittest discover artiq.test.coredevice -v
2021-08-04 10:37:16 +08:00
touch $out
2021-08-04 10:37:16 +08:00
echo Completed
2020-11-10 22:49:07 +08:00
2021-08-04 10:37:16 +08:00
(echo b; sleep 5) | nc -N -w6 192.168.1.31 3131
echo Board powered off
)
2020-07-04 17:27:42 +08:00
'';
});
}