Source: Make: DIY Projects and Ideas for Makers
If you’re making (or disassembling) anything complicated, you might yearn for a better view inside. An oscilloscope or logic analyzer can be a vital tool for digital electronics, and also surprisingly useful for embedded software. Your code can help too, via messages logged to file or serial port.
But sometimes you really need an interactive view of your program’s internals, and on an embedded system this means you need an in-circuit debugger (ICD).Some of you already know about source-level debugging from other contexts, like debugging desktop applications in Xcode or Visual Studio, using breakpoints and single-step functionality for scripts in a web browser’s console, or using a standalone debugger like the GNU Debugger, WinDbg, or LLDB. If you’re more used to Arduino, however, this kind of tool might be new to you.
Debugger generally refers to a system made up of debugging software on your PC, possibly software on the chip you’re testing, and usually some hardware both inside and outside the chip. Many microcontrollers have an on-chip debugger (OCD) baked into the silicon.
A debugger can step through code one line or instruction at a time while showing the contents of variables, and can view or edit memory. You can run your program at full speed until it hits a breakpoint — an intentional pause in your code — where it stops and the debugger resumes. With a debugger attached, you can also typically interact with a processor’s peripherals, load programs into flash memory, and read the flash contents (unless protections are in place to prevent this!
).What’s a Debug Server?
The debugger app on your PC keeps a detailed memory map for your code, but you also need some hardware — or software — on your microcontroller to provide for reading and writing memory, trapping breakpoints, and running instructions in a controlled way. One solution is a debug server.
The GNU Debugger (GDB) defines an especially simple server protocol for use over a serial port or network, including localhost. Implementations of this gdbserver exist for different operating systems. Traditionally this was a software-only component, but the protocol is now commonly used as a gateway to hardware devices or emulators.
Likewise, your IDE options now range far beyond a basic GDB command line, with tools like Eclipse, Visual Studio Code, and IDA Pro supporting the same GDB protocol.
Hardware Debug Ports
…
The post Get Started with In-Circuit Debugging appeared first on FeedBox.