VSCode + JTAG调试合宙ESP32C3的经历
VSCode + JTAG调试合宙ESP32C3
环境
Windows10
VSCode + ESP-IDF
合宙ESP32C3(无串口芯片版本)
理论
想要直接使用内置JTAG,USB要求连接GPIO18和GPIO19


合宙ESP32C3有串口芯片版本USB经过CH343连接的串口,无法使用内置JTAG

合宙ESP32C3无串口芯片版本满足要求

步骤
连接PC后有一个虚拟串口和一个USB JTAG接口

按住BOOT,然后按下RST,松开BOOT,芯片进入下载模式,下载固件
PS F:\Espressif\frameworks\esp-idf-v4.4.3\workspace\hello_world> idf.py flash -p COM16 -b 921600
Executing action: flash
Running ninja in directory f:\espressif\frameworks\esp-idf-v4.4.3\workspace\hello_world\build
Executing "ninja flash"...
[1/5] cmd.exe /C "cd /D F:\Espressif\frameworks\esp-idf-v4.4.3\workspace\hello_world\build\esp-idf\esptool_py && ...ion_table/partition-table.bin F:/Espressif/frameworks/esp-idf-v4.4.3/workspace/hello_world/build/hello_world.bin"hello_world.bin binary size 0x25130 bytes. Smallest app partition is 0x100000 bytes. 0xdaed0 bytes (86%) free.
[2/5] Performing build step for 'bootloader'
[1/1] cmd.exe /C "cd /D F:\Espressif\frameworks\esp-idf-v4.4.3\workspace\hello_world\build\bootloader\esp-idf\esptool_py && F:\Espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe F:/Espressif/frameworks/esp-idf-v4.4.3/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x0 F:/Espressif/frameworks/esp-idf-v4.4.3/workspace/hello_world/build/bootloader/bootloader.bin"
Bootloader binary size 0x4d70 bytes. 0x3290 bytes (40%) free.
[2/3] cmd.exe /C "cd /D F:\Espressif\frameworks\esp-idf-v4.4.3\components\esptool_py && F:\Espressif\tools\cmake\...rkspace/hello_world/build" -P F:/Espressif/frameworks/esp-idf-v4.4.3/components/esptool_py/run_serial_tool.cmake"esptool.py esp32c3 -p COM16 -b 921600 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 2MB 0x0 bootloader/bootloader.bin 0x10000 hello_world.bin 0x8000 partition_table/partition-table.bin
esptool.py v3.3.2
Serial port COM16
Connecting....
Chip is ESP32-C3 (revision 3)
Features: Wi-Fi
Crystal is 40MHz
MAC: 60:55:f9:75:9c:90
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00004fff...
Flash will be erased from 0x00010000 to 0x00035fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Compressed 19824 bytes to 12050...
Writing at 0x00000000... (100 %)
Wrote 19824 bytes (12050 compressed) at 0x00000000 in 0.3 seconds (effective 585.5 kbit/s)...
Hash of data verified.
Compressed 151856 bytes to 82022...
Writing at 0x00010000... (16 %)
Writing at 0x00019991... (33 %)
Writing at 0x000202c8... (50 %)
Writing at 0x0002749a... (66 %)
Writing at 0x0002dacd... (83 %)
Writing at 0x00035037... (100 %)
Wrote 151856 bytes (82022 compressed) at 0x00010000 in 1.8 seconds (effective 687.7 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 103...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.0 seconds (effective 684.5 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
Done
PS F:\Espressif\frameworks\esp-idf-v4.4.3\workspace\hello_world>
启动OpenOCD和GDB前先按下RST重启芯片,运行在正常模式,而不是下载模式
使用乐鑫OpenOCD,搭配board/esp32c3-builtin.cfg

启动OpenOCD,监听3333,成功
PS F:\Espressif\frameworks\esp-idf-v4.4.3\workspace\hello_world> openocd -f board/esp32c3-builtin.cfg
Open On-Chip Debugger v0.11.0-esp32-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
Info : esp_usb_jtag: VID set to 0x303a and PID to 0x1001
Info : esp_usb_jtag: capabilities descriptor set to 0x2000
Warn : Transport "jtag" was already selected
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : esp_usb_jtag: serial (60:55:F9:75:9C:90)
Info : esp_usb_jtag: Device found. Base speed 40000KHz, div range 1 to 255
Info : clock speed 40000 kHz
Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0)
Info : datacount=2 progbufsize=16
Info : Examined RISC-V core; found 1 harts
Info : hart 0: XLEN=32, misa=0x40101104
Info : starting gdb server for esp32c3 on 3333
Info : Listening on port 3333 for gdb connections
根据官方教程创建gdbinit文件,端口3333
target remote :3333
set remote hardware-watchpoint-limit 2
mon reset halt
flushregs
thb app_main
c
启动GDB调试,成功,此时已经可以使用GDB调试了
PS F:\Espressif\frameworks\esp-idf-v4.4.3\workspace\hello_world> riscv32-esp-elf-gdb -x gdbinit build/hello_world.elf
F:\Espressif\tools\riscv32-esp-elf\esp-2021r2-patch5-8.4.0\riscv32-esp-elf\bin\riscv32-esp-elf-gdb.exe: warning: Couldn't determine a path for the index cache directory.
GNU gdb (crosstool-NG esp-2021r2-patch5) 9.2.90.20200913-git
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-host_w64-mingw32 --target=riscv32-esp-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from build/hello_world.elf...
0x40000000 in ?? ()
JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0)
Reset cause (3) - (Software core reset)
Hardware assisted breakpoint 1 at 0x42005eee: file F:/Espressif/frameworks/esp-idf-v4.4.3/workspace/hello_world/main/hello_world_main.c, line 17.
[New Thread 1070136696]
[New Thread 1070130304]
[Switching to Thread 1070134812]
Thread 1 "main" hit Temporary breakpoint 1, app_main () at F:/Espressif/frameworks/esp-idf-v4.4.3/workspace/hello_world/main/hello_world_main.c:17
17 {
(gdb)
OpenOCD可以看到GDB连接后的行为
Info : accepting 'gdb' connection on tcp/3333
Memory protection is enabled. Reset target to disable it...
Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0)
Info : Reset cause (3) - (Software core reset)
Warn : No symbols for FreeRTOS!
Info : [esp32c3] Found 8 triggers
Info : Flash mapping 0: 0x10020 -> 0x3c020020, 27 KB
Info : Flash mapping 1: 0x20020 -> 0x42000020, 75 KB
Info : Auto-detected flash bank 'esp32c3.flash' size 4096 KB
Info : Using flash bank 'esp32c3.flash' size 4096 KB
Info : Flash mapping 0: 0x10020 -> 0x3c020020, 27 KB
Info : Flash mapping 1: 0x20020 -> 0x42000020, 75 KB
Info : Using flash bank 'esp32c3.irom' size 76 KB
Info : Flash mapping 0: 0x10020 -> 0x3c020020, 27 KB
Info : Flash mapping 1: 0x20020 -> 0x42000020, 75 KB
Info : Using flash bank 'esp32c3.drom' size 28 KB
Warn : negative reply, retrying
Warn : Prefer GDB command "target extended-remote :3333" instead of "target remote :3333"
Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0)
Info : Reset cause (3) - (Software core reset)
VSCode
使用指令行已成功,接下来使用VSCode
VSCode ESP-IDF插件官方说明如下,我使用ESP-IDF Debug Adapter失败,使用Microsoft C/C++ extension调试成功
vscode-esp-idf-extension/DEBUGGING.md at master · espressif/vscode-esp-idf-extension · GitHub
使用ESP-IDF插件,启动OpenOCD,打印如下,本质和指令行直接调用没啥区别


