JTAG debugging with vscode

glrtheil
Posts: 61
Joined: Tue Dec 07, 2021 2:48 pm

JTAG debugging with vscode

Postby glrtheil » Wed Oct 18, 2023 5:10 pm

I'm not using a dev board. We have a production device with JTAG built in. I can flash using JTAG, but that's it. I'm dying to figure out how to do anything else with it, especially monitoring and debugging.

What's really frustrating is there seems to be no way to configure openocd to run automatically on flash. I have to run it manually. Here's what I'm using to get it running properly:

Code: Select all

openocd -f interface/jlink.cfg -f board/esp-wroom-32.cfg
After that's running, I'm able to flash using vscode after I set it to use JTAG.

However, if openocd is NOT running, when I use the command palette to "build, flash, and start a monitor", it builds then pops up a message saying openOCD is not running, asking if I want to launch it. Then it just runs openocd with no parameters and therefore it fails and never runs.

My primary need is first to be able to monitor the output of the ESP, as I've always done with serial. Secondarily I'd love to be able to debug. Any ideas on how I can accomplish this?

ESP_radurentea
Posts: 18
Joined: Thu Mar 09, 2023 8:30 am

Re: JTAG debugging with vscode

Postby ESP_radurentea » Tue Oct 24, 2023 2:21 pm

Hi,

You can use custom configuration for OPENOCD, by using the command "ESP-IDF: Select OpenOCD Board Configuration" which have different presets or even custom configurations.
Also, when you flash via JTAG you should be asked if you want to start OpenOCD.

For debugging, I recommend you to look at the debugging documentation https://github.com/espressif/vscode-esp ... bugging.md first and if you still have questions, let me know!

glrtheil
Posts: 61
Joined: Tue Dec 07, 2021 2:48 pm

Re: JTAG debugging with vscode

Postby glrtheil » Wed Oct 25, 2023 5:48 pm

ESP_radurentea wrote:
Tue Oct 24, 2023 2:21 pm
You can use custom configuration for OPENOCD, by using the command "ESP-IDF: Select OpenOCD Board Configuration" which have different presets or even custom configurations.
Also, when you flash via JTAG you should be asked if you want to start OpenOCD.

For debugging, I recommend you to look at the debugging documentation https://github.com/espressif/vscode-esp ... bugging.md first and if you still have questions, let me know!
Thanks for that info. Bummer that I have to create a custom file to make that work, rather than being able to specify both jlink and esp32 within vscode, but I made it work. When I start a debug session, I get this:
⚡️ Flashed Successfully (JTag)
C:\Users\Ricky\.espressif\tools\openocd-esp32\v0.10.0-esp32-20211111\openocd-esp32\bin\openocd.exe


[Debug Adapter]
Traceback (most recent call last):
File "c:\Users\Ricky\.vscode\extensions\espressif.esp-idf-extension-1.6.5\esp_debug_adapter\debug_adapter_main.py", line 26, in <module>
from debug_adapter import cli
File "c:\Users\Ricky\.vscode\extensions\espressif.esp-idf-extension-1.6.5\esp_debug_adapter\debug_adapter\__init__.py", line 25, in <module>
from .debug_adapter import DebugAdapter, A2VSC_READY2CONNECT_STRING, A2VSC_STOPPED_STRING, A2VSC_STARTED_STRING
File "c:\Users\Ricky\.vscode\extensions\espressif.esp-idf-extension-1.6.5\esp_debug_adapter\debug_adapter\debug_adapter.py", line 26, in <module>
import esp_debug_backend as dbg
ModuleNotFoundError: No module named 'esp_debug_backend'

[Stopped] : ESP-IDF Debug Adapter

ESP_radurentea
Posts: 18
Joined: Thu Mar 09, 2023 8:30 am

Re: JTAG debugging with vscode

Postby ESP_radurentea » Thu Oct 26, 2023 7:47 am

Try installing the debug adapter requirements again with the ESP-IDF: Install ESP-IDF Python Packages command from Command Palette.

I will keep in mind the issue with the jlink as a feature request and see what we can do.

glrtheil
Posts: 61
Joined: Tue Dec 07, 2021 2:48 pm

Re: JTAG debugging with vscode

Postby glrtheil » Fri Oct 27, 2023 3:04 pm

That definitely made a change, but still not quite working as expected. Here's the logs:
[OpenOCD]
Info : New GDB Connection: 1, Target esp32.cp
[OpenOCD]
u0, state: halted
Warn : ignoring character 0x43
Warn : ignoring character 0x6f
Warn : ignoring character 0x6e
.....
Warn : ignoring character 0x22
Warn : ignoring character 0x3a
Warn : ignoring character 0x31
Warn : ignoring character 0x7d

[OpenOCD]
Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive packet not sent! (1142). Workaround: increase "set remotetimeout" in GDB
The debugger is definitely connected, as I can see the ESP app has stopped doing anything. In the Run and Debug tab of vs code the status indicator just seems to be stuck on loading. The debug tooks palette comes up and I can hit restart or stop. If I hit restart it says "'Debug ESP' is already running. Do you want to start another instance?", which of course does not work since there's already a connection. That kills gdb and my program does not continue to execute.I'm then stuck where it thinks its still running, but the debug tool palette disappears.

I then have to stop openOCD, start openOCD, reboot the ESP, and try again. If I hit stop, I have to hit it several times before the gdb connection is dropped.

Is it something with my launch.json?

Code: Select all

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "espidf",
      "name": "Debug ESP",
      "request": "launch",
      "debugPort": 3333,
      // "program": "${workspaceFolder}/build/main.elf"
    }
  ]
}

ESP_radurentea
Posts: 18
Joined: Thu Mar 09, 2023 8:30 am

Re: JTAG debugging with vscode

Postby ESP_radurentea » Tue Oct 31, 2023 10:02 am

Can you run doctor command from command palette for me and paste the output here (it will be copied to clipboard)?

Who is online

Users browsing this forum: No registered users and 47 guests