PlatformIO Community

ESP32c3 debugging

Oh wow you got it.

Does it still work with the pio pkg command? (Ctrl+C to abort the old session)

image

Do I need to put anything in the platformio.ini or launch.json to start debug? I haven’t tried yet

Try putting in

debug_server = pio pkg exec -p tool-openocd-esp32 -c "openocd -f board/esp32c3-builtin.cfg"

in there and press the debug button. What’s the output in the “Debug Console” tab?

If that does not work, try the format

debug_server = 
   pio
   pkg
   exec
   -p
   tool-openocd-esp32
   -c
   "openocd -f board/esp32c3-builtin.cfg"

Got this in debug console:
undefinedError: Could not launch Debug Server ‘pio pkg exec -p tool-openocd-esp32 -c “openocd -f board/esp32c3-builtin.cfg”’. Please check that it is installed and is included in a system PATH

Going to try the other one. Should I take out the debug_tool = custom that I have in there too

No that’s actually good.

Does it say the same with the second variation?

It was working for a few seconds! … Then
image

The call stack started up and before I could read some values I got that error.

Could you manually start the openocd like you did before, then set

debug_tool = custom
debug_server = 
debug_port = localhost:3333

and retry (so that it hopefully connects to your preopened server)

Progress for sure!
image

openocd showed this

C:\openocd-esp32\bin>openocd.exe -s share\openocd\scripts -f board/esp32c3-builtin.cfg
Open On-Chip Debugger v0.11.0-esp32-20211220 (2021-12-20-15:43)
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: 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 : 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
Error: OpenOCD only supports Debug Module version 2 (0.13) and 3 (0.14), not 0 (dmstatus=0x0). This error might be caused by a JTAG signal issue. Try reducing the JTAG clock speed.
Info : Hart 0 unexpectedly reset
Info : Hart 0 unexpectedly reset
Info : Hart 0 unexpectedly reset
Info : Hart 0 unexpectedly reset
Info : Hart 0 unexpectedly reset
Info : Hart 0 unexpectedly reset
Info : accepting ‘gdb’ connection on tcp/3333
Warn : No symbols for FreeRTOS!
Info : [0] Found 8 triggers
Info : Flash mapping 0: 0x10020 → 0x3c020020, 31 KB
Info : Flash mapping 1: 0x20020 → 0x42000020, 118 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, 31 KB
Info : Flash mapping 1: 0x20020 → 0x42000020, 118 KB
Info : Using flash bank ‘esp32c3.irom’ size 120 KB
Info : Flash mapping 0: 0x10020 → 0x3c020020, 31 KB
Info : Flash mapping 1: 0x20020 → 0x42000020, 118 KB
Info : Using flash bank ‘esp32c3.drom’ size 32 KB
Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0)
** Programming Started **
Info : PROF: Data transferred in 205.757 ms @ 58.3212 KB/s
** Programming Finished **
** Verify Started **
** Verified OK **
Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0)
** Programming Started **
Info : PROF: Data transferred in 78.942 ms @ 50.6701 KB/s
** Programming Finished **
** Verify Started **
** Verified OK **
Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0)
** Programming Started **
Info : PROF: Data transferred in 125.271 ms @ 63.8615 KB/s
** Programming Finished **
** Verify Started **
** Verified OK **
Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0)
** Programming Started **
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1523 ms). Workaround: increase “set remotetimeout” in GDB
Info : PROF: Data transferred in 2952.98 ms @ 66.3736 KB/s
** Programming Finished **
** Verify Started **
** Verified OK **
Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0)
Info : Hart 0 unexpectedly reset
Info : Hart 0 unexpectedly reset
Info : Hart 0 unexpectedly reset
Info : Hart 0 unexpectedly reset
Info : Hart 0 unexpectedly reset
Info : Hart 0 unexpectedly reset
Info : Hart 0 unexpectedly reset
Info : Hart 0 unexpectedly reset
Info : Hart 0 unexpectedly reset
Info : Hart 0 unexpectedly reset
Info : Hart 0 unexpectedly reset

image

I had set a breakpoint, not sure if that was the cause

Hm… In your OpenOCD command, before the -f flag, can you do a -c "adapter_khz 500" to downgrade the speed to 500kHz and see if that error message is still there?

image

That’s with the 500 khz

Adding debug_init_break = setup should get rid of the red errror. Could dou try that?

I don’t think I put that in the right file.
JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0)

.pioinit:20: Error in sourced command file:

Undefined command: “setup”. Try “help”.

Was that for the platformio.ini? or launch.json

I put it in platformio

Sorry, break setup instead of setup.

I think it’s working!!

image

No, it’s not hitting the breakpoint. Try replacing setup with loop in debug_init_break. Is the LED still blinknig as dicated in the loop program?

You’re right. No, it’s not blinking. I’ll try the loop

If I press continue pause, that’s what comes up
image

This is the program and the controls are now showing at the top and the weren’t all enabled before. II thought maybe the delay was causing issues so replaced with the taskdelay but I don’t think that had anything to do with it.
image