boards: arduino_due: Add make flash support

This patch automates flashing process for arduino_due board. Just make flash will able
to flash binary file on the board.

Bossa tool(http://www.shumatech.com/web/products/bossa) manual flashing process is
automated through shell script and currently this binary is only available for
x86_64 architecture.

JIRA : ZEP-145

Change-Id: Ib7b525466239d0437e449c56827f8a9b3e5a96a1
Signed-off-by: Punit Vara <punit.vara@intel.com>
diff --git a/boards/arm/arduino_due/Makefile.board b/boards/arm/arduino_due/Makefile.board
new file mode 100644
index 0000000..14650cd
--- /dev/null
+++ b/boards/arm/arduino_due/Makefile.board
@@ -0,0 +1 @@
+FLASH_SCRIPT = bossa-flash.sh
diff --git a/scripts/Makefile.toolchain.zephyr b/scripts/Makefile.toolchain.zephyr
index f5796e3..faea0b1 100644
--- a/scripts/Makefile.toolchain.zephyr
+++ b/scripts/Makefile.toolchain.zephyr
@@ -113,7 +113,9 @@
 OPENOCD ?= ${TOOLCHAIN_HOME}/usr/bin/openocd
 OPENOCD_DEFAULT_PATH ?= ${TOOLCHAIN_HOME}/usr/share/openocd/scripts
 
-export LIB_INCLUDE_DIR CROSS_COMPILE TOOLCHAIN_LIBS QEMU_BIN_PATH QEMU TOOLCHAIN_CFLAGS OPENOCD OPENOCD_DEFAULT_PATH DTC
+BOSSAC ?= ${TOOLCHAIN_HOME}/usr/bin/bossac
+
+export LIB_INCLUDE_DIR CROSS_COMPILE TOOLCHAIN_LIBS QEMU_BIN_PATH QEMU TOOLCHAIN_CFLAGS OPENOCD OPENOCD_DEFAULT_PATH DTC BOSSAC
 
 ifndef MAKEFILE_TOOLCHAIN_DO_PASS2
 MAKEFILE_TOOLCHAIN_DO_PASS2=true
diff --git a/scripts/support/bossa-flash.sh b/scripts/support/bossa-flash.sh
new file mode 100755
index 0000000..348f59b
--- /dev/null
+++ b/scripts/support/bossa-flash.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# This script is loosly based on a script with same purpose provided
+# by RIOT-OS (https://github.com/RIOT-OS/RIOT)
+
+BOSSAC_CMD="${BOSSAC:-bossac}"
+if [ `uname` = "Linux" ]; then
+    stty -F /dev/ttyACM0 raw ispeed 1200 ospeed 1200 cs8 \
+-cstopb ignpar eol 255 eof 255
+    ${BOSSAC} -R -e -w -v -b "${O}/${KERNEL_BIN_NAME}"
+else
+    echo "CAUTION: No flash tool for your host system found!"
+fi
+