Skip to content

Instantly share code, notes, and snippets.

@mattvenn
Last active June 7, 2017 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattvenn/930590aabbb46beba6a9306312d3e620 to your computer and use it in GitHub Desktop.
Save mattvenn/930590aabbb46beba6a9306312d3e620 to your computer and use it in GitHub Desktop.
GDB + debugWire + Linux

gdb + avarice + debugwire on attiny88

enable debugwire

enable with avrdude (fuse for attiny88):

avrdude -c dragon_isp -P usb -p attiny88 -v -U hfuse:w:0xd9:m

compilation

  • must be compiled with -ggdb or great (--gdb3) but doesn't seem to help with macros

  • no optimisations

    COMPILE = $(GCC_PATH) -ggdb3 -Wall -Wextra $(OPTIMIZATION) -std=gnu11 -flto -mmcu=$(DEVICE) -DF_CPU=$(CLOCK)

need main.hex and main.elf

debugging

start avarice:

make && avarice -g -w  -P attiny88 --program --file main.elf :4242 -r

minimum required

avarice -g -w -P attiny88 :4242

then start gdb:

avr-gdb main.elf

and connect:

target remote localhost:4242

gdb useful commands

  • list
  • until main.c:23 # continue till this line
  • continue
  • print loops
  • p/x loops # print in hex
  • p/t loops # print in binary
  • step
  • set $pc += 2 # jump an instruction to get out of breakpoint
  • layout # change different layouts
  • x/t 0x2B # examine address in memory

breakpoints

only sw breakpoints with debugwire, so if need breakpoints use:

asm('break');

switch back to spi/icsp mode

NB. VTG/VCC pin (2 on header) must be connected to chip supply for this to work!

avrdude -c dragon_isp -P usb -p attiny88 -v

to disable debugwire on attiny88

avrdude -c dragon_isp -P usb -p attiny88 -v -U hfuse:w:0xdd:m

unresolved problems

  • after breaking, can't conitnue without setting $pc (skip to next instruction: set $pc += 2)
  • macros aren't defined

sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment