How to debug an ESP32S3 via USB with an Arduino project and GDB?

× Not what you are looking for? Did you want USB/WiFi debug, trace and performance monitoring instead?

The ESP32SS3 Modules are being adopted many boards, all of which can now be debugged using an External Hardware debugger, directly in Visual Studio, with vMicro!

This page applies to all ESP32S3 Modules. See these pages for the ESP32S2 via JTAGESP32S3 via JTAGESP32C3 via USB, and ESP32C3 via JTAG.

Note Icon Note:

If you are using ESP32 Core v2.0.0 - 2.0.2 there is an issue with the GDB.exe reported here.  Update to v2.0.3 onwards which have the issue resolved.

If you are using "Upload via Programmer", ensure you do not use v2.0.4 as this has an issue with bootloaders.

 

External Debug Interface: USB (Default)

If you are looking to use JTAG to debug this board please see the seperate page here.

To see a list of all debuggers currently supported within vMicro please click here.

NOTE: Ensure no pin assignments in your Sketch or Libraries are using the IO19 or IO20 to ensure the USB Debugging works correctly.
           All boards support the vMicro Software Debugger which only requires the Serial interface to work


USB Debugger Connections

The ESP32C3 has a built in USB debug probe, which can be accessed by wiring up your board to a USB-A connector as shown below:

ESPS3 JTAG Connections

 

Then you will also need to connect your Debugger to the PC on one USB port, and the ESP32 on another USB Port.

 

Note Icon Note:

If debugging does not start successfully, try pulling GPIO3 to HIGH and repowering the board. This does depend on the fuse bits set on your chip.

Software Setup

Note Icon Note:

  • This is only reliable from vMicro Version 2022.0429.02 onwards.
  • This currenly requires a Local board.txt to function at its best:
    debug.toolingsystem=gdbscript
    # Most stable OpenOCD Version for newer ESP32 Boards 
    tools.openocd.debug.path={runtime.tools.openocd-esp32-0.10.1-2021.11.11.path}
    # Ensure the board resets when using Debug > Attach to Process for convenience
    vs-cmd.Debug.AttachtoProcess.tools.openocd.initCmd=-c "init; reset halt"
    # Ensure the Flash Size is set to 0 to prevent issues
    tools.esps3usb.vmserver.args={params.verbose} -l "{{build.path}/{build.project_name}_DebugOpenOCD.log}" -s "{path}/share/openocd/scripts/" -c "set ESP_FLASH_SIZE 0" -f "{path}/share/openocd/scripts/interface/{build.openocddebugger}" -c "set ESP32_RTOS none" {initCmd}
    
    

 

There is also a video guide to the software and driver setup described below

Ensure you have Visual Studio and the vMicro Extension Installed

Open your Sketch and select the Debug > Hardware, and the ESP32S3-USB probe.

Visual Studio Toolbar Selections for ESP32

NOTE - The vMicro > Debugger > Compiler Optimization MUST be set to "No Optimization" for this board to function with the debugger

You may need to install an additional USB Driver on Interface 2 of your debugger to allow it to function with this software - check in the debugger list here

Remember - If you have installed a new driver, you may have to do it again if you connect the debugger to a different USB port next time.....

 

Start Debugger

  1. Ensure you have the Debug Configuration selected from the Configuration Manager Window
  2. If you know where you want the first breakpoint in your code, add it now
  3. To start the debugging process, you can either:
    • "Debug > Attach to Process" button if your code has already been uploaded to the ESP32 board
    • "Debug > Start Debugging" if your code has not been uploaded
ESP32 Debugging in vMicro and Visual Studio

Congratulations - you should have the debugger running, and further windows can be opened from the "Debug > Windows" menu once you have started debugging

 

See our GDB Debugging in Brief guide, or our detailed GDB Debugging Tutorial for Arduino to learn more about using the debugging interface.

 

There is also a video guide on this below: