ESP-PROG JTAG Debugger with WROVER behaves weird

Hi all,

i’ve been using the ESP-PROG and PIO unified Debugger on an ESP32WROVER dev kit and it’s really not working out for me, giving me sporadic and different errors between uploads without actually changing code. Sometimes it works, sometimes it does not, loosing my sanity here. I have to draw a line here and ask for help.

I get two main problems when i start the debugging:

1. It compiles and throws this error:

failed to launch GDB: .pioinit:11: Error in sourced file: Remote communication error. Target disconnected.: No error. (from interpreter-exec console “source.pioinit”)

I couldn’t find much info about this error and i have to admit that i don’t have a clue about json files. A window pops up and asks me to view the lauch.json file, which i should not modify manually. What’s the point then? After unplugging or resetting either board or debugger it might still reappear or jump to the next error below:

2. It compiles and enters the debugging process, but never stops at the setup function like i specified in platformio.ini, the yellow bar doesn’t appear

It appears to be running, but interacting with it seems to give me unexpected answers (a few examples):

PRESSING PAUSE:
Program received signal
SIGINT, Interrupt.
0x40009394 in ?? ()

PRESSING CONTINUE:
nothing

STEP OVER:
nothing, pauses again immediatly

STEP INTO:
same as step over

STEP OUT OF:
a window pops up: Could not step out: Warning: Cannot insert breakpoint 0. Cannot access memory at address 0x40007a27 (from exec-finish --thread 1)

PRESSING STOP:
Cannot execute this command while the target is running.
Use the “interrupt” command to stop the target
and then try again

Also, in a working case, the last message of the debug console before stopping at the setup-function tells me the line and specs of the setup function. In this weird case however, all i get is:
Temporary breakpoint 1 at 0x400d1ab0: file src\main.cpp, line 49.
PlatformIO: Initialization completed
PlatformIO: Resume the execution to debug_init_break = tbreak setup
PlatformIO: More configuration options → Redirecting...
Note: automatically using hardware breakpoints for read-only addresses.

this looks fine but doesn’t follow up on anything (???)

my resources:

platformio.ini:

[env:esp-wrover-kit]
platform = espressif32
board = esp-wrover-kit
framework = arduino
monitor_speed = 115200
debug_init_break = tbreak setup
upload_port = COM9
debug_tool = esp-prog
lib_deps = 
    adafruit/Adafruit NeoPixel@^1.7.0
    marcoschwartz/LiquidCrystal_I2C@^1.1.4

launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "platformio-debug",
            "request": "launch",
            "name": "PIO Debug",
            "executable": "c:/Users/<myuser>/Fieldrecorder/Code/PlatformIO/native/esp32-memsmic-wav beta cleanup/.pio/build/esp-wrover-kit/firmware.elf",
            "projectEnvName": "esp-wrover-kit",
            "toolchainBinDir": "C:/Users/<myuser>/.platformio/packages/toolchain-xtensa32/bin",
            "preLaunchTask": {
                "type": "PlatformIO",
                "task": "Pre-Debug"
            },
            "internalConsoleOptions": "openOnSessionStart"
        },
        {
            "type": "platformio-debug",
            "request": "launch",
            "name": "PIO Debug (skip Pre-Debug)",
            "executable": "c:/Users/<myuser>/Fieldrecorder/Code/PlatformIO/native/esp32-memsmic-wav beta cleanup/.pio/build/esp-wrover-kit/firmware.elf",
            "projectEnvName": "esp-wrover-kit",
            "toolchainBinDir": "C:/Users/<myuser>/.platformio/packages/toolchain-xtensa32/bin",
            "internalConsoleOptions": "openOnSessionStart"
        }
    ]
}

other:
my code should not be a problem since it worked before and isn’t even executed in this problem. I’m using freeRTOS and different tasks. I should also add that i run many sensors, so at first i thought it was a power issue. I now have connected the ESP-PROG and the ESP32WROVER to my PC independently from another. The interaction with the board is only over the debugger, the other USB-cable is just for power. Since i did a lot of un and replugging, could i have fried one of the boards? Is this expected behavior from dead or partially dead ESP-boards?

I would be so glad if someone had an idea what was going on and knows how to fix this. Thank you very much.

ESP32 debugging has many quirks, like never using JTAG pins, not being able to insert more than 2 breakpoints, etc.

A general countermeasure would be to decrease the JTAG clock and also double-ensuring that a firmware with debug symbols is uploaded.

You would e.g. do that by adding

debug_speed = 500
; build in debug mode instead of release mode
build_type = debug

to the platformio.ini (docs). Then re-upload the firmware to the board normally and retry debugging.