PlatformIO Community

Error: FreeRTOS: uxTopUsedPriority is not defined

I am trying to debug esp32 with jlink, but openocd prompts Error: FreeRTOS: uxTopUsedPriority is not defined
And GDB is not started.

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-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
DEPRECATED! use 'adapter speed' not 'adapter_khz'
adapter speed: 9600 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
Info : J-Link V9 compiled May  7 2021 16:26:12
Info : Hardware version: 9.50
Info : VTarget = 3.306 V
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.
4
Error: Unexpected OCD_ID = 00000000
Warn : target esp32.cpu1 examination failed
Info : [esp32.cpu0] Debug controller was reset.
3
Error: Unexpected OCD_ID = 00000000
Info : starting gdb server for esp32.cpu0 on pipe
Info : accepting 'gdb' connection from pipe
2
Error: Unexpected OCD_ID = 00000000
Info : [esp32.cpu0] Target halted, PC=0x4000F979, debug_reason=00000000
Info : Set GDB target to 'esp32.cpu0'
Warn : No symbols for FreeRTOS!
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Error: Failed to get flash maps (4294967290)!
Warn : Failed to get flash mappings (-4)!
2
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
Error: Failed to get flash maps (4294967290)!
Warn : Failed to get flash mappings (-4)!
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Info : Using flash bank 'esp32.cpu0.irom' size 0 KB
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Error: Failed to get flash maps (4294967290)!
Warn : Failed to get flash mappings (-4)!
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Info : Using flash bank 'esp32.cpu0.drom' size 0 KB
Info : New GDB Connection: 1, Target esp32.cpu0, state: halted
0x4000f979 in ?? ()
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 0x13d8c 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

I try it for many times and it is same.

And then I use PIO Debug(without uploading)
It can start the GDB!
But there are no breakpoints in effect

Hardware assisted breakpoint 1 at 0x400d1827: file main/main.c, line 20.
PlatformIO: Initialization completed
PlatformIO: Resume the execution to `debug_init_break = thb app_main`
PlatformIO: More configuration options -> https://bit.ly/pio-debug
Warn : address 0x400d1f27 not writable
Error: [esp32.cpu0] Failed to write breakpoint instruction (-4)!
Error: [esp32.cpu0] Failed to add SW breakpoint!
Error: can't add breakpoint: unknown reason
Warning:
Cannot insert breakpoint 2.
Cannot access memory at address 0x400d1f27

Command aborted.

Please help me, Thanks

Can you decrease the debug frequency? Maybe the later errors are a consequence of all the previous failures like Unexpected OCD_ID = 00000000 .

debug_speed = 500

in the platformio.ini for 500khz instead of 5MHz.

Let me have a try
By the way, why when I start the debug, the program will compile two time in each I start the debug.
Although I don’t change any code between the debug

Sadly, it doesn’t work very well

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-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
DEPRECATED! use 'adapter speed' not 'adapter_khz'
adapter speed: 9600 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
Info : J-Link V9 compiled May  7 2021 16:26:12
Info : Hardware version: 9.50
Info : VTarget = 3.300 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] Target halted, PC=0x4013ADF2, debug_reason=00000001
Info : [esp32.cpu1] Target halted, PC=0x4013ADF2, debug_reason=00000000
Info : starting gdb server for esp32.cpu0 on pipe
Info : accepting 'gdb' connection from pipe
Warn : No symbols for FreeRTOS!
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Info : Set GDB target to 'esp32.cpu0'
Error: Failed to get flash maps (4294967290)!
Warn : Failed to get flash mappings (-4)!
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
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
Error: Failed to get flash maps (4294967290)!
Warn : Failed to get flash mappings (-4)!
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Info : Using flash bank 'esp32.cpu0.irom' size 0 KB
Info : [esp32.cpu0] Target halted, PC=0x40092612, debug_reason=00000001
Error: Failed to get flash maps (4294967290)!
Warn : Failed to get flash mappings (-4)!
Info : [esp32.cpu0] Target halted, PC=0x40092612, 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! (1102 ms). Workaround: increase "set remotetimeout" in GDB
0x4013adf2 in esp_netif_action_connected (esp_netif=0x0, base=<optimized out>, event_id=-2146912519, data=0x3ffba850) at C:\Users\22380\.platformio\packages\framework-espidf\components\esp_netif\esp_netif_handlers.c:73
73	            if (memcmp(&ip, &old_ip, sizeof(ip))) {
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 0x1326c 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

I opened a new question containing a more detailed log, and we can continue the discussion there
https://community.platformio.org/t/esp32-jlink-debug-in-win10-vscode-pioinit-error-in-sourced-command-file-load-failed/30529