diff --git a/Makefile.include b/Makefile.include index 763c0aa00920..9bb29c5ad766 100644 --- a/Makefile.include +++ b/Makefile.include @@ -709,10 +709,13 @@ distclean: -@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i distclean ; done -@rm -rf $(BINDIRBASE) +# Include PROGRAMMER_FLASH/PROGRAMMER_RESET variables +include $(RIOTMAKE)/tools/programmer.inc.mk + # Define flash-recipe with a default value define default-flash-recipe $(call check_cmd,$(FLASHER),Flash program) - $(FLASHER) $(FFLAGS) + $(PROGRAMMER_FLASH) endef flash-recipe ?= $(default-flash-recipe) @@ -774,7 +777,7 @@ endif reset: $(call check_cmd,$(RESET),Reset program) - $(RESET) $(RESET_FLAGS) + $(PROGRAMMER_RESET) # tests related targets and variables include $(RIOTMAKE)/tests/tests.inc.mk diff --git a/makefiles/tools/programmer.inc.mk b/makefiles/tools/programmer.inc.mk new file mode 100644 index 000000000000..48c288561c1a --- /dev/null +++ b/makefiles/tools/programmer.inc.mk @@ -0,0 +1,26 @@ +# Configure the programmer related variables + +PROGRAMMER_QUIET ?= $(QUIET) +ifeq (0,$(PROGRAMMER_QUIET)) + PROGRAMMER_VERBOSE_OPT ?= --verbose +endif + +# Don't use the programmer wrapper for the CI (where speed and verbose output +# are important) +ifneq (1,$(RIOT_CI_BUILD)) + USE_PROGRAMMER_WRAPPER_SCRIPT ?= 1 +else + USE_PROGRAMMER_WRAPPER_SCRIPT ?= 0 +endif + +ifeq (1,$(USE_PROGRAMMER_WRAPPER_SCRIPT)) + PROGRAMMER_FLASH ?= @$(RIOTTOOLS)/programmer/programmer.py \ + --action Flashing --cmd "$(FLASHER) $(FFLAGS)" \ + --programmer "$(PROGRAMMER)" $(PROGRAMMER_VERBOSE_OPT) + PROGRAMMER_RESET ?= @$(RIOTTOOLS)/programmer/programmer.py \ + --action Resetting --cmd "$(RESET) $(RESET_FLAGS)" \ + --programmer "$(PROGRAMMER)" $(PROGRAMMER_VERBOSE_OPT) +else + PROGRAMMER_FLASH ?= $(FLASHER) $(FFLAGS) + PROGRAMMER_RESET ?= $(RESET) $(RESET_FLAGS) +endif