Files
vt1200/bad-apple/tools/load.sh
T

53 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
# Deliver the network-build payload over rdebug, then send movie.bin over UDP.
#
# tools/load.sh --host 192.168.99.2 --movie data/movie.bin
#
# The terminal must be booted and answering ping. The payload calls the OS
# socket API, receives into a malloc'd buffer, then disables interrupts and
# plays. Recovery after that point is a power cycle.
set -eu
HERE=$(cd "$(dirname "$0")" && pwd)
ROOT=$(cd "$HERE/../.." && pwd)
HOST=192.168.99.2
PORT=7001
MOVIE=$ROOT/bad-apple/data/movie.bin
WAIT=180
SETTLE=3
while [ $# -gt 0 ]; do
case "$1" in
--host) HOST=$2; shift 2 ;;
--port) PORT=$2; shift 2 ;;
--movie) MOVIE=$2; shift 2 ;;
--wait) WAIT=$2; shift 2 ;;
--settle) SETTLE=$2; shift 2 ;;
-h|--help) sed -n '2,12p' "$0"; exit 0 ;;
*) echo "load.sh: unknown option $1" >&2; exit 2 ;;
esac
done
if [ ! -f "$MOVIE" ]; then
echo "load.sh: no movie at $MOVIE" >&2
exit 2
fi
start=$(date +%s)
while ! ping -c1 -W1 "$HOST" >/dev/null 2>&1; do
if [ $(( $(date +%s) - start )) -ge "$WAIT" ]; then
echo "load.sh: $HOST did not answer within ${WAIT}s" >&2
exit 1
fi
done
echo "load.sh: $HOST answers"
python3 "$ROOT/harness/badapple/rdebug_load.py" \
--host "$HOST" \
--image "$ROOT/bad-apple/player/build/player-net.bin" \
--env "$ROOT/bad-apple/player/build/player-net.env"
sleep "$SETTLE"
python3 "$HERE/send_movie.py" --host "$HOST" --port "$PORT" --movie "$MOVIE"
echo "load.sh: sent; the screen is the evidence. Power-cycle to recover."