[OpenOCD]
[Stopped] : OpenOCD Server
[OpenOCD]
Open On-Chip Debugger v0.11.0-esp32-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
[OpenOCD]
debug_level: 2
[OpenOCD]
Info : only one transport option; autoselect 'jtag'
[OpenOCD]
Info : esp_usb_jtag: VID set to 0x303a and PID to 0x1001
Info : esp_usb_jtag: capabilities descriptor set to 0x2000
Warn : Transport "jtag" was already selected
[OpenOCD]
Info : Listening on port 6666 for tcl connections
[OpenOCD]
Info : Listening on port 4444 for telnet connections
[OpenOCD]
Info : esp_usb_jtag: serial (60:55:F9:75:9C:90)
[OpenOCD]
Info : esp_u[OpenOCD]
sb_jtag: Device found. Base speed 40000KHz, div range 1 to 255
[OpenOCD]
Info : cloc[OpenOCD]
k speed 40000 kHz
[OpenOCD]
Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg:[OpenOCD]
0x612 (Espressif Systems), part: 0x0005, ver: 0x0)
[OpenOCD]
Info : datacount=2 progbufsize=16
[OpenOCD]
Info : Examined RISC-V[OpenOCD]
core; found 1 harts
Info : hart 0: XLEN=32, misa=0x40101104
[OpenOCD]
Info : [esp32c3] Found 8 trig[OpenOCD]
gers
[OpenOCD]
Info : starting gdb server for esp32c3 on 3333
Info : Listening on port 3333 for gdb connections
根据插件官方说明,创建launch.json,我修改了"miDebuggerPath",根据自己的情况修改即可
{
"version": "0.2.0",
"configurations": [
{
"name": "GDB",
"type": "cppdbg",
"request": "launch",
"MIMode": "gdb",
"miDebuggerPath": "F:/Espressif/tools/riscv32-esp-elf/esp-2021r2-patch5-8.4.0/riscv32-esp-elf/bin/riscv32-esp-elf-gdb.exe",
"program": "${workspaceFolder}/build/${command:espIdf.getProjectName}.elf",
"windows": {
"program": "${workspaceFolder}\\build\\${command:espIdf.getProjectName}.elf"
},
"cwd": "${workspaceFolder}",
"environment": [{ "name": "PATH", "value": "${config:idf.customExtraPaths}" }],
"setupCommands": [
{ "text": "target remote :3333" },
{ "text": "set remote hardware-watchpoint-limit 2"},
{ "text": "mon reset halt" },
{ "text": "thb app_main" },
{ "text": "flushregs" }
],
"externalConsole": false,
"logging": {
"engineLogging": true
}
}
]
}
打个断点按下F5进行调试,按了三下才开启,原因未知

