About debug-platformio
A PlatformIO debugging skill for embedded projects, covering live target debugging and crash-context inspection. It uses project configuration to select the debugging setup and supports handoff with the build skill.
Key features
- 01Detects the pio CLI and debug_tool
- 02Runs download-and-halt and attach-only modes
- 03Captures registers and call stacks
- 04Reads Cortex-M fault registers
- 05Classifies connection and debug failures
Use cases
- 01Step through firmware on a target board
- 02Inspect registers and variables during debugging
- 03Collect HardFault and stack-trace context
- 04Resume debugging after a successful build
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ leokemp223/ embed-ai-tool --skill debug-platformioAfter installing, type/debug-platformioin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
agents/openai.yamlreferences/usage.mdscripts/pio_debugger.pyDetails
From the project READMEPlatformIO 调试
适用场景
Project Profile中标明build_system: platformio或工作区中存在platformio.ini。- 用户需要对目标板进行在线调试(单步、断点、查看寄存器和变量)。
- 需要分析崩溃现场(HardFault 寄存器、调用栈)。
必要输入
- PlatformIO 工程目录(包含
platformio.ini)。 - 可选的环境名称和调试模式。
自动探测
- 自动定位
pioCLI。 - 解析
platformio.ini中的debug_tool配置。 - PlatformIO 自动管理调试服务器(OpenOCD/pyOCD/J-Link GDB Server),无需手动配置。
执行步骤
- 先阅读 references/usage.md,确认本次操作。
- 探测调试环境:
python scripts/pio_debugger.py --detect --project-dir <工程目录> --env <环境名> - 执行调试:
python scripts/pio_debugger.py --project-dir <工程目录> --env <环境名> --mode download-and-halt
调试模式
download-and-halt:下载固件到目标板,暂停在入口点,输出寄存器和回溯信息。attach-only:附加到正在运行的目标,不下载固件,输出当前状态。crash-context:暂停目标,读取寄存器、完整回溯和 Cortex-M Fault 寄存器(CFSR/HFSR/MMFAR/BFAR)。
失败分流
connection-failure:调试器未连接或设备无响应。debug-not-supported:板卡不支持调试或未配置 debug_tool。debug-failure:调试会话异常终止。
输出约定
示例输出格式:
调试完成 ✅
工程: ESP32_DEV → 环境: esp32dev
板卡: esp32dev | 调试工具: esp-prog
模式: download-and-halt
关键观察: 5 条(寄存器、回溯帧)
交接关系
- 从
build-platformio接收编译成功的工程信息。 - 调试发现问题后可回交给
build-platformio修改代码重新编译。
Comments
Markdown supported