I am trying to use the builtin JTAG serial to debug my ESP32S3 project. The issue I am facing is the debugger does not stop at setup when starting debugging.
Once the project is running I need to interrupt it, clear all breakpoints (in spite of none being set), then I can set a breakpoint, continue the project, then the breakpoint is hit.
This is my INI file:
platform = espressif32
board = um_tinys3
framework = arduino
build_type = debug
build_flags =
'-D ARDUINO_USB_MODE=1'
'-D ARDUINO_USB_CDC_ON_BOOT=1'
debug_tool = esp-builtin
debug_init_break = break setup
upload_port = COM3
upload_speed = 115200
; upload_protocol = espota
; upload_port = 10.0.0.100
; monitor_port = COM3
monitor_speed = 460800
lib_deps = contrem/arduino-timer @ ^3.0.1
ArduinoOta
This makes debugging slower than the already slow builtin JTAG.
If you don’t have a “setup” function declared, you should see an error (i.e. Function “setup” not defined) while monitoring the debug console.
I am using the esp-idf framework with PlatformIO and VS-Code, and my .ini configuration is similar to yours. However, in my case, I have it set to break when it hits the ‘app_main’ function. See screenshots.
;build in debug mode instead of release mode
build_type = debug
; serial upload options
upload_speed = 2000000 ;ESP32-S3 USB-Serial Converter maximum 2000000bps
upload_port = COM3
; serial monitor options
monitor_speed = 115200
monitor_port = COM10
; debugging options
debug_init_break = break app_main
debug_tool = esp-builtin
It is slow as molasses but you get used to it. 
1 Like
Thank you.
I do have setup defined and in the debug view I see:
PlatformIO: Resume the execution to `debug_init_break = break setup`
However, it doesn’t stop there.
1 Like
Yeah. Same here. You will realize this: once start debugging that way, it just goes through debug_init_break and it keeps running; if you set a breakpoint somewhere at loop(), it actually stops.
Try comment “debug_ini_break” out of platformio.ini and set no breakpoints: it shoud stop at app_main (Arduino Framework) and then you can set your breakpoints at setup(). No new findings for that issue.
Fun fact: ESP32 S3 indeed DOES break at setup() using Arduino IDE… xD
That’s my platformio.ini and some personal remarks:
[env:esp32-s3-devkitc1-n16r8] ; [may-2025] https://github.com/sivar2311/platformio_boards/tree/main/boards
platform = espressif32
board = esp32-s3-devkitc1-n16r8
framework = arduino
; extras
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
monitor_port = COM9 ; primary usb port for programming/monitoring: Windows > Device Manager > Ports > "USB-Enhanced-SERIAL CH343 (COM9)"
upload_port = COM9 ; same - no need to use jtag COM port: Windows > Device Manager > Ports > "USB JTAG/serial debug unit (Interface 0) (COM10)"
monitor_dtr = 0 ; prevents "wait for download mode whenever Serial Monitor task is started"
monitor_rts = 0 ; prevents "wait for download mode whenever Serial Monitor task is started"
; for jtag debugging
build_type = debug
debug_tool = esp-builtin
; debug_init_break = break setup ; yes - it's commented out; to default break at app_main()
PS: Although its related to ESP32, the following link at “Debugging the Firmware” shows the app_main() break behaviour.
https://docs.platformio.org/en/stable/tutorials/espressif32/arduino_debugging_unit_testing.html
I have updated OpenOCD in pioarduino in branch development. You can try with
platform = https://github.com/pioarduino/platform-espressif32.git#develop
1 Like
@msantos2007, @jason2866, Thank you for the input.
My initial problem is that I am not using the pioarduino platform, must change that and give these suggestions a try.
Again … thanks.
1 Like
@jason2866 I tried the new repository and it has broken my build:
‘xtensa-esp32s3-elf-g++’ is not recognized as an internal or external command,
I went back to my original platform.ini and it is still broken.
delete the hidden folder .platformio
Platformio will reinstall.
1 Like
OK, I deleted the .platformio hidden folder, and my original project now builds.
I will try the alternate platform repo later, need to get some work done now.
I hope I don’t need to go through this again to use the new repo?
Also, I noticed you link was for the development branch and not the release branch. Is that required?
I had to remove any “Espressif 32” related platforms at Pio Home > Platforms > Installed tab. Then, at Desktop Tab, hit Advanced Installation, pasted @jason2866 's link and Install.
Here is updated platformio.ini:
[env:esp32-s3-devkitc1-n16r8]
platform = espressif32
board = esp32-s3-devkitc1-n16r8
framework = arduino
; extras
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
monitor_port = COM9
upload_port = COM9
monitor_dtr = 0
monitor_rts = 0
; for jtag debugging
build_type = debug
debug_tool = esp-builtin
debug_init_break = tbreak setup
; prevent not showing variables (Variables List) or skip some breakpoints by debugger
debug_build_flags = -O0
-g3
-ggdb3
@jason2866 @msantos2007
I Installed the release build of pioarduino and was able to get my project to build correctly.
Also, by removing “debug_init_break = tbreak setup” the code stopped at the program entry point, and I was able to then set a breakpoint at the start of “Setup.”
While single-stepping the code was reasonable, the time taken to start debugging was extremely long, in excess of 40 seconds, and that was when the code did not need rebuilding.
My computer is a fast HP laptop with 64GB of memory, so that is not the issue. When doing non-Arduino work, e.g. STM32, build/flash/run times are very, very fast.
Is this what you see for startup performance?
1 Like
Don’t know the project, so i can’t say anything about. Just one note avoid Windows it needs for everything nearly twice the time than Linux orr MAC
1 Like