Skip to content

Commit

Permalink
makefiles/edbg: refactor to use wrapper script
Browse files Browse the repository at this point in the history
  • Loading branch information
aabadie committed Feb 18, 2021
1 parent 4b98bd2 commit 6cf7fd8
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions makefiles/tools/edbg.inc.mk
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
include $(RIOTMAKE)/tools/edbg-devices.inc.mk

# Edbg use a bin file for flashing
FLASHFILE ?= $(BINFILE)

RIOT_EDBG = $(RIOTTOOLS)/edbg/edbg
EDBG ?= $(RIOT_EDBG)
FLASHER ?= $(EDBG)
FLASHFILE ?= $(BINFILE)
ifneq (0,$(shell command -v $(EDBG) 2>&1 > /dev/null ; echo $$?))
FLASHDEPS += $(RIOT_EDBG)
EDBG := $(RIOT_EDBG)
endif

# Use USB serial number to select device when more than one is connected
# Use /dist/tools/usb-serial/list-ttys.sh to find out serial number.
# Usage:
Expand All @@ -15,22 +21,21 @@ endif

# Set offset according to IMAGE_OFFSET if it's defined
EDBG_ARGS += $(if $(IMAGE_OFFSET),--offset $(IMAGE_OFFSET))
EDBG_ARGS += --target $(EDBG_DEVICE_TYPE)

FFLAGS ?= $(EDBG_ARGS) --target $(EDBG_DEVICE_TYPE) --verbose \
--file $(FLASHFILE)
EDBG_TARGETS = flash reset
# Export EDBG to required targets
$(call target-export-variables,$(EDBG_TARGETS),EDBG)

ifeq ($(RIOT_EDBG),$(FLASHER))
FLASHDEPS += $(RIOT_EDBG)
endif
RESET ?= $(EDBG)
RESET_FLAGS ?= $(EDBG_ARGS) --target $(EDBG_DEVICE_TYPE)
# Export EDBG_ARGS to required targets
$(call target-export-variables,$(EDBG_TARGETS),EDBG_ARGS)

define edbg-flash-recipe
$(call check_cmd,$(FLASHER),Flash program)
$(FLASHER) $(FFLAGS) --verify || $(FLASHER) $(FFLAGS) --verify --program
endef
# Set flasher and reset for the RIOT build system
FLASHER ?= $(RIOTTOOLS)/edbg/edbg.sh
FFLAGS ?= flash $(FLASHFILE)

flash-recipe = $(edbg-flash-recipe)
RESET ?= $(RIOTTOOLS)/edbg/edbg.sh
RESET_FLAGS ?= reset

# use openocd for debugging, must be included at the end so FLASHER/RESET
# variables are already set for edbg.
Expand Down

0 comments on commit 6cf7fd8

Please sign in to comment.