Quick description of avr-gdb.
Today avr-gdb works only as in circuit debugger because I don't have a
simulator.
avr-gdb needed in monitor.
Monitor consists of two parts:
1) AVR part (0x1d0 bytes of code and 0x40 bytes of data);
2) PC part.
PC part of monitor can (with help of AVR part of monitor):
- read/write AVR registers (include SREG, PC and SP);
- read/write AVR memory;
- read/write AVR IO.
- put/clear up to 8 breakpoints;
- step one instruction.
AVR part of monitor written in C (avr-gcc).
AVR part of monitor stops only on source coded breakpoints (`TRAP()'). After stopping you can work with the AVR part (with chip).
PC and AVR connected as:
Connect AVR with parallel port
AVR Parallel Port
Signal name Pin Pin Signal name
GND 20 ------------ 19 GND
GND 20 ------------ 21 GND
SCK 8 ------------ 1 Strobe
MOSI 6 ------------ 12 Out of paper
MISO 7 ------------ 11 Busy
Reset 9 ------------ 16 Init
Connect parallel port pin 12 with parallel port pin 2 through diod
Out of paper 12 ----|>|--- 2 Data 0
This connection allow to use send_byte and program AVR flash with Uros Platise `uisp' in `-dapa' mode.
How the avr-gdb works:
The avr-gdb connects with monitor (PC part of monitor) through TCP
After connection: program in AVR runs until TRAP() executed.
(TRAP () is a source coded breakpoint).
After a AVR program trap's you can :
- watch any global variables;
- disassemble functions;
- watch registers and local variables;
- up's and down's by stack;
- list source texts;
- run any function with parameters in AVR chip;
- any thing which GDB can;
- step one instruction;
- put breakpoints (up to 8);
- clear breakpoints;
- continue execution until next TRAP();
- stepping until TRAP () or any breakpoint;
continue AVR program only if no breakpoint sets (gdb command `c'). stepping AVR program if one or more breakpoint sets (gdb command `c').
Under emacs all this works as a native PC debugging except source coded TRAP()'s.
You can use any gdb GUI frontend: xxgdb, Source Navigator, ...
How to run
- Compile a C program with `-g' command line option;
- Write this program to AVR Flash. I'm use:
avr-ld --oformat=srec a.out -o a.srec uisp -dapa --erase uisp -dapa --upload if=a.srec -v=3
- Run AVR monitor. (`mon localhost' or `remon localhost');
- Run avr-gdb;
- Type following commands under avr-gdb:
file a.out target avr localhost:11111
- The program in AVR chip will be executed until the program reaches a source coded breakpoint ( TRAP(); ).
