diff --git a/boards/arduino-mega2560/Makefile.include b/boards/arduino-mega2560/Makefile.include index 1ed943f90b5ae36e6e01c5099702c39d81a3d3fb..af890c57248e442641d53e850d8c126fc4550651 100644 --- a/boards/arduino-mega2560/Makefile.include +++ b/boards/arduino-mega2560/Makefile.include @@ -28,16 +28,28 @@ else endif export FLASHER export PORT +export DIST_PATH = $(RIOTBOARD)/$(BOARD)/dist +export DEBUGSERVER_PORT = 4242 +export DEBUGSERVER = $(DIST_PATH)/debug_srv.sh +export DEBUGSERVER_FLAGS = "-g -j usb :$(DEBUGSERVER_PORT)" +export DEBUGGER_FLAGS = "-x $(RIOTBOARD)/$(BOARD)/dist/gdb.conf $(ELFFILE)" +export DEBUGGER = $(DIST_PATH)/debug.sh $(DEBUGSERVER_FLAGS) $(DIST_PATH) $(DEBUGSERVER_PORT) + +# PROGRAMMER defaults to stk500v2 which is the internal flasher via USB. Can be +# overridden for debugging (which requires changes that require to use an ISP) +export PROGRAMMER ?= stk500v2 + +ifeq ($(PROGRAMMER), stk500v2) + export PROGRAMMER_FLAGS = -P $(PORT) -b 115200 +endif # define build specific options export CPU_USAGE = -mmcu=atmega2560 export CFLAGS += -ggdb -g3 -std=gnu99 -Os -Wall -Wstrict-prototypes $(CPU_USAGE) export ASFLAGS += -ggdb -g3 $(CPU_USAGE) $(FPU_USAGE) export LINKFLAGS += -g3 -ggdb -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -static -lgcc -e reset_handler -# linkerscript specified in cpu/Makefile.include -#export LINKFLAGS += -T$(LINKERSCRIPT) export OFLAGS += -j .text -j .data -O ihex -export FFLAGS += -p m2560 -c stk500v2 -P $(PORT) -b 115200 -F -U flash:w:bin/$(BOARD)/$(PROJECT)$(APPLICATION).hex +export FFLAGS += -p m2560 -c $(PROGRAMMER) $(PROGRAMMER_FLAGS) -F -U flash:w:bin/$(BOARD)/$(PROJECT)$(APPLICATION).hex # export board specific includes to the global includes-listing export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include diff --git a/boards/arduino-mega2560/dist/debug.sh b/boards/arduino-mega2560/dist/debug.sh new file mode 100755 index 0000000000000000000000000000000000000000..ddeca9ff2f6a5b4b1d2d7a1c4fe5ab22320233e0 --- /dev/null +++ b/boards/arduino-mega2560/dist/debug.sh @@ -0,0 +1,8 @@ +#!/bin/bash +sleep 2 +setsid -w avarice $1 & +#sleep 2 && $2/avr-gdb-wrapper -ex "target remote localhost:$3" $4 +sleep 3 && avr-gdb -ex "target remote localhost:$3" $4 + +# avarice exits with 1 if the connection is released, therefore we always exit with 0 +exit 0 diff --git a/boards/arduino-mega2560/dist/debug_srv.sh b/boards/arduino-mega2560/dist/debug_srv.sh new file mode 100755 index 0000000000000000000000000000000000000000..449651afbcf975b9bb41adcc25bd6c798ab503f5 --- /dev/null +++ b/boards/arduino-mega2560/dist/debug_srv.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +sleep 2 +avarice $1 + +# avarice exits with 1 if the connection is released, therefore we always exit with 0 +exit 0 diff --git a/boards/arduino-mega2560/dist/gdb.conf b/boards/arduino-mega2560/dist/gdb.conf new file mode 100644 index 0000000000000000000000000000000000000000..ca68eb344c3f4a9e6f7eeecd2331c36110ac4c10 --- /dev/null +++ b/boards/arduino-mega2560/dist/gdb.conf @@ -0,0 +1 @@ +set $pc=0x00