2020-11-21 22:31:03 +01:00
|
|
|
FLASHER ?= avrdude
|
2020-04-14 15:23:23 +02:00
|
|
|
DIST_PATH = $(BOARDDIR)/dist
|
2019-03-27 13:45:25 +01:00
|
|
|
AVARICE_PATH = $(RIOTTOOLS)/avarice
|
2018-05-14 19:27:10 +02:00
|
|
|
DEBUGSERVER_PORT = 4242
|
2020-11-21 22:31:03 +01:00
|
|
|
DEBUGSERVER ?= $(AVARICE_PATH)/debug_srv.sh
|
2022-09-23 13:41:27 +02:00
|
|
|
# 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
|
2019-03-27 15:59:29 +01:00
|
|
|
AVR_DEBUGDEVICE ?= --edbg
|
|
|
|
AVR_DEBUGINTERFACE ?= usb
|
|
|
|
ifneq (,$(filter $(CPU),atmega328p))
|
|
|
|
# Use debugWIRE as protocol for debugging (ATmega328P does not support JTAG)
|
|
|
|
DEBUGPROTO := -w
|
|
|
|
else
|
2021-01-02 19:32:51 +01:00
|
|
|
# Use JTAG as protocol for debugging as default
|
|
|
|
DEBUGPROTO ?= -j $(AVR_DEBUGINTERFACE)
|
2019-03-27 15:59:29 +01:00
|
|
|
endif
|
2020-11-21 22:31:03 +01:00
|
|
|
DEBUGSERVER_FLAGS ?= "$(AVR_DEBUGDEVICE) $(DEBUGPROTO) :$(DEBUGSERVER_PORT)"
|
2022-05-31 12:39:16 +02:00
|
|
|
DEBUGGER_FLAGS ?= "-x $(AVARICE_PATH)/gdb.conf $(DEBUG_ELFFILE)"
|
2019-03-27 13:45:25 +01:00
|
|
|
DEBUGGER = "$(AVARICE_PATH)/debug.sh" $(DEBUGSERVER_FLAGS) $(AVARICE_PATH) $(DEBUGSERVER_PORT)
|
2018-05-14 19:27:10 +02:00
|
|
|
|
2021-01-02 19:32:51 +01:00
|
|
|
ifeq (atxmega,$(CPU))
|
|
|
|
AVRDUDE_PROGRAMMER_FLAGS ?= -p $(subst atxmega,x,$(CPU_MODEL))
|
|
|
|
else
|
|
|
|
AVRDUDE_PROGRAMMER_FLAGS = -p $(subst atmega,m,$(CPU))
|
|
|
|
endif
|
2019-02-20 21:59:06 +01:00
|
|
|
|
2019-02-20 21:40:40 +01:00
|
|
|
# Set flasher port only for programmers that require it
|
2020-11-19 18:38:41 +01:00
|
|
|
ifneq (,$(filter $(AVRDUDE_PROGRAMMER),arduino avr109 buspirate stk500v1 stk500v2 wiring))
|
2019-02-20 21:40:40 +01:00
|
|
|
# make the flasher port configurable (e.g. with atmelice the port is usb)
|
|
|
|
# defaults to terminal's serial port if not configured
|
2020-11-19 18:38:41 +01:00
|
|
|
AVRDUDE_PROGRAMMER_FLAGS += -P $(PROG_DEV)
|
2019-02-20 21:40:40 +01:00
|
|
|
endif
|
2020-11-19 18:38:41 +01:00
|
|
|
AVRDUDE_PROGRAMMER_FLAGS += $(FFLAGS_EXTRA)
|
2018-05-14 19:27:10 +02:00
|
|
|
|
|
|
|
# don't force to flash HEXFILE, but set it as default
|
|
|
|
FLASHFILE ?= $(HEXFILE)
|
2020-11-19 18:38:41 +01:00
|
|
|
FFLAGS += -c $(AVRDUDE_PROGRAMMER) $(AVRDUDE_PROGRAMMER_FLAGS) -U flash:w:$(FLASHFILE)
|
2019-11-25 14:39:25 +01:00
|
|
|
|
2020-11-19 18:38:41 +01:00
|
|
|
ifeq (,$(filter $(AVRDUDE_PROGRAMMER),arduino avr109 stk500v1 stk500v2 wiring))
|
2019-11-25 14:39:25 +01:00
|
|
|
# Use avrdude to trigger a reset, if programming is not done via UART and a
|
|
|
|
# bootloader.
|
2020-11-19 18:38:41 +01:00
|
|
|
RESET ?= $(FLASHER) -c $(AVRDUDE_PROGRAMMER) $(AVRDUDE_PROGRAMMER_FLAGS)
|
2019-11-25 14:39:25 +01:00
|
|
|
endif
|