From a886c7c0d5503b2125b759f3b9865233d3a83390 Mon Sep 17 00:00:00 2001
From: Jonas <j.remmert@phytec.de>
Date: Fri, 11 Mar 2016 09:11:03 +0100
Subject: [PATCH] pba-d-01-kw2x: enable support to flash board selected by its
 SERIAL no

---
 boards/pba-d-01-kw2x/Makefile.include | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/boards/pba-d-01-kw2x/Makefile.include b/boards/pba-d-01-kw2x/Makefile.include
index 649e536d1b..caedbab8e1 100644
--- a/boards/pba-d-01-kw2x/Makefile.include
+++ b/boards/pba-d-01-kw2x/Makefile.include
@@ -29,6 +29,18 @@ export PRE_FLASH_CHECK_SCRIPT = $(RIOTCPU)/kinetis_common/dist/check-fcfield-elf
 
 include $(RIOTBOARD)/$(BOARD)/Makefile.dep
 
+# Add board selector (USB serial) to OpenOCD options if specified.
+# Use /dist/tools/usb-serial/list-ttys.sh to find out serial number.
+#   Usage: SERIAL="0200..." BOARD="pba-d-01-kw2x" make flash
+ifneq (,$(SERIAL))
+    export OPENOCD_EXTRA_INIT += "-c cmsis_dap_serial $(SERIAL)"
+    SERIAL_TTY = $(shell $(RIOTBASE)/dist/tools/usb-serial/find-tty.sh $(SERIAL))
+    ifeq (,$(SERIAL_TTY))
+        $(error Did not find a device with serial $(SERIAL))
+    endif
+    PORT_LINUX := $(SERIAL_TTY)
+endif
+
 # setup serial terminal
 include $(RIOTBOARD)/Makefile.include.serial
 
-- 
GitLab