diff --git a/boards/arduino-mega2560/Makefile.include b/boards/arduino-mega2560/Makefile.include index f8c28919ff..67afc9315b 100644 --- a/boards/arduino-mega2560/Makefile.include +++ b/boards/arduino-mega2560/Makefile.include @@ -25,11 +25,11 @@ ARDUINO_MEGA2560_COMPAT_WITH_CLONES ?= 1 ifeq (1,$(ARDUINO_MEGA2560_COMPAT_WITH_CLONES)) TTY_SELECT_CMD := $(RIOTTOOLS)/usb-serial/ttys.py \ --most-recent \ - --format path \ + --format path serial \ $(TTY_BOARD_FILTER) || \ $(RIOTTOOLS)/usb-serial/ttys.py \ --most-recent \ - --format path \ + --format path serial \ $(TTY_BOARD_FILTER_CLONE) endif diff --git a/doc/doxygen/src/flashing.md b/doc/doxygen/src/flashing.md index 46f0b8301e..298d4cd50a 100644 --- a/doc/doxygen/src/flashing.md +++ b/doc/doxygen/src/flashing.md @@ -478,20 +478,20 @@ In most cases, just adding a simple `TTY_BOARD_FILTER` is sufficient. If we however have wildly different flavors of the same board (e.g. genuine Arduino Mega 2560 with an ATmega16U2 and clones with a cheap USB to UART bridge) that we all want to support, we have to instead provide a `TTY_SELECT_CMD` that prints -the path to the TTY and exists with `0` if a TTY was found, or that exists with -`1` and prints nothing when no TTY was found. We can still use the `ttys.py` -script to detect all Arduino Mega 2560 versions: We first try to detect a -genuine Arduino Mega and fall back to selecting cheap USB UART bridges when that -fails using the `||` shell operator: +the path to and the serial of the TTY (separated by a space) and exists with +`0` if a TTY was found, or that exists with `1` and prints nothing when no TTY +was found. We can still use the `ttys.py` script to detect all Arduino Mega +2560 versions: We first try to detect a genuine Arduino Mega and fall back to +selecting cheap USB UART bridges when that fails using the `||` shell operator: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TTY_SELECT_CMD := $(RIOTTOOLS)/usb-serial/ttys.py \ --most-recent \ - --format path \ + --format path serial \ --vendor 'Arduino' \ --model-db 'Mega 2560|Mega ADK' || \ $(RIOTTOOLS)/usb-serial/ttys.py \ --most-recent \ - --format path \ + --format path serial \ --driver 'cp210x' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/makefiles/tools/serial.inc.mk b/makefiles/tools/serial.inc.mk index d2097afaa1..cb6e768a46 100644 --- a/makefiles/tools/serial.inc.mk +++ b/makefiles/tools/serial.inc.mk @@ -5,10 +5,15 @@ ifeq (1,$(MOST_RECENT_PORT)) endif TTY_SELECT_CMD ?= $(RIOTTOOLS)/usb-serial/ttys.py \ --most-recent \ - --format path \ + --format path serial \ $(TTY_BOARD_FILTER) - PORT_DETECTED := $(shell $(TTY_SELECT_CMD) || echo 'no-tty-detected') - PORT ?= $(PORT_DETECTED) + TTY_DETECTED := $(shell $(TTY_SELECT_CMD) || echo 'no-tty-detected no-serial-detected') + PORT_DETECTED := $(firstword $(TTY_DETECTED)) + PORT_SERIAL_DETECTED := $(lastword $(TTY_DETECTED)) + PORT ?= $(firstword $(TTY_DETECTED)) + ifeq (1,$(DEBUG_ADAPTER_ID_IS_TTY_SERIAL)) + DEBUG_ADAPTER_ID ?= $(PORT_SERIAL_DETECTED) + endif endif # Otherwise, use as default the most commonly used ports on Linux and OSX PORT_LINUX ?= /dev/ttyACM0