How to use the PlatformIO debugger on the ESP32 using an ESP-prog

3 min read 1 year ago
Published on Aug 09, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

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:

Step 2: Install Necessary Drivers

Before you can use the ESP-Prog, you'll need to install the appropriate drivers:

  1. FTDI Drivers:

  2. 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:

  1. Install PlatformIO:

  2. Create a New Project:

    • Open PlatformIO and click on “New Project.”
    • Select your ESP32 board and choose the framework (e.g., Arduino).
  3. Configure platformio.ini:

    • Open the platformio.ini file in your project.
    • Add the following lines to enable debugging:
      debug_tool = esp-prog
      

Step 4: Set Up Debugging Environment

To prepare for debugging, follow these steps:

  1. Connect the ESP-Prog to your ESP32:

    • Make sure to connect the pins correctly:
      • GND to GND
      • VCC to VCC
      • TMS to TMS
      • TCK to TCK
      • TDI to TDI
      • TDO to TDO
  2. Upload Your Code:

    • Write or upload your ESP32 code in PlatformIO.
    • Use the upload option to flash your code onto the ESP32.
  3. 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!