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: content/learn/02.microcontrollers/04.debugging/debugging.md
+23-19Lines changed: 23 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -154,11 +154,15 @@ The Arduino® Zero board features an on-board debugger, the Atmel® Embedded Deb
154
154
155
155

156
156
157
-
Arduino® boards with a SAMD microcontroller feature native on-chip debug capabilities; these debugging capabilities can be used with an external ICD tool over JTAG or SWD interfaces. CMSIS-DAP compliant debug probes can be used with the Arduino IDE 2.0 out of the box without any configuration file; non-standard debug probes require a special configuration. Check out these tutorials to learn how to use an external ICD tool with SAMD based Arduino boards and the Arduino IDE 2.0:
157
+
Arduino® boards with a SAMD microcontroller feature native on-chip debug capabilities; these debugging capabilities can be used with an external ICD tool over JTAG or SWD interfaces. **CMSIS-DAP compliant debug probes can be used with the Arduino IDE 2.0** out of the box without any configuration file; non-standard debug probes require a special configuration. Check out these tutorials to learn how to use an external ICD tool with SAMD based Arduino boards and the Arduino IDE 2.0:
158
158
159
159
*[Debugging with the SEGGER J-Link](https://docs.arduino.cc/tutorials/mkr-wifi-1010/mkr-jlink-setup).
160
160
*[Debugging with the Atmel-ICE](https://docs.arduino.cc/tutorials/mkr-wifi-1010/atmel-ice).
161
161
162
+
The [Arduino® Portenta H7](https://store.arduino.cc/products/portenta-h7), [H7 Lite](https://store.arduino.cc/products/portenta-h7-lite), and [H7 Lite Connected](https://store.arduino.cc/products/portenta-h7-lite-connected) boards from the [Pro family](https://www.arduino.cc/pro) also support ICD debugging; these boards use the TRACE32 debugger from Lauterbach. The TRACE32 debugger allows testing embedded hardware and software by using the in-circuit debug interface of processors. Check out this tutorial to learn how to use the TRACE32 debugger with the Portenta family boards:
163
+
164
+
*[Lauterbach TRACE32 GDB Front-End Debugger for Portenta H7](https://docs.arduino.cc/tutorials/portenta-h7/por-ard-trace32).
165
+
162
166
### Hardware Tools
163
167
164
168
Embedded systems developers and typical software developers differ on a key aspect: their "closeness" to hardware; embedded system developers are usually closer to hardware than typical software developers. There are several tools that embedded systems developers use to find out what is going on with the hardware, which is very helpful for low-level software debugging. These tools are **multimeters**, **logic analyzers**, **oscilloscopes**, and **software-defined radios** (SDRs).
@@ -224,7 +228,7 @@ Shown visual representation of the signal via SDR software can now be used to ve
224
228
225
229
## Debugging Techniques Example
226
230
227
-
A simple example will demonstrate the implementation of different debugging techniques and how they can be handy for the development process of a program in the Arduino® ecosystem. We will use the Arduino® Nano 33 BLE Sense board, and its onboard inertial measurement unit (IMU) features to show the debugging process's importance. The example code uses accelerometer, gyroscope, and magnetometer data simultaneously, having the tasks be executed to obtain every value:
231
+
A simple example will demonstrate the implementation of some of the debugging techniques we discussed before and how they can be handy for the development process of code in the Arduino® ecosystem. We will use the [Arduino® Nano 33 BLE Sense](https://store.arduino.cc/products/arduino-nano-33-ble-sense) board, and its onboard inertial measurement unit (IMU) features to show the debugging process's importance. The example code uses accelerometer, gyroscope, and magnetometer data simultaneously, having the tasks be executed to obtain every value:
228
232
229
233
```arduino
230
234
/*
@@ -297,7 +301,7 @@ void accelerometer_task() {
297
301
IMU.readAcceleration(x, y, z);
298
302
good++;
299
303
} else {
300
-
Serial.println(F("Accelerometer data not ready"));
304
+
Serial.println(F("- Accelerometer data not ready"));
301
305
bad++;
302
306
}
303
307
@@ -337,7 +341,7 @@ void accelerometer_task() {
337
341
}
338
342
339
343
// Gyroscope setup
340
-
void gyroscope_setup(){
344
+
void gyroscope_setup(){
341
345
Serial.print(F("- Gyroscope sample rate = "));
342
346
Serial.print(IMU.gyroscopeSampleRate());
343
347
Serial.println(F(" Hz"));
@@ -346,7 +350,7 @@ void gyroscope_setup(){
346
350
}
347
351
348
352
// Read gyroscope data in all three directions task
// Simple log of Good or Bad Pass Marks during runtime
407
-
Serial.println(F("\n Strategic Array Dump Result >>"));
408
-
Serial.print(F("Good Marks: "));
409
+
// Debugging array buffer
410
+
void disp_debug_buffer() {
411
+
Serial.println(F("\n Debugging array buffer result >>"));
412
+
Serial.print(F("- Good marks: "));
409
413
Serial.println(GoodBuffer[count]);
410
414
411
-
Serial.print(F("Bad Marks: "));
415
+
Serial.print(F("- Bad marks: "));
412
416
Serial.println(BadBuffer[count]);
413
417
}
414
418
415
-
void debug_stop(){
419
+
void debug_stop(){
416
420
Serial.flush();
417
421
exit(1);
418
422
}
@@ -430,7 +434,7 @@ In the Arduino Serial Monitor, we can observe that it has a `1` good mark and a
430
434
431
435
The accelerometer performed its task without any issue except the first runtime instance, resulting in `9` good marks but `1` bad mark due to this behavior. The `Serial.println(F())` instruction of module setups and task runtimes also shows us if the code could get past the operations without any issue. By this, it is possible to know the code structure does not misbehave, but for the first time when the device is starting, the accelerometer requires more time to get the data ready in the first instance.
432
436
433
-
Additionally, it is possible to modify the loop code by simply adding a `digitalWrite(LED_BUILTIN, HIGH)` instruction and a `digitalWrite(LED_BUILTIN, LOW)` instruction to measure the time it takes to complete the three module tasks. It will also be helpful to understand the power consumption it draws from this runtime instance:
437
+
Additionally, it is possible to modify the loop code by simply adding a `digitalWrite(LED_BUILTIN, HIGH)` instruction before tasks are called instruction and a `digitalWrite(LED_BUILTIN, LOW)` instruction after the tasks are exectued to measure the time it takes to complete them. This can also be helpful to understand the power consumption it draws from this runtime instance:
434
438
435
439
```arduino
436
440
void loop() {
@@ -442,7 +446,7 @@ void loop() {
442
446
digitalWrite(LED_BUILTIN, LOW);
443
447
}
444
448
445
-
Save_Debug_Buffer();
449
+
save_debug_buffer();
446
450
447
451
debug_stop();
448
452
}
@@ -459,7 +463,7 @@ Debugging is a necessary step for developing robust and reliable embedded system
459
463
460
464
Knowing the potential causes of bugs allows us to adopt strategies that minimize their occurrence. Many different debugging techniques and external devices are present to aid this process. Maybe some software designs do not require the usage of external debuggers, for example. However, when the software involves different requirements, especially scalability, things change drastically for the development process. The debugging techniques and the external debuggers will support this development process, thus granting sophisticated software. In most cases, we will know how the device will behave with the software, its computational performance, and even achieve non-power hungry devices due to clean memory management.
461
465
462
-
Debugging may be an overlooked aspect of development, but it is the most serious yet crucial tool for development. If we desire to develop a robust and reliable device, the debugging process should consistently be implemented to achieve this goals.
466
+
Debugging may be an overlooked aspect in developing embedded systems, but it is its most serious yet crucial tool. If we desire to develop robust and reliable embedded systems, the debugging process should consistently be implemented to achieve these goals.
0 commit comments