Skip to content

Commit 4419ec1

Browse files
committed
Add debugging documentation
1 parent 15aa07f commit 4419ec1

File tree

9 files changed

+96
-0
lines changed

9 files changed

+96
-0
lines changed

content/hardware/03.nano/boards/nano-esp32/features.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ The Nano ESP32's core is based on the well maintained & documented <a href="http
2727
The first Nano board to feature a USB-C® connector!
2828
</Feature>
2929

30+
<Feature title="Debugging" image="mcu">
31+
The Nano ESP32 supports out of the box debugging with no additional hardware required!<FeatureLink variant="secondary" title="Documentation" url="/tutorials/nano-esp32/debugging"/>
32+
</Feature>
33+
3034
</FeatureList>
294 KB
Loading
177 KB
Loading
113 KB
Loading
112 KB
Loading
157 KB
Loading
89.1 KB
Loading
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
title: Debugging with the Nano ESP32
3+
description: Get started with debugging using the Arduino Nano ESP32 with the IDE 2.
4+
author: Hannes Siebeneicher
5+
hardware:
6+
- hardware/03.nano/boards/nano-esp32
7+
tags: [ESP32, Debugging, IDE]
8+
---
9+
10+
Debugging is a crucial step especially when developing more complex projects. But even for beginners, it can be worth looking into as it gives you a lot more insights on what your code does at a specific time.
11+
12+
## What Is Debugging?
13+
14+
Debugging is an essential skill for anyone working with technology, whether you're a software developer, a student learning to code, or someone who just wants to understand how computers work. Here's why it's so crucial:
15+
16+
**Improving Performance**: Debugging helps identify and resolve issues that can slow down your software or make it behave unpredictably.
17+
18+
**Ensuring Reliability**: Debugging ensures that your programs and devices work correctly and reliably, preventing crashes or malfunctions.
19+
20+
**Saving Time and Frustration**: Fixing bugs early in the development process can save you hours, days, or even weeks of frustration down the road.
21+
22+
**Learning Opportunity**: Debugging challenges your problem-solving skills and deepens your understanding of programming and technology.
23+
24+
## Software & Hardware Needed
25+
26+
- [Arduino Nano ESP32](https://store.arduino.cc/nano-esp32)
27+
- [Arduino IDE](/software/ide-v2)
28+
- [Arduino Nano ESP32 Core](https://github.com/arduino/arduino-esp32) (2.0.12 or newer)
29+
30+
## IDE Setup
31+
32+
In order to use the debugging feature on the Nano ESP32 you will need to download and install the IDE 2.2.0 or newer. After you install it, you have to configure the IDE as follows:
33+
34+
- **Tools** > **USB Mode** > **Debug mode (Hardware CDC)**
35+
36+
![Debug Mode](./assets/debugMode.png)
37+
38+
- **Tools** > **Programmer** > **Esptool**
39+
40+
![Select Programmer](./assets/programmer.png)
41+
42+
- **Sketch** > **Optimize for Debugging**
43+
44+
![Optimize for Debugging](./assets/optimize.png)
45+
46+
## Running a Debug Session
47+
48+
If this is your first time debugging your code we recommend starting with the classic Blink example. It's a simple sketch but works great for understanding the basics of debugging.
49+
50+
Before starting a debug session make sure to always do one of the following:
51+
52+
- Either connect a jumper cable between the **GND** and the **B1** pins and press the reset button **once**. The RGB LED will turn on with a green or blue color. Inside **Tools**, the board will be shown as a random ESP32 board.
53+
54+
***This is because in this mode all ESP32 chips share the same identifier assigned to USB devices, therefore the IDE selects a random ESP32 board.***
55+
56+
Continue to select **Tools** > **Board** > **Arduino Nano ESP32** as well as the correct **Port**.
57+
58+
After that select **Sketch** > **Upload Using Programmer**.
59+
60+
- Or double tap the reset button. You will see the RGB LED fading slowly which means you correctly entered the recovery / Device Firmware Update (DFU) mode. You should see two ports in the drop-down menu, one showing a USB symbol and another one showing a cube.
61+
62+
![DFU Mode](./assets/dfuMode.png)
63+
64+
**After the upload completes** either way, make sure to also **manually reset** the board by pressing the reset button **once**. Otherwise, it may not properly connect via USB and not show up inside the IDE.
65+
66+
Finally, after completing all steps above the last step is to start the debugging sessions via the **Start Debugging** button found at the top of the IDE next to the Upload button.
67+
68+
![Start Debugging](./assets/startDebugging.png)
69+
70+
***Note: During the upload you will see a debug_custom.json being created at the top of the IDE. If you want to debug using another board it's important that you delete this file otherwise the IDE will use the wrong debugger and fail. You can find the file inside your sketch folder at ~\Documents\Arduino\skecthes\"Your Sketch".***
71+
72+
After starting the debugging session you will have to press the continue button **several times** until you reach you main sketch and the breakpoints you set. This is due to how the recovery system works and is **expected behavior**.
73+
74+
![Continue Button](./assets/continueBtn.png)
75+
76+
## Restore Normal Upload Functionality
77+
78+
Debug-enabled sketches will only accept updates with the above instructions. To restore normal upload functionality, set **Tools** > **USB Mode** to "**Normal mode (Tiny USB)**". You can also uncheck "**Optimize for Debugging**" to increase compilation speed.
79+
80+
Then repeat the steps described above:
81+
82+
- Either connect a jumper cable between the **GND** and the **B1** pins press the reset button **once** and upload using programmer
83+
84+
- Or **double tap** the reset button to enter **DFU mode** and perform a normal upload using the upload button.
85+
86+
## Learn More
87+
88+
To learn more about how to debug using the IDE check out [Debugging with the Arduino IDE 2](/software/ide-v2/tutorials/ide-v2-debugger)
89+
90+
## Summary
91+
92+
In this article we covered the basic steps for getting started with debugging using the Arduino Nano ESP32 and the IDE 2.
685 KB
Loading

0 commit comments

Comments
 (0)