Skip to content

Commit 1f8fe98

Browse files
committed
Update tutorial content
1 parent 5010c9b commit 1f8fe98

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed
Loading

content/learn/02.microcontrollers/04.debugging/debugging.md

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ There are some basic debugging tools and techniques that we can use and implemen
2424
* Remote debuggers.
2525
* Simulators.
2626
* In-circuit emulators and in-circuit debuggers.
27-
* Hardware tools: oscilloscopes, logic analyzers and software-defined radios.
27+
* Hardware tools: multimeters, logic analyzers, oscilloscopes, and software-defined radios.
2828

2929
Let us take a look into each one of the debugging tools and techniques.
3030

@@ -117,7 +117,7 @@ Remote debuggers usually have two essential parts: a **front-end debugger** and
117117
* The front-end debugger contains the user interface (can be graphical or command-line-based) and offers the programmer choices about the execution of the code in the embedded system hardware.
118118
* The back-end debugger, also known as the "debug monitor," is specific for a particular processor architecture or family an usually work with an external hardware tool, like an in-circuit emulator or an in-circuit debugger. It starts when the processor resets and handles the runtime instruction between the front-end debugger and the embedded system hardware.
119119

120-
***The debugger tool is a newly introduced yet less famous feature of Arduino IDE 2.0. Check out [this tutorial](https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-debugger) that shows how to use the Arduino® IDE 2.0 debugger with compatible boards.***
120+
***The debugger tool is a newly introduced yet less famous feature of Arduino IDE 2.0. Check out [this tutorial](https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-debugger) that shows how to use the Arduino® IDE 2.0 debugger with supported boards.***
121121

122122
### Simulators
123123

@@ -131,10 +131,34 @@ Simulators are tools used to **simulate the functionality and the instruction se
131131

132132
An **in-circuit emulator** (or ICE) is a specialized tool that allows developers to examine the state of the processor while a particular program is running. ICEs are considered embedded systems by themselves; they are a copy of the target processor and its memory (RAM and ROM); this is why they provide an unintrusive way to debug code at the target processor. Historically, ICEs were the tool of choice of embedded systems developers, but as processor complexity and clock speed increased, ICEs became more expensive, and their availability declined considerably.
133133

134-
An **in-circuit debugger** (or ICD) is also a specialized tool connected between a host computer and a processor for debugging real-time applications faster and easier; this uses some memory and GPIO pins of the target microcontroller during the debugging operations. With an ICD, a monitor program runs inside the processor; with this program, the developer can set breakpoints, run code, single step the program, examine variables and registers on the processor, and, if required, change their values.
134+
An **in-circuit debugger** (or ICD) is also a specialized tool connected between a host computer and a processor for debugging real-time applications faster and easier; this tool uses some memory and GPIO pins of the target microcontroller during the debugging operations. With an ICD, developers access an on-chip debug module which is integrated into the CPU over an interface (for example, JTAG). This debug module allows developers to load, run, halt and step the processor.
135135

136136
***The fundamental difference between an ICE and an ICD relies on the resources used to control the debug target. In ICEs, resources are provided by the emulation hardware; in ICDs, resources are provided by the target processor.***
137137

