#!/bin/sh # SPDX-License-Identifier: Apache-2.0 # The power campaign, in a fixed order: the run/halt step response, a known-answer vehicle where one # is present, a null, each job class, then the clock-scaling check. Run ON the board as root, # detached, and touch nothing on the board until DONE appears (the meter reads the whole board, the # processor included): # sudo setsid nohup sh power_campaign.sh [OUTDIR] > /dev/null 2>&1 & # Needs wai-quantum-landscape-fpga and the loaded engine. A known-answer vehicle of your own goes in # KNOWN_ANSWER (a script taking the bitstream name, settle, passes and samples, printing # "pass run|halt sample microwatts" lines) and KNOWN_BITSTREAM; without them that step is skipped, # and the null and the clock-scaling check are the instrument's checks. cd "$(dirname "$0")" OUT=${1:-power-$(date -u +%Y%m%dT%H%M%SZ)}/power; mkdir -p "$OUT" BIT=${ENGINE_BITSTREAM:-landscape.bit.bin} log() { echo "$(date -u +%FT%TZ) $*" >> "$OUT/campaign.log"; } guard() { # the tool leaves out itself and what it descends from: this script, and run_all.sh if that started it f=$(./wai-quantum-landscape-fpga foreign) || { log "STOP: another session is on the board: $f"; echo STOPPED > "$OUT/DONE"; exit 3; } } log "start; $(./wai-quantum-landscape-fpga status 2>&1 | tr '\n' ' ')" guard ./wai-quantum-landscape-fpga meter t0-recall 1 0 300 > "$OUT/step.dat" 2>&1; log "step done" if [ -n "${KNOWN_ANSWER:-}" ] && [ -n "${KNOWN_BITSTREAM:-}" ]; then guard sh "$KNOWN_ANSWER" "$KNOWN_BITSTREAM" 60 8 30 > "$OUT/known_answer.dat" 2>&1; log "known answer done exit=$?" [ -d /sys/class/gpio/gpio594 ] && echo 594 > /sys/class/gpio/unexport ./wai-quantum-landscape-fpga load "$BIT" >> "$OUT/campaign.log" 2>&1 || { log "reload of the engine failed"; echo FAILED > "$OUT/DONE"; exit 2; } else log "known answer skipped: KNOWN_ANSWER and KNOWN_BITSTREAM not set" fi for spec in "null:t0-recall 8 60 30 --null --predict 0" "t0-recall:t0-recall 10 60 30 --predict 160" \ "gibbs-recall:gibbs-recall 10 60 30 --predict 12" "t0-idle:t0-idle 8 60 30 --predict 4"; do name=${spec%%:*}; args=${spec#*:} guard ./wai-quantum-landscape-fpga meter $args > "$OUT/$name.dat" 2>&1; log "$name done exit=$?" done guard ./wai-quantum-landscape-fpga clock 30 >> "$OUT/campaign.log" 2>&1 ./wai-quantum-landscape-fpga meter t0-recall 6 60 30 --predict 80 > "$OUT/t0-recall-50MHz.dat" 2>&1; log "50 MHz done exit=$?" ./wai-quantum-landscape-fpga clock 15 >> "$OUT/campaign.log" 2>&1 log "end" echo DONE > "$OUT/DONE"