How to debug an ESP32-CAM with an Arduino project and GDB?

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

The ESP32-S Module is used in the ESP32-CAM Modules available, which can now be debugged using an External Hardware debugger, directly in Visual Studio, with vMicro!

Note Icon Note:

If you are using ESP32 Core v2.0.1 or 2.0.2 there is an issue with the GDB.exe reported here.  Roll Back to v2.0.0 to ensure this is reliable, or use 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: JTAG

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

NOTE: If using External JTAG debugging any SDCard functionality will need to be removed as this conflicts with the JTAG pin assignments.
           All boards support the vMicro Software Debugger which only requires the Serial interface to work


External Debugger Connections

To connect your JTAG debugger to the ESP32-CAM board you will need to connect the below pins:

ESP32-CAM JTAG Connections

 

For the ESP32-CAM you will also need to wire a USB-Serial converter to allow code upload, which can be wired in as below:

ESP32-CAM Upload Connections

 

Now both the USB-Serial and Debugger can be plugged into the PC.

NOTE - To perform each upload you need to connect IO0 to GND, Press Reset, Then Upload. Once complete remove the IO0 wire and press Reset again.

Software Setup

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 relevant Debugger you have available

Visual Studio Toolbar Selections for ESP32-CAM

You may need to install an additional USB Driver on Interface 0 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, it is best to upload the code first on this board due to the IO0 grounding, then:
    • "Debug > Attach to Process" button if your code has already been uploaded to the ESP32-CAM board
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 for the ESP32 below, which is the same as the ESP32-CAM for debugging:

 

Note Icon We Need Your Help:

If you want to see the Peripheral View feature in Visual Studio 2022 like we do, please upvote this issue with Microsoft.

 

Further Reading