Debug working on blink test, but fails in another implemented code. Error Message: Failed to launch GBD: .pioinit:11: Error in sourced command file: Remote communication error. Target disconnected.:No error

Hi everyone, i have manage to follow up all the required steps to upload and debug with esp-prog in platformIO on VSC with a simple blink test code in a ESP-WROOM-32 chip. Here it works flawlessly ( i can modify global variables, create breakpoints, etc).

Debug is a necessary step i need to achieve.
The problem starts when i try to debug another code. It flawlessly compiles and uploads. I can see it working and interact as normal.

but when i run the debug it wont work as well.

One window pop up after the upload:
image

Failed to launch GBD: .pioinit:11: Error in sourced command file: Remote communication error. Target disconnected.:No error

and the debugger console shows:

Reading symbols from D:\Documents\\Firmware\.pio\build\esp32dev\firmware.elf...
done.
PlatformIO Unified Debugger -> http://bit.ly/pio-debug
PlatformIO: debug_tool = esp-prog
PlatformIO: Initializing remote target...
Open On-Chip Debugger  v0.10.0-esp32-20210401 (2021-04-01-15:46)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 20000 kHz

WARNING: boards/esp-wroom-32.cfg is deprecated, and may be removed in a future release.
adapter speed: 200 kHz

Info : tcl server disabled
Info : telnet server disabled
2
Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
Info : clock speed 200 kHz
Error: JTAG scan chain interrogation failed: all zeroes
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway...
Error: esp32.cpu0: IR capture error; saw 0x00 not 0x01
Warn : Bypassing JTAG setup events due to errors
Info : accepting 'gdb' connection from pipe
Warn : No symbols for FreeRTOS!
Error: Target not examined yet
Error executing event gdb-attach on target esp32.cpu0:

Error: Target not halted
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
Error: attempted 'gdb' connection rejected
Error: error during select: Unknown error
.pioinit:11: Error in sourced command file:
Remote communication error.  Target disconnected.: No error.

I have tried to update the GDB openocd, PlatformIO and VSC. also decreased the debugger speed down to 200 but stills not working.

what can be a possible reason to this?
what can i do to solve this problem?

PlatformIO.ini :slight_smile:

[env:esp32dev]

platform = GitHub - platformio/platform-espressif32: Espressif 32: development platform for PlatformIO // as recommended to use the last version

board = esp32dev

framework = arduino

monitor_speed=115200

upload_speed = 115200

;JTAG firmware upload and debug

debug_tool = esp-prog

upload_protocol = esp-prog

upload_port = COM5

debug_init_break = tbreak setup

debug_speed = 200 // 500 or commented is the same :frowning:

Thanks in advance, best regards.

Jim

*[EDIT] to add that i have tried in another PC and the results are the same :frowning:

If it works on a blinky example but not with a more complicated piece of code, you have proven that all the wiring etc. is correct and that it must be a problem in your firmware.

Do you use any of the JTAG signals in your code?

@maxgerhardt thanks for the answer.

well, yes. I already have checked connection. and the JTAG GPIO pins arent used in software.

|MTDO / GPIO15|TDO|
|MTDI / GPIO12|TDI|
|MTCK / GPIO13|TCK|
|MTMS / GPIO14|TMS|

i haven’t found that i call those GPIO pins, is there a way that those can indirectly be called?

I’m using a finite state machine arduino library, and one LCD display ST7735s, SD and WiFi connection.

How can i verify if something is interfering with the JTAG interface? :thinking:

Well either by static analysis (seeing if there are any e.g. pinMode calls with pin numbers 12 to 15), or checking with a logic analyzer if there is any activity during normal sketch operation on those pins. OpenOCD says

so its as if TDO is LOW all the time (or JTAG input on TMS, TCK and TDI is ignored).

Can you upload the sketch that is not debuggable?

Im goin to try this.

Yes, i can upload the sketch , and is working. I can communicate instructions for the display through the serial monitor without problems.
with platformIO.ini like this:

[env:esp32dev]
platform = GitHub - platformio/platform-espressif32: Espressif 32: development platform for PlatformIO
board = esp32dev
framework = arduino
monitor_speed=115200
upload_speed = 115200

;JTAG firmware upload and debug
;debug_tool = esp-prog
;upload_protocol = esp-prog
;upload_port = COM5
;debug_init_break = tbreak setup
;debug_speed = 500

one question that is on my mind, it makes me curious.
when i upload the code with the narrow for the blink code and uncommented jtag lines in plaformio.ini it shows success and uploads. buuuuuut, if i try the same in a more complex code it fails.
image

so my steps for blink are:

  1. upload the code with jtag lines commented
  2. uncomment jtag lines
  3. run debug
    then, the same not working for the more complex code.

does it have something to do with the error we are looking to solve?