1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/makefiles/tools/avrdude.inc.mk
Marian Buschsieweke 7df2bc2072
tools/avarice: deduce debugger from AVRDUDE_PROGRAMMER
If `AVRDUDE_PROGRAMMER` is already set to a programmer that is also
capable of debugging, we can assume that typically the user will want
to use the same hardware for debugging. Thus, let `AVR_DEBUGDEVICE`
default to the matching hardware.
2022-09-23 13:41:27 +02:00

51 lines
2.0 KiB
Makefile

FLASHER ?= avrdude
DIST_PATH = $(BOARDDIR)/dist
AVARICE_PATH = $(RIOTTOOLS)/avarice
DEBUGSERVER_PORT = 4242
DEBUGSERVER ?= $(AVARICE_PATH)/debug_srv.sh
# Allow choosing debugger hardware via AVR_DEBUGDEVICE. If the
# AVRDUDE_PROGRAMMER however is also capable of debugging, use that by default
ifneq (,$(filter $(AVRDUDE_PROGRAMMER),atmelice xplainedpro xplainedpro_pdi))
AVR_DEBUGDEVICE ?= --edbg
endif
ifneq (,$(filter dragon%,$(AVRDUDE_PROGRAMMER)))
AVR_DEBUGDEVICE ?= --dragon
endif
# Atmel ICE / EDBG is the most sensible fallback
AVR_DEBUGDEVICE ?= --edbg
AVR_DEBUGINTERFACE ?= usb
ifneq (,$(filter $(CPU),atmega328p))
# Use debugWIRE as protocol for debugging (ATmega328P does not support JTAG)
DEBUGPROTO := -w
else
# Use JTAG as protocol for debugging as default
DEBUGPROTO ?= -j $(AVR_DEBUGINTERFACE)
endif
DEBUGSERVER_FLAGS ?= "$(AVR_DEBUGDEVICE) $(DEBUGPROTO) :$(DEBUGSERVER_PORT)"
DEBUGGER_FLAGS ?= "-x $(AVARICE_PATH)/gdb.conf $(DEBUG_ELFFILE)"
DEBUGGER = "$(AVARICE_PATH)/debug.sh" $(DEBUGSERVER_FLAGS) $(AVARICE_PATH) $(DEBUGSERVER_PORT)
ifeq (atxmega,$(CPU))
AVRDUDE_PROGRAMMER_FLAGS ?= -p $(subst atxmega,x,$(CPU_MODEL))
else
AVRDUDE_PROGRAMMER_FLAGS = -p $(subst atmega,m,$(CPU))
endif
# Set flasher port only for programmers that require it
ifneq (,$(filter $(AVRDUDE_PROGRAMMER),arduino avr109 buspirate stk500v1 stk500v2 wiring))
# make the flasher port configurable (e.g. with atmelice the port is usb)
# defaults to terminal's serial port if not configured
AVRDUDE_PROGRAMMER_FLAGS += -P $(PROG_DEV)
endif
AVRDUDE_PROGRAMMER_FLAGS += $(FFLAGS_EXTRA)
# don't force to flash HEXFILE, but set it as default
FLASHFILE ?= $(HEXFILE)
FFLAGS += -c $(AVRDUDE_PROGRAMMER) $(AVRDUDE_PROGRAMMER_FLAGS) -U flash:w:$(FLASHFILE)
ifeq (,$(filter $(AVRDUDE_PROGRAMMER),arduino avr109 stk500v1 stk500v2 wiring))
# Use avrdude to trigger a reset, if programming is not done via UART and a
# bootloader.
RESET ?= $(FLASHER) -c $(AVRDUDE_PROGRAMMER) $(AVRDUDE_PROGRAMMER_FLAGS)
endif