You want to make a single step in your program, but the debugger takes you to some unknown area of the program. This was, in fact, my first experience when I tried out Microchip’s MPLAB X IDE debugger on the innocent blinking sketch. Is this a bug or a feature?Continue reading
As mentioned in an earlier blog post this year, hardware debuggers are the premier class of embedded debugging tools. However, until today, there were only very few relatively expensive tools around supporting the debugWIRE interface that is used by the classic ATtinys and a few ATmega MCUs.
The good news is that now you can turn an Arduino Uno, Nano, or Pro Mini into a debugWIRE hardware debugger that communicates with
avr-gdb, the AVR version of the GNU project debugger.
When you develop a tool for a protocol that is undocumented, it is not surprising that you will encounter situations you will not have be anticipated. And this was exactly what I experienced developing the hardware debugger dw-link, which connects debugWIRE MCUs to the GDB debugger. Although a substantial part of the debugWIRE protocol has been reverse engineered, I encountered still plenty of surprising situations: Split personality MCUs, stuck-at-one bits in program counters, secret I/O addresses, half-legal opcodes, and more.Continue reading
The above xkcd comic, which is titled Debugger, alludes to the concern that when you try to apply a particular method to itself, you might not get what you asked for. Turing’s Halting problem is a very famous example of this, i.e., you cannot algorithmically decide whether an algorithm terminates on an input. So, does that issue apply to debuggers as well? In particular, I asked myself whether it makes sense to debug the hardware debugger I am developing with itself.Continue reading
Link-time optimization (LTO) is a very powerful compiler-optimization technique. As I noticed, it does not go very well together with debugging object-oriented programs under GCC, at least for AVR MCUs. I noticed that in the context of debugging an Arduino program, and it took me quite a while to figure out that LTO is the culprit.Continue reading
How can you use a stub in order to squash your software bugs? This blog post shows how to arrive in 7 easy steps at a working debugging solution using a gdb-stub for some 8-bit AVR MCUs. The only additional hardware you need is an ISP programmer in order to burn a new bootloader (well, if you are satisfied with a very slow running program, you do not even need this).
One has to add to the title (quoted from a tweet by Filipe Fortes) that the detective suffers from a memory loss. Otherwise, the case could be solved easily. Similarly, with debugging: If I only knew what nasty things I have hidden in the source code, I could just remove them – but I simply do not know. In this blog post, we will have a look at what kind of tools one could use to find the skeletons hidden in the closet.
Gdb, the GNU debugger, is probably the most used open source debugger for embedded systems. The AVR version of GDB on the Mac is unfortunately not very cooperative. If you try to read an elf file, you get the following funny message (reminding us of HAL9000):
I’m sorry, Dave, I can’t do that. Symbol format `elf32-avr’ unknown.
But with the right homebrew formula, one can teach GDB some new tricks …
EDIT: The problem has been solved by the homebrew maintainers.