Skip to content

修复: OpenOCD 分号命令兼容性、tool_config 导入容错、Pico SDK 自动探测(跨平台 Win/macOS/Linux)#4

Open
hackerboygn wants to merge 6 commits into
LeoKemp223:masterfrom
hackerboygn:fix/powershell-openocd-compat
Open

修复: OpenOCD 分号命令兼容性、tool_config 导入容错、Pico SDK 自动探测(跨平台 Win/macOS/Linux)#4
hackerboygn wants to merge 6 commits into
LeoKemp223:masterfrom
hackerboygn:fix/powershell-openocd-compat

Conversation

@hackerboygn

Copy link
Copy Markdown

问题

  1. 分号命令兼容性:OpenOCD 脚本使用 -c "init; program ... verify reset exit" 这种分号分隔的多命令形式,在部分 OpenOCD 版本中不能正常工作。

  2. tool_config 导入崩溃:脚本独立运行时(不在 repo 原目录结构中),tool_config 模块导入失败导致脚本崩溃。

  3. 调试目标缺失诊断--target 未指定时缺乏提示,用户不知道如何配置(如 RP2350 需要 rp2350.cfg)。

  4. Pico SDK OpenOCD 未探测:Pico SDK 自带 OpenOCD 包含芯片特定目标配置(如 rp2350.cfg),脚本未自动添加其 scripts 搜索路径。

修改

openocd_flasher.py (+17 / -5)

  1. 拆分分号命令-c "init; program ..." → 独立 -c init -c "program ..." 参数,兼容所有 OpenOCD 版本。
  2. tool_config 容错:导入包裹 try/except,独立运行时降级为空函数。
  3. Pico SDK OpenOCD 自动探测find_pico_sdk_openocd_scripts() 扫描 ~/.pico-sdk/openocd/*/scripts/,自动注入 -s 搜索路径。支持 Windows (openocd.exe)、macOS/Linux (bin/openocd)。

gdb_debugger.py (+23 / -4)

  1. 拆分分号命令:同上。
  2. tool_config 容错:同上。
  3. --target 缺失诊断:未指定 --target 时打印明确提示。
  4. Pico SDK OpenOCD 自动探测:同上。

平台兼容性

平台 Path.home() Pico SDK 路径 OpenOCD exe subprocess
Windows ~/.pico-sdk/openocd/ openocd.exe ✅ list 参数
macOS 同上 bin/openocd ✅ list 参数
Linux 同上 bin/openocd ✅ list 参数

影响范围

仅改动 flash-openocddebug-gdb-openocd 两个 skill 的脚本。所有修改向后兼容,不破坏现有功能。

- Split semicolon-separated OpenOCD -c commands into individual -c args
  for compatibility with older OpenOCD versions (e.g., Pico SDK bundled)
- Add --target missing diagnostic warning in gdb_debugger.py
- Wrap tool_config import with try/except fallback for standalone usage
- Add find_pico_sdk_openocd_scripts() to scan ~/.pico-sdk/openocd/*/
  for OpenOCD scripts directories containing chip-specific targets
- Inject -s <scripts_dir> into build_flash_command() and
  build_openocd_command() so system OpenOCD can find rp2350.cfg
- Works cross-platform (Windows: openocd.exe, Unix: bin/openocd)
…stalls

When scripts are installed under a single directory (e.g. embed-tool),
the original SKILLS_ROOT-based path resolution fails. Add fallback to
check the workflow runner's own directory for the target script.
…t init

- Add -c init to build_openocd_command for dual-core target init
- Add 1.5s delay after OpenOCD port opens for target stabilization
- Replace target extended-remote with target remote (better Pico SDK compat)
- Replace load+reset halt sequence with monitor reset init (avoids GDB reflash)
- Add monitor halt to attach-only mode for reliable register reads
…ig.py

Move platform-specific OpenOCD scripts detection from individual skill
scripts into the shared tool_config layer. Both openocd_flasher.py and
gdb_debugger.py now import from tool_config with fallback stubs.

This centralizes environment detection and makes it available to all
skills without code duplication.
Rename find_pico_sdk_openocd_scripts -> find_sdk_bundled_openocd_scripts
Replace chip-specific examples with generic terms (stm32h7x, dual/multi-core)
Use 'SDK-bundled' terminology instead of vendor-specific names
@hackerboygn hackerboygn force-pushed the fix/powershell-openocd-compat branch from 2d2616f to 5d7cfcb Compare June 7, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant