From c103b3f6baf38ec4f04f0732f286d44841bb6701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 18 Jun 2018 15:16:51 +0200 Subject: [PATCH 1/4] serial: Do not export PORT. This variable is only used for the term recipe (and maybe for flashing). They should not be evaluated if they are not needed and the user should not see a warning that the port is not set if he does not use port (for example in make all.) --- boards/native/Makefile.include | 4 ++-- makefiles/tools/serial.inc.mk | 1 - makefiles/vars.inc.mk | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/boards/native/Makefile.include b/boards/native/Makefile.include index 9ee94c3eb305..5c0458ccc70e 100644 --- a/boards/native/Makefile.include +++ b/boards/native/Makefile.include @@ -95,9 +95,9 @@ export LINKFLAGS += -ffunction-sections # set the tap interface for term/valgrind ifneq (,$(filter netdev_default gnrc_netdev_default,$(USEMODULE))) - export PORT ?= tap0 + PORT ?= tap0 else - export PORT = + PORT = endif TERMFLAGS := $(PORT) $(TERMFLAGS) diff --git a/makefiles/tools/serial.inc.mk b/makefiles/tools/serial.inc.mk index 8abcf7fe1d1f..115647d84f50 100644 --- a/makefiles/tools/serial.inc.mk +++ b/makefiles/tools/serial.inc.mk @@ -8,7 +8,6 @@ endif ifeq ($(PORT),) $(info Warning: no PORT set!) endif -export PORT export BAUD ?= 115200 diff --git a/makefiles/vars.inc.mk b/makefiles/vars.inc.mk index b46d5f70b501..850476fbe634 100644 --- a/makefiles/vars.inc.mk +++ b/makefiles/vars.inc.mk @@ -74,7 +74,7 @@ export GIT_CACHE_DIR # path to git-cache cache directory export FLASH_ADDR # Define an offset to flash code into ROM memory. # TERMPROG # The command to call on "make term". # TERMFLAGS # Additional parameters to supply to TERMPROG. -export PORT # The port to connect the TERMPROG to. +# PORT # The port to connect the TERMPROG to. export ELFFILE # The unstripped result of the compilation. export HEXFILE # The stripped result of the compilation. # FLASHFILE # The output file used for flashing (transition phase: only if defined) From 7f1357b721dfc025ee9b012eba1ce5286867d12e Mon Sep 17 00:00:00 2001 From: Juan Carrano Date: Mon, 3 Jun 2019 13:16:09 +0200 Subject: [PATCH 2/4] tools/usb-serial: do not advise people to export PORT. The example in the tool documentation contains several things that are wrong: - exports PORT. - Defines the port using :=. - Defines PORT instead of PORT_LINUX, PORT_DARWIN - ifeq-based logic (which will force an evaluation). I have not tested the new example script. --- dist/tools/usb-serial/README.md | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/dist/tools/usb-serial/README.md b/dist/tools/usb-serial/README.md index ffa21ad76c04..d7df920f05f7 100644 --- a/dist/tools/usb-serial/README.md +++ b/dist/tools/usb-serial/README.md @@ -41,29 +41,14 @@ solution): # Add serial matching command ifneq ($(PROGRAMMER_SERIAL),) OOCD_BOARD_FLAGS += -c 'ftdi_serial $(PROGRAMMER_SERIAL)' - - ifeq ($(PORT),) - # try to find tty name by serial number, only works on Linux currently. - ifeq ($(OS),Linux) - PORT := $(firstword $(shell $(RIOTTOOLS)/usb-serial/find-tty.sh "^$(PROGRAMMER_SERIAL)$$")) - endif - endif endif - # Fallback PORT if no serial was specified or if the specified serial was not found - ifeq ($(PORT),) - ifeq ($(OS),Linux) - PORT := $(firstword $(shell $(RIOTTOOLS)/usb-serial/find-tty.sh)) - else ifeq ($(OS),Darwin) - PORT := $(shell ls -1 /dev/tty.SLAB_USBtoUART* | head -n 1) - endif - endif + PORT_LINUX_EXACT = $(if $(PROGRAMMER_SERIAL),$(firstword $(shell $(RIOTTOOLS)/usb-serial/find-tty.sh "^$(PROGRAMMER_SERIAL)$$")),) + + PORT_LINUX = $(if $(PORT_LINUX_EXACT),$(PORT_LINUX_EXACT),$(firstword $(shell $(RIOTTOOLS)/usb-serial/find-tty.sh))) + + PORT_DARWIN = $(shell ls -1 /dev/tty.SLAB_USBtoUART* | head -n 1) - # TODO: add support for windows as host platform - ifeq ($(PORT),) - $(info CAUTION: No terminal port for your host system found!) - endif - export PORT Limitations From 184c34b723ceed94aa74411a3089d947ddc032cd Mon Sep 17 00:00:00 2001 From: Juan Carrano Date: Tue, 6 Nov 2018 18:59:15 +0100 Subject: [PATCH 3/4] makefiles/tools/serial: ensure PORT is set and fail early. By ensuring the PORT auto-detection worked, we can give meaningful error messages and fail earlier. This uses ensure_value from makefiles/utils/checks.mk. An include was added to Makefile.include to make this fuction available to all other makefiles. --- Makefile.include | 3 +++ makefiles/tools/serial.inc.mk | 7 ++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile.include b/Makefile.include index f9ed21b6a1a6..5c109aadbe9e 100644 --- a/Makefile.include +++ b/Makefile.include @@ -86,6 +86,9 @@ OS := $(shell uname) # set python path, e.g. for tests PYTHONPATH := $(RIOTBASE)/dist/pythonlibs/:$(PYTHONPATH) +# Basic utilities included before anything else +include $(RIOTMAKE)/utils/checks.mk + # Include Docker settings near the top because we need to build the environment # command line before some of the variable origins are overwritten below when # using abspath, strip etc. diff --git a/makefiles/tools/serial.inc.mk b/makefiles/tools/serial.inc.mk index 115647d84f50..2a2a68718496 100644 --- a/makefiles/tools/serial.inc.mk +++ b/makefiles/tools/serial.inc.mk @@ -1,12 +1,9 @@ # set default port depending on operating system OS := $(shell uname) ifeq ($(OS),Linux) - PORT ?= $(PORT_LINUX) + PORT ?= $(call ensure_value,$(PORT_LINUX),No port set) else ifeq ($(OS),Darwin) - PORT ?= $(PORT_DARWIN) -endif -ifeq ($(PORT),) - $(info Warning: no PORT set!) + PORT ?= $(call ensure_value,$(PORT_DARWIN),No port set) endif export BAUD ?= 115200 From 3d967308dede6f1d5428ee0f23a0799fd242d39f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Tue, 13 Nov 2018 08:13:12 -0800 Subject: [PATCH 4/4] DELETEME: unset PORT to test murdock build. --- .murdock | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.murdock b/.murdock index 77d881c5ae6f..7ea1cb4b4861 100755 --- a/.murdock +++ b/.murdock @@ -194,6 +194,11 @@ compile() { [ ! -d "$appdir" ] && error "$0: compile: error: application directory \"$appdir\" doesn't exist" [ ! -d "boards/$board" ] && error "$0: compile: error: board directory \"boards/$board\" doesn't exist" + # Try removing PORT that should be already be set by murdock + # https://github.com/RIOT-OS/RIOT/pull/7695#discussion_r180896514 + # to let the auto-detection work and fail in murdock + unset PORT + # compile CCACHE_BASEDIR="$(pwd)" BOARD=$board TOOLCHAIN=$toolchain RIOT_CI_BUILD=1 \ make -C${appdir} clean all test-input-hash -j${JOBS:-4}