ESP32 Debug is OK for simple program but fails for complex program

Hi, i have a strange Debugging problem with Debug ESP32 board, ESP-Prog & PlatformIO.

The wiring are OK and I can debug a simple led program,
when i debug complex program (without to use GPPIO 12,13,14 & 15) the debug fail.
Hardware & platformio.ini are the same
Can you help me?
Thanks

Hardware Wiring
Board: az-delivery-devkit-v4
Board link to usb PC via usb COM9
ESP-Prog link to usb PC via usb COM11
None Vcc link

TEST LED PROGRAM

  1. Power on DevKitC-v4 board via usb
  2. Power on Esp-prog board via usb
  3. Run VSC with PlatformIO
  4. Upload code to DevKiC board
  5. Start Debuggin
  6. Debug is OK

Simple led program

void setup() {
pinMode(2, OUTPUT);
Serial.begin(115200);
while (!Serial);
}
void loop() {
digitalWrite(2, HIGH);
delay(1000);
digitalWrite(2, LOW);
delay(1000);
Serial.print(".");
}

platformio.ino led program
[env:az-delivery-devkit-v4]
platform = espressif32
board = az-delivery-devkit-v4
framework = arduino
board_build.partitions = partitions_OTA_1.9MB-APP_190KB-SPIF.csv
monitor_speed = 115200
monitor_port = COM9
upload_port = COM9
upload_protocol = esptool
debug_tool = esp-prog
debug_init_break = tbreak setup

On monitor COM9

ets Jun 8 2016 00:22:57

rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13104
load:0x40080400,len:3036
entry 0x400805e4
E (147) esp_core_dump_flash: No core Äf~mp partition found!
E (147) esp_core_dump_flash: No core dump partition found!

On debug console
undefinedD:\Users\nicola.platformio\packages\toolchain-xtensa-esp32@8.4.0+2021r2-patch5\bin\xtensa-esp32-elf-gdb.exe: warning: Couldn’t determine a path for the index cache directory.
Reading symbols from d:_IoT\Platformio\Led1.pio\build\az-delivery-devkit-v4\firmware.elf…
PlatformIO Unified Debugger → bit.ly/pio-debug
PlatformIO: debug_tool = esp-prog
PlatformIO: Initializing remote target…
Open On-Chip Debugger v0.11.0-esp32-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read openocdorg /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: 5000 kHz

Info : tcl server disabled
Info : telnet server disabled
Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
Info : clock speed 5000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
Info : starting gdb server for esp32.cpu0 on pipe
Info : accepting ‘gdb’ connection from pipe
Info : [esp32.cpu0] Target halted, PC=0x400F0A9E, debug_reason=00000000
Info : Set GDB target to ‘esp32.cpu0’
Info : [esp32.cpu1] Target halted, PC=0x400F0A9E, debug_reason=00000000
Warn : No symbols for FreeRTOS!
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Info : Flash mapping 0: 0x10020 → 0x3f400020, 49 KB
Info : Flash mapping 1: 0x20020 → 0x400d0020, 133 KB
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Info : Auto-detected flash bank ‘esp32.cpu0.flash’ size 4096 KB
Info : Using flash bank ‘esp32.cpu0.flash’ size 4096 KB
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Info : Flash mapping 0: 0x10020 → 0x3f400020, 49 KB
Info : Flash mapping 1: 0x20020 → 0x400d0020, 133 KB
Info : Using flash bank ‘esp32.cpu0.irom’ size 136 KB
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Info : Flash mapping 0: 0x10020 → 0x3f400020, 49 KB
Info : Flash mapping 1: 0x20020 → 0x400d0020, 133 KB
Info : Using flash bank ‘esp32.cpu0.drom’ size 52 KB
Info : New GDB Connection: 1, Target esp32.cpu0, state: halted
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1030 ms). Workaround: increase “set remotetimeout” in GDB
0x400f0a9e in esp_pm_impl_waiti () at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/hal/esp32/include/hal/cpu_ll.h:183
183 /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/hal/esp32/include/hal/cpu_ll.h: No such file or directory.
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : [esp32.cpu0] requesting target halt and executing a soft reset
[esp32.cpu0] requesting target halt and executing a soft reset
Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu0] Target halted, PC=0x500000CF, debug_reason=00000000
[esp32.cpu0] Debug controller was reset.
[esp32.cpu0] Core was reset.
[esp32.cpu0] Target halted, PC=0x500000CF, debug_reason=00000000
Info : [esp32.cpu1] requesting target halt and executing a soft reset
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu0] Target halted, PC=0x40000400, debug_reason=00000000
[esp32.cpu1] requesting target halt and executing a soft reset
[esp32.cpu0] Core was reset.
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
[esp32.cpu0] Target halted, PC=0x40000400, debug_reason=00000000
[esp32.cpu1] Debug controller was reset.
[esp32.cpu1] Core was reset.
Info : [esp32.cpu1] Target halted, PC=0x40000400, debug_reason=00000000
[esp32.cpu1] Target halted, PC=0x40000400, debug_reason=00000000
Temporary breakpoint 1 at 0x400d1343: file src/main.cpp, line 8.
PlatformIO: Initialization completed
PlatformIO: Resume the execution to debug_init_break = tbreak setup
PlatformIO: More configuration options → bit.ly/pio-debug
Note: automatically using hardware breakpoints for read-only addresses.
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Info : [esp3
2.cpu0] Target halted, PC=0x400D9004, debug_reason=00000000
[esp32.cpu0] Target halted, PC=0x400D9004, debug_reason=00000000
Info : Set GDB target to ‘esp32.cpu0’
Set GDB target to ‘esp32.cpu0’
Info : [esp32.cpu1] Target halted, PC=0x400D1343, debug_reason=00000001
[esp32.cpu1] Target halted, PC=0x400D1343, debug_reason=00000001
[New Thread 1073468596]
[New Thread 1073494628]
[New Thread 1073446332]
[New Thread 1073461528]
[New Thread 1073445672]
[New Thread 1073467196]
[Switching to Thread 1073449076]
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001

Thread 1 “loopTask” hit Temporary breakpoint 1, setup () at src/main.cpp:8
8 pinMode(LED_BUILTIN, OUTPUT); // initialize LED digital pin as an output.

TEST OTHER PROGRAM

  1. Power on DevKitC-v4 board via usb
  2. Power on Esp-prog board via usb
  3. Run VSC with PlatformIO
  4. Upload code to DevKiC board
  5. Start Debuggin
  6. Debug Failure

Upload program
Writing at 0x001a9ca3… (98 %)
Writing at 0x001af1e3… (100 %)
Wrote 1718496 bytes (1093906 compressed) at 0x00010000 in 28.3 seconds (effective 485.7 kbit/s)…
Hash of data verified.
Leaving…
Hard resetting via RTS pin…
[SUCCESS] Took 99.25 seconds

platformio.ino other program
[env:az-delivery-devkit-v4]
platform = espressif32
board = az-delivery-devkit-v4
framework = arduino
board_build.partitions = partitions_OTA_1.9MB-APP_190KB-SPIF.csv
monitor_speed = 115200
monitor_port = COM9
upload_port = COM9
upload_protocol = esptool
debug_tool = esp-prog
debug_init_break = tbreak setup
debug_speed = 500

Visual Studio Code
Failed to launch GDB: .pioinit:11 Error in sourced command file:
Remote communication error. Target disconnected.: Success. (from interpreter-exec console
“source.pioinit”)
Open ‘launch.json’ button
Cancel button

launch.json
{
“version”: “0.2.0”,
“configurations”: [
{
“type”: “platformio-debug”,
“request”: “launch”,
“name”: “PIO Debug”,
“executable”: “d:/_IoT/YAHAS/Code/ESP/platformio/NodeAgent/.pio/build/az-delivery-devkit-v4/firmware.elf”,
“projectEnvName”: “az-delivery-devkit-v4”,
“toolchainBinDir”: “D:/Users/nicola/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/bin”,
“internalConsoleOptions”: “openOnSessionStart”,
“preLaunchTask”: {
“type”: “PlatformIO”,
“task”: “Pre-Debug”
}
},
{
“type”: “platformio-debug”,
“request”: “launch”,
“name”: “PIO Debug (skip Pre-Debug)”,
“executable”: “d:/_IoT/YAHAS/Code/ESP/platformio/NodeAgent/.pio/build/az-delivery-devkit-v4/firmware.elf”,
“projectEnvName”: “az-delivery-devkit-v4”,
“toolchainBinDir”: “D:/Users/nicola/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/bin”,
“internalConsoleOptions”: “openOnSessionStart”
},
{
“type”: “platformio-debug”,
“request”: “launch”,
“name”: “PIO Debug (without uploading)”,
“executable”: “d:/_IoT/YAHAS/Code/ESP/platformio/NodeAgent/.pio/build/az-delivery-devkit-v4/firmware.elf”,
“projectEnvName”: “az-delivery-devkit-v4”,
“toolchainBinDir”: “D:/Users/nicola/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/bin”,
“internalConsoleOptions”: “openOnSessionStart”,
“loadMode”: “manual”
}
]
}

Debug console
undefinedD:\Users\nicola.platformio\packages\toolchain-xtensa-esp32@8.4.0+2021r2-patch5\bin\xtensa-esp32-elf-gdb.exe: warning: Couldn’t determine a path for the index cache directory.
Reading symbols from d:_IoT_YAHAS_\Code\ESP\platformio\NodeAgent.pio\build\az-delivery-devkit-v4\firmware.elf…
PlatformIO Unified Debugger → bit.ly/pio-debug
PlatformIO: debug_tool = esp-prog
PlatformIO: Initializing remote target…
Open On-Chip Debugger v0.11.0-esp32-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read openocdorg /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: 500 kHz

Info : tcl server disabled
Info : telnet server disabled
Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
Info : clock speed 500 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
Error: Unexpected OCD_ID = 00000000
Warn : target esp32.cpu0 examination failed
Error: Unexpected OCD_ID = 00000000
Warn : target esp32.cpu1 examination failed
Info : starting gdb server for esp32.cpu0 on pipe
Info : accepting ‘gdb’ connection from pipe
Error: Target not examined yet
Error executing event gdb-attach on target esp32.cpu0:

Warn : No symbols for FreeRTOS!
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.: Success.

Hello. I got the same problem. Debug start and function with a simple blink program. It fails with more complex program.

Same issue for me. Simple code works, with higher complexity it fails.

Could you solve the issue?

Same problem here!!

And it is being reported several times …

Anyone has any hint?