I finally am able to use the Arduino IDE to do debugging using the USB JTAG built into the
ESP32s3! It's not perfect yet, still some bugs and issues. Here's a brief description. Treat it
as a series of hints. This was on a Windows 11 PC with Arduino IDE v 2.3.0. but I think Win 10 will be similar. The microprocessor board was an Adafruit QTPY esp32s3 but I think any esp32s3 using the native USB will be similar.
You'll need to dig around for details (e.g. the Zadig drivers) and your actual experience may differ from mine because of platform, OS etc.
I will not/can't help you with that, you'll have to work it out yourself. Just take heart that
it is now possible.
What appears to work for me, at least somewhat consistently is:
Make an arduino project for your esp32s3 device. Save it as usual.
Added a debug.cfg file to the project folder, and put "adapter driver esp_usb_jtag" in it. (no quotes)
Plugin your esp32s3 (not s2 as it doesn't support usb jtag interface....)
See if Windows device manager can see either a new com port or a dew device labelled as a usb jtag/serial.
If it's a pure serial com port, you might need to 'update' its driver to make it back into a usb jtag/serial unit (Use device manager, properties, browse, pick from list)
Use Zadig to update drivers for usb jtag device interfaces. Use USB Serial(CDC) on interface 0 and libusk on interface 2
(interface 2 might be hiding in the libusb devices)
Hit the icon on the IDE top bar to start debugging. This should create a launch.json file. It might fail because it can't flash the device.
Copy the debug config in launch.json and add it to the config array as a new config.
Make it "attach" rather than "launch". Give it a new name, "my config"
Restart the ide, open the debug window, make sure "my config" is selected from the dropdown.
Reset the micro to make sure a program is running on the micro (i.e that it isn't in boot mode)
hit the green triangle in the debug side window to start the debug
hit the blue triangle to run continuously, then || to pause, step over etc. Set break points.
Use dark theme, high contrast to better show line number in the source code. Be careful that it actually aligned. Try putting breakpoints in.
If they don't all go where you click but appear a few lines offset, you might not be aligned.
(i.e. you changed the source code since last compiling) Don't do that. It messes up the 'where am I in the source file" indication
Stop the debugger and hit reset on the micro before trying to upload new code to it.
Restart IDE after uploading new code if the debug window buttons all disappear. (Make sure to select "my config")
Rinse and repeat.
My heartfelt thanks to all who are working to make this feature work!
Thanks @tcornall! Support for a more powerful and flexible system of configuring Arduino boards platforms for use with the Arduino IDE 2.x integrated sketch debugger was added in Arduino IDE 2.3.0. Although the previous system is still generally supported, the initial debugger support implementation in the "esp32" boards platform had to use a quite hacky approach in order to overcome the limitations of the previous system and that initial implementation was broken by the changes in Arduino IDE 2.3.0. This is the reason why the debugging experience with ESP32 boards in Arduino IDE 2.3.0 is currently not very user friendly.
The "esp32" boards platform has already been updated to a much better approach taking advantage of the new system:
That pull request was merged earlier today, but there hasn't been a new release of the "esp32" boards platform since that time. Since you already have found a way to proceed with the latest release versions, you are probably happy enough to carry on with that until the situation improves with the next release of the "esp32" boards platform, but for anyone else who is struggling with that I can offer two alternatives:
Alternative A: Use Arduino IDE 2.2.1
As I mentioned above, the ESP32 debugging experience is currently more friendly with Arduino IDE 2.2.1. You can download Arduino IDE 2.2.1 from the links listed under the "Assets" section of the 2.2.1 release page in the IDE's GitHub repository:
You will get an update offer when you start Arduino IDE 2.2.1. You must decline that offer otherwise it will just update to 2.3.0.
You should watch for a new release of the "esp32" and/or "Arduino ESP32 Boards" (if you are using the Nano ESP32) platforms. Once that release happens, update to Arduino IDE 2.3.0 again.
Arduino IDE >=2.3.0 is required for debugging boards of the "Arduino Mbed OS" boards platforms. If you want to debug those boards in addition to ESP32 boards, you can keep your Arduino IDE 2.3.0 installation in place in addition to the 2.2.1 installation and use the appropriate IDE version for the debugging session with each board.
Alternative B: Use the development version of the "esp32" platform
The new debugger system is already in place in the development version of the "esp32" boards platform. Advanced users can follow the manual installation instructions here to get the development version of the platform:
Thanks @ptillisch.
I am embarrassed to admit that I initially forgot to add my greatest thanks for all the work of the Arduino team and other developers who are contributing to the ongoing efforts to get the IDE to meet everybody's expectations. The fact that I have toyed with VSC and ESP-IDF in order to use the debugger but have rushed back to the Arduino IDE just as soon as feasible speak to just how usable it is!
Debugger fails when trying to "launch" i.e. flash new code and then debug. I got around this using an "attach" configuration that uses existing uploaded code.
The debug side-window goes blank after I upload a newly compiled project. I simply restart the IDE. I may have to reset the micro as well before gdb-server is happy
Trying to single-step thru the constructor in a class . Culprit seems to be a maths function used on one line. pow(). Up until then single-stepping was ok. After that it wasn't. Since it was 2 to a power, I used 2<<n instead and now single stepping works ok. (will be a problem elsewhere tho')
Looking at local variables in the debug window and lots of them appear "optimized out" even though I have "optimize for debugging" turned on in the sketch settings
Small bother, but uploading newly compiled code WITHOUT first stopping the debugger causes problems. It'd be nice if that happened automagically.
Disabling a breakpoint has no effect. Still breaks at that point. So I remove them and put them back later. OK if I only have a few breakpoints but it's nice to have a list that I can turn off and on. Did find that if I disable/enable a break point, then stop debugging, then restart debugging, it DOES have an effect.
IDE 2.3.1 fixed the 'blank debug window' problem but introduced a new one. Now variables don't show. (This had been working in the nightly build I was using that also fixed the blank debug window but the released 2.3.1 has introduced this new problem)
The bug was fixed yesterday so if it is bothersome to you you can get the fix by using the latest nightly build of Arduino IDE. The nightly build download links are listed here:
Although the nightly build is generally intended to be used for beta testing, since the 2.3.0 release was made so recently the bug fix is the only difference between the release version and the current nightly build so the nightly should be as stable as the release version.
The configuration of the "esp32" platform causes the -Og flag to be used in the compilation commands when Sketch > Optimize for Debugging is enabled. This flag disables the types of optimizations that would make it difficult for a human to get any useful understanding of a program by stepping with the debugger, but it doesn't disable optimization altogether. The compiler will still optimize out unused variables.
An update that might help anyone "debugging esp32S3 using built-in JTAG".
After a bit of trial and error the debugger seems to work great with IDE 2.3.2 and ESP32 Arduino Core 2.0.15. The new core was released last week. I did not need to edit the cfg or json files as in @tcornall's workarounds. debug.cfg, debug.svd and debug_custon.json files automatically showed up in the project folder. I did update the drivers with Zadig but I'm not sure it was necessary. I got a flash write error at one point but that might have gone away after updating the ESP32 Arduino Core. I'm not quite sure because it was trial and error at that point.
The board I'm using is a LilyGO T-Display-S3 AMOLED Touch. It's great having real source-level debugging.
Thanks to the Arduino team for enabling this functionality!
OK, I am SO glad I found this thread as all else that I have tried was an absolute failure! As of now (today) this is what I did to enable ESP-32 "LilyGO T-Display-S3" debugging in Arduino IDE 2.3.3 under Win11 Home:
I did load the idf-env drivers from expressif using their powershell script from expressif. When the ESP-32 is plugged in I now see a "UST JTAG/serial debug unit" in device manager (don't believe that was there prior).
Then:
Install/upgrade to "Arduino 2.3.3"
Install the "esp32" boards by Espressif Systems, v3.0.5
Install the "Arduino ESP32 Boards" by Arduino, 1.8.6 (not actually used but do anyway...)
-- When prompted ALLOW the driver to be installed (critical step - apparently)
Select the "LilyGo T-Display-S3" board from the esp32 board set
Load your sketch (I tested with the "GetChipID" ino
Plug in your board and make sure it is seen
Select your brake-point(s)
Compile and load sketch
Start debugger
I did not load the zadig drivers.
It is/seems a little wonky at times AND can not currently use serial console while debugging BUT since I can trace/watch/break small price to pay. It is working now.
I have spend a couple of weeks on and off trying to get this to work. Very happy I can now use a "real" debugger/debugging on my STM32F(s) and ESP-32 C3(s)!
Update: I can now also use the serial monitor, not sure why as I changed nothing. Used the example "WiFiScan", can debug and also see console Serial.print output. Nice...