diff --git a/boards/samd21-xpro/Makefile.include b/boards/samd21-xpro/Makefile.include index 06056fc46..427ba1fb7 100644 --- a/boards/samd21-xpro/Makefile.include +++ b/boards/samd21-xpro/Makefile.include @@ -2,4 +2,7 @@ export CPU = samd21 export CPU_MODEL = samd21j18a +# set edbg device type +EDBG_DEVICE_TYPE = atmel_cm0p + include $(RIOTMAKE)/boards/sam0.inc.mk diff --git a/boards/samr21-xpro/Makefile.include b/boards/samr21-xpro/Makefile.include index acc6ee400..ba753cc0a 100644 --- a/boards/samr21-xpro/Makefile.include +++ b/boards/samr21-xpro/Makefile.include @@ -2,4 +2,7 @@ export CPU = samd21 export CPU_MODEL = samr21g18a +# set edbg device type +EDBG_DEVICE_TYPE = atmel_cm0p + include $(RIOTMAKE)/boards/sam0.inc.mk diff --git a/dist/tools/edbg/.gitignore b/dist/tools/edbg/.gitignore new file mode 100644 index 000000000..87a897f7e --- /dev/null +++ b/dist/tools/edbg/.gitignore @@ -0,0 +1 @@ +edbg diff --git a/dist/tools/edbg/Makefile b/dist/tools/edbg/Makefile new file mode 100644 index 000000000..82f7fbbf1 --- /dev/null +++ b/dist/tools/edbg/Makefile @@ -0,0 +1,13 @@ +PKG_NAME=edbg +PKG_URL=https://github.com/ataradov/edbg +PKG_VERSION=d499ffd8297233b65dd91fd58fb98b9f9a03fec1 +PKG_LICENSE=BSD-3-Clause +PKG_BUILDDIR=$(CURDIR)/bin + +.PHONY: all + +all: git-download + "$(MAKE)" -C $(PKG_BUILDDIR) + mv $(PKG_BUILDDIR)/edbg . + +include $(RIOTBASE)/pkg/pkg.mk diff --git a/makefiles/boards/sam0.inc.mk b/makefiles/boards/sam0.inc.mk index 89a76ea42..ef7578e52 100644 --- a/makefiles/boards/sam0.inc.mk +++ b/makefiles/boards/sam0.inc.mk @@ -10,6 +10,7 @@ include $(RIOTMAKE)/tools/serial.inc.mk # Usage: SERIAL="ATML..." BOARD= make flash ifneq (,$(SERIAL)) export OPENOCD_EXTRA_INIT += "-c cmsis_dap_serial $(SERIAL)" + EDBG_ARGS += "--serial $(SERIAL)" SERIAL_TTY = $(firstword $(shell $(RIOTBASE)/dist/tools/usb-serial/find-tty.sh $(SERIAL))) ifeq (,$(SERIAL_TTY)) $(error Did not find a device with serial $(SERIAL)) @@ -17,5 +18,15 @@ ifneq (,$(SERIAL)) PORT_LINUX := $(SERIAL_TTY) endif -# this board uses openocd +# set this to either openocd or edbg +PROGRAMMER ?= edbg + +# use edbg if selected and a device type has been set +ifeq ($(PROGRAMMER),edbg) + ifneq (,$(EDBG_DEVICE_TYPE)) + include $(RIOTMAKE)/tools/edbg.inc.mk + endif +endif + +# this board uses openocd for debug and possibly flashing include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/makefiles/tools/edbg.inc.mk b/makefiles/tools/edbg.inc.mk new file mode 100644 index 000000000..353be21a9 --- /dev/null +++ b/makefiles/tools/edbg.inc.mk @@ -0,0 +1,10 @@ +RIOT_EDBG = $(RIOTBASE)/dist/tools/edbg/edbg +EDBG ?= $(RIOT_EDBG) +FLASHER ?= $(EDBG) +OFLAGS ?= -O binary +HEXFILE = $(ELFFILE:.elf=.bin) +FFLAGS ?= $(EDBG_ARGS) -t $(EDBG_DEVICE_TYPE) -b -e -v -p -f $(HEXFILE) + +ifeq ($(RIOT_EDBG),$(FLASHER)) + FLASHDEPS += $(RIOT_EDBG) +endif diff --git a/makefiles/tools/openocd.inc.mk b/makefiles/tools/openocd.inc.mk index 1f836ea03..f2b694115 100644 --- a/makefiles/tools/openocd.inc.mk +++ b/makefiles/tools/openocd.inc.mk @@ -1,4 +1,4 @@ -export FLASHER = $(RIOTBASE)/dist/tools/openocd/openocd.sh +export FLASHER ?= $(RIOTBASE)/dist/tools/openocd/openocd.sh export DEBUGGER = $(RIOTBASE)/dist/tools/openocd/openocd.sh export DEBUGSERVER = $(RIOTBASE)/dist/tools/openocd/openocd.sh export RESET = $(RIOTBASE)/dist/tools/openocd/openocd.sh diff --git a/makefiles/tools/targets.inc.mk b/makefiles/tools/targets.inc.mk index f1a0ed503..4be923a92 100644 --- a/makefiles/tools/targets.inc.mk +++ b/makefiles/tools/targets.inc.mk @@ -9,3 +9,8 @@ $(RIOTBASE)/dist/tools/bossa/bossac: @echo "[INFO] bossac binary not found - building it from source" @make -C $(RIOTBASE)/dist/tools/bossa @echo "[INFO] bossac binary successfully build!" + +$(RIOTBASE)/dist/tools/edbg/edbg: + @echo "[INFO] edbg binary not found - building it from source now" + CC= CFLAGS= make -C $(RIOTBASE)/dist/tools/edbg + @echo "[INFO] edbg binary successfully build!"