#!/bin/bash # psp-debug.sh — build (optional), reset, and run Dusk on a live PSP. # # Prerequisites: # usbhostfs_pc running (served from the build-psp/ dir, as host0:). # PSP must be running psplink (visible on PSP screen). # # Usage: # ./scripts/psp-debug.sh # reset + run # ./scripts/psp-debug.sh --build # rebuild via docker first, then run # # PSP stdout streams to this terminal via pspsh (logDebug, printf, etc.). # Run from a real terminal — pspsh needs stdin connected to a TTY. # # IMPORTANT: crashes put the PSP hardware in a bad state. # Always reset before relaunching. If reset doesn't respond, power-cycle the PSP. set -euo pipefail PSPSH="pspsh" PRX_HOST="host0:/Dusk.prx" RESET_SLEEP=3 # ---- rebuild (optional) ----------------------------------------------------- if [[ "${1:-}" == "--build" || "${1:-}" == "-b" ]]; then echo "==> Building PSP (docker)..." "$(dirname "$0")/build-psp-docker.sh" echo "" fi # ---- sanity checks ---------------------------------------------------------- if ! command -v "$PSPSH" &>/dev/null; then echo "ERROR: pspsh not found in PATH" echo " Add /home/yourwishes/pspdev/bin to PATH or set PSPSH= in this script." exit 1 fi if ! nc -z localhost 10000 2>/dev/null; then echo "ERROR: psplink is not reachable on localhost:10000." echo " Ensure usbhostfs_pc is running and the PSP shows the psplink prompt." exit 1 fi # ---- reset any running process ---------------------------------------------- echo "==> Resetting PSP..." "$PSPSH" -e "reset" echo " Waiting ${RESET_SLEEP}s for PSP to settle..." sleep "$RESET_SLEEP" # ---- launch + stream output ------------------------------------------------- # Pre-send the exec command, then relay /dev/tty so pspsh keeps a live stdin. # PSP stdout flows through pspsh directly to this terminal. # Ctrl-C to stop. echo "==> Launching $PRX_HOST" echo " (PSP stdout streams here — Ctrl-C to stop)" echo "------------------------------------------------------------" { printf 'exec %s\n' "$PRX_HOST"; cat /dev/tty; } | "$PSPSH"