Git Product home page Git Product logo

mynotes's People

Watchers

 avatar

mynotes's Issues

esp32s3 vscode debug环境搭建

简介

本文的目的是:在vscode 环境下配置JTAG 接口,为ESP32S3开发板配置debug环境
具体地,通过 JTAG (Joint Test Action Group) 接口使用 OpenOCD 调试 ESP32-S3 时所需要的关键软件和硬件包括 xtensa-esp32s3-elf-gdb 调试器、OpenOCD 片上调试器 和连接到 ESP32-S3 目标的 JTAG 适配器。
image
https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32s3/api-guides/jtag-debugging/using-debugger.html

什么是OpenOCD?

OpenOCD(Open On-Chip Debugger)开源片上调试器,是一款开源软件,最初是由Dominic Rath同学还在大学期间发起的(2005年)项目。OpenOCD旨在提供针对嵌入式设备的调试、系统编程和边界扫描功能。
image
https://zhuanlan.zhihu.com/p/41517198

OpenOCD的配置文件

关于esp32s3的OpenOCD 配置文件有三个,可以通过选择目标板的时候选择,ctrl+shift+P,选择OpenOCD Board Configuration
image
image
配置文件也可以在文件夹下找到:
~/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32/share/openocd/scripts/board

三个配置文件的解释:

  • esp32s3-bridge.cfg

ESP USB Bridge 是一个 ESP-IDF 项目,能够利用 ESP32-S2 或 ESP32-S3 在计算机 (PC) 和目标微控制器 (MCU) 之间建立桥接,从而替代 USB 转 UART /JTAG 桥接芯片(例如 CP210x)。
https://www.espressif.com.cn/zh-hans/news/ESP_USB_Bridge
https://blog.csdn.net/linguisti/article/details/127346875
image

  • esp32s3-builtin.cfg
    仅需一根 USB 线即可高效连接 PC 与 ESP32-S3,因为 ESP32-S3 芯片本身提供了两路 USB 通道,一路连接到 JTAG,另一路连接到 USB 终端。
    image
    image

  • esp32s3-ftdi.cfg
    ESP-Prog 是一款乐鑫推出的开发调试工具,具有自动下载固件、串口通信、JTAG 在线调试等功能。自动下载固件和串口通信功能适用于 ESP8266 和 ESP32 平台,JTAG 在线调试功能适用于 ESP32 平台。
    ESP-Prog 使用简单方便,仅用一根 USB 线即可实现与电脑的连接,电脑端可识别出下载功能和 JTAG 功能对应的两个端口。
    ESP-Prog 可使用排线与用户板连接,连接器可选 2.54 mm 和 1.27 mm 两种间距的封装,具有防呆设计。用户板上需按对应顺序放置 Program (6-Pin) 和 JTAG (10-Pin) 的连接器。
    image
    image

配置 板载USB JTAG 接口的权限

image
也可以手动添加
image
结果为
image

在vscode的launch.json中配置

The Visual Studio Code uses .vscode/launch.json to configure debug as specified in Visual Studio Code Debugging.
Example launch.json for ESP-IDF Debug Adapter:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "GDB",
      "type": "cppdbg",
      "request": "launch",
      "MIMode": "gdb",
      "miDebuggerPath": "${command:espIdf.getXtensaGdb}",
      "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
      }
    }
  ]
}

https://github.com/espressif/vscode-esp-idf-extension/blob/master/docs/DEBUGGING.md

启动OpenOCD

Ctrl+shit+p,OpenOCD Manager
image
或者在vsc的状态栏
image
设置断点main起始处,启动gdb
image
image
或者用idp.py gdbtui 启动TUI界面
image
https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32s3/api-guides/jtag-debugging/using-debugger.html#jtag-debugging-using-debugger-command-line

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.