VSCode + JTAG调试合宙ESP32C3的经历的更多相关文章
- 合宙AIR105使用Keil MDK + DAP-Link 烧录和调试
关于AIR105 AIR105是合宙LuatOS生态下的一款芯片, 1月初上市, 开发板与摄像头一起搭售(赠送). 从配置信息看, 芯片性能相当不错: Cortex-M4F内核, 最高频率204Mhz ...
- 合宙AIR105(二): 时钟设置和延迟函数
目录 合宙AIR105(一): Keil MDK开发环境, DAP-Link 烧录和调试 合宙AIR105(二): 时钟设置和延迟函数 Air105 的时钟 高频振荡源 芯片支持使用内部振荡源, 或使 ...
- 合宙AIR105(三): 定时器, 定时器中断和PWM输出
目录 合宙AIR105(一): Keil MDK开发环境, DAP-Link 烧录和调试 合宙AIR105(二): 时钟设置和延迟函数 合宙AIR105(三): 定时器, 定时器中断和PWM输出 Ai ...
- 合宙AIR105(四): SPI, MAX7219 8x8LED驱动
目录 合宙AIR105(一): Keil MDK开发环境, DAP-Link 烧录和调试 合宙AIR105(二): 时钟设置和延迟函数 合宙AIR105(三): 定时器, 定时器中断和PWM输出 合宙 ...
- 合宙模块LUA相关资料汇总
1. 目录 1. 目录 [2. LUA二次开发](#2. LUA二次开发) 2.1 [新手教程](#2.1 新手教程) 2.2 [进阶教程](#2.2 进阶教程) 2.3 [LUA开发环境](#2.3 ...
- 合宙Air32F103CBT6开发板上手报告
2022年6月初合宙新上市了 Air32F103 系列 MCU, 市面上 STM32F103 的克隆军队又增加了新的一员. 这次不知道是哪家的贴牌, 分 Air32F103CBT6 和 Air32F1 ...
- linux系统下如何在vscode中调试C++代码
本篇博客以一个简单的hello world程序,介绍在vscode中调试C++代码的配置过程. 1. 安装编译器 vscode是一个轻量的代码编辑器,并不具备代码编译功能,代码编译需要交给编译器完成. ...
- 合宙模块AT相关资料汇总
1. 目录 1. 目录 [2. 新手教程](#2. 新手教程) [3. 产品资料](#3. 产品资料) 3.1 [2G模块(GPRS / GPRS+GNSS)](#3.1 2G模块(GPRS / GP ...
- 【转载】Windows下VSCode编译调试c/c++
懒得自己配置或自己配置出现不明问题的朋友可以点这里: [VSCode]Windows下VSCode便携式c/c++环境 http://blog.csdn.net/c_duoduo/article/de ...
- visual studio code(vscode) 调试php(转)
原文链接:http://www.cnblogs.com/CLR010/p/5276077.html visual studio code(vscode) 调试php 1.下载vscode (vis ...
随机推荐
- 多线程-多个子线程执行结果插入List集合
业务场景:将多个子线程的执行结果存入List,但是总会出现List集合的长度小于子线程的执行数的情况 1.错误示例(多个线程同时操作同一个List对象,List是线程不安全) package unit ...
- HarmonyOS多媒体框架介绍
原文:https://mp.weixin.qq.com/s/_2LHv7s7X4IJMCPU8hcCeg,点击链接查看更多技术内容. 随着科技进步,我们的生活发生了翻天覆地的变化.过去几年音视频技 ...
- Linux&Ubuntu之更换服务器
前言 更换网卡.主板上的板载网卡.主板是服务器硬件维护的常规操作.通常新换(板载)网卡的MAC地址会变更,而部分服务器更换主板也会导致板载网卡MAC地址变化.由于CAS(Ubuntu)系统会将新MAC ...
- js 使用flow
前言 what is flow?我想是的,很多人都没有接触过,的确,他是一个新的项目,是的facebook开发的东西,一般还是可以的,有必要去学习一下,在react还是比较重要的. 它做的一件事叫做静 ...
- Vue3.0 框架搭建的后台管理模板
一个Vue3.0框架搭建的后台管理模板 开源vue3.0版本基于vue3.x+ant-design-vue构建的免费开源admin项目,star高达8.4K+ 支持电脑端.手机.平板等平台 底层使用e ...
- 2024-04-21:用go语言,给一棵根为1的树,每次询问子树颜色种类数。 假设节点总数为n,颜色总数为m, 每个节点的颜色,依次给出,整棵树以1节点做头, 有k次查询,询问某个节点为头的子树,一共
2024-04-21:用go语言,给一棵根为1的树,每次询问子树颜色种类数. 假设节点总数为n,颜色总数为m, 每个节点的颜色,依次给出,整棵树以1节点做头, 有k次查询,询问某个节点为头的子树,一共 ...
- node统计指定文件夹内代码行数
1. 来源 想对于自己接触前端日常学习与思考的代码行数进行一个统计,看自己大约敲了多少代码 2.代码 const fs = require('fs') const path = require('pa ...
- 很强!4.7k star,推荐一款Python工具,可实现自动化操作!!
1.介绍 在日常工作中,肯定会遇到一些重复性的工作,不管是点击某个按钮.写东西,打印东西,还是复制粘贴拷贝资料之类的,需要进行大量的重复操作.按键精灵大家都听说过,传统的方式,大家可以使用按键精灵将操 ...
- OpenYurt:延伸原生 Kubernetes 到边缘场景下的落地实践
简介: 随着云原生技术的逐步成熟,阿里云容器服务团队在具体落地实践过程中不断探索云原生技术的应用边界.同时随着物联网和 5G 的迅猛发展,传统的边缘计算架构已经不能满足业务发展的需要. 如何基于云原生 ...
- 淘宝推荐、视频搜索背后的检索技术竟是它!深度揭秘达摩院向量检索引擎Proxima
简介: 淘宝搜索推荐.视频搜索的背后使用了什么样的检索技术?非结构化数据检索,向量检索,以及多模态检索,它们到底解决了什么问题?今天由阿里巴巴达摩院的科学家从业务问题出发,抽丝剥茧,深度揭秘达摩院内部 ...