You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _dev/How-to-debug.md
+55-82Lines changed: 55 additions & 82 deletions
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,47 @@
1
1
# How to debug
2
2
3
3
Below, some ways to debug:
4
+
*[Arduino IDE 2 (Supported and recommended way)](#arduino-ide-2-supported-and-recommended-way)
4
5
*[Eclipse and Sloeber](#eclipse-and-sloeber)
5
6
*[PlatformIO](#PlatformIO)
6
7
*[Visual Studio and VisualGDB](#visual-studio-and-visualgdb)
7
8
*[Visual Studio Code and Arduino extension](#Visual-Studio-Code-and-Arduino-extension)
8
9
*[Command line GDB](#command-line-gdb)
9
10
10
11
> [!WARNING]
11
-
> **Only the Arduino IDE is officially supported.**
12
+
> **Only the Arduino IDE 2 is officially supported.**
12
13
14
+
# Arduino IDE 2 (Supported and recommended way)
15
+
16
+
> [!Note]
17
+
> Requires a [ST-Link/V2](https://www.st.com/content/st_com/en/products/development-tools/hardware-development-tools/hardware-development-tools-for-stm32/st-link-v2.html) or [ST-Link/V3](https://www.st.com/en/development-tools/stlink-v3set.html) device connected to the PC over USB and to the board via the SWD interface.
18
+
19
+
1. If not already done, [[Getting-Started#Install-Arduino.cc-IDE]]
20
+
21
+
2. Configure the IDE to the desired board. Here the [Nucleo L476RG](http://www.st.com/en/evaluation-tools/nucleo-l476rg.html) which already includes a ST-Link.
22
+
23
+
See [[Getting-Started#configuring-ide]]
24
+
25
+
3. Open the Blink sketch from the "**File> Examples > 01.Basics > Blink**".
26
+
27
+
4. Select the "**Optimize for debugging**" in the "**Sketch**" menu:
28
+
29
+
[[/img/debug/arduino/OptimizeDebug.png|alt="Optimize for debugging"]]
30
+
31
+
5. Click the upload button
32
+
33
+
See [[Getting-Started#upload-method]] to change the upload method.
> Refer to official documentation to see how [Using the Debugger](https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-debugger/#using-the-debugger).
13
45
14
46
# Eclipse and Sloeber
15
47
## 1 - Software requirements
@@ -29,11 +61,11 @@ The GNU MCU Eclipse plug-ins provide multiple tools based on the GNU toolchains
29
61
30
62
Launch Eclipse, go to _**“Help > Eclipse Marketplace”**_ and search for the _**"GNU MCU plug-in"**_. <br>
In the tree view, expand _**“GNU MCU Eclipse {version}”**_ and uncheck all items. In previous versions, you had to choose the OpenOCD entry. Since there is no such entry, you cannot select it. OpenOCD will automatically be installed. Confirm and follow the recommended instructions. Then restart Eclipse.<br>
To finish the OpenOCD plug-in configuration, and for a simpler integration, install OpenOCD binaries by following the [“How to install the OpenOCD binaries”](https://gnu-mcu-eclipse.github.io/openocd/install/
39
71
) tutorial. This Guide will tell you to extract the openocd binaries to a specific path (Windows).
@@ -42,19 +74,19 @@ To finish the OpenOCD plug-in configuration, and for a simpler integration, inst
42
74
From the Eclipse main tab, go to _**“Help > Eclipse Marketplace”**_ and search for _**Sloeber**_. <br>
43
75
Download the _**"Sloeber plugin"**_ , follow the recommended instructions and restart Eclipse. <br>
44
76
By now, the main tab should look like the following:
Hit _**“Apply and Close”**_ then re-open the _**“Arduino > Preferences”**_ menu. The STM32 Core is now available in the _**“Platforms and Boards”**_ menu.
Move to the _**“Startup”**_ tab, scroll until the _**“Run/Restart Commands”**_ fields and add:<br>
160
192
```
@@ -172,11 +204,11 @@ If the configuration process runs correctly, you will be able to see the debug c
172
204
173
205
If you are facing problems with messages like "binary not found" you should try to click on the drop down menu and then on your configuration instead of just click on the debug icon.
Now, you can easily debug your code by using the Eclipse debug features including running step-by-step mode, live breakpoint, inspecting memory access, live view of variable contents and many more.
> For further options see [vscode-arduino Readme](https://github.com/microsoft/vscode-arduino/blob/main/README.md)
219
-
220
-
Now, Ensure STM32 core installation is installed by opening the "**Arduino Board Manager**". Open the Command Palette (<kbd>F1</kbd> or <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd>) and search/select **Arduino: Board Manager**, `STM32 Cores` should be listed in `Contributed` Type:
Firstly, it is necessary to choose a board to build.
229
-
230
-
Open the "**Arduino Board Configuration**". Open the Command Palette (<kbd>F1</kbd> or <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd>) and search/select **Arduino: Board Config**
In this example, [Nucleo L476RG](http://www.st.com/en/evaluation-tools/nucleo-l476rg.html).
235
-
236
-
### 3.2 Choose an example
237
-
238
-
Open the "**Arduino Examples**" by opening the Command Palette (<kbd>F1</kbd> or <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd>) and search/select **Arduino: Examples**
Opening the Command Palette (<kbd>F1</kbd> or <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd>) and search/select **Arduino: Verify** to only build or **Arduino: Upload** to build and upload.
See the Visual Studio Code extension for Arduino [README.md](https://github.com/microsoft/vscode-arduino/blob/main/README.md).
264
234
265
235
# Command Line GDB
266
236
267
-
## 5. Command Line GDB
268
-
### 5.1. Requirements
237
+
## 1. Command Line GDB
238
+
### 1.1. Requirements
269
239
* Linux, tested in Ubuntu 18.04
270
240
* Requires Arduino IDE with stm32duino installed
271
241
* STLink compatible dongle
272
242
* assuming Blue Pill board, but it probably work with any other STM32 board
273
243
274
-
### 5.2. Compiling for Debug
244
+
### 1.2. Compiling for Debug
275
245
* In the Arduino IDE, go to menu File->Preferences and check compilation verbose
276
246
* Open your code, for example, the blink code
277
247
* In the Arduino IDE, go to Tools->Optimize->Debug. This will include -g in the compilation process, including debug symbols
@@ -321,7 +291,7 @@ Application is running
321
291
Start operation achieved successfully
322
292
```
323
293
324
-
### 5.3 Debugging with Command Line GDB
294
+
### 1.3 Debugging with Command Line GDB
325
295
326
296
* Open a terminal and run `st-info` to start gdbserver
327
297
* Open another terminal and run `~/.arduino15/packages/STM32/tools/xpack-arm-none-eabi-gcc/9.2.1-1.1/bin/arm-none-eabi-gdb /tmp/arduino_build_742171/Blink-stm32.ino.elf` to run the gdb used by stm32duino. Note that the path to the ELF file was figure out in the compilation messages in the Arduino IDE, shown in the previous section.
@@ -349,7 +319,10 @@ c
349
319
c
350
320
```
351
321
352
-
### 5.4 Debugging with GUI GDB
322
+
### 1.4 Debugging with GUI GDB
353
323
354
324
* It is also possible to debug with GUI, such as `ddd`. It requires software installation with the command `sudo apt-get install -y ddd`.
355
-
* To run `ddd`, open a terminal and type `ddd --debugger ~/.arduino15/packages/STM32/tools/xpack-arm-none-eabi-gcc/9.2.1-1.1/bin/arm-none-eabi-gdb /tmp/arduino_build_742171/Blink-stm32.ino.elf`. Note that you must point to the appropriate gdb and ELF file.
325
+
* To run `ddd`, open a terminal and type `ddd --debugger ~/.arduino15/packages/STM32/tools/xpack-arm-none-eabi-gcc/9.2.1-1.1/bin/arm-none-eabi-gdb /tmp/arduino_build_742171/Blink-stm32.ino.elf`.
326
+
327
+
> [!NOTE]
328
+
> Check to point to the appropriate gdb and ELF file.
0 commit comments