PlatformIO Community

esp32+Jlink debug in Win10+Vscode .pioinit:12: Error in sourced command file: Load failed

On Win10+vscode platform, I tried to use jlink to debug esp32, but I ran into some trouble.
When I gave debugging to a project under development, it was first compiled (Pre-Debug) in the terminal and successfully compiled, but then it was compiled again at the debug console and when its compilation was done, the following error was reported when it was supposed to do firmware burn-in.
Pre-debug:

 *  正在执行任务: C:\Users\22380\.platformio\penv\Scripts\platformio.exe debug 

Processing esp32dev (platform: espressif32; board: esp32dev; framework: espidf)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (5.2.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (jlink) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-espidf @ 3.40402.0 (4.4.2)
 - tool-cmake @ 3.16.4
 - tool-esptoolpy @ 1.40201.0 (4.2.1)
 - tool-idf @ 1.0.1
 - tool-mconf @ 1.4060000.20190628 (406.0.0)
 - tool-ninja @ 1.9.0
 - tool-openocd-esp32 @ 2.1100.20220706 (11.0)
 - toolchain-esp32ulp @ 1.22851.191205 (2.28.51)
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3
Reading CMake configuration...
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in debug mode
Retrieving maximum program size .pio\build\esp32dev\firmware.elf
Checking size .pio\build\esp32dev\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   9.6% (used 31516 bytes from 327680 bytes)
Flash: [======    ]  63.4% (used 665237 bytes from 1048576 bytes)
================================================================== [SUCCESS] Took 11.40 seconds ==================================================================
 

Debug console:

Processing esp32dev (platform: espressif32; board: esp32dev; framework: espidf)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (5.2.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (jlink) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-espidf @ 3.40402.0 (4.4.2)
 - tool-cmake @ 3.16.4
 - tool-esptoolpy @ 1.40201.0 (4.2.1)
 - tool-idf @ 1.0.1
 - tool-mconf @ 1.4060000.20190628 (406.0.0)
 - tool-ninja @ 1.9.0
 - tool-openocd-esp32 @ 2.1100.20220706 (11.0)
 - toolchain-esp32ulp @ 1.22851.191205 (2.28.51)
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3
Reading CMake configuration...
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in debug mode
Compiling .pio\build\esp32dev\main\main.o
In file included from main/main.c:14:
main/dap_init.h:10:20: warning: 'MDNS_TAG' defined but not used [-Wunused-variable]
 static const char *MDNS_TAG = "server_common";
                    ^~~~~~~~
Compiling .pio\build\esp32dev\main\timer.o
Compiling .pio\build\esp32dev\main\tcp_server.o
Compiling .pio\build\esp32dev\main\usbip_server.o
Compiling .pio\build\esp32dev\main\DAP_handle.o

........

Indexing .pio\build\esp32dev\bootloader\esp-idf\xtensa\libxtensa.a
Archiving .pio\build\esp32dev\bootloader\esp-idf\spi_flash\libspi_flash.a
Indexing .pio\build\esp32dev\bootloader\esp-idf\spi_flash\libspi_flash.a
Linking .pio\build\esp32dev\bootloader.elf
Building .pio\build\esp32dev\bootloader.bin
esptool.py v4.2.1
Creating esp32 image...
Merged 1 ELF section
Successfully created esp32 image.
Linking .pio\build\esp32dev\firmware.elf
Retrieving maximum program size .pio\build\esp32dev\firmware.elf
Checking size .pio\build\esp32dev\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   9.6% (used 31516 bytes from 327680 bytes)
Flash: [======    ]  63.4% (used 665237 bytes from 1048576 bytes)
Building .pio\build\esp32dev\firmware.bin
esptool.py v4.2.1
Creating esp32 image...
Merged 25 ELF sections
Successfully created esp32 image.
========================= [SUCCESS] Took 55.75 seconds =========================
undefinedC:\Users\22380\.platformio\packages\toolchain-xtensa-esp32\bin\xtensa-esp32-elf-gdb.exe: warning: Couldn't determine a path for the index cache directory.
Reading symbols from c:\Users\22380\Documents\GitHub\wireless-esp8266-dap\.pio\build\esp32dev\firmware.elf...
PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = jlink
PlatformIO: Initializing remote target...
Open On-Chip Debugger v0.11.0-esp32-20211220-1338-g554a6c26 (2022-04-08-09:23)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
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
Info : J-Link V9 compiled May  7 2021 16:26:12
Info : Hardware version: 9.50
Info : VTarget = 3.304 V
Info : clock speed 500 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=0x4013DCA2, debug_reason=00000000
Info : Set GDB target to 'esp32.cpu0'
Info : esp32.cpu1: Target halted, PC=0x4013DCA2, debug_reason=00000000
Warn : No symbols for FreeRTOS!
Info : esp32.cpu0: Target halted, PC=0x4009260E, debug_reason=00000001
Error: Failed to get flash maps (4294967290)!
Warn : Failed to get flash mappings (-4)!
Info : esp32.cpu0: Target halted, PC=0x4009260E, debug_reason=00000001
Info : esp32.cpu0: Target halted, PC=0x4009260E, 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=0x4009260E, debug_reason=00000001
Error: Failed to get flash maps (4294967290)!
Warn : Failed to get flash mappings (-4)!
Info : esp32.cpu0: Target halted, PC=0x4009260E, debug_reason=00000001
Info : Using flash bank 'esp32.cpu0.irom' size 0 KB
Info : esp32.cpu0: Target halted, PC=0x4009260E, debug_reason=00000001
Error: Failed to get flash maps (4294967290)!
Warn : Failed to get flash mappings (-4)!
Info : esp32.cpu0: Target halted, PC=0x4009260E, debug_reason=00000001
Info : Using flash bank 'esp32.cpu0.drom' size 0 KB
Info : New GDB Connection: 1, Target esp32.cpu0, state: halted
Warn : negative reply, retrying
Warn : negative reply, retrying
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1106 ms). Workaround: increase "set remotetimeout" in GDB
0x4013dca2 in esp_pm_impl_waiti () at C:\Users\22380\.platformio\packages\framework-espidf\components\hal\esp32\include/hal/cpu_ll.h:183
183	    asm volatile ("waiti 0\n");
Error: FreeRTOS: uxTopUsedPriority is not defined, consult the OpenOCD manual for a work-around!
Loading section .flash.appdesc, size 0x100 lma 0x3f400020
Warn : address 0x3f400020 not writable
Loading section .flash.rodata, size 0x1303c lma 0x3f400120
Warn : address 0x3f400120 not writable
.pioinit:12: Error in sourced command file:
Load failed
.pioinit:12: Error in sourced command file:
Load failed

platformio.ini

[platformio]
src_dir = main

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = espidf
build_type=debug
debug_speed=500
debug_tool = jlink
upload_protocol = esptool

monitor_speed = 115200
debug_load_mode=modified

When I create a new empty ESP32 project for debugging, the debugging function works fine and it only compiles once (at Pre-Debug), after which its not recompiled at the debug console.

I would be grateful if you could help me!