From c6b8cbea00ee267592e9572b81f0fb3b9efb5ff5 Mon Sep 17 00:00:00 2001 From: Juan Carrano Date: Thu, 6 Dec 2018 14:46:20 +0100 Subject: [PATCH 1/2] kinetis-based-boards: use FLASHDEPS instead of flash: xxxx. With the canned recipe for flashing, flash dependencies should be added to FLASHDEPS, instead of writing `flash: dependencies`. This ensures that both flash and flash-only depend on the same prerequisites. --- boards/common/frdm/Makefile.include | 3 +-- boards/mulle/Makefile.include | 3 +-- boards/pba-d-01-kw2x/Makefile.include | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/boards/common/frdm/Makefile.include b/boards/common/frdm/Makefile.include index 2cf811ce4f..b12569e9c4 100644 --- a/boards/common/frdm/Makefile.include +++ b/boards/common/frdm/Makefile.include @@ -23,8 +23,7 @@ export OPENOCD_PRE_VERIFY_CMDS += \ -c 'resume 0x20000000' export OPENOCD_EXTRA_INIT -.PHONY: flash -flash: $(RIOTCPU)/$(CPU)/dist/wdog-disable.bin +FLASHDEPS += $(RIOTCPU)/$(CPU)/dist/wdog-disable.bin export OPENOCD_CONFIG ?= $(RIOTBOARD)/common/frdm/dist/old-openocd-$(CPU_FAMILY).cfg endif diff --git a/boards/mulle/Makefile.include b/boards/mulle/Makefile.include index 6d8b0ea77b..d0c6e24957 100644 --- a/boards/mulle/Makefile.include +++ b/boards/mulle/Makefile.include @@ -58,8 +58,7 @@ export OPENOCD_PRE_VERIFY_CMDS += \ -c 'resume 0x20000000' export PRE_FLASH_CHECK_SCRIPT = $(RIOTCPU)/$(CPU)/dist/check-fcfield-elf.sh -.PHONY: flash -flash: $(RIOTCPU)/$(CPU)/dist/wdog-disable.bin +FLASHDEPS += $(RIOTCPU)/$(CPU)/dist/wdog-disable.bin # this board uses openocd include $(RIOTMAKE)/tools/openocd.inc.mk diff --git a/boards/pba-d-01-kw2x/Makefile.include b/boards/pba-d-01-kw2x/Makefile.include index e5cae31cf5..6d9fd09d3a 100644 --- a/boards/pba-d-01-kw2x/Makefile.include +++ b/boards/pba-d-01-kw2x/Makefile.include @@ -10,8 +10,7 @@ export CPU_MODEL ?= mkw21d256vha5 PORT_LINUX ?= /dev/ttyACM0 PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) -.PHONY: flash -flash: $(RIOTCPU)/$(CPU)/dist/wdog-disable.bin +FLASHDEPS += $(RIOTCPU)/$(CPU)/dist/wdog-disable.bin # We need special handling of the watchdog if we want to speed up the flash # verification by using the MCU to compute the image checksum after flashing. From ae524e917fe36662f9d6153c0022e5f5deb22c96 Mon Sep 17 00:00:00 2001 From: Juan Carrano Date: Wed, 5 Dec 2018 12:33:12 +0100 Subject: [PATCH 2/2] Makefile.include: flash: do not peek into MAKECMDGOALS. When flash-only was introduced (in #8373), the `flash` rule was made conditionally dependent on `all` by looking for `flash-only` in MAKECMDGOALS. This was done to avoid code duplication. There's a cleaner way, by using canned recipes. When we upgrade the requirements to gnu make 4, the flash recipe can be defined as ?=. --- Makefile.include | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Makefile.include b/Makefile.include index 699ff7931b..82331e03d6 100644 --- a/Makefile.include +++ b/Makefile.include @@ -511,16 +511,19 @@ distclean: -@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i distclean ; done -@rm -rf $(BINDIRBASE) -# if make target != 'flash-only', add target 'all' to ensure build before flash -ifeq (,$(filter flash-only, $(MAKECMDGOALS))) - BUILD_BEFORE_FLASH = all -endif +define flash-recipe + $(call check_cmd,$(FLASHER),Flash program) + $(FLASHER) $(FFLAGS) +endef -flash: $(BUILD_BEFORE_FLASH) $(FLASHDEPS) - $(call check_cmd,$(FLASHER),Flash program) - $(FLASHER) $(FFLAGS) +# Do not add dependencies to "flash" directly, use FLASHDEPS, as this is shared +# with flash-only too -flash-only: flash +flash: all $(FLASHDEPS) + $(flash-recipe) + +flash-only: $(FLASHDEPS) + $(flash-recipe) preflash: $(BUILD_BEFORE_FLASH) $(PREFLASHER) $(PREFFLAGS)