138+
#### Arduino® ICD Support
139+
140+
The Arduino® boards with a SAMD microcontroller support ICD debugging; these boards are the following:
141+
142+
* [Zero](https://store.arduino.cc/products/arduino-zero).
143+
* [Nano 33 IoT](https://store.arduino.cc/products/arduino-nano-33-iot).
144+
* [MKR Zero](https://store.arduino.cc/collections/boards/products/arduino-mkr-zero-i2s-bus-sd-for-sound-music-digital-audio-data).
145+
* [MKR WiFi 1010](https://store.arduino.cc/collections/boards/products/arduino-mkr-wifi-1010).
146+
* [MKR WAN 1300](https://store.arduino.cc/products/arduino-mkr-wan-1300-lora-connectivity).
147+
* [MKR WAN 1310](https://store.arduino.cc/products/arduino-mkr-wan-1310).
148+
* [MKR FOX 1200](https://store.arduino.cc/products/arduino-mkr-fox-1200).
149+
* [MKR NB 1500](https://store.arduino.cc/products/arduino-mkr-nb-1500).
150+
* [MKR GSM 1400](https://store.arduino.cc/products/arduino-mkr-gsm-1400).
151+
* [MKR Vidor 4000](https://store.arduino.cc/products/arduino-mkr-vidor-4000).
152+
153+
The Arduino® Zero board features an on-board debugger, the Atmel® Embedded Debugger (EDGB). In addition to programming and debugging support, the EDGB also offers data streaming capabilities between the host computer and the target processor. Check out [this tutorial](https://docs.arduino.cc/tutorials/zero/debugging-with-zero) to learn how to use the Arduino® Zero board debugging capabilities with the [Arduino IDE 2.0](https://www.arduino.cc/en/software).
154+
155+
![Arduino® Zero EDGB.](assets/debugging_img07.png)
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:
158+
159+
* [Debugging with the Segger J-Link](https://docs.arduino.cc/tutorials/mkr-wifi-1010/mkr-jlink-setup).
160+
* [Debugging with the Atmel-ICE](https://docs.arduino.cc/tutorials/mkr-wifi-1010/atmel-ice).
161+
138162
### Hardware Tools
139163

140164
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).
@@ -145,7 +169,7 @@ Let us take a look at each one of the hardware debugging tools. A basic understa
145169

146170
#### Multimeters
147171

148-
A multimeter (DMM) is a hardware tool that can be used to measure two or more electrical values, usually voltage (in volts), current (in amps), and resistance (in ohms). DMMs are great tools and one of the most fundamental pieces of test equipment that can be used to debug electrical problems within an embedded system.
172+
A digital multimeter (DMM) is a hardware tool that can be used to measure two or more electrical values, usually voltage (in volts), current (in amps), and resistance (in ohms). DMMs are great tools and one of the most fundamental pieces of test equipment that can be used to debug electrical problems within an embedded system.
149173

150174
![Digital multimeter. Source: Fluke®.](assets/debugging_img06.png)
151175

@@ -173,7 +197,7 @@ While there may be several debugging techniques, using a LED as a pass mark for
173197

174198
Sometimes, LEDs might not be present or might not be available in a particular system; there is no way to make a visual inspection in the system. However, we can use an oscilloscope directly to monitor the state of GPIO pins of the system in this case. The oscilloscope, in this case, can be used to monitor specific GPIO pins and see if the code gives specific feedback by driving the GPIO pin to the desired logic state. A DMM can also be handy for the same task.
175199

176-
To get the most out of an oscilloscope and GPIO pins is by measuring its **performance**, this means to determine the an specific signal's **electrical and timing properties**. For example, an unnecessary delay in the code can be identified with this information:
200+
To get the most out of an oscilloscope and GPIO pins is by measuring its **performance**, this means to determine a signal's **electrical and timing properties**. For example, an unnecessary delay in the code can be identified with this information:
177201

178202
```arduino
179203
void myFunction() {
@@ -186,9 +210,9 @@ void myFunction() {
186210

187211
`myFunction()` execution duration can be measured by setting a GPIO pin to be driven to a high logic level when its execution begins; when `myFunction()` execution ends, the GPIO pin can be driven to a low logic level. An oscilloscope can then provide information if the function execution took precisely the defined time, longer or shorter than expected, or if it has any unaccounted electrical behavior that changes the expected behavior.
188212

189-
Now let's talk about **wireless communications**. Wireless communications are a key feature in the development of new Internet of Things (IoT) devices with different requirements or specifications and for different purposes. Wireless communication is present on many embedded systems, and Arduino® hardware is no exception for this feature. The question now is: how do we debug wireless communications between devices?
213+
Now let us talk about **wireless communications**. Wireless communications are a key feature in developing new Internet of Things (IoT) devices with different requirements or specifications and for different purposes. Wireless communication is present on many embedded systems, and Arduino® hardware is no exception for this feature. The question now is: how do we debug wireless communications between devices?
190214

191-
A simple technique used to debug wireless communications between devices consists of using **acknowledge flags**. Acknowledge flags are used to verify successful communication between devices; this process is found on physical communication layers, such as I2C or SPI, providing the present status between these devices. It goes the same for wireless communication between devices. Due to different protocol types in wireless communication, acknowledged methods may differ. The easiest way to confirm that the data exchange was successful is to check the log on each end device. So why would we need to debug on a radio frequency spectrum that is working correctly? It is to verify that the transceiver configuration is correct, mainly its transmission power.
215+
A simple technique used to debug wireless communications between devices consists of using **acknowledge flags**. Acknowledge flags are used to verify successful communication between devices; this process is found on physical communication layers, such as I2C or SPI, providing the present status between these devices. It goes the same for wireless communication between devices. Due to different protocol types in wireless communication, acknowledged methods may differ; the easiest way to confirm that the data exchange was successful is to check the log on each end device. So why would we need to debug on a radio frequency spectrum that is working correctly? It is to verify that the transceiver configuration is correct, mainly its transmission power.
192216

193217
There are several software to assist this process and one of them is GQRX supported on OSX and Linux. For the Windows operating system, AirSpy could be software of choice to assist for this type of task. The SDR via USB stick can be used as a low cost spectrum analyzer, using the user's computer as a hot for radio station. The devices to be debugged are powered on while SDR takes care of catching any present transmission on the air and display it on the screen.
194218

@@ -401,12 +425,12 @@ Additionally, it is possible to modify the loop code by adding simply GPIO 13 to
401425

402426
```arduino
403427
void loop() {
404-
for (int i = 0; i < 5; i++){
405-
digitalWrite(13, HIGH);
428+
for (int i = 0; i < 5; i++) {
429+
digitalWrite(LED_BUILTIN, HIGH);
406430
accelerometer_task();
407431
gyroscope_task();
408432
magnetometer_task();
409-
digitalWrite(13, LOW);
433+
digitalWrite(LED_BUILTIN, LOW);
410434
}
411435
412436
Save_Debug_Buffer();
@@ -424,7 +448,7 @@ Debugging is a necessary step for developing robust and reliable embedded system
424448
* **Localization**: this phase involves narrowing the range of possibilities until the bug can be isolated to a specific code segment in the embedded software.
425449
* **Correction**: this phase involves eradicating the bug from the software.
426450

427-
Knowing the potential causes of bugs, allows us to adopt strategies that can minimize their occurrence.
451+
Knowing the potential causes of bugs allows us to adopt strategies that minimize their occurrence.
428452

429453
## Further Reading and Resources
430454

0 commit comments

Comments
 (0)