Files
stm32f103_spl_clion/tools/debug-server.sh
2026-08-10 23:36:24 +08:00

31 lines
1.2 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# ============================================================
# 启动 ST-LINK GDB Server供 CLion 的 Embedded/Remote GDB Server 调试连接
#
# 用法:
# 1) 接好 ST-Link (SWD), 给板子供电
# 2) 运行本脚本 (CLion 里点 "Debug-Server" 运行配置, 或终端 bash tools/debug-server.sh)
# 3) 在 CLion 调试配置里用 target remote localhost:61234 连接
#
# GDB Server : ST-LINK_gdbserver (CubeCLT 自带)
# 连接模式 : under-reset (-m 0) —— 对 F103 最稳, 能抓复位/卡死态
# ============================================================
set -e
CLT="/c/ST/STM32CubeCLT_1.18.0"
GDBSERVER="$CLT/STLink-gdb-server/bin/ST-LINK_gdbserver.exe"
CP="$CLT/STM32CubeProgrammer/bin" # Connection Bridge: 提供 ST-LINK 驱动桥接, 必需
if [ ! -x "$GDBSERVER" ]; then
echo "找不到 ST-LINK_gdbserver.exe: $GDBSERVER" >&2
echo "请确认 STM32CubeCLT 已安装在 $CLT" >&2
exit 1
fi
echo "==[ ST-LINK GDB Server 启动 ]=="
echo "==[ 监听 :61234 连接模式 under-reset ]=="
echo "==[ 在 CLion 调试配置里 target remote localhost:61234 连接 ]=="
echo "==[ Ctrl+C 退出 ]=="
echo "----------------------------------------------------------------"
exec "$GDBSERVER" -cp "$CP" -p 61234 -m 0