How to use the PlatformIO debugger on the ESP32 using an ESP-prog
Table of Contents
Introduction
This tutorial will guide you through the process of using the PlatformIO debugger with your ESP32 projects using an ESP-Prog programmer. You will learn how to set up the required hardware, install necessary drivers, configure PlatformIO, and use the debugging features effectively.
Step 1: Gather Required Hardware
To get started, ensure you have the following hardware components:
-
ESP-Prog:
- Purchase options:
-
ESP32 Boards:
- Examples include:
-
Debug Shields (optional):
Step 2: Install Necessary Drivers
Before you can use the ESP-Prog, you'll need to install the appropriate drivers:
-
FTDI Drivers:
- Download from FTDI Chip.
-
Zadig (for Windows users):
- Download from Zadig.
- Use this tool to install the driver for the ESP-Prog.
Step 3: Set Up PlatformIO
Follow these steps to set up PlatformIO:
-
Install PlatformIO:
- Visit PlatformIO's website and download the appropriate version for your IDE (e.g., VSCode).
-
Create a New Project:
- Open PlatformIO and click on “New Project.”
- Select your ESP32 board and choose the framework (e.g., Arduino).
-
Configure
platformio.ini:- Open the
platformio.inifile in your project. - Add the following lines to enable debugging:
debug_tool = esp-prog
- Open the
Step 4: Set Up Debugging Environment
To prepare for debugging, follow these steps:
-
Connect the ESP-Prog to your ESP32:
- Make sure to connect the pins correctly:
GNDtoGNDVCCtoVCCTMStoTMSTCKtoTCKTDItoTDITDOtoTDO
- Make sure to connect the pins correctly:
-
Upload Your Code:
- Write or upload your ESP32 code in PlatformIO.
- Use the upload option to flash your code onto the ESP32.
-
Start the Debugger:
- Click on the debug icon in PlatformIO.
- Set breakpoints in your code where you want to pause execution.
- Start the debugging session by clicking on the debug button.
Step 5: Using the Debugger
Once your debugger is set up, you can start using its features:
- Breakpoints: Set breakpoints in your code to pause execution and inspect variable states.
- Step Over/Into: Use these options to navigate through your code line by line.
- Watch Variables: Monitor the values of variables in real-time.
- Call Stack: Inspect the call stack to understand the flow of function calls.
Conclusion
You have successfully set up the PlatformIO debugger for your ESP32 projects using an ESP-Prog. This powerful tool will help you troubleshoot and improve your projects by allowing you to step through your code and inspect its operation in real time. For further exploration, consider diving deeper into debugging techniques or exploring additional features in PlatformIO. Happy debugging!