#!/usr/bin/env bash # Lance ST-LINK_gdbserver pour le debug VS Code / GDB de la STM32H7S78-DK. # # Usage: gcc/gdbserver.sh [port] # # boot Debug du Boot (flash interne 0x08000000), sans loader externe # appli Debug de l'Appli (flash externe 0x70000000), avec le loader externe # pour que "load" puisse programmer la flash OctoSPI # # Options imposees par la carte (cf. AGENTS.md) : -m 1 -k (acces port 1, connexion # sous reset). Sans elles : "Cannot connect to access port 1". # Un seul outil peut tenir le ST-Link : arrete flash.sh / CubeProgrammer avant. set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # shellcheck source=toolchain-env.sh source "$ROOT/gcc/toolchain-env.sh" TARGET="${1:-}" PORT="${2:-61234}" LOADER="$ROOT/gcc/MX66UW1G45G_STM32H7S78-DK.stldr" [[ -x "${ST_GDBSERVER:-}" ]] || { echo "error: ST-LINK_gdbserver introuvable (STM32CubeIDE dans ~/st ?)" >&2; exit 1; } [[ -d "${ST_PROGRAMMER_BIN:-}" ]] || { echo "error: dossier STM32CubeProgrammer introuvable" >&2; exit 1; } ARGS=(-p "$PORT" --swd --halt -m 1 -k -cp "$ST_PROGRAMMER_BIN") case "$TARGET" in boot) ;; appli) ARGS+=(-el "$LOADER") ;; *) echo "usage: $0 [port]" >&2; exit 2 ;; esac # Un ancien serveur reste parfois actif apres un debug interrompu : il tiendrait le ST-Link. pkill -f '[S]T-LINK_gdbserver' 2>/dev/null && sleep 0.5 || true echo ">>> ST-LINK_gdbserver ($TARGET) sur le port $PORT" exec "$ST_GDBSERVER" "${ARGS[@]}"