#!/bin/sh
# Copy Ch361 C18 host data only. Its bootlet words are byte-identical to the loaded C6 core; no RBF is copied.
set -eu

DEST="${1:-terasic@192.168.50.161:~}"
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
DATA="$ROOT/sim/data/top_psmct32_raster_demo"
FILES="
$ROOT/tools/ps2_sh3_sched.c
$DATA/sh3_zs640c18_epochs.txt
$DATA/sh3_zs640c180_tex_lpddr.mem
$DATA/feeder_sh3_zs640c180.mem
$DATA/feeder_sh3_zs640c181.mem
$DATA/feeder_sh3_zs640c182.mem
$DATA/feeder_sh3_zs640c183.mem
$DATA/feeder_sh3_zs640c184.mem
$DATA/feeder_sh3_zs640c185.mem
"

missing=0
for f in $FILES; do
    if [ ! -f "$f" ]; then echo "MISSING: $f" >&2; missing=1; fi
done
if [ "$missing" -ne 0 ]; then
    echo "Regenerate C18 first: make -C sim sh3_zs640c18_fixture" >&2
    exit 1
fi

echo "Copying 9 C18 host/data files -> $DEST"
# shellcheck disable=SC2086
exec scp $FILES "$DEST"
