1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 05:52:44 +01:00

Merge pull request #7068 from haukepetersen/add_tool_bossa

tools: introduce shared tooling for using BOSSA
This commit is contained in:
Alexandre Abadie 2017-05-23 07:17:13 +02:00 committed by GitHub
commit 0b918db35c
16 changed files with 81 additions and 57 deletions

View File

@ -360,13 +360,16 @@ distclean:
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i distclean ; done
-@rm -rf $(BINDIRBASE)
flash: all
flash: all $(FLASHDEPS)
@command -v $(FLASHER) >/dev/null 2>&1 || \
{ $(COLOR_ECHO) \
'${COLOR_RED}Flash program $(FLASHER) not found. Aborting.${COLOR_RESET}'; \
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 :=

View File

@ -6,9 +6,9 @@ export CPU_MODEL = sam3x8e
PORT_LINUX ?= /dev/ttyACM0
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
# define board specific flasher options
export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
export OFLAGS = -O binary
# setup serial terminal
include $(RIOTMAKE)/tools/serial.inc.mk
# setup flasher (using BOSSA)
export BOSSA_ARDUINO_PREFLASH = yes
include $(RIOTMAKE)/tools/bossa.inc.mk

Binary file not shown.

Binary file not shown.

View File

@ -1,11 +0,0 @@
#!/bin/sh
if [ `uname` = "Linux" ]; then
stty -F "${PORT}" raw ispeed 1200 ospeed 1200 cs8 -cstopb ignpar eol 255 eof 255
"${RIOTBOARD}"/"${BOARD}"/dist/bossac -R -e -w -v -b "${HEXFILE}"
elif [ `uname` = "Darwin" ]; then
stty -f ${PORT} raw ispeed 1200 ospeed 1200 cs8 -cstopb ignpar eol 255 eof 255
"${RIOTBOARD}"/"${BOARD}"/dist/bossac_osx -R -e -w -v -b "${HEXFILE}"
else
echo "CAUTION: No flash tool for your host system found!"
fi

View File

@ -6,23 +6,19 @@ export CPU_MODEL = samd21g18a
export PORT_LINUX ?= /dev/ttyACM0
export PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
# setup serial terminal
include $(RIOTMAKE)/tools/serial.inc.mk
# setup the flash tool used
ifeq ($(PROGRAMMER),jlink)
# in case J-Link is attached to SWD pins, use a plain CPU memory model
export JLINK_DEVICE := atsamw25
include $(RIOTMAKE)/tools/jlink.inc.mk
else
# when BOSSA is used (default), use a different flash map
# refer https://github.com/shumatech/BOSSA for this programmer
export PROGRAMMER = bossa
# on default, we use BOSSA to flash this board
export LINKER_SCRIPT ?= $(RIOTCPU)/sam0_common/ldscripts/$(CPU_MODEL)_mkr1000.ld
# define board specific flasher options
export FLASHER = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
export OFLAGS = -O binary
include $(RIOTMAKE)/tools/bossa.inc.mk
endif
# setup serial terminal
include $(RIOTMAKE)/tools/serial.inc.mk
# setup the boards dependencies
include $(RIOTBOARD)/$(BOARD)/Makefile.dep

Binary file not shown.

Binary file not shown.

View File

@ -1,14 +0,0 @@
#!/bin/sh
# To put the board in update mode, manually double press the reset button before
# running `make flash`.
if [ `uname` = "Linux" ]; then
stty -F "${PORT}" raw ispeed 1200 ospeed 1200 cs8 -cstopb ignpar eol 255 eof 255
"${RIOTBOARD}"/"${BOARD}"/dist/bossac --port=${PORT} -i -b -U true -i -e -w -v "${HEXFILE}" -R
elif [ `uname` = "Darwin" ]; then
stty -f ${PORT} raw ispeed 1200 ospeed 1200 cs8 -cstopb ignpar eol 255 eof 255
"${RIOTBOARD}"/"${BOARD}"/dist/bossac_osx --port=${PORT} -i -b -U true -i -e -w -v "${HEXFILE}" -R
else
echo "CAUTION: No flash tool for your host system found!"
fi

View File

@ -2,23 +2,13 @@
export CPU = sam3
export CPU_MODEL = sam3x8e
#define the flash-tool and default port depending on the host operating system
OS := $(shell uname)
ifeq ($(OS),Linux)
PORT ?= /dev/ttyUSB0
FLASHER = $(RIOTBOARD)/$(BOARD)/dist/bossac_udoo
else ifeq ($(OS),Darwin)
PORT = /dev/tty.SLAB_USBtoUART
FLASHER = $(RIOTBOARD)/$(BOARD)/dist/bossac_udoo_osx
else
$(info CAUTION: No flash tool for your host system found!)
# TODO: add support for windows as host platform
endif
export FLASHER
export PORT
export OFLAGS = -O binary
export FFLAGS = -R -e -w -v -b bin/$(BOARD)/$(APPLICATION).hex
# define the default port depending on host OS
PORT_LINUX ?= /dev/ttyACM0
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
# setup serial terminal
include $(RIOTMAKE)/tools/serial.inc.mk
# setup the flash tool (BOSSA)
export BOSSA_ARDUINO_PREFLASH = yes
include $(RIOTMAKE)/tools/bossa.inc.mk

Binary file not shown.

Binary file not shown.

2
dist/tools/bossa/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
bossac
bin

17
dist/tools/bossa/Makefile vendored Normal file
View File

@ -0,0 +1,17 @@
PKG_NAME = bossa
PKG_URL = https://github.com/shumatech/BOSSA
PKG_VERSION = 26154375695f345491bba158d57177aa231d6765
PKG_LICENSE = BSD-3-Clause
PKG_BUILDDIR = $(CURDIR)/bin
.PHONY: all
all: git-download
@echo "[INFO] compiling bossac from source now"
@env -u CXX COMMON_CXXFLAGS="-std=c++11" $(MAKE) BINDIR=$(PKG_BUILDDIR) -C $(PKG_BUILDDIR) strip-bossac
@mv $(PKG_BUILDDIR)/bossac $(CURDIR)/bossac
distclean::
@rm -f $(CURDIR)/bossac
include $(RIOTBASE)/pkg/pkg.mk

View File

@ -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

View File

@ -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!"