first commit
This commit is contained in:
30
tools/debug-server.sh
Normal file
30
tools/debug-server.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/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
|
||||
37
tools/flash.sh
Normal file
37
tools/flash.sh
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
# ============================================================
|
||||
# 一键: configure (首次) -> build -> flash -> reset & run
|
||||
# 调试器: ST-Link / J-Link / DAP-Link 均可 (走 SWD)
|
||||
# 产物: build/stm32f103_spl_clion.elf
|
||||
# ============================================================
|
||||
set -e
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
CLT="/c/ST/STM32CubeCLT_1.18.0"
|
||||
CMAKE="$CLT/CMake/bin/cmake.exe"
|
||||
NINJA="$CLT/Ninja/bin/ninja.exe"
|
||||
PROG="$CLT/STM32CubeProgrammer/bin/STM32_Programmer_CLI.exe"
|
||||
BUILD="$ROOT/build"
|
||||
ELF="$BUILD/stm32f103_spl_clion.elf"
|
||||
TOOLCHAIN_FILE="$ROOT/cmake/gcc-arm-none-eabi.cmake"
|
||||
|
||||
# ---- 1. 首次 configure (生成 build.ninja) ----
|
||||
if [ ! -f "$BUILD/build.ninja" ]; then
|
||||
echo "==[ 1/3 configure ]=="
|
||||
"$CMAKE" -S "$ROOT" -B "$BUILD" -G Ninja \
|
||||
-DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" \
|
||||
-DCMAKE_MAKE_PROGRAM="$NINJA" \
|
||||
-DCMAKE_BUILD_TYPE=Debug
|
||||
else
|
||||
echo "==[ 1/3 configure ]== (skipped, build/ 已存在)"
|
||||
fi
|
||||
|
||||
# ---- 2. 编译 ----
|
||||
echo "==[ 2/3 build ]=="
|
||||
"$CMAKE" --build "$BUILD" --config Debug
|
||||
|
||||
# ---- 3. 烧录 + 校验 + 复位运行 ----
|
||||
echo "==[ 3/3 flash ]=="
|
||||
"$PROG" -c port=swd -w "$ELF" -v -rst
|
||||
|
||||
echo "==[ done: 已烧录并复位运行 ]=="
|
||||
Reference in New Issue
Block a user