Go Down

Topic: Simple Dumping Monitor (Read 5780 times) previous topic - next topic

Vanyamba

Feb 02, 2011, 07:47 am Last Edit: Mar 01, 2011, 03:46 am by Vanyamba Reason: 1
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.

More about debugging functions of the library http://arduino.cc/forum/index.php/topic,51910.0.html

Download DumpMon http://sites.google.com/site/vanyambauseslinux/home/fajlovyj-menedzer/DumpMon-0.7.tar.gz (17,7 KB)

Attach below is version 0.1. Current version is 0.7. Please download DumpMon with link above.

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
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.

______
Rob

Rob Gray aka the GRAYnomad www.robgray.com

Vanyamba


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.

Graynomad

OK I've managed to have a dump, thanks.

Still with 21, I guess the IDE only reads the include paths when it boots.

BTW, I'm writing something similar but mine is different in that it uses some hardware to reduce the footprint on the target system.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Vanyamba

That's great!  :)

I've just updated Simple Dumping Monitor. Current version is 0.3.
http://sites.google.com/site/vanyambauseslinux/home/fajlovyj-menedzer/DumpMon.tar.gz

'\r' added to '\n' to use it with 'screen'. http://swoolley.org/man.cgi/1/screen

Vanyamba

Version 0.5 of DumpMon is now available.
Major update is the interrupts table dump added. This is so cool. :)
http://sites.google.com/site/vanyambauseslinux/home/fajlovyj-menedzer/DumpMon-0.5.tar.gz

Graynomad

Just downloaded, works well, just needs full symbolic debugging :)

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Vanyamba


Just downloaded, works well, just needs full symbolic debugging :)


Thanks, Rob. It was hard work but...

Download DumpMon version 0.6 and use new advanced debug features! :)
http://sites.google.com/site/vanyambauseslinux/home/fajlovyj-menedzer/DumpMon-0.6.tar.gz

See dumpmonDebug example in order how to use symblic debug functions.

New commands added:

  • G - go-execution mode. Use this command to execute the sketch without breaks.

  • S - step-execution mode. Use this command to enter step-execution mode.

  • N - step up to next breakpoint. Use this command to execute up to next breakpoint.



:)

westfw

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...

Vanyamba


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.

westfw

Quote
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.)

Vanyamba


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.

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).

Vanyamba

Show available RAM function added in version 0.7.

http://sites.google.com/site/vanyambauseslinux/home/fajlovyj-menedzer/DumpMon-0.7.tar.gz

WillR

I just got this error...

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

See entire output below....

Code: [Select]
D:\Arduino\arduino-0022\hardware\tools\avr\bin\avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=22 -ID:\Arduino\arduino-0022\hardware\arduino\cores\arduino -ID:\Arduino\arduino-0022\libraries\DumpMon C:\Users\dave\AppData\Local\Temp\build7581516507984079922.tmp\dumpmon.cpp -oC:\Users\dave\AppData\Local\Temp\build7581516507984079922.tmp\dumpmon.cpp.o
D:\Arduino\arduino-0022\hardware\tools\avr\bin\avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=22 -ID:\Arduino\arduino-0022\hardware\arduino\cores\arduino -ID:\Arduino\arduino-0022\libraries\DumpMon -ID:\Arduino\arduino-0022\libraries\DumpMon\utility D:\Arduino\arduino-0022\libraries\DumpMon\dumpdebug.cpp -oC:\Users\dave\AppData\Local\Temp\build7581516507984079922.tmp\DumpMon\dumpdebug.cpp.o
D:\Arduino\arduino-0022\hardware\tools\avr\bin\avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=22 -ID:\Arduino\arduino-0022\hardware\arduino\cores\arduino -ID:\Arduino\arduino-0022\libraries\DumpMon -ID:\Arduino\arduino-0022\libraries\DumpMon\utility D:\Arduino\arduino-0022\libraries\DumpMon\dumpmonlib.cpp -oC:\Users\dave\AppData\Local\Temp\build7581516507984079922.tmp\DumpMon\dumpmonlib.cpp.o
D:\Arduino\arduino-0022\hardware\tools\avr\bin\avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=22 -ID:\Arduino\arduino-0022\hardware\arduino\cores\arduino -ID:\Arduino\arduino-0022\libraries\DumpMon -ID:\Arduino\arduino-0022\libraries\DumpMon\utility D:\Arduino\arduino-0022\libraries\DumpMon\interrupts.cpp -oC:\Users\dave\AppData\Local\Temp\build7581516507984079922.tmp\DumpMon\interrupts.cpp.o
D:\Arduino\arduino-0022\hardware\tools\avr\bin\avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=22 -ID:\Arduino\arduino-0022\hardware\arduino\cores\arduino -ID:\Arduino\arduino-0022\libraries\DumpMon -ID:\Arduino\arduino-0022\libraries\DumpMon\utility D:\Arduino\arduino-0022\libraries\DumpMon\memory.cpp -oC:\Users\dave\AppData\Local\Temp\build7581516507984079922.tmp\DumpMon\memory.cpp.o
D:\Arduino\arduino-0022\hardware\tools\avr\bin\avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=22 -ID:\Arduino\arduino-0022\hardware\arduino\cores\arduino -ID:\Arduino\arduino-0022\libraries\DumpMon -ID:\Arduino\arduino-0022\libraries\DumpMon\utility D:\Arduino\arduino-0022\libraries\DumpMon\printpgm.cpp -oC:\Users\dave\AppData\Local\Temp\build7581516507984079922.tmp\DumpMon\printpgm.cpp.o
D:\Arduino\arduino-0022\hardware\tools\avr\bin\avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=22 -ID:\Arduino\arduino-0022\hardware\arduino\cores\arduino -ID:\Arduino\arduino-0022\libraries\DumpMon -ID:\Arduino\arduino-0022\libraries\DumpMon\utility D:\Arduino\arduino-0022\libraries\DumpMon\registers.cpp -oC:\Users\dave\AppData\Local\Temp\build7581516507984079922.tmp\DumpMon\registers.cpp.o
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


This is the version 7

So no luck...

Just another Hacker

Vanyamba


-mmcu=atmega2560


Currently I am working on ATmega2560 support.  ;)

Go Up