ESP32-S3 在Platformio实现单步调试
发布时间:2026/9/1 11:59:46 作者:尧图编辑部 阅读量:1,286

大家好笔者最近在使用ESP32-S3时想要在Platformio上实现JTAG的单步调试遇到了很多困难今天才得以实现故做此纪录。在Platformio下称PIO上调试时我们首先需要修改一下platformio.ini的内容至于具体如何修改这个文件大家可以参考官方文档勤用翻译Section [env] — PlatformIO latest documentation笔者这里使用的是ESP32-S3自带的USB口进行JTAG调试(不需要外接J-LINK等JTAG模块)所以只添加了断点初始化设置否则进入调试会停在奇怪的地方debug_init_break tbreak setup如果大家想使用J-LINK可能需要加上debug_tool jlink有时候jlink调试速度过快还会出现问题大家也可以尝试修改调试速度debug_speed 500 //单位KHZ笔者前几天使用jlink时老是提示一大堆错误以下是错误代码Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html adapter speed: 5000 kHz Info : tcl server disabled Info : telnet server disabled Info : J-Link V9 compiled Mar 2 2018 17:07:57 Info : Hardware version: 9.40 Info : VTarget 3.296 V Info : clock speed 5000 kHz Error: JTAG scan chain interrogation failed: all zeroes Error: Check JTAG interface, timings, target power, etc. Error: Trying to use configured scan chain anyway... Error: esp32s3.cpu0: IR capture error; saw 0x00 not 0x01 Warn : Bypassing JTAG setup events due to errors Error: Unexpected OCD_ID 00000000 Warn : target esp32s3.cpu0 examination failed Error: Unexpected OCD_ID 00000000 Warn : target esp32s3.cpu1 examination failed Info : starting gdb server for esp32s3.cpu0 on pipe Info : accepting gdb connection from pipe Error: Target not examined yet Error executing event gdb-attach on target esp32s3.cpu0: Warn : No symbols for FreeRTOS! Error: Target not halted Error: auto_probe failed Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use gdb_memory_map disable. Error: attempted gdb connection rejected Error: error during select: Unknown error .pioinit:11: Error in sourced command file: Remote communication error. Target disconnected.: Success.笔者上网查询认为是Openocd没有正确配置的问题并且也更新了ESP32-S3官方jtag驱动首先是Openocd的配置笔者在cmd中输入openocd --version提示没有openocd应该是环境变量没有配置。我们找到PIO安装时自带的oepnocd一般来说路径为C:\Users\用户名\.platformio\packages\tool-openocd-esp32\bin然后我们在系统环境变量Path中添加这个路径之后重启就可以在pio中使用了接着是JTAG驱动我们先卸载原本JTAG驱动之后管理员权限运行PowerShell在其中运行Invoke-WebRequest https://dl.espressif.com/dl/idf-env/idf-env.exe -OutFile .\idf-env.exe; .\idf-env.exe driver install --espressif重启你的电脑最后在PIO中F5就可以开始你的调试了希望可以帮助大家解决问题参考文献JTAG 调试 - ESP32-S3 - — ESP-IDF 编程指南 latest 文档 (espressif.com)Section [env] — PlatformIO latest documentationConfigure ESP32-S3 Built-in JTAG Interface - ESP32-S3 - — ESP-IDF 编程指南 latest 文档 (espressif.com)