From d80f18de0b110f7137dfda019c023ab97fc9989b Mon Sep 17 00:00:00 2001
From: Lucas Jenss <lucas@x3ro.de>
Date: Tue, 27 Oct 2015 10:36:42 +0100
Subject: [PATCH] Minor usability improvements for samr21 usage

---
 Makefile.include                    | 3 +++
 boards/samr21-xpro/Makefile.include | 8 ++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Makefile.include b/Makefile.include
index 0c0622888b..dcbc2efc25 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -287,6 +287,9 @@ term: $(filter flash, $(MAKECMDGOALS))
 		exit 1; }
 	$(TERMPROG) $(TERMFLAGS)
 
+list-ttys:
+	$(AD)$(RIOTBASE)/dist/tools/usb-serial/list-ttys.sh
+
 doc:
 	make -BC $(RIOTBASE) doc
 
diff --git a/boards/samr21-xpro/Makefile.include b/boards/samr21-xpro/Makefile.include
index e472d36b60..db23d819ac 100644
--- a/boards/samr21-xpro/Makefile.include
+++ b/boards/samr21-xpro/Makefile.include
@@ -16,8 +16,12 @@ include $(RIOTBOARD)/Makefile.include.serial
 # Use /dist/tools/usb-serial/list-ttys.sh to find out serial number.
 #   Usage: SERIAL="ATML..." BOARD="samr21-xpro" make flash
 ifneq (,$(SERIAL))
-export OPENOCD_EXTRA_INIT += "-c cmsis_dap_serial $(SERIAL)"
-PORT_LINUX := $(shell $(RIOTBASE)/dist/tools/usb-serial/find-tty.sh $(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
 
 # this board uses openocd
-- 
GitLab