diff --git a/examples/gnrc_border_router/Makefile b/examples/gnrc_border_router/Makefile index 52581de201..9a11dbc87e 100644 --- a/examples/gnrc_border_router/Makefile +++ b/examples/gnrc_border_router/Makefile @@ -7,36 +7,6 @@ BOARD ?= samr21-xpro # This has to be the absolute path to the RIOT base directory: RIOTBASE ?= $(CURDIR)/../.. -# use ethos (ethernet over serial) for network communication and stdio over -# UART, but not on native, as native has a tap interface towards the host. -ifeq (,$(filter native,$(BOARD))) - # ethos baudrate can be configured from make command - ETHOS_BAUDRATE ?= 115200 - CFLAGS += -DETHOS_BAUDRATE=$(ETHOS_BAUDRATE) -else - TERMFLAGS += -z [::1]:17754 -endif -GNRC_NETIF_NUMOF := 2 - -# SLIP legacy compatibility -# Uncomment the lines below if you want to use SLIP with this example and don't -# forget to comment the lines above for ethos. -#ifeq (,$(SLIP_UART)) -# set default (last available UART) -#SLIP_UART="UART_DEV(UART_NUMOF-1)" -#endif -#ifeq (,$(SLIP_BAUDRATE)) -# set default -#SLIP_BAUDRATE=115200 -#endif - -#GNRC_NETIF_NUMOF := 2 -#INCLUDES += -I$(CURDIR) -#CFLAGS += -DSLIP_UART=$(SLIP_UART) -#CFLAGS += -DSLIP_BAUDRATE=$(SLIP_BAUDRATE) -# Include SLIP package for IP over Serial communication -#USEMODULE += slipdev - # Include packages that pull up and auto-init the link layer. # NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present USEMODULE += gnrc_netdev_default @@ -50,6 +20,11 @@ USEMODULE += shell USEMODULE += shell_commands USEMODULE += ps +# Optionally include RPL as a routing protocol. When includede gnrc_uhcpc will +# configure the node as a RPL DODAG root when receiving a prefix. +#USEMODULE += gnrc_rpl + +# Optionally use DHCPv6 instead of UHCP USE_DHCPV6 ?= 0 ifeq (1,$(USE_DHCPV6)) @@ -60,9 +35,12 @@ else USEMODULE += gnrc_uhcpc endif -# Optionally include RPL as a routing protocol. When includede gnrc_uhcpc will -# configure the node as a RPL DODAG root when receiving a prefix. -#USEMODULE += gnrc_rpl +# Optionally use SLIP instead of ethos when not on native +# (added to USEMODULE in Makefile.board.dep) +USE_SLIP ?= 0 + +# Use two network interfaces +GNRC_NETIF_NUMOF := 2 # Comment this out to disable code in RIOT that does safety checking # which is not needed in a production environment but helps in the @@ -71,32 +49,29 @@ DEVELHELP ?= 1 # Change this to 0 show compiler invocation lines by default: QUIET ?= 1 + +# Ethos/native TAP interface and UHCP prefix can be configured from make command TAP ?= tap0 IPV6_PREFIX ?= 2001:db8::/64 -ifeq (native,$(BOARD)) -ifneq (1,$(USE_DHCPV6)) -TERMDEPS += uhcpd-daemon - -.PHONY: uhcpd-daemon - -uhcpd-daemon: host-tools - $(RIOTTOOLS)/uhcpd/bin/uhcpd $(TAP) $(IPV6_PREFIX) & -endif # USE_DHCPV6 +# MODULE DEPENDENT CONFIGURATION IMPORT +# ===================================== +# use ethos (ethernet over serial) or SLIP (serial-line IP) for network +# communication and stdio over UART, but not on native, as native has a tap +# interface towards the host. +ifeq (,$(filter native,$(BOARD))) + ifeq (1,$(USE_SLIP)) + # SLIP baudrate and UART device can be configured from make command + SLIP_UART ?= "UART_DEV(UART_NUMOF-1)" + SLIP_BAUDRATE ?= 115200 + include $(CURDIR)/Makefile.slip.conf + else + # ethos baudrate can be configured from make command + ETHOS_BAUDRATE ?= 115200 + include $(CURDIR)/Makefile.ethos.conf + endif else -# We override the `make term` command to use ethos -ifeq (1,$(USE_DHCPV6)) -TERMPROG ?= sudo $(RIOTTOOLS)/ethos/ethos -TERMFLAGS ?= $(TAP) $(PORT) $(ETHOS_BAUDRATE) -else # USE_DHCPV6 -TERMPROG ?= sudo sh $(RIOTTOOLS)/ethos/start_network.sh -TERMFLAGS ?= $(PORT) $(TAP) $(IPV6_PREFIX) -endif - -STATIC_ROUTES ?= 1 -# We depend on the ethos host tools to run the border router, we build them -# if necessary -TERMDEPS += host-tools + include $(CURDIR)/Makefile.native.conf endif # As there is an 'Kconfig' we want to explicitly disable Kconfig by setting @@ -105,19 +80,34 @@ SHOULD_RUN_KCONFIG ?= include $(RIOTBASE)/Makefile.include -ifndef CONFIG_GNRC_DHCPV6_CLIENT_6LBR_STATIC_ROUTE -ifeq (1,$(STATIC_ROUTES)) - CFLAGS += -DCONFIG_GNRC_DHCPV6_CLIENT_6LBR_STATIC_ROUTE=1 - # CONFIG_GNRC_DHCPV6_CLIENT_6LBR_STATIC_ROUTE=1 requires one more address for - # `fe80::2`. - CFLAGS += -DCONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF=3 -endif +# Compile-time configuration for DHCPv6 client (needs to come after +# Makefile.include as this might come from Kconfig) +ifeq (1,$(USE_DHCPV6)) + ifndef CONFIG_GNRC_DHCPV6_CLIENT_6LBR_STATIC_ROUTE + ifeq (1,$(STATIC_ROUTES)) + CFLAGS += -DCONFIG_GNRC_DHCPV6_CLIENT_6LBR_STATIC_ROUTE=1 + # CONFIG_GNRC_DHCPV6_CLIENT_6LBR_STATIC_ROUTE=1 requires one more address + # for `fe80::2`. + CFLAGS += -DCONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF=3 + endif + endif endif + .PHONY: host-tools host-tools: $(Q)env -u CC -u CFLAGS make -C $(RIOTTOOLS) +# define native specific targets to only run UHCP daemon when required +ifneq (,$(filter native,$(BOARD))) +ifneq (1,$(USE_DHCPV6)) +.PHONY: uhcpd-daemon + +uhcpd-daemon: host-tools + $(RIOTTOOLS)/uhcpd/bin/uhcpd $(TAP) $(IPV6_PREFIX) & +endif +endif + # Set a custom channel if needed include $(RIOTMAKE)/default-radio-settings.inc.mk diff --git a/examples/gnrc_border_router/Makefile.board.dep b/examples/gnrc_border_router/Makefile.board.dep index 56cdaf5ed9..7c3e57e5ad 100644 --- a/examples/gnrc_border_router/Makefile.board.dep +++ b/examples/gnrc_border_router/Makefile.board.dep @@ -1,6 +1,10 @@ # Put board specific dependencies here ifeq (,$(filter native,$(BOARD))) - USEMODULE += stdio_ethos + ifeq (1,$(USE_SLIP)) + USEMODULE += slipdev + else + USEMODULE += stdio_ethos + endif else USEMODULE += socket_zep endif diff --git a/examples/gnrc_border_router/Makefile.ethos.conf b/examples/gnrc_border_router/Makefile.ethos.conf new file mode 100644 index 0000000000..138ee5077b --- /dev/null +++ b/examples/gnrc_border_router/Makefile.ethos.conf @@ -0,0 +1,12 @@ +CFLAGS += -DETHOS_BAUDRATE=$(ETHOS_BAUDRATE) + +STATIC_ROUTES ?= 1 + +ifeq (1,$(USE_DHCPV6)) + ETHOS_ONLY=--ethos-only +endif + +# Configure terminal parameters +TERMDEPS += host-tools +TERMPROG ?= sudo sh $(RIOTTOOLS)/ethos/start_network.sh +TERMFLAGS ?= $(ETHOS_ONLY) $(PORT) $(TAP) $(IPV6_PREFIX) diff --git a/examples/gnrc_border_router/Makefile.native.conf b/examples/gnrc_border_router/Makefile.native.conf new file mode 100644 index 0000000000..3340a9f171 --- /dev/null +++ b/examples/gnrc_border_router/Makefile.native.conf @@ -0,0 +1,9 @@ +# native has a TAP interface towards the host, just add parameters for +# `socket_zep` +TERMFLAGS += -z [::1]:17754 + +ifneq (1,$(USE_DHCPV6)) + # We don't need to start ethos so just start the UHCPD daemon in the + # background + TERMDEPS += uhcpd-daemon +endif diff --git a/examples/gnrc_border_router/Makefile.slip.conf b/examples/gnrc_border_router/Makefile.slip.conf new file mode 100644 index 0000000000..2262e9579a --- /dev/null +++ b/examples/gnrc_border_router/Makefile.slip.conf @@ -0,0 +1,6 @@ +INCLUDES += -I$(CURDIR) + +CFLAGS += -DSLIP_UART=$(SLIP_UART) +CFLAGS += -DSLIP_BAUDRATE=$(SLIP_BAUDRATE) + +STATIC_ROUTES ?= 1