From 0d9ba806bc081361403193153b3de4cec7090cb7 Mon Sep 17 00:00:00 2001 From: Hauke Petersen <hauke.petersen@fu-berlin.de> Date: Wed, 17 May 2017 11:54:52 +0200 Subject: [PATCH] make/tools: added shared script+mk for using BOSSA --- Makefile.include | 7 +++++++ makefiles/tools/bossa.inc.mk | 26 ++++++++++++++++++++++++++ makefiles/tools/targets.inc.mk | 11 +++++++++++ 3 files changed, 44 insertions(+) create mode 100644 makefiles/tools/bossa.inc.mk create mode 100644 makefiles/tools/targets.inc.mk diff --git a/Makefile.include b/Makefile.include index 5b72acff2a..71f4cacd06 100644 --- a/Makefile.include +++ b/Makefile.include @@ -367,6 +367,9 @@ flash: all $(FLASHDEPS) exit 1; } $(FLASHER) $(FFLAGS) +preflash: all + $(PREFLASHER) $(PREFFLAGS) + term: $(filter flash, $(MAKECMDGOALS)) @command -v $(TERMPROG) >/dev/null 2>&1 || \ { $(COLOR_ECHO) \ @@ -430,6 +433,10 @@ include $(RIOTMAKE)/features.inc.mk # Export variables used throughout the whole make system: include $(RIOTMAKE)/vars.inc.mk +# Include build targets for selected tools after the default RIOT targets have +# been defined (-> so the `all` will be always the first target) +include $(RIOTMAKE)/tools/targets.inc.mk + # Warn if the selected board and drivers don't provide all needed features: ifneq (, $(filter all, $(if $(MAKECMDGOALS), $(MAKECMDGOALS), all))) EXPECT_ERRORS := diff --git a/makefiles/tools/bossa.inc.mk b/makefiles/tools/bossa.inc.mk new file mode 100644 index 0000000000..89aed6d8e3 --- /dev/null +++ b/makefiles/tools/bossa.inc.mk @@ -0,0 +1,26 @@ +export FLASHER ?= $(RIOTBASE)/dist/tools/bossa/bossac +export FFLAGS ?= -p $(PORT) -i -i -w -v -b -R $(HEXFILE) + +export OFLAGS = -O binary +export HEXFILE = $(ELFFILE:.elf=.bin) + +# some arduino boards need to toggle the serial interface a little bit to get +# them ready for flashing... +ifneq (,$(BOSSA_ARDUINO_PREFLASH)) +OS := $(shell uname) +ifeq ($(OS),Linux) + STTY_FLAG = -F +else ifeq ($(OS),Darwin) + STTY_FLAG = -f +endif + +PREFLASHER ?= stty +PREFFLAGS ?= $(STTY_FLAG) $(PORT) raw ispeed 1200 ospeed 1200 cs8 -cstopb ignpar eol 255 eof 255 +FLASHDEPS += preflash +endif + +# if we go with the default (BOSSA shipped with RIOT), we download and build +# the tool if not already done +ifeq ($(RIOTBASE)/dist/tools/bossa/bossac,$(FLASHER)) +FLASHDEPS += $(RIOTBASE)/dist/tools/bossa/bossac +endif diff --git a/makefiles/tools/targets.inc.mk b/makefiles/tools/targets.inc.mk new file mode 100644 index 0000000000..f1a0ed5032 --- /dev/null +++ b/makefiles/tools/targets.inc.mk @@ -0,0 +1,11 @@ +# This file contains a collection of targets defined by tools shipped with RIOT. +# The reason for keeping those targets separated from their tool Makfiles is +# that these targets have to be defined after the default build targets +# (as `all`), so `all` will always be the first target defined and thereby the +# default target when `make` is called without any further argument. + +# target for building the bossac binary +$(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!" -- GitLab