Simple Dumping Monitor library for ATmega168/ATmega328p based Arduino boards allows you to dump registers, timer states, interrupts and memories, either RAM, Flash and ROM.
Starting with version 0.6 simple symbolic debugger functions were added.
Being compiled, the library requires near 11 KBytes of Flash memory and requires less than 1 KByte of RAM (227 Bytes for dumpmon.pde example, 377 Bytes for dumpmonDebug.pde example).
In order to use the library, you should download library's archive, unpack it to libraries directory of the Arduino IDE Software directory. As result it would be libraries/DumpMon directory created.
There are two sketches inside the DumpMon/Examples directory:
dumpmon.pde - to use the library as a sketch
dumpmonBlink.pde - this is the Blink example with serial monitoring functions
dumpmonDebug.pde - debugging functions example
After successful compilation and uploading of the sketch into Arduino board, open Serial Monitor window and set the correct USART speed (it uses 19200 in examples). Then use following commands to dump microcontroller states:
? - display help
R - dump current registers states
I - dump interrupt vectors table
V - display available RAM
T0 - dump Timer0 state
T1 - dump Timer1 state
T2 - dump Timer2 state
M000 - dump RAM memory, beginning from address 000
F0000 - dump Flash memory, beginning from address 0000
O000 - dump ROM memory, beginning from address 000
A - repeat previous command
C - continue the dump output (for timers - show next timer, for registers and interrupts - repeat the output
Addresses are hexadecimal only. Comands and addresses could be entered in both upper and lower cases.
Downloaded and installed in the arduino-0021/libraries folder, then read dumpmonBlink.pde into the IDE and get this when I compile
dumpmonBlink.cpp:4:57: error: dumpmon.h: No such file or directory
dumpmonBlink.cpp: In function 'void setup()':
dumpmonBlink:9: error: 'dumpmonSetup' was not declared in this scope
dumpmonBlink.cpp: In function 'void loop()':
dumpmonBlink:13: error: 'dumpmonLoop' was not declared in this scope
I don't normally use the IDE so don't know what to tweak.
Graynomad:
Downloaded and installed in the arduino-0021/libraries folder, then read dumpmonBlink.pde into the IDE and get this when I compile
dumpmonBlink.cpp:4:57: error: dumpmon.h: No such file or directory
It doesn't see DumpMon library at libraries folder.
Please try to restart Arduino IDE.
I've got some auto-reset issues with 0021 version. So I could recomend to install 0022.
How does this compare in size and complexity to an implementation that would support remote access from gdb?
I think there are some sample gdb for AVR out there...
westfw:
How does this compare in size and complexity to an implementation that would support remote access from gdb?
Debugging with AVR-GDB is made through JTAG interface with AVR ICE (In-Circuit Emulator).
This is much different way to debug. User can set breakpoint at any address of program without reprogramming of the Flash memory.
Debugging with AVR-GDB is made through JTAG interface with AVR ICE (In-Circuit Emulator).
Debugging with AVR-GDB is USUALLY done using JTAG or other debug interface, but gdb also has a "remote" protocol that can send the data over an ordinary serial line using a "stub" piece of software in the target (See http://www.hex-rays.com/idapro/idadoc/1335.shtml for instance.) Most reasonably complete "monitor" programs are pretty close to having all the features needed by the gdb remote protocol (but the parsing tends to be simpler for gdb remote.)
westfw:
Debugging with AVR-GDB is USUALLY done using JTAG or other debug interface, but gdb also has a "remote" protocol that can send the data over an ordinary serial line using a "stub" piece of software in the target (See http://www.hex-rays.com/idapro/idadoc/1335.shtml for instance.)
As I know, AVR ICE is an "Arduino as ISP programmer" board, which implements GDB Remote Serial Protocol for debugging via JTAG. This is more universal programmer, because it can be used with any AVR microcontrollers. I guess, AVR JTAG protocol is proprietary.
westfw:
Most reasonably complete "monitor" programs are pretty close to having all the features needed by the gdb remote protocol (but the parsing tends to be simpler for gdb remote.)
You want to know, does it to implement RSP is more difficult than to implement state machine with three switch case construction in three functions (dumpmonlib.cpp)? No, it's not more difficult, but it requires more Flash memory and more RAM, and it should work at bootloader memory (sketches work at program memory).
D:\Arduino\arduino-0022\libraries\DumpMon\registers.cpp: In function 'void getRegisters(registers_t*)':
D:\Arduino\arduino-0022\libraries\DumpMon\registers.cpp:148: error: 'PRR' was not declared in this scope
I just installed DumpMon 0.34 today and I got an error message complaining about ve_avr.h file not found in breakisr.cpp during compilation of dumpmonBlink sketch.
Fortunately the ChangeLog mentions ve_avr.h was renamed to ve_avr_dumpmon.h in version 0.34.. easy to fix.
WARNING: Category 'Device' in library Wio LTE Arduino Library is not valid. Setting to 'Uncategorized'
Build options changed, rebuilding all
C:\Users\dtran.TECOMSYS\Documents\Arduino\libraries\DumpMon\breakisr.cpp:12:20: fatal error: ve_avr.h: No such file or directory
#include "ve_avr.h"
^
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.