Skip to content

Commit acc58da

Browse files
committed
Clarify debugging steps
1 parent 3e83dd3 commit acc58da

File tree

2 files changed

+38
-13
lines changed

2 files changed

+38
-13
lines changed
216 KB
Loading

content/hardware/03.nano/boards/nano-esp32/tutorials/debugging/debugging.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,57 @@ To use the debugging feature on the Nano ESP32, you need to have the IDE 2.2.0 o
4747

4848
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.
4949

50-
Before starting a debug session make sure to always do one of the following:
50+
Before starting a debug session you need to upload your sketch using one of the following methods:
5151

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. Remove the jumper cable and you should see the RGB LED light up in a purple or yellow color. Then inside **Tools**, the board will be shown as a random ESP32 board.
52+
### Method 1
53+
54+
- 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.
55+
56+
- Remove the jumper cable and you should see the RGB LED light up in a purple or yellow color. Note that inside **Tools**, the board will be shown as a random ESP32 board.
5357

5458
***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.***
5559

56-
Continue to select **Tools** > **Board** > **Arduino Nano ESP32** as well as the correct **Port**.
60+
- Continue to select **Tools** > **Board** > **Arduino Nano ESP32** as well as the correct **Port**.
61+
62+
![Select Port](./assets/selectPort.png)
63+
64+
- After that select **Sketch** > **Upload Using Programmer**.
5765

58-
After that select **Sketch** > **Upload Using Programmer**.
66+
### Method 2
5967

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.
68+
- Slowly double-tap the reset button to enter the recovery / Device Firmware Update (DFU) mode.
69+
70+
***Performing the double press can be a little tricky. Press it once, wait until you see the RGB LED flashing in different colours, then press again. If done correctly the RGB LED will start fading slowly.***
71+
72+
- You should see two ports in the drop-down menu, one showing a USB symbol and another one showing a cube.
6173

6274
![DFU Mode](./assets/dfuMode.png)
6375

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.
76+
- Select the port next to the **USB symbol** and upload a sketch like normal.
77+
78+
### After Successful Upload
79+
80+
After uploading a sketch using **either** Method 1 or Method 2 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.
6581

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.
82+
### Start Debugging
83+
84+
Finally, after completing all necessary 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.
6785

6886
![Start Debugging](./assets/startDebugging.png)
6987

7088
***Note: During the upload you will see a debug_custom.json appear in the file view. 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, typically at `~/documents/Arduino/<yoursketch>`***
7189

90+
### Debugging on Linux
91+
92+
When debugging on a Linux machine you may encounter the following error, due to your user not having the authorization to connect:
93+
94+
```
95+
Error: libusb_open() failed with LIBUSB_ERROR_ACCESS
96+
Error: esp_usb_jtag: could not find or open device!
97+
```
98+
99+
To fix this, you can copy [this file](https://raw.githubusercontent.com/espressif/openocd-esp32/master/contrib/60-openocd.rules) in your `/etc/udev/rules.d/` folder (as root).
100+
72101
After starting the debugging session you have to press the continue button **several times** until you reach your main sketch and the breakpoints you set. This is due to how the recovery system works is expected behavior.
73102

74103
![Continue Button](./assets/continueBtn.png)
@@ -77,15 +106,11 @@ After starting the debugging session you have to press the continue button **sev
77106

78107
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.
79108

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.
109+
Then **either** repeat [Method 1](#method-1) or [Method 2](#method-2).
85110

86111
## Summary
87112

88-
In this article we covered the basic steps for debugging the Arduino Nano ESP32 using the Arduino IDE. We have learned how to select the debug mode, how to place the board in the right mode, and how to test out the Arduino IDE's debugging features.
113+
In this article, we covered the basic steps for debugging the Arduino Nano ESP32 using the Arduino IDE. We have learned how to select the debug mode, how to place the board in the right mode, and how to test out the Arduino IDE's debugging features.
89114

90115
## Learn More
91116
This article only covers how to configure the Nano ESP32 for debugging, and how to get things working. To learn more about how to use the debugging features in the IDE, see the [Debugging with the Arduino IDE 2](/software/ide-v2/tutorials/ide-v2-debugger) article, which covers things in more detail.

0 commit comments

Comments
 (0)