From d280f8854e3cd45ca901d61984ce64431b29435c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 1 Jul 2017 08:39:39 -0600 Subject: [PATCH 01/33] include/nuttx/net and net/: Move private prototype of netdev_foreach() from the public include/nuttx/net/net.h to the private net/netdev/ndetdev.h header file where it belongs. --- include/nuttx/net/net.h | 28 +--------------------------- net/devif/ipv6_input.c | 2 +- net/netdev/netdev.h | 31 +++++++++++++++++++++++++++++++ net/netdev/netdev_foreach.c | 9 +++------ 4 files changed, 36 insertions(+), 34 deletions(-) diff --git a/include/nuttx/net/net.h b/include/nuttx/net/net.h index 4ccbdfde381..e12fb99d1ed 100644 --- a/include/nuttx/net/net.h +++ b/include/nuttx/net/net.h @@ -137,11 +137,6 @@ struct socketlist }; #endif -/* Callback from netdev_foreach() */ - -struct net_driver_s; /* Forward reference. Defined in nuttx/net/netdev.h */ -typedef int (*netdev_callback_t)(FAR struct net_driver_s *dev, FAR void *arg); - /**************************************************************************** * Public Data ****************************************************************************/ @@ -1177,6 +1172,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap); * ****************************************************************************/ +struct net_driver_s; /* Forward reference */ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype); /**************************************************************************** @@ -1199,28 +1195,6 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype); int netdev_unregister(FAR struct net_driver_s *dev); -/**************************************************************************** - * Name: netdev_foreach - * - * Description: - * Enumerate each registered network device. - * - * NOTE: netdev semaphore held throughout enumeration. - * - * Parameters: - * callback - Will be called for each registered device - * arg - User argument passed to callback() - * - * Returned Value: - * 0:Enumeration completed 1:Enumeration terminated early by callback - * - * Assumptions: - * Called from normal user mode - * - ****************************************************************************/ - -int netdev_foreach(netdev_callback_t callback, FAR void *arg); - #undef EXTERN #ifdef __cplusplus } diff --git a/net/devif/ipv6_input.c b/net/devif/ipv6_input.c index 98db2cd7c90..8d2a28776cd 100644 --- a/net/devif/ipv6_input.c +++ b/net/devif/ipv6_input.c @@ -87,7 +87,6 @@ #include -#include #include #include #include @@ -242,6 +241,7 @@ static bool check_destipaddr(FAR struct net_driver_s *dev, * to this input. * * Assumptions: + * The network is locked. * ****************************************************************************/ diff --git a/net/netdev/netdev.h b/net/netdev/netdev.h index 06409909cfd..206a9e67faa 100644 --- a/net/netdev/netdev.h +++ b/net/netdev/netdev.h @@ -70,6 +70,15 @@ extern "C" EXTERN struct net_driver_s *g_netdevices; #endif +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* Callback from netdev_foreach() */ + +struct net_driver_s; /* Forward reference */ +typedef int (*netdev_callback_t)(FAR struct net_driver_s *dev, FAR void *arg); + /**************************************************************************** * Public Function Prototypes ****************************************************************************/ @@ -120,6 +129,28 @@ bool netdev_verify(FAR struct net_driver_s *dev); FAR struct net_driver_s *netdev_findbyname(FAR const char *ifname); #endif +/**************************************************************************** + * Name: netdev_foreach + * + * Description: + * Enumerate each registered network device. + * + * NOTE: netdev semaphore held throughout enumeration. + * + * Parameters: + * callback - Will be called for each registered device + * arg - User argument passed to callback() + * + * Returned Value: + * 0:Enumeration completed 1:Enumeration terminated early by callback + * + * Assumptions: + * Called from normal user mode + * + ****************************************************************************/ + +int netdev_foreach(netdev_callback_t callback, FAR void *arg); + /**************************************************************************** * Name: netdev_findby_ipv4addr * diff --git a/net/netdev/netdev_foreach.c b/net/netdev/netdev_foreach.c index bb6a9c6c3ef..94961829738 100644 --- a/net/netdev/netdev_foreach.c +++ b/net/netdev/netdev_foreach.c @@ -41,7 +41,7 @@ #if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0 #include -#include + #include #include "netdev/netdev.h" @@ -66,7 +66,7 @@ * 0:Enumeration completed 1:Enumeration terminated early by callback * * Assumptions: - * Called from normal user mode + * The network is locked. * ****************************************************************************/ @@ -75,9 +75,8 @@ int netdev_foreach(netdev_callback_t callback, FAR void *arg) FAR struct net_driver_s *dev; int ret = 0; - if (callback) + if (callback != NULL) { - net_lock(); for (dev = g_netdevices; dev; dev = dev->flink) { if (callback(dev, arg) != 0) @@ -86,8 +85,6 @@ int netdev_foreach(netdev_callback_t callback, FAR void *arg) break; } } - - net_unlock(); } return ret; From 0b4a9a0b3d4deed2c46f77a22d8e11424412d23e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 1 Jul 2017 17:24:40 -0600 Subject: [PATCH 02/33] same570-xplained: Refresh configurations. --- configs/same70-xplained/netnsh/defconfig | 44 ++++++++++++++++++------ configs/same70-xplained/nsh/defconfig | 38 +++++++++++++++++--- 2 files changed, 66 insertions(+), 16 deletions(-) diff --git a/configs/same70-xplained/netnsh/defconfig b/configs/same70-xplained/netnsh/defconfig index 6a549028108..3d31de8a40a 100644 --- a/configs/same70-xplained/netnsh/defconfig +++ b/configs/same70-xplained/netnsh/defconfig @@ -34,6 +34,7 @@ CONFIG_BUILD_FLAT=y # CONFIG_MOTOROLA_SREC is not set CONFIG_RAW_BINARY=y # CONFIG_UBOOT_UIMAGE is not set +# CONFIG_DFU_BINARY is not set # # Customize Header Files @@ -129,8 +130,6 @@ CONFIG_ARCH_CORTEXM7=y # CONFIG_ARCH_CORTEXR7F is not set CONFIG_ARCH_FAMILY="armv7-m" CONFIG_ARCH_CHIP="samv7" -# CONFIG_ARCH_TOOLCHAIN_IAR is not set -CONFIG_ARCH_TOOLCHAIN_GNU=y # CONFIG_ARMV7M_USEBASEPRI is not set CONFIG_ARCH_HAVE_CMNVECTOR=y CONFIG_ARMV7M_CMNVECTOR=y @@ -319,6 +318,8 @@ CONFIG_SAMV7_EMAC0_ISETH0=y # CONFIG_SAMV7_EMAC_PREALLOCATE is not set # CONFIG_SAMV7_EMAC_NBC is not set CONFIG_SAMV7_EMAC_HPWORK=y +# CONFIG_ARCH_TOOLCHAIN_IAR is not set +CONFIG_ARCH_TOOLCHAIN_GNU=y # # Architecture Options @@ -339,6 +340,7 @@ CONFIG_ARCH_HAVE_MPU=y # CONFIG_ARCH_HAVE_EXTCLK is not set # CONFIG_ARCH_HAVE_POWEROFF is not set CONFIG_ARCH_HAVE_RESET=y +# CONFIG_ARCH_HAVE_RTC_SUBSECONDS is not set # CONFIG_ARCH_USE_MPU is not set # CONFIG_ARCH_IRQPRIO is not set CONFIG_ARCH_STACKDUMP=y @@ -536,15 +538,6 @@ CONFIG_DEV_NULL=y # # Buffering # - -# -# Common I/O Buffer Support -# -CONFIG_MM_IOB=y -CONFIG_IOB_NBUFFERS=24 -CONFIG_IOB_BUFSIZE=196 -CONFIG_IOB_NCHAINS=8 -CONFIG_IOB_THROTTLE=8 # CONFIG_DRVR_WRITEBUFFER is not set # CONFIG_DRVR_READAHEAD is not set # CONFIG_RAMDISK is not set @@ -772,7 +765,9 @@ CONFIG_USART1_2STOP=0 # System Logging # # CONFIG_ARCH_SYSLOG is not set +CONFIG_SYSLOG_WRITE=y # CONFIG_RAMLOG is not set +# CONFIG_SYSLOG_BUFFER is not set # CONFIG_SYSLOG_INTBUFFER is not set # CONFIG_SYSLOG_TIMESTAMP is not set CONFIG_SYSLOG_SERIAL_CONSOLE=y @@ -890,6 +885,11 @@ CONFIG_ARP_SEND_DELAYMSEC=20 # CONFIG_NET_ARCH_INCR32 is not set # CONFIG_NET_ARCH_CHKSUM is not set CONFIG_NET_STATISTICS=y +# CONFIG_NET_HAVE_STAR is not set + +# +# Network Topologies +# # # Routing Table Configuration @@ -958,6 +958,15 @@ CONFIG_MM_REGIONS=1 # CONFIG_ARCH_HAVE_HEAP2 is not set # CONFIG_GRAN is not set +# +# Common I/O Buffer Support +# +CONFIG_MM_IOB=y +CONFIG_IOB_NBUFFERS=24 +CONFIG_IOB_BUFSIZE=196 +CONFIG_IOB_NCHAINS=8 +CONFIG_IOB_THROTTLE=8 + # # Audio Support # @@ -966,6 +975,7 @@ CONFIG_MM_REGIONS=1 # # Wireless Support # +# CONFIG_WIRELESS is not set # # Binary Loader @@ -1216,6 +1226,7 @@ CONFIG_NETUTILS_NETLIB=y # CONFIG_NETUTILS_NTPCLIENT is not set # CONFIG_NETUTILS_PPPD is not set # CONFIG_NETUTILS_SMTP is not set +# CONFIG_NETUTILS_TELNETC is not set CONFIG_NETUTILS_TELNETD=y CONFIG_NETUTILS_TFTPC=y CONFIG_NETUTILS_WEBCLIENT=y @@ -1293,6 +1304,7 @@ CONFIG_NSH_DISABLE_PRINTF=y # CONFIG_NSH_DISABLE_SLEEP is not set # CONFIG_NSH_DISABLE_TIME is not set # CONFIG_NSH_DISABLE_TEST is not set +# CONFIG_NSH_DISABLE_TELNETD is not set # CONFIG_NSH_DISABLE_UMOUNT is not set # CONFIG_NSH_DISABLE_UNAME is not set # CONFIG_NSH_DISABLE_UNSET is not set @@ -1329,6 +1341,7 @@ CONFIG_NSH_ARCHINIT=y # Networking Configuration # CONFIG_NSH_NETINIT=y +# CONFIG_NSH_NETLOCAL is not set CONFIG_NSH_NETINIT_THREAD=y CONFIG_NSH_NETINIT_MONITOR=y CONFIG_NSH_NETINIT_SIGNO=18 @@ -1378,6 +1391,7 @@ CONFIG_NSH_IOBUFFER_SIZE=512 # # CONFIG_SYSTEM_CLE is not set # CONFIG_SYSTEM_CUTERM is not set +# CONFIG_SYSTEM_DHCPC_RENEW is not set # CONFIG_SYSTEM_FLASH_ERASEALL is not set # CONFIG_SYSTEM_FREE is not set # CONFIG_SYSTEM_HEX2BIN is not set @@ -1392,6 +1406,7 @@ CONFIG_I2CTOOL_DEFFREQ=400000 # CONFIG_SYSTEM_INSTALL is not set # CONFIG_SYSTEM_MDIO is not set # CONFIG_SYSTEM_NETDB is not set +# CONFIG_SYSTEM_NTPC is not set # CONFIG_SYSTEM_RAMTEST is not set CONFIG_READLINE_HAVE_EXTMATCH=y CONFIG_SYSTEM_READLINE=y @@ -1408,3 +1423,10 @@ CONFIG_READLINE_ECHO=y # # Wireless Libraries and NSH Add-Ons # + +# +# IEEE 802.15.4 applications +# +# CONFIG_IEEE802154_LIBMAC is not set +# CONFIG_IEEE802154_LIBUTILS is not set +# CONFIG_IEEE802154_I8SAK is not set diff --git a/configs/same70-xplained/nsh/defconfig b/configs/same70-xplained/nsh/defconfig index be26e40beac..ad62b1e4bbe 100644 --- a/configs/same70-xplained/nsh/defconfig +++ b/configs/same70-xplained/nsh/defconfig @@ -34,6 +34,7 @@ CONFIG_BUILD_FLAT=y # CONFIG_MOTOROLA_SREC is not set CONFIG_RAW_BINARY=y # CONFIG_UBOOT_UIMAGE is not set +# CONFIG_DFU_BINARY is not set # # Customize Header Files @@ -95,6 +96,7 @@ CONFIG_ARCH="arm" # CONFIG_ARCH_CHIP_LPC2378 is not set # CONFIG_ARCH_CHIP_LPC31XX is not set # CONFIG_ARCH_CHIP_LPC43XX is not set +# CONFIG_ARCH_CHIP_MOXART is not set # CONFIG_ARCH_CHIP_NUC1XX is not set # CONFIG_ARCH_CHIP_SAMA5 is not set # CONFIG_ARCH_CHIP_SAMD is not set @@ -102,11 +104,12 @@ CONFIG_ARCH="arm" # CONFIG_ARCH_CHIP_SAM34 is not set CONFIG_ARCH_CHIP_SAMV7=y # CONFIG_ARCH_CHIP_STM32 is not set +# CONFIG_ARCH_CHIP_STM32F0 is not set # CONFIG_ARCH_CHIP_STM32F7 is not set # CONFIG_ARCH_CHIP_STM32L4 is not set # CONFIG_ARCH_CHIP_STR71X is not set # CONFIG_ARCH_CHIP_TMS570 is not set -# CONFIG_ARCH_CHIP_MOXART is not set +# CONFIG_ARCH_CHIP_XMC4 is not set # CONFIG_ARCH_ARM7TDMI is not set # CONFIG_ARCH_ARM926EJS is not set # CONFIG_ARCH_ARM920T is not set @@ -127,8 +130,6 @@ CONFIG_ARCH_CORTEXM7=y # CONFIG_ARCH_CORTEXR7F is not set CONFIG_ARCH_FAMILY="armv7-m" CONFIG_ARCH_CHIP="samv7" -# CONFIG_ARCH_TOOLCHAIN_IAR is not set -CONFIG_ARCH_TOOLCHAIN_GNU=y # CONFIG_ARMV7M_USEBASEPRI is not set CONFIG_ARCH_HAVE_CMNVECTOR=y CONFIG_ARMV7M_CMNVECTOR=y @@ -302,6 +303,8 @@ CONFIG_SAMV7_HSMCI_DMA=y # CONFIG_SAMV7_HSMCI_RDPROOF is not set # CONFIG_SAMV7_HSMCI_WRPROOF is not set # CONFIG_SAMV7_HSMCI_UNALIGNED is not set +# CONFIG_ARCH_TOOLCHAIN_IAR is not set +CONFIG_ARCH_TOOLCHAIN_GNU=y # # Architecture Options @@ -322,6 +325,7 @@ CONFIG_ARCH_HAVE_MPU=y # CONFIG_ARCH_HAVE_EXTCLK is not set # CONFIG_ARCH_HAVE_POWEROFF is not set CONFIG_ARCH_HAVE_RESET=y +# CONFIG_ARCH_HAVE_RTC_SUBSECONDS is not set # CONFIG_ARCH_USE_MPU is not set # CONFIG_ARCH_IRQPRIO is not set CONFIG_ARCH_STACKDUMP=y @@ -439,6 +443,8 @@ CONFIG_SCHED_WAITPID=y # # CONFIG_PTHREAD_MUTEX_TYPES is not set CONFIG_PTHREAD_MUTEX_ROBUST=y +# CONFIG_PTHREAD_MUTEX_UNSAFE is not set +# CONFIG_PTHREAD_MUTEX_BOTH is not set CONFIG_NPTHREAD_KEYS=4 # CONFIG_PTHREAD_CLEANUP is not set # CONFIG_CANCELLATION_POINTS is not set @@ -694,6 +700,7 @@ CONFIG_USART1_2STOP=0 # CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set +# CONFIG_USBMISC is not set # CONFIG_HAVE_USBTRACE is not set # CONFIG_DRIVERS_WIRELESS is not set # CONFIG_DRIVERS_CONTACTLESS is not set @@ -702,7 +709,9 @@ CONFIG_USART1_2STOP=0 # System Logging # # CONFIG_ARCH_SYSLOG is not set +CONFIG_SYSLOG_WRITE=y # CONFIG_RAMLOG is not set +# CONFIG_SYSLOG_BUFFER is not set # CONFIG_SYSLOG_INTBUFFER is not set # CONFIG_SYSLOG_TIMESTAMP is not set CONFIG_SYSLOG_SERIAL_CONSOLE=y @@ -778,6 +787,11 @@ CONFIG_MM_REGIONS=1 # CONFIG_ARCH_HAVE_HEAP2 is not set # CONFIG_GRAN is not set +# +# Common I/O Buffer Support +# +# CONFIG_MM_IOB is not set + # # Audio Support # @@ -786,6 +800,7 @@ CONFIG_MM_REGIONS=1 # # Wireless Support # +# CONFIG_WIRELESS is not set # # Binary Loader @@ -946,7 +961,6 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024 # CONFIG_EXAMPLES_MM is not set # CONFIG_EXAMPLES_MODBUS is not set # CONFIG_EXAMPLES_MOUNT is not set -# CONFIG_EXAMPLES_NRF24L01TERM is not set CONFIG_EXAMPLES_NSH=y # CONFIG_EXAMPLES_NULL is not set # CONFIG_EXAMPLES_NX is not set @@ -972,12 +986,12 @@ CONFIG_EXAMPLES_NSH=y # CONFIG_EXAMPLES_SMP is not set # CONFIG_EXAMPLES_STAT is not set # CONFIG_EXAMPLES_TCPECHO is not set -# CONFIG_EXAMPLES_TELNETD is not set # CONFIG_EXAMPLES_TIFF is not set # CONFIG_EXAMPLES_TOUCHSCREEN is not set # CONFIG_EXAMPLES_USBSERIAL is not set # CONFIG_EXAMPLES_WATCHDOG is not set # CONFIG_EXAMPLES_WEBSERVER is not set +# CONFIG_EXAMPLES_XBC_TEST is not set # # File System Utilities @@ -1086,6 +1100,7 @@ CONFIG_NSH_DISABLE_PRINTF=y # CONFIG_NSH_DISABLE_SLEEP is not set # CONFIG_NSH_DISABLE_TIME is not set # CONFIG_NSH_DISABLE_TEST is not set +# CONFIG_NSH_DISABLE_TELNETD is not set # CONFIG_NSH_DISABLE_UMOUNT is not set # CONFIG_NSH_DISABLE_UNAME is not set # CONFIG_NSH_DISABLE_UNSET is not set @@ -1148,6 +1163,8 @@ CONFIG_I2CTOOL_MAXREGADDR=0xff CONFIG_I2CTOOL_DEFFREQ=400000 # CONFIG_SYSTEM_INSTALL is not set CONFIG_SYSTEM_RAMTEST=y +CONFIG_SYSTEM_RAMTEST_PRIORITY=100 +CONFIG_SYSTEM_RAMTEST_STACKSIZE=1024 CONFIG_READLINE_HAVE_EXTMATCH=y CONFIG_SYSTEM_READLINE=y CONFIG_READLINE_ECHO=y @@ -1159,3 +1176,14 @@ CONFIG_READLINE_ECHO=y # CONFIG_SYSTEM_UBLOXMODEM is not set # CONFIG_SYSTEM_VI is not set # CONFIG_SYSTEM_ZMODEM is not set + +# +# Wireless Libraries and NSH Add-Ons +# + +# +# IEEE 802.15.4 applications +# +# CONFIG_IEEE802154_LIBMAC is not set +# CONFIG_IEEE802154_LIBUTILS is not set +# CONFIG_IEEE802154_I8SAK is not set From 44bd7d3b7f95fcf035288b8922c01999c5da61e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Goran=20Meki=C4=87?= Date: Sat, 1 Jul 2017 22:43:10 +0200 Subject: [PATCH 03/33] Initial clang compile --- .../nucleo-f4x1re/f401-nsh-clang/Make.defs | 117 ++ .../nucleo-f4x1re/f401-nsh-clang/defconfig | 1284 +++++++++++++++++ include/nuttx/compiler.h | 2 + 3 files changed, 1403 insertions(+) create mode 100644 configs/nucleo-f4x1re/f401-nsh-clang/Make.defs create mode 100644 configs/nucleo-f4x1re/f401-nsh-clang/defconfig diff --git a/configs/nucleo-f4x1re/f401-nsh-clang/Make.defs b/configs/nucleo-f4x1re/f401-nsh-clang/Make.defs new file mode 100644 index 00000000000..586784f71c2 --- /dev/null +++ b/configs/nucleo-f4x1re/f401-nsh-clang/Make.defs @@ -0,0 +1,117 @@ +############################################################################ +# configs/nucleo-f4x1re/f401-nsh-clang/Make.defs +# +# Copyright (C) 2014 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +include ${TOPDIR}/.config +include ${TOPDIR}/tools/Config.mk +include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs + +ifeq ($(CONFIG_ARCH_CHIP_STM32F401RE),y) +LDSCRIPT = f401re.ld +else +ifeq ($(CONFIG_ARCH_CHIP_STM32F411RE),y) +LDSCRIPT = f411re.ld +endif +endif + +ifeq ($(WINTOOL),y) + # Windows-native toolchains + DIRLINK = $(TOPDIR)/tools/copydir.sh + DIRUNLINK = $(TOPDIR)/tools/unlink.sh + MKDEP = $(TOPDIR)/tools/mkwindeps.sh + ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" + ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}" +else + # Linux/Cygwin-native toolchain + MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT) + ARCHINCLUDES = -I. -isystem $(TOPDIR)/include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx + ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) +endif + +CC = clang +CXX = clang++ +CPP = clang -E +LD = $(CROSSDEV)ld +AR = $(ARCROSSDEV)ar rcs +NM = $(ARCROSSDEV)nm +OBJCOPY = $(CROSSDEV)objcopy +OBJDUMP = $(CROSSDEV)objdump + +ARCHCCVERSION = {shell $(CC) -v 2>&1 | sed -n '/clang version/p' | sed -e 's/.* clang version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g'} +ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fomit-frame-pointer +endif + +ARCHCFLAGS = -fno-builtin -nostdlib -ffreestanding -target arm-none-eabi -march=armv7-m -mcpu=cortex-m4 +ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -nostdlib -ffreestanding -target arm-none-eabi -march=armv7-m -mcpu=cortex-m4 -DCONFIG_WCHAR_BUILTIN +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef +ARCHWARNINGSXX = -Wall -Wshadow -Wundef +ARCHDEFINES = +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +AFLAGS = $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +ASMEXT = .S +OBJEXT = .o +LIBEXT = .a +EXEEXT = + +ifneq ($(CROSSDEV),arm-nuttx-elf-) + LDFLAGS += -nostartfiles -nodefaultlibs +endif +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif + +HOSTCC = clang +HOSTINCLUDES = -I. +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe +HOSTLDFLAGS = diff --git a/configs/nucleo-f4x1re/f401-nsh-clang/defconfig b/configs/nucleo-f4x1re/f401-nsh-clang/defconfig new file mode 100644 index 00000000000..51dbf6f2828 --- /dev/null +++ b/configs/nucleo-f4x1re/f401-nsh-clang/defconfig @@ -0,0 +1,1284 @@ +# +# Automatically generated file; DO NOT EDIT. +# Nuttx/ Configuration +# + +# +# Build Setup +# +# CONFIG_EXPERIMENTAL is not set +# CONFIG_DEFAULT_SMALL is not set +CONFIG_HOST_LINUX=y +# CONFIG_HOST_OSX is not set +# CONFIG_HOST_WINDOWS is not set +# CONFIG_HOST_OTHER is not set + +# +# Build Configuration +# +CONFIG_APPS_DIR="../apps" +CONFIG_BUILD_FLAT=y +# CONFIG_BUILD_2PASS is not set + +# +# Binary Output Formats +# +# CONFIG_RRLOAD_BINARY is not set +# CONFIG_INTELHEX_BINARY is not set +# CONFIG_MOTOROLA_SREC is not set +CONFIG_RAW_BINARY=y +# CONFIG_UBOOT_UIMAGE is not set +# CONFIG_DFU_BINARY is not set + +# +# Customize Header Files +# +# CONFIG_ARCH_STDINT_H is not set +# CONFIG_ARCH_STDBOOL_H is not set +# CONFIG_ARCH_MATH_H is not set +# CONFIG_ARCH_FLOAT_H is not set +# CONFIG_ARCH_STDARG_H is not set +# CONFIG_ARCH_DEBUG_H is not set + +# +# Debug Options +# +CONFIG_DEBUG_ALERT=y +# CONFIG_DEBUG_FEATURES is not set +CONFIG_ARCH_HAVE_STACKCHECK=y +# CONFIG_STACK_COLORATION is not set +CONFIG_ARCH_HAVE_HEAPCHECK=y +# CONFIG_HEAP_COLORATION is not set +CONFIG_DEBUG_SYMBOLS=y +CONFIG_ARCH_HAVE_CUSTOMOPT=y +# CONFIG_DEBUG_NOOPT is not set +# CONFIG_DEBUG_CUSTOMOPT is not set +CONFIG_DEBUG_FULLOPT=y + +# +# System Type +# +CONFIG_ARCH_ARM=y +# CONFIG_ARCH_AVR is not set +# CONFIG_ARCH_HC is not set +# CONFIG_ARCH_MIPS is not set +# CONFIG_ARCH_MISOC is not set +# CONFIG_ARCH_RENESAS is not set +# CONFIG_ARCH_RISCV is not set +# CONFIG_ARCH_SIM is not set +# CONFIG_ARCH_X86 is not set +# CONFIG_ARCH_XTENSA is not set +# CONFIG_ARCH_Z16 is not set +# CONFIG_ARCH_Z80 is not set +CONFIG_ARCH="arm" + +# +# ARM Options +# +# CONFIG_ARCH_CHIP_A1X is not set +# CONFIG_ARCH_CHIP_C5471 is not set +# CONFIG_ARCH_CHIP_DM320 is not set +# CONFIG_ARCH_CHIP_EFM32 is not set +# CONFIG_ARCH_CHIP_IMX1 is not set +# CONFIG_ARCH_CHIP_IMX6 is not set +# CONFIG_ARCH_CHIP_KINETIS is not set +# CONFIG_ARCH_CHIP_KL is not set +# CONFIG_ARCH_CHIP_LM is not set +# CONFIG_ARCH_CHIP_TIVA is not set +# CONFIG_ARCH_CHIP_LPC11XX is not set +# CONFIG_ARCH_CHIP_LPC17XX is not set +# CONFIG_ARCH_CHIP_LPC214X is not set +# CONFIG_ARCH_CHIP_LPC2378 is not set +# CONFIG_ARCH_CHIP_LPC31XX is not set +# CONFIG_ARCH_CHIP_LPC43XX is not set +# CONFIG_ARCH_CHIP_MOXART is not set +# CONFIG_ARCH_CHIP_NUC1XX is not set +# CONFIG_ARCH_CHIP_SAMA5 is not set +# CONFIG_ARCH_CHIP_SAMD is not set +# CONFIG_ARCH_CHIP_SAML is not set +# CONFIG_ARCH_CHIP_SAM34 is not set +# CONFIG_ARCH_CHIP_SAMV7 is not set +CONFIG_ARCH_CHIP_STM32=y +# CONFIG_ARCH_CHIP_STM32F0 is not set +# CONFIG_ARCH_CHIP_STM32F7 is not set +# CONFIG_ARCH_CHIP_STM32L4 is not set +# CONFIG_ARCH_CHIP_STR71X is not set +# CONFIG_ARCH_CHIP_TMS570 is not set +# CONFIG_ARCH_CHIP_XMC4 is not set +# CONFIG_ARCH_ARM7TDMI is not set +# CONFIG_ARCH_ARM926EJS is not set +# CONFIG_ARCH_ARM920T is not set +# CONFIG_ARCH_CORTEXM0 is not set +# CONFIG_ARCH_CORTEXM23 is not set +# CONFIG_ARCH_CORTEXM3 is not set +# CONFIG_ARCH_CORTEXM33 is not set +CONFIG_ARCH_CORTEXM4=y +# CONFIG_ARCH_CORTEXM7 is not set +# CONFIG_ARCH_CORTEXA5 is not set +# CONFIG_ARCH_CORTEXA8 is not set +# CONFIG_ARCH_CORTEXA9 is not set +# CONFIG_ARCH_CORTEXR4 is not set +# CONFIG_ARCH_CORTEXR4F is not set +# CONFIG_ARCH_CORTEXR5 is not set +# CONFIG_ARCH_CORTEXR5F is not set +# CONFIG_ARCH_CORTEXR7 is not set +# CONFIG_ARCH_CORTEXR7F is not set +CONFIG_ARCH_FAMILY="armv7-m" +CONFIG_ARCH_CHIP="stm32" +# CONFIG_ARMV7M_USEBASEPRI is not set +CONFIG_ARCH_HAVE_CMNVECTOR=y +# CONFIG_ARMV7M_CMNVECTOR is not set +# CONFIG_ARMV7M_LAZYFPU is not set +CONFIG_ARCH_HAVE_FPU=y +# CONFIG_ARCH_HAVE_DPFPU is not set +# CONFIG_ARCH_FPU is not set +# CONFIG_ARCH_HAVE_TRUSTZONE is not set +CONFIG_ARM_HAVE_MPU_UNIFIED=y +# CONFIG_ARM_MPU is not set + +# +# ARMV7M Configuration Options +# +# CONFIG_ARMV7M_HAVE_ICACHE is not set +# CONFIG_ARMV7M_HAVE_DCACHE is not set +# CONFIG_ARMV7M_HAVE_ITCM is not set +# CONFIG_ARMV7M_HAVE_DTCM is not set +# CONFIG_ARMV7M_TOOLCHAIN_IARL is not set +# CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT is not set +# CONFIG_ARMV7M_TOOLCHAIN_CODEREDL is not set +# CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL is not set +CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y +CONFIG_ARMV7M_HAVE_STACKCHECK=y +# CONFIG_ARMV7M_STACKCHECK is not set +# CONFIG_ARMV7M_ITMSYSLOG is not set +# CONFIG_SERIAL_TERMIOS is not set + +# +# STM32 Configuration Options +# +# CONFIG_ARCH_CHIP_STM32L151C6 is not set +# CONFIG_ARCH_CHIP_STM32L151C8 is not set +# CONFIG_ARCH_CHIP_STM32L151CB is not set +# CONFIG_ARCH_CHIP_STM32L151R6 is not set +# CONFIG_ARCH_CHIP_STM32L151R8 is not set +# CONFIG_ARCH_CHIP_STM32L151RB is not set +# CONFIG_ARCH_CHIP_STM32L151V6 is not set +# CONFIG_ARCH_CHIP_STM32L151V8 is not set +# CONFIG_ARCH_CHIP_STM32L151VB is not set +# CONFIG_ARCH_CHIP_STM32L152C6 is not set +# CONFIG_ARCH_CHIP_STM32L152C8 is not set +# CONFIG_ARCH_CHIP_STM32L152CB is not set +# CONFIG_ARCH_CHIP_STM32L152R6 is not set +# CONFIG_ARCH_CHIP_STM32L152R8 is not set +# CONFIG_ARCH_CHIP_STM32L152RB is not set +# CONFIG_ARCH_CHIP_STM32L152V6 is not set +# CONFIG_ARCH_CHIP_STM32L152V8 is not set +# CONFIG_ARCH_CHIP_STM32L152VB is not set +# CONFIG_ARCH_CHIP_STM32L152CC is not set +# CONFIG_ARCH_CHIP_STM32L152RC is not set +# CONFIG_ARCH_CHIP_STM32L152VC is not set +# CONFIG_ARCH_CHIP_STM32L162ZD is not set +# CONFIG_ARCH_CHIP_STM32L162VE is not set +# CONFIG_ARCH_CHIP_STM32F100C8 is not set +# CONFIG_ARCH_CHIP_STM32F100CB is not set +# CONFIG_ARCH_CHIP_STM32F100R8 is not set +# CONFIG_ARCH_CHIP_STM32F100RB is not set +# CONFIG_ARCH_CHIP_STM32F100RC is not set +# CONFIG_ARCH_CHIP_STM32F100RD is not set +# CONFIG_ARCH_CHIP_STM32F100RE is not set +# CONFIG_ARCH_CHIP_STM32F100V8 is not set +# CONFIG_ARCH_CHIP_STM32F100VB is not set +# CONFIG_ARCH_CHIP_STM32F100VC is not set +# CONFIG_ARCH_CHIP_STM32F100VD is not set +# CONFIG_ARCH_CHIP_STM32F100VE is not set +# CONFIG_ARCH_CHIP_STM32F102CB is not set +# CONFIG_ARCH_CHIP_STM32F103T8 is not set +# CONFIG_ARCH_CHIP_STM32F103TB is not set +# CONFIG_ARCH_CHIP_STM32F103C4 is not set +# CONFIG_ARCH_CHIP_STM32F103C8 is not set +# CONFIG_ARCH_CHIP_STM32F103CB is not set +# CONFIG_ARCH_CHIP_STM32F103R8 is not set +# CONFIG_ARCH_CHIP_STM32F103RB is not set +# CONFIG_ARCH_CHIP_STM32F103RC is not set +# CONFIG_ARCH_CHIP_STM32F103RD is not set +# CONFIG_ARCH_CHIP_STM32F103RE is not set +# CONFIG_ARCH_CHIP_STM32F103RG is not set +# CONFIG_ARCH_CHIP_STM32F103V8 is not set +# CONFIG_ARCH_CHIP_STM32F103VB is not set +# CONFIG_ARCH_CHIP_STM32F103VC is not set +# CONFIG_ARCH_CHIP_STM32F103VE is not set +# CONFIG_ARCH_CHIP_STM32F103ZE is not set +# CONFIG_ARCH_CHIP_STM32F105VB is not set +# CONFIG_ARCH_CHIP_STM32F105RB is not set +# CONFIG_ARCH_CHIP_STM32F107VC is not set +# CONFIG_ARCH_CHIP_STM32F205RG is not set +# CONFIG_ARCH_CHIP_STM32F207IG is not set +# CONFIG_ARCH_CHIP_STM32F207ZE is not set +# CONFIG_ARCH_CHIP_STM32F302K6 is not set +# CONFIG_ARCH_CHIP_STM32F302K8 is not set +# CONFIG_ARCH_CHIP_STM32F302CB is not set +# CONFIG_ARCH_CHIP_STM32F302CC is not set +# CONFIG_ARCH_CHIP_STM32F302RB is not set +# CONFIG_ARCH_CHIP_STM32F302RC is not set +# CONFIG_ARCH_CHIP_STM32F302VB is not set +# CONFIG_ARCH_CHIP_STM32F302VC is not set +# CONFIG_ARCH_CHIP_STM32F303K6 is not set +# CONFIG_ARCH_CHIP_STM32F303K8 is not set +# CONFIG_ARCH_CHIP_STM32F303C6 is not set +# CONFIG_ARCH_CHIP_STM32F303C8 is not set +# CONFIG_ARCH_CHIP_STM32F303CB is not set +# CONFIG_ARCH_CHIP_STM32F303CC is not set +# CONFIG_ARCH_CHIP_STM32F303RB is not set +# CONFIG_ARCH_CHIP_STM32F303RC is not set +# CONFIG_ARCH_CHIP_STM32F303RD is not set +# CONFIG_ARCH_CHIP_STM32F303RE is not set +# CONFIG_ARCH_CHIP_STM32F303VB is not set +# CONFIG_ARCH_CHIP_STM32F303VC is not set +# CONFIG_ARCH_CHIP_STM32F334K4 is not set +# CONFIG_ARCH_CHIP_STM32F334K6 is not set +# CONFIG_ARCH_CHIP_STM32F334K8 is not set +# CONFIG_ARCH_CHIP_STM32F334C4 is not set +# CONFIG_ARCH_CHIP_STM32F334C6 is not set +# CONFIG_ARCH_CHIP_STM32F334C8 is not set +# CONFIG_ARCH_CHIP_STM32F334R4 is not set +# CONFIG_ARCH_CHIP_STM32F334R6 is not set +# CONFIG_ARCH_CHIP_STM32F334R8 is not set +# CONFIG_ARCH_CHIP_STM32F372C8 is not set +# CONFIG_ARCH_CHIP_STM32F372R8 is not set +# CONFIG_ARCH_CHIP_STM32F372V8 is not set +# CONFIG_ARCH_CHIP_STM32F372CB is not set +# CONFIG_ARCH_CHIP_STM32F372RB is not set +# CONFIG_ARCH_CHIP_STM32F372VB is not set +# CONFIG_ARCH_CHIP_STM32F372CC is not set +# CONFIG_ARCH_CHIP_STM32F372RC is not set +# CONFIG_ARCH_CHIP_STM32F372VC is not set +# CONFIG_ARCH_CHIP_STM32F373C8 is not set +# CONFIG_ARCH_CHIP_STM32F373R8 is not set +# CONFIG_ARCH_CHIP_STM32F373V8 is not set +# CONFIG_ARCH_CHIP_STM32F373CB is not set +# CONFIG_ARCH_CHIP_STM32F373RB is not set +# CONFIG_ARCH_CHIP_STM32F373VB is not set +# CONFIG_ARCH_CHIP_STM32F373CC is not set +# CONFIG_ARCH_CHIP_STM32F373RC is not set +# CONFIG_ARCH_CHIP_STM32F373VC is not set +CONFIG_ARCH_CHIP_STM32F401RE=y +# CONFIG_ARCH_CHIP_STM32F410RB is not set +# CONFIG_ARCH_CHIP_STM32F411RE is not set +# CONFIG_ARCH_CHIP_STM32F411VE is not set +# CONFIG_ARCH_CHIP_STM32F405RG is not set +# CONFIG_ARCH_CHIP_STM32F405VG is not set +# CONFIG_ARCH_CHIP_STM32F405ZG is not set +# CONFIG_ARCH_CHIP_STM32F407VE is not set +# CONFIG_ARCH_CHIP_STM32F407VG is not set +# CONFIG_ARCH_CHIP_STM32F407ZE is not set +# CONFIG_ARCH_CHIP_STM32F407ZG is not set +# CONFIG_ARCH_CHIP_STM32F407IE is not set +# CONFIG_ARCH_CHIP_STM32F407IG is not set +# CONFIG_ARCH_CHIP_STM32F427V is not set +# CONFIG_ARCH_CHIP_STM32F427Z is not set +# CONFIG_ARCH_CHIP_STM32F427I is not set +# CONFIG_ARCH_CHIP_STM32F429V is not set +# CONFIG_ARCH_CHIP_STM32F429Z is not set +# CONFIG_ARCH_CHIP_STM32F429I is not set +# CONFIG_ARCH_CHIP_STM32F429B is not set +# CONFIG_ARCH_CHIP_STM32F429N is not set +# CONFIG_ARCH_CHIP_STM32F446M is not set +# CONFIG_ARCH_CHIP_STM32F446R is not set +# CONFIG_ARCH_CHIP_STM32F446V is not set +# CONFIG_ARCH_CHIP_STM32F446Z is not set +# CONFIG_ARCH_CHIP_STM32F469A is not set +# CONFIG_ARCH_CHIP_STM32F469I is not set +# CONFIG_ARCH_CHIP_STM32F469B is not set +# CONFIG_ARCH_CHIP_STM32F469N is not set +CONFIG_STM32_FLASH_CONFIG_DEFAULT=y +# CONFIG_STM32_FLASH_CONFIG_4 is not set +# CONFIG_STM32_FLASH_CONFIG_6 is not set +# CONFIG_STM32_FLASH_CONFIG_8 is not set +# CONFIG_STM32_FLASH_CONFIG_B is not set +# CONFIG_STM32_FLASH_CONFIG_C is not set +# CONFIG_STM32_FLASH_CONFIG_D is not set +# CONFIG_STM32_FLASH_CONFIG_E is not set +# CONFIG_STM32_FLASH_CONFIG_F is not set +# CONFIG_STM32_FLASH_CONFIG_G is not set +# CONFIG_STM32_FLASH_CONFIG_I is not set +# CONFIG_STM32_STM32L15XX is not set +# CONFIG_STM32_ENERGYLITE is not set +# CONFIG_STM32_STM32F10XX is not set +# CONFIG_STM32_VALUELINE is not set +# CONFIG_STM32_CONNECTIVITYLINE is not set +# CONFIG_STM32_PERFORMANCELINE is not set +# CONFIG_STM32_USBACCESSLINE is not set +# CONFIG_STM32_HIGHDENSITY is not set +# CONFIG_STM32_MEDIUMDENSITY is not set +# CONFIG_STM32_LOWDENSITY is not set +# CONFIG_STM32_STM32F20XX is not set +# CONFIG_STM32_STM32F205 is not set +# CONFIG_STM32_STM32F207 is not set +# CONFIG_STM32_STM32F30XX is not set +# CONFIG_STM32_STM32F302 is not set +# CONFIG_STM32_STM32F303 is not set +# CONFIG_STM32_STM32F33XX is not set +# CONFIG_STM32_STM32F37XX is not set +CONFIG_STM32_STM32F40XX=y +CONFIG_STM32_STM32F401=y +# CONFIG_STM32_STM32F410 is not set +# CONFIG_STM32_STM32F411 is not set +# CONFIG_STM32_STM32F405 is not set +# CONFIG_STM32_STM32F407 is not set +# CONFIG_STM32_STM32F427 is not set +# CONFIG_STM32_STM32F429 is not set +# CONFIG_STM32_STM32F446 is not set +# CONFIG_STM32_STM32F469 is not set +# CONFIG_STM32_DFU is not set + +# +# STM32 Peripheral Support +# +# CONFIG_STM32_HAVE_CCM is not set +# CONFIG_STM32_HAVE_USBDEV is not set +CONFIG_STM32_HAVE_OTGFS=y +# CONFIG_STM32_HAVE_FSMC is not set +# CONFIG_STM32_HAVE_HRTIM1 is not set +# CONFIG_STM32_HAVE_LTDC is not set +# CONFIG_STM32_HAVE_USART3 is not set +# CONFIG_STM32_HAVE_UART4 is not set +# CONFIG_STM32_HAVE_UART5 is not set +CONFIG_STM32_HAVE_USART6=y +# CONFIG_STM32_HAVE_UART7 is not set +# CONFIG_STM32_HAVE_UART8 is not set +CONFIG_STM32_HAVE_TIM1=y +# CONFIG_STM32_HAVE_TIM2 is not set +CONFIG_STM32_HAVE_TIM3=y +CONFIG_STM32_HAVE_TIM4=y +CONFIG_STM32_HAVE_TIM5=y +# CONFIG_STM32_HAVE_TIM6 is not set +# CONFIG_STM32_HAVE_TIM7 is not set +# CONFIG_STM32_HAVE_TIM8 is not set +CONFIG_STM32_HAVE_TIM9=y +CONFIG_STM32_HAVE_TIM10=y +CONFIG_STM32_HAVE_TIM11=y +# CONFIG_STM32_HAVE_TIM12 is not set +# CONFIG_STM32_HAVE_TIM13 is not set +# CONFIG_STM32_HAVE_TIM14 is not set +# CONFIG_STM32_HAVE_TIM15 is not set +# CONFIG_STM32_HAVE_TIM16 is not set +# CONFIG_STM32_HAVE_TIM17 is not set +# CONFIG_STM32_HAVE_ADC2 is not set +# CONFIG_STM32_HAVE_ADC3 is not set +# CONFIG_STM32_HAVE_ADC4 is not set +# CONFIG_STM32_HAVE_ADC1_DMA is not set +# CONFIG_STM32_HAVE_ADC2_DMA is not set +# CONFIG_STM32_HAVE_ADC3_DMA is not set +# CONFIG_STM32_HAVE_ADC4_DMA is not set +# CONFIG_STM32_HAVE_SDADC1 is not set +# CONFIG_STM32_HAVE_SDADC2 is not set +# CONFIG_STM32_HAVE_SDADC3 is not set +# CONFIG_STM32_HAVE_SDADC1_DMA is not set +# CONFIG_STM32_HAVE_SDADC2_DMA is not set +# CONFIG_STM32_HAVE_SDADC3_DMA is not set +# CONFIG_STM32_HAVE_CAN1 is not set +# CONFIG_STM32_HAVE_CAN2 is not set +# CONFIG_STM32_HAVE_COMP1 is not set +# CONFIG_STM32_HAVE_COMP2 is not set +# CONFIG_STM32_HAVE_COMP3 is not set +# CONFIG_STM32_HAVE_COMP4 is not set +# CONFIG_STM32_HAVE_COMP5 is not set +# CONFIG_STM32_HAVE_COMP6 is not set +# CONFIG_STM32_HAVE_COMP7 is not set +# CONFIG_STM32_HAVE_DAC1 is not set +# CONFIG_STM32_HAVE_DAC2 is not set +# CONFIG_STM32_HAVE_RNG is not set +# CONFIG_STM32_HAVE_ETHMAC is not set +CONFIG_STM32_HAVE_I2C2=y +CONFIG_STM32_HAVE_I2C3=y +CONFIG_STM32_HAVE_SPI2=y +CONFIG_STM32_HAVE_SPI3=y +CONFIG_STM32_HAVE_I2S3=y +# CONFIG_STM32_HAVE_SPI4 is not set +# CONFIG_STM32_HAVE_SPI5 is not set +# CONFIG_STM32_HAVE_SPI6 is not set +# CONFIG_STM32_HAVE_SAIPLL is not set +# CONFIG_STM32_HAVE_I2SPLL is not set +# CONFIG_STM32_HAVE_OPAMP1 is not set +# CONFIG_STM32_HAVE_OPAMP2 is not set +# CONFIG_STM32_HAVE_OPAMP3 is not set +# CONFIG_STM32_HAVE_OPAMP4 is not set +# CONFIG_STM32_ADC1 is not set +# CONFIG_STM32_BKPSRAM is not set +# CONFIG_STM32_CCMDATARAM is not set +# CONFIG_STM32_CRC is not set +# CONFIG_STM32_CRYP is not set +# CONFIG_STM32_DMA1 is not set +# CONFIG_STM32_DMA2 is not set +# CONFIG_STM32_DCMI is not set +# CONFIG_STM32_HASH is not set +# CONFIG_STM32_I2C1 is not set +# CONFIG_STM32_I2C2 is not set +# CONFIG_STM32_I2C3 is not set +# CONFIG_STM32_OPAMP is not set +CONFIG_STM32_OTGFS=y +# CONFIG_STM32_OTGHS is not set +CONFIG_STM32_PWR=y +# CONFIG_STM32_SDIO is not set +# CONFIG_STM32_SPI1 is not set +# CONFIG_STM32_SPI2 is not set +# CONFIG_STM32_SPI3 is not set +# CONFIG_STM32_I2S3 is not set +CONFIG_STM32_SYSCFG=y +# CONFIG_STM32_TIM1 is not set +# CONFIG_STM32_TIM2 is not set +# CONFIG_STM32_TIM3 is not set +# CONFIG_STM32_TIM4 is not set +# CONFIG_STM32_TIM5 is not set +# CONFIG_STM32_TIM9 is not set +# CONFIG_STM32_TIM10 is not set +# CONFIG_STM32_TIM11 is not set +# CONFIG_STM32_USART1 is not set +CONFIG_STM32_USART2=y +# CONFIG_STM32_USART6 is not set +# CONFIG_STM32_IWDG is not set +# CONFIG_STM32_WWDG is not set +# CONFIG_STM32_NOEXT_VECTORS is not set + +# +# Alternate Pin Mapping +# +# CONFIG_STM32_FLASH_PREFETCH is not set +# CONFIG_STM32_FLASH_WORKAROUND_DATA_CACHE_CORRUPTION_ON_RWW is not set +# CONFIG_STM32_JTAG_DISABLE is not set +# CONFIG_STM32_JTAG_FULL_ENABLE is not set +# CONFIG_STM32_JTAG_NOJNTRST_ENABLE is not set +CONFIG_STM32_JTAG_SW_ENABLE=y +CONFIG_STM32_DISABLE_IDLE_SLEEP_DURING_DEBUG=y +# CONFIG_STM32_FORCEPOWER is not set +# CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG is not set + +# +# Timer Configuration +# +# CONFIG_STM32_ONESHOT is not set +# CONFIG_STM32_FREERUN is not set +# CONFIG_STM32_TIM1_CAP is not set +# CONFIG_STM32_TIM3_CAP is not set +# CONFIG_STM32_TIM4_CAP is not set +# CONFIG_STM32_TIM5_CAP is not set +# CONFIG_STM32_TIM9_CAP is not set +# CONFIG_STM32_TIM10_CAP is not set +# CONFIG_STM32_TIM11_CAP is not set +CONFIG_STM32_USART=y +CONFIG_STM32_SERIALDRIVER=y + +# +# U[S]ART Configuration +# + +# +# U[S]ART Device Configuration +# +CONFIG_STM32_USART2_SERIALDRIVER=y +# CONFIG_STM32_USART2_1WIREDRIVER is not set +# CONFIG_USART2_RS485 is not set + +# +# Serial Driver Configuration +# +# CONFIG_SERIAL_DISABLE_REORDERING is not set +# CONFIG_STM32_FLOWCONTROL_BROKEN is not set +# CONFIG_STM32_USART_BREAKS is not set +# CONFIG_STM32_USART_SINGLEWIRE is not set +# CONFIG_STM32_HAVE_RTC_COUNTER is not set +# CONFIG_STM32_HAVE_RTC_SUBSECONDS is not set + +# +# USB FS Host Configuration +# + +# +# USB HS Host Configuration +# + +# +# USB Host Debug Configuration +# + +# +# USB Device Configuration +# +# CONFIG_ARCH_TOOLCHAIN_IAR is not set +CONFIG_ARCH_TOOLCHAIN_GNU=y + +# +# Architecture Options +# +# CONFIG_ARCH_NOINTC is not set +# CONFIG_ARCH_VECNOTIRQ is not set +# CONFIG_ARCH_DMA is not set +CONFIG_ARCH_HAVE_IRQPRIO=y +# CONFIG_ARCH_L2CACHE is not set +# CONFIG_ARCH_HAVE_COHERENT_DCACHE is not set +# CONFIG_ARCH_HAVE_ADDRENV is not set +# CONFIG_ARCH_NEED_ADDRENV_MAPPING is not set +# CONFIG_ARCH_HAVE_MULTICPU is not set +CONFIG_ARCH_HAVE_VFORK=y +# CONFIG_ARCH_HAVE_MMU is not set +CONFIG_ARCH_HAVE_MPU=y +# CONFIG_ARCH_NAND_HWECC is not set +# CONFIG_ARCH_HAVE_EXTCLK is not set +# CONFIG_ARCH_HAVE_POWEROFF is not set +CONFIG_ARCH_HAVE_RESET=y +# CONFIG_ARCH_HAVE_RTC_SUBSECONDS is not set +# CONFIG_ARCH_USE_MPU is not set +# CONFIG_ARCH_IRQPRIO is not set +CONFIG_ARCH_STACKDUMP=y +# CONFIG_ENDIAN_BIG is not set +# CONFIG_ARCH_IDLE_CUSTOM is not set +# CONFIG_ARCH_HAVE_RAMFUNCS is not set +CONFIG_ARCH_HAVE_RAMVECTORS=y +# CONFIG_ARCH_RAMVECTORS is not set +# CONFIG_ARCH_MINIMAL_VECTORTABLE is not set + +# +# Board Settings +# +CONFIG_BOARD_LOOPSPERMSEC=8499 +# CONFIG_ARCH_CALIBRATION is not set + +# +# Interrupt options +# +CONFIG_ARCH_HAVE_INTERRUPTSTACK=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_HAVE_HIPRI_INTERRUPT=y +# CONFIG_ARCH_HIPRI_INTERRUPT is not set + +# +# Boot options +# +# CONFIG_BOOT_RUNFROMEXTSRAM is not set +CONFIG_BOOT_RUNFROMFLASH=y +# CONFIG_BOOT_RUNFROMISRAM is not set +# CONFIG_BOOT_RUNFROMSDRAM is not set +# CONFIG_BOOT_COPYTORAM is not set + +# +# Boot Memory Configuration +# +CONFIG_RAM_START=0x20000000 +CONFIG_RAM_SIZE=98304 +# CONFIG_ARCH_HAVE_SDRAM is not set + +# +# Board Selection +# +CONFIG_ARCH_BOARD_NUCLEO_F401RE=y +# CONFIG_ARCH_BOARD_CUSTOM is not set +CONFIG_ARCH_BOARD="nucleo-f4x1re" + +# +# Common Board Options +# +CONFIG_ARCH_HAVE_LEDS=y +CONFIG_ARCH_LEDS=y +CONFIG_ARCH_HAVE_BUTTONS=y +CONFIG_ARCH_BUTTONS=y +CONFIG_ARCH_HAVE_IRQBUTTONS=y +# CONFIG_ARCH_IRQBUTTONS is not set + +# +# Board-Specific Options +# +# CONFIG_BOARD_CRASHDUMP is not set +# CONFIG_LIB_BOARDCTL is not set + +# +# RTOS Features +# +CONFIG_DISABLE_OS_API=y +# CONFIG_DISABLE_POSIX_TIMERS is not set +# CONFIG_DISABLE_PTHREAD is not set +# CONFIG_DISABLE_SIGNALS is not set +# CONFIG_DISABLE_MQUEUE is not set +# CONFIG_DISABLE_ENVIRON is not set + +# +# Clocks and Timers +# +CONFIG_ARCH_HAVE_TICKLESS=y +# CONFIG_SCHED_TICKLESS is not set +CONFIG_USEC_PER_TICK=10000 +# CONFIG_SYSTEM_TIME64 is not set +# CONFIG_CLOCK_MONOTONIC is not set +CONFIG_ARCH_HAVE_TIMEKEEPING=y +# CONFIG_JULIAN_TIME is not set +CONFIG_START_YEAR=2014 +CONFIG_START_MONTH=5 +CONFIG_START_DAY=5 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_PREALLOC_WDOGS=8 +CONFIG_WDOG_INTRESERVE=1 +CONFIG_PREALLOC_TIMERS=4 + +# +# Tasks and Scheduling +# +# CONFIG_SPINLOCK is not set +# CONFIG_INIT_NONE is not set +CONFIG_INIT_ENTRYPOINT=y +# CONFIG_INIT_FILEPATH is not set +CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_RR_INTERVAL=200 +# CONFIG_SCHED_SPORADIC is not set +CONFIG_TASK_NAME_SIZE=0 +CONFIG_MAX_TASKS=16 +# CONFIG_SCHED_HAVE_PARENT is not set +CONFIG_SCHED_WAITPID=y + +# +# Pthread Options +# +# CONFIG_PTHREAD_MUTEX_TYPES is not set +CONFIG_PTHREAD_MUTEX_ROBUST=y +# CONFIG_PTHREAD_MUTEX_UNSAFE is not set +# CONFIG_PTHREAD_MUTEX_BOTH is not set +CONFIG_NPTHREAD_KEYS=4 +# CONFIG_PTHREAD_CLEANUP is not set +# CONFIG_CANCELLATION_POINTS is not set + +# +# Performance Monitoring +# +# CONFIG_SCHED_CPULOAD is not set +# CONFIG_SCHED_INSTRUMENTATION is not set + +# +# Files and I/O +# +CONFIG_DEV_CONSOLE=y +# CONFIG_FDCLONE_DISABLE is not set +# CONFIG_FDCLONE_STDIO is not set +CONFIG_SDCLONE_DISABLE=y +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NAME_MAX=32 +# CONFIG_PRIORITY_INHERITANCE is not set + +# +# RTOS hooks +# +# CONFIG_BOARD_INITIALIZE is not set +# CONFIG_SCHED_STARTHOOK is not set +# CONFIG_SCHED_ATEXIT is not set +# CONFIG_SCHED_ONEXIT is not set + +# +# Signal Numbers +# +CONFIG_SIG_SIGUSR1=1 +CONFIG_SIG_SIGUSR2=2 +CONFIG_SIG_SIGALARM=3 +CONFIG_SIG_SIGCONDTIMEDOUT=16 + +# +# POSIX Message Queue Options +# +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_MQ_MAXMSGSIZE=32 +# CONFIG_MODULE is not set + +# +# Work queue support +# +# CONFIG_SCHED_WORKQUEUE is not set +# CONFIG_SCHED_HPWORK is not set +# CONFIG_SCHED_LPWORK is not set + +# +# Stack and heap information +# +CONFIG_IDLETHREAD_STACKSIZE=1024 +CONFIG_USERMAIN_STACKSIZE=2048 +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_PTHREAD_STACK_DEFAULT=2048 +# CONFIG_LIB_SYSCALL is not set + +# +# Device Drivers +# +CONFIG_DISABLE_POLL=y +CONFIG_DEV_NULL=y +# CONFIG_DEV_ZERO is not set +# CONFIG_DEV_URANDOM is not set +# CONFIG_DEV_LOOP is not set + +# +# Buffering +# +# CONFIG_DRVR_WRITEBUFFER is not set +# CONFIG_DRVR_READAHEAD is not set +# CONFIG_RAMDISK is not set +# CONFIG_CAN is not set +# CONFIG_ARCH_HAVE_PWM_PULSECOUNT is not set +# CONFIG_ARCH_HAVE_PWM_MULTICHAN is not set +# CONFIG_PWM is not set +CONFIG_ARCH_HAVE_I2CRESET=y +# CONFIG_I2C is not set +# CONFIG_ARCH_HAVE_SPI_CRCGENERATION is not set +# CONFIG_ARCH_HAVE_SPI_CS_CONTROL is not set +CONFIG_ARCH_HAVE_SPI_BITORDER=y +CONFIG_SPI=y +# CONFIG_SPI_SLAVE is not set +CONFIG_SPI_EXCHANGE=y +# CONFIG_SPI_CMDDATA is not set +# CONFIG_SPI_CALLBACK is not set +# CONFIG_SPI_HWFEATURES is not set +# CONFIG_SPI_BITORDER is not set +# CONFIG_SPI_CS_DELAY_CONTROL is not set +# CONFIG_SPI_DRIVER is not set +# CONFIG_SPI_BITBANG is not set +# CONFIG_I2S is not set + +# +# Timer Driver Support +# +# CONFIG_TIMER is not set +# CONFIG_ONESHOT is not set +# CONFIG_RTC is not set +# CONFIG_WATCHDOG is not set +# CONFIG_ANALOG is not set +# CONFIG_AUDIO_DEVICES is not set +# CONFIG_VIDEO_DEVICES is not set +# CONFIG_BCH is not set +# CONFIG_INPUT is not set + +# +# IO Expander/GPIO Support +# +# CONFIG_IOEXPANDER is not set +# CONFIG_DEV_GPIO is not set + +# +# LCD Driver Support +# +# CONFIG_LCD is not set +# CONFIG_SLCD is not set + +# +# LED Support +# +# CONFIG_USERLED is not set +# CONFIG_RGBLED is not set +# CONFIG_PCA9635PW is not set +# CONFIG_NCP5623C is not set +# CONFIG_MMCSD is not set +# CONFIG_MODEM is not set +# CONFIG_MTD is not set +# CONFIG_EEPROM is not set +# CONFIG_PIPES is not set +# CONFIG_PM is not set +# CONFIG_POWER is not set +# CONFIG_SENSORS is not set +CONFIG_SERIAL=y +# CONFIG_DEV_LOWCONSOLE is not set +# CONFIG_SERIAL_REMOVABLE is not set +CONFIG_SERIAL_CONSOLE=y +# CONFIG_16550_UART is not set +# CONFIG_UART_SERIALDRIVER is not set +# CONFIG_UART0_SERIALDRIVER is not set +# CONFIG_UART1_SERIALDRIVER is not set +# CONFIG_UART2_SERIALDRIVER is not set +# CONFIG_UART3_SERIALDRIVER is not set +# CONFIG_UART4_SERIALDRIVER is not set +# CONFIG_UART5_SERIALDRIVER is not set +# CONFIG_UART6_SERIALDRIVER is not set +# CONFIG_UART7_SERIALDRIVER is not set +# CONFIG_UART8_SERIALDRIVER is not set +# CONFIG_SCI0_SERIALDRIVER is not set +# CONFIG_SCI1_SERIALDRIVER is not set +# CONFIG_USART0_SERIALDRIVER is not set +# CONFIG_USART1_SERIALDRIVER is not set +CONFIG_USART2_SERIALDRIVER=y +# CONFIG_USART3_SERIALDRIVER is not set +# CONFIG_USART4_SERIALDRIVER is not set +# CONFIG_USART5_SERIALDRIVER is not set +# CONFIG_USART6_SERIALDRIVER is not set +# CONFIG_USART7_SERIALDRIVER is not set +# CONFIG_USART8_SERIALDRIVER is not set +# CONFIG_OTHER_UART_SERIALDRIVER is not set +CONFIG_MCU_SERIAL=y +CONFIG_STANDARD_SERIAL=y +# CONFIG_SERIAL_IFLOWCONTROL is not set +# CONFIG_SERIAL_OFLOWCONTROL is not set +# CONFIG_SERIAL_DMA is not set +CONFIG_ARCH_HAVE_SERIAL_TERMIOS=y +CONFIG_USART2_SERIAL_CONSOLE=y +# CONFIG_OTHER_SERIAL_CONSOLE is not set +# CONFIG_NO_SERIAL_CONSOLE is not set + +# +# USART2 Configuration +# +CONFIG_USART2_RXBUFSIZE=256 +CONFIG_USART2_TXBUFSIZE=256 +CONFIG_USART2_BAUD=115200 +CONFIG_USART2_BITS=8 +CONFIG_USART2_PARITY=0 +CONFIG_USART2_2STOP=0 +# CONFIG_USART2_IFLOWCONTROL is not set +# CONFIG_USART2_OFLOWCONTROL is not set +# CONFIG_USART2_DMA is not set +# CONFIG_PSEUDOTERM is not set +# CONFIG_USBDEV is not set +# CONFIG_USBHOST is not set +# CONFIG_USBMISC is not set +# CONFIG_HAVE_USBTRACE is not set +# CONFIG_DRIVERS_WIRELESS is not set +# CONFIG_DRIVERS_CONTACTLESS is not set + +# +# System Logging +# +# CONFIG_ARCH_SYSLOG is not set +CONFIG_SYSLOG_WRITE=y +# CONFIG_RAMLOG is not set +# CONFIG_SYSLOG_BUFFER is not set +# CONFIG_SYSLOG_INTBUFFER is not set +# CONFIG_SYSLOG_TIMESTAMP is not set +CONFIG_SYSLOG_SERIAL_CONSOLE=y +# CONFIG_SYSLOG_CHAR is not set +CONFIG_SYSLOG_CONSOLE=y +# CONFIG_SYSLOG_NONE is not set +# CONFIG_SYSLOG_FILE is not set +# CONFIG_SYSLOG_CHARDEV is not set + +# +# Networking Support +# +# CONFIG_ARCH_HAVE_NET is not set +# CONFIG_ARCH_HAVE_PHY is not set +# CONFIG_NET is not set + +# +# Crypto API +# +# CONFIG_CRYPTO is not set + +# +# File Systems +# + +# +# File system configuration +# +# CONFIG_DISABLE_MOUNTPOINT is not set +# CONFIG_FS_AUTOMOUNTER is not set +# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set +# CONFIG_PSEUDOFS_SOFTLINKS is not set +# CONFIG_FS_READABLE is not set +# CONFIG_FS_WRITABLE is not set +# CONFIG_FS_NAMED_SEMAPHORES is not set +CONFIG_FS_MQUEUE_MPATH="/var/mqueue" +# CONFIG_FS_RAMMAP is not set +# CONFIG_FS_FAT is not set +# CONFIG_FS_NXFFS is not set +# CONFIG_FS_ROMFS is not set +# CONFIG_FS_TMPFS is not set +# CONFIG_FS_SMARTFS is not set +# CONFIG_FS_BINFS is not set +# CONFIG_FS_PROCFS is not set +# CONFIG_FS_UNIONFS is not set + +# +# Graphics Support +# +# CONFIG_NX is not set + +# +# Memory Management +# +# CONFIG_MM_SMALL is not set +CONFIG_MM_REGIONS=1 +# CONFIG_ARCH_HAVE_HEAP2 is not set +# CONFIG_GRAN is not set + +# +# Common I/O Buffer Support +# +# CONFIG_MM_IOB is not set + +# +# Audio Support +# +# CONFIG_AUDIO is not set + +# +# Wireless Support +# +# CONFIG_WIRELESS is not set + +# +# Binary Loader +# +# CONFIG_BINFMT_DISABLE is not set +# CONFIG_BINFMT_EXEPATH is not set +# CONFIG_NXFLAT is not set +# CONFIG_ELF is not set +CONFIG_BUILTIN=y +# CONFIG_PIC is not set +# CONFIG_SYMTAB_ORDEREDBYNAME is not set + +# +# Library Routines +# + +# +# Standard C Library Options +# + +# +# Standard C I/O +# +# CONFIG_STDIO_DISABLE_BUFFERING is not set +CONFIG_STDIO_BUFFER_SIZE=64 +CONFIG_STDIO_LINEBUFFER=y +CONFIG_NUNGET_CHARS=2 +# CONFIG_NOPRINTF_FIELDWIDTH is not set +# CONFIG_LIBC_FLOATINGPOINT is not set +CONFIG_LIBC_LONG_LONG=y +# CONFIG_LIBC_SCANSET is not set +# CONFIG_EOL_IS_CR is not set +# CONFIG_EOL_IS_LF is not set +# CONFIG_EOL_IS_BOTH_CRLF is not set +CONFIG_EOL_IS_EITHER_CRLF=y +# CONFIG_MEMCPY_VIK is not set +# CONFIG_LIBM is not set + +# +# Architecture-Specific Support +# +CONFIG_ARCH_LOWPUTC=y +# CONFIG_ARCH_ROMGETC is not set +# CONFIG_LIBC_ARCH_MEMCPY is not set +# CONFIG_LIBC_ARCH_MEMCMP is not set +# CONFIG_LIBC_ARCH_MEMMOVE is not set +# CONFIG_LIBC_ARCH_MEMSET is not set +# CONFIG_LIBC_ARCH_STRCHR is not set +# CONFIG_LIBC_ARCH_STRCMP is not set +# CONFIG_LIBC_ARCH_STRCPY is not set +# CONFIG_LIBC_ARCH_STRNCPY is not set +# CONFIG_LIBC_ARCH_STRLEN is not set +# CONFIG_LIBC_ARCH_STRNLEN is not set +# CONFIG_LIBC_ARCH_ELF is not set +# CONFIG_ARMV7M_MEMCPY is not set + +# +# stdlib Options +# +CONFIG_LIB_RAND_ORDER=1 +CONFIG_LIB_HOMEDIR="/" + +# +# Program Execution Options +# +# CONFIG_LIBC_EXECFUNCS is not set +CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=1024 +CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=2048 + +# +# errno Decode Support +# +# CONFIG_LIBC_STRERROR is not set +# CONFIG_LIBC_PERROR_STDOUT is not set + +# +# memcpy/memset Options +# +# CONFIG_MEMSET_OPTSPEED is not set +# CONFIG_LIBC_DLLFCN is not set +# CONFIG_LIBC_MODLIB is not set +# CONFIG_LIBC_WCHAR is not set +# CONFIG_LIBC_LOCALE is not set + +# +# Time/Time Zone Support +# +# CONFIG_LIBC_LOCALTIME is not set +# CONFIG_TIME_EXTENDED is not set +CONFIG_ARCH_HAVE_TLS=y + +# +# Thread Local Storage (TLS) +# +# CONFIG_TLS is not set + +# +# Network-Related Options +# +# CONFIG_LIBC_IPv4_ADDRCONV is not set +# CONFIG_LIBC_IPv6_ADDRCONV is not set +# CONFIG_LIBC_NETDB is not set + +# +# NETDB Support +# +# CONFIG_LIBC_IOCTL_VARIADIC is not set +CONFIG_LIB_SENDFILE_BUFSIZE=512 + +# +# Non-standard Library Support +# +# CONFIG_LIB_CRC64_FAST is not set +# CONFIG_LIB_KBDCODEC is not set +# CONFIG_LIB_SLCDCODEC is not set +# CONFIG_LIB_HEX2BIN is not set + +# +# Basic CXX Support +# +# CONFIG_C99_BOOL8 is not set +CONFIG_HAVE_CXX=y +# CONFIG_CXX_NEWLONG is not set + +# +# LLVM C++ Library (libcxx) +# +# CONFIG_LIBCXX is not set + +# +# uClibc++ Standard C++ Library +# +# CONFIG_UCLIBCXX is not set + +# +# Application Configuration +# + +# +# Built-In Applications +# +CONFIG_BUILTIN_PROXY_STACKSIZE=1024 + +# +# CAN Utilities +# + +# +# Examples +# +# CONFIG_EXAMPLES_BUTTONS is not set +# CONFIG_EXAMPLES_CCTYPE is not set +# CONFIG_EXAMPLES_CHAT is not set +# CONFIG_EXAMPLES_CONFIGDATA is not set +# CONFIG_EXAMPLES_CXXTEST is not set +# CONFIG_EXAMPLES_DHCPD is not set +# CONFIG_EXAMPLES_ELF is not set +# CONFIG_EXAMPLES_FTPC is not set +# CONFIG_EXAMPLES_FTPD is not set +# CONFIG_EXAMPLES_HELLO is not set +# CONFIG_EXAMPLES_HELLOXX is not set +# CONFIG_EXAMPLES_HIDKBD is not set +# CONFIG_EXAMPLES_IGMP is not set +# CONFIG_EXAMPLES_JSON is not set +# CONFIG_EXAMPLES_KEYPADTEST is not set +# CONFIG_EXAMPLES_MEDIA is not set +# CONFIG_EXAMPLES_MM is not set +# CONFIG_EXAMPLES_MODBUS is not set +# CONFIG_EXAMPLES_MOUNT is not set +# CONFIG_EXAMPLES_NRF24L01TERM is not set +CONFIG_EXAMPLES_NSH=y +# CONFIG_EXAMPLES_NULL is not set +# CONFIG_EXAMPLES_NX is not set +# CONFIG_EXAMPLES_NXFFS is not set +# CONFIG_EXAMPLES_NXHELLO is not set +# CONFIG_EXAMPLES_NXIMAGE is not set +# CONFIG_EXAMPLES_NXLINES is not set +# CONFIG_EXAMPLES_NXTERM is not set +# CONFIG_EXAMPLES_NXTEXT is not set +# CONFIG_EXAMPLES_OSTEST is not set +# CONFIG_EXAMPLES_PCA9635 is not set +# CONFIG_EXAMPLES_POSIXSPAWN is not set +# CONFIG_EXAMPLES_PPPD is not set +# CONFIG_EXAMPLES_RFID_READUID is not set +# CONFIG_EXAMPLES_RGBLED is not set +# CONFIG_EXAMPLES_SENDMAIL is not set +# CONFIG_EXAMPLES_SERIALBLASTER is not set +# CONFIG_EXAMPLES_SERIALRX is not set +# CONFIG_EXAMPLES_SERLOOP is not set +# CONFIG_EXAMPLES_SLCD is not set +# CONFIG_EXAMPLES_SMART_TEST is not set +# CONFIG_EXAMPLES_SMART is not set +# CONFIG_EXAMPLES_SMP is not set +# CONFIG_EXAMPLES_STAT is not set +# CONFIG_EXAMPLES_TCPECHO is not set +# CONFIG_EXAMPLES_TELNETD is not set +# CONFIG_EXAMPLES_TIFF is not set +# CONFIG_EXAMPLES_TOUCHSCREEN is not set +# CONFIG_EXAMPLES_USBTERM is not set +# CONFIG_EXAMPLES_WATCHDOG is not set +# CONFIG_EXAMPLES_WEBSERVER is not set + +# +# File System Utilities +# +# CONFIG_FSUTILS_INIFILE is not set + +# +# GPS Utilities +# +# CONFIG_GPSUTILS_MINMEA_LIB is not set + +# +# Graphics Support +# +# CONFIG_TIFF is not set +# CONFIG_GRAPHICS_TRAVELER is not set + +# +# Interpreters +# +# CONFIG_INTERPRETERS_FICL is not set +# CONFIG_INTERPRETERS_MICROPYTHON is not set +# CONFIG_INTERPRETERS_MINIBASIC is not set +# CONFIG_INTERPRETERS_PCODE is not set + +# +# FreeModBus +# +# CONFIG_MODBUS is not set + +# +# Network Utilities +# +# CONFIG_NETUTILS_CODECS is not set +# CONFIG_NETUTILS_ESP8266 is not set +# CONFIG_NETUTILS_FTPC is not set +# CONFIG_NETUTILS_JSON is not set +# CONFIG_NETUTILS_SMTP is not set + +# +# NSH Library +# +CONFIG_NSH_LIBRARY=y +# CONFIG_NSH_MOTD is not set + +# +# Command Line Configuration +# +CONFIG_NSH_READLINE=y +# CONFIG_NSH_CLE is not set +CONFIG_NSH_LINELEN=64 +# CONFIG_NSH_DISABLE_SEMICOLON is not set +# CONFIG_NSH_CMDPARMS is not set +CONFIG_NSH_MAXARGUMENTS=6 +# CONFIG_NSH_ARGCAT is not set +CONFIG_NSH_NESTDEPTH=3 +# CONFIG_NSH_DISABLEBG is not set +CONFIG_NSH_BUILTIN_APPS=y + +# +# Disable Individual commands +# +# CONFIG_NSH_DISABLE_ADDROUTE is not set +# CONFIG_NSH_DISABLE_BASENAME is not set +# CONFIG_NSH_DISABLE_CAT is not set +# CONFIG_NSH_DISABLE_CD is not set +# CONFIG_NSH_DISABLE_CP is not set +# CONFIG_NSH_DISABLE_CMP is not set +CONFIG_NSH_DISABLE_DATE=y +# CONFIG_NSH_DISABLE_DD is not set +# CONFIG_NSH_DISABLE_DF is not set +# CONFIG_NSH_DISABLE_DELROUTE is not set +# CONFIG_NSH_DISABLE_DIRNAME is not set +# CONFIG_NSH_DISABLE_ECHO is not set +# CONFIG_NSH_DISABLE_EXEC is not set +# CONFIG_NSH_DISABLE_EXIT is not set +# CONFIG_NSH_DISABLE_FREE is not set +# CONFIG_NSH_DISABLE_GET is not set +# CONFIG_NSH_DISABLE_HELP is not set +# CONFIG_NSH_DISABLE_HEXDUMP is not set +# CONFIG_NSH_DISABLE_IFCONFIG is not set +CONFIG_NSH_DISABLE_IFUPDOWN=y +# CONFIG_NSH_DISABLE_KILL is not set +# CONFIG_NSH_DISABLE_LOSETUP is not set +CONFIG_NSH_DISABLE_LOSMART=y +# CONFIG_NSH_DISABLE_LS is not set +# CONFIG_NSH_DISABLE_MB is not set +# CONFIG_NSH_DISABLE_MKDIR is not set +# CONFIG_NSH_DISABLE_MKRD is not set +# CONFIG_NSH_DISABLE_MH is not set +# CONFIG_NSH_DISABLE_MOUNT is not set +# CONFIG_NSH_DISABLE_MV is not set +# CONFIG_NSH_DISABLE_MW is not set +CONFIG_NSH_DISABLE_PRINTF=y +# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_NSH_DISABLE_PUT is not set +# CONFIG_NSH_DISABLE_PWD is not set +# CONFIG_NSH_DISABLE_RM is not set +# CONFIG_NSH_DISABLE_RMDIR is not set +# CONFIG_NSH_DISABLE_SET is not set +# CONFIG_NSH_DISABLE_SH is not set +# CONFIG_NSH_DISABLE_SLEEP is not set +# CONFIG_NSH_DISABLE_TIME is not set +# CONFIG_NSH_DISABLE_TEST is not set +# CONFIG_NSH_DISABLE_UMOUNT is not set +# CONFIG_NSH_DISABLE_UNAME is not set +# CONFIG_NSH_DISABLE_UNSET is not set +# CONFIG_NSH_DISABLE_USLEEP is not set +# CONFIG_NSH_DISABLE_WGET is not set +# CONFIG_NSH_DISABLE_XD is not set +CONFIG_NSH_MMCSDMINOR=0 + +# +# Configure Command Options +# +# CONFIG_NSH_CMDOPT_DF_H is not set +# CONFIG_NSH_CMDOPT_DD_STATS is not set +CONFIG_NSH_CODECS_BUFSIZE=128 +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_NSH_FILEIOSIZE=512 + +# +# Scripting Support +# +# CONFIG_NSH_DISABLESCRIPT is not set +# CONFIG_NSH_DISABLE_ITEF is not set +# CONFIG_NSH_DISABLE_LOOPS is not set + +# +# Console Configuration +# +CONFIG_NSH_CONSOLE=y +# CONFIG_NSH_ALTCONDEV is not set +# CONFIG_NSH_ARCHINIT is not set +# CONFIG_NSH_LOGIN is not set +# CONFIG_NSH_CONSOLE_LOGIN is not set + +# +# NxWidgets/NxWM +# + +# +# Platform-specific Support +# +# CONFIG_PLATFORM_CONFIGDATA is not set + +# +# System Libraries and NSH Add-Ons +# +# CONFIG_SYSTEM_CLE is not set +# CONFIG_SYSTEM_CUTERM is not set +# CONFIG_SYSTEM_FREE is not set +# CONFIG_SYSTEM_HEX2BIN is not set +# CONFIG_SYSTEM_HEXED is not set +# CONFIG_SYSTEM_INSTALL is not set +# CONFIG_SYSTEM_RAMTEST is not set +CONFIG_READLINE_HAVE_EXTMATCH=y +CONFIG_SYSTEM_READLINE=y +CONFIG_READLINE_ECHO=y +# CONFIG_READLINE_TABCOMPLETION is not set +# CONFIG_READLINE_CMD_HISTORY is not set +# CONFIG_SYSTEM_SUDOKU is not set +# CONFIG_SYSTEM_SYSTEM is not set +# CONFIG_SYSTEM_TEE is not set +# CONFIG_SYSTEM_UBLOXMODEM is not set +# CONFIG_SYSTEM_VI is not set +# CONFIG_SYSTEM_ZMODEM is not set diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h index 15a0f059a9a..fa981e76d55 100644 --- a/include/nuttx/compiler.h +++ b/include/nuttx/compiler.h @@ -250,7 +250,9 @@ /* GCC supports both types double and long long */ +#ifndef __clang__ # define CONFIG_HAVE_LONG_LONG 1 +#endif # define CONFIG_HAVE_FLOAT 1 # define CONFIG_HAVE_DOUBLE 1 # define CONFIG_HAVE_LONG_DOUBLE 1 From cf44fd6ec01b1118c295e184ca438a38ce194c1d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 2 Jul 2017 06:42:48 -0600 Subject: [PATCH 04/33] Add CLANG definitions in Kconfig and Toolchain.defs --- arch/arm/src/armv7-m/Kconfig | 10 ++++++ arch/arm/src/armv7-m/Toolchain.defs | 33 +++++++++++++++++++ .../nucleo-f4x1re/f401-nsh-clang/Make.defs | 2 +- .../nucleo-f4x1re/f401-nsh-clang/defconfig | 24 ++++++++++---- 4 files changed, 62 insertions(+), 7 deletions(-) diff --git a/arch/arm/src/armv7-m/Kconfig b/arch/arm/src/armv7-m/Kconfig index 381725e0060..5908816483a 100644 --- a/arch/arm/src/armv7-m/Kconfig +++ b/arch/arm/src/armv7-m/Kconfig @@ -108,6 +108,16 @@ config ARMV7M_TOOLCHAIN_GNU_EABIW bool "Generic GNU EABI toolchain under Windows" depends on TOOLCHAIN_WINDOWS select ARCH_TOOLCHAIN_GNU + +config ARMV7M_TOOLCHAIN_CLANGL + bool "Generic Clang toolchain under Linux (or other POSIX environment)" + depends on !WINDOWS_NATIVE + select ARCH_TOOLCHAIN_GNU + +config ARMV7M_TOOLCHAIN_CLANGW + bool "Generic Clang toolchain under Windows" + depends on TOOLCHAIN_WINDOWS + select ARCH_TOOLCHAIN_GNU ---help--- This option should work for any modern GNU toolchain (GCC 4.5 or newer) configured for arm-none-eabi. diff --git a/arch/arm/src/armv7-m/Toolchain.defs b/arch/arm/src/armv7-m/Toolchain.defs index 74b1fcdcc3a..9838cdf1bf2 100644 --- a/arch/arm/src/armv7-m/Toolchain.defs +++ b/arch/arm/src/armv7-m/Toolchain.defs @@ -102,6 +102,18 @@ ifeq ($(filter y, \ CONFIG_ARMV7M_TOOLCHAIN ?= GNU_EABIW endif +ifeq ($(filter y, \ + $(CONFIG_ARMV7M_TOOLCHAIN_CLANGL) \ + ),y) + CONFIG_ARMV7M_TOOLCHAIN ?= CLANGL +endif + +ifeq ($(filter y, \ + $(CONFIG_ARMV7M_TOOLCHAIN_CLANGW) \ + ),y) + CONFIG_ARMV7M_TOOLCHAIN ?= CLANGW +endif + # # Supported toolchains # @@ -255,6 +267,27 @@ ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),GNU_EABIW) endif endif +# Clang toolchain on OS X, Linux or any typical Posix system + +ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),CLANGL) + CROSSDEV ?= arm-none-eabi- + ARCROSSDEV ?= arm-none-eabi- + MAXOPTIMIZATION ?= -Os + ARCHCPUFLAGS = $(TOOLCHAIN_MCPU) -mthumb $(TOOLCHAIN_MFLOAT) +endif + +# Clang toolchain under Windows + +ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),CLANGW) + CROSSDEV ?= arm-none-eabi- + ARCROSSDEV ?= arm-none-eabi- + MAXOPTIMIZATION ?= -Os + ARCHCPUFLAGS = $(TOOLCHAIN_MCPU) -mthumb $(TOOLCHAIN_MFLOAT) + ifeq ($(CONFIG_WINDOWS_CYGWIN),y) + WINTOOL = y + endif +endif + # Raisonance RIDE7 under Windows ifeq ($(CONFIG_ARMV7M_TOOLCHAIN),RAISONANCE) diff --git a/configs/nucleo-f4x1re/f401-nsh-clang/Make.defs b/configs/nucleo-f4x1re/f401-nsh-clang/Make.defs index 586784f71c2..2d2e46689b3 100644 --- a/configs/nucleo-f4x1re/f401-nsh-clang/Make.defs +++ b/configs/nucleo-f4x1re/f401-nsh-clang/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # configs/nucleo-f4x1re/f401-nsh-clang/Make.defs # -# Copyright (C) 2014 Gregory Nutt. All rights reserved. +# Copyright (C) 2017 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without diff --git a/configs/nucleo-f4x1re/f401-nsh-clang/defconfig b/configs/nucleo-f4x1re/f401-nsh-clang/defconfig index 51dbf6f2828..1e70d31d46e 100644 --- a/configs/nucleo-f4x1re/f401-nsh-clang/defconfig +++ b/configs/nucleo-f4x1re/f401-nsh-clang/defconfig @@ -16,7 +16,7 @@ CONFIG_HOST_LINUX=y # # Build Configuration # -CONFIG_APPS_DIR="../apps" +# CONFIG_APPS_DIR="../apps" CONFIG_BUILD_FLAT=y # CONFIG_BUILD_2PASS is not set @@ -147,7 +147,8 @@ CONFIG_ARM_HAVE_MPU_UNIFIED=y # CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT is not set # CONFIG_ARMV7M_TOOLCHAIN_CODEREDL is not set # CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL is not set -CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y +# CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL is not set +CONFIG_ARMV7M_TOOLCHAIN_CLANGL=y CONFIG_ARMV7M_HAVE_STACKCHECK=y # CONFIG_ARMV7M_STACKCHECK is not set # CONFIG_ARMV7M_ITMSYSLOG is not set @@ -1083,7 +1084,6 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024 # CONFIG_EXAMPLES_MM is not set # CONFIG_EXAMPLES_MODBUS is not set # CONFIG_EXAMPLES_MOUNT is not set -# CONFIG_EXAMPLES_NRF24L01TERM is not set CONFIG_EXAMPLES_NSH=y # CONFIG_EXAMPLES_NULL is not set # CONFIG_EXAMPLES_NX is not set @@ -1104,17 +1104,16 @@ CONFIG_EXAMPLES_NSH=y # CONFIG_EXAMPLES_SERIALRX is not set # CONFIG_EXAMPLES_SERLOOP is not set # CONFIG_EXAMPLES_SLCD is not set -# CONFIG_EXAMPLES_SMART_TEST is not set # CONFIG_EXAMPLES_SMART is not set +# CONFIG_EXAMPLES_SMART_TEST is not set # CONFIG_EXAMPLES_SMP is not set # CONFIG_EXAMPLES_STAT is not set # CONFIG_EXAMPLES_TCPECHO is not set -# CONFIG_EXAMPLES_TELNETD is not set # CONFIG_EXAMPLES_TIFF is not set # CONFIG_EXAMPLES_TOUCHSCREEN is not set -# CONFIG_EXAMPLES_USBTERM is not set # CONFIG_EXAMPLES_WATCHDOG is not set # CONFIG_EXAMPLES_WEBSERVER is not set +# CONFIG_EXAMPLES_XBC_TEST is not set # # File System Utilities @@ -1219,6 +1218,7 @@ CONFIG_NSH_DISABLE_PRINTF=y # CONFIG_NSH_DISABLE_SLEEP is not set # CONFIG_NSH_DISABLE_TIME is not set # CONFIG_NSH_DISABLE_TEST is not set +# CONFIG_NSH_DISABLE_TELNETD is not set # CONFIG_NSH_DISABLE_UMOUNT is not set # CONFIG_NSH_DISABLE_UNAME is not set # CONFIG_NSH_DISABLE_UNSET is not set @@ -1260,6 +1260,7 @@ CONFIG_NSH_CONSOLE=y # Platform-specific Support # # CONFIG_PLATFORM_CONFIGDATA is not set +# CONFIG_HAVE_CXXINITIALIZE is not set # # System Libraries and NSH Add-Ons @@ -1282,3 +1283,14 @@ CONFIG_READLINE_ECHO=y # CONFIG_SYSTEM_UBLOXMODEM is not set # CONFIG_SYSTEM_VI is not set # CONFIG_SYSTEM_ZMODEM is not set + +# +# Wireless Libraries and NSH Add-Ons +# + +# +# IEEE 802.15.4 applications +# +# CONFIG_IEEE802154_LIBMAC is not set +# CONFIG_IEEE802154_LIBUTILS is not set +# CONFIG_IEEE802154_I8SAK is not set From 8fa5e9772b30b219d6dcfd8e99c525ae8e14ef7a Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 2 Jul 2017 06:51:21 -0600 Subject: [PATCH 05/33] Clang: Should there not be a prefix when using a cross compiler where clang refers to the host clang. --- configs/nucleo-f4x1re/f401-nsh-clang/Make.defs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configs/nucleo-f4x1re/f401-nsh-clang/Make.defs b/configs/nucleo-f4x1re/f401-nsh-clang/Make.defs index 2d2e46689b3..99163814492 100644 --- a/configs/nucleo-f4x1re/f401-nsh-clang/Make.defs +++ b/configs/nucleo-f4x1re/f401-nsh-clang/Make.defs @@ -61,6 +61,9 @@ else ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) endif +#CC = $(CROSSDEV)clang +#CXX = $(CROSSDEV)clang++ +#CPP = $(CROSSDEV)clang -E CC = clang CXX = clang++ CPP = clang -E From 09ab651e02de9e23ecf678791f6149668d74721d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 2 Jul 2017 11:04:57 -0600 Subject: [PATCH 06/33] samv71-xult: Add support for the MRF24J40 radio and create a mrf24j40-starhub configuration. A few fixes to IPv6 and 6LoWPAN were required to have 6LoWPAN and Ethernet coexisting. Untested and expect some complexity in the bring-up. --- arch/arm/src/samv7/sam_lowputc.c | 6 +- configs/clicker2-stm32/src/stm32_mrf24j40.c | 5 +- configs/clicker2-stm32/src/stm32_spi.c | 19 +- configs/samv71-xult/Kconfig | 31 + configs/samv71-xult/README.txt | 99 ++ configs/samv71-xult/include/board.h | 1 - .../samv71-xult/mrf24j40-starhub/Make.defs | 128 ++ .../samv71-xult/mrf24j40-starhub/SAVEconfig | 377 ++++ .../samv71-xult/mrf24j40-starhub/defconfig | 1543 +++++++++++++++++ configs/samv71-xult/src/Makefile | 6 +- configs/samv71-xult/src/sam_autoleds.c | 4 +- configs/samv71-xult/src/sam_buttons.c | 2 +- configs/samv71-xult/src/sam_hsmci.c | 12 +- configs/samv71-xult/src/sam_maxtouch.c | 20 +- configs/samv71-xult/src/sam_mrf24j40.c | 323 ++++ configs/samv71-xult/src/sam_spi.c | 45 +- configs/samv71-xult/src/sam_userleds.c | 2 +- configs/samv71-xult/src/sam_wm8904.c | 18 +- configs/samv71-xult/src/samv71-xult.h | 59 +- include/nuttx/net/icmpv6.h | 15 +- net/devif/ipv6_forward.c | 1 + net/sixlowpan/sixlowpan_input.c | 1 + net/sixlowpan/sixlowpan_tcpsend.c | 1 + net/sixlowpan/sixlowpan_udpsend.c | 1 + 24 files changed, 2659 insertions(+), 60 deletions(-) create mode 100644 configs/samv71-xult/mrf24j40-starhub/Make.defs create mode 100644 configs/samv71-xult/mrf24j40-starhub/SAVEconfig create mode 100644 configs/samv71-xult/mrf24j40-starhub/defconfig create mode 100644 configs/samv71-xult/src/sam_mrf24j40.c diff --git a/arch/arm/src/samv7/sam_lowputc.c b/arch/arm/src/samv7/sam_lowputc.c index fe298f4f23f..c9d4b6e9ce5 100644 --- a/arch/arm/src/samv7/sam_lowputc.c +++ b/arch/arm/src/samv7/sam_lowputc.c @@ -364,9 +364,9 @@ void sam_lowsetup(void) # warning The SYSIO Pin4 must be bound to PB4 to use USART1 # endif - uint32_t sysioreg = getreg32(SAM_MATRIX_CCFG_SYSIO); - sysioreg |= MATRIX_CCFG_SYSIO_SYSIO4; - putreg32(sysioreg, SAM_MATRIX_CCFG_SYSIO); + regval = getreg32(SAM_MATRIX_CCFG_SYSIO); + regval |= MATRIX_CCFG_SYSIO_SYSIO4; + putreg32(regval, SAM_MATRIX_CCFG_SYSIO); #endif diff --git a/configs/clicker2-stm32/src/stm32_mrf24j40.c b/configs/clicker2-stm32/src/stm32_mrf24j40.c index b2996299455..d523fd257bb 100644 --- a/configs/clicker2-stm32/src/stm32_mrf24j40.c +++ b/configs/clicker2-stm32/src/stm32_mrf24j40.c @@ -135,6 +135,7 @@ static struct stm32_priv_s g_mrf24j40_mb1_priv = .dev.attach = stm32_attach_irq, .dev.enable = stm32_enable_irq, .handler = NULL, + .arg = NULL, .intcfg = GPIO_MB1_INT, .spidev = 3, }; @@ -145,7 +146,9 @@ static struct stm32_priv_s g_mrf24j40_mb2_priv = { .dev.attach = stm32_attach_irq, .dev.enable = stm32_enable_irq, - .uint32_t = GPIO_MB2_INT, + .handler = NULL, + .arg = NULL, + .intcfg = GPIO_MB2_INT, .spidev = 2, }; #endif diff --git a/configs/clicker2-stm32/src/stm32_spi.c b/configs/clicker2-stm32/src/stm32_spi.c index 84e0538ab61..c56ade201a5 100644 --- a/configs/clicker2-stm32/src/stm32_spi.c +++ b/configs/clicker2-stm32/src/stm32_spi.c @@ -136,17 +136,18 @@ void stm32_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected) { spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); - switch(devid) - { + switch (devid) + { #ifdef CONFIG_IEEE802154_MRF24J40 - case SPIDEV_IEEE802154(0): - /* Set the GPIO low to select and high to de-select */ - stm32_gpiowrite(GPIO_MB1_CS, !selected); - break; + case SPIDEV_IEEE802154(0): + /* Set the GPIO low to select and high to de-select */ + + stm32_gpiowrite(GPIO_MB1_CS, !selected); + break; #endif - default: - break; - } + default: + break; + } } uint8_t stm32_spi3status(FAR struct spi_dev_s *dev, uint32_t devid) diff --git a/configs/samv71-xult/Kconfig b/configs/samv71-xult/Kconfig index 94432376663..46ef50caaf1 100644 --- a/configs/samv71-xult/Kconfig +++ b/configs/samv71-xult/Kconfig @@ -9,6 +9,37 @@ config SAMV71XULT_MXTXPLND bool "MaXTouch Xplained connected" default n +config SAMV71XULT_CLICKSHIELD + bool "Mikroe Click Shield" + default n + ---help--- + In the mrf24j40-starhub configuration, a click shield from + MikroElectronika was used along with a Click "Bee" module. The + click shield supports two click shields. + +config SAMV71XULT_MB1_SPI + bool + default n + +config SAMV71XULT_MB2_SPI + bool + default n + +choice + prompt "Bee mikroBUS" + depends on SAMV71XULT_CLICKSHIELD && IEEE802154_MRF24J40 + default SAMV71XULT_MB1_BEE + +config SAMV71XULT_MB1_BEE + bool "MRF24J40 Bee in mikroBUS1" + select SAMV71XULT_MB1_SPI + +config SAMV71XULT_MB2_BEE + bool "MRF24J40 Bee in mikroBUS2" + select SAMV71XULT_MB2_SPI + +endchoice # Bee mikroBUS + if SAMV71XULT_MXTXPLND choice diff --git a/configs/samv71-xult/README.txt b/configs/samv71-xult/README.txt index e47eb987ca4..122aa35c09f 100644 --- a/configs/samv71-xult/README.txt +++ b/configs/samv71-xult/README.txt @@ -25,6 +25,7 @@ Contents - maXTouch Xplained Pro - MCAN1 Loopback Test - SPI Slave + - Click Shield - Tickless OS - Debugging - Configurations @@ -1437,6 +1438,61 @@ SPI Slave b) It will hog all of the CPU for the duration of the transfer). +Click Shield +============ + + In the mrf24j40-starhub configuration, a click shield from + MikroElectronika was used along with a Click "Bee" module. The click + shield supports two click shields and the following tables describe the + relationship between the pins on each click shield, the Arduino + connector and the SAME70 pins. + + --------- ---------------------- -------- --------- ------------------ ---------- + mikroBUS1 Arduino SAME70 mikroBUS2 Arduino SAME70 + --------- ---------------------- -------- --------- ------------------ ---------- + AN HD1 A0 AN0 Pin 1 AD0 PD26 AN HD1 A1 AN1 Pin 2 AD1 PC31 + RST HD1 A3 Pin 4 AD3 PD30 RST HD1 A2 Pin 3 AD2 PA19 + CS HD4 D10 SPI-SS Pin 8 D10 PD25 CS HD4 D9 Pin 9 D9 PC9 + SCK HD4 D13 SPI-SCK Pin 5 D13 PD22 SCK Same + MISO HD4 D12 SPI-MISO Pin 6 D12 PD20 MISO Same + MOSI HD4 D11 SPI-MOSI Pin 7 D11 PD21 MOSI Same + 3.3V N/A 3.3V N/A + GND N/A GND N/A + PWM HD3 D6 PWMA Pin 2 D6 PA2 PWM HD3 D5 PWMB Pin 5 D5 PD11 + INT HD3 D2 INT0 Pin 6 D2 PA5 INT HD3 D3 INT1 Pin 5 D3 PA6 + RX HD3 D0 HDR-RX* Pin 8 D0 PD28 RX Same + TX HD3 D1 HDR-TX* Pin 7 D1 PD20 TX Same + SCL HD1 A5 I2C-SCL Pin 5 AD5 PE0 SDA Same + SDA HD1 A4 I2C-SDA Pin 6 AD4 PC13 SCL Same + 5V N/A 5V N/A + GND N/A GND N/A + --------- ---------------------- -------- --------- ------------------ ---------- + + * Depends upon setting of SW1, UART vs PROG. + + --- ----- ------------------------------ --------------------------------- + PIN PORT SHIELD FUNCTION PIN CONFIGURATION + --- ----- ------------------------------ --------------------------------- + AD0 PD26 microBUS2 Analog TD *** Not an AFE pin *** + AD1 PC31 microBUS2 Analog AFE1_AD6 GPIO_AFE1_AD6 + AD2 PA19 microBUS2 GPIO reset output + AD3 PD30 microBUS1 GPIO reset output + AD4 PC13 (both) I2C-SDA *** Does not support I2C SDA *** + AD5 PE0 (both) I2C-SCL *** Does not support I2C SCL *** + + D0 PD28 (both) HDR_RX URXD3 GPIO_UART3_RXD + D1 PD30 (both) HDR_TX UTXD3 GPIO_UART3_TXD_1 + D2 PA0 microBUS1 GPIO interrupt input + D3 PA6 microBUS2 GPIO interrupt input + D5 PD11 microBUS2 PWM PWMC0_H0 + D6 PC19 microBUS1 PWN PWMC0_H2 + D9 PC9 microBUS2 CS GPIO output + D10 PD25 microBUS1 CS GPIO output SPI0_NPCS1 + D11 PD21 (both) SPI-MOSI SPI0_MOSI GPIO_SPI0_MOSI + D12 PD20 (both) SPI-MISO SPI0_MISO GPIO_SPI0_MISO + D13 PD22 (both) SPI-SCK SPI0_SPCK GPIO_SPI0_SPCK + --- ----- ------------------------------ --------------------------------- + Tickless OS =========== @@ -1791,6 +1847,49 @@ Configuration sub-directories STATUS: 2017-01-30: Does not yet run correctly. + mrf24j40-starhub + + This configuration implement a hub node in a 6LoWPAN start network. + It is intended for the us the mrf24j40-starpoint configuration with + the clicker2-stm32 configurations. Essentially, the SAMV71-XULT + plays the roll of the hub in the configuration and the clicker2-stm32 + boards are the endpoints in the start. + + NOTES: + 1. This configuration derives from the netnsh configuration, but adds + support for IPv6, 6LoWPAN, and the MRF24J40 IEEE 802.15.4 radio. + + 2. This configuration uses the Mikroe BEE MRF24j40 click boards and + connects to the SAMV71-XULT using a click shield as described above. + + 3. You must must have also have at least two clicker2-stm32 boards each + with an MRF24J40 BEE click board in order to run these tests. + + 4. Telnet: The clicker2-stm32 star point configuration supports the + Telnet daemon, but not the Telnet client; the star hub configuration + supports the Telnet client, but not the Telnet daemon. Therefore, + the star hub can Telnet to any point in the star, the star endpoints + cannot initiate telnet sessions. + + 5. TCP and UDP Tests: The same TCP and UDP tests as described for + the clicker2-stm32 mrf24j40-starpoint coniguration are supported on + the star endpoints, but NOT on the star hub. Therefore, all network + testing is between endpoints with the hub acting, well, only like a + hub. + + The nsh> dmesg command can be use at any time on any node to see + any debug output that you have selected. + + Telenet sessions may be initiated only from the hub to a star + endpoint: + + C: nsh> telnet <-- Runs the Telnet client + + Where is the IP address of either the E1 or I2 endpoints. + + STATUS: + 2017-07-02: Configurations added. Not yet tested. + mxtxplnd: Configures the NuttShell (nsh) located at examples/nsh. There are five diff --git a/configs/samv71-xult/include/board.h b/configs/samv71-xult/include/board.h index e2226d764b8..0c180927f11 100644 --- a/configs/samv71-xult/include/board.h +++ b/configs/samv71-xult/include/board.h @@ -300,7 +300,6 @@ #define GPIO_UART3_TXD GPIO_UART3_TXD_1 - /* - Arduino Communications. Additional UART/USART connections are available * on the Arduino Communications connection J505: * diff --git a/configs/samv71-xult/mrf24j40-starhub/Make.defs b/configs/samv71-xult/mrf24j40-starhub/Make.defs new file mode 100644 index 00000000000..08a41968f72 --- /dev/null +++ b/configs/samv71-xult/mrf24j40-starhub/Make.defs @@ -0,0 +1,128 @@ +############################################################################ +# configs/samv71-xult/mrf24j40-starhub/Make.defs +# +# Copyright (C) 2017 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +include ${TOPDIR}/.config +include ${TOPDIR}/tools/Config.mk +include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs + +ifeq ($(CONFIG_ARMV7M_DTCM),y) + LDSCRIPT = flash-dtcm.ld +else + LDSCRIPT = flash-sram.ld +endif + +ifeq ($(WINTOOL),y) + # Windows-native toolchains + DIRLINK = $(TOPDIR)/tools/copydir.sh + DIRUNLINK = $(TOPDIR)/tools/unlink.sh + MKDEP = $(TOPDIR)/tools/mkwindeps.sh + ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" + ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}" +else + # Linux/Cygwin-native toolchain + MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT) + ARCHINCLUDES = -I. -isystem $(TOPDIR)/include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx + ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) +endif + +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E +LD = $(CROSSDEV)ld +AR = $(CROSSDEV)ar rcs +NM = $(CROSSDEV)nm +OBJCOPY = $(CROSSDEV)objcopy +OBJDUMP = $(CROSSDEV)objdump + +ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'} +ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += $(MAXOPTIMIZATION) +endif + +ARCHCFLAGS = -fno-builtin +ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -fno-strict-aliasing +ARCHWARNINGSXX = -Wall -Wshadow -Wundef +ARCHDEFINES = +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +AFLAGS = $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +# Loadable module definitions + +CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs + +LDMODULEFLAGS = -r -e module_initialize +ifeq ($(WINTOOL),y) + LDMODULEFLAGS += -T "${shell cygpath -w $(TOPDIR)/libc/modlib/gnu-elf.ld}" +else + LDMODULEFLAGS += -T $(TOPDIR)/libc/modlib/gnu-elf.ld +endif + +ASMEXT = .S +OBJEXT = .o +LIBEXT = .a +EXEEXT = + +ifneq ($(CROSSDEV),arm-nuttx-elf-) + LDFLAGS += -nostartfiles -nodefaultlibs +endif +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif + + +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe +HOSTLDFLAGS = + diff --git a/configs/samv71-xult/mrf24j40-starhub/SAVEconfig b/configs/samv71-xult/mrf24j40-starhub/SAVEconfig new file mode 100644 index 00000000000..61c27df924b --- /dev/null +++ b/configs/samv71-xult/mrf24j40-starhub/SAVEconfig @@ -0,0 +1,377 @@ +CONFIG_ARCH_ARM=y +CONFIG_ARCH_BOARD_SAME70_XPLAINED=y +CONFIG_ARCH_BOARD="same70-xplained" +CONFIG_ARCH_BUTTONS=y +CONFIG_ARCH_CHIP_SAME70=y +CONFIG_ARCH_CHIP_SAME70Q=y +CONFIG_ARCH_CHIP_SAME70Q21=y +CONFIG_ARCH_CHIP_SAMV7=y +CONFIG_ARCH_CHIP="samv7" +CONFIG_ARCH_CORTEXM7=y +CONFIG_ARCH_DMA=y +CONFIG_ARCH_DPFPU=y +CONFIG_ARCH_FAMILY="armv7-m" +CONFIG_ARCH_FPU=y +CONFIG_ARCH_HAVE_BUTTONS=y +CONFIG_ARCH_HAVE_CMNVECTOR=y +CONFIG_ARCH_HAVE_CUSTOMOPT=y +CONFIG_ARCH_HAVE_DPFPU=y +CONFIG_ARCH_HAVE_FPU=y +CONFIG_ARCH_HAVE_HEAPCHECK=y +CONFIG_ARCH_HAVE_HIPRI_INTERRUPT=y +CONFIG_ARCH_HAVE_I2CRESET=y +CONFIG_ARCH_HAVE_INTERRUPTSTACK=y +CONFIG_ARCH_HAVE_IRQBUTTONS=y +CONFIG_ARCH_HAVE_IRQPRIO=y +CONFIG_ARCH_HAVE_LEDS=y +CONFIG_ARCH_HAVE_MPU=y +CONFIG_ARCH_HAVE_NET=y +CONFIG_ARCH_HAVE_NETDEV_STATISTICS=y +CONFIG_ARCH_HAVE_PHY=y +CONFIG_ARCH_HAVE_RAMFUNCS=y +CONFIG_ARCH_HAVE_RAMVECTORS=y +CONFIG_ARCH_HAVE_RESET=y +CONFIG_ARCH_HAVE_SDIO=y +CONFIG_ARCH_HAVE_SERIAL_TERMIOS=y +CONFIG_ARCH_HAVE_SPI_BITORDER=y +CONFIG_ARCH_HAVE_SPI_CS_CONTROL=y +CONFIG_ARCH_HAVE_STACKCHECK=y +CONFIG_ARCH_HAVE_TICKLESS=y +CONFIG_ARCH_HAVE_TIMEKEEPING=y +CONFIG_ARCH_HAVE_TLS=y +CONFIG_ARCH_HAVE_VFORK=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_IRQBUTTONS=y +CONFIG_ARCH_LEDS=y +CONFIG_ARCH_LOWPUTC=y +CONFIG_ARCH_PHY_INTERRUPT=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_TOOLCHAIN_GNU=y +CONFIG_ARCH="arm" +CONFIG_ARM_HAVE_MPU_UNIFIED=y +CONFIG_ARMV7M_CMNVECTOR=y +CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y +CONFIG_ARMV7M_DCACHE=y +CONFIG_ARMV7M_HAVE_DCACHE=y +CONFIG_ARMV7M_HAVE_DTCM=y +CONFIG_ARMV7M_HAVE_ICACHE=y +CONFIG_ARMV7M_HAVE_ITCM=y +CONFIG_ARMV7M_HAVE_STACKCHECK=y +CONFIG_ARMV7M_ICACHE=y +CONFIG_ARMV7M_LAZYFPU=y +CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y +CONFIG_AT24XX_ADDR=0x57 +CONFIG_AT24XX_EXTENDED=y +CONFIG_AT24XX_EXTSIZE=160 +CONFIG_AT24XX_FREQUENCY=100000 +CONFIG_AT24XX_SIZE=2 +CONFIG_AT25_SPIFREQUENCY=20000000 +CONFIG_AT25_SPIMODE=0 +CONFIG_BOARD_INITIALIZE=y +CONFIG_BOARD_LOOPSPERMSEC=51262 +CONFIG_BOOT_RUNFROMFLASH=y +CONFIG_BUILD_FLAT=y +CONFIG_BUILTIN_PROXY_STACKSIZE=1024 +CONFIG_BUILTIN=y +CONFIG_SAME70XPLND_CLICK_MB1_BEE=y +CONFIG_SAME70XPLND_CLICK_MB1_SPI=y +CONFIG_DEBUG_ALERT=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEV_CONSOLE=y +CONFIG_DEV_NULL=y +CONFIG_DISABLE_OS_API=y +CONFIG_DISABLE_POLL=y +CONFIG_DRIVERS_IEEE802154=y +CONFIG_DRIVERS_WIRELESS=y +CONFIG_EOL_IS_EITHER_CRLF=y +CONFIG_ETH0_PHY_KSZ8081=y +CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y +CONFIG_EXAMPLES_NSH=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FAT_MAXFNAME=32 +CONFIG_FS_FAT=y +CONFIG_FS_MQUEUE_MPATH="/var/mqueue" +CONFIG_FS_PROCFS=y +CONFIG_FS_READABLE=y +CONFIG_FS_WRITABLE=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_HOST_WINDOWS=y +CONFIG_IDLETHREAD_STACKSIZE=1024 +CONFIG_IEEE802154_DEFAULT_EADDR=0x00fade00deadbeef +CONFIG_IEEE802154_I8SAK_PRIORITY=100 +CONFIG_IEEE802154_I8SAK_STACKSIZE=2048 +CONFIG_IEEE802154_I8SAK=y +CONFIG_IEEE802154_IND_IRQRESERVE=10 +CONFIG_IEEE802154_IND_PREALLOC=32 +CONFIG_IEEE802154_LIBMAC=y +CONFIG_IEEE802154_LIBUTILS=y +CONFIG_IEEE802154_MACDEV_RECVRPRIO=0 +CONFIG_IEEE802154_MACDEV=y +CONFIG_IEEE802154_MRF24J40=y +CONFIG_IEEE802154_NETDEV_LPWORK=y +CONFIG_IEEE802154_NETDEV_RECVRPRIO=1 +CONFIG_IEEE802154_NETDEV=y +CONFIG_INIT_ENTRYPOINT=y +CONFIG_INTELHEX_BINARY=y +CONFIG_IOB_BUFSIZE=128 +CONFIG_IOB_NBUFFERS=32 +CONFIG_IOB_NCHAINS=16 +CONFIG_IOB_THROTTLE=8 +CONFIG_LIB_BOARDCTL=y +CONFIG_LIB_HOMEDIR="/" +CONFIG_LIB_RAND_ORDER=1 +CONFIG_LIB_SENDFILE_BUFSIZE=512 +CONFIG_LIBC_LONG_LONG=y +CONFIG_LIBC_MAX_TMPFILE=32 +CONFIG_LIBC_NETDB=y +CONFIG_LIBC_TMPDIR="/tmp" +CONFIG_MAC802154_HPWORK=y +CONFIG_MAC802154_NNOTIF=48 +CONFIG_MAC802154_NPANDESC=5 +CONFIG_MAC802154_NTXDESC=32 +CONFIG_MAX_TASKS=16 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_MCU_SERIAL=y +CONFIG_MM_IOB=y +CONFIG_MM_REGIONS=1 +CONFIG_MMCSD_HAVECARDDETECT=y +CONFIG_MMCSD_MULTIBLOCK_DISABLE=y +CONFIG_MMCSD_NSLOTS=1 +CONFIG_MMCSD_SDIO=y +CONFIG_MMCSD=y +CONFIG_MQ_MAXMSGSIZE=32 +CONFIG_MTD_AT24XX=y +CONFIG_MTD_AT25=y +CONFIG_MTD_CONFIG_ERASEDVALUE=0xff +CONFIG_MTD_CONFIG=y +CONFIG_MTD=y +CONFIG_NAME_MAX=32 +CONFIG_NET_6LOWPAN_COMPRESSION_HC06=y +CONFIG_NET_6LOWPAN_COMPRESSION_THRESHOLD=63 +CONFIG_NET_6LOWPAN_FRAG=y +CONFIG_NET_6LOWPAN_FRAMELEN=127 +CONFIG_NET_6LOWPAN_MAX_MACTRANSMITS=4 +CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_0=0xaa +CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_1=0xaa +CONFIG_NET_6LOWPAN_MAXADDRCONTEXT=1 +CONFIG_NET_6LOWPAN_MAXAGE=20 +CONFIG_NET_6LOWPAN_MTU=1294 +CONFIG_NET_6LOWPAN_TCP_RECVWNDO=1220 +CONFIG_NET_6LOWPAN=y +CONFIG_NET_BROADCAST=y +CONFIG_NET_ETH_MTU=590 +CONFIG_NET_ETH_TCP_RECVWNDO=536 +CONFIG_NET_ETHERNET=y +CONFIG_NET_GUARDSIZE=2 +CONFIG_NET_HAVE_STAR=y +CONFIG_NET_HOSTNAME="MRF24J40-Hub" +CONFIG_NET_IPFORWARD=y +# CONFIG_NET_IPv4 is not set +CONFIG_NET_IPv6_NCONF_ENTRIES=8 +CONFIG_NET_IPv6=y +CONFIG_NET_MAX_LISTENPORTS=20 +CONFIG_NET_NACTIVESOCKETS=16 +CONFIG_NET_SOCKOPTS=y +CONFIG_NET_STAR=y +CONFIG_NET_STARHUB=y +CONFIG_NET_STATISTICS=y +CONFIG_NET_TCP_CONNS=8 +CONFIG_NET_TCP_NWRBCHAINS=8 +CONFIG_NET_TCP_READAHEAD=y +CONFIG_NET_TCP_RECVDELAY=0 +CONFIG_NET_TCP_WRITE_BUFFERS=y +CONFIG_NET_TCP=y +CONFIG_NET_TCPBACKLOG=y +CONFIG_NET_UDP_CHECKSUMS=y +CONFIG_NET_UDP_CONNS=8 +CONFIG_NET_UDP_READAHEAD=y +CONFIG_NET_UDP=y +CONFIG_NET=y +CONFIG_NETDB_DNSCLIENT_ENTRIES=8 +CONFIG_NETDB_DNSCLIENT_LIFESEC=3600 +CONFIG_NETDB_DNSCLIENT_MAXRESPONSE=96 +CONFIG_NETDB_DNSCLIENT_NAMESIZE=32 +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDB_DNSSERVER_NOADDR=y +CONFIG_NETDEV_IOCTL=y +CONFIG_NETDEV_LATEINIT=y +CONFIG_NETDEV_PHY_IOCTL=y +CONFIG_NETDEV_STATISTICS=y +CONFIG_NETDEV_TELNET=y +CONFIG_NETDEV_WIRELESS_IOCTL=y +CONFIG_NETDEVICES=y +CONFIG_NETUTILS_NETLIB=y +CONFIG_NETUTILS_TELNETC=y +CONFIG_NETUTILS_TELNETD=y +CONFIG_NETUTILS_TFTPC=y +CONFIG_NETUTILS_WEBCLIENT=y +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NPTHREAD_KEYS=4 +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_ARGCAT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_CMDOPT_HEXDUMP=y +CONFIG_NSH_CMDPARMS=y +CONFIG_NSH_CODECS_BUFSIZE=128 +CONFIG_NSH_CONSOLE=y +CONFIG_NSH_DISABLE_DATE=y +CONFIG_NSH_DISABLE_GET=y +CONFIG_NSH_DISABLE_LOSMART=y +CONFIG_NSH_DISABLE_PRINTF=y +CONFIG_NSH_DISABLE_PUT=y +CONFIG_NSH_DISABLE_WGET=y +CONFIG_NSH_DRIPADDR=0x0a000001 +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_IOBUFFER_SIZE=512 +CONFIG_NSH_IPADDR=0x0a000002 +CONFIG_NSH_LIBRARY=y +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_MACADDR=0x00fade00deadbeef +CONFIG_NSH_MAX_ROUNDTRIP=20 +CONFIG_NSH_MAXARGUMENTS=6 +CONFIG_NSH_MMCSDMINOR=0 +CONFIG_NSH_MMCSDSLOTNO=0 +CONFIG_NSH_NESTDEPTH=3 +CONFIG_NSH_NETINIT_MONITOR=y +CONFIG_NSH_NETINIT_RETRYMSEC=2000 +CONFIG_NSH_NETINIT_SIGNO=18 +CONFIG_NSH_NETINIT_THREAD_PRIORITY=80 +CONFIG_NSH_NETINIT_THREAD_STACKSIZE=1568 +CONFIG_NSH_NETINIT_THREAD=y +CONFIG_NSH_NETINIT=y +CONFIG_NSH_NETLOCAL=y +CONFIG_NSH_NETMASK=0xffffff00 +CONFIG_NSH_NOMAC=y +CONFIG_NSH_PROC_MOUNTPOINT="/proc" +CONFIG_NSH_READLINE=y +CONFIG_NSH_SWMAC=y +CONFIG_NSH_TELNET=y +CONFIG_NSH_TELNETD_CLIENTPRIO=100 +CONFIG_NSH_TELNETD_CLIENTSTACKSIZE=2048 +CONFIG_NSH_TELNETD_DAEMONPRIO=100 +CONFIG_NSH_TELNETD_DAEMONSTACKSIZE=2048 +CONFIG_NSH_TELNETD_PORT=23 +CONFIG_NSH_WGET_USERAGENT="NuttX/6.xx.x (; http://www.nuttx.org/)" +CONFIG_NSOCKET_DESCRIPTORS=8 +CONFIG_NUNGET_CHARS=2 +CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=1024 +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_PREALLOC_TIMERS=4 +CONFIG_PREALLOC_WDOGS=32 +CONFIG_PTHREAD_MUTEX_ROBUST=y +CONFIG_PTHREAD_STACK_DEFAULT=2048 +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_RAM_SIZE=393216 +CONFIG_RAM_START=0x20400000 +CONFIG_RAMLOG_BUFSIZE=8192 +CONFIG_RAMLOG_NONBLOCKING=y +CONFIG_RAMLOG_NPOLLWAITERS=4 +CONFIG_RAMLOG_SYSLOG=y +CONFIG_RAMLOG=y +CONFIG_RAW_BINARY=y +CONFIG_READLINE_ECHO=y +CONFIG_READLINE_HAVE_EXTMATCH=y +CONFIG_RR_INTERVAL=200 +CONFIG_SAMV7_EMAC_HPWORK=y +CONFIG_SAMV7_EMAC=y +CONFIG_SAMV7_EMAC0_AUTONEG=y +CONFIG_SAMV7_EMAC0_ISETH0=y +CONFIG_SAMV7_EMAC0_NRXBUFFERS=16 +CONFIG_SAMV7_EMAC0_NTXBUFFERS=8 +CONFIG_SAMV7_EMAC0_PHYADDR=1 +CONFIG_SAMV7_EMAC0_PHYSR_100FD=0x6 +CONFIG_SAMV7_EMAC0_PHYSR_100HD=0x2 +CONFIG_SAMV7_EMAC0_PHYSR_10FD=0x5 +CONFIG_SAMV7_EMAC0_PHYSR_10HD=0x1 +CONFIG_SAMV7_EMAC0_PHYSR_ALTCONFIG=y +CONFIG_SAMV7_EMAC0_PHYSR_ALTMODE=0x7 +CONFIG_SAMV7_EMAC0_PHYSR=30 +CONFIG_SAMV7_EMAC0_RMII=y +CONFIG_SAMV7_EMAC0=y +CONFIG_SAMV7_ERASE_ENABLE=y +CONFIG_SAMV7_GPIO_IRQ=y +CONFIG_SAMV7_GPIOA_IRQ=y +CONFIG_SAMV7_GPIOC_IRQ=y +CONFIG_SAMV7_HAVE_EBI=y +CONFIG_SAMV7_HAVE_HSMCI0=y +CONFIG_SAMV7_HAVE_MCAN1=y +CONFIG_SAMV7_HAVE_SDRAMC=y +CONFIG_SAMV7_HAVE_SPI0=y +CONFIG_SAMV7_HAVE_SPI1=y +CONFIG_SAMV7_HAVE_TWIHS2=y +CONFIG_SAMV7_HAVE_USART0=y +CONFIG_SAMV7_HAVE_USART1=y +CONFIG_SAMV7_HAVE_USART2=y +CONFIG_SAMV7_HAVE_USBHS=y +CONFIG_SAMV7_HSMCI_DMA=y +CONFIG_SAMV7_HSMCI=y +CONFIG_SAMV7_HSMCI0=y +CONFIG_SAMV7_JTAG_FULL_ENABLE=y +CONFIG_SAMV7_TWIHS0_FREQUENCY=100000 +CONFIG_SAMV7_TWIHS0_GLITCH_FILTER=1 +CONFIG_SAMV7_TWIHS0=y +# CONFIG_SAMV7_UART0 is not set +# CONFIG_SAMV7_UART1 is not set +# CONFIG_SAMV7_UART2 is not set +# CONFIG_SAMV7_UART3 is not set +# CONFIG_SAMV7_UART4 is not set +CONFIG_SAMV7_USART1=y +CONFIG_SAMV7_XDMAC=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPERIOD=50000 +CONFIG_SCHED_HPWORKPRIORITY=224 +CONFIG_SCHED_HPWORKSTACKSIZE=2048 +CONFIG_SCHED_LPNTHREADS=1 +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_LPWORKPERIOD=50000 +CONFIG_SCHED_LPWORKPRIORITY=160 +CONFIG_SCHED_LPWORKSTACKSIZE=2048 +CONFIG_SCHED_WAITPID=y +CONFIG_SCHED_WORKQUEUE=y +CONFIG_SDCLONE_DISABLE=y +CONFIG_SDIO_BLOCKSETUP=y +CONFIG_SDIO_DMA=y +CONFIG_SERIAL_CONSOLE=y +CONFIG_SERIAL_NPOLLWAITERS=2 +CONFIG_SERIAL=y +CONFIG_SIG_SIGALARM=3 +CONFIG_SIG_SIGCONDTIMEDOUT=16 +CONFIG_SIG_SIGUSR1=1 +CONFIG_SIG_SIGUSR2=2 +CONFIG_SIG_SIGWORK=17 +CONFIG_SPI_EXCHANGE=y +CONFIG_SPI=y +CONFIG_STANDARD_SERIAL=y +CONFIG_START_DAY=1 +CONFIG_START_MONTH=7 +CONFIG_START_YEAR=2017 +CONFIG_STDIO_BUFFER_SIZE=64 +CONFIG_STDIO_LINEBUFFER=y +CONFIG_SYSTEM_READLINE=y +CONFIG_SYSTEM_TELNET_CLIENT=y +CONFIG_SYSTEM_TELNET_CLIENT_PRIORITY=100 +CONFIG_SYSTEM_TELNET_CLIENT_STACKSIZE=2048 +CONFIG_TASK_NAME_SIZE=31 +CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=2048 +CONFIG_TELNET_RXBUFFER_SIZE=256 +CONFIG_TELNET_TXBUFFER_SIZE=256 +CONFIG_TOOLCHAIN_WINDOWS=y +CONFIG_USART1_2STOP=0 +CONFIG_USART1_BAUD=115200 +CONFIG_USART1_BITS=8 +CONFIG_USART1_PARITY=0 +CONFIG_USART1_RXBUFSIZE=256 +CONFIG_USART1_SERIAL_CONSOLE=y +CONFIG_USART1_SERIALDRIVER=y +CONFIG_USART1_TXBUFSIZE=256 +CONFIG_USEC_PER_TICK=10000 +CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_USERMAIN_STACKSIZE=2048 +CONFIG_WDOG_INTRESERVE=4 +CONFIG_WEBCLIENT_TIMEOUT=10 +CONFIG_WINDOWS_CYGWIN=y +CONFIG_WIRELESS_IEEE802154=y +CONFIG_WIRELESS=y diff --git a/configs/samv71-xult/mrf24j40-starhub/defconfig b/configs/samv71-xult/mrf24j40-starhub/defconfig new file mode 100644 index 00000000000..541ca9f7a92 --- /dev/null +++ b/configs/samv71-xult/mrf24j40-starhub/defconfig @@ -0,0 +1,1543 @@ +# +# Automatically generated file; DO NOT EDIT. +# Nuttx/ Configuration +# + +# +# Build Setup +# +# CONFIG_EXPERIMENTAL is not set +# CONFIG_DEFAULT_SMALL is not set +# CONFIG_HOST_LINUX is not set +# CONFIG_HOST_OSX is not set +CONFIG_HOST_WINDOWS=y +# CONFIG_HOST_OTHER is not set +CONFIG_TOOLCHAIN_WINDOWS=y +# CONFIG_WINDOWS_NATIVE is not set +CONFIG_WINDOWS_CYGWIN=y +# CONFIG_WINDOWS_UBUNTU is not set +# CONFIG_WINDOWS_MSYS is not set +# CONFIG_WINDOWS_OTHER is not set + +# +# Build Configuration +# +# CONFIG_APPS_DIR="../apps" +CONFIG_BUILD_FLAT=y +# CONFIG_BUILD_2PASS is not set + +# +# Binary Output Formats +# +# CONFIG_RRLOAD_BINARY is not set +CONFIG_INTELHEX_BINARY=y +# CONFIG_MOTOROLA_SREC is not set +CONFIG_RAW_BINARY=y +# CONFIG_UBOOT_UIMAGE is not set +# CONFIG_DFU_BINARY is not set + +# +# Customize Header Files +# +# CONFIG_ARCH_STDINT_H is not set +# CONFIG_ARCH_STDBOOL_H is not set +# CONFIG_ARCH_MATH_H is not set +# CONFIG_ARCH_FLOAT_H is not set +# CONFIG_ARCH_STDARG_H is not set +# CONFIG_ARCH_DEBUG_H is not set + +# +# Debug Options +# +CONFIG_DEBUG_ALERT=y +# CONFIG_DEBUG_FEATURES is not set +CONFIG_ARCH_HAVE_STACKCHECK=y +# CONFIG_STACK_COLORATION is not set +# CONFIG_ARCH_HAVE_HEAPCHECK is not set +# CONFIG_DEBUG_SYMBOLS is not set +CONFIG_ARCH_HAVE_CUSTOMOPT=y +# CONFIG_DEBUG_NOOPT is not set +# CONFIG_DEBUG_CUSTOMOPT is not set +CONFIG_DEBUG_FULLOPT=y + +# +# System Type +# +CONFIG_ARCH_ARM=y +# CONFIG_ARCH_AVR is not set +# CONFIG_ARCH_HC is not set +# CONFIG_ARCH_MIPS is not set +# CONFIG_ARCH_MISOC is not set +# CONFIG_ARCH_RENESAS is not set +# CONFIG_ARCH_RISCV is not set +# CONFIG_ARCH_SIM is not set +# CONFIG_ARCH_X86 is not set +# CONFIG_ARCH_XTENSA is not set +# CONFIG_ARCH_Z16 is not set +# CONFIG_ARCH_Z80 is not set +CONFIG_ARCH="arm" + +# +# ARM Options +# +# CONFIG_ARCH_CHIP_A1X is not set +# CONFIG_ARCH_CHIP_C5471 is not set +# CONFIG_ARCH_CHIP_DM320 is not set +# CONFIG_ARCH_CHIP_EFM32 is not set +# CONFIG_ARCH_CHIP_IMX1 is not set +# CONFIG_ARCH_CHIP_IMX6 is not set +# CONFIG_ARCH_CHIP_KINETIS is not set +# CONFIG_ARCH_CHIP_KL is not set +# CONFIG_ARCH_CHIP_LM is not set +# CONFIG_ARCH_CHIP_TIVA is not set +# CONFIG_ARCH_CHIP_LPC11XX is not set +# CONFIG_ARCH_CHIP_LPC17XX is not set +# CONFIG_ARCH_CHIP_LPC214X is not set +# CONFIG_ARCH_CHIP_LPC2378 is not set +# CONFIG_ARCH_CHIP_LPC31XX is not set +# CONFIG_ARCH_CHIP_LPC43XX is not set +# CONFIG_ARCH_CHIP_MOXART is not set +# CONFIG_ARCH_CHIP_NUC1XX is not set +# CONFIG_ARCH_CHIP_SAMA5 is not set +# CONFIG_ARCH_CHIP_SAMD is not set +# CONFIG_ARCH_CHIP_SAML is not set +# CONFIG_ARCH_CHIP_SAM34 is not set +CONFIG_ARCH_CHIP_SAMV7=y +# CONFIG_ARCH_CHIP_STM32 is not set +# CONFIG_ARCH_CHIP_STM32F0 is not set +# CONFIG_ARCH_CHIP_STM32F7 is not set +# CONFIG_ARCH_CHIP_STM32L4 is not set +# CONFIG_ARCH_CHIP_STR71X is not set +# CONFIG_ARCH_CHIP_TMS570 is not set +# CONFIG_ARCH_CHIP_XMC4 is not set +# CONFIG_ARCH_ARM7TDMI is not set +# CONFIG_ARCH_ARM926EJS is not set +# CONFIG_ARCH_ARM920T is not set +# CONFIG_ARCH_CORTEXM0 is not set +# CONFIG_ARCH_CORTEXM23 is not set +# CONFIG_ARCH_CORTEXM3 is not set +# CONFIG_ARCH_CORTEXM33 is not set +# CONFIG_ARCH_CORTEXM4 is not set +CONFIG_ARCH_CORTEXM7=y +# CONFIG_ARCH_CORTEXA5 is not set +# CONFIG_ARCH_CORTEXA8 is not set +# CONFIG_ARCH_CORTEXA9 is not set +# CONFIG_ARCH_CORTEXR4 is not set +# CONFIG_ARCH_CORTEXR4F is not set +# CONFIG_ARCH_CORTEXR5 is not set +# CONFIG_ARCH_CORTEXR5F is not set +# CONFIG_ARCH_CORTEXR7 is not set +# CONFIG_ARCH_CORTEXR7F is not set +CONFIG_ARCH_FAMILY="armv7-m" +CONFIG_ARCH_CHIP="samv7" +# CONFIG_ARMV7M_USEBASEPRI is not set +CONFIG_ARCH_HAVE_CMNVECTOR=y +CONFIG_ARMV7M_CMNVECTOR=y +CONFIG_ARMV7M_LAZYFPU=y +CONFIG_ARCH_HAVE_FPU=y +CONFIG_ARCH_HAVE_DPFPU=y +CONFIG_ARCH_FPU=y +CONFIG_ARCH_DPFPU=y +# CONFIG_ARCH_HAVE_TRUSTZONE is not set +CONFIG_ARM_HAVE_MPU_UNIFIED=y +# CONFIG_ARM_MPU is not set + +# +# ARMV7M Configuration Options +# +CONFIG_ARMV7M_HAVE_ICACHE=y +CONFIG_ARMV7M_HAVE_DCACHE=y +CONFIG_ARMV7M_ICACHE=y +CONFIG_ARMV7M_DCACHE=y +CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y +CONFIG_ARMV7M_HAVE_ITCM=y +CONFIG_ARMV7M_HAVE_DTCM=y +# CONFIG_ARMV7M_ITCM is not set +# CONFIG_ARMV7M_DTCM is not set +# CONFIG_ARMV7M_TOOLCHAIN_IARW is not set +# CONFIG_ARMV7M_TOOLCHAIN_ATOLLIC is not set +# CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT is not set +# CONFIG_ARMV7M_TOOLCHAIN_CODEREDW is not set +# CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW is not set +# CONFIG_ARMV7M_TOOLCHAIN_DEVKITARM is not set +# CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL is not set +CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y +# CONFIG_ARMV7M_TOOLCHAIN_RAISONANCE is not set +CONFIG_ARMV7M_HAVE_STACKCHECK=y +# CONFIG_ARMV7M_STACKCHECK is not set +# CONFIG_ARMV7M_ITMSYSLOG is not set +# CONFIG_SERIAL_TERMIOS is not set + +# +# SAMV7 Configuration Options +# +# CONFIG_ARCH_CHIP_SAME70Q19 is not set +# CONFIG_ARCH_CHIP_SAME70Q20 is not set +# CONFIG_ARCH_CHIP_SAME70Q21 is not set +# CONFIG_ARCH_CHIP_SAME70N19 is not set +# CONFIG_ARCH_CHIP_SAME70N20 is not set +# CONFIG_ARCH_CHIP_SAME70N21 is not set +# CONFIG_ARCH_CHIP_SAME70J19 is not set +# CONFIG_ARCH_CHIP_SAME70J20 is not set +# CONFIG_ARCH_CHIP_SAME70J21 is not set +# CONFIG_ARCH_CHIP_SAMV71Q19 is not set +# CONFIG_ARCH_CHIP_SAMV71Q20 is not set +CONFIG_ARCH_CHIP_SAMV71Q21=y +# CONFIG_ARCH_CHIP_SAMV71N19 is not set +# CONFIG_ARCH_CHIP_SAMV71N20 is not set +# CONFIG_ARCH_CHIP_SAMV71N21 is not set +# CONFIG_ARCH_CHIP_SAMV71J19 is not set +# CONFIG_ARCH_CHIP_SAMV71J20 is not set +# CONFIG_ARCH_CHIP_SAMV71J21 is not set +# CONFIG_ARCH_CHIP_SAME70 is not set +# CONFIG_ARCH_CHIP_SAME70Q is not set +# CONFIG_ARCH_CHIP_SAME70N is not set +# CONFIG_ARCH_CHIP_SAME70J is not set +CONFIG_ARCH_CHIP_SAMV71=y +CONFIG_ARCH_CHIP_SAMV71Q=y +# CONFIG_ARCH_CHIP_SAMV71N is not set +# CONFIG_ARCH_CHIP_SAMV71J is not set +# CONFIG_SAMV7_MCAN is not set +CONFIG_SAMV7_HAVE_MCAN1=y +# CONFIG_SAMV7_DAC is not set +# CONFIG_SAMV7_HAVE_DAC1 is not set +CONFIG_SAMV7_HAVE_EBI=y +CONFIG_SAMV7_EMAC=y +CONFIG_SAMV7_HSMCI=y +CONFIG_SAMV7_HAVE_HSMCI0=y +# CONFIG_SAMV7_HAVE_ISI8 is not set +CONFIG_SAMV7_HAVE_MEDIALB=y +CONFIG_SAMV7_HAVE_SDRAMC=y +CONFIG_SAMV7_HAVE_SPI0=y +CONFIG_SAMV7_HAVE_SPI1=y +# CONFIG_SAMV7_QSPI_IS_SPI is not set +# CONFIG_SAMV7_SSC is not set +# CONFIG_SAMV7_HAVE_TC is not set +CONFIG_SAMV7_HAVE_TWIHS2=y +# CONFIG_SAMV7_HAVE_USBFS is not set +CONFIG_SAMV7_HAVE_USBHS=y +CONFIG_SAMV7_HAVE_USART0=y +CONFIG_SAMV7_HAVE_USART1=y +CONFIG_SAMV7_HAVE_USART2=y +# CONFIG_SAMV7_SPI is not set +# CONFIG_SAMV7_SPI_MASTER is not set +# CONFIG_SAMV7_SPI_SLAVE is not set + +# +# SAMV7 Peripheral Selection +# +# CONFIG_SAMV7_ACC is not set +# CONFIG_SAMV7_ADC is not set +# CONFIG_SAMV7_AFEC0 is not set +# CONFIG_SAMV7_AFEC1 is not set +# CONFIG_SAMV7_MCAN0 is not set +# CONFIG_SAMV7_MCAN1 is not set +# CONFIG_SAMV7_DAC0 is not set +# CONFIG_SAMV7_EBI is not set +CONFIG_SAMV7_EMAC0=y +CONFIG_SAMV7_XDMAC=y +CONFIG_SAMV7_HSMCI0=y +# CONFIG_SAMV7_ISI is not set +# CONFIG_SAMV7_MLB is not set +# CONFIG_SAMV7_PWM0 is not set +# CONFIG_SAMV7_PWM1 is not set +# CONFIG_SAMV7_QSPI is not set +# CONFIG_SAMV7_RTC is not set +# CONFIG_SAMV7_RTT is not set +# CONFIG_SAMV7_SDRAMC is not set +# CONFIG_SAMV7_SMC is not set +# CONFIG_SAMV7_SPI0 is not set +# CONFIG_SAMV7_SPI1 is not set +# CONFIG_SAMV7_SSC0 is not set +# CONFIG_SAMV7_TC0 is not set +# CONFIG_SAMV7_TC1 is not set +# CONFIG_SAMV7_TC2 is not set +# CONFIG_SAMV7_TC3 is not set +# CONFIG_SAMV7_TRNG is not set +CONFIG_SAMV7_TWIHS0=y +# CONFIG_SAMV7_TWIHS1 is not set +# CONFIG_SAMV7_TWIHS2 is not set +# CONFIG_SAMV7_UART0 is not set +# CONFIG_SAMV7_UART1 is not set +# CONFIG_SAMV7_UART2 is not set +# CONFIG_SAMV7_UART3 is not set +# CONFIG_SAMV7_UART4 is not set +# CONFIG_SAMV7_USBDEVHS is not set +# CONFIG_SAMV7_USBHOSTHS is not set +# CONFIG_SAMV7_USART0 is not set +CONFIG_SAMV7_USART1=y +# CONFIG_SAMV7_USART2 is not set +# CONFIG_SAMV7_WDT is not set +# CONFIG_SAMV7_RSWDT is not set +# CONFIG_SAMV7_JTAG_DISABLE is not set +CONFIG_SAMV7_JTAG_FULL_ENABLE=y +# CONFIG_SAMV7_JTAG_FULL_SW_ENABLE is not set +# CONFIG_SAMV7_JTAG_SW_ENABLE is not set +# CONFIG_SAMV7_ERASE_DISABLE is not set +CONFIG_SAMV7_ERASE_ENABLE=y +# CONFIG_SAMV7_SYSTEMRESET is not set +CONFIG_SAMV7_GPIO_IRQ=y +CONFIG_SAMV7_GPIOA_IRQ=y +CONFIG_SAMV7_GPIOB_IRQ=y +# CONFIG_SAMV7_GPIOC_IRQ is not set +CONFIG_SAMV7_GPIOD_IRQ=y +# CONFIG_SAMV7_GPIOE_IRQ is not set +# CONFIG_SAMV7_PROGMEM is not set + +# +# TWIHS device driver options +# +CONFIG_SAMV7_TWIHS0_FREQUENCY=100000 +CONFIG_SAMV7_TWIHS0_GLITCH_FILTER=1 + +# +# HSMCI device driver options +# +CONFIG_SAMV7_HSMCI_DMA=y +# CONFIG_SAMV7_HSMCI_RDPROOF is not set +# CONFIG_SAMV7_HSMCI_WRPROOF is not set +# CONFIG_SAMV7_HSMCI_UNALIGNED is not set + +# +# EMAC device driver options +# +CONFIG_SAMV7_EMAC0_NRXBUFFERS=16 +CONFIG_SAMV7_EMAC0_NTXBUFFERS=8 +CONFIG_SAMV7_EMAC0_PHYADDR=1 +# CONFIG_SAMV7_EMAC0_PHYINIT is not set +# CONFIG_SAMV7_EMAC0_MII is not set +CONFIG_SAMV7_EMAC0_RMII=y +CONFIG_SAMV7_EMAC0_AUTONEG=y +CONFIG_SAMV7_EMAC0_PHYSR=30 +CONFIG_SAMV7_EMAC0_PHYSR_ALTCONFIG=y +CONFIG_SAMV7_EMAC0_PHYSR_ALTMODE=0x7 +CONFIG_SAMV7_EMAC0_PHYSR_10HD=0x1 +CONFIG_SAMV7_EMAC0_PHYSR_100HD=0x2 +CONFIG_SAMV7_EMAC0_PHYSR_10FD=0x5 +CONFIG_SAMV7_EMAC0_PHYSR_100FD=0x6 +CONFIG_SAMV7_EMAC0_ISETH0=y +# CONFIG_SAMV7_EMAC_PREALLOCATE is not set +# CONFIG_SAMV7_EMAC_NBC is not set +CONFIG_SAMV7_EMAC_HPWORK=y +# CONFIG_SAMV7_EMAC_LPWORK is not set +# CONFIG_ARCH_TOOLCHAIN_IAR is not set +CONFIG_ARCH_TOOLCHAIN_GNU=y + +# +# Architecture Options +# +# CONFIG_ARCH_NOINTC is not set +# CONFIG_ARCH_VECNOTIRQ is not set +CONFIG_ARCH_DMA=y +CONFIG_ARCH_HAVE_IRQPRIO=y +# CONFIG_ARCH_L2CACHE is not set +# CONFIG_ARCH_HAVE_COHERENT_DCACHE is not set +# CONFIG_ARCH_HAVE_ADDRENV is not set +# CONFIG_ARCH_NEED_ADDRENV_MAPPING is not set +# CONFIG_ARCH_HAVE_MULTICPU is not set +CONFIG_ARCH_HAVE_VFORK=y +# CONFIG_ARCH_HAVE_MMU is not set +CONFIG_ARCH_HAVE_MPU=y +# CONFIG_ARCH_NAND_HWECC is not set +# CONFIG_ARCH_HAVE_EXTCLK is not set +# CONFIG_ARCH_HAVE_POWEROFF is not set +CONFIG_ARCH_HAVE_RESET=y +# CONFIG_ARCH_HAVE_RTC_SUBSECONDS is not set +# CONFIG_ARCH_USE_MPU is not set +# CONFIG_ARCH_IRQPRIO is not set +CONFIG_ARCH_STACKDUMP=y +# CONFIG_ENDIAN_BIG is not set +# CONFIG_ARCH_IDLE_CUSTOM is not set +CONFIG_ARCH_HAVE_RAMFUNCS=y +# CONFIG_ARCH_RAMFUNCS is not set +CONFIG_ARCH_HAVE_RAMVECTORS=y +# CONFIG_ARCH_RAMVECTORS is not set +# CONFIG_ARCH_MINIMAL_VECTORTABLE is not set + +# +# Board Settings +# +CONFIG_BOARD_LOOPSPERMSEC=51262 +# CONFIG_ARCH_CALIBRATION is not set + +# +# Interrupt options +# +CONFIG_ARCH_HAVE_INTERRUPTSTACK=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_HAVE_HIPRI_INTERRUPT=y +# CONFIG_ARCH_HIPRI_INTERRUPT is not set + +# +# Boot options +# +# CONFIG_BOOT_RUNFROMEXTSRAM is not set +CONFIG_BOOT_RUNFROMFLASH=y +# CONFIG_BOOT_RUNFROMISRAM is not set +# CONFIG_BOOT_RUNFROMSDRAM is not set +# CONFIG_BOOT_COPYTORAM is not set + +# +# Boot Memory Configuration +# +CONFIG_RAM_START=0x20400000 +CONFIG_RAM_SIZE=393216 +# CONFIG_ARCH_HAVE_SDRAM is not set + +# +# Board Selection +# +CONFIG_ARCH_BOARD_SAMV71_XULT=y +# CONFIG_ARCH_BOARD_CUSTOM is not set +CONFIG_ARCH_BOARD="samv71-xult" + +# +# Common Board Options +# +CONFIG_ARCH_HAVE_LEDS=y +CONFIG_ARCH_LEDS=y +CONFIG_ARCH_HAVE_BUTTONS=y +CONFIG_ARCH_BUTTONS=y +CONFIG_ARCH_HAVE_IRQBUTTONS=y +CONFIG_ARCH_IRQBUTTONS=y + +# +# Board-Specific Options +# +# CONFIG_SAMV71XULT_MXTXPLND is not set +CONFIG_SAMV71XULT_CLICKSHIELD=y +CONFIG_SAMV71XULT_MB1_SPI=y +# CONFIG_SAMV71XULT_MB2_SPI is not set +CONFIG_SAMV71XULT_MB1_BEE=y +# CONFIG_SAMV71XULT_MB2_BEE is not set +# CONFIG_BOARD_CRASHDUMP is not set +CONFIG_LIB_BOARDCTL=y +# CONFIG_BOARDCTL_RESET is not set +# CONFIG_BOARDCTL_UNIQUEID is not set +# CONFIG_BOARDCTL_TSCTEST is not set +# CONFIG_BOARDCTL_GRAPHICS is not set +# CONFIG_BOARDCTL_IOCTL is not set + +# +# RTOS Features +# +CONFIG_DISABLE_OS_API=y +# CONFIG_DISABLE_POSIX_TIMERS is not set +# CONFIG_DISABLE_PTHREAD is not set +# CONFIG_DISABLE_SIGNALS is not set +# CONFIG_DISABLE_MQUEUE is not set +# CONFIG_DISABLE_ENVIRON is not set + +# +# Clocks and Timers +# +CONFIG_ARCH_HAVE_TICKLESS=y +# CONFIG_SCHED_TICKLESS is not set +CONFIG_USEC_PER_TICK=10000 +# CONFIG_SYSTEM_TIME64 is not set +# CONFIG_CLOCK_MONOTONIC is not set +# CONFIG_ARCH_HAVE_TIMEKEEPING is not set +# CONFIG_JULIAN_TIME is not set +CONFIG_START_YEAR=2017 +CONFIG_START_MONTH=7 +CONFIG_START_DAY=1 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_PREALLOC_WDOGS=32 +CONFIG_WDOG_INTRESERVE=4 +CONFIG_PREALLOC_TIMERS=4 + +# +# Tasks and Scheduling +# +# CONFIG_SPINLOCK is not set +# CONFIG_INIT_NONE is not set +CONFIG_INIT_ENTRYPOINT=y +# CONFIG_INIT_FILEPATH is not set +CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_RR_INTERVAL=200 +# CONFIG_SCHED_SPORADIC is not set +CONFIG_TASK_NAME_SIZE=31 +CONFIG_MAX_TASKS=16 +# CONFIG_SCHED_HAVE_PARENT is not set +CONFIG_SCHED_WAITPID=y + +# +# Pthread Options +# +# CONFIG_PTHREAD_MUTEX_TYPES is not set +CONFIG_PTHREAD_MUTEX_ROBUST=y +# CONFIG_PTHREAD_MUTEX_UNSAFE is not set +# CONFIG_PTHREAD_MUTEX_BOTH is not set +CONFIG_NPTHREAD_KEYS=4 +# CONFIG_PTHREAD_CLEANUP is not set +# CONFIG_CANCELLATION_POINTS is not set + +# +# Performance Monitoring +# +# CONFIG_SCHED_CPULOAD is not set +# CONFIG_SCHED_INSTRUMENTATION is not set + +# +# Files and I/O +# +CONFIG_DEV_CONSOLE=y +# CONFIG_FDCLONE_DISABLE is not set +# CONFIG_FDCLONE_STDIO is not set +CONFIG_SDCLONE_DISABLE=y +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NAME_MAX=32 +# CONFIG_PRIORITY_INHERITANCE is not set + +# +# RTOS hooks +# +CONFIG_BOARD_INITIALIZE=y +# CONFIG_BOARD_INITTHREAD is not set +# CONFIG_SCHED_STARTHOOK is not set +# CONFIG_SCHED_ATEXIT is not set +# CONFIG_SCHED_ONEXIT is not set +# CONFIG_SIG_EVTHREAD is not set + +# +# Signal Numbers +# +CONFIG_SIG_SIGUSR1=1 +CONFIG_SIG_SIGUSR2=2 +CONFIG_SIG_SIGALARM=3 +CONFIG_SIG_SIGCONDTIMEDOUT=16 +CONFIG_SIG_SIGWORK=17 + +# +# POSIX Message Queue Options +# +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_MQ_MAXMSGSIZE=32 +# CONFIG_MODULE is not set + +# +# Work queue support +# +CONFIG_SCHED_WORKQUEUE=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPRIORITY=224 +CONFIG_SCHED_HPWORKPERIOD=50000 +CONFIG_SCHED_HPWORKSTACKSIZE=2048 +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_LPNTHREADS=1 +CONFIG_SCHED_LPWORKPRIORITY=160 +CONFIG_SCHED_LPWORKPERIOD=50000 +CONFIG_SCHED_LPWORKSTACKSIZE=2048 + +# +# Stack and heap information +# +CONFIG_IDLETHREAD_STACKSIZE=1024 +CONFIG_USERMAIN_STACKSIZE=2048 +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_PTHREAD_STACK_DEFAULT=2048 +# CONFIG_LIB_SYSCALL is not set + +# +# Device Drivers +# +CONFIG_DISABLE_POLL=y +CONFIG_DEV_NULL=y +# CONFIG_DEV_ZERO is not set +# CONFIG_DEV_URANDOM is not set +# CONFIG_DEV_LOOP is not set + +# +# Buffering +# +# CONFIG_DRVR_WRITEBUFFER is not set +# CONFIG_DRVR_READAHEAD is not set +# CONFIG_RAMDISK is not set +# CONFIG_CAN is not set +# CONFIG_ARCH_HAVE_PWM_PULSECOUNT is not set +# CONFIG_ARCH_HAVE_PWM_MULTICHAN is not set +# CONFIG_PWM is not set +CONFIG_ARCH_HAVE_I2CRESET=y +CONFIG_I2C=y +# CONFIG_I2C_SLAVE is not set +# CONFIG_I2C_POLLED is not set +# CONFIG_I2C_RESET is not set +# CONFIG_I2C_TRACE is not set +# CONFIG_I2C_DRIVER is not set +# CONFIG_ARCH_HAVE_SPI_CRCGENERATION is not set +CONFIG_ARCH_HAVE_SPI_CS_CONTROL=y +# CONFIG_ARCH_HAVE_SPI_BITORDER is not set +CONFIG_SPI=y +# CONFIG_SPI_SLAVE is not set +CONFIG_SPI_EXCHANGE=y +# CONFIG_SPI_CMDDATA is not set +CONFIG_SPI_CALLBACK=y +# CONFIG_SPI_HWFEATURES is not set +# CONFIG_SPI_CS_CONTROL is not set +# CONFIG_SPI_CS_DELAY_CONTROL is not set +# CONFIG_SPI_DRIVER is not set +# CONFIG_SPI_BITBANG is not set +# CONFIG_I2S is not set + +# +# Timer Driver Support +# +# CONFIG_TIMER is not set +# CONFIG_ONESHOT is not set +# CONFIG_RTC is not set +# CONFIG_WATCHDOG is not set +# CONFIG_TIMERS_CS2100CP is not set +# CONFIG_ANALOG is not set +# CONFIG_AUDIO_DEVICES is not set +# CONFIG_VIDEO_DEVICES is not set +# CONFIG_BCH is not set +# CONFIG_INPUT is not set + +# +# IO Expander/GPIO Support +# +# CONFIG_IOEXPANDER is not set +# CONFIG_DEV_GPIO is not set + +# +# LCD Driver Support +# +# CONFIG_LCD is not set +# CONFIG_SLCD is not set + +# +# LED Support +# +# CONFIG_USERLED is not set +# CONFIG_RGBLED is not set +# CONFIG_PCA9635PW is not set +# CONFIG_NCP5623C is not set +CONFIG_MMCSD=y +CONFIG_MMCSD_NSLOTS=1 +# CONFIG_MMCSD_READONLY is not set +CONFIG_MMCSD_MULTIBLOCK_DISABLE=y +CONFIG_MMCSD_MMCSUPPORT=y +CONFIG_MMCSD_HAVECARDDETECT=y +CONFIG_MMCSD_SPI=y +CONFIG_MMCSD_SPICLOCK=20000000 +CONFIG_MMCSD_SPIMODE=0 +CONFIG_ARCH_HAVE_SDIO=y +CONFIG_SDIO_DMA=y +# CONFIG_ARCH_HAVE_SDIOWAIT_WRCOMPLETE is not set +CONFIG_MMCSD_SDIO=y +# CONFIG_SDIO_PREFLIGHT is not set +# CONFIG_SDIO_MUXBUS is not set +# CONFIG_SDIO_WIDTH_D1_ONLY is not set +CONFIG_SDIO_BLOCKSETUP=y +# CONFIG_MODEM is not set +CONFIG_MTD=y + +# +# MTD Configuration +# +# CONFIG_MTD_PARTITION is not set +# CONFIG_MTD_SECT512 is not set +# CONFIG_MTD_BYTE_WRITE is not set +# CONFIG_MTD_PROGMEM is not set +CONFIG_MTD_CONFIG=y +# CONFIG_MTD_CONFIG_RAM_CONSOLIDATE is not set +CONFIG_MTD_CONFIG_ERASEDVALUE=0xff + +# +# MTD Device Drivers +# +# CONFIG_MTD_NAND is not set +# CONFIG_RAMMTD is not set +# CONFIG_FILEMTD is not set +CONFIG_MTD_AT24XX=y +# CONFIG_AT24XX_MULTI is not set +CONFIG_AT24XX_SIZE=2 +CONFIG_AT24XX_ADDR=0x57 +CONFIG_AT24XX_EXTENDED=y +CONFIG_AT24XX_EXTSIZE=160 +CONFIG_AT24XX_FREQUENCY=100000 +CONFIG_MTD_AT25=y +CONFIG_AT25_SPIMODE=0 +CONFIG_AT25_SPIFREQUENCY=20000000 +# CONFIG_MTD_AT45DB is not set +# CONFIG_MTD_IS25XP is not set +# CONFIG_MTD_M25P is not set +# CONFIG_MTD_MX25L is not set +# CONFIG_MTD_S25FL1 is not set +# CONFIG_MTD_N25QXXX is not set +# CONFIG_MTD_SMART is not set +# CONFIG_MTD_RAMTRON is not set +# CONFIG_MTD_SST25 is not set +# CONFIG_MTD_SST25XX is not set +# CONFIG_MTD_SST26 is not set +# CONFIG_MTD_SST39FV is not set +# CONFIG_MTD_W25 is not set +# CONFIG_EEPROM is not set +CONFIG_NETDEVICES=y + +# +# General Ethernet MAC Driver Options +# +# CONFIG_NETDEV_LOOPBACK is not set +CONFIG_NETDEV_TELNET=y +CONFIG_TELNET_RXBUFFER_SIZE=256 +CONFIG_TELNET_TXBUFFER_SIZE=256 +CONFIG_NETDEV_MULTINIC=y +CONFIG_ARCH_HAVE_NETDEV_STATISTICS=y +CONFIG_NETDEV_STATISTICS=y +CONFIG_NETDEV_LATEINIT=y + +# +# External Ethernet MAC Device Support +# +# CONFIG_NET_DM90x0 is not set +# CONFIG_ENC28J60 is not set +# CONFIG_ENCX24J600 is not set +# CONFIG_NET_SLIP is not set +# CONFIG_NET_FTMAC100 is not set + +# +# External Ethernet PHY Device Support +# +CONFIG_ARCH_PHY_INTERRUPT=y +# CONFIG_ETH0_PHY_NONE is not set +# CONFIG_ETH0_PHY_AM79C874 is not set +# CONFIG_ETH0_PHY_KS8721 is not set +# CONFIG_ETH0_PHY_KSZ8041 is not set +# CONFIG_ETH0_PHY_KSZ8051 is not set +# CONFIG_ETH0_PHY_KSZ8061 is not set +CONFIG_ETH0_PHY_KSZ8081=y +# CONFIG_ETH0_PHY_KSZ90x1 is not set +# CONFIG_ETH0_PHY_DP83848C is not set +# CONFIG_ETH0_PHY_LAN8720 is not set +# CONFIG_ETH0_PHY_LAN8740 is not set +# CONFIG_ETH0_PHY_LAN8740A is not set +# CONFIG_ETH0_PHY_LAN8742A is not set +# CONFIG_ETH0_PHY_DM9161 is not set +CONFIG_ETH1_PHY_NONE=y +# CONFIG_ETH1_PHY_AM79C874 is not set +# CONFIG_ETH1_PHY_KS8721 is not set +# CONFIG_ETH1_PHY_KSZ8041 is not set +# CONFIG_ETH1_PHY_KSZ8051 is not set +# CONFIG_ETH1_PHY_KSZ8081 is not set +# CONFIG_ETH1_PHY_KSZ90x1 is not set +# CONFIG_ETH1_PHY_DP83848C is not set +# CONFIG_ETH1_PHY_LAN8720 is not set +# CONFIG_ETH1_PHY_DM9161 is not set +# CONFIG_PIPES is not set +# CONFIG_PM is not set +# CONFIG_POWER is not set +# CONFIG_SENSORS is not set +CONFIG_SERIAL=y +# CONFIG_DEV_LOWCONSOLE is not set +# CONFIG_SERIAL_REMOVABLE is not set +CONFIG_SERIAL_CONSOLE=y +# CONFIG_16550_UART is not set +# CONFIG_UART_SERIALDRIVER is not set +# CONFIG_UART0_SERIALDRIVER is not set +# CONFIG_UART1_SERIALDRIVER is not set +# CONFIG_UART2_SERIALDRIVER is not set +# CONFIG_UART3_SERIALDRIVER is not set +# CONFIG_UART4_SERIALDRIVER is not set +# CONFIG_UART5_SERIALDRIVER is not set +# CONFIG_UART6_SERIALDRIVER is not set +# CONFIG_UART7_SERIALDRIVER is not set +# CONFIG_UART8_SERIALDRIVER is not set +# CONFIG_SCI0_SERIALDRIVER is not set +# CONFIG_SCI1_SERIALDRIVER is not set +# CONFIG_USART0_SERIALDRIVER is not set +CONFIG_USART1_SERIALDRIVER=y +# CONFIG_USART2_SERIALDRIVER is not set +# CONFIG_USART3_SERIALDRIVER is not set +# CONFIG_USART4_SERIALDRIVER is not set +# CONFIG_USART5_SERIALDRIVER is not set +# CONFIG_USART6_SERIALDRIVER is not set +# CONFIG_USART7_SERIALDRIVER is not set +# CONFIG_USART8_SERIALDRIVER is not set +# CONFIG_OTHER_UART_SERIALDRIVER is not set +CONFIG_MCU_SERIAL=y +CONFIG_STANDARD_SERIAL=y +# CONFIG_SERIAL_IFLOWCONTROL is not set +# CONFIG_SERIAL_OFLOWCONTROL is not set +# CONFIG_SERIAL_DMA is not set +CONFIG_ARCH_HAVE_SERIAL_TERMIOS=y +CONFIG_USART1_SERIAL_CONSOLE=y +# CONFIG_OTHER_SERIAL_CONSOLE is not set +# CONFIG_NO_SERIAL_CONSOLE is not set + +# +# USART1 Configuration +# +CONFIG_USART1_RXBUFSIZE=256 +CONFIG_USART1_TXBUFSIZE=256 +CONFIG_USART1_BAUD=115200 +CONFIG_USART1_BITS=8 +CONFIG_USART1_PARITY=0 +CONFIG_USART1_2STOP=0 +# CONFIG_USART1_IFLOWCONTROL is not set +# CONFIG_USART1_OFLOWCONTROL is not set +# CONFIG_USART1_DMA is not set +# CONFIG_PSEUDOTERM is not set +# CONFIG_USBDEV is not set +# CONFIG_USBHOST is not set +# CONFIG_USBMISC is not set +# CONFIG_HAVE_USBTRACE is not set +CONFIG_DRIVERS_WIRELESS=y +# CONFIG_WL_CC1101 is not set +# CONFIG_WL_CC3000 is not set +CONFIG_DRIVERS_IEEE802154=y +CONFIG_IEEE802154_MRF24J40=y +# CONFIG_IEEE802154_AT86RF233 is not set +# CONFIG_DRIVERS_IEEE80211 is not set +# CONFIG_WL_NRF24L01 is not set +# CONFIG_DRIVERS_CONTACTLESS is not set + +# +# System Logging +# +# CONFIG_ARCH_SYSLOG is not set +# CONFIG_SYSLOG_WRITE is not set +CONFIG_RAMLOG=y +# CONFIG_RAMLOG_CONSOLE is not set +CONFIG_RAMLOG_BUFSIZE=8192 +# CONFIG_RAMLOG_CRLF is not set +CONFIG_RAMLOG_NONBLOCKING=y +# CONFIG_SYSLOG_INTBUFFER is not set +# CONFIG_SYSLOG_TIMESTAMP is not set +# CONFIG_SYSLOG_SERIAL_CONSOLE is not set +# CONFIG_SYSLOG_CHAR is not set +CONFIG_RAMLOG_SYSLOG=y +# CONFIG_SYSLOG_CONSOLE is not set +# CONFIG_SYSLOG_NONE is not set +# CONFIG_SYSLOG_FILE is not set +# CONFIG_CONSOLE_SYSLOG is not set +# CONFIG_SYSLOG_CHARDEV is not set + +# +# Networking Support +# +CONFIG_ARCH_HAVE_NET=y +CONFIG_ARCH_HAVE_PHY=y +CONFIG_NET=y +# CONFIG_NET_PROMISCUOUS is not set + +# +# Driver buffer configuration +# +CONFIG_NET_ETH_MTU=590 +CONFIG_NET_ETH_TCP_RECVWNDO=536 +CONFIG_NET_GUARDSIZE=2 + +# +# Data link support +# +CONFIG_NET_MULTILINK=y +CONFIG_NET_ETHERNET=y +CONFIG_NET_6LOWPAN=y +# CONFIG_NET_LOOPBACK is not set +# CONFIG_NET_TUN is not set +# CONFIG_NET_USRSOCK is not set + +# +# Network Device Operations +# +CONFIG_NETDEV_IOCTL=y +CONFIG_NETDEV_PHY_IOCTL=y +CONFIG_NETDEV_WIRELESS_IOCTL=y + +# +# Internet Protocol Selection +# +# CONFIG_NET_IPv4 is not set +CONFIG_NET_IPv6=y +CONFIG_NET_IPv6_NCONF_ENTRIES=8 + +# +# 6LoWPAN Configuration +# +CONFIG_NET_6LOWPAN_FRAG=y +CONFIG_NET_6LOWPAN_FRAMELEN=127 +# CONFIG_NET_6LOWPAN_COMPRESSION_IPv6 is not set +# CONFIG_NET_6LOWPAN_COMPRESSION_HC1 is not set +CONFIG_NET_6LOWPAN_COMPRESSION_HC06=y +CONFIG_NET_6LOWPAN_COMPRESSION_THRESHOLD=63 +CONFIG_NET_6LOWPAN_MAXADDRCONTEXT=1 +CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_0=0xaa +CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_1=0xaa +# CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREINIT_1 is not set +# CONFIG_NET_6LOWPAN_EXTENDEDADDR is not set +CONFIG_NET_6LOWPAN_MAXAGE=20 +CONFIG_NET_6LOWPAN_MAX_MACTRANSMITS=4 +CONFIG_NET_6LOWPAN_MTU=1294 +CONFIG_NET_6LOWPAN_TCP_RECVWNDO=1220 +CONFIG_NET_IPFORWARD=y + +# +# Socket Support +# +CONFIG_NSOCKET_DESCRIPTORS=8 +CONFIG_NET_NACTIVESOCKETS=16 +CONFIG_NET_SOCKOPTS=y +# CONFIG_NET_SOLINGER is not set + +# +# Raw Socket Support +# +# CONFIG_NET_PKT is not set + +# +# Unix Domain Socket Support +# +# CONFIG_NET_LOCAL is not set + +# +# TCP/IP Networking +# +CONFIG_NET_TCP=y +# CONFIG_NET_TCP_NO_STACK is not set +# CONFIG_NET_TCPURGDATA is not set +CONFIG_NET_TCP_CONNS=8 +CONFIG_NET_MAX_LISTENPORTS=20 +CONFIG_NET_TCP_READAHEAD=y +CONFIG_NET_TCP_WRITE_BUFFERS=y +CONFIG_NET_TCP_NWRBCHAINS=8 +CONFIG_NET_TCP_RECVDELAY=0 +CONFIG_NET_TCPBACKLOG=y +# CONFIG_NET_SENDFILE is not set + +# +# UDP Networking +# +CONFIG_NET_UDP=y +# CONFIG_NET_UDP_NO_STACK is not set +CONFIG_NET_UDP_CHECKSUMS=y +CONFIG_NET_UDP_CONNS=8 +CONFIG_NET_BROADCAST=y +# CONFIG_NET_RXAVAIL is not set +CONFIG_NET_UDP_READAHEAD=y + +# +# ICMPv6 Networking Support +# +CONFIG_NET_ICMPv6=y +CONFIG_NET_ICMPv6_PING=y +CONFIG_NET_ICMPv6_NEIGHBOR=y +CONFIG_ICMPv6_NEIGHBOR_MAXTRIES=5 +CONFIG_ICMPv6_NEIGHBOR_DELAYMSEC=20 +# CONFIG_NET_ICMPv6_AUTOCONF is not set +# CONFIG_NET_ICMPv6_ROUTER is not set + +# +# IGMPv2 Client Support +# +# CONFIG_NET_IGMP is not set + +# +# ARP Configuration +# + +# +# User-space networking stack API +# +# CONFIG_NET_ARCH_INCR32 is not set +# CONFIG_NET_ARCH_CHKSUM is not set +CONFIG_NET_STATISTICS=y +CONFIG_NET_HAVE_STAR=y + +# +# Network Topologies +# +CONFIG_NET_STAR=y +# CONFIG_NET_STARPOINT is not set +CONFIG_NET_STARHUB=y + +# +# Routing Table Configuration +# +# CONFIG_NET_ROUTE is not set +CONFIG_NET_HOSTNAME="MRF24J40-Hub" + +# +# Crypto API +# +# CONFIG_CRYPTO is not set + +# +# File Systems +# + +# +# File system configuration +# +# CONFIG_DISABLE_MOUNTPOINT is not set +# CONFIG_FS_AUTOMOUNTER is not set +# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set +# CONFIG_PSEUDOFS_SOFTLINKS is not set +CONFIG_FS_READABLE=y +CONFIG_FS_WRITABLE=y +# CONFIG_FS_AIO is not set +# CONFIG_FS_NAMED_SEMAPHORES is not set +CONFIG_FS_MQUEUE_MPATH="/var/mqueue" +# CONFIG_FS_RAMMAP is not set +CONFIG_FS_FAT=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FAT_MAXFNAME=32 +# CONFIG_FS_FATTIME is not set +# CONFIG_FAT_FORCE_INDIRECT is not set +# CONFIG_FAT_DMAMEMORY is not set +# CONFIG_FAT_DIRECT_RETRY is not set +# CONFIG_FS_NXFFS is not set +# CONFIG_FS_ROMFS is not set +# CONFIG_FS_TMPFS is not set +# CONFIG_FS_SMARTFS is not set +# CONFIG_FS_BINFS is not set +CONFIG_FS_PROCFS=y +# CONFIG_FS_PROCFS_REGISTER is not set + +# +# Exclude individual procfs entries +# +# CONFIG_FS_PROCFS_EXCLUDE_PROCESS is not set +# CONFIG_FS_PROCFS_EXCLUDE_UPTIME is not set +# CONFIG_FS_PROCFS_EXCLUDE_MOUNTS is not set +# CONFIG_FS_PROCFS_EXCLUDE_NET is not set +# CONFIG_FS_PROCFS_EXCLUDE_MTD is not set +# CONFIG_FS_UNIONFS is not set + +# +# Graphics Support +# +# CONFIG_NX is not set + +# +# Memory Management +# +# CONFIG_MM_SMALL is not set +CONFIG_MM_REGIONS=1 +# CONFIG_ARCH_HAVE_HEAP2 is not set +# CONFIG_GRAN is not set + +# +# Common I/O Buffer Support +# +CONFIG_MM_IOB=y +CONFIG_IOB_NBUFFERS=32 +CONFIG_IOB_BUFSIZE=128 +CONFIG_IOB_NCHAINS=16 +CONFIG_IOB_THROTTLE=8 + +# +# Audio Support +# +# CONFIG_AUDIO is not set + +# +# Wireless Support +# +CONFIG_WIRELESS=y +CONFIG_WIRELESS_IEEE802154=y +CONFIG_IEEE802154_DEFAULT_EADDR=0x00fade00deadbeef +CONFIG_MAC802154_HPWORK=y +# CONFIG_MAC802154_LPWORK is not set +CONFIG_MAC802154_NTXDESC=32 +CONFIG_MAC802154_NNOTIF=48 +CONFIG_MAC802154_NPANDESC=5 +CONFIG_IEEE802154_IND_PREALLOC=32 +CONFIG_IEEE802154_IND_IRQRESERVE=10 +CONFIG_IEEE802154_MACDEV=y +CONFIG_IEEE802154_MACDEV_RECVRPRIO=0 +CONFIG_IEEE802154_NETDEV=y +CONFIG_IEEE802154_NETDEV_RECVRPRIO=1 +# CONFIG_IEEE802154_NETDEV_HPWORK is not set +CONFIG_IEEE802154_NETDEV_LPWORK=y +# CONFIG_IEEE802154_LOOPBACK is not set + +# +# Binary Loader +# +# CONFIG_BINFMT_DISABLE is not set +# CONFIG_BINFMT_EXEPATH is not set +# CONFIG_NXFLAT is not set +# CONFIG_ELF is not set +CONFIG_BUILTIN=y +# CONFIG_PIC is not set +# CONFIG_SYMTAB_ORDEREDBYNAME is not set + +# +# Library Routines +# + +# +# Standard C Library Options +# + +# +# Standard C I/O +# +# CONFIG_STDIO_DISABLE_BUFFERING is not set +CONFIG_STDIO_BUFFER_SIZE=64 +CONFIG_STDIO_LINEBUFFER=y +CONFIG_NUNGET_CHARS=2 +# CONFIG_NOPRINTF_FIELDWIDTH is not set +# CONFIG_LIBC_FLOATINGPOINT is not set +CONFIG_LIBC_LONG_LONG=y +# CONFIG_LIBC_SCANSET is not set +# CONFIG_EOL_IS_CR is not set +# CONFIG_EOL_IS_LF is not set +# CONFIG_EOL_IS_BOTH_CRLF is not set +CONFIG_EOL_IS_EITHER_CRLF=y +# CONFIG_MEMCPY_VIK is not set +# CONFIG_LIBM is not set + +# +# Architecture-Specific Support +# +CONFIG_ARCH_LOWPUTC=y +# CONFIG_ARCH_ROMGETC is not set +# CONFIG_LIBC_ARCH_MEMCPY is not set +# CONFIG_LIBC_ARCH_MEMCMP is not set +# CONFIG_LIBC_ARCH_MEMMOVE is not set +# CONFIG_LIBC_ARCH_MEMSET is not set +# CONFIG_LIBC_ARCH_STRCHR is not set +# CONFIG_LIBC_ARCH_STRCMP is not set +# CONFIG_LIBC_ARCH_STRCPY is not set +# CONFIG_LIBC_ARCH_STRNCPY is not set +# CONFIG_LIBC_ARCH_STRLEN is not set +# CONFIG_LIBC_ARCH_STRNLEN is not set +# CONFIG_LIBC_ARCH_ELF is not set +# CONFIG_ARMV7M_MEMCPY is not set + +# +# stdlib Options +# +CONFIG_LIB_RAND_ORDER=1 +CONFIG_LIB_HOMEDIR="/" +CONFIG_LIBC_TMPDIR="/tmp" +CONFIG_LIBC_MAX_TMPFILE=32 + +# +# Program Execution Options +# +# CONFIG_LIBC_EXECFUNCS is not set +CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=1024 +CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=2048 + +# +# errno Decode Support +# +# CONFIG_LIBC_STRERROR is not set +# CONFIG_LIBC_PERROR_STDOUT is not set + +# +# memcpy/memset Options +# +# CONFIG_MEMSET_OPTSPEED is not set +# CONFIG_LIBC_DLLFCN is not set +# CONFIG_LIBC_MODLIB is not set +# CONFIG_LIBC_WCHAR is not set +# CONFIG_LIBC_LOCALE is not set + +# +# Time/Time Zone Support +# +# CONFIG_LIBC_LOCALTIME is not set +# CONFIG_TIME_EXTENDED is not set +CONFIG_ARCH_HAVE_TLS=y + +# +# Thread Local Storage (TLS) +# +# CONFIG_TLS is not set + +# +# Network-Related Options +# +# CONFIG_LIBC_IPv4_ADDRCONV is not set +CONFIG_LIBC_NETDB=y + +# +# NETDB Support +# +# CONFIG_NETDB_HOSTFILE is not set +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDB_DNSCLIENT_ENTRIES=8 +CONFIG_NETDB_DNSCLIENT_NAMESIZE=32 +CONFIG_NETDB_DNSCLIENT_LIFESEC=3600 +CONFIG_NETDB_DNSCLIENT_MAXRESPONSE=96 +# CONFIG_NETDB_RESOLVCONF is not set +CONFIG_NETDB_DNSSERVER_NOADDR=y +# CONFIG_NETDB_DNSSERVER_IPv6 is not set +# CONFIG_LIBC_IOCTL_VARIADIC is not set +CONFIG_LIB_SENDFILE_BUFSIZE=512 + +# +# Non-standard Library Support +# +# CONFIG_LIB_CRC64_FAST is not set +# CONFIG_LIB_KBDCODEC is not set +# CONFIG_LIB_SLCDCODEC is not set +# CONFIG_LIB_HEX2BIN is not set + +# +# Basic CXX Support +# +# CONFIG_C99_BOOL8 is not set +CONFIG_HAVE_CXX=y +# CONFIG_CXX_NEWLONG is not set + +# +# LLVM C++ Library (libcxx) +# +# CONFIG_LIBCXX is not set + +# +# uClibc++ Standard C++ Library +# +# CONFIG_UCLIBCXX is not set + +# +# Application Configuration +# + +# +# Built-In Applications +# +CONFIG_BUILTIN_PROXY_STACKSIZE=1024 + +# +# CAN Utilities +# + +# +# Examples +# +# CONFIG_EXAMPLES_BUTTONS is not set +# CONFIG_EXAMPLES_CCTYPE is not set +# CONFIG_EXAMPLES_CHAT is not set +# CONFIG_EXAMPLES_CONFIGDATA is not set +# CONFIG_EXAMPLES_CXXTEST is not set +# CONFIG_EXAMPLES_DHCPD is not set +# CONFIG_EXAMPLES_DISCOVER is not set +# CONFIG_EXAMPLES_ELF is not set +# CONFIG_EXAMPLES_FSTEST is not set +# CONFIG_EXAMPLES_FTPC is not set +# CONFIG_EXAMPLES_FTPD is not set +# CONFIG_EXAMPLES_HELLO is not set +# CONFIG_EXAMPLES_HELLOXX is not set +# CONFIG_EXAMPLES_HIDKBD is not set +# CONFIG_EXAMPLES_IGMP is not set +# CONFIG_EXAMPLES_JSON is not set +# CONFIG_EXAMPLES_KEYPADTEST is not set +# CONFIG_EXAMPLES_MEDIA is not set +# CONFIG_EXAMPLES_MM is not set +# CONFIG_EXAMPLES_MODBUS is not set +# CONFIG_EXAMPLES_MOUNT is not set +# CONFIG_EXAMPLES_NETTEST is not set +# CONFIG_EXAMPLES_NRF24L01TERM is not set +CONFIG_EXAMPLES_NSH=y +CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y +# CONFIG_EXAMPLES_NULL is not set +# CONFIG_EXAMPLES_NX is not set +# CONFIG_EXAMPLES_NXFFS is not set +# CONFIG_EXAMPLES_NXHELLO is not set +# CONFIG_EXAMPLES_NXIMAGE is not set +# CONFIG_EXAMPLES_NXLINES is not set +# CONFIG_EXAMPLES_NXTERM is not set +# CONFIG_EXAMPLES_NXTEXT is not set +# CONFIG_EXAMPLES_OSTEST is not set +# CONFIG_EXAMPLES_PCA9635 is not set +# CONFIG_EXAMPLES_POSIXSPAWN is not set +# CONFIG_EXAMPLES_PPPD is not set +# CONFIG_EXAMPLES_RFID_READUID is not set +# CONFIG_EXAMPLES_RGBLED is not set +# CONFIG_EXAMPLES_SENDMAIL is not set +# CONFIG_EXAMPLES_SERIALBLASTER is not set +# CONFIG_EXAMPLES_SERIALRX is not set +# CONFIG_EXAMPLES_SERLOOP is not set +# CONFIG_EXAMPLES_SLCD is not set +# CONFIG_EXAMPLES_SMART is not set +# CONFIG_EXAMPLES_SMART_TEST is not set +# CONFIG_EXAMPLES_SMP is not set +# CONFIG_EXAMPLES_STAT is not set +# CONFIG_EXAMPLES_TCPECHO is not set +# CONFIG_EXAMPLES_TELNETD is not set +# CONFIG_EXAMPLES_TIFF is not set +# CONFIG_EXAMPLES_TOUCHSCREEN is not set +# CONFIG_EXAMPLES_UDP is not set +# CONFIG_EXAMPLES_UDPBLASTER is not set +# CONFIG_EXAMPLES_USBSERIAL is not set +# CONFIG_EXAMPLES_WATCHDOG is not set +# CONFIG_EXAMPLES_WEBSERVER is not set +# CONFIG_EXAMPLES_XBC_TEST is not set + +# +# File System Utilities +# +# CONFIG_FSUTILS_FLASH_ERASEALL is not set +# CONFIG_FSUTILS_INIFILE is not set +# CONFIG_FSUTILS_PASSWD is not set + +# +# GPS Utilities +# +# CONFIG_GPSUTILS_MINMEA_LIB is not set + +# +# Graphics Support +# +# CONFIG_TIFF is not set +# CONFIG_GRAPHICS_TRAVELER is not set + +# +# Interpreters +# +# CONFIG_INTERPRETERS_BAS is not set +# CONFIG_INTERPRETERS_FICL is not set +# CONFIG_INTERPRETERS_MICROPYTHON is not set +# CONFIG_INTERPRETERS_MINIBASIC is not set +# CONFIG_INTERPRETERS_PCODE is not set + +# +# FreeModBus +# +# CONFIG_MODBUS is not set + +# +# Network Utilities +# +# CONFIG_NETUTILS_CODECS is not set +# CONFIG_NETUTILS_DISCOVER is not set +# CONFIG_NETUTILS_ESP8266 is not set +# CONFIG_NETUTILS_FTPC is not set +# CONFIG_NETUTILS_JSON is not set +CONFIG_NETUTILS_NETLIB=y +# CONFIG_NETUTILS_NTPCLIENT is not set +# CONFIG_NETUTILS_PPPD is not set +# CONFIG_NETUTILS_SMTP is not set +CONFIG_NETUTILS_TELNETC=y +CONFIG_NETUTILS_TELNETD=y +CONFIG_NETUTILS_TFTPC=y +CONFIG_NETUTILS_WEBCLIENT=y +CONFIG_NSH_WGET_USERAGENT="NuttX/6.xx.x (; http://www.nuttx.org/)" +CONFIG_WEBCLIENT_TIMEOUT=10 +# CONFIG_NETUTILS_WEBSERVER is not set +# CONFIG_NETUTILS_XMLRPC is not set + +# +# NSH Library +# +CONFIG_NSH_LIBRARY=y +# CONFIG_NSH_MOTD is not set + +# +# Command Line Configuration +# +CONFIG_NSH_READLINE=y +# CONFIG_NSH_CLE is not set +CONFIG_NSH_LINELEN=64 +# CONFIG_NSH_DISABLE_SEMICOLON is not set +CONFIG_NSH_CMDPARMS=y +CONFIG_NSH_MAXARGUMENTS=6 +CONFIG_NSH_ARGCAT=y +CONFIG_NSH_NESTDEPTH=3 +# CONFIG_NSH_DISABLEBG is not set +CONFIG_NSH_BUILTIN_APPS=y + +# +# Disable Individual commands +# +# CONFIG_NSH_DISABLE_ADDROUTE is not set +# CONFIG_NSH_DISABLE_BASENAME is not set +# CONFIG_NSH_DISABLE_CAT is not set +# CONFIG_NSH_DISABLE_CD is not set +# CONFIG_NSH_DISABLE_CP is not set +# CONFIG_NSH_DISABLE_CMP is not set +CONFIG_NSH_DISABLE_DATE=y +# CONFIG_NSH_DISABLE_DD is not set +# CONFIG_NSH_DISABLE_DF is not set +# CONFIG_NSH_DISABLE_DELROUTE is not set +# CONFIG_NSH_DISABLE_DIRNAME is not set +# CONFIG_NSH_DISABLE_ECHO is not set +# CONFIG_NSH_DISABLE_EXEC is not set +# CONFIG_NSH_DISABLE_EXIT is not set +# CONFIG_NSH_DISABLE_FREE is not set +CONFIG_NSH_DISABLE_GET=y +# CONFIG_NSH_DISABLE_HELP is not set +# CONFIG_NSH_DISABLE_HEXDUMP is not set +# CONFIG_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_IFUPDOWN is not set +# CONFIG_NSH_DISABLE_KILL is not set +# CONFIG_NSH_DISABLE_LOSETUP is not set +CONFIG_NSH_DISABLE_LOSMART=y +# CONFIG_NSH_DISABLE_LS is not set +# CONFIG_NSH_DISABLE_MB is not set +# CONFIG_NSH_DISABLE_MKDIR is not set +# CONFIG_NSH_DISABLE_MKFATFS is not set +# CONFIG_NSH_DISABLE_MKRD is not set +# CONFIG_NSH_DISABLE_MH is not set +# CONFIG_NSH_DISABLE_MOUNT is not set +# CONFIG_NSH_DISABLE_MV is not set +# CONFIG_NSH_DISABLE_MW is not set +# CONFIG_NSH_DISABLE_NSLOOKUP is not set +CONFIG_NSH_DISABLE_PRINTF=y +# CONFIG_NSH_DISABLE_PS is not set +CONFIG_NSH_DISABLE_PUT=y +# CONFIG_NSH_DISABLE_PWD is not set +# CONFIG_NSH_DISABLE_RM is not set +# CONFIG_NSH_DISABLE_RMDIR is not set +# CONFIG_NSH_DISABLE_SET is not set +# CONFIG_NSH_DISABLE_SH is not set +# CONFIG_NSH_DISABLE_SLEEP is not set +# CONFIG_NSH_DISABLE_TIME is not set +# CONFIG_NSH_DISABLE_TEST is not set +CONFIG_NSH_DISABLE_TELNETD=y +# CONFIG_NSH_DISABLE_UMOUNT is not set +# CONFIG_NSH_DISABLE_UNAME is not set +# CONFIG_NSH_DISABLE_UNSET is not set +# CONFIG_NSH_DISABLE_USLEEP is not set +CONFIG_NSH_DISABLE_WGET=y +# CONFIG_NSH_DISABLE_XD is not set +CONFIG_NSH_MMCSDMINOR=0 +CONFIG_NSH_MMCSDSLOTNO=0 +CONFIG_NSH_MMCSDSPIPORTNO=0 + +# +# Configure Command Options +# +CONFIG_NSH_CMDOPT_DF_H=y +# CONFIG_NSH_CMDOPT_DD_STATS is not set +CONFIG_NSH_CODECS_BUFSIZE=128 +CONFIG_NSH_CMDOPT_HEXDUMP=y +CONFIG_NSH_PROC_MOUNTPOINT="/proc" +CONFIG_NSH_FILEIOSIZE=512 + +# +# Scripting Support +# +# CONFIG_NSH_DISABLESCRIPT is not set +# CONFIG_NSH_DISABLE_ITEF is not set +# CONFIG_NSH_DISABLE_LOOPS is not set + +# +# Console Configuration +# +CONFIG_NSH_CONSOLE=y +CONFIG_NSH_ARCHINIT=y + +# +# Networking Configuration +# +CONFIG_NSH_NETINIT=y +CONFIG_NSH_NETLOCAL=y + +# +# IP Address Configuration +# + +# +# Target IPv6 address +# +CONFIG_NSH_IPv6ADDR_1=0xfc00 +CONFIG_NSH_IPv6ADDR_2=0x0000 +CONFIG_NSH_IPv6ADDR_3=0x0000 +CONFIG_NSH_IPv6ADDR_4=0x0000 +CONFIG_NSH_IPv6ADDR_5=0x0000 +CONFIG_NSH_IPv6ADDR_6=0x0000 +CONFIG_NSH_IPv6ADDR_7=0x0000 +CONFIG_NSH_IPv6ADDR_8=0x0002 + +# +# Router IPv6 address +# +CONFIG_NSH_DRIPv6ADDR_1=0xfc00 +CONFIG_NSH_DRIPv6ADDR_2=0x0000 +CONFIG_NSH_DRIPv6ADDR_3=0x0000 +CONFIG_NSH_DRIPv6ADDR_4=0x0000 +CONFIG_NSH_DRIPv6ADDR_5=0x0000 +CONFIG_NSH_DRIPv6ADDR_6=0x0000 +CONFIG_NSH_DRIPv6ADDR_7=0x0000 +CONFIG_NSH_DRIPv6ADDR_8=0x0001 + +# +# IPv6 Network mask +# +CONFIG_NSH_IPv6NETMASK_1=0xffff +CONFIG_NSH_IPv6NETMASK_2=0xffff +CONFIG_NSH_IPv6NETMASK_3=0xffff +CONFIG_NSH_IPv6NETMASK_4=0xffff +CONFIG_NSH_IPv6NETMASK_5=0xffff +CONFIG_NSH_IPv6NETMASK_6=0xffff +CONFIG_NSH_IPv6NETMASK_7=0xffff +CONFIG_NSH_IPv6NETMASK_8=0x0000 +# CONFIG_NSH_DNS is not set +CONFIG_NSH_NOMAC=y +CONFIG_NSH_SWMAC=y +CONFIG_NSH_MACADDR=0x00fade00deadbeef +CONFIG_NSH_MAX_ROUNDTRIP=20 + +# +# Telnet Configuration +# +CONFIG_NSH_TELNET=y +CONFIG_NSH_TELNETD_PORT=23 +CONFIG_NSH_TELNETD_DAEMONPRIO=100 +CONFIG_NSH_TELNETD_DAEMONSTACKSIZE=2048 +CONFIG_NSH_TELNETD_CLIENTPRIO=100 +CONFIG_NSH_TELNETD_CLIENTSTACKSIZE=2048 +CONFIG_NSH_IOBUFFER_SIZE=512 +# CONFIG_NSH_LOGIN is not set +# CONFIG_NSH_CONSOLE_LOGIN is not set +# CONFIG_NSH_TELNET_LOGIN is not set + +# +# NxWidgets/NxWM +# + +# +# Platform-specific Support +# +# CONFIG_PLATFORM_CONFIGDATA is not set +CONFIG_HAVE_CXXINITIALIZE=y + +# +# System Libraries and NSH Add-Ons +# +# CONFIG_SYSTEM_CLE is not set +# CONFIG_SYSTEM_CUTERM is not set +# CONFIG_SYSTEM_FLASH_ERASEALL is not set +# CONFIG_SYSTEM_FREE is not set +# CONFIG_SYSTEM_HEX2BIN is not set +# CONFIG_SYSTEM_HEXED is not set +# CONFIG_SYSTEM_I2CTOOL is not set +# CONFIG_SYSTEM_INSTALL is not set +# CONFIG_SYSTEM_MDIO is not set +# CONFIG_SYSTEM_NETDB is not set +# CONFIG_SYSTEM_NTPC is not set +# CONFIG_SYSTEM_RAMTEST is not set +CONFIG_READLINE_HAVE_EXTMATCH=y +CONFIG_SYSTEM_READLINE=y +CONFIG_READLINE_ECHO=y +# CONFIG_READLINE_TABCOMPLETION is not set +# CONFIG_READLINE_CMD_HISTORY is not set +# CONFIG_SYSTEM_SUDOKU is not set +# CONFIG_SYSTEM_SYSTEM is not set +# CONFIG_SYSTEM_TEE is not set +# CONFIG_SYSTEM_UBLOXMODEM is not set +# CONFIG_SYSTEM_VI is not set +# CONFIG_SYSTEM_ZMODEM is not set + +# +# Wireless Libraries and NSH Add-Ons +# + +# +# IEEE 802.15.4 applications +# +CONFIG_IEEE802154_LIBMAC=y +CONFIG_IEEE802154_LIBUTILS=y +CONFIG_IEEE802154_I8SAK=y +CONFIG_IEEE802154_I8SAK_PRIORITY=100 +CONFIG_IEEE802154_I8SAK_STACKSIZE=2048 +# CONFIG_WIRELESS_IWPAN is not set diff --git a/configs/samv71-xult/src/Makefile b/configs/samv71-xult/src/Makefile index 790601ecda9..37371c8a12d 100644 --- a/configs/samv71-xult/src/Makefile +++ b/configs/samv71-xult/src/Makefile @@ -1,7 +1,7 @@ ############################################################################ # configs/samv71-xult/src/Makefile # -# Copyright (C) 2015-2016 Gregory Nutt. All rights reserved. +# Copyright (C) 2015-2017 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -115,4 +115,8 @@ CSRCS += sam_maxtouch.c sam_atmxtconfig.c endif endif +ifeq ($(CONFIG_IEEE802154_MRF24J40),y) +CSRCS += sam_mrf24j40.c +endif + include $(TOPDIR)/configs/Board.mk diff --git a/configs/samv71-xult/src/sam_autoleds.c b/configs/samv71-xult/src/sam_autoleds.c index a528c1db6ef..0410d032cae 100644 --- a/configs/samv71-xult/src/sam_autoleds.c +++ b/configs/samv71-xult/src/sam_autoleds.c @@ -41,7 +41,7 @@ * * ------ ----------- --------------------- * SAMV71 Function Shared functionality - * PIO + * GPIO * ------ ----------- --------------------- * PA23 Yellow LED0 EDBG GPIO * PC09 Yellow LED1 LCD, and Shield @@ -103,7 +103,7 @@ void board_autoled_initialize(void) { - /* Configure LED PIOs for output */ + /* Configure LED GPIOs for output */ sam_configgpio(GPIO_LED0); sam_configgpio(GPIO_LED1); diff --git a/configs/samv71-xult/src/sam_buttons.c b/configs/samv71-xult/src/sam_buttons.c index adcd280d73f..b78265a7788 100644 --- a/configs/samv71-xult/src/sam_buttons.c +++ b/configs/samv71-xult/src/sam_buttons.c @@ -146,7 +146,7 @@ void board_button_initialize(void) regval |= MATRIX_CCFG_SYSIO_SYSIO12; putreg32(regval, SAM_MATRIX_CCFG_SYSIO); - /* Configure button PIOs */ + /* Configure button GPIOs */ (void)sam_configgpio(GPIO_SW0); (void)sam_configgpio(GPIO_SW1); diff --git a/configs/samv71-xult/src/sam_hsmci.c b/configs/samv71-xult/src/sam_hsmci.c index 2835e64357c..2f4e5e90175 100644 --- a/configs/samv71-xult/src/sam_hsmci.c +++ b/configs/samv71-xult/src/sam_hsmci.c @@ -84,8 +84,8 @@ struct sam_hsmci_state_s { struct sdio_dev_s *hsmci; /* R/W device handle */ - gpio_pinset_t cdcfg; /* Card detect PIO pin configuration */ - gpio_pinset_t pwrcfg; /* Power PIO pin configuration */ + gpio_pinset_t cdcfg; /* Card detect GPIO pin configuration */ + gpio_pinset_t pwrcfg; /* Power GPIO pin configuration */ uint8_t irq; /* Interrupt number (same as pid) */ uint8_t slotno; /* Slot number */ bool cd; /* TRUE: card is inserted */ @@ -126,7 +126,7 @@ bool sam_cardinserted_internal(struct sam_hsmci_state_s *state) { bool inserted; - /* Get the state of the PIO pin */ + /* Get the state of the GPIO pin */ inserted = sam_gpioread(state->cdcfg); mcinfo("Slot %d inserted: %s\n", state->slotno, inserted ? "NO" : "YES"); @@ -189,7 +189,7 @@ static int sam_hsmci0_cardetect(int irq, void *regs, FAR void *arg) * Name: sam_hsmci_state * * Description: - * Initialize HSMCI PIOs. + * Initialize HSMCI GPIOs. * ****************************************************************************/ @@ -230,7 +230,7 @@ int sam_hsmci_initialize(int slotno, int minor) return -EINVAL; } - /* Initialize card-detect, write-protect, and power enable PIOs */ + /* Initialize card-detect, write-protect, and power enable GPIOs */ sam_configgpio(state->cdcfg); sam_dumpgpio(state->cdcfg, "HSMCI Card Detect"); @@ -297,7 +297,7 @@ bool sam_cardinserted(int slotno) return false; } - /* Return the state of the PIO pin */ + /* Return the state of the GPIO pin */ return sam_cardinserted_internal(state); } diff --git a/configs/samv71-xult/src/sam_maxtouch.c b/configs/samv71-xult/src/sam_maxtouch.c index 32e1cda60d3..e6e97de0e52 100644 --- a/configs/samv71-xult/src/sam_maxtouch.c +++ b/configs/samv71-xult/src/sam_maxtouch.c @@ -92,15 +92,15 @@ struct sama5d4ek_tscinfo_s * Private Function Prototypes ****************************************************************************/ -/* IRQ/PIO access callbacks. These operations all hidden behind - * callbacks to isolate the maXTouch driver from differences in PIO +/* IRQ/GPIO access callbacks. These operations all hidden behind + * callbacks to isolate the maXTouch driver from differences in GPIO * interrupt handling by varying boards and MCUs. If possible, * interrupts should be configured on both rising and falling edges * so that contact and loss-of-contact events can be detected. * - * attach - Attach the maXTouch interrupt handler to the PIO interrupt - * enable - Enable or disable the PIO interrupt - * clear - Acknowledge/clear any pending PIO interrupt + * attach - Attach the maXTouch interrupt handler to the GPIO interrupt + * enable - Enable or disable the GPIO interrupt + * clear - Acknowledge/clear any pending GPIO interrupt */ static int mxt_attach(FAR const struct mxt_lower_s *lower, mxt_handler_t isr, @@ -141,15 +141,15 @@ static struct sama5d4ek_tscinfo_s g_mxtinfo = ****************************************************************************/ /**************************************************************************** - * IRQ/PIO access callbacks. These operations all hidden behind - * callbacks to isolate the maXTouch driver from differences in PIO + * IRQ/GPIO access callbacks. These operations all hidden behind + * callbacks to isolate the maXTouch driver from differences in GPIO * interrupt handling by varying boards and MCUs. If possible, * interrupts should be configured on both rising and falling edges * so that contact and loss-of-contact events can be detected. * - * attach - Attach the maXTouch interrupt handler to the PIO interrupt - * enable - Enable or disable the PIO interrupt - * clear - Acknowledge/clear any pending PIO interrupt + * attach - Attach the maXTouch interrupt handler to the GPIO interrupt + * enable - Enable or disable the GPIO interrupt + * clear - Acknowledge/clear any pending GPIO interrupt * ****************************************************************************/ diff --git a/configs/samv71-xult/src/sam_mrf24j40.c b/configs/samv71-xult/src/sam_mrf24j40.c new file mode 100644 index 00000000000..ecaa44b643a --- /dev/null +++ b/configs/samv71-xult/src/sam_mrf24j40.c @@ -0,0 +1,323 @@ +/**************************************************************************** + * configs/samv71-xult/src/sam_mrf24j40.c + * + * Copyright (C) 2017 Gregory Nutt, All rights reserver + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "sam_gpio.h" +#include "sam_spi.h" + +#include "samv71-xult.h" + +#ifdef HAVE_MRF24J40 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct sam_priv_s +{ + struct mrf24j40_lower_s dev; + uint32_t intcfg; + uint8_t irq; + uint8_t spidev; +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/* IRQ/GPIO access callbacks. These operations all hidden behind callbacks + * to isolate the MRF24J40 driver from differences in GPIO interrupt handling + * varying boards and MCUs. + * + * irq_attach - Attach the MRF24J40 interrupt handler to the GPIO + interrupt + * irq_enable - Enable or disable the GPIO interrupt + */ + +static int sam_attach_irq(FAR const struct mrf24j40_lower_s *lower, + xcpt_t handler, FAR void *arg); +static void sam_enable_irq(FAR const struct mrf24j40_lower_s *lower, + bool state); +static int sam_mrf24j40_devsetup(FAR struct sam_priv_s *priv); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* A reference to a structure of this type must be passed to the MRF24J40 + * driver. This structure provides information about the configuration + * of the MRF24J40 and provides some board-specific hooks. + * + * Memory for this structure is provided by the caller. It is not copied + * by the driver and is presumed to persist while the driver is active. The + * memory must be writable because, under certain circumstances, the driver + * may modify frequency or X plate resistance values. + */ + +#ifdef CONFIG_SAMV71XULT_MB1_BEE +static struct sam_priv_s g_mrf24j40_mb1_priv = +{ + .dev.attach = sam_attach_irq, + .dev.enable = sam_enable_irq, + .intcfg = CLICK_MB1_INTR, + .irq = IRQ_MB1, + .spidev = 0, +}; +#endif + +#ifdef CONFIG_SAMV71XULT_MB2_BEE +static struct sam_priv_s g_mrf24j40_mb2_priv = +{ + .dev.attach = sam_attach_irq, + .dev.enable = sam_enable_irq, + .intcfg = CLICK_MB2_INTR, + .irq = IRQ_MB2, + .spidev = 0, +}; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/* IRQ/GPIO access callbacks. These operations all hidden behind + * callbacks to isolate the MRF24J40 driver from differences in GPIO + * interrupt handling by varying boards and MCUs. If possible, + * interrupts should be configured on both rising and falling edges + * so that contact and loss-of-contact events can be detected. + * + * irq_attach - Attach the MRF24J40 interrupt handler to the GPIO + * interrupt + * irq_enable - Enable or disable the GPIO interrupt + */ + +static int sam_attach_irq(FAR const struct mrf24j40_lower_s *lower, + xcpt_t handler, FAR void *arg) +{ + FAR struct sam_priv_s *priv = (FAR struct sam_priv_s *)lower; + int ret; + + DEBUGASSERT(priv != NULL); + + ret = irq_attach(priv->irq, handler, arg); + if (ret < 0) + { + wlerr("ERROR: Failed to attach WM8904 interrupt: %d\n", ret); + } + + return ret; +} + +static void sam_enable_irq(FAR const struct mrf24j40_lower_s *lower, + bool state) +{ + FAR struct sam_priv_s *piv = (FAR struct sam_priv_s *)lower; + static bool enabled; + irqstate_t flags; + + /* The caller should not attempt to enable interrupts if the handler + * has not yet been 'attached' + */ + + wlinfo("state:%d\n", (int)state); + DEBUGASSERT(priv != NULL); + + /* Has the interrupt state changed */ + + flags = enter_critical_section(); + if (state != enabled) + { + /* Enable or disable interrupts */ + + if (state) + { + wlinfo("Enabling\n"); + sam_gpioirqenable(priv->irq); + enabled = true; + } + else + { + wlinfo("Disabling\n"); + sam_gpioirqdisable(priv->irq); + enabled = false; + } + } + + leave_critical_section(flags); +} + +/**************************************************************************** + * Name: sam_mrf24j40_devsetup + * + * Description: + * Initialize one the MRF24J40 device in one mikroBUS slot + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +static int sam_mrf24j40_devsetup(FAR struct sam_priv_s *priv) +{ + FAR struct ieee802154_radio_s *radio; + MACHANDLE mac; + FAR struct spi_dev_s *spi; + int ret; + + /* Configure the interrupt pin */ + + (void)sam_configgpio(priv->intcfg); + sam_gpioirq(priv->intcfg); + + /* Initialize the SPI bus and get an instance of the SPI interface */ + + spi = sam_spibus_initialize(priv->spidev); + if (spi == NULL) + { + wlerr("ERROR: Failed to initialize SPI bus %d\n", priv->spidev); + return -ENODEV; + } + + /* Initialize and register the SPI MRF24J40 device */ + + radio = mrf24j40_init(spi, &priv->dev); + if (radio == NULL) + { + wlerr("ERROR: Failed to initialize SPI bus %d\n", priv->spidev); + return -ENODEV; + } + + /* Create a 802.15.4 MAC device from a 802.15.4 compatible radio device. */ + + mac = mac802154_create(radio); + if (mac == NULL) + { + wlerr("ERROR: Failed to initialize IEEE802.15.4 MAC\n"); + return -ENODEV; + } + +#ifdef CONFIG_IEEE802154_NETDEV + /* Use the IEEE802.15.4 MAC interface instance to create a 6LoWPAN + * network interface by wrapping the MAC intrface instance in a + * network device driver via mac802154dev_register(). + */ + + ret = mac802154netdev_register(mac); + if (ret < 0) + { + wlerr("ERROR: Failed to register the MAC network driver wpan%d: %d\n", + 0, ret); + return ret; + } +#endif + +#ifdef CONFIG_IEEE802154_MACDEV + /* If want to call these APIs from userspace, you have to wrap the MAC + * interface in a character device viamac802154dev_register(). + */ + + ret = mac802154dev_register(mac, 0); + if (ret < 0) + { + wlerr("ERROR: Failed to register the MAC character driver /dev/ieee%d: %d\n", + 0, ret); + return ret; + } +#endif + + return OK; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: sam_mrf24j40_initialize + * + * Description: + * Initialize the MRF24J40 device. + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +int sam_mrf24j40_initialize(void) +{ + int ret; + +#ifdef CONFIG_SAMV71XULT_MB1_BEE + wlinfo("Configuring BEE in mikroBUS1\n"); + + ret = sam_mrf24j40_devsetup(&g_mrf24j40_mb1_priv); + if (ret < 0) + { + wlerr("ERROR: Failed to initialize BD in mikroBUS1: %d\n", ret); + } +#endif + +#ifdef CONFIG_SAMV71XULT_MB2_BEE + wlinfo("Configuring BEE in mikroBUS2\n"); + + ret = sam_mrf24j40_devsetup(&g_mrf24j40_mb2_priv); + if (ret < 0) + { + wlerr("ERROR: Failed to initialize BD in mikroBUS2: %d\n", ret); + } +#endif + + UNUSED(ret); + return OK; +} +#endif /* HAVE_MRF24J40 */ diff --git a/configs/samv71-xult/src/sam_spi.c b/configs/samv71-xult/src/sam_spi.c index eb39246e709..8c740642fd7 100644 --- a/configs/samv71-xult/src/sam_spi.c +++ b/configs/samv71-xult/src/sam_spi.c @@ -63,13 +63,24 @@ * Name: sam_spidev_initialize * * Description: - * Called to configure SPI chip select PIO pins for the SAMV71-XULT board. + * Called to configure SPI chip select GPIO pins for the SAMV71-XULT board. * ************************************************************************************/ void sam_spidev_initialize(void) { #ifdef CONFIG_SAMV7_SPI0_MASTER + +#ifdef CONFIG_SAMV71XULT_MB1_SPI + /* Enable chip select for mikroBUS1 */ + + (void)stm32_configgpio(CLICK_MB1_CS); +#endif +#ifdef CONFIG_SAMV71XULT_MB2_SPI + /* Enable chip select for mikroBUS2 */ + + (void)stm32_configgpio(CLICK_MB2_CS); + #endif #ifdef CONFIG_SAMV7_SPI0_SLAVE @@ -101,10 +112,10 @@ void sam_spidev_initialize(void) * pins. * 2. Provide sam_spi[0|1]select() and sam_spi[0|1]status() functions in your board- * specific logic. These functions will perform chip selection and - * status operations using PIOs in the way your board is configured. + * status operations using GPIOs in the way your board is configured. * 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide * sam_spi[0|1]cmddata() functions in your board-specific logic. This - * function will perform cmd/data selection operations using PIOs in + * function will perform cmd/data selection operations using GPIOs in * the way your board is configured. * 3. Add a call to sam_spibus_initialize() in your low level application * initialization logic @@ -119,16 +130,16 @@ void sam_spidev_initialize(void) * Name: sam_spi[0|1]select * * Description: - * PIO chip select pins may be programmed by the board specific logic in + * GPIO chip select pins may be programmed by the board specific logic in * one of two different ways. First, the pins may be programmed as SPI * peripherals. In that case, the pins are completely controlled by the * SPI driver. This method still needs to be provided, but it may be only * a stub. * - * An alternative way to program the PIO chip select pins is as a normal - * PIO output. In that case, the automatic control of the CS pins is + * An alternative way to program the GPIO chip select pins is as a normal + * GPIO output. In that case, the automatic control of the CS pins is * bypassed and this function must provide control of the chip select. - * NOTE: In this case, the PIO output pin does *not* have to be the + * NOTE: In this case, the GPIO output pin does *not* have to be the * same as the NPCS pin normal associated with the chip select number. * * Input Parameters: @@ -143,12 +154,32 @@ void sam_spidev_initialize(void) #ifdef CONFIG_SAMV7_SPI0_MASTER void sam_spi0select(uint32_t devid, bool selected) { + spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); + + switch (devid) + { +#ifdef CONFIG_IEEE802154_MRF24J40 + case SPIDEV_IEEE802154(0): + /* Set the GPIO low to select and high to de-select */ + +#if defined(CONFIG_SAMV71XULT_MB1_BEE) + stm32_gpiowrite(CLICK_MB1_CS, !selected); +#elif defined(CONFIG_SAMV71XULT_MB2_BEE) + stm32_gpiowrite(CLICK_MB2_CS, !selected); +#endif + break; +#endif + + default: + break; + } } #endif #ifdef CONFIG_SAMV7_SPI1_MASTER void sam_spi1select(uint32_t devid, bool selected) { + spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); } #endif diff --git a/configs/samv71-xult/src/sam_userleds.c b/configs/samv71-xult/src/sam_userleds.c index a3f4bf8c552..155774427df 100644 --- a/configs/samv71-xult/src/sam_userleds.c +++ b/configs/samv71-xult/src/sam_userleds.c @@ -66,7 +66,7 @@ void board_userled_initialize(void) { - /* Configure LED PIOs for output */ + /* Configure LED GPIOs for output */ sam_configgpio(GPIO_LED0); sam_configgpio(GPIO_LED1); diff --git a/configs/samv71-xult/src/sam_wm8904.c b/configs/samv71-xult/src/sam_wm8904.c index 4d256485031..ccc4bc8161a 100644 --- a/configs/samv71-xult/src/sam_wm8904.c +++ b/configs/samv71-xult/src/sam_wm8904.c @@ -87,14 +87,14 @@ struct samv71xult_mwinfo_s * Private Function Prototypes ****************************************************************************/ -/* IRQ/PIO access callbacks. These operations all hidden behind - * callbacks to isolate the WM8904 driver from differences in PIO +/* IRQ/GPIO access callbacks. These operations all hidden behind + * callbacks to isolate the WM8904 driver from differences in GPIO * interrupt handling by varying boards and MCUs. If possible, * interrupts should be configured on both rising and falling edges * so that contact and loss-of-contact events can be detected. * - * attach - Attach the WM8904 interrupt handler to the PIO interrupt - * enable - Enable or disable the PIO interrupt + * attach - Attach the WM8904 interrupt handler to the GPIO interrupt + * enable - Enable or disable the GPIO interrupt */ static int wm8904_attach(FAR const struct wm8904_lower_s *lower, @@ -136,15 +136,15 @@ static struct samv71xult_mwinfo_s g_wm8904info = ****************************************************************************/ /**************************************************************************** - * IRQ/PIO access callbacks. These operations all hidden behind - * callbacks to isolate the WM8904 driver from differences in PIO + * IRQ/GPIO access callbacks. These operations all hidden behind + * callbacks to isolate the WM8904 driver from differences in GPIO * interrupt handling by varying boards and MCUs. If possible, * interrupts should be configured on both rising and falling edges * so that contact and loss-of-contact events can be detected. * - * attach - Attach the WM8904 interrupt handler to the PIO interrupt - * enable - Enable or disable the PIO interrupt - * clear - Acknowledge/clear any pending PIO interrupt + * attach - Attach the WM8904 interrupt handler to the GPIO interrupt + * enable - Enable or disable the GPIO interrupt + * clear - Acknowledge/clear any pending GPIO interrupt * ****************************************************************************/ diff --git a/configs/samv71-xult/src/samv71-xult.h b/configs/samv71-xult/src/samv71-xult.h index f635ff361c5..ae2b71b3a0c 100644 --- a/configs/samv71-xult/src/samv71-xult.h +++ b/configs/samv71-xult/src/samv71-xult.h @@ -1,7 +1,7 @@ /************************************************************************************ * configs/samv71-xult/src/samv71-xult.h * - * Copyright (C) 2015-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -72,6 +72,7 @@ #define HAVE_RTC_PCF85263 1 #define HAVE_I2CTOOL 1 #define HAVE_LED_DRIVER 1 +#define HAVE_MRF24J40 1 /* HSMCI */ /* Can't support MMC/SD if the card interface is not enabled */ @@ -87,10 +88,10 @@ # undef HAVE_HSMCI #endif -/* We need PIO interrupts on GPIOD to support card detect interrupts */ +/* We need GPIO interrupts on GPIOD to support card detect interrupts */ #if defined(HAVE_HSMCI) && !defined(CONFIG_SAMV7_GPIOD_IRQ) -# warning PIOD interrupts not enabled. No MMC/SD support. +# warning GPIOD interrupts not enabled. No MMC/SD support. # undef HAVE_HSMCI #endif @@ -375,6 +376,24 @@ # endif #endif +/* Check if the MRF24J40 is supported in this configuration */ + +#ifndef CONFIG_IEEE802154_MRF24J40 +# undef HAVE_MRF24J40 +#endif + +#ifndef CONFIG_SAMV71XULT_CLICKSHIELD +# undef HAVE_MRF24J40 +#endif + +#ifndef CONFIG_SAMV7_SPI0_MASTER +# undef HAVE_MRF24J40 +#endif + +#ifndef CONFIG_SAMV7_GPIOA_IRQ +# undef HAVE_MRF24J40 +#endif + /* SAMV71-XULT GPIO Pin Definitions *************************************************/ /* Ethernet MAC. @@ -419,7 +438,7 @@ * * ------ ----------- --------------------- * SAMV71 Function Shared functionality - * PIO + * GPIO * ------ ----------- --------------------- * PA23 Yellow LED0 EDBG GPIO * PC09 Yellow LED1 LCD, and Shield @@ -440,7 +459,7 @@ * * ------ ----------- --------------------- * SAMV71 Function Shared functionality - * PIO + * GPIO * ------ ----------- --------------------- * RESET RESET Trace, Shield, and EDBG * PA09 SW0 EDBG GPIO and Camera @@ -503,7 +522,7 @@ /* WM8904 Audio Codec ***************************************************************/ /* SAMV71 Interface WM8904 Interface * ---- ------------ ------- ---------------------------------- - * PIO Usage Pin Function + * GPIO Usage Pin Function * ---- ------------ ------- ---------------------------------- * PA3 TWD0 SDA I2C control interface, data line * PA4 TWCK0 SCLK I2C control interface, clock line @@ -522,8 +541,8 @@ * interrupt on the high level. */ -#define GPIO_INT_WM8904 (PIO_INPUT | PIO_CFG_DEFAULT | PIO_CFG_DEGLITCH | \ - PIO_INT_HIGHLEVEL | PIO_PORT_PIOD | PIO_PIN11) +#define GPIO_INT_WM8904 (GPIO_INPUT | GPIO_CFG_DEFAULT | GPIO_CFG_DEGLITCH | \ + GPIO_INT_HIGHLEVEL | GPIO_PORT_PIOD | GPIO_PIN11) #define IRQ_INT_WM8904 SAM_IRQ_PD11 /* The MW8904 communicates on TWI0, I2C address 0x1a for control operations */ @@ -535,6 +554,30 @@ #define WM8904_SSC_BUS 0 +/* Click Shield */ +/* Reset (RST#) Pulled-up on the click board */ + +#define CLICK_MB1_RESET (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ + GPIO_PORT_PIOD | GPIO_PIN30) +#define CLICK_MB2_RESET (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ + GPIO_PORT_PIOA | GPIO_PIN19) +/* Interrupts */ + +#define CLICK_MB1_INTR (GPIO_INPUT | GPIO_CFG_DEFAULT | GPIO_CFG_DEGLITCH | \ + GPIO_INT_HIGHLEVEL | GPIO_PORT_PIOA | GPIO_PIN0) +#define CLICK_MB2_INTR (GPIO_INPUT | GPIO_CFG_DEFAULT | GPIO_CFG_DEGLITCH | \ + GPIO_INT_HIGHLEVEL | GPIO_PORT_PIOA | GPIO_PIN6) + +#define IRQ_MB1 SAM_IRQ_PA0 +#define IRQ_MB2 SAM_IRQ_PA6 + +/* SP chip selects */ + +#define CLICK_MB1_CS (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_SET | \ + GPIO_PORT_PIOD | GPIO_PIN25) +#define CLICK_MB2_CS (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_SET | \ + GPIO_PORT_PIOC | GPIO_PIN9) + /************************************************************************************ * Public Types ************************************************************************************/ diff --git a/include/nuttx/net/icmpv6.h b/include/nuttx/net/icmpv6.h index d303cfa8480..e0e8ecba99c 100644 --- a/include/nuttx/net/icmpv6.h +++ b/include/nuttx/net/icmpv6.h @@ -127,7 +127,20 @@ * Public Type Definitions ****************************************************************************/ -/* The ICMP and IP headers */ +/* The ICMPv6 header */ + +struct icmpv6_hdr_s +{ + uint8_t type; /* Defines the format of the ICMP message */ + uint8_t code; /* Further qualifies the ICMP messages */ + uint16_t chksum; /* Checksum of ICMP header and data */ + + /* Data following the ICMP header contains the data specific to the + * message type indicated by the Type and Code fields. + */ +}; + +/* The ICMPv6 and IPv6 headers */ struct icmpv6_iphdr_s { diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index 905b977ed1c..b84891e4da1 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -42,6 +42,7 @@ #include #include +#include #include #include diff --git a/net/sixlowpan/sixlowpan_input.c b/net/sixlowpan/sixlowpan_input.c index 6a784cb2339..552d47c8bfb 100644 --- a/net/sixlowpan/sixlowpan_input.c +++ b/net/sixlowpan/sixlowpan_input.c @@ -60,6 +60,7 @@ #include "nuttx/net/netdev.h" #include "nuttx/net/ip.h" +#include "nuttx/net/icmpv6.h" #include "nuttx/net/sixlowpan.h" #include "nuttx/wireless/ieee802154/ieee802154_mac.h" diff --git a/net/sixlowpan/sixlowpan_tcpsend.c b/net/sixlowpan/sixlowpan_tcpsend.c index be1f04055b1..1a274a7b302 100644 --- a/net/sixlowpan/sixlowpan_tcpsend.c +++ b/net/sixlowpan/sixlowpan_tcpsend.c @@ -51,6 +51,7 @@ #include "netdev/netdev.h" #include "devif/devif.h" #include "socket/socket.h" +#include "icmpv6/icmpv6.h" #include "tcp/tcp.h" #include "utils/utils.h" #include "sixlowpan/sixlowpan_internal.h" diff --git a/net/sixlowpan/sixlowpan_udpsend.c b/net/sixlowpan/sixlowpan_udpsend.c index 686ae660ca7..7d53f61184a 100644 --- a/net/sixlowpan/sixlowpan_udpsend.c +++ b/net/sixlowpan/sixlowpan_udpsend.c @@ -50,6 +50,7 @@ #include "netdev/netdev.h" #include "socket/socket.h" +#include "icmpv6/icmpv6.h" #include "udp/udp.h" #include "utils/utils.h" #include "sixlowpan/sixlowpan_internal.h" From 5cb3edb55232e2f3eab5497ff80db952e10c680c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 2 Jul 2017 11:27:27 -0600 Subject: [PATCH 07/33] Update some naming used in Documentation --- Documentation/NuttShell.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation/NuttShell.html b/Documentation/NuttShell.html index 48e207bc266..c545a40a547 100644 --- a/Documentation/NuttShell.html +++ b/Documentation/NuttShell.html @@ -8,7 +8,7 @@

NuttShell (NSH)

-

Last Updated: June 26, 2017

+

Last Updated: July 2, 2017

@@ -1810,11 +1810,11 @@ nsh> mount -t procfs /proc

Command Syntax:

    -ifdown <nic-name>
    +ifdown <interface>
     

Synopsis. - Take down the interface identified by the name <nic-name>. + Take down the interface identified by the name <interface>.

Example: @@ -1833,11 +1833,11 @@ ifdown eth0

Command Syntax:

    -ifup <nic-name>
    +ifup <interface>
     

Synopsis. - Bring up down the interface identified by the name <nic-name>. + Bring up down the interface identified by the name <interface>.

Example: From 7d7fd9112d6df32e4807fea4b1e51fd0961cd963 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 2 Jul 2017 13:06:23 -0600 Subject: [PATCH 08/33] samv71-xult/mrf24j40-starhub: Put the serial console on UART3, i.e., on a Arduino serial shield. --- configs/samv71-xult/README.txt | 27 ++++++++++++----- .../samv71-xult/mrf24j40-starhub/defconfig | 30 +++++++++---------- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/configs/samv71-xult/README.txt b/configs/samv71-xult/README.txt index 122aa35c09f..0afcf8c74bf 100644 --- a/configs/samv71-xult/README.txt +++ b/configs/samv71-xult/README.txt @@ -1629,10 +1629,17 @@ Debugging orientation of the JTAG connection. I have been using Atmel Studio to write code to flash then I use the Segger - J-Link GDB server to debug. I have been using the 'Device Programming' I + J-Link GDB server to debug. I have been using the 'Device Programming' available under the Atmel Studio 'Tool' menu. I have to disconnect the - SAM-ICE while programming with the EDBG. I am sure that you could come up - with a GDB server-only solution if you wanted. + SAM-ICE while programming with the EDBG. + + You can also load code into flash directory with J-Link: + + arm-none-eabi-gdb + (gdb) target remote localhost:2331 + (gdb) mon reset + (gdb) mon halt + (gdb) load nuttx I run GDB like this from the directory containing the NuttX ELF file: @@ -1856,22 +1863,26 @@ Configuration sub-directories boards are the endpoints in the start. NOTES: - 1. This configuration derives from the netnsh configuration, but adds + 1. The serial console is configured by default for use with and Arduino + serial shield (UART3). You will need to reconfigure if you will + to use a different U[S]ART. + + 2. This configuration derives from the netnsh configuration, but adds support for IPv6, 6LoWPAN, and the MRF24J40 IEEE 802.15.4 radio. - 2. This configuration uses the Mikroe BEE MRF24j40 click boards and + 3. This configuration uses the Mikroe BEE MRF24j40 click boards and connects to the SAMV71-XULT using a click shield as described above. - 3. You must must have also have at least two clicker2-stm32 boards each + 4. You must must have also have at least two clicker2-stm32 boards each with an MRF24J40 BEE click board in order to run these tests. - 4. Telnet: The clicker2-stm32 star point configuration supports the + 5. Telnet: The clicker2-stm32 star point configuration supports the Telnet daemon, but not the Telnet client; the star hub configuration supports the Telnet client, but not the Telnet daemon. Therefore, the star hub can Telnet to any point in the star, the star endpoints cannot initiate telnet sessions. - 5. TCP and UDP Tests: The same TCP and UDP tests as described for + 6. TCP and UDP Tests: The same TCP and UDP tests as described for the clicker2-stm32 mrf24j40-starpoint coniguration are supported on the star endpoints, but NOT on the star hub. Therefore, all network testing is between endpoints with the hub acting, well, only like a diff --git a/configs/samv71-xult/mrf24j40-starhub/defconfig b/configs/samv71-xult/mrf24j40-starhub/defconfig index 541ca9f7a92..5db386e4bd3 100644 --- a/configs/samv71-xult/mrf24j40-starhub/defconfig +++ b/configs/samv71-xult/mrf24j40-starhub/defconfig @@ -260,12 +260,12 @@ CONFIG_SAMV7_TWIHS0=y # CONFIG_SAMV7_UART0 is not set # CONFIG_SAMV7_UART1 is not set # CONFIG_SAMV7_UART2 is not set -# CONFIG_SAMV7_UART3 is not set +CONFIG_SAMV7_UART3=y # CONFIG_SAMV7_UART4 is not set # CONFIG_SAMV7_USBDEVHS is not set # CONFIG_SAMV7_USBHOSTHS is not set # CONFIG_SAMV7_USART0 is not set -CONFIG_SAMV7_USART1=y +# CONFIG_SAMV7_USART1 is not set # CONFIG_SAMV7_USART2 is not set # CONFIG_SAMV7_WDT is not set # CONFIG_SAMV7_RSWDT is not set @@ -738,7 +738,7 @@ CONFIG_SERIAL_CONSOLE=y # CONFIG_UART0_SERIALDRIVER is not set # CONFIG_UART1_SERIALDRIVER is not set # CONFIG_UART2_SERIALDRIVER is not set -# CONFIG_UART3_SERIALDRIVER is not set +CONFIG_UART3_SERIALDRIVER=y # CONFIG_UART4_SERIALDRIVER is not set # CONFIG_UART5_SERIALDRIVER is not set # CONFIG_UART6_SERIALDRIVER is not set @@ -747,7 +747,7 @@ CONFIG_SERIAL_CONSOLE=y # CONFIG_SCI0_SERIALDRIVER is not set # CONFIG_SCI1_SERIALDRIVER is not set # CONFIG_USART0_SERIALDRIVER is not set -CONFIG_USART1_SERIALDRIVER=y +# CONFIG_USART1_SERIALDRIVER is not set # CONFIG_USART2_SERIALDRIVER is not set # CONFIG_USART3_SERIALDRIVER is not set # CONFIG_USART4_SERIALDRIVER is not set @@ -762,22 +762,22 @@ CONFIG_STANDARD_SERIAL=y # CONFIG_SERIAL_OFLOWCONTROL is not set # CONFIG_SERIAL_DMA is not set CONFIG_ARCH_HAVE_SERIAL_TERMIOS=y -CONFIG_USART1_SERIAL_CONSOLE=y +CONFIG_UART3_SERIAL_CONSOLE=y # CONFIG_OTHER_SERIAL_CONSOLE is not set # CONFIG_NO_SERIAL_CONSOLE is not set # -# USART1 Configuration +# UART3 Configuration # -CONFIG_USART1_RXBUFSIZE=256 -CONFIG_USART1_TXBUFSIZE=256 -CONFIG_USART1_BAUD=115200 -CONFIG_USART1_BITS=8 -CONFIG_USART1_PARITY=0 -CONFIG_USART1_2STOP=0 -# CONFIG_USART1_IFLOWCONTROL is not set -# CONFIG_USART1_OFLOWCONTROL is not set -# CONFIG_USART1_DMA is not set +CONFIG_UART3_RXBUFSIZE=256 +CONFIG_UART3_TXBUFSIZE=256 +CONFIG_UART3_BAUD=115200 +CONFIG_UART3_BITS=8 +CONFIG_UART3_PARITY=0 +CONFIG_UART3_2STOP=0 +# CONFIG_UART3_IFLOWCONTROL is not set +# CONFIG_UART3_OFLOWCONTROL is not set +# CONFIG_UART3_DMA is not set # CONFIG_PSEUDOTERM is not set # CONFIG_USBDEV is not set # CONFIG_USBHOST is not set From 634b13c14379bc0c134ae4af790e410ab5ccf6f9 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 2 Jul 2017 14:25:51 -0600 Subject: [PATCH 09/33] samv71-xult/mrf24j40-starhub: Tweaks to defconfig --- configs/samv71-xult/README.txt | 46 +++++++++++++++++-- .../samv71-xult/mrf24j40-starhub/defconfig | 9 ++-- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/configs/samv71-xult/README.txt b/configs/samv71-xult/README.txt index 0afcf8c74bf..ce758615b03 100644 --- a/configs/samv71-xult/README.txt +++ b/configs/samv71-xult/README.txt @@ -1876,14 +1876,54 @@ Configuration sub-directories 4. You must must have also have at least two clicker2-stm32 boards each with an MRF24J40 BEE click board in order to run these tests. - 5. Telnet: The clicker2-stm32 star point configuration supports the + 5. The network initialization thread is NOT enabled. As a result, the + startup will hang if the Ethernet cable is not plugged in. For more + information, see the paragraphs above entitled "Network Initialization + Thread" and "Network Monitor". + + 6. This configuration supports logging of debug output to a circular + buffer in RAM. This feature is discussed fully in this Wiki page: + http://nuttx.org/doku.php?id=wiki:howtos:syslog . Relevant + configuration settings are summarized below: + + Device Drivers: + CONFIG_RAMLOG=y : Enable the RAM-based logging feature. + CONFIG_RAMLOG_CONSOLE=n : (We don't use the RAMLOG console) + CONFIG_RAMLOG_SYSLOG=y : This enables the RAM-based logger as the + system logger. + CONFIG_RAMLOG_NONBLOCKING=y : Needs to be non-blocking for dmesg + CONFIG_RAMLOG_BUFSIZE=8192 : Buffer size is 8KiB + + NOTE: This RAMLOG feature is really only of value if debug output + is enabled. But, by default, no debug output is disabled in this + configuration. Therefore, there is no logic that will add anything + to the RAM buffer. This feature is configured and in place only + to support any future debugging needs that you may have. + + If you don't plan on using the debug features, then by all means + disable this feature and save 8KiB of RAM! + + NOTE: There is an issue with capturing data in the RAMLOG: If + the system crashes, all of the crash dump information will go into + the RAMLOG and you will be unable to access it! You can tell that + the system has crashed because (a) it will be unresponsive and (b) + the LD2 will be blinking at about 2Hz. + + You can also reconfigure to use stdout for debug output be disabling + all of the CONFIG_RAMLOG* settings listed above and enabling the + following in the .config file: + + CONFIG_SYSLOG_CONSOLE=y + CONFIG_SYSLOG_SERIAL_CONSOLE=y + + 7. Telnet: The clicker2-stm32 star point configuration supports the Telnet daemon, but not the Telnet client; the star hub configuration supports the Telnet client, but not the Telnet daemon. Therefore, the star hub can Telnet to any point in the star, the star endpoints cannot initiate telnet sessions. - 6. TCP and UDP Tests: The same TCP and UDP tests as described for - the clicker2-stm32 mrf24j40-starpoint coniguration are supported on + 8. TCP and UDP Tests: The same TCP and UDP tests as described for + the clicker2-stm32 mrf24j40-starpoint configuration are supported on the star endpoints, but NOT on the star hub. Therefore, all network testing is between endpoints with the hub acting, well, only like a hub. diff --git a/configs/samv71-xult/mrf24j40-starhub/defconfig b/configs/samv71-xult/mrf24j40-starhub/defconfig index 5db386e4bd3..d8b6c1c5682 100644 --- a/configs/samv71-xult/mrf24j40-starhub/defconfig +++ b/configs/samv71-xult/mrf24j40-starhub/defconfig @@ -686,7 +686,7 @@ CONFIG_TELNET_TXBUFFER_SIZE=256 CONFIG_NETDEV_MULTINIC=y CONFIG_ARCH_HAVE_NETDEV_STATISTICS=y CONFIG_NETDEV_STATISTICS=y -CONFIG_NETDEV_LATEINIT=y +# CONFIG_NETDEV_LATEINIT is not set # # External Ethernet MAC Device Support @@ -706,8 +706,8 @@ CONFIG_ARCH_PHY_INTERRUPT=y # CONFIG_ETH0_PHY_KS8721 is not set # CONFIG_ETH0_PHY_KSZ8041 is not set # CONFIG_ETH0_PHY_KSZ8051 is not set -# CONFIG_ETH0_PHY_KSZ8061 is not set -CONFIG_ETH0_PHY_KSZ8081=y +CONFIG_ETH0_PHY_KSZ8061=y +# CONFIG_ETH0_PHY_KSZ8081 is not set # CONFIG_ETH0_PHY_KSZ90x1 is not set # CONFIG_ETH0_PHY_DP83848C is not set # CONFIG_ETH0_PHY_LAN8720 is not set @@ -1430,7 +1430,8 @@ CONFIG_NSH_ARCHINIT=y # Networking Configuration # CONFIG_NSH_NETINIT=y -CONFIG_NSH_NETLOCAL=y +# CONFIG_NSH_NETLOCAL is not set +# CONFIG_NSH_NETINIT_THREAD is not set # # IP Address Configuration From 41d4958a779c1a0353d83e250abe2c256cf34465 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 2 Jul 2017 15:01:11 -0600 Subject: [PATCH 10/33] Add missing MRF24J40 bring-up logic --- configs/samv71-xult/src/sam_bringup.c | 10 ++++++++++ configs/samv71-xult/src/samv71-xult.h | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/configs/samv71-xult/src/sam_bringup.c b/configs/samv71-xult/src/sam_bringup.c index b24cfc96432..6234c845ae0 100644 --- a/configs/samv71-xult/src/sam_bringup.c +++ b/configs/samv71-xult/src/sam_bringup.c @@ -529,6 +529,16 @@ int sam_bringup(void) } #endif +#ifdef HAVE_MRF24J40 + /* Configure MRF24J40 wireless */ + + ret = sam_mrf24j40_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: sam_mrf24j40_initialize() failed: %d\n", ret); + } +#endif + #ifdef HAVE_ELF /* Initialize the ELF binary loader */ diff --git a/configs/samv71-xult/src/samv71-xult.h b/configs/samv71-xult/src/samv71-xult.h index ae2b71b3a0c..ef4a5151407 100644 --- a/configs/samv71-xult/src/samv71-xult.h +++ b/configs/samv71-xult/src/samv71-xult.h @@ -386,6 +386,10 @@ # undef HAVE_MRF24J40 #endif +#if !defined(CONFIG_SAMV71XULT_MB1_BEE) && !defined(CONFIG_SAMV71XULT_MB2_BEE) +# undef HAVE_MRF24J40 +#endif + #ifndef CONFIG_SAMV7_SPI0_MASTER # undef HAVE_MRF24J40 #endif @@ -843,5 +847,21 @@ int sam_wm8904_initialize(int minor); int sam_audio_null_initialize(int minor); #endif /* HAVE_AUDIO_NULL */ +/**************************************************************************** + * Name: stm32_mrf24j40_initialize + * + * Description: + * Initialize the MRF24J40 device. + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +#ifdef HAVE_MRF24J40 +int sam_mrf24j40_initialize(void); +#endif + #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_SAMV71_XULT_SRC_SAMV71_XULT_H */ From a8f43e1216edd2916c98eb9384863bbad49efa60 Mon Sep 17 00:00:00 2001 From: Jan Pobrislo Date: Sun, 2 Jul 2017 16:40:11 -0600 Subject: [PATCH 11/33] stm32f4 discovery: Add logic to register the button driver and the user led driver if so configured --- configs/stm32f4discovery/src/stm32_bringup.c | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/configs/stm32f4discovery/src/stm32_bringup.c b/configs/stm32f4discovery/src/stm32_bringup.c index 042c3386fc8..ba7fe283415 100644 --- a/configs/stm32f4discovery/src/stm32_bringup.c +++ b/configs/stm32f4discovery/src/stm32_bringup.c @@ -57,6 +57,14 @@ # include "stm32_usbhost.h" #endif +#ifdef CONFIG_BUTTONS +# include +#endif + +#ifdef CONFIG_USERLED +# include +#endif + #include "stm32f4discovery.h" /* Conditional logic in stm32f4discover.h will determine if certain features @@ -179,6 +187,16 @@ int stm32_bringup(void) } #endif +#ifdef CONFIG_BUTTONS + /* Register the BUTTON driver */ + + ret = btn_lower_initialize("/dev/buttons"); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: btn_lower_initialize() failed: %d\n", ret); + } +#endif + #ifdef CONFIG_QENCODER /* Initialize and register the qencoder driver */ @@ -192,6 +210,16 @@ int stm32_bringup(void) } #endif +#ifdef CONFIG_USERLED + /* Register the LED driver */ + + ret = userled_lower_initialize("/dev/userleds"); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret); + } +#endif + #ifdef HAVE_RTC_DRIVER /* Instantiate the STM32 lower-half RTC driver */ From 56801c3389362798cdb7732717f895066ab03fa3 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 2 Jul 2017 18:33:31 -0600 Subject: [PATCH 12/33] samv71-xult: Fix SP0 vs. TWHS0 in mrf24j40-starhub/defconfig; fix copy-paste errors in SPI initialization logic. --- .../samv71-xult/mrf24j40-starhub/defconfig | 20 ++++++++++++------- configs/samv71-xult/src/sam_spi.c | 9 +++++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/configs/samv71-xult/mrf24j40-starhub/defconfig b/configs/samv71-xult/mrf24j40-starhub/defconfig index d8b6c1c5682..ece6471edd8 100644 --- a/configs/samv71-xult/mrf24j40-starhub/defconfig +++ b/configs/samv71-xult/mrf24j40-starhub/defconfig @@ -219,8 +219,8 @@ CONFIG_SAMV7_HAVE_USBHS=y CONFIG_SAMV7_HAVE_USART0=y CONFIG_SAMV7_HAVE_USART1=y CONFIG_SAMV7_HAVE_USART2=y -# CONFIG_SAMV7_SPI is not set -# CONFIG_SAMV7_SPI_MASTER is not set +CONFIG_SAMV7_SPI=y +CONFIG_SAMV7_SPI_MASTER=y # CONFIG_SAMV7_SPI_SLAVE is not set # @@ -246,7 +246,7 @@ CONFIG_SAMV7_HSMCI0=y # CONFIG_SAMV7_RTT is not set # CONFIG_SAMV7_SDRAMC is not set # CONFIG_SAMV7_SMC is not set -# CONFIG_SAMV7_SPI0 is not set +CONFIG_SAMV7_SPI0=y # CONFIG_SAMV7_SPI1 is not set # CONFIG_SAMV7_SSC0 is not set # CONFIG_SAMV7_TC0 is not set @@ -254,7 +254,7 @@ CONFIG_SAMV7_HSMCI0=y # CONFIG_SAMV7_TC2 is not set # CONFIG_SAMV7_TC3 is not set # CONFIG_SAMV7_TRNG is not set -CONFIG_SAMV7_TWIHS0=y +# CONFIG_SAMV7_TWIHS0 is not set # CONFIG_SAMV7_TWIHS1 is not set # CONFIG_SAMV7_TWIHS2 is not set # CONFIG_SAMV7_UART0 is not set @@ -285,10 +285,16 @@ CONFIG_SAMV7_GPIOD_IRQ=y # CONFIG_SAMV7_PROGMEM is not set # -# TWIHS device driver options +# SPI Device Driver Configuration # -CONFIG_SAMV7_TWIHS0_FREQUENCY=100000 -CONFIG_SAMV7_TWIHS0_GLITCH_FILTER=1 +CONFIG_SAMV7_SPI0_MASTER=y + +# +# SPI Master Configuration +# +# CONFIG_SAMV7_SPI_CS_DECODING is not set +# CONFIG_SAMV7_SPI_VARSELECT is not set +# CONFIG_SAMV7_SPI_DMA is not set # # HSMCI device driver options diff --git a/configs/samv71-xult/src/sam_spi.c b/configs/samv71-xult/src/sam_spi.c index 8c740642fd7..81163fab648 100644 --- a/configs/samv71-xult/src/sam_spi.c +++ b/configs/samv71-xult/src/sam_spi.c @@ -74,14 +74,15 @@ void sam_spidev_initialize(void) #ifdef CONFIG_SAMV71XULT_MB1_SPI /* Enable chip select for mikroBUS1 */ - (void)stm32_configgpio(CLICK_MB1_CS); + (void)sam_configgpio(CLICK_MB1_CS); #endif #ifdef CONFIG_SAMV71XULT_MB2_SPI /* Enable chip select for mikroBUS2 */ - (void)stm32_configgpio(CLICK_MB2_CS); + (void)sam_configgpio(CLICK_MB2_CS); #endif +#endif /* CONFIG_SAMV7_SPI0_MASTER */ #ifdef CONFIG_SAMV7_SPI0_SLAVE #endif @@ -163,9 +164,9 @@ void sam_spi0select(uint32_t devid, bool selected) /* Set the GPIO low to select and high to de-select */ #if defined(CONFIG_SAMV71XULT_MB1_BEE) - stm32_gpiowrite(CLICK_MB1_CS, !selected); + sam_gpiowrite(CLICK_MB1_CS, !selected); #elif defined(CONFIG_SAMV71XULT_MB2_BEE) - stm32_gpiowrite(CLICK_MB2_CS, !selected); + sam_gpiowrite(CLICK_MB2_CS, !selected); #endif break; #endif From acb0dcecace29882ac908df7c92a2f4cbcfda44d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 2 Jul 2017 18:36:55 -0600 Subject: [PATCH 13/33] samv71-xult: Fix a typo in MRF24J40 initialization. --- configs/samv71-xult/src/sam_mrf24j40.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/samv71-xult/src/sam_mrf24j40.c b/configs/samv71-xult/src/sam_mrf24j40.c index ecaa44b643a..eeb894be93e 100644 --- a/configs/samv71-xult/src/sam_mrf24j40.c +++ b/configs/samv71-xult/src/sam_mrf24j40.c @@ -159,7 +159,7 @@ static int sam_attach_irq(FAR const struct mrf24j40_lower_s *lower, static void sam_enable_irq(FAR const struct mrf24j40_lower_s *lower, bool state) { - FAR struct sam_priv_s *piv = (FAR struct sam_priv_s *)lower; + FAR struct sam_priv_s *priv = (FAR struct sam_priv_s *)lower; static bool enabled; irqstate_t flags; From 057b438499729da2313feadb9f4cae0bf08c1ce1 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 3 Jul 2017 06:56:47 -0600 Subject: [PATCH 14/33] samv71-xult/mrf24j40-starhub: Disabled CONFIG_BOARD_INITIALIZE; Correct MRF24J40 interrupt edge. --- configs/samv71-xult/mrf24j40-starhub/defconfig | 3 +-- configs/samv71-xult/src/samv71-xult.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/configs/samv71-xult/mrf24j40-starhub/defconfig b/configs/samv71-xult/mrf24j40-starhub/defconfig index ece6471edd8..1569c899ac1 100644 --- a/configs/samv71-xult/mrf24j40-starhub/defconfig +++ b/configs/samv71-xult/mrf24j40-starhub/defconfig @@ -499,8 +499,7 @@ CONFIG_NAME_MAX=32 # # RTOS hooks # -CONFIG_BOARD_INITIALIZE=y -# CONFIG_BOARD_INITTHREAD is not set +# CONFIG_BOARD_INITIALIZE is not set # CONFIG_SCHED_STARTHOOK is not set # CONFIG_SCHED_ATEXIT is not set # CONFIG_SCHED_ONEXIT is not set diff --git a/configs/samv71-xult/src/samv71-xult.h b/configs/samv71-xult/src/samv71-xult.h index ef4a5151407..a619a735ca9 100644 --- a/configs/samv71-xult/src/samv71-xult.h +++ b/configs/samv71-xult/src/samv71-xult.h @@ -568,9 +568,9 @@ /* Interrupts */ #define CLICK_MB1_INTR (GPIO_INPUT | GPIO_CFG_DEFAULT | GPIO_CFG_DEGLITCH | \ - GPIO_INT_HIGHLEVEL | GPIO_PORT_PIOA | GPIO_PIN0) + GPIO_INT_FALLING | GPIO_PORT_PIOA | GPIO_PIN0) #define CLICK_MB2_INTR (GPIO_INPUT | GPIO_CFG_DEFAULT | GPIO_CFG_DEGLITCH | \ - GPIO_INT_HIGHLEVEL | GPIO_PORT_PIOA | GPIO_PIN6) + GPIO_INT_FALLING | GPIO_PORT_PIOA | GPIO_PIN6) #define IRQ_MB1 SAM_IRQ_PA0 #define IRQ_MB2 SAM_IRQ_PA6 From e76c9875a4f66be97b9735c95794d0ca9712b2d2 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 3 Jul 2017 13:04:38 +0000 Subject: [PATCH 15/33] Make.defs edited online with Bitbucket --- configs/nucleo-f4x1re/f401-nsh-clang/Make.defs | 3 --- 1 file changed, 3 deletions(-) diff --git a/configs/nucleo-f4x1re/f401-nsh-clang/Make.defs b/configs/nucleo-f4x1re/f401-nsh-clang/Make.defs index 99163814492..2d2e46689b3 100644 --- a/configs/nucleo-f4x1re/f401-nsh-clang/Make.defs +++ b/configs/nucleo-f4x1re/f401-nsh-clang/Make.defs @@ -61,9 +61,6 @@ else ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) endif -#CC = $(CROSSDEV)clang -#CXX = $(CROSSDEV)clang++ -#CPP = $(CROSSDEV)clang -E CC = clang CXX = clang++ CPP = clang -E From 21dcc8cbc7892cb27242523c57e2747f12cdf711 Mon Sep 17 00:00:00 2001 From: Eetu Nevalainen Date: Mon, 3 Jul 2017 11:06:07 -0600 Subject: [PATCH 16/33] stm32f40xxx_rtcc ISR register and write protection fix --- arch/arm/src/stm32/stm32f40xxx_rtcc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/arm/src/stm32/stm32f40xxx_rtcc.c b/arch/arm/src/stm32/stm32f40xxx_rtcc.c index a2af73794e5..2d511d1325d 100644 --- a/arch/arm/src/stm32/stm32f40xxx_rtcc.c +++ b/arch/arm/src/stm32/stm32f40xxx_rtcc.c @@ -600,6 +600,10 @@ static int stm32_rtc_alarm_handler(int irq, void *context, void *arg) uint32_t cr; int ret = OK; + /* Disable the write protection for RTC registers */ + + rtc_wprunlock(); + isr = getreg32(STM32_RTC_ISR); /* Check for EXTI from Alarm A or B and handle according */ @@ -624,7 +628,7 @@ static int stm32_rtc_alarm_handler(int irq, void *context, void *arg) } isr = getreg32(STM32_RTC_ISR) & ~RTC_ISR_ALRAF; - putreg32(isr, STM32_RTC_CR); + putreg32(isr, STM32_RTC_ISR); } } @@ -649,11 +653,14 @@ static int stm32_rtc_alarm_handler(int irq, void *context, void *arg) } isr = getreg32(STM32_RTC_ISR) & ~RTC_ISR_ALRBF; - putreg32(isr, STM32_RTC_CR); + putreg32(isr, STM32_RTC_ISR); } } #endif + /* Re-enable the write protection for RTC registers */ + + rtc_wprlock(); return ret; } #endif From 3b697327cc9a9585432cd9914427ee69f9dc21ec Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 3 Jul 2017 11:51:39 -0600 Subject: [PATCH 17/33] samv71-xult/mrf24j40-starhub: Fix MRF24J40 interrupt pin. --- configs/samv71-xult/README.txt | 40 ++++++++++++++------------ configs/samv71-xult/src/sam_mrf24j40.c | 2 +- configs/samv71-xult/src/samv71-xult.h | 33 +++++++++++++++++++-- 3 files changed, 52 insertions(+), 23 deletions(-) diff --git a/configs/samv71-xult/README.txt b/configs/samv71-xult/README.txt index ce758615b03..d50a022d989 100644 --- a/configs/samv71-xult/README.txt +++ b/configs/samv71-xult/README.txt @@ -1473,25 +1473,27 @@ Click Shield --- ----- ------------------------------ --------------------------------- PIN PORT SHIELD FUNCTION PIN CONFIGURATION --- ----- ------------------------------ --------------------------------- - AD0 PD26 microBUS2 Analog TD *** Not an AFE pin *** - AD1 PC31 microBUS2 Analog AFE1_AD6 GPIO_AFE1_AD6 - AD2 PA19 microBUS2 GPIO reset output - AD3 PD30 microBUS1 GPIO reset output - AD4 PC13 (both) I2C-SDA *** Does not support I2C SDA *** - AD5 PE0 (both) I2C-SCL *** Does not support I2C SCL *** - - D0 PD28 (both) HDR_RX URXD3 GPIO_UART3_RXD - D1 PD30 (both) HDR_TX UTXD3 GPIO_UART3_TXD_1 - D2 PA0 microBUS1 GPIO interrupt input - D3 PA6 microBUS2 GPIO interrupt input - D5 PD11 microBUS2 PWM PWMC0_H0 - D6 PC19 microBUS1 PWN PWMC0_H2 - D9 PC9 microBUS2 CS GPIO output - D10 PD25 microBUS1 CS GPIO output SPI0_NPCS1 - D11 PD21 (both) SPI-MOSI SPI0_MOSI GPIO_SPI0_MOSI - D12 PD20 (both) SPI-MISO SPI0_MISO GPIO_SPI0_MISO - D13 PD22 (both) SPI-SCK SPI0_SPCK GPIO_SPI0_SPCK - --- ----- ------------------------------ --------------------------------- + AD0 PD26 microBUS2 Analog TD PD26 *** Not an AFE pin *** + AD1 PC31 microBUS2 Analog PC31 AFE1_AD6 GPIO_AFE1_AD6 + AD2 PD30 microBUS2 GPIO reset output PD30 + AD3 PA19 microBUS1 GPIO reset output PA19 + AD4 PC13 (both) I2C-SDA PC13 *** Does not support I2C SDA *** + AD5 PC30 (both) I2C-SCL PC30 *** Does not support I2C SCL *** + AD6 PA17 *** Not used *** + AD7 PC12 *** Not used *** + D0 PD28 (both) HDR_RX PD28 URXD3 GPIO_UART3_RXD + D1 PD30 (both) HDR_TX PD30 UTXD3 GPIO_UART3_TXD_1 + D2 PA5 microBUS1 GPIO interrupt input PA5 + D3 PA6 microBUS2 GPIO interrupt input PA6 + D4 PD27 *** Not used *** + D5 PD11 microBUS2 PWM PD11 PWMC0_H0 + D6 PC19 microBUS1 PWN PC19 PWMC0_H2 + D7 PA2 *** Not used *** + D9 PC9 microBUS2 CS GPIO output PC9 + D10 PD25 microBUS1 CS GPIO output PD25 SPI0_NPCS1 + D11 PD21 (both) SPI-MOSI PD21 SPI0_MOSI GPIO_SPI0_MOSI + D12 PD20 (both) SPI-MISO PD20 SPI0_MISO GPIO_SPI0_MISO + D13 PD22 (both) SPI-SCK PD22 SPI0_SPCK GPIO_SPI0_SPCK Tickless OS =========== diff --git a/configs/samv71-xult/src/sam_mrf24j40.c b/configs/samv71-xult/src/sam_mrf24j40.c index eeb894be93e..9748ea08183 100644 --- a/configs/samv71-xult/src/sam_mrf24j40.c +++ b/configs/samv71-xult/src/sam_mrf24j40.c @@ -167,8 +167,8 @@ static void sam_enable_irq(FAR const struct mrf24j40_lower_s *lower, * has not yet been 'attached' */ - wlinfo("state:%d\n", (int)state); DEBUGASSERT(priv != NULL); + wlinfo("state: %d irq: %u\n", (int)state, priv->irq); /* Has the interrupt state changed */ diff --git a/configs/samv71-xult/src/samv71-xult.h b/configs/samv71-xult/src/samv71-xult.h index a619a735ca9..fcbef2b7f02 100644 --- a/configs/samv71-xult/src/samv71-xult.h +++ b/configs/samv71-xult/src/samv71-xult.h @@ -558,7 +558,34 @@ #define WM8904_SSC_BUS 0 -/* Click Shield */ +/* Click Shield + * + * --- ----- ------------------------------ --------------------------------- + * PIN PORT SHIELD FUNCTION PIN CONFIGURATION + * --- ----- ------------------------------ --------------------------------- + * AD0 PD26 microBUS2 Analog TD PD26 *** Not an AFE pin *** + * AD1 PC31 microBUS2 Analog PC31 AFE1_AD6 GPIO_AFE1_AD6 + * AD2 PD30 microBUS2 GPIO reset output PD30 + * AD3 PA19 microBUS1 GPIO reset output PA19 + * AD4 PC13 (both) I2C-SDA PC13 *** Does not support I2C SDA *** + * AD5 PC30 (both) I2C-SCL PC30 *** Does not support I2C SCL *** + * AD6 PA17 *** Not used *** + * AD7 PC12 *** Not used *** + * D0 PD28 (both) HDR_RX PD28 URXD3 GPIO_UART3_RXD + * D1 PD30 (both) HDR_TX PD30 UTXD3 GPIO_UART3_TXD_1 + * D2 PA5 microBUS1 GPIO interrupt input PA5 + * D3 PA6 microBUS2 GPIO interrupt input PA6 + * D4 PD27 *** Not used *** + * D5 PD11 microBUS2 PWM PD11 PWMC0_H0 + * D6 PC19 microBUS1 PWN PC19 PWMC0_H2 + * D7 PA2 *** Not used *** + * D9 PC9 microBUS2 CS GPIO output PC9 + * D10 PD25 microBUS1 CS GPIO output PD25 SPI0_NPCS1 + * D11 PD21 (both) SPI-MOSI PD21 SPI0_MOSI GPIO_SPI0_MOSI + * D12 PD20 (both) SPI-MISO PD20 SPI0_MISO GPIO_SPI0_MISO + * D13 PD22 (both) SPI-SCK PD22 SPI0_SPCK GPIO_SPI0_SPCK + */ + /* Reset (RST#) Pulled-up on the click board */ #define CLICK_MB1_RESET (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ @@ -568,11 +595,11 @@ /* Interrupts */ #define CLICK_MB1_INTR (GPIO_INPUT | GPIO_CFG_DEFAULT | GPIO_CFG_DEGLITCH | \ - GPIO_INT_FALLING | GPIO_PORT_PIOA | GPIO_PIN0) + GPIO_INT_FALLING | GPIO_PORT_PIOA | GPIO_PIN5) #define CLICK_MB2_INTR (GPIO_INPUT | GPIO_CFG_DEFAULT | GPIO_CFG_DEGLITCH | \ GPIO_INT_FALLING | GPIO_PORT_PIOA | GPIO_PIN6) -#define IRQ_MB1 SAM_IRQ_PA0 +#define IRQ_MB1 SAM_IRQ_PA5 #define IRQ_MB2 SAM_IRQ_PA6 /* SP chip selects */ From 445af2e5a06a29fe11a9bee2612ca6d63da4f2eb Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 3 Jul 2017 12:06:17 -0600 Subject: [PATCH 18/33] samv71-xult/mrf24j40-starhub: Should have pull-ups on interrupting inputs. --- configs/samv71-xult/README.txt | 1 + configs/samv71-xult/src/samv71-xult.h | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/configs/samv71-xult/README.txt b/configs/samv71-xult/README.txt index d50a022d989..3db6d01f1d6 100644 --- a/configs/samv71-xult/README.txt +++ b/configs/samv71-xult/README.txt @@ -1489,6 +1489,7 @@ Click Shield D5 PD11 microBUS2 PWM PD11 PWMC0_H0 D6 PC19 microBUS1 PWN PC19 PWMC0_H2 D7 PA2 *** Not used *** + D8 PA17 *** Not used *** D9 PC9 microBUS2 CS GPIO output PC9 D10 PD25 microBUS1 CS GPIO output PD25 SPI0_NPCS1 D11 PD21 (both) SPI-MOSI PD21 SPI0_MOSI GPIO_SPI0_MOSI diff --git a/configs/samv71-xult/src/samv71-xult.h b/configs/samv71-xult/src/samv71-xult.h index fcbef2b7f02..5bb24665267 100644 --- a/configs/samv71-xult/src/samv71-xult.h +++ b/configs/samv71-xult/src/samv71-xult.h @@ -579,6 +579,7 @@ * D5 PD11 microBUS2 PWM PD11 PWMC0_H0 * D6 PC19 microBUS1 PWN PC19 PWMC0_H2 * D7 PA2 *** Not used *** + * D8 PA17 *** Not used *** * D9 PC9 microBUS2 CS GPIO output PC9 * D10 PD25 microBUS1 CS GPIO output PD25 SPI0_NPCS1 * D11 PD21 (both) SPI-MOSI PD21 SPI0_MOSI GPIO_SPI0_MOSI @@ -594,9 +595,9 @@ GPIO_PORT_PIOA | GPIO_PIN19) /* Interrupts */ -#define CLICK_MB1_INTR (GPIO_INPUT | GPIO_CFG_DEFAULT | GPIO_CFG_DEGLITCH | \ +#define CLICK_MB1_INTR (GPIO_INPUT | GPIO_CFG_PULLUP | GPIO_CFG_DEGLITCH | \ GPIO_INT_FALLING | GPIO_PORT_PIOA | GPIO_PIN5) -#define CLICK_MB2_INTR (GPIO_INPUT | GPIO_CFG_DEFAULT | GPIO_CFG_DEGLITCH | \ +#define CLICK_MB2_INTR (GPIO_INPUT | GPIO_CFG_PULLUP | GPIO_CFG_DEGLITCH | \ GPIO_INT_FALLING | GPIO_PORT_PIOA | GPIO_PIN6) #define IRQ_MB1 SAM_IRQ_PA5 From 72c4f12286a8f421ced322f5136a4988eca4cda8 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 3 Jul 2017 12:37:37 -0600 Subject: [PATCH 19/33] samv71-xult/mrf24j40-starhub: Reset pins backward; update README. --- configs/samv71-xult/README.txt | 5 +++++ configs/samv71-xult/src/samv71-xult.h | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/configs/samv71-xult/README.txt b/configs/samv71-xult/README.txt index 3db6d01f1d6..56d2620ff0c 100644 --- a/configs/samv71-xult/README.txt +++ b/configs/samv71-xult/README.txt @@ -1943,6 +1943,11 @@ Configuration sub-directories STATUS: 2017-07-02: Configurations added. Not yet tested. + 2017-07-03: Initial testing, appears to be working, but endpoints + fail to associate; sniffer shows that nothing sent fro the star + hub. I am thinking that there is something wrong with the + GPIO interrupt configuration so that no MRF24J40 interrupt are + being received. mxtxplnd: diff --git a/configs/samv71-xult/src/samv71-xult.h b/configs/samv71-xult/src/samv71-xult.h index 5bb24665267..789bfb925fc 100644 --- a/configs/samv71-xult/src/samv71-xult.h +++ b/configs/samv71-xult/src/samv71-xult.h @@ -576,8 +576,8 @@ * D2 PA5 microBUS1 GPIO interrupt input PA5 * D3 PA6 microBUS2 GPIO interrupt input PA6 * D4 PD27 *** Not used *** - * D5 PD11 microBUS2 PWM PD11 PWMC0_H0 - * D6 PC19 microBUS1 PWN PC19 PWMC0_H2 + * D5 PD11 microBUS2 PWMB PD11 PWMC0_H0 + * D6 PC19 microBUS1 PWMA PC19 PWMC0_H2 * D7 PA2 *** Not used *** * D8 PA17 *** Not used *** * D9 PC9 microBUS2 CS GPIO output PC9 @@ -590,9 +590,9 @@ /* Reset (RST#) Pulled-up on the click board */ #define CLICK_MB1_RESET (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ - GPIO_PORT_PIOD | GPIO_PIN30) -#define CLICK_MB2_RESET (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ GPIO_PORT_PIOA | GPIO_PIN19) +#define CLICK_MB2_RESET (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ + GPIO_PORT_PIOD | GPIO_PIN30) /* Interrupts */ #define CLICK_MB1_INTR (GPIO_INPUT | GPIO_CFG_PULLUP | GPIO_CFG_DEGLITCH | \ From 5060a7cdf219bd2b3170c9e9901d98ae8bd1c238 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 3 Jul 2017 13:00:30 -0600 Subject: [PATCH 20/33] samv71-xult/mrf24j40: Add reset logic (but comment out because it is not necessary) --- configs/samv71-xult/src/sam_mrf24j40.c | 24 ++++++++++++++++++++++++ configs/samv71-xult/src/samv71-xult.h | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/configs/samv71-xult/src/sam_mrf24j40.c b/configs/samv71-xult/src/sam_mrf24j40.c index 9748ea08183..370706204d9 100644 --- a/configs/samv71-xult/src/sam_mrf24j40.c +++ b/configs/samv71-xult/src/sam_mrf24j40.c @@ -57,6 +57,12 @@ #ifdef HAVE_MRF24J40 +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#undef BEE_RESET + /**************************************************************************** * Private Types ****************************************************************************/ @@ -65,6 +71,9 @@ struct sam_priv_s { struct mrf24j40_lower_s dev; uint32_t intcfg; +#ifdef BEE_RESET + uint32_t rstcfg; +#endif uint8_t irq; uint8_t spidev; }; @@ -108,6 +117,9 @@ static struct sam_priv_s g_mrf24j40_mb1_priv = .dev.attach = sam_attach_irq, .dev.enable = sam_enable_irq, .intcfg = CLICK_MB1_INTR, +#ifdef BEE_RESET + .rstcfg = CLICK_MB1_RESET, +#endif .irq = IRQ_MB1, .spidev = 0, }; @@ -119,6 +131,9 @@ static struct sam_priv_s g_mrf24j40_mb2_priv = .dev.attach = sam_attach_irq, .dev.enable = sam_enable_irq, .intcfg = CLICK_MB2_INTR, +#ifdef BEE_RESET + .rstcfg = CLICK_MB2_RESET, +#endif .irq = IRQ_MB2, .spidev = 0, }; @@ -213,6 +228,15 @@ static int sam_mrf24j40_devsetup(FAR struct sam_priv_s *priv) FAR struct spi_dev_s *spi; int ret; +#ifdef BEE_RESET + /* Bring the MRF24J40 out of reset + * NOTE: Not necessary. The RST# input is pulled high on the BEE. + */ + + (void)sam_configgpio(priv->rstcfg); + sam_gpiowrite(priv->rstcfg, true); +#endif + /* Configure the interrupt pin */ (void)sam_configgpio(priv->intcfg); diff --git a/configs/samv71-xult/src/samv71-xult.h b/configs/samv71-xult/src/samv71-xult.h index 789bfb925fc..2db049c86dd 100644 --- a/configs/samv71-xult/src/samv71-xult.h +++ b/configs/samv71-xult/src/samv71-xult.h @@ -593,7 +593,8 @@ GPIO_PORT_PIOA | GPIO_PIN19) #define CLICK_MB2_RESET (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ GPIO_PORT_PIOD | GPIO_PIN30) -/* Interrupts */ + +/* Interrupts. No pull-ups on the BEE; assumig active low. */ #define CLICK_MB1_INTR (GPIO_INPUT | GPIO_CFG_PULLUP | GPIO_CFG_DEGLITCH | \ GPIO_INT_FALLING | GPIO_PORT_PIOA | GPIO_PIN5) From 81cd76484f40361068b71b06634cff9f1a496f1e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 3 Jul 2017 15:34:28 -0600 Subject: [PATCH 21/33] Add some partial IP forwarding logic. --- net/devif/ipv6_forward.c | 254 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 237 insertions(+), 17 deletions(-) diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index b84891e4da1..aaaf1dfd115 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -52,6 +52,35 @@ #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv6) +/**************************************************************************** + * Private Types + ****************************************************************************/ + +#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_ICMPv6) +/* IPv6 + UDP or ICMPv6 header */ + +struct ipv6l3_hdr_s +{ + struct ipv6_hdr_s ipv6; + union + { +#ifdef CONFIG_NET_UDP + struct udp_hdr_s udp; +#ifdef CONFIG_NET_ICMPv6 + struct icmpv6_iphdr_s icmp; + } u; +}; +#endif + +/* This is the send state structure */ + +struct forward_s +{ + FAR net_driver_s *dev; /* Forwarding device */ + struct ipv6l3_hdr_s hdr; /* Copy of origin L2+L3 headers */ + FAR struct iob_queue_s iobq; /* IOBs contained the data payload */ +}; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -118,6 +147,149 @@ static int ipv6_packet_conversion(FAR struct net_driver_s *dev, # define ipv6_packet_conversion(dev, ipv6) #endif /* CONFIG_NET_6LOWPAN */ +/**************************************************************************** + * Name: ipv6_hdrsize + * + * Description: + * Return the size of the IPv6 header and the following. + * + * Input Parameters: + * ipv6 - A pointer to the IPv6 header in within the IPv6 packet. This + * is immeidately followed by the L3 header which may be TCP, UDP, + * or ICMPv6. + * + * Returned Value: + * The size of the combined L2 + L3 headers is returned on success. An + * error is returned only if the prototype is not supported. + * + ****************************************************************************/ + +static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6) +{ + /* Copy the following protocol header, */ + + switch (ipv6->proto) + { +#ifdef CONFIG_NET_TCP + case IP_PROTO_TCP: + { + FAR struct tcp_hdr_s *tcp = + (FAR struct tcp_hdr_s *)((FAR uintptr_t *)ipv6 + IPv6_HDRLEN); + unsigned int tcpsize; + + /* The TCP header length is encoded in the top 4 bits of the + * tcpoffset field (in units of 32-bit words). + */ + + tcpsize = ((uint16_t)tcp->tcpoffset >> 4) << 2; + return IPv6_HDRLEN + tcpsize; + } + break; +#endif + +#ifdef CONFIG_NET_UDP + case IP_PROTO_UDP: + return IPv6_HDRLEN + UDP_HDRLEN; + break; +#endif + +#ifdef CONFIG_NET_ICMPv6 + case IP_PROTO_ICMP6: + return IPv6_HDRLEN + ICMPv6_HDRLEN; + break; +#endif + + default: + nwarn("WARNING: Unrecognized proto: %u\n", ipv6->proto); + return -EPROTONOSUPPORT; + } +} + +/**************************************************************************** + * Name: ipv6_dev_forward + * + * Description: + * Set up to forward the UDP or ICMPv6 packet on the specified device. + * This function will set up a send "interrupt" handler that will perform + * the actual send asynchronously. + * + * Input Parameters: + * dev - The device on which the packet was received and which contains + * the IPv6 packet. + * ipv6 - A convenience pointer to the IPv6 header in within the IPv6 + * packet. This is immeidately followed by the L3 header which may + * be UDP or ICMPv6. + * iob - A list of IOBs containing the data payload to be sent. + * + * + * On input: + * - dev->d_buf holds the received packet. + * - dev->d_len holds the length of the received packet MINUS the + * size of the L1 header. That was subtracted out by ipv6_input. + * - ipv6 points to the IPv6 header with dev->d_buf. + * + * Returned Value: + * Zero is returned if the packet was successfully forward; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller (ipv6_input()) should drop the packet. + * + ****************************************************************************/ + +#if defined(CONFIG_NETDEV_MULTINIC) +static int ipv6_dev_forward(FAR struct net_driver_s *dev, + FAR struct ipv6_hdr_s *ipv6, + FAR struct iob_s *iob) +{ + /* Notify the forwarding device that TX data is available */ + + /* Set up to send the packet when the selected device polls for TX data. + * If the packet is TCP, it must obey ACK and windowing rules. + */ + +#warning Missing logic + + /* REVISIT: For Ethernet we may have to fix up the Ethernet header: + * - source MAC, the MAC of the current device. + * - dest MAC, the MAC associated with the destination IPv6 adress. + * This will involve ICMPv6 and Neighbor Discovery. + * - Because of TCP window, the packet may have to be sent in smaller + * pieces. + */ + +# warning Missing logic + nwarn("WARNING: UPD/ICMPv6 packet forwarding not yet supported\n"); + return -ENOSYS; +} +#endif + +/**************************************************************************** + * Name: ipv6_dropstats + * + * Description: + * Update statistics for a droped packet. + * + * Input Parameters: + * ipv6 - A convenience pointer to the IPv6 header in within the IPv6 + * packet to be dropped. + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_NET_STATISTICS +static void ipv6_dropstats(FAR struct ipv6_hdr_s *ipv) +{ +g_netstats.icmpv6.drop++ +g_netstats.udp.drop++; +g_netstats.tcp.drop++; + +g_netstats.ipv6.drop++ +} +#else +# define ipv6_dropstats(ipv6) +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -187,35 +359,83 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) ret = ipv6_packet_conversion(dev, fwddev, ipv6); if (ret < 0) { - /* Extract the IPv6 + L3 header; Move the data payload to an IOB - * chain. + FAR struct iob_s *iob = NULL; + FAR uint8_t *payload; + unsigned int paysize; + int hdrsize; + + /* Get the size of the IPv6 + L3 header. Use this to determine + * start of the data payload. + * + * Remember that the size of the L1 header has already been + * subtracted from dev->d_len. */ - /* Notify the forwarding device that TX data is available */ + hdrsize = ipv6_hdrsize(ipv6); + if (hdrsize < 0) + { + goto drop; + } - /* Set up to send the packet when the selected device polls for TX - * data. - */ + payload = (FAR uint8_t *)ipv6 + hdrsize; + paysize = dev->d_len - hdrsize; - /* REVISIT: For Ethernet we may have to fix up the Ethernet header: - * - source MAC, the MAC of the current device. - * - dest MAC, the MAC associated with the destination IPv6 adress. - * This will involve ICMPv6 and Neighbor Discovery. - */ + if (paysize > 0) + { + /* Try to allocate the head of an IOB chain. If this fails, + * the the packet will be dropped; we are not operating in a + * context where waiting for an IOB is a good idea + */ - /* Return success with dev->d_len = 0 */ + iob = iob_tryalloc(false); + if (iob == NULL) + { + ret = -ENOMEM; + goto errout_with_iob; + } -# warning Missing logic - nwarn("WARNING: Packet forwarding not yet supported " - "across different devices\n"); + /* Copy the packet data payload into an IOB chain. + * iob_trycopin() will not wait, but will fail there are no + * available IOBs. + */ + + ret = iob_trycopyin(iob, payload, paysize, 0); + if (ret < 0) + { + goto errout_with_iob; + } + } + + /* Then set up to forward the packet */ + + if (ipv6->proto == IP_PROTO_TCP) + { + ret = tcp_ipv6_forward(dev, ipv6, iob); + } + else + { + ret = ipv6_dev_forward(dev, ipv6, iob); + } + + if (ret >= 0) + { + dev->d_len = 0; + return OK; + } + +errout_with_iob: + iob_free_chain(iob); + +drop: + ipv6_dropstats(ipv6); + dev->d_len = 0; return -ENOSYS; } } else #endif /* CONFIG_NETDEV_MULTINIC */ -#if defined(CONFIG_NET_6LOWPAN) /* REVISIT: Currently only suport for - * 6LoWPAN */ +#if defined(CONFIG_NET_6LOWPAN) /* REVISIT: Currently only suport for 6LoWPAN */ { /* Single network device */ From 83a875f39483cbc3a2b57f86ade9ef29fd65e878 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 3 Jul 2017 15:58:01 -0600 Subject: [PATCH 22/33] IP forwarding: Add some fragments of TCP forwarding logic. --- net/devif/ipv6_forward.c | 66 ++++++++++++++----------- net/tcp/Make.defs | 6 +++ net/tcp/tcp.h | 28 +++++++++++ net/tcp/tcp_forward.c | 101 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 172 insertions(+), 29 deletions(-) create mode 100644 net/tcp/tcp_forward.c diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index aaaf1dfd115..2c3d0a82658 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -166,7 +166,7 @@ static int ipv6_packet_conversion(FAR struct net_driver_s *dev, static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6) { - /* Copy the following protocol header, */ + /* Size is determined by the following protocol header, */ switch (ipv6->proto) { @@ -211,27 +211,20 @@ static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6) * Description: * Set up to forward the UDP or ICMPv6 packet on the specified device. * This function will set up a send "interrupt" handler that will perform - * the actual send asynchronously. + * the actual send asynchronously and must return without waiting for the + * send to complete. * * Input Parameters: - * dev - The device on which the packet was received and which contains - * the IPv6 packet. - * ipv6 - A convenience pointer to the IPv6 header in within the IPv6 - * packet. This is immeidately followed by the L3 header which may - * be UDP or ICMPv6. + * dev - The device on which the packet should be forwarded. + * ipv6 - A pointer to the IPv6 header in within the IPv6 packet. This + * is immeidately followed by the L3 header which may be UDP or + * ICMPv6. * iob - A list of IOBs containing the data payload to be sent. * - * - * On input: - * - dev->d_buf holds the received packet. - * - dev->d_len holds the length of the received packet MINUS the - * size of the L1 header. That was subtracted out by ipv6_input. - * - ipv6 points to the IPv6 header with dev->d_buf. - * * Returned Value: - * Zero is returned if the packet was successfully forward; A negated + * Zero is returned if the packet was successfully forwarded; A negated * errno value is returned if the packet is not forwardable. In that - * latter case, the caller (ipv6_input()) should drop the packet. + * latter case, the caller should free the IOB list and drop the packet. * ****************************************************************************/ @@ -242,9 +235,7 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, { /* Notify the forwarding device that TX data is available */ - /* Set up to send the packet when the selected device polls for TX data. - * If the packet is TCP, it must obey ACK and windowing rules. - */ + /* Set up to send the packet when the selected device polls for TX data. */ #warning Missing logic @@ -252,12 +243,9 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, * - source MAC, the MAC of the current device. * - dest MAC, the MAC associated with the destination IPv6 adress. * This will involve ICMPv6 and Neighbor Discovery. - * - Because of TCP window, the packet may have to be sent in smaller - * pieces. */ -# warning Missing logic - nwarn("WARNING: UPD/ICMPv6 packet forwarding not yet supported\n"); + nwarn("WARNING: UPD/ICMPv6 packet forwarding not yet supported\n"); return -ENOSYS; } #endif @@ -280,11 +268,31 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, #ifdef CONFIG_NET_STATISTICS static void ipv6_dropstats(FAR struct ipv6_hdr_s *ipv) { -g_netstats.icmpv6.drop++ -g_netstats.udp.drop++; -g_netstats.tcp.drop++; + switch (ipv6->proto) + { +#ifdef CONFIG_NET_TCP + case IP_PROTO_TCP: + g_netstats.tcp.drop++; + break; +#endif -g_netstats.ipv6.drop++ +#ifdef CONFIG_NET_UDP + case IP_PROTO_UDP: + g_netstats.udp.drop++; + break; +#endif + +#ifdef CONFIG_NET_ICMPv6 + case IP_PROTO_ICMP6: + g_netstats.icmpv6.drop++ + break; +#endif + + default: + break; + } + + g_netstats.ipv6.drop++ } #else # define ipv6_dropstats(ipv6) @@ -410,11 +418,11 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) if (ipv6->proto == IP_PROTO_TCP) { - ret = tcp_ipv6_forward(dev, ipv6, iob); + ret = tcp_ipv6_forward(fwddev, ipv6, iob); } else { - ret = ipv6_dev_forward(dev, ipv6, iob); + ret = ipv6_dev_forward(fwddev, ipv6, iob); } if (ret >= 0) diff --git a/net/tcp/Make.defs b/net/tcp/Make.defs index 29b6167a65f..f9e7c893882 100644 --- a/net/tcp/Make.defs +++ b/net/tcp/Make.defs @@ -60,6 +60,12 @@ NET_CSRCS += tcp_conn.c tcp_seqno.c tcp_devpoll.c tcp_finddev.c tcp_timer.c NET_CSRCS += tcp_send.c tcp_input.c tcp_appsend.c tcp_listen.c NET_CSRCS += tcp_callback.c tcp_backlog.c tcp_ipselect.c +# IP forwarding + +ifeq ($(CONFIG_NET_IPFORWARD),y) +NET_CSRCS += tcp_forward.c +endif + # TCP write buffering ifeq ($(CONFIG_NET_TCP_WRITE_BUFFERS),y) diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h index 83891b10244..a56068b147f 100644 --- a/net/tcp/tcp.h +++ b/net/tcp/tcp.h @@ -794,6 +794,34 @@ int tcp_accept_connection(FAR struct net_driver_s *dev, void tcp_send(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, uint16_t flags, uint16_t len); +/**************************************************************************** + * Name: tcp_ipv6_forward + * + * Description: + * Set up to forward the TCP packet on the specified device. This + * function will set up a send "interrupt" handler that will perform + * the actual send asynchronously and must return without waiting for the + * send to complete. + * + * Input Parameters: + * dev - The device on which the packet should be forwarded. + * ipv6 - A pointer to the IPv6 header in within the IPv6 packet. This + * is immeidately followed by the TCP header. + * iob - A list of IOBs containing the data payload to be sent. + * + * Returned Value: + * Zero is returned if the packet was successfully forwarded; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller should free the IOB list and drop the packet. + * + ****************************************************************************/ + +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv6) && \ + defined(CONFIG_NETDEV_MULTINIC) +int tcp_ipv6_forward(FAR struct net_driver_s *dev, + FAR struct ipv6_hdr_s *ipv6, FAR struct iob_s *iob); +#endif + /**************************************************************************** * Name: tcp_reset * diff --git a/net/tcp/tcp_forward.c b/net/tcp/tcp_forward.c new file mode 100644 index 00000000000..11972242291 --- /dev/null +++ b/net/tcp/tcp_forward.c @@ -0,0 +1,101 @@ +/**************************************************************************** + * net/tcp/tcp_forward.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include +#include + +#include "tcp/tcp.h" + +#if defined(CONFIG_NET) && defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_TCP) + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tcp_ipv6_forward + * + * Description: + * Set up to forward the TCP packet on the specified device. This + * function will set up a send "interrupt" handler that will perform + * the actual send asynchronously and must return without waiting for the + * send to complete. + * + * Input Parameters: + * dev - The device on which the packet should be forwarded. + * ipv6 - A pointer to the IPv6 header in within the IPv6 packet. This + * is immeidately followed by the TCP header. + * iob - A list of IOBs containing the data payload to be sent. + * + * Returned Value: + * Zero is returned if the packet was successfully forwarded; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller should free the IOB list and drop the packet. + * + ****************************************************************************/ + +#if defined(CONFIG_NET_IPv6) && defined(CONFIG_NETDEV_MULTINIC) +int tcp_ipv6_forward(FAR struct net_driver_s *dev, + FAR struct ipv6_hdr_s *ipv6, FAR struct iob_s *iob) +{ + /* Notify the forwarding device that TX data is available */ + + /* Set up to send the packet when the selected device polls for TX data. + * TCP packets must obey ACK and windowing rules. + */ + +#warning Missing logic + + /* REVISIT: For Ethernet we may have to fix up the Ethernet header: + * - source MAC, the MAC of the current device. + * - dest MAC, the MAC associated with the destination IPv6 adress. + * This will involve ICMPv6 and Neighbor Discovery. + * - Because of TCP window, the packet may have to be sent in smaller + * pieces. + */ + + nwarn("WARNING: TCP packet forwarding not yet supported\n"); + return -ENOSYS; +} +#endif /* CONFIG_NET_IPv6 && CONFIG_NETDEV_MULTINIC */ +#endif /* CONFIG_NET && CONFIG_NET_IPFORWARD && CONFIG_NET_TCP */ From eafcf4d05907da121f7b5869be3fb6ee7b1ce891 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 3 Jul 2017 16:02:59 -0600 Subject: [PATCH 23/33] Clean up some conditional logic --- net/devif/ipv6_forward.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index 2c3d0a82658..c90e1aebeb0 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -228,7 +228,8 @@ static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6) * ****************************************************************************/ -#if defined(CONFIG_NETDEV_MULTINIC) +#if defined(CONFIG_NETDEV_MULTINIC) && \ + (defined(CONFIG_NET_UDP) || defined(CONFIG_NET_ICMPv6)) static int ipv6_dev_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6, FAR struct iob_s *iob) @@ -248,6 +249,8 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, nwarn("WARNING: UPD/ICMPv6 packet forwarding not yet supported\n"); return -ENOSYS; } +#else +# define ipv6_dev_forward(dev,ipv6,iob) -EPROTONOSUPPORT #endif /**************************************************************************** @@ -416,12 +419,18 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) /* Then set up to forward the packet */ +#ifdef CONFIG_NET_TCP if (ipv6->proto == IP_PROTO_TCP) { + /* Forward a TCP packet, handling ACKs, windowing, etc. */ + ret = tcp_ipv6_forward(fwddev, ipv6, iob); } else +#endif { + /* Forward a UDP or ICMPv6 packet */ + ret = ipv6_dev_forward(fwddev, ipv6, iob); } From 856d7e73b7f9fb1445d5f776b906ce31b9d04710 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 3 Jul 2017 16:22:25 -0600 Subject: [PATCH 24/33] Some compile time fixes --- net/devif/ipv6_forward.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index c90e1aebeb0..a8c69d24baa 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -42,12 +42,14 @@ #include #include +#include #include #include #include #include "netdev/netdev.h" #include "sixlowpan/sixlowpan.h" +#include "tcp/tcp.h" #include "devif/devif.h" #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv6) @@ -56,7 +58,9 @@ * Private Types ****************************************************************************/ -#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_ICMPv6) +#if defined(CONFIG_NETDEV_MULTINIC) && \ + (defined(CONFIG_NET_UDP) || defined(CONFIG_NET_ICMPv6)) + /* IPv6 + UDP or ICMPv6 header */ struct ipv6l3_hdr_s @@ -66,21 +70,24 @@ struct ipv6l3_hdr_s { #ifdef CONFIG_NET_UDP struct udp_hdr_s udp; +#endif #ifdef CONFIG_NET_ICMPv6 struct icmpv6_iphdr_s icmp; +#endif } u; }; -#endif /* This is the send state structure */ struct forward_s { - FAR net_driver_s *dev; /* Forwarding device */ - struct ipv6l3_hdr_s hdr; /* Copy of origin L2+L3 headers */ - FAR struct iob_queue_s iobq; /* IOBs contained the data payload */ + FAR struct net_driver_s *dev; /* Forwarding device */ + struct ipv6l3_hdr_s hdr; /* Copy of origin L2+L3 headers */ + FAR struct iob_queue_s iobq; /* IOBs contained the data payload */ }; +#endif /* CONFIG_NETDEV_MULTINIC && (CONFIG_NET_UDP || CONFIG_NET_ICMPv6) */ + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -164,6 +171,7 @@ static int ipv6_packet_conversion(FAR struct net_driver_s *dev, * ****************************************************************************/ +#ifdef CONFIG_NETDEV_MULTINIC static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6) { /* Size is determined by the following protocol header, */ @@ -204,6 +212,7 @@ static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6) return -EPROTONOSUPPORT; } } +#endif /**************************************************************************** * Name: ipv6_dev_forward @@ -269,7 +278,7 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, ****************************************************************************/ #ifdef CONFIG_NET_STATISTICS -static void ipv6_dropstats(FAR struct ipv6_hdr_s *ipv) +static void ipv6_dropstats(FAR struct ipv6_hdr_s *ipv6) { switch (ipv6->proto) { @@ -287,7 +296,7 @@ static void ipv6_dropstats(FAR struct ipv6_hdr_s *ipv) #ifdef CONFIG_NET_ICMPv6 case IP_PROTO_ICMP6: - g_netstats.icmpv6.drop++ + g_netstats.icmpv6.drop++; break; #endif @@ -295,7 +304,7 @@ static void ipv6_dropstats(FAR struct ipv6_hdr_s *ipv) break; } - g_netstats.ipv6.drop++ + g_netstats.ipv6.drop++; } #else # define ipv6_dropstats(ipv6) @@ -410,7 +419,7 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) * available IOBs. */ - ret = iob_trycopyin(iob, payload, paysize, 0); + ret = iob_trycopyin(iob, payload, paysize, 0, false); if (ret < 0) { goto errout_with_iob; From eba16af7ba9eb3b56c3352b9ca35099f5cd9e705 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 3 Jul 2017 16:22:57 -0600 Subject: [PATCH 25/33] Adds a little more IP foward framework --- net/devif/ipv6_forward.c | 280 ++++++++++++++++++++++++++++++++++++--- net/tcp/Make.defs | 6 + net/tcp/tcp.h | 28 ++++ net/tcp/tcp_forward.c | 101 ++++++++++++++ 4 files changed, 398 insertions(+), 17 deletions(-) create mode 100644 net/tcp/tcp_forward.c diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index b84891e4da1..a8c69d24baa 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -42,16 +42,52 @@ #include #include +#include #include #include #include #include "netdev/netdev.h" #include "sixlowpan/sixlowpan.h" +#include "tcp/tcp.h" #include "devif/devif.h" #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv6) +/**************************************************************************** + * Private Types + ****************************************************************************/ + +#if defined(CONFIG_NETDEV_MULTINIC) && \ + (defined(CONFIG_NET_UDP) || defined(CONFIG_NET_ICMPv6)) + +/* IPv6 + UDP or ICMPv6 header */ + +struct ipv6l3_hdr_s +{ + struct ipv6_hdr_s ipv6; + union + { +#ifdef CONFIG_NET_UDP + struct udp_hdr_s udp; +#endif +#ifdef CONFIG_NET_ICMPv6 + struct icmpv6_iphdr_s icmp; +#endif + } u; +}; + +/* This is the send state structure */ + +struct forward_s +{ + FAR struct net_driver_s *dev; /* Forwarding device */ + struct ipv6l3_hdr_s hdr; /* Copy of origin L2+L3 headers */ + FAR struct iob_queue_s iobq; /* IOBs contained the data payload */ +}; + +#endif /* CONFIG_NETDEV_MULTINIC && (CONFIG_NET_UDP || CONFIG_NET_ICMPv6) */ + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -118,6 +154,162 @@ static int ipv6_packet_conversion(FAR struct net_driver_s *dev, # define ipv6_packet_conversion(dev, ipv6) #endif /* CONFIG_NET_6LOWPAN */ +/**************************************************************************** + * Name: ipv6_hdrsize + * + * Description: + * Return the size of the IPv6 header and the following. + * + * Input Parameters: + * ipv6 - A pointer to the IPv6 header in within the IPv6 packet. This + * is immeidately followed by the L3 header which may be TCP, UDP, + * or ICMPv6. + * + * Returned Value: + * The size of the combined L2 + L3 headers is returned on success. An + * error is returned only if the prototype is not supported. + * + ****************************************************************************/ + +#ifdef CONFIG_NETDEV_MULTINIC +static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6) +{ + /* Size is determined by the following protocol header, */ + + switch (ipv6->proto) + { +#ifdef CONFIG_NET_TCP + case IP_PROTO_TCP: + { + FAR struct tcp_hdr_s *tcp = + (FAR struct tcp_hdr_s *)((FAR uintptr_t *)ipv6 + IPv6_HDRLEN); + unsigned int tcpsize; + + /* The TCP header length is encoded in the top 4 bits of the + * tcpoffset field (in units of 32-bit words). + */ + + tcpsize = ((uint16_t)tcp->tcpoffset >> 4) << 2; + return IPv6_HDRLEN + tcpsize; + } + break; +#endif + +#ifdef CONFIG_NET_UDP + case IP_PROTO_UDP: + return IPv6_HDRLEN + UDP_HDRLEN; + break; +#endif + +#ifdef CONFIG_NET_ICMPv6 + case IP_PROTO_ICMP6: + return IPv6_HDRLEN + ICMPv6_HDRLEN; + break; +#endif + + default: + nwarn("WARNING: Unrecognized proto: %u\n", ipv6->proto); + return -EPROTONOSUPPORT; + } +} +#endif + +/**************************************************************************** + * Name: ipv6_dev_forward + * + * Description: + * Set up to forward the UDP or ICMPv6 packet on the specified device. + * This function will set up a send "interrupt" handler that will perform + * the actual send asynchronously and must return without waiting for the + * send to complete. + * + * Input Parameters: + * dev - The device on which the packet should be forwarded. + * ipv6 - A pointer to the IPv6 header in within the IPv6 packet. This + * is immeidately followed by the L3 header which may be UDP or + * ICMPv6. + * iob - A list of IOBs containing the data payload to be sent. + * + * Returned Value: + * Zero is returned if the packet was successfully forwarded; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller should free the IOB list and drop the packet. + * + ****************************************************************************/ + +#if defined(CONFIG_NETDEV_MULTINIC) && \ + (defined(CONFIG_NET_UDP) || defined(CONFIG_NET_ICMPv6)) +static int ipv6_dev_forward(FAR struct net_driver_s *dev, + FAR struct ipv6_hdr_s *ipv6, + FAR struct iob_s *iob) +{ + /* Notify the forwarding device that TX data is available */ + + /* Set up to send the packet when the selected device polls for TX data. */ + +#warning Missing logic + + /* REVISIT: For Ethernet we may have to fix up the Ethernet header: + * - source MAC, the MAC of the current device. + * - dest MAC, the MAC associated with the destination IPv6 adress. + * This will involve ICMPv6 and Neighbor Discovery. + */ + + nwarn("WARNING: UPD/ICMPv6 packet forwarding not yet supported\n"); + return -ENOSYS; +} +#else +# define ipv6_dev_forward(dev,ipv6,iob) -EPROTONOSUPPORT +#endif + +/**************************************************************************** + * Name: ipv6_dropstats + * + * Description: + * Update statistics for a droped packet. + * + * Input Parameters: + * ipv6 - A convenience pointer to the IPv6 header in within the IPv6 + * packet to be dropped. + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_NET_STATISTICS +static void ipv6_dropstats(FAR struct ipv6_hdr_s *ipv6) +{ + switch (ipv6->proto) + { +#ifdef CONFIG_NET_TCP + case IP_PROTO_TCP: + g_netstats.tcp.drop++; + break; +#endif + +#ifdef CONFIG_NET_UDP + case IP_PROTO_UDP: + g_netstats.udp.drop++; + break; +#endif + +#ifdef CONFIG_NET_ICMPv6 + case IP_PROTO_ICMP6: + g_netstats.icmpv6.drop++; + break; +#endif + + default: + break; + } + + g_netstats.ipv6.drop++; +} +#else +# define ipv6_dropstats(ipv6) +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -187,35 +379,89 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) ret = ipv6_packet_conversion(dev, fwddev, ipv6); if (ret < 0) { - /* Extract the IPv6 + L3 header; Move the data payload to an IOB - * chain. + FAR struct iob_s *iob = NULL; + FAR uint8_t *payload; + unsigned int paysize; + int hdrsize; + + /* Get the size of the IPv6 + L3 header. Use this to determine + * start of the data payload. + * + * Remember that the size of the L1 header has already been + * subtracted from dev->d_len. */ - /* Notify the forwarding device that TX data is available */ + hdrsize = ipv6_hdrsize(ipv6); + if (hdrsize < 0) + { + goto drop; + } - /* Set up to send the packet when the selected device polls for TX - * data. - */ + payload = (FAR uint8_t *)ipv6 + hdrsize; + paysize = dev->d_len - hdrsize; - /* REVISIT: For Ethernet we may have to fix up the Ethernet header: - * - source MAC, the MAC of the current device. - * - dest MAC, the MAC associated with the destination IPv6 adress. - * This will involve ICMPv6 and Neighbor Discovery. - */ + if (paysize > 0) + { + /* Try to allocate the head of an IOB chain. If this fails, + * the the packet will be dropped; we are not operating in a + * context where waiting for an IOB is a good idea + */ - /* Return success with dev->d_len = 0 */ + iob = iob_tryalloc(false); + if (iob == NULL) + { + ret = -ENOMEM; + goto errout_with_iob; + } -# warning Missing logic - nwarn("WARNING: Packet forwarding not yet supported " - "across different devices\n"); + /* Copy the packet data payload into an IOB chain. + * iob_trycopin() will not wait, but will fail there are no + * available IOBs. + */ + + ret = iob_trycopyin(iob, payload, paysize, 0, false); + if (ret < 0) + { + goto errout_with_iob; + } + } + + /* Then set up to forward the packet */ + +#ifdef CONFIG_NET_TCP + if (ipv6->proto == IP_PROTO_TCP) + { + /* Forward a TCP packet, handling ACKs, windowing, etc. */ + + ret = tcp_ipv6_forward(fwddev, ipv6, iob); + } + else +#endif + { + /* Forward a UDP or ICMPv6 packet */ + + ret = ipv6_dev_forward(fwddev, ipv6, iob); + } + + if (ret >= 0) + { + dev->d_len = 0; + return OK; + } + +errout_with_iob: + iob_free_chain(iob); + +drop: + ipv6_dropstats(ipv6); + dev->d_len = 0; return -ENOSYS; } } else #endif /* CONFIG_NETDEV_MULTINIC */ -#if defined(CONFIG_NET_6LOWPAN) /* REVISIT: Currently only suport for - * 6LoWPAN */ +#if defined(CONFIG_NET_6LOWPAN) /* REVISIT: Currently only suport for 6LoWPAN */ { /* Single network device */ diff --git a/net/tcp/Make.defs b/net/tcp/Make.defs index 29b6167a65f..f9e7c893882 100644 --- a/net/tcp/Make.defs +++ b/net/tcp/Make.defs @@ -60,6 +60,12 @@ NET_CSRCS += tcp_conn.c tcp_seqno.c tcp_devpoll.c tcp_finddev.c tcp_timer.c NET_CSRCS += tcp_send.c tcp_input.c tcp_appsend.c tcp_listen.c NET_CSRCS += tcp_callback.c tcp_backlog.c tcp_ipselect.c +# IP forwarding + +ifeq ($(CONFIG_NET_IPFORWARD),y) +NET_CSRCS += tcp_forward.c +endif + # TCP write buffering ifeq ($(CONFIG_NET_TCP_WRITE_BUFFERS),y) diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h index 83891b10244..a56068b147f 100644 --- a/net/tcp/tcp.h +++ b/net/tcp/tcp.h @@ -794,6 +794,34 @@ int tcp_accept_connection(FAR struct net_driver_s *dev, void tcp_send(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, uint16_t flags, uint16_t len); +/**************************************************************************** + * Name: tcp_ipv6_forward + * + * Description: + * Set up to forward the TCP packet on the specified device. This + * function will set up a send "interrupt" handler that will perform + * the actual send asynchronously and must return without waiting for the + * send to complete. + * + * Input Parameters: + * dev - The device on which the packet should be forwarded. + * ipv6 - A pointer to the IPv6 header in within the IPv6 packet. This + * is immeidately followed by the TCP header. + * iob - A list of IOBs containing the data payload to be sent. + * + * Returned Value: + * Zero is returned if the packet was successfully forwarded; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller should free the IOB list and drop the packet. + * + ****************************************************************************/ + +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv6) && \ + defined(CONFIG_NETDEV_MULTINIC) +int tcp_ipv6_forward(FAR struct net_driver_s *dev, + FAR struct ipv6_hdr_s *ipv6, FAR struct iob_s *iob); +#endif + /**************************************************************************** * Name: tcp_reset * diff --git a/net/tcp/tcp_forward.c b/net/tcp/tcp_forward.c new file mode 100644 index 00000000000..11972242291 --- /dev/null +++ b/net/tcp/tcp_forward.c @@ -0,0 +1,101 @@ +/**************************************************************************** + * net/tcp/tcp_forward.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include +#include + +#include "tcp/tcp.h" + +#if defined(CONFIG_NET) && defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_TCP) + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tcp_ipv6_forward + * + * Description: + * Set up to forward the TCP packet on the specified device. This + * function will set up a send "interrupt" handler that will perform + * the actual send asynchronously and must return without waiting for the + * send to complete. + * + * Input Parameters: + * dev - The device on which the packet should be forwarded. + * ipv6 - A pointer to the IPv6 header in within the IPv6 packet. This + * is immeidately followed by the TCP header. + * iob - A list of IOBs containing the data payload to be sent. + * + * Returned Value: + * Zero is returned if the packet was successfully forwarded; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller should free the IOB list and drop the packet. + * + ****************************************************************************/ + +#if defined(CONFIG_NET_IPv6) && defined(CONFIG_NETDEV_MULTINIC) +int tcp_ipv6_forward(FAR struct net_driver_s *dev, + FAR struct ipv6_hdr_s *ipv6, FAR struct iob_s *iob) +{ + /* Notify the forwarding device that TX data is available */ + + /* Set up to send the packet when the selected device polls for TX data. + * TCP packets must obey ACK and windowing rules. + */ + +#warning Missing logic + + /* REVISIT: For Ethernet we may have to fix up the Ethernet header: + * - source MAC, the MAC of the current device. + * - dest MAC, the MAC associated with the destination IPv6 adress. + * This will involve ICMPv6 and Neighbor Discovery. + * - Because of TCP window, the packet may have to be sent in smaller + * pieces. + */ + + nwarn("WARNING: TCP packet forwarding not yet supported\n"); + return -ENOSYS; +} +#endif /* CONFIG_NET_IPv6 && CONFIG_NETDEV_MULTINIC */ +#endif /* CONFIG_NET && CONFIG_NET_IPFORWARD && CONFIG_NET_TCP */ From 32a96bda6dcd65e7f0c6825ae30e155148c6b7bd Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 4 Jul 2017 07:05:42 -0600 Subject: [PATCH 26/33] IPv6 forwarding logic must decrement the TTL and drop the packet if the hop limit is exceeded. --- net/devif/ipv6_forward.c | 84 ++++++++++++++++++++++++++++++++++------ net/utils/net_ipchksum.c | 2 +- 2 files changed, 74 insertions(+), 12 deletions(-) diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index a8c69d24baa..c334a4c0d61 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -262,6 +262,58 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, # define ipv6_dev_forward(dev,ipv6,iob) -EPROTONOSUPPORT #endif +/**************************************************************************** + * Name: ipv6_decr_ttl + * + * Description: + * Decrement the IPv6 TTL (time to live value). TTL field is set by the + * sender of the packet and reduced by every router on the route to its + * destination. If the TTL field reaches zero before the datagram arrives + * at its destination, then the datagram is discarded and an ICMP error + * packet (11 - Time Exceeded) is sent back to the sender. + * + * The purpose of the TTL field is to avoid a situation in which an + * undeliverable datagram keeps circulating on an Internet system, and + * such a system eventually becoming swamped by such "immortals". + * + * Input Parameters: + * ipv6 - A pointer to the IPv6 header in within the IPv6 packet to be + * forwarded. + * + * Returned Value: + * The new TTL value is returned. A value <= 0 means the hop limit has + * expired. + * + ****************************************************************************/ + +static int ipv6_decr_ttl(FAR struct ipv6_hdr_s *ipv6) +{ + int ttl = (int)ipv6->ttl - 1; + + if (ttl <= 0) + { +#ifdef CONFIG_NET_ICMPv6 + /* Return an ICMPv6 error packet back to the sender. */ +#warning Missing logic +#endif + + /* Return zero which must cause the packet to be dropped */ + + return 0; + } + + /* Save the updated TTL value */ + + ipv6->ttl = ttl; + + /* NOTE: We do not have to recalculate the IPv6 checksum because (1) the + * IPv6 header does not include a checksum itself and (2) the TTL is not + * included in the sum for the TCP and UDP headers. + */ + + return ttl; +} + /**************************************************************************** * Name: ipv6_dropstats * @@ -350,6 +402,15 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) FAR struct net_driver_s *fwddev; int ret; + /* Decrement the TTL. If it decrements to zero, then drop the packet */ + + ret = ipv6_decr_ttl(ipv6); + if (ret < 1) + { + ret = -EMULTIHOP; + goto drop; + } + /* Search for a device that can forward this packet. This is a trivial * serch if there is only a single network device (CONFIG_NETDEV_MULTINIC * not defined). But netdev_findby_ipv6addr() will still assure @@ -394,6 +455,7 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) hdrsize = ipv6_hdrsize(ipv6); if (hdrsize < 0) { + ret = -EPROTONOSUPPORT; goto drop; } @@ -411,7 +473,7 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) if (iob == NULL) { ret = -ENOMEM; - goto errout_with_iob; + goto drop; } /* Copy the packet data payload into an IOB chain. @@ -422,7 +484,8 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) ret = iob_trycopyin(iob, payload, paysize, 0, false); if (ret < 0) { - goto errout_with_iob; + iob_free_chain(iob); + goto drop; } } @@ -438,7 +501,9 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) else #endif { - /* Forward a UDP or ICMPv6 packet */ + /* Forward a UDP or ICMPv6 packet. Because ipv6_hdrsize() succeeded, + * we know that it is a forward-able type. + */ ret = ipv6_dev_forward(fwddev, ipv6, iob); } @@ -448,14 +513,6 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) dev->d_len = 0; return OK; } - -errout_with_iob: - iob_free_chain(iob); - -drop: - ipv6_dropstats(ipv6); - dev->d_len = 0; - return -ENOSYS; } } else @@ -507,6 +564,11 @@ drop: */ return OK; + +drop: + ipv6_dropstats(ipv6); + dev->d_len = 0; + return ret; } #endif /* CONFIG_NET_IPFORWARD && CONFIG_NET_IPv6 */ diff --git a/net/utils/net_ipchksum.c b/net/utils/net_ipchksum.c index 2006033599d..18fa1e2b92b 100644 --- a/net/utils/net_ipchksum.c +++ b/net/utils/net_ipchksum.c @@ -118,7 +118,7 @@ uint16_t ipv4_upperlayer_chksum(FAR struct net_driver_s *dev, uint8_t proto) * Name: ipv6_upperlayer_chksum * * Description: - * Perform the checksum calcaultion over the IPv6, protocol headers, and + * Perform the checksum calculation over the IPv6, protocol headers, and * data payload as necessary. * * Input Parameters: From c0c275c8fccb60c53b8a1d25a5059f0649b3810f Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 4 Jul 2017 10:19:52 -0600 Subject: [PATCH 27/33] IP forwarding. Adds a little more structure to handle passing packets received on one network device to another network device. Logic is still incomplete. --- include/nuttx/net/icmp.h | 26 ++- include/nuttx/net/tcp.h | 11 +- net/Kconfig | 17 ++ net/devif/Make.defs | 6 + net/devif/devif_initialize.c | 9 +- net/devif/ip_forward.c | 139 +++++++++++++++ net/devif/ip_forward.h | 186 ++++++++++++++++++++ net/devif/ipv6_forward.c | 327 ++++++++++++++++++++--------------- net/icmpv6/Make.defs | 7 + net/icmpv6/icmpv6.h | 28 +++ net/icmpv6/icmpv6_forward.c | 98 +++++++++++ net/tcp/tcp.h | 15 +- net/tcp/tcp_forward.c | 15 +- net/udp/Make.defs | 6 + net/udp/udp.h | 29 ++++ net/udp/udp_forward.c | 98 +++++++++++ 16 files changed, 854 insertions(+), 163 deletions(-) create mode 100644 net/devif/ip_forward.c create mode 100644 net/devif/ip_forward.h create mode 100644 net/icmpv6/icmpv6_forward.c create mode 100644 net/udp/udp_forward.c diff --git a/include/nuttx/net/icmp.h b/include/nuttx/net/icmp.h index 875deaae425..33c38f2cf66 100644 --- a/include/nuttx/net/icmp.h +++ b/include/nuttx/net/icmp.h @@ -99,7 +99,26 @@ * Public Type Definitions ****************************************************************************/ -/* The ICMP and IP headers */ +struct icmp_hdr_s +{ + /* ICMP header */ + + uint8_t type; /* Defines the format of the ICMP message */ + uint8_t icode; /* Further qualifies the ICMP messsage */ + uint16_t icmpchksum; /* Checksum of ICMP header and data */ + + /* All ICMP packets have an 8-byte header and variable-sized data section. + * The first 4 bytes of the header have fixed format, while the last 4 bytes + * depend on the type/code of that ICMP packet. + */ + + /* ICMP_ECHO_REQUEST and ICMP_ECHO_REPLY data */ + + uint16_t id; /* Used to match requests with replies */ + uint16_t seqno; /* " " "" " " " " " " " " */ +}; + +/* The ICMP and IPv4 headers */ struct icmp_iphdr_s { @@ -122,8 +141,9 @@ struct icmp_iphdr_s uint8_t icode; /* Further qualifies the ICMP messsage */ uint16_t icmpchksum; /* Checksum of ICMP header and data */ - /* Data following the ICMP header contains the data specific to the - * message type indicated by the Type and Code fields. + /* All ICMP packets have an 8-byte header and variable-sized data section. + * The first 4 bytes of the header have fixed format, while the last 4 bytes + * depend on the type/code of that ICMP packet. */ /* ICMP_ECHO_REQUEST and ICMP_ECHO_REPLY data */ diff --git a/include/nuttx/net/tcp.h b/include/nuttx/net/tcp.h index fd26d7ba5ed..67f75077577 100644 --- a/include/nuttx/net/tcp.h +++ b/include/nuttx/net/tcp.h @@ -95,9 +95,16 @@ # define TCP_STOPPED 0x10 /* Bit 4: stopped */ /* Bit 5-7: Unused, but not available */ -/* TCP header sizes */ +/* TCP header sizes + * + * The minimum size header is 5 words and the maximum is 15 words thus + * giving the minimum size of 20 bytes and maximum of 60 bytes, allowing for + * up to 40 bytes of options in the header. + */ -#define TCP_HDRLEN 20 /* Size of TCP header */ +#define TCP_HDRLEN 20 /* Size of TCP header (minimum) */ +#define TCP_OPT_HDRLEN(n) (20 + ((n) << 2)) /* Size of TCP header w/options */ +#define TCP_MAX_HDRLEN 60 /* Maximum size of TCP header */ #ifdef CONFIG_NET_IPv4 # define IPv4TCP_HDRLEN (TCP_HDRLEN + IPv4_HDRLEN) /* Size of IPv4 + TCP header */ diff --git a/net/Kconfig b/net/Kconfig index c3a8022a751..6a1ce6ab111 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -299,6 +299,23 @@ config NET_IPFORWARD reason why IPv4 forwarding has not been implemented, it just has not yet been done. +config NET_IPFORWARD_NSTRUCT + int "Number of pre-allocated forwarding structures" + default 4 + depends on NET_IPFORWARD && CONFIG_NETDEV_MULTINIC + ---help--- + When packets are forward from on device to another, a structure must + be allocated to hold the state of forwarding across several + asynchronous events. Those structures are pre-allocated for + minimal, deterministic performance and to prevent hogging of memory + (of course, that means that this value must be carefully selected + for your application). This setting defines the number of such pre- + allocated structures. + + NOTE: This setting effectively puts a maximum on the number of + packets that may be waiting to be forwarded from one network device + to another. + endmenu # Internet Protocol Selection source "net/socket/Kconfig" diff --git a/net/devif/Make.defs b/net/devif/Make.defs index 714f4356e1d..c436648101d 100644 --- a/net/devif/Make.defs +++ b/net/devif/Make.defs @@ -51,6 +51,12 @@ NET_CSRCS += ipv6_forward.c endif endif +ifeq ($(CONFIG_NET_IPFORWARD),y) +ifeq ($(CONFIG_NETDEV_MULTINIC),y) +NET_CSRCS += ip_forward.c +endif +endif + # I/O buffer chain support required? ifeq ($(CONFIG_MM_IOB),y) diff --git a/net/devif/devif_initialize.c b/net/devif/devif_initialize.c index 4142019e2c8..be858e59204 100644 --- a/net/devif/devif_initialize.c +++ b/net/devif/devif_initialize.c @@ -1,7 +1,7 @@ /**************************************************************************** * net/devif/devif_initialize.c * - * Copyright (C) 2007-2011, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2011, 2014, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Adapted for NuttX from logic in uIP which also has a BSD-like license: @@ -50,6 +50,7 @@ #include #include +#include "devif/ip_forward.h" #include "devif/devif.h" /**************************************************************************** @@ -167,5 +168,11 @@ void devif_initialize(void) /* Initialize callback support */ devif_callback_init(); + +#ifdef HAVE_FWDALLOC + /* Initialize IP forwarding support */ + + ip_forward_initialize(); +#endif } #endif /* CONFIG_NET */ diff --git a/net/devif/ip_forward.c b/net/devif/ip_forward.c new file mode 100644 index 00000000000..a1a59e23f52 --- /dev/null +++ b/net/devif/ip_forward.c @@ -0,0 +1,139 @@ +/**************************************************************************** + * net/devif/ip_forward.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include "devif/ip_forward.h" + +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* This is an array of pre-allocating forwarding structures */ + +static struct forward_s g_fwdpool[CONFIG_NET_IPFORWARD_NSTRUCT]; + +/* This is a list of free forwarding structures */ + +static FAR struct forward_s *g_fwdfree; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ip_forward_initialize + * + * Description: + * Initialize the struct forward_s allocator. + * + * Assumptions: + * Called early in system initialization. + * + ****************************************************************************/ + +void ip_forward_initialize(void) +{ + FAR struct forward_s *fwd; + int i; + + /* Add all pre-allocated forwarding structures to the free list */ + + g_fwdfree = NULL; + + for (i = 0; i < CONFIG_NET_IPFORWARD_NSTRUCT; i++) + { + fwd = &g_fwdpool[i]; + fwd->f_flink = g_fwdfree; + g_fwdfree = fwd; + } +} + +/**************************************************************************** + * Name: ip_forward_alloc + * + * Description: + * Allocate a forwarding structure by removing a pre-allocated entry from + * a free list. + * + * Assumptions: + * Caller holds the network lock. Mutually excluvive access to the free + * list is assured by this lock. + * + ****************************************************************************/ + +FAR struct forward_s *ip_forward_alloc(void) +{ + FAR struct forward_s *fwd; + + fwd = g_fwdfree; + if (fwd != NULL) + { + g_fwdfree = fwd->f_flink; + memset (fwd, 0, sizeof(struct forward_s)); + } + + return fwd; +} + +/**************************************************************************** + * Name: ip_forward_free + * + * Description: + * Free a forwarding structure by adding it to a free list. + * + * Assumptions: + * Caller holds the network lock. Mutually excluvive access to the free + * list is assured by this lock. + * + ****************************************************************************/ + +void ip_forward_free(FAR struct forward_s *fwd) +{ + fwd->f_flink = g_fwdfree; + g_fwdfree = fwd; +} + +#endif /* CONFIG_NET_IPFORWARD && CONFIG_NETDEV_MULTINIC */ diff --git a/net/devif/ip_forward.h b/net/devif/ip_forward.h new file mode 100644 index 00000000000..a61fab2667d --- /dev/null +++ b/net/devif/ip_forward.h @@ -0,0 +1,186 @@ +/**************************************************************************** + * net/devif/ip_forward.h + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __NET_DEVIF_IP_FORWARD_H +#define __NET_DEVIF_IP_FORWARD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include +#include +#include + +#undef HAVE_FWDALLOC +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define HAVE_FWDALLOC 1 + +#ifndef CONFIG_NET_IPFORWARD_NSTRUCT +# define CONFIG_NET_IPFORWARD_NSTRUCT 4 +#endif + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* IPv4 + L2 header */ + +#ifdef CONFIG_NET_IPv4 +struct ipv6_fwdhdr_s +{ + struct ipv4_hdr_s l2; + union + { +#ifdef CONFIG_NET_TCP + uint8_t pad[TCP_MAX_HDRLEN]; + struct tcp_hdr_s tcp; +#endif +#ifdef CONFIG_NET_UDP + struct udp_hdr_s udp; +#endif +#ifdef CONFIG_NET_ICMPv6 + struct icmp_hdr_s icmp; +#endif + } l3; +}; +#endif + +/* IPv6 + L2 header */ + +#ifdef CONFIG_NET_IPv6 +struct ipv6_fwdhdr_s +{ + struct ipv6_hdr_s l2; + union + { +#ifdef CONFIG_NET_TCP + uint8_t pad[TCP_MAX_HDRLEN]; + struct tcp_hdr_s tcp; +#endif +#ifdef CONFIG_NET_UDP + struct udp_hdr_s udp; +#endif +#ifdef CONFIG_NET_ICMPv6 + struct icmpv6_hdr_s icmpv6; +#endif + } l3; +}; +#endif + +/* IPv4 or IPv6 + L2 header */ + +union ip_fwdhdr_u +{ +#ifdef CONFIG_NET_IPv4 + struct ipv4_fwdhdr_s ipv4; +#endif +#ifdef CONFIG_NET_IPv6 + struct ipv6_fwdhdr_s ipv6; +#endif +}; + +/* This is the send state structure */ + +struct net_driver_s; /* Forward reference */ +struct iob_s; /* Forward reference */ + +struct forward_s +{ + FAR struct forward_s *f_flink; /* Supports a singly linked list */ + FAR struct net_driver_s *f_dev; /* Forwarding device */ + FAR struct iob_s *f_iob; /* IOBs containing the data payload */ + union ip_fwdhdr_u f_hdr; /* Copy of original L2+L3 headers */ + uint8_t f_hdrsize; /* The size of the L2+L3 headers */ +}; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: ip_forward_initialize + * + * Description: + * Initialize the struct forward_s allocator. + * + * Assumptions: + * Called early in system initialization. + * + ****************************************************************************/ + +void ip_forward_initialize(void); + +/**************************************************************************** + * Name: ip_forward_alloc + * + * Description: + * Allocate a forwarding structure by removing a pre-allocated entry from + * a free list. + * + * Assumptions: + * Caller holds the network lock. Mutually excluvive access to the free + * list is assured by this lock. + * + ****************************************************************************/ + +FAR struct forward_s *ip_forward_alloc(void); + +/**************************************************************************** + * Name: ip_forward_free + * + * Description: + * Free a forwarding structure by adding it to a free list. + * + * Assumptions: + * Caller holds the network lock. Mutually excluvive access to the free + * list is assured by this lock. + * + ****************************************************************************/ + +void ip_forward_free(FAR struct forward_s *fwd); + +#endif /* CONFIG_NET_IPFORWARD && CONFIG_NETDEV_MULTINIC */ +#endif /* __NET_DEVIF_IP_FORWARD_H */ diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index f04323e5d9c..951ed25f345 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -39,6 +39,7 @@ #include +#include #include #include @@ -49,45 +50,14 @@ #include "netdev/netdev.h" #include "sixlowpan/sixlowpan.h" +#include "udp/udp.h" #include "tcp/tcp.h" +#include "icmpv6/icmpv6.h" +#include "devif/ip_forward.h" #include "devif/devif.h" #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv6) -/**************************************************************************** - * Private Types - ****************************************************************************/ - -#if defined(CONFIG_NETDEV_MULTINIC) && \ - (defined(CONFIG_NET_UDP) || defined(CONFIG_NET_ICMPv6)) - -/* IPv6 + UDP or ICMPv6 header */ - -struct ipv6l3_hdr_s -{ - struct ipv6_hdr_s ipv6; - union - { -#ifdef CONFIG_NET_UDP - struct udp_hdr_s udp; -#endif -#ifdef CONFIG_NET_ICMPv6 - struct icmpv6_iphdr_s icmp; -#endif - } u; -}; - -/* This is the send state structure */ - -struct forward_s -{ - FAR struct net_driver_s *dev; /* Forwarding device */ - struct ipv6l3_hdr_s hdr; /* Copy of origin L2+L3 headers */ - FAR struct iob_queue_s iobq; /* IOBs contained the data payload */ -}; - -#endif /* CONFIG_NETDEV_MULTINIC && (CONFIG_NET_UDP || CONFIG_NET_ICMPv6) */ - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -218,50 +188,188 @@ static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6) * Name: ipv6_dev_forward * * Description: - * Set up to forward the UDP or ICMPv6 packet on the specified device. - * This function will set up a send "interrupt" handler that will perform - * the actual send asynchronously and must return without waiting for the - * send to complete. + * This function is called from ipv6_forward when it is necessary to + * forward a packet from the current device to different device. In this + * case, the forwarding operation must be performed asynchronously when + * the TX poll is received from the forwarding device. * * Input Parameters: - * dev - The device on which the packet should be forwarded. - * ipv6 - A pointer to the IPv6 header in within the IPv6 packet. This - * is immeidately followed by the L3 header which may be UDP or - * ICMPv6. - * iob - A list of IOBs containing the data payload to be sent. + * dev - The device on which the packet was received and which + * contains the IPv6 packet. + * fwdddev - The device on which the packet must be forwarded. + * ipv6 - A pointer to the IPv6 header in within the IPv6 packet * * Returned Value: - * Zero is returned if the packet was successfully forwarded; A negated + * Zero is returned if the packet was successfully forward; A negated * errno value is returned if the packet is not forwardable. In that - * latter case, the caller should free the IOB list and drop the packet. + * latter case, the caller (ipv6_input()) should drop the packet. * ****************************************************************************/ -#if defined(CONFIG_NETDEV_MULTINIC) && \ - (defined(CONFIG_NET_UDP) || defined(CONFIG_NET_ICMPv6)) +#ifdef CONFIG_NETDEV_MULTINIC static int ipv6_dev_forward(FAR struct net_driver_s *dev, - FAR struct ipv6_hdr_s *ipv6, - FAR struct iob_s *iob) + FAR struct net_driver_s *fwddev, + FAR struct ipv6_hdr_s *ipv6) { - /* Notify the forwarding device that TX data is available */ + FAR struct forward_s *fwd = NULL; + int hdrsize; + int ret; - /* Set up to send the packet when the selected device polls for TX data. */ + /* Perform any necessary packet conversions. */ -#warning Missing logic + ret = ipv6_packet_conversion(dev, fwddev, ipv6); + if (ret < 0) + { + FAR uint8_t *payload; + unsigned int paysize; - /* REVISIT: For Ethernet we may have to fix up the Ethernet header: - * - source MAC, the MAC of the current device. - * - dest MAC, the MAC associated with the destination IPv6 adress. - * This will involve ICMPv6 and Neighbor Discovery. - */ + /* Get a pre-allocated forwarding structure, This structure will be + * completely zeroed when we receive it. + */ - nwarn("WARNING: UPD/ICMPv6 packet forwarding not yet supported\n"); - return -ENOSYS; -} -#else -# define ipv6_dev_forward(dev,ipv6,iob) -EPROTONOSUPPORT + fwd = ip_forward_alloc(); + if (fwd == NULL) + { + nwarn("WARNING: Failed to allocate forwarding structure\n"); + ret = -ENOMEM; + goto errout; + } + + /* Initialize the easy stuff in the forwarding structure */ + + fwd->f_dev = fwddev; /* Forwarding device */ + + /* Get the size of the IPv6 + L3 header. Use this to determine start + * of the data payload. + * + * Remember that the size of the L1 header has already been subtracted + * from dev->d_len. + */ + + hdrsize = ipv6_hdrsize(ipv6); + if (hdrsize < IPv6_HDRLEN) + { + nwarn("WARNING: Could not determine L2+L3 header size\n"); + ret = -EPROTONOSUPPORT; + goto errout_with_fwd; + } + + /* Save the entire L2 and L3 headers in the state structure */ + + if (hdrsize > sizeof(union ip_fwdhdr_u)) + { + nwarn("WARNING: Header is too big for pre-allocated structure\n"); + ret = -E2BIG; + goto errout_with_fwd; + } + + memcpy(&fwd->f_hdr, ipv6, hdrsize); + fwd->f_hdrsize = hdrsize; + + /* Use the L2 + L3 header size to determine start and size of the data + * payload. + * + * Remember that the size of the L1 header has already been subtracted + * from dev->d_len. + */ + + payload = (FAR uint8_t *)ipv6 + hdrsize; + paysize = dev->d_len - hdrsize; + + /* If there is a payload, then copy it into an IOB chain */ + + if (paysize > 0) + { + /* Try to allocate the head of an IOB chain. If this fails, + * the the packet will be dropped; we are not operating in a + * context where waiting for an IOB is a good idea + */ + + fwd->f_iob = iob_tryalloc(false); + if (fwd->f_iob == NULL) + { + nwarn("WARNING: iob_tryalloc() failed\n"); + ret = -ENOMEM; + goto errout_with_fwd; + } + + /* Copy the packet data payload into an IOB chain. + * iob_trycopin() will not wait, but will fail there are no + * available IOBs. + */ + + ret = iob_trycopyin(fwd->f_iob, payload, paysize, 0, false); + if (ret < 0) + { + nwarn("WARNING: iob_trycopyin() failed: %d\n", ret); + goto errout_with_iobchain; + } + } + + /* Then set up to forward the packet according to the protocol */ + + switch (ipv6->proto) + { +#ifdef CONFIG_NET_TCP + case IP_PROTO_TCP: + { + /* Forward a TCP packet, handling ACKs, windowing, etc. */ + + ret = tcp_ipv6_dev_forward(fwd); + } + break; #endif +#ifdef CONFIG_NET_UDP + case IP_PROTO_UDP: + { + /* Forward a UDP packet */ + + ret = udp_ipv6_dev_forward(fwd); + } + break; +#endif + +#ifdef CONFIG_NET_ICMPv6 + case IP_PROTO_ICMP6: + { + /* Forward an ICMPv6 packet */ + + ret = icmpv6_dev_forward(fwd); + } + break; +#endif + + default: + nwarn("WARNING: Unrecognized proto: %u\n", ipv6->proto); + ret = -EPROTONOSUPPORT; + break; + } + } + + if (ret >= 0) + { + dev->d_len = 0; + return OK; + } + +errout_with_iobchain: + if (fwd != NULL && fwd->f_iob != NULL) + { + iob_free_chain(fwd->f_iob); + } + +errout_with_fwd: + if (fwd != NULL) + { + ip_forward_free(fwd); + } + +errout: + return ret; +} +#endif /* CONFIG_NETDEV_MULTINIC */ + /**************************************************************************** * Name: ipv6_decr_ttl * @@ -435,86 +543,12 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) if (fwddev != dev) { - /* Perform any necessary packet conversions. */ + /* Send the packet asynchrously on the forwarding device. */ - ret = ipv6_packet_conversion(dev, fwddev, ipv6); + ret = ipv6_dev_forward(dev, fwddev, ipv6); if (ret < 0) { - FAR struct iob_s *iob = NULL; - FAR uint8_t *payload; - unsigned int paysize; - int hdrsize; - - /* Get the size of the IPv6 + L3 header. Use this to determine - * start of the data payload. - * - * Remember that the size of the L1 header has already been - * subtracted from dev->d_len. - */ - - hdrsize = ipv6_hdrsize(ipv6); - if (hdrsize < 0) - { - ret = -EPROTONOSUPPORT; - goto drop; - } - - payload = (FAR uint8_t *)ipv6 + hdrsize; - paysize = dev->d_len - hdrsize; - - if (paysize > 0) - { - /* Try to allocate the head of an IOB chain. If this fails, - * the the packet will be dropped; we are not operating in a - * context where waiting for an IOB is a good idea - */ - - iob = iob_tryalloc(false); - if (iob == NULL) - { - ret = -ENOMEM; - goto drop; - } - - /* Copy the packet data payload into an IOB chain. - * iob_trycopin() will not wait, but will fail there are no - * available IOBs. - */ - - ret = iob_trycopyin(iob, payload, paysize, 0, false); - if (ret < 0) - { - iob_free_chain(iob); - goto drop; - } - } - - /* Then set up to forward the packet */ - -#ifdef CONFIG_NET_TCP - if (ipv6->proto == IP_PROTO_TCP) - { - /* Forward a TCP packet, handling ACKs, windowing, etc. */ - - ret = tcp_ipv6_forward(fwddev, ipv6, iob); - } - else -#endif - { - /* Forward a UDP or ICMPv6 packet. Because ipv6_hdrsize() succeeded, - * we know that it is a forward-able type. - */ - - ret = ipv6_dev_forward(fwddev, ipv6, iob); - } - - if (ret < 0) - { - goto drop; - } - - dev->d_len = 0; - return OK; + goto drop; } } else @@ -522,7 +556,11 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) #if defined(CONFIG_NET_6LOWPAN) /* REVISIT: Currently only suport for 6LoWPAN */ { - /* Single network device */ + /* Single network device. The use case here is where an endpoint acts + * as a hub in a star configuration. This is typical for a wireless star + * configuration where not all endpoints are accessible from all other + * endpoints, but seems less useful for a wired network. + */ /* Perform any necessary packet conversions. If the packet was handled * via a backdoor path (or dropped), then dev->d_len will be zero. If @@ -545,18 +583,21 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) /* Nothing other 6LoWPAN forwarding is currently handled and that * case was dealt with in ipv6_packet_conversion(). + * + * REVISIT: Is tht an issue? Do other use cases make sense? */ -# warning Missing logic nwarn("WARNING: Packet forwarding supported only for 6LoWPAN\n"); - return -ENOSYS; + ret = -ENOSYS; + goto drop; } } #else /* CONFIG_NET_6LOWPAN */ { nwarn("WARNING: Packet forwarding not supported in this configuration\n"); - return -ENOSYS; + ret = -ENOSYS; + goto drop; } #endif /* CONFIG_NET_6LOWPAN */ diff --git a/net/icmpv6/Make.defs b/net/icmpv6/Make.defs index 272c3047534..d634478679a 100644 --- a/net/icmpv6/Make.defs +++ b/net/icmpv6/Make.defs @@ -62,6 +62,13 @@ endif ifeq ($(CONFIG_NET_ICMPv6_ROUTER),y) NET_CSRCS += icmpv6_radvertise.c endif + +# IP forwarding + +ifeq ($(CONFIG_NET_IPFORWARD),y) +NET_CSRCS += icmpv6_forward.c +endif + # Include ICMPv6 build support DEPPATH += --dep-path icmpv6 diff --git a/net/icmpv6/icmpv6.h b/net/icmpv6/icmpv6.h index 1f01202b8aa..5589ed5061f 100644 --- a/net/icmpv6/icmpv6.h +++ b/net/icmpv6/icmpv6.h @@ -176,6 +176,34 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr); # define icmpv6_neighbor(i) (0) #endif +/**************************************************************************** + * Name: icmpv6_dev_forward + * + * Description: + * Called by the IP forwarding logic when an ICMPv6 packet is received on + * one network device, but must be forwarded on another network device. + * + * Set up to forward the ICMPv6 packet on the specified device. The + * function will set up a send "interrupt" handler that will perform the + * actual send asynchronously and must return without waiting for the + * send to complete. + * + * Input Parameters: + * fwd - An initialized instance of the common forwarding structure that + * includes everything needed to perform the forwarding operation. + * + * Returned Value: + * Zero is returned if the packet was successfully forwarded; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller should free the IOB list and drop the packet. + * + ****************************************************************************/ + +#if defined(CONFIG_NETDEV_MULTINIC) && defined(CONFIG_NET_IPFORWARD) +struct forward_s; +int icmpv6_dev_forward(FAR struct forward_s *fwd); +#endif + /**************************************************************************** * Name: icmpv6_poll * diff --git a/net/icmpv6/icmpv6_forward.c b/net/icmpv6/icmpv6_forward.c new file mode 100644 index 00000000000..debbb36d159 --- /dev/null +++ b/net/icmpv6/icmpv6_forward.c @@ -0,0 +1,98 @@ +/**************************************************************************** + * net/icmpv6/icmpv6_forward.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include +#include + +#include "devif/ip_forward.h" +#include "icmpv6/icmpv6.h" + +#if defined(CONFIG_NET) && defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_ICMPv6) + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: icmpv6_dev_forward + * + * Description: + * Called by the IP forwarding logic when an ICMPv6 packet is received on + * one network device, but must be forwarded on another network device. + * + * Set up to forward the ICMPv6 packet on the specified device. The + * function will set up a send "interrupt" handler that will perform the + * actual send asynchronously and must return without waiting for the + * send to complete. + * + * Input Parameters: + * fwd - An initialized instance of the common forwarding structure that + * includes everything needed to perform the forwarding operation. + * + * Returned Value: + * Zero is returned if the packet was successfully forwarded; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller should free the IOB list and drop the packet. + * + ****************************************************************************/ + +#if defined(CONFIG_NETDEV_MULTINIC) && defined(CONFIG_NET_ICMPv6) +int icmpv6_dev_forward(FAR struct forward_s *fwd) +{ + /* Set up to send the packet when the selected device polls for TX data. */ + + /* Notify the forwarding device that TX data is available */ + +#warning Missing logic + + /* REVISIT: For Ethernet we may have to fix up the Ethernet header: + * - source MAC, the MAC of the current device. + * - dest MAC, the MAC associated with the destination IPv6 adress. + * This will involve ICMPv6 and Neighbor Discovery. + */ + + nwarn("WARNING: UPD/ICMPv6 packet forwarding not yet supported\n"); + return -ENOSYS; +} +#endif /* CONFIG_NET_ICMPv6 && CONFIG_NETDEV_MULTINIC */ +#endif /* CONFIG_NET && CONFIG_NET_IPFORWARD && CONFIG_NET_ICMPv6 */ diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h index a56068b147f..627a114ed6c 100644 --- a/net/tcp/tcp.h +++ b/net/tcp/tcp.h @@ -795,19 +795,20 @@ void tcp_send(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, uint16_t flags, uint16_t len); /**************************************************************************** - * Name: tcp_ipv6_forward + * Name: tcp_ipv6_dev_forward * * Description: + * Called by the IP forwarding logic when an TCP packet is received on + * one network device, but must be forwarded on another network device. + * * Set up to forward the TCP packet on the specified device. This * function will set up a send "interrupt" handler that will perform * the actual send asynchronously and must return without waiting for the * send to complete. * * Input Parameters: - * dev - The device on which the packet should be forwarded. - * ipv6 - A pointer to the IPv6 header in within the IPv6 packet. This - * is immeidately followed by the TCP header. - * iob - A list of IOBs containing the data payload to be sent. + * fwd - An initialized instance of the common forwarding structure that + * includes everything needed to perform the forwarding operation. * * Returned Value: * Zero is returned if the packet was successfully forwarded; A negated @@ -818,8 +819,8 @@ void tcp_send(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv6) && \ defined(CONFIG_NETDEV_MULTINIC) -int tcp_ipv6_forward(FAR struct net_driver_s *dev, - FAR struct ipv6_hdr_s *ipv6, FAR struct iob_s *iob); +struct forward_s; /* Forward reference */ +int tcp_ipv6_dev_forward(FAR struct forward_s *fwd); #endif /**************************************************************************** diff --git a/net/tcp/tcp_forward.c b/net/tcp/tcp_forward.c index 11972242291..ebb4c69b986 100644 --- a/net/tcp/tcp_forward.c +++ b/net/tcp/tcp_forward.c @@ -44,6 +44,7 @@ #include #include +#include "devif/ip_forward.h" #include "tcp/tcp.h" #if defined(CONFIG_NET) && defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_TCP) @@ -53,19 +54,20 @@ ****************************************************************************/ /**************************************************************************** - * Name: tcp_ipv6_forward + * Name: tcp_ipv6_dev_forward * * Description: + * Called by the IP forwarding logic when an TCP packet is received on + * one network device, but must be forwarded on another network device. + * * Set up to forward the TCP packet on the specified device. This * function will set up a send "interrupt" handler that will perform * the actual send asynchronously and must return without waiting for the * send to complete. * * Input Parameters: - * dev - The device on which the packet should be forwarded. - * ipv6 - A pointer to the IPv6 header in within the IPv6 packet. This - * is immeidately followed by the TCP header. - * iob - A list of IOBs containing the data payload to be sent. + * fwd - An initialized instance of the common forwarding structure that + * includes everything needed to perform the forwarding operation. * * Returned Value: * Zero is returned if the packet was successfully forwarded; A negated @@ -75,8 +77,7 @@ ****************************************************************************/ #if defined(CONFIG_NET_IPv6) && defined(CONFIG_NETDEV_MULTINIC) -int tcp_ipv6_forward(FAR struct net_driver_s *dev, - FAR struct ipv6_hdr_s *ipv6, FAR struct iob_s *iob) +int tcp_ipv6_dev_forward(FAR struct forward_s *fwd) { /* Notify the forwarding device that TX data is available */ diff --git a/net/udp/Make.defs b/net/udp/Make.defs index 4b3992911df..e28161496ed 100644 --- a/net/udp/Make.defs +++ b/net/udp/Make.defs @@ -48,6 +48,12 @@ NET_CSRCS += udp_netpoll.c endif endif +# IP forwarding + +ifeq ($(CONFIG_NET_IPFORWARD),y) +NET_CSRCS += udp_forward.c +endif + # Transport layer NET_CSRCS += udp_conn.c udp_devpoll.c udp_send.c udp_input.c udp_finddev.c diff --git a/net/udp/udp.h b/net/udp/udp.h index 83197afae31..64d2e7aa3dd 100644 --- a/net/udp/udp.h +++ b/net/udp/udp.h @@ -428,6 +428,35 @@ FAR struct net_driver_s *udp_find_raddr_device(FAR struct udp_conn_s *conn); uint16_t udp_callback(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn, uint16_t flags); +/**************************************************************************** + * Name: udp_ipv6_dev_forward + * + * Description: + * Called by the IP forwarding logic when an UDP packet is received on + * one network device, but must be forwarded on another network device. + * + * Set up to forward the UDP packet on the specified device. This + * function will set up a send "interrupt" handler that will perform the + * actual send asynchronously and must return without waiting for the + * send to complete. + * + * Input Parameters: + * fwd - An initialized instance of the common forwarding structure that + * includes everything needed to perform the forwarding operation. + * + * Returned Value: + * Zero is returned if the packet was successfully forwarded; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller should free the IOB list and drop the packet. + * + ****************************************************************************/ + +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv6) && \ + defined(CONFIG_NETDEV_MULTINIC) +struct forward_s; /* Forward reference */ +int udp_ipv6_dev_forward(FAR struct forward_s *fwd); +#endif + /**************************************************************************** * Name: psock_udp_send * diff --git a/net/udp/udp_forward.c b/net/udp/udp_forward.c new file mode 100644 index 00000000000..e1e5fc92f4c --- /dev/null +++ b/net/udp/udp_forward.c @@ -0,0 +1,98 @@ +/**************************************************************************** + * net/udp/udp_forward.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include +#include + +#include "devif/ip_forward.h" +#include "udp/udp.h" + +#if defined(CONFIG_NET) && defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_UDP) + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: udp_ipv6_dev_forward + * + * Description: + * Called by the IP forwarding logic when an UDP packet is received on + * one network device, but must be forwarded on another network device. + * + * Set up to forward the UDP packet on the specified device. This + * function will set up a send "interrupt" handler that will perform the + * actual send asynchronously and must return without waiting for the + * send to complete. + * + * Input Parameters: + * fwd - An initialized instance of the common forwarding structure that + * includes everything needed to perform the forwarding operation. + * + * Returned Value: + * Zero is returned if the packet was successfully forwarded; A negated + * errno value is returned if the packet is not forwardable. In that + * latter case, the caller should free the IOB list and drop the packet. + * + ****************************************************************************/ + +#if defined(CONFIG_NET_IPv6) && defined(CONFIG_NETDEV_MULTINIC) +int udp_ipv6_dev_forward(FAR struct forward_s *fwd) +{ + /* Set up to send the packet when the selected device polls for TX data. */ + + /* Notify the forwarding device that TX data is available */ + +#warning Missing logic + + /* REVISIT: For Ethernet we may have to fix up the Ethernet header: + * - source MAC, the MAC of the current device. + * - dest MAC, the MAC associated with the destination IPv6 adress. + * This will involve ICMPv6 and Neighbor Discovery. + */ + + nwarn("WARNING: UPD/ICMPv6 packet forwarding not yet supported\n"); + return -ENOSYS; +} +#endif /* CONFIG_NET_IPv6 && CONFIG_NETDEV_MULTINIC */ +#endif /* CONFIG_NET && CONFIG_NET_IPFORWARD && CONFIG_NET_UDP */ From 5e617f8410af1f624043e53ac73739cf876bd582 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 4 Jul 2017 12:05:21 -0600 Subject: [PATCH 28/33] UDP networking: The TTL (time to live) was not being set in the IPv4 or IPv6 header unless the UDP socket was bound. --- net/devif/ipv6_forward.c | 6 +++++- net/devif/ipv6_input.c | 1 + net/udp/udp_conn.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index 951ed25f345..eaf868533ff 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -106,18 +106,20 @@ static int ipv6_packet_conversion(FAR struct net_driver_s *dev, { /* Otherwise, we will have to drop the packet */ - nwarn("WARNING: Dropping. Unsupported 6LoWPAN protocol: %d\n", + nwarn("WARNING: Dropping. Unsupported 6LoWPAN protocol: %d\n", ipv6->proto); #ifdef CONFIG_NET_STATISTICS g_netstats.ipv6.drop++; #endif + return -EPROTONOSUPPORT; } dev->d_len = 0; return OK; } + nwarn("WARNING: Dropping. Unsupported link layer\n"); return -EPFNOSUPPORT; } #else @@ -515,6 +517,7 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) ret = ipv6_decr_ttl(ipv6); if (ret < 1) { + nwarn("WARNING: Hop limit exceeded... Dropping!\n"); ret = -EMULTIHOP; goto drop; } @@ -548,6 +551,7 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) ret = ipv6_dev_forward(dev, fwddev, ipv6); if (ret < 0) { + nwarn("WARNING: ipv6_dev_forward faield: %d\n", ret); goto drop; } } diff --git a/net/devif/ipv6_input.c b/net/devif/ipv6_input.c index 8d2a28776cd..4d656f37493 100644 --- a/net/devif/ipv6_input.c +++ b/net/devif/ipv6_input.c @@ -370,6 +370,7 @@ int ipv6_input(FAR struct net_driver_s *dev) { /* Not destined for us and not forwardable... drop the packet. */ + nwarn("WARNING: Not destined for us; not forwardable... Dropping!\n"); #ifdef CONFIG_NET_STATISTICS g_netstats.ipv6.drop++; #endif diff --git a/net/udp/udp_conn.c b/net/udp/udp_conn.c index 077a840566e..daa7dce3c13 100644 --- a/net/udp/udp_conn.c +++ b/net/udp/udp_conn.c @@ -457,6 +457,7 @@ FAR struct udp_conn_s *udp_alloc(uint8_t domain) conn->domain = domain; #endif conn->lport = 0; + conn->ttl = IP_TTL; /* Enqueue the connection into the active list */ @@ -760,7 +761,6 @@ int udp_connect(FAR struct udp_conn_s *conn, FAR const struct sockaddr *addr) #endif /* CONFIG_NET_IPv6 */ } - conn->ttl = IP_TTL; return OK; } From f07420dedf828694dd1eba08f1bb28f6ba701826 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 4 Jul 2017 14:31:26 -0600 Subject: [PATCH 29/33] SAME70-Xplained: Add MRF24J40 support. --- configs/same70-xplained/Kconfig | 31 ++ configs/same70-xplained/README.txt | 59 +++ configs/same70-xplained/src/Makefile | 6 +- configs/same70-xplained/src/sam_bringup.c | 13 +- configs/same70-xplained/src/sam_mrf24j40.c | 347 ++++++++++++++++++ configs/same70-xplained/src/sam_spi.c | 32 ++ configs/same70-xplained/src/same70-xplained.h | 94 ++++- configs/samv71-xult/README.txt | 14 +- configs/samv71-xult/src/sam_bringup.c | 1 - configs/samv71-xult/src/sam_spi.c | 2 +- 10 files changed, 586 insertions(+), 13 deletions(-) create mode 100644 configs/same70-xplained/src/sam_mrf24j40.c diff --git a/configs/same70-xplained/Kconfig b/configs/same70-xplained/Kconfig index 95ffaaa0fff..ab5c765cfa9 100644 --- a/configs/same70-xplained/Kconfig +++ b/configs/same70-xplained/Kconfig @@ -5,6 +5,37 @@ if ARCH_BOARD_SAME70_XPLAINED +config SAME70XPLAINED_CLICKSHIELD + bool "Mikroe Click Shield" + default n + ---help--- + In the mrf24j40-starhub configuration, a click shield from + MikroElectronika was used along with a Click "Bee" module. The + click shield supports two click shields. + +config SAME70XPLAINED_MB1_SPI + bool + default n + +config SAME70XPLAINED_MB2_SPI + bool + default n + +choice + prompt "Bee mikroBUS" + depends on SAME70XPLAINED_CLICKSHIELD && IEEE802154_MRF24J40 + default SAME70XPLAINED_MB1_BEE + +config SAME70XPLAINED_MB1_BEE + bool "MRF24J40 Bee in mikroBUS1" + select SAME70XPLAINED_MB1_SPI + +config SAME70XPLAINED_MB2_BEE + bool "MRF24J40 Bee in mikroBUS2" + select SAME70XPLAINED_MB2_SPI + +endchoice # Bee mikroBUS + config SAME70XPLAINED_HSMCI0_AUTOMOUNT bool "HSMCI0 automounter" default n diff --git a/configs/same70-xplained/README.txt b/configs/same70-xplained/README.txt index 1b10b484b04..e2275469698 100644 --- a/configs/same70-xplained/README.txt +++ b/configs/same70-xplained/README.txt @@ -19,6 +19,7 @@ Contents - USBHS Device Controller Driver - MCAN1 Loopback Test - SPI Slave + - Click Shield - Tickless OS - Debugging - Using OpenOCD and GDB to flash via the EDBG chip @@ -834,6 +835,64 @@ SPI Slave b) It will hog all of the CPU for the duration of the transfer). +Click Shield +============ + + In the mrf24j40-starhub configuration, a click shield from + MikroElectronika was used along with a Click "Bee" module. The click + shield supports two click shields and the following tables describe the + relationship between the pins on each click shield, the Arduino + connector and the SAME70 pins. + + --------- ---------------------- -------- --------- ------------------ ---------- + mikroBUS1 Arduino SAME70 mikroBUS2 Arduino SAME70 + --------- ---------------------- -------- --------- ------------------ ---------- + AN HD1 A0 AN0 Pin 1 AD0 PD26 AN HD1 A1 AN1 Pin 2 AD1 PC31 + RST HD1 A3 Pin 4 AD3 PA19 RST HD1 A2 Pin 3 AD2 PD30 + CS HD4 D10 SPI-SS Pin 8 D10 PD25 CS HD4 D9 Pin 9 D9 PC9 + SCK HD4 D13 SPI-SCK Pin 5 D13 PD22 SCK Same + MISO HD4 D12 SPI-MISO Pin 6 D12 PD20 MISO Same + MOSI HD4 D11 SPI-MOSI Pin 7 D11 PD21 MOSI Same + 3.3V N/A 3.3V N/A + GND N/A GND N/A + PWM HD3 D6 PWMA Pin 2 D6 PC19 PWM HD3 D5 PWMB Pin 5 D5 PD11 + INT HD3 D2 INT0 Pin 6 D2 PA5 INT HD3 D3 INT1 Pin 5 D3 PA6 + RX HD3 D0 HDR-RX* Pin 8 D0 PD28 RX Same + TX HD3 D1 HDR-TX* Pin 7 D1 PD30 TX Same + SCL HD1 A5 I2C-SCL Pin 5 AD5 PC30 SDA Same + SDA HD1 A4 I2C-SDA Pin 6 AD4 PC13 SCL Same + 5V N/A 5V N/A + GND N/A GND N/A + --------- ---------------------- -------- --------- ------------------ ---------- + + * Depends upon setting of SW1, UART vs PROG. + + --- ----- ------------------------------ --------------------------------- + PIN PORT SHIELD FUNCTION SAME70PIN CONFIGURATION + --- ----- ------------------------------ --------------------------------- + AD0 PD26 microBUS2 Analog TD PD26 *** Not an AFE pin *** + AD1 PC31 microBUS2 Analog PC31 AFE1_AD6 GPIO_AFE1_AD6 + AD2 PD30 microBUS2 GPIO reset output PD30 + AD3 PA19 microBUS1 GPIO reset output PA19 + AD4 PC13 (both) I2C-SDA PC13 *** Does not support I2C SDA *** + AD5 PC30 (both) I2C-SCL PC30 *** Does not support I2C SCL *** + AD6 PA17 *** Not used *** + AD7 PC12 *** Not used *** + D0 PD28 (both) HDR_RX PD28 URXD3 GPIO_UART3_RXD + D1 PD30 (both) HDR_TX PD30 UTXD3 GPIO_UART3_TXD_1 + D2 PA5 microBUS1 GPIO interrupt input PA5 + D3 PA6 microBUS2 GPIO interrupt input PA6 + D4 PD27 *** Not used *** + D5 PD11 microBUS2 PWM PD11 PWMC0_H0 + D6 PC19 microBUS1 PWN PC19 PWMC0_H2 + D7 PA2 *** Not used *** + D8 PA17 *** Not used *** + D9 PC9 microBUS2 CS GPIO output PC9 + D10 PD25 microBUS1 CS GPIO output PD25 SPI0_NPCS1 + D11 PD21 (both) SPI-MOSI PD21 SPI0_MOSI GPIO_SPI0_MOSI + D12 PD20 (both) SPI-MISO PD20 SPI0_MISO GPIO_SPI0_MISO + D13 PD22 (both) SPI-SCK PD22 SPI0_SPCK GPIO_SPI0_SPCK + Tickless OS =========== diff --git a/configs/same70-xplained/src/Makefile b/configs/same70-xplained/src/Makefile index 1f2eafb849a..8d2583374b7 100644 --- a/configs/same70-xplained/src/Makefile +++ b/configs/same70-xplained/src/Makefile @@ -1,7 +1,7 @@ ############################################################################ # configs/same70-xplained/src/Makefile # -# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -94,4 +94,8 @@ ifneq (,$(findstring y,$(CONFIG_SAMV7_DAC0) $(CONFIG_SAMV7_DAC1))) CSRCS += sam_dac.c endif +ifeq ($(CONFIG_IEEE802154_MRF24J40),y) +CSRCS += sam_mrf24j40.c +endif + include $(TOPDIR)/configs/Board.mk diff --git a/configs/same70-xplained/src/sam_bringup.c b/configs/same70-xplained/src/sam_bringup.c index 4b41c93674f..91c191914ee 100644 --- a/configs/same70-xplained/src/sam_bringup.c +++ b/configs/same70-xplained/src/sam_bringup.c @@ -1,7 +1,7 @@ /**************************************************************************** * config/same70-xplained/src/sam_bringup.c * - * Copyright (C) 2015, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -329,10 +329,19 @@ int sam_bringup(void) } #endif +#ifdef HAVE_MRF24J40 + /* Configure MRF24J40 wireless */ + + ret = sam_mrf24j40_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: sam_mrf24j40_initialize() failed: %d\n", ret); + } +#endif + #ifdef HAVE_ELF /* Initialize the ELF binary loader */ - syslog(LOG_ERR, "Initializing the ELF binary loader\n"); ret = elf_initialize(); if (ret < 0) { diff --git a/configs/same70-xplained/src/sam_mrf24j40.c b/configs/same70-xplained/src/sam_mrf24j40.c new file mode 100644 index 00000000000..c7f718855c9 --- /dev/null +++ b/configs/same70-xplained/src/sam_mrf24j40.c @@ -0,0 +1,347 @@ +/**************************************************************************** + * configs/same70-xplained/src/sam_mrf24j40.c + * + * Copyright (C) 2017 Gregory Nutt, All rights reserver + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "sam_gpio.h" +#include "sam_spi.h" + +#include "same70-xplained.h" + +#ifdef HAVE_MRF24J40 + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#undef BEE_RESET + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct sam_priv_s +{ + struct mrf24j40_lower_s dev; + uint32_t intcfg; +#ifdef BEE_RESET + uint32_t rstcfg; +#endif + uint8_t irq; + uint8_t spidev; +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/* IRQ/GPIO access callbacks. These operations all hidden behind callbacks + * to isolate the MRF24J40 driver from differences in GPIO interrupt handling + * varying boards and MCUs. + * + * irq_attach - Attach the MRF24J40 interrupt handler to the GPIO + interrupt + * irq_enable - Enable or disable the GPIO interrupt + */ + +static int sam_attach_irq(FAR const struct mrf24j40_lower_s *lower, + xcpt_t handler, FAR void *arg); +static void sam_enable_irq(FAR const struct mrf24j40_lower_s *lower, + bool state); +static int sam_mrf24j40_devsetup(FAR struct sam_priv_s *priv); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* A reference to a structure of this type must be passed to the MRF24J40 + * driver. This structure provides information about the configuration + * of the MRF24J40 and provides some board-specific hooks. + * + * Memory for this structure is provided by the caller. It is not copied + * by the driver and is presumed to persist while the driver is active. The + * memory must be writable because, under certain circumstances, the driver + * may modify frequency or X plate resistance values. + */ + +#ifdef CONFIG_SAME70XPLAINED_MB1_BEE +static struct sam_priv_s g_mrf24j40_mb1_priv = +{ + .dev.attach = sam_attach_irq, + .dev.enable = sam_enable_irq, + .intcfg = CLICK_MB1_INTR, +#ifdef BEE_RESET + .rstcfg = CLICK_MB1_RESET, +#endif + .irq = IRQ_MB1, + .spidev = 0, +}; +#endif + +#ifdef CONFIG_SAME70XPLAINED_MB2_BEE +static struct sam_priv_s g_mrf24j40_mb2_priv = +{ + .dev.attach = sam_attach_irq, + .dev.enable = sam_enable_irq, + .intcfg = CLICK_MB2_INTR, +#ifdef BEE_RESET + .rstcfg = CLICK_MB2_RESET, +#endif + .irq = IRQ_MB2, + .spidev = 0, +}; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/* IRQ/GPIO access callbacks. These operations all hidden behind + * callbacks to isolate the MRF24J40 driver from differences in GPIO + * interrupt handling by varying boards and MCUs. If possible, + * interrupts should be configured on both rising and falling edges + * so that contact and loss-of-contact events can be detected. + * + * irq_attach - Attach the MRF24J40 interrupt handler to the GPIO + * interrupt + * irq_enable - Enable or disable the GPIO interrupt + */ + +static int sam_attach_irq(FAR const struct mrf24j40_lower_s *lower, + xcpt_t handler, FAR void *arg) +{ + FAR struct sam_priv_s *priv = (FAR struct sam_priv_s *)lower; + int ret; + + DEBUGASSERT(priv != NULL); + + ret = irq_attach(priv->irq, handler, arg); + if (ret < 0) + { + wlerr("ERROR: Failed to attach WM8904 interrupt: %d\n", ret); + } + + return ret; +} + +static void sam_enable_irq(FAR const struct mrf24j40_lower_s *lower, + bool state) +{ + FAR struct sam_priv_s *priv = (FAR struct sam_priv_s *)lower; + static bool enabled; + irqstate_t flags; + + /* The caller should not attempt to enable interrupts if the handler + * has not yet been 'attached' + */ + + DEBUGASSERT(priv != NULL); + wlinfo("state: %d irq: %u\n", (int)state, priv->irq); + + /* Has the interrupt state changed */ + + flags = enter_critical_section(); + if (state != enabled) + { + /* Enable or disable interrupts */ + + if (state) + { + wlinfo("Enabling\n"); + sam_gpioirqenable(priv->irq); + enabled = true; + } + else + { + wlinfo("Disabling\n"); + sam_gpioirqdisable(priv->irq); + enabled = false; + } + } + + leave_critical_section(flags); +} + +/**************************************************************************** + * Name: sam_mrf24j40_devsetup + * + * Description: + * Initialize one the MRF24J40 device in one mikroBUS slot + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +static int sam_mrf24j40_devsetup(FAR struct sam_priv_s *priv) +{ + FAR struct ieee802154_radio_s *radio; + MACHANDLE mac; + FAR struct spi_dev_s *spi; + int ret; + +#ifdef BEE_RESET + /* Bring the MRF24J40 out of reset + * NOTE: Not necessary. The RST# input is pulled high on the BEE. + */ + + (void)sam_configgpio(priv->rstcfg); + sam_gpiowrite(priv->rstcfg, true); +#endif + + /* Configure the interrupt pin */ + + (void)sam_configgpio(priv->intcfg); + sam_gpioirq(priv->intcfg); + + /* Initialize the SPI bus and get an instance of the SPI interface */ + + spi = sam_spibus_initialize(priv->spidev); + if (spi == NULL) + { + wlerr("ERROR: Failed to initialize SPI bus %d\n", priv->spidev); + return -ENODEV; + } + + /* Initialize and register the SPI MRF24J40 device */ + + radio = mrf24j40_init(spi, &priv->dev); + if (radio == NULL) + { + wlerr("ERROR: Failed to initialize SPI bus %d\n", priv->spidev); + return -ENODEV; + } + + /* Create a 802.15.4 MAC device from a 802.15.4 compatible radio device. */ + + mac = mac802154_create(radio); + if (mac == NULL) + { + wlerr("ERROR: Failed to initialize IEEE802.15.4 MAC\n"); + return -ENODEV; + } + +#ifdef CONFIG_IEEE802154_NETDEV + /* Use the IEEE802.15.4 MAC interface instance to create a 6LoWPAN + * network interface by wrapping the MAC intrface instance in a + * network device driver via mac802154dev_register(). + */ + + ret = mac802154netdev_register(mac); + if (ret < 0) + { + wlerr("ERROR: Failed to register the MAC network driver wpan%d: %d\n", + 0, ret); + return ret; + } +#endif + +#ifdef CONFIG_IEEE802154_MACDEV + /* If want to call these APIs from userspace, you have to wrap the MAC + * interface in a character device viamac802154dev_register(). + */ + + ret = mac802154dev_register(mac, 0); + if (ret < 0) + { + wlerr("ERROR: Failed to register the MAC character driver /dev/ieee%d: %d\n", + 0, ret); + return ret; + } +#endif + + return OK; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: sam_mrf24j40_initialize + * + * Description: + * Initialize the MRF24J40 device. + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +int sam_mrf24j40_initialize(void) +{ + int ret; + +#ifdef CONFIG_SAME70XPLAINED_MB1_BEE + wlinfo("Configuring BEE in mikroBUS1\n"); + + ret = sam_mrf24j40_devsetup(&g_mrf24j40_mb1_priv); + if (ret < 0) + { + wlerr("ERROR: Failed to initialize BD in mikroBUS1: %d\n", ret); + } +#endif + +#ifdef CONFIG_SAME70XPLAINED_MB2_BEE + wlinfo("Configuring BEE in mikroBUS2\n"); + + ret = sam_mrf24j40_devsetup(&g_mrf24j40_mb2_priv); + if (ret < 0) + { + wlerr("ERROR: Failed to initialize BD in mikroBUS2: %d\n", ret); + } +#endif + + UNUSED(ret); + return OK; +} +#endif /* HAVE_MRF24J40 */ diff --git a/configs/same70-xplained/src/sam_spi.c b/configs/same70-xplained/src/sam_spi.c index e50136df930..60fd5c0c37e 100644 --- a/configs/same70-xplained/src/sam_spi.c +++ b/configs/same70-xplained/src/sam_spi.c @@ -70,6 +70,18 @@ void sam_spidev_initialize(void) { #ifdef CONFIG_SAMV7_SPI0_MASTER +#ifdef CONFIG_SAME70XPLAINED_MB1_SPI + /* Enable chip select for mikroBUS1 */ + + (void)sam_configgpio(CLICK_MB1_CS); +#endif + +#ifdef CONFIG_SAME70XPLAINED_MB2_SPI + /* Enable chip select for mikroBUS2 */ + + (void)sam_configgpio(CLICK_MB2_CS); + +#endif #endif #ifdef CONFIG_SAMV7_SPI0_SLAVE @@ -143,12 +155,32 @@ void sam_spidev_initialize(void) #ifdef CONFIG_SAMV7_SPI0_MASTER void sam_spi0select(uint32_t devid, bool selected) { + spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); + + switch (devid) + { +#ifdef CONFIG_IEEE802154_MRF24J40 + case SPIDEV_IEEE802154(0): + /* Set the GPIO low to select and high to de-select */ + +#if defined(CONFIG_SAME70XPLAINED_MB1_BEE) + sam_gpiowrite(CLICK_MB1_CS, !selected); +#elif defined(CONFIG_SAME70XPLAINED_MB2_BEE) + sam_gpiowrite(CLICK_MB2_CS, !selected); +#endif + break; +#endif + + default: + break; + } } #endif #ifdef CONFIG_SAMV7_SPI1_MASTER void sam_spi1select(uint32_t devid, bool selected) { + spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert"); } #endif diff --git a/configs/same70-xplained/src/same70-xplained.h b/configs/same70-xplained/src/same70-xplained.h index ed0e98e1564..b415ed3b857 100644 --- a/configs/same70-xplained/src/same70-xplained.h +++ b/configs/same70-xplained/src/same70-xplained.h @@ -1,7 +1,7 @@ /************************************************************************************ * configs/same70-xplained/src/same70-xplained.h * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -63,6 +63,7 @@ #define HAVE_MTDCONFIG 1 #define HAVE_PROGMEM_CHARDEV 1 #define HAVE_I2CTOOL 1 +#define HAVE_MRF24J40 1 /* HSMCI */ /* Can't support MMC/SD if the card interface is not enabled */ @@ -207,6 +208,28 @@ # endif #endif +/* Check if the MRF24J40 is supported in this configuration */ + +#ifndef CONFIG_IEEE802154_MRF24J40 +# undef HAVE_MRF24J40 +#endif + +#ifndef CONFIG_SAME70XPLAINED_CLICKSHIELD +# undef HAVE_MRF24J40 +#endif + +#if !defined(CONFIG_SAME70XPLAINED_MB1_BEE) && !defined(CONFIG_SAME70XPLAINED_MB2_BEE) +# undef HAVE_MRF24J40 +#endif + +#ifndef CONFIG_SAMV7_SPI0_MASTER +# undef HAVE_MRF24J40 +#endif + +#ifndef CONFIG_SAMV7_GPIOA_IRQ +# undef HAVE_MRF24J40 +#endif + /* SAME70-XPLD GPIO Pin Definitions *************************************************/ /* Ethernet MAC. @@ -299,6 +322,59 @@ #define GPIO_VBUSON (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_SET | \ GPIO_PORT_PIOC | GPIO_PIN16) +/* Click Shield + * + * --- ----- ------------------------------ --------------------------------- + * PIN PORT SHIELD FUNCTION PIN CONFIGURATION + * --- ----- ------------------------------ --------------------------------- + * AD0 PD26 microBUS2 Analog TD PD26 *** Not an AFE pin *** + * AD1 PC31 microBUS2 Analog PC31 AFE1_AD6 GPIO_AFE1_AD6 + * AD2 PD30 microBUS2 GPIO reset output PD30 + * AD3 PA19 microBUS1 GPIO reset output PA19 + * AD4 PC13 (both) I2C-SDA PC13 *** Does not support I2C SDA *** + * AD5 PC30 (both) I2C-SCL PC30 *** Does not support I2C SCL *** + * AD6 PA17 *** Not used *** + * AD7 PC12 *** Not used *** + * D0 PD28 (both) HDR_RX PD28 URXD3 GPIO_UART3_RXD + * D1 PD30 (both) HDR_TX PD30 UTXD3 GPIO_UART3_TXD_1 + * D2 PA5 microBUS1 GPIO interrupt input PA5 + * D3 PA6 microBUS2 GPIO interrupt input PA6 + * D4 PD27 *** Not used *** + * D5 PD11 microBUS2 PWMB PD11 PWMC0_H0 + * D6 PC19 microBUS1 PWMA PC19 PWMC0_H2 + * D7 PA2 *** Not used *** + * D8 PA17 *** Not used *** + * D9 PC9 microBUS2 CS GPIO output PC9 + * D10 PD25 microBUS1 CS GPIO output PD25 SPI0_NPCS1 + * D11 PD21 (both) SPI-MOSI PD21 SPI0_MOSI GPIO_SPI0_MOSI + * D12 PD20 (both) SPI-MISO PD20 SPI0_MISO GPIO_SPI0_MISO + * D13 PD22 (both) SPI-SCK PD22 SPI0_SPCK GPIO_SPI0_SPCK + */ + +/* Reset (RST#) Pulled-up on the click board */ + +#define CLICK_MB1_RESET (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ + GPIO_PORT_PIOA | GPIO_PIN19) +#define CLICK_MB2_RESET (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \ + GPIO_PORT_PIOD | GPIO_PIN30) + +/* Interrupts. No pull-ups on the BEE; assumig active low. */ + +#define CLICK_MB1_INTR (GPIO_INPUT | GPIO_CFG_PULLUP | GPIO_CFG_DEGLITCH | \ + GPIO_INT_FALLING | GPIO_PORT_PIOA | GPIO_PIN5) +#define CLICK_MB2_INTR (GPIO_INPUT | GPIO_CFG_PULLUP | GPIO_CFG_DEGLITCH | \ + GPIO_INT_FALLING | GPIO_PORT_PIOA | GPIO_PIN6) + +#define IRQ_MB1 SAM_IRQ_PA5 +#define IRQ_MB2 SAM_IRQ_PA6 + +/* SP chip selects */ + +#define CLICK_MB1_CS (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_SET | \ + GPIO_PORT_PIOD | GPIO_PIN25) +#define CLICK_MB2_CS (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_SET | \ + GPIO_PORT_PIOC | GPIO_PIN9) + /************************************************************************************ * Public Types ************************************************************************************/ @@ -536,5 +612,21 @@ bool sam_writeprotected(int slotno); int sam_at24config(void); #endif +/**************************************************************************** + * Name: stm32_mrf24j40_initialize + * + * Description: + * Initialize the MRF24J40 device. + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +#ifdef HAVE_MRF24J40 +int sam_mrf24j40_initialize(void); +#endif + #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_SAME70_XPLAINED_SRC_SAME70_XPLAINED_H */ diff --git a/configs/samv71-xult/README.txt b/configs/samv71-xult/README.txt index 56d2620ff0c..c408f4dc863 100644 --- a/configs/samv71-xult/README.txt +++ b/configs/samv71-xult/README.txt @@ -1445,24 +1445,24 @@ Click Shield MikroElectronika was used along with a Click "Bee" module. The click shield supports two click shields and the following tables describe the relationship between the pins on each click shield, the Arduino - connector and the SAME70 pins. + connector and the SAMV71 pins. --------- ---------------------- -------- --------- ------------------ ---------- - mikroBUS1 Arduino SAME70 mikroBUS2 Arduino SAME70 + mikroBUS1 Arduino SAMV71 mikroBUS2 Arduino SAMV71 --------- ---------------------- -------- --------- ------------------ ---------- AN HD1 A0 AN0 Pin 1 AD0 PD26 AN HD1 A1 AN1 Pin 2 AD1 PC31 - RST HD1 A3 Pin 4 AD3 PD30 RST HD1 A2 Pin 3 AD2 PA19 + RST HD1 A3 Pin 4 AD3 PA19 RST HD1 A2 Pin 3 AD2 PD30 CS HD4 D10 SPI-SS Pin 8 D10 PD25 CS HD4 D9 Pin 9 D9 PC9 SCK HD4 D13 SPI-SCK Pin 5 D13 PD22 SCK Same MISO HD4 D12 SPI-MISO Pin 6 D12 PD20 MISO Same MOSI HD4 D11 SPI-MOSI Pin 7 D11 PD21 MOSI Same 3.3V N/A 3.3V N/A GND N/A GND N/A - PWM HD3 D6 PWMA Pin 2 D6 PA2 PWM HD3 D5 PWMB Pin 5 D5 PD11 + PWM HD3 D6 PWMA Pin 2 D6 PC19 PWM HD3 D5 PWMB Pin 5 D5 PD11 INT HD3 D2 INT0 Pin 6 D2 PA5 INT HD3 D3 INT1 Pin 5 D3 PA6 RX HD3 D0 HDR-RX* Pin 8 D0 PD28 RX Same - TX HD3 D1 HDR-TX* Pin 7 D1 PD20 TX Same - SCL HD1 A5 I2C-SCL Pin 5 AD5 PE0 SDA Same + TX HD3 D1 HDR-TX* Pin 7 D1 PD30 TX Same + SCL HD1 A5 I2C-SCL Pin 5 AD5 PC30 SDA Same SDA HD1 A4 I2C-SDA Pin 6 AD4 PC13 SCL Same 5V N/A 5V N/A GND N/A GND N/A @@ -1471,7 +1471,7 @@ Click Shield * Depends upon setting of SW1, UART vs PROG. --- ----- ------------------------------ --------------------------------- - PIN PORT SHIELD FUNCTION PIN CONFIGURATION + PIN PORT SHIELD FUNCTION SAMV71PIN CONFIGURATION --- ----- ------------------------------ --------------------------------- AD0 PD26 microBUS2 Analog TD PD26 *** Not an AFE pin *** AD1 PC31 microBUS2 Analog PC31 AFE1_AD6 GPIO_AFE1_AD6 diff --git a/configs/samv71-xult/src/sam_bringup.c b/configs/samv71-xult/src/sam_bringup.c index 6234c845ae0..68460f1cb40 100644 --- a/configs/samv71-xult/src/sam_bringup.c +++ b/configs/samv71-xult/src/sam_bringup.c @@ -542,7 +542,6 @@ int sam_bringup(void) #ifdef HAVE_ELF /* Initialize the ELF binary loader */ - syslog(LOG_ERR, "Initializing the ELF binary loader\n"); ret = elf_initialize(); if (ret < 0) { diff --git a/configs/samv71-xult/src/sam_spi.c b/configs/samv71-xult/src/sam_spi.c index 81163fab648..712db8e0cbc 100644 --- a/configs/samv71-xult/src/sam_spi.c +++ b/configs/samv71-xult/src/sam_spi.c @@ -70,12 +70,12 @@ void sam_spidev_initialize(void) { #ifdef CONFIG_SAMV7_SPI0_MASTER - #ifdef CONFIG_SAMV71XULT_MB1_SPI /* Enable chip select for mikroBUS1 */ (void)sam_configgpio(CLICK_MB1_CS); #endif + #ifdef CONFIG_SAMV71XULT_MB2_SPI /* Enable chip select for mikroBUS2 */ From 7999822189ca9d7ee088a96b0dccd8a0cd54b8e4 Mon Sep 17 00:00:00 2001 From: Jan Pobrislo Date: Tue, 4 Jul 2017 14:43:19 -0600 Subject: [PATCH 30/33] I've found that the interrupts aren't enabled since nothing updates them after btn_poll() marks the file descriptor structure as being polling. I've managed to make it work with this change. --- drivers/input/button_upper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/input/button_upper.c b/drivers/input/button_upper.c index 93b54454e07..816cf01c4a0 100644 --- a/drivers/input/button_upper.c +++ b/drivers/input/button_upper.c @@ -769,7 +769,7 @@ static int btn_poll(FAR struct file *filep, FAR struct pollfd *fds, if (i >= CONFIG_BUTTONS_NPOLLWAITERS) { - ierr("ERROR: Too man poll waiters\n"); + ierr("ERROR: Too many poll waiters\n"); fds->priv = NULL; ret = -EBUSY; goto errout_with_dusem; @@ -797,6 +797,7 @@ static int btn_poll(FAR struct file *filep, FAR struct pollfd *fds, } errout_with_dusem: + btn_enable(priv); btn_givesem(&priv->bu_exclsem); return ret; } From ffae9f0251a31124186a3a897ff0abce65c61417 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 4 Jul 2017 15:58:39 -0600 Subject: [PATCH 31/33] include/nuttx/input: Remove bogus, obsolete keypad.h header file. --- include/nuttx/input/keypad.h | 55 ------------------------------------ 1 file changed, 55 deletions(-) delete mode 100644 include/nuttx/input/keypad.h diff --git a/include/nuttx/input/keypad.h b/include/nuttx/input/keypad.h deleted file mode 100644 index b38111c9e54..00000000000 --- a/include/nuttx/input/keypad.h +++ /dev/null @@ -1,55 +0,0 @@ -/************************************************************************************ - * include/nuttx/input/keypad.h - * - * Copyright (C) 2012 Denis Carikli. - * Author: Denis Carikli - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ************************************************************************************/ - -#ifndef __INCLUDE_NUTTX_INPUT_KEYPAD_H -#define __INCLUDE_NUTTX_INPUT_KEYPAD_H - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifdef __cplusplus -extern "C" -{ -#endif - -int keypad_kbdinit(void); - -#ifdef __cplusplus -} -#endif - -#endif /* __INCLUDE_NUTTX_INPUT_KEYPAD_H */ - From 65c3fa6375ecb36ae955d184c223f3e2c2851d94 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 5 Jul 2017 07:27:17 -0600 Subject: [PATCH 32/33] net/udp: Fix a copy-paste error that could effect networking when both IPv4 and IPv6 are enabled. --- net/udp/udp_psock_sendto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/udp/udp_psock_sendto.c b/net/udp/udp_psock_sendto.c index 8cdac7ff4b2..616d1d3b47e 100644 --- a/net/udp/udp_psock_sendto.c +++ b/net/udp/udp_psock_sendto.c @@ -194,7 +194,7 @@ static inline void sendto_ipselect(FAR struct net_driver_s *dev, /* Select the IPv6 domain */ DEBUGASSERT(psock->s_domain == PF_INET6); - udp_ipv4_select(dev); + udp_ipv6_select(dev); } } #endif From 31f832d8c5457e1e29a2b52eaaef8503245428b6 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 5 Jul 2017 11:01:16 -0600 Subject: [PATCH 33/33] IP forwarding: Flesh out TCP, UDP, and ICMPv6 packet forwarding logic. --- configs/same70-xplained/README.txt | 4 +- configs/samv71-xult/README.txt | 4 +- net/devif/Make.defs | 2 +- net/devif/devif_forward.c | 102 ++++++++ net/devif/devif_iobsend.c | 28 --- net/devif/devif_send.c | 31 +-- net/devif/ip_forward.h | 66 +++++- net/devif/ipv6_forward.c | 41 +++- net/icmpv6/Make.defs | 2 + net/icmpv6/icmpv6.h | 10 +- net/icmpv6/icmpv6_forward.c | 260 ++++++++++++++++++-- net/icmpv6/icmpv6_neighbor.c | 2 +- net/tcp/Make.defs | 4 +- net/tcp/tcp.h | 18 +- net/tcp/tcp_forward.c | 367 +++++++++++++++++++++++++++-- net/tcp/tcp_send_unbuffered.c | 2 +- net/udp/Make.defs | 2 + net/udp/udp.h | 12 +- net/udp/udp_forward.c | 301 +++++++++++++++++++++-- net/udp/udp_psock_sendto.c | 6 +- 20 files changed, 1102 insertions(+), 162 deletions(-) create mode 100644 net/devif/devif_forward.c diff --git a/configs/same70-xplained/README.txt b/configs/same70-xplained/README.txt index e2275469698..0e611261f9a 100644 --- a/configs/same70-xplained/README.txt +++ b/configs/same70-xplained/README.txt @@ -883,8 +883,8 @@ Click Shield D2 PA5 microBUS1 GPIO interrupt input PA5 D3 PA6 microBUS2 GPIO interrupt input PA6 D4 PD27 *** Not used *** - D5 PD11 microBUS2 PWM PD11 PWMC0_H0 - D6 PC19 microBUS1 PWN PC19 PWMC0_H2 + D5 PD11 microBUS2 PWMB PD11 PWMC0_H0 + D6 PC19 microBUS1 PWMA PC19 PWMC0_H2 D7 PA2 *** Not used *** D8 PA17 *** Not used *** D9 PC9 microBUS2 CS GPIO output PC9 diff --git a/configs/samv71-xult/README.txt b/configs/samv71-xult/README.txt index c408f4dc863..3b234ba3f28 100644 --- a/configs/samv71-xult/README.txt +++ b/configs/samv71-xult/README.txt @@ -1486,8 +1486,8 @@ Click Shield D2 PA5 microBUS1 GPIO interrupt input PA5 D3 PA6 microBUS2 GPIO interrupt input PA6 D4 PD27 *** Not used *** - D5 PD11 microBUS2 PWM PD11 PWMC0_H0 - D6 PC19 microBUS1 PWN PC19 PWMC0_H2 + D5 PD11 microBUS2 PWMB PD11 PWMC0_H0 + D6 PC19 microBUS1 PWMA PC19 PWMC0_H2 D7 PA2 *** Not used *** D8 PA17 *** Not used *** D9 PC9 microBUS2 CS GPIO output PC9 diff --git a/net/devif/Make.defs b/net/devif/Make.defs index c436648101d..4dcce7379b6 100644 --- a/net/devif/Make.defs +++ b/net/devif/Make.defs @@ -53,7 +53,7 @@ endif ifeq ($(CONFIG_NET_IPFORWARD),y) ifeq ($(CONFIG_NETDEV_MULTINIC),y) -NET_CSRCS += ip_forward.c +NET_CSRCS += ip_forward.c devif_forward.c endif endif diff --git a/net/devif/devif_forward.c b/net/devif/devif_forward.c new file mode 100644 index 00000000000..87e4ad07e58 --- /dev/null +++ b/net/devif/devif_forward.c @@ -0,0 +1,102 @@ +/**************************************************************************** + * net/devif/devif_forward.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include + +#include "devif/ip_forward.h" +#include "devif/devif.h" + +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: devif_forward + * + * Description: + * Called from protocol-specific IP forwarding logic to re-send a packet. + * + * Input Parameters: + * fwd - An initialized instance of the common forwarding structure that + * includes everything needed to perform the forwarding operation. + * + * Returned Value: + * None + * + * Assumptions: + * The network is locked. + * + ****************************************************************************/ + +void devif_forward(FAR struct forward_s *fwd) +{ + unsigned int offset; + int ret; + + DEBUGASSERT(fwd != NULL && fwd->f_dev != NULL); + offset = NET_LL_HDRLEN(fwd->f_dev); + + /* Copy the saved L2 + L3 header */ + + DEBUGASSERT(offset + fwd->f_hdrsize <= NET_DEV_MTU(fwd->f_dev)); + memcpy(&fwd->f_dev->d_buf[offset], &fwd->f_hdr, fwd->f_hdrsize); + offset += fwd->f_hdrsize; + + /* Copy the IOB chain that contains the payload */ + + if (fwd->f_iob != NULL && fwd->f_iob->io_pktlen > 0) + { + DEBUGASSERT(offset + fwd->f_iob->io_pktlen <= NET_DEV_MTU(fwd->f_dev)); + ret = iob_copyout(&fwd->f_dev->d_buf[offset], fwd->f_iob, + fwd->f_iob->io_pktlen, 0); + + DEBUGASSERT(ret == fwd->f_iob->io_pktlen); + offset += fwd->f_iob->io_pktlen; + } + + fwd->f_dev->d_sndlen = offset; +} + +#endif /* CONFIG_NET_IPFORWARD && CONFIG_NETDEV_MULTINIC */ diff --git a/net/devif/devif_iobsend.c b/net/devif/devif_iobsend.c index 5575a2b60ca..7b44a2068cc 100644 --- a/net/devif/devif_iobsend.c +++ b/net/devif/devif_iobsend.c @@ -48,34 +48,6 @@ #ifdef CONFIG_MM_IOB -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Public Constant Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Constant Data - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/net/devif/devif_send.c b/net/devif/devif_send.c index 8bcfedb0b01..43c913a97b6 100644 --- a/net/devif/devif_send.c +++ b/net/devif/devif_send.c @@ -47,33 +47,7 @@ #include -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Public Constant Data - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Private Constant Data - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ +#include "devif/devif.h" /**************************************************************************** * Public Functions @@ -87,8 +61,7 @@ * the network interface driver. * * Assumptions: - * Called from the interrupt level or, at a minimum, with interrupts - * disabled. + * The network is locked. * ****************************************************************************/ diff --git a/net/devif/ip_forward.h b/net/devif/ip_forward.h index a61fab2667d..c8cd65e4deb 100644 --- a/net/devif/ip_forward.h +++ b/net/devif/ip_forward.h @@ -49,6 +49,10 @@ #include #include +#include "udp/udp.h" +#include "tcp/tcp.h" +#include "icmpv6/icmpv6.h" + #undef HAVE_FWDALLOC #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) @@ -69,7 +73,7 @@ /* IPv4 + L2 header */ #ifdef CONFIG_NET_IPv4 -struct ipv6_fwdhdr_s +struct fwd_ipv4hdr_u { struct ipv4_hdr_s l2; union @@ -91,7 +95,7 @@ struct ipv6_fwdhdr_s /* IPv6 + L2 header */ #ifdef CONFIG_NET_IPv6 -struct ipv6_fwdhdr_s +struct fwd_ipv6hdr_u { struct ipv6_hdr_s l2; union @@ -112,28 +116,46 @@ struct ipv6_fwdhdr_s /* IPv4 or IPv6 + L2 header */ -union ip_fwdhdr_u +union fwd_iphdr_u { #ifdef CONFIG_NET_IPv4 - struct ipv4_fwdhdr_s ipv4; + struct fwd_ipv4hdr_u ipv4; #endif #ifdef CONFIG_NET_IPv6 - struct ipv6_fwdhdr_s ipv6; + struct fwd_ipv6hdr_u ipv6; +#endif +}; + +/* Connection structures */ + +union fwd_conn_u +{ +#ifdef CONFIG_NET_TCP + struct tcp_conn_s tcp; +#endif +#ifdef CONFIG_NET_UDP + struct udp_conn_s udp; +#endif +#ifdef CONFIG_NET_ICMPv6 + struct icmpv6_conn_s icmpv6; #endif }; /* This is the send state structure */ -struct net_driver_s; /* Forward reference */ -struct iob_s; /* Forward reference */ +struct devif_callback_s; /* Forward refernce */ +struct net_driver_s; /* Forward reference */ +struct iob_s; /* Forward reference */ struct forward_s { - FAR struct forward_s *f_flink; /* Supports a singly linked list */ - FAR struct net_driver_s *f_dev; /* Forwarding device */ - FAR struct iob_s *f_iob; /* IOBs containing the data payload */ - union ip_fwdhdr_u f_hdr; /* Copy of original L2+L3 headers */ - uint8_t f_hdrsize; /* The size of the L2+L3 headers */ + FAR struct forward_s *f_flink; /* Supports a singly linked list */ + FAR struct net_driver_s *f_dev; /* Forwarding device */ + FAR struct iob_s *f_iob; /* IOBs containing the data payload */ + FAR struct devif_callback_s *f_cb; /* Reference to callback instance */ + union fwd_iphdr_u f_hdr; /* Copy of original L2+L3 headers */ + union fwd_conn_u f_conn; /* Protocol-specific connectin struct */ + uint8_t f_hdrsize; /* The size of the L2+L3 headers */ }; /**************************************************************************** @@ -182,5 +204,25 @@ FAR struct forward_s *ip_forward_alloc(void); void ip_forward_free(FAR struct forward_s *fwd); +/**************************************************************************** + * Name: devif_forward + * + * Description: + * Called from protocol-specific IP forwarding logic to re-send a packet. + * + * Input Parameters: + * fwd - An initialized instance of the common forwarding structure that + * includes everything needed to perform the forwarding operation. + * + * Returned Value: + * None + * + * Assumptions: + * The network is locked. + * + ****************************************************************************/ + +void devif_forward(FAR struct forward_s *fwd); + #endif /* CONFIG_NET_IPFORWARD && CONFIG_NETDEV_MULTINIC */ #endif /* __NET_DEVIF_IP_FORWARD_H */ diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index eaf868533ff..fa2ec6f77ef 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -225,6 +225,17 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, FAR uint8_t *payload; unsigned int paysize; + /* Verify that the full packet will fit within the forwarding devices + * MTU. We provide no support for fragmenting forwarded packets. + */ + + if (NET_LL_HDRLEN(fwddev) + dev->d_len > NET_DEV_MTU(fwddev)) + { + nwarn("WARNING: Packet > MTU... Dropping\n"); + ret = -EFBIG; + goto errout; + } + /* Get a pre-allocated forwarding structure, This structure will be * completely zeroed when we receive it. */ @@ -246,6 +257,10 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, * * Remember that the size of the L1 header has already been subtracted * from dev->d_len. + * + * REVISIT: Consider an alternative design that does not require data + * copying. This would require a pool of d_buf's that are managed by + * the network rather than the network device. */ hdrsize = ipv6_hdrsize(ipv6); @@ -258,7 +273,7 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, /* Save the entire L2 and L3 headers in the state structure */ - if (hdrsize > sizeof(union ip_fwdhdr_u)) + if (hdrsize > sizeof(union fwd_iphdr_u)) { nwarn("WARNING: Header is too big for pre-allocated structure\n"); ret = -E2BIG; @@ -278,7 +293,12 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, payload = (FAR uint8_t *)ipv6 + hdrsize; paysize = dev->d_len - hdrsize; - /* If there is a payload, then copy it into an IOB chain */ + /* If there is a payload, then copy it into an IOB chain. + * + * REVISIT: Consider an alternative design that does not require data + * copying. This would require a pool of d_buf's that are managed by + * the network rather than the network device. + */ if (paysize > 0) { @@ -308,16 +328,21 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, } } - /* Then set up to forward the packet according to the protocol */ + /* Then set up to forward the packet according to the protocol. + * + * REVISIT: Are these protocol specific forwarders necessary? I think + * that this could be done with a single forwarding function for all + * protocols. + */ switch (ipv6->proto) { #ifdef CONFIG_NET_TCP case IP_PROTO_TCP: { - /* Forward a TCP packet, handling ACKs, windowing, etc. */ + /* Forward a TCP packet. */ - ret = tcp_ipv6_dev_forward(fwd); + ret = tcp_forward(fwd); } break; #endif @@ -327,7 +352,7 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, { /* Forward a UDP packet */ - ret = udp_ipv6_dev_forward(fwd); + ret = udp_forward(fwd); } break; #endif @@ -337,7 +362,7 @@ static int ipv6_dev_forward(FAR struct net_driver_s *dev, { /* Forward an ICMPv6 packet */ - ret = icmpv6_dev_forward(fwd); + ret = icmpv6_forward(fwd); } break; #endif @@ -428,7 +453,7 @@ static int ipv6_decr_ttl(FAR struct ipv6_hdr_s *ipv6) * Name: ipv6_dropstats * * Description: - * Update statistics for a droped packet. + * Update statistics for a dropped packet. * * Input Parameters: * ipv6 - A convenience pointer to the IPv6 header in within the IPv6 diff --git a/net/icmpv6/Make.defs b/net/icmpv6/Make.defs index d634478679a..92ac9cf2341 100644 --- a/net/icmpv6/Make.defs +++ b/net/icmpv6/Make.defs @@ -66,8 +66,10 @@ endif # IP forwarding ifeq ($(CONFIG_NET_IPFORWARD),y) +ifeq ($(CONFIG_NETDEV_MULTINIC),y) NET_CSRCS += icmpv6_forward.c endif +endif # Include ICMPv6 build support diff --git a/net/icmpv6/icmpv6.h b/net/icmpv6/icmpv6.h index 5589ed5061f..8ff15abaee2 100644 --- a/net/icmpv6/icmpv6.h +++ b/net/icmpv6/icmpv6.h @@ -55,8 +55,10 @@ /* Allocate a new ICMPv6 data callback */ -#define icmpv6_callback_alloc(dev) devif_callback_alloc(dev, &(dev)->d_conncb) -#define icmpv6_callback_free(dev,cb) devif_dev_callback_free(dev, cb) +#define icmpv6_callback_alloc(dev) \ + devif_callback_alloc((dev), &(dev)->d_conncb) +#define icmpv6_callback_free(dev,cb) \ + devif_dev_callback_free((dev), (cb)) /**************************************************************************** * Public Type Definitions @@ -177,7 +179,7 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr); #endif /**************************************************************************** - * Name: icmpv6_dev_forward + * Name: icmpv6_forward * * Description: * Called by the IP forwarding logic when an ICMPv6 packet is received on @@ -201,7 +203,7 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr); #if defined(CONFIG_NETDEV_MULTINIC) && defined(CONFIG_NET_IPFORWARD) struct forward_s; -int icmpv6_dev_forward(FAR struct forward_s *fwd); +int icmpv6_forward(FAR struct forward_s *fwd); #endif /**************************************************************************** diff --git a/net/icmpv6/icmpv6_forward.c b/net/icmpv6/icmpv6_forward.c index debbb36d159..ea5ba544c19 100644 --- a/net/icmpv6/icmpv6_forward.c +++ b/net/icmpv6/icmpv6_forward.c @@ -37,30 +37,251 @@ #include +#include #include #include +#include + #include #include #include +#include #include "devif/ip_forward.h" +#include "devif/devif.h" +#include "netdev/netdev.h" #include "icmpv6/icmpv6.h" -#if defined(CONFIG_NET) && defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_ICMPv6) +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_ICMPv6) && \ + defined(CONFIG_NETDEV_MULTINIC) /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: icmpv6_dev_forward + * Name: icmpv6_forward_addrchck * * Description: - * Called by the IP forwarding logic when an ICMPv6 packet is received on + * Check if the destination IP address is in the IPv4 ARP or IPv6 Neighbor + * tables. If not, then the send won't actually make it out... it will be + * replaced with an ARP request (IPv4) or a Neighbor Solicitation (IPv6). + * + * NOTE 1: This could be an expensive check if there are a lot of + * entries in the ARP or Neighbor tables. + * + * NOTE 2: If we are actually harvesting IP addresses on incoming IP + * packets, then this check should not be necessary; the MAC mapping + * should already be in the ARP table in many cases (IPv4 only). + * + * NOTE 3: If CONFIG_NET_ARP_SEND then we can be assured that the IP + * address mapping is already in the ARP table. + * + * Parameters: + * fwd - The forwarding state structure + * + * Returned Value: + * None + * + * Assumptions: + * The network is locked. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_ETHERNET +static inline bool icmpv6_forward_addrchck(FAR struct forward_s *fwd) +{ +#ifdef CONFIG_NET_IPv4 +#ifdef CONFIG_NET_IPv6 + if (conn->domain == PF_INET) +#endif + { +#if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) + return (arp_find(fwd->f_hdr.ipv4.l2.destipaddr) != NULL); +#else + return true; +#endif + } +#endif /* CONFIG_NET_IPv4 */ + +#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NET_IPv4 + else +#endif + { +#if !defined(CONFIG_NET_ICMPv6_NEIGHBOR) + return (neighbor_findentry(fwd->f_hdr.ipv6.l2.destipaddr) != NULL); +#else + return true; +#endif + } +#endif /* CONFIG_NET_IPv6 */ +} + +#else /* CONFIG_NET_ETHERNET */ +# define icmpv6_forward_addrchck(r) (true) +#endif /* CONFIG_NET_ETHERNET */ + +/**************************************************************************** + * Name: icmpv6_dropstats + * + * Description: + * Update statistics for a dropped packet. + * + * Input Parameters: + * fwd - The forwarding state structure + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_NET_STATISTICS +static void icmpv6_dropstats(FAR struct forward_s *fwd) +{ + /* Increment the count of dropped ICMPV6 packets */ + + g_netstats.icmpv6.drop++; + + /* Increment the count of dropped IPv4 or IPv6 packets */ + +#ifdef CONFIG_NET_IPv4 +#ifdef CONFIG_NET_IPv6 + if ((fwd->f_hdr.ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) +#endif + { + g_netstats.ipv4.drop++; + } +#endif +#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NET_IPv4 + else +#endif + { + g_netstats.ipv6.drop++; + } +#endif +} +#else +# define icmpv6_dropstats(ipv6) +#endif + +/**************************************************************************** + * Name: icmpv6_forward_interrupt + * + * Description: + * This function is called from the interrupt level to perform the actual + * send operation when polled by the lower, device interfacing layer. + * + * Parameters: + * dev The structure of the network driver that caused the interrupt + * conn An instance of the ICMPV6 connection structure cast to void * + * pvpriv An instance of struct forward_s cast to void* + * flags Set of events describing why the callback was invoked + * + * Returned Value: + * Modified value of the input flags + * + * Assumptions: + * The network is locked + * + ****************************************************************************/ + +static uint16_t icmpv6_forward_interrupt(FAR struct net_driver_s *dev, + FAR void *conn, FAR void *pvpriv, + uint16_t flags) +{ + FAR struct forward_s *fwd = (FAR struct forward_s *)pvpriv; + + ninfo("flags: %04x\n", flags); + DEBUGASSERT(fwd != NULL); + + /* Make sure that this is from the forwarding device */ + + if (dev == fwd->f_dev) + { + /* If the network device has gone down, then we will have terminate + * the wait now with an error. + */ + + if ((flags & NETDEV_DOWN) != 0) + { + /* Terminate the transfer with an error. */ + + nwarn("WARNING: Network is down... Dropping\n"); + icmpv6_dropstats(fwd); + } + + /* Check if the outgoing packet is available. It may have been claimed + * by another send interrupt serving a different thread -OR- if the output + * buffer currently contains unprocessed incoming data. In these cases + * we will just have to wait for the next polling cycle. + */ + + else if (dev->d_sndlen > 0 || (flags & ICMPv6_NEWDATA) != 0) + { + /* Another thread has beat us sending data or the buffer is busy, + * Wait for the next polling cycle and check again. + */ + + return flags; + } + + /* It looks like we are good to forward the data */ + + else + { + /* Copy the ICMPv6 data into driver's packet buffer and send it. */ + + devif_forward(fwd); + + /* Check if the destination IP address is in the ARP or Neighbor + * table. If not, then the send won't actually make it out... it + * will be replaced with an ARP request or Neighbor Solicitation. + */ + + if (!icmpv6_forward_addrchck(fwd)) + { + return flags; + } + } + + /* Free the allocated callback structure */ + + fwd->f_cb->flags = 0; + fwd->f_cb->priv = NULL; + fwd->f_cb->event = NULL; + + icmpv6_callback_free(dev, fwd->f_cb); + + /* Free any IOBs */ + + if (fwd->f_iob != NULL) + { + iob_free_chain(fwd->f_iob); + } + + /* And release the forwarding state structure */ + + ip_forward_free(fwd); + } + + return flags; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: icmpv6_forward + * + * Description: + * Called by the IP forwarding logic when an ICMPV6 packet is received on * one network device, but must be forwarded on another network device. * - * Set up to forward the ICMPv6 packet on the specified device. The + * Set up to forward the ICMPV6 packet on the specified device. This * function will set up a send "interrupt" handler that will perform the * actual send asynchronously and must return without waiting for the * send to complete. @@ -76,23 +297,26 @@ * ****************************************************************************/ -#if defined(CONFIG_NETDEV_MULTINIC) && defined(CONFIG_NET_ICMPv6) -int icmpv6_dev_forward(FAR struct forward_s *fwd) +int icmpv6_forward(FAR struct forward_s *fwd) { - /* Set up to send the packet when the selected device polls for TX data. */ + DEBUGASSERT(fwd != NULL && fwd->f_dev != NULL); - /* Notify the forwarding device that TX data is available */ + /* Set up the callback in the connection */ -#warning Missing logic + fwd->f_cb = icmpv6_callback_alloc(fwd->f_dev); + if (fwd->f_cb != NULL) + { + fwd->f_cb->flags = (ICMPv6_POLL | NETDEV_DOWN); + fwd->f_cb->priv = (FAR void *)fwd; + fwd->f_cb->event = icmpv6_forward_interrupt; - /* REVISIT: For Ethernet we may have to fix up the Ethernet header: - * - source MAC, the MAC of the current device. - * - dest MAC, the MAC associated with the destination IPv6 adress. - * This will involve ICMPv6 and Neighbor Discovery. - */ + /* Notify the device driver of the availability of TX data */ - nwarn("WARNING: UPD/ICMPv6 packet forwarding not yet supported\n"); - return -ENOSYS; + netdev_txnotify_dev(fwd->f_dev); + return OK; + } + + return -EBUSY; } -#endif /* CONFIG_NET_ICMPv6 && CONFIG_NETDEV_MULTINIC */ -#endif /* CONFIG_NET && CONFIG_NET_IPFORWARD && CONFIG_NET_ICMPv6 */ + +#endif /* CONFIG_NET_IPFORWARD && CONFIG_NET_ICMPv6 && CONFIG_NETDEV_MULTINIC */ diff --git a/net/icmpv6/icmpv6_neighbor.c b/net/icmpv6/icmpv6_neighbor.c index de7ba28046a..9c58b87a1f8 100644 --- a/net/icmpv6/icmpv6_neighbor.c +++ b/net/icmpv6/icmpv6_neighbor.c @@ -314,7 +314,7 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr) (void)sem_init(&state.snd_sem, 0, 0); /* Doesn't really fail */ sem_setprotocol(&state.snd_sem, SEM_PRIO_NONE); - state.snd_retries = 0; /* No retries yet */ + state.snd_retries = 0; /* No retries yet */ net_ipv6addr_copy(state.snd_ipaddr, lookup); /* IP address to query */ #ifdef CONFIG_NETDEV_MULTINIC diff --git a/net/tcp/Make.defs b/net/tcp/Make.defs index f9e7c893882..7f3a88582b5 100644 --- a/net/tcp/Make.defs +++ b/net/tcp/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # net/tcp/Make.defs # -# Copyright (C) 2014 Gregory Nutt. All rights reserved. +# Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -63,8 +63,10 @@ NET_CSRCS += tcp_callback.c tcp_backlog.c tcp_ipselect.c # IP forwarding ifeq ($(CONFIG_NET_IPFORWARD),y) +ifeq ($(CONFIG_NETDEV_MULTINIC),y) NET_CSRCS += tcp_forward.c endif +endif # TCP write buffering diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h index 627a114ed6c..8b554fff864 100644 --- a/net/tcp/tcp.h +++ b/net/tcp/tcp.h @@ -71,18 +71,18 @@ */ # define tcp_callback_alloc(conn) \ - devif_callback_alloc(conn->dev, &conn->list) + devif_callback_alloc((conn)->dev, &(conn)->list) # define tcp_callback_free(conn,cb) \ - devif_conn_callback_free(conn->dev, cb, &conn->list) + devif_conn_callback_free((conn)->dev, (cb), &(conn)->list) /* These macros allocate and free callback structures used for receiving * notifications of device-related events. */ # define tcp_monitor_callback_alloc(conn) \ - devif_callback_alloc(conn->dev, NULL) + devif_callback_alloc((conn)->dev, NULL) # define tcp_monitor_callback_free(conn,cb) \ - devif_conn_callback_free(conn->dev, cb, NULL) + devif_conn_callback_free((conn)->dev, (cb), NULL) #else /* These macros allocate and free callback structures used for receiving @@ -90,9 +90,9 @@ */ # define tcp_callback_alloc(conn) \ - devif_callback_alloc(g_netdevices, &conn->list) + devif_callback_alloc(g_netdevices, &(conn)->list) # define tcp_callback_free(conn,cb) \ - devif_conn_callback_free(g_netdevices, cb, &conn->list) + devif_conn_callback_free(g_netdevices, (cb), &(conn)->list) /* These macros allocate and free callback structures used for receiving * notifications of device-related events. @@ -101,7 +101,7 @@ # define tcp_monitor_callback_alloc(conn) \ devif_callback_alloc(g_netdevices, NULL) # define tcp_monitor_callback_free(conn,cb) \ - devif_conn_callback_free(g_netdevices, cb, NULL) + devif_conn_callback_free(g_netdevices, (cb), NULL) #endif #ifdef CONFIG_NET_TCP_WRITE_BUFFERS @@ -795,7 +795,7 @@ void tcp_send(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, uint16_t flags, uint16_t len); /**************************************************************************** - * Name: tcp_ipv6_dev_forward + * Name: tcp_forward * * Description: * Called by the IP forwarding logic when an TCP packet is received on @@ -820,7 +820,7 @@ void tcp_send(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv6) && \ defined(CONFIG_NETDEV_MULTINIC) struct forward_s; /* Forward reference */ -int tcp_ipv6_dev_forward(FAR struct forward_s *fwd); +int tcp_forward(FAR struct forward_s *fwd); #endif /**************************************************************************** diff --git a/net/tcp/tcp_forward.c b/net/tcp/tcp_forward.c index ebb4c69b986..22c021aa367 100644 --- a/net/tcp/tcp_forward.c +++ b/net/tcp/tcp_forward.c @@ -37,32 +37,316 @@ #include +#include +#include #include #include +#include + #include #include #include +#include #include "devif/ip_forward.h" +#include "devif/devif.h" +#include "netdev/netdev.h" #include "tcp/tcp.h" -#if defined(CONFIG_NET) && defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_TCP) +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_TCP) && \ + defined(CONFIG_NETDEV_MULTINIC) /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: tcp_ipv6_dev_forward + * Name: forward_ipselect + * + * Description: + * If both IPv4 and IPv6 support are enabled, then we will need to select + * which one to use when generating the outgoing packet. If only one + * domain is selected, then the setup is already in place and we need do + * nothing. + * + * Parameters: + * fwd - The forwarding state structure + * + * Returned Value: + * None + * + * Assumptions: + * The network is locked. + * + ****************************************************************************/ + +#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) +static inline void forward_ipselect(FAR struct forward_s *fwd) +{ + /* Which domain the connection support */ + + if (fwd->f_conn.tcp.domain == PF_INET) + { + /* Select the IPv4 domain */ + + tcp_ipv4_select(dev); + } + else /* if (conn->domain == PF_INET6) */ + { + /* Select the IPv6 domain */ + + DEBUGASSERT(conn->domain == PF_INET6); + tcp_ipv6_select(dev); + } +} +#endif + +/**************************************************************************** + * Name: tcp_forward_addrchck + * + * Description: + * Check if the destination IP address is in the IPv4 ARP or IPv6 Neighbor + * tables. If not, then the send won't actually make it out... it will be + * replaced with an ARP request (IPv4) or a Neighbor Solicitation (IPv6). + * + * NOTE 1: This could be an expensive check if there are a lot of + * entries in the ARP or Neighbor tables. + * + * NOTE 2: If we are actually harvesting IP addresses on incoming IP + * packets, then this check should not be necessary; the MAC mapping + * should already be in the ARP table in many cases (IPv4 only). + * + * NOTE 3: If CONFIG_NET_ARP_SEND then we can be assured that the IP + * address mapping is already in the ARP table. + * + * Parameters: + * fwd - The forwarding state structure + * + * Returned Value: + * None + * + * Assumptions: + * The network is locked. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_ETHERNET +static inline bool tcp_forward_addrchck(FAR struct forward_s *fwd) +{ + FAR struct tcp_conn_s *conn = &fwd->f_conn.tcp; + +#ifdef CONFIG_NET_IPv4 +#ifdef CONFIG_NET_IPv6 + if (conn->domain == PF_INET) +#endif + { +#if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) + return (arp_find(conn->u.ipv4.raddr) != NULL); +#else + return true; +#endif + } +#endif /* CONFIG_NET_IPv4 */ + +#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NET_IPv4 + else +#endif + { +#if !defined(CONFIG_NET_ICMPv6_NEIGHBOR) + return (neighbor_findentry(conn->u.ipv6.raddr) != NULL); +#else + return true; +#endif + } +#endif /* CONFIG_NET_IPv6 */ + + UNUSED(conn); +} + +#else /* CONFIG_NET_ETHERNET */ +# define tcp_forward_addrchck(r) (true) +#endif /* CONFIG_NET_ETHERNET */ + +/**************************************************************************** + * Name: tcp_dropstats + * + * Description: + * Update statistics for a dropped packet. + * + * Input Parameters: + * fwd - The forwarding state structure + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_NET_STATISTICS +static void tcp_dropstats(FAR struct forward_s *fwd) +{ + /* Increment the count of dropped TCP packets */ + + g_netstats.tcp.drop++; + + /* Increment the count of dropped IPv4 or IPv6 packets */ + +#ifdef CONFIG_NET_IPv4 +#ifdef CONFIG_NET_IPv6 + if (fwd->f_conn.tcp.domain == PF_INET) +#endif + { + g_netstats.ipv4.drop++; + } +#endif +#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NET_IPv4 + else +#endif + { + g_netstats.ipv6.drop++; + } +#endif +} +#else +# define tcp_dropstats(ipv6) +#endif + +/**************************************************************************** + * Name: tcp_forward_interrupt + * + * Description: + * This function is called from the interrupt level to perform the actual + * send operation when polled by the lower, device interfacing layer. + * + * NOTE: Our role here is just data passthrough. We don't really care + * about ACKing, dynamic windows or any of the other TCP complexities. + * That is really something between the two endpoints and does not matter + * the forwarding hub. + * + * Parameters: + * dev The structure of the network driver that caused the interrupt + * conn An instance of the TCP connection structure cast to void * + * pvpriv An instance of struct forward_s cast to void* + * flags Set of events describing why the callback was invoked + * + * Returned Value: + * Modified value of the input flags + * + * Assumptions: + * The network is locked + * + ****************************************************************************/ + +static uint16_t tcp_forward_interrupt(FAR struct net_driver_s *dev, + FAR void *conn, FAR void *pvpriv, + uint16_t flags) +{ + FAR struct forward_s *fwd = (FAR struct forward_s *)pvpriv; + + ninfo("flags: %04x\n", flags); + DEBUGASSERT(fwd != NULL); + + /* Make sure that this is from the forwarding device */ + + if (dev == fwd->f_dev) + { + /* If the network device has gone down, then we will have terminate + * the wait now with an error. + * + * REVISIT: TCP disconnection events should should not be recieved here. + * Rather the disconnection events will be handled by the TCP endpoints. + */ + + if ((flags & NETDEV_DOWN) != 0) + { + /* Terminate the transfer with an error. */ + + nwarn("WARNING: Network is down... Dropping\n"); + tcp_dropstats(fwd); + } + + /* Check if the outgoing packet is available. It may have been claimed + * by a sendto interrupt serving a different thread -OR- if the output + * buffer currently contains unprocessed incoming data. In these cases + * we will just have to wait for the next polling cycle. + */ + + else if (dev->d_sndlen > 0 || (flags & TCP_NEWDATA) != 0) + { + /* Another thread has beat us sending data or the buffer is busy, + * Wait for the next polling cycle and check again. + */ + + return flags; + } + + /* It looks like we are good to forward the data */ + + else + { +#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) + /* If both IPv4 and IPv6 support are enabled, then we will need to + * select which one to use when generating the outgoing packet. + * If only one domain is selected, then the setup is already in + * place and we need do nothing. + */ + + forward_ipselect(dev, fwd); +#endif + /* Copy the user data into d_appdata and send it. */ + + devif_forward(fwd); + + /* Check if the destination IP address is in the ARP or Neighbor + * table. If not, then the send won't actually make it out... it + * will be replaced with an ARP request or Neighbor Solicitation. + */ + + if (!tcp_forward_addrchck(fwd)) + { + return flags; + } + } + + /* Free the allocated callback structure */ + + fwd->f_cb->flags = 0; + fwd->f_cb->priv = NULL; + fwd->f_cb->event = NULL; + + tcp_callback_free(&fwd->f_conn.tcp, fwd->f_cb); + + /* Free any IOBs */ + + if (fwd->f_iob != NULL) + { + iob_free_chain(fwd->f_iob); + } + + /* And release the forwarding state structure */ + + ip_forward_free(fwd); + } + + return flags; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: tcp_forward * * Description: * Called by the IP forwarding logic when an TCP packet is received on * one network device, but must be forwarded on another network device. * * Set up to forward the TCP packet on the specified device. This - * function will set up a send "interrupt" handler that will perform - * the actual send asynchronously and must return without waiting for the + * function will set up a send "interrupt" handler that will perform the + * actual send asynchronously and must return without waiting for the * send to complete. * * Input Parameters: @@ -76,27 +360,68 @@ * ****************************************************************************/ -#if defined(CONFIG_NET_IPv6) && defined(CONFIG_NETDEV_MULTINIC) -int tcp_ipv6_dev_forward(FAR struct forward_s *fwd) +int tcp_forward(FAR struct forward_s *fwd) { - /* Notify the forwarding device that TX data is available */ + DEBUGASSERT(fwd != NULL && fwd->f_dev != NULL); + FAR struct tcp_conn_s *conn = &fwd->f_conn.tcp; - /* Set up to send the packet when the selected device polls for TX data. - * TCP packets must obey ACK and windowing rules. + /* Set up some minimal connection structure so that we appear to be a + * real TCP connection. */ -#warning Missing logic + conn->dev = fwd->f_dev; - /* REVISIT: For Ethernet we may have to fix up the Ethernet header: - * - source MAC, the MAC of the current device. - * - dest MAC, the MAC associated with the destination IPv6 adress. - * This will involve ICMPv6 and Neighbor Discovery. - * - Because of TCP window, the packet may have to be sent in smaller - * pieces. - */ +#ifdef CONFIG_NET_IPv4 +#ifdef CONFIG_NET_IPv6 + if ((fwd->f_hdr.ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) +#endif + { + FAR struct ipv4_hdr_s *ipv4 = &fwd->f_hdr.ipv4.l2; + FAR struct tcp_hdr_s *tcp = &fwd->f_hdr.ipv4.l3.tcp; - nwarn("WARNING: TCP packet forwarding not yet supported\n"); - return -ENOSYS; +#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) + conn->domain = PF_INET; +#endif + conn->lport = tcp->srcport; + conn->rport = tcp->destport; + net_ipv4addr_copy(conn->u.ipv4.laddr, ipv4->srcipaddr); + net_ipv4addr_copy(conn->u.ipv4.raddr, ipv4->destipaddr); + } +#endif +#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NET_IPv4 + else +#endif + { + FAR struct ipv6_hdr_s *ipv6 = &fwd->f_hdr.ipv6.l2; + FAR struct tcp_hdr_s *tcp = &fwd->f_hdr.ipv6.l3.tcp; + +#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) + conn->domain = PF_INET6; +#endif + conn->lport = tcp->srcport; + conn->rport = tcp->destport; + net_ipv6addr_copy(conn->u.ipv6.laddr, ipv6->srcipaddr); + net_ipv6addr_copy(conn->u.ipv6.raddr, ipv6->destipaddr); + } +#endif + + /* Set up the callback in the connection */ + + fwd->f_cb = tcp_callback_alloc(conn); + if (fwd->f_cb != NULL) + { + fwd->f_cb->flags = (TCP_POLL | NETDEV_DOWN); + fwd->f_cb->priv = (FAR void *)fwd; + fwd->f_cb->event = tcp_forward_interrupt; + + /* Notify the device driver of the availability of TX data */ + + netdev_txnotify_dev(fwd->f_dev); + return OK; + } + + return -EBUSY; } -#endif /* CONFIG_NET_IPv6 && CONFIG_NETDEV_MULTINIC */ -#endif /* CONFIG_NET && CONFIG_NET_IPFORWARD && CONFIG_NET_TCP */ + +#endif /* CONFIG_NET_IPFORWARD && CONFIG_NET_TCP && CONFIG_NETDEV_MULTINIC */ diff --git a/net/tcp/tcp_send_unbuffered.c b/net/tcp/tcp_send_unbuffered.c index 6bb13f593de..2de4a5a975d 100644 --- a/net/tcp/tcp_send_unbuffered.c +++ b/net/tcp/tcp_send_unbuffered.c @@ -181,7 +181,7 @@ static inline int send_timeout(FAR struct send_s *pstate) static inline void tcpsend_ipselect(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn) { - /* Which domain the socket support */ + /* Which domain does the socket support */ if (conn->domain == PF_INET) { diff --git a/net/udp/Make.defs b/net/udp/Make.defs index e28161496ed..9dda0a16042 100644 --- a/net/udp/Make.defs +++ b/net/udp/Make.defs @@ -51,8 +51,10 @@ endif # IP forwarding ifeq ($(CONFIG_NET_IPFORWARD),y) +ifeq ($(CONFIG_NETDEV_MULTINIC),y) NET_CSRCS += udp_forward.c endif +endif # Transport layer diff --git a/net/udp/udp.h b/net/udp/udp.h index 64d2e7aa3dd..91a690f5fe0 100644 --- a/net/udp/udp.h +++ b/net/udp/udp.h @@ -68,10 +68,10 @@ /* Allocate a new UDP data callback */ -#define udp_callback_alloc(dev, conn) \ - devif_callback_alloc(dev, &conn->list) -#define udp_callback_free(dev, conn,cb) \ - devif_conn_callback_free(dev, cb, &conn->list) +#define udp_callback_alloc(dev,conn) \ + devif_callback_alloc((dev), &(conn)->list) +#define udp_callback_free(dev,conn,cb) \ + devif_conn_callback_free((dev), (cb), &(conn)->list) /**************************************************************************** * Public Type Definitions @@ -429,7 +429,7 @@ uint16_t udp_callback(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn, uint16_t flags); /**************************************************************************** - * Name: udp_ipv6_dev_forward + * Name: udp_forward * * Description: * Called by the IP forwarding logic when an UDP packet is received on @@ -454,7 +454,7 @@ uint16_t udp_callback(FAR struct net_driver_s *dev, #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_IPv6) && \ defined(CONFIG_NETDEV_MULTINIC) struct forward_s; /* Forward reference */ -int udp_ipv6_dev_forward(FAR struct forward_s *fwd); +int udp_forward(FAR struct forward_s *fwd); #endif /**************************************************************************** diff --git a/net/udp/udp_forward.c b/net/udp/udp_forward.c index e1e5fc92f4c..f264ec62bea 100644 --- a/net/udp/udp_forward.c +++ b/net/udp/udp_forward.c @@ -37,24 +37,290 @@ #include +#include #include #include +#include + #include #include #include +#include #include "devif/ip_forward.h" +#include "devif/devif.h" +#include "netdev/netdev.h" #include "udp/udp.h" -#if defined(CONFIG_NET) && defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_UDP) +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NET_UDP) && \ + defined(CONFIG_NETDEV_MULTINIC) /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: udp_ipv6_dev_forward + * Name: forward_ipselect + * + * Description: + * If both IPv4 and IPv6 support are enabled, then we will need to select + * which one to use when generating the outgoing packet. If only one + * domain is selected, then the setup is already in place and we need do + * nothing. + * + * Parameters: + * fwd - The forwarding state structure + * + * Returned Value: + * None + * + * Assumptions: + * The network is locked. + * + ****************************************************************************/ + +#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) +static inline void forward_ipselect(FAR struct forward_s *fwd) +{ + /* Select IPv4 or IPv6 */ + + if ((fwd->f_hdr.ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) + { + udp_ipv4_select(fwd->f_dev); + } + else + { + udp_ipv6_select(fwd->f_dev); + } +} +#endif + +/**************************************************************************** + * Name: udp_forward_addrchk + * + * Description: + * Check if the destination IP address is in the IPv4 ARP or IPv6 Neighbor + * tables. If not, then the send won't actually make it out... it will be + * replaced with an ARP request (IPv4) or a Neighbor Solicitation (IPv6). + * + * NOTE 1: This could be an expensive check if there are a lot of + * entries in the ARP or Neighbor tables. + * + * NOTE 2: If we are actually harvesting IP addresses on incoming IP + * packets, then this check should not be necessary; the MAC mapping + * should already be in the ARP table in many cases (IPv4 only). + * + * NOTE 3: If CONFIG_NET_ARP_SEND then we can be assured that the IP + * address mapping is already in the ARP table. + * + * Parameters: + * fwd - The forwarding state structure + * + * Returned Value: + * None + * + * Assumptions: + * The network is locked. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_ETHERNET +static inline bool udp_forward_addrchk(FAR struct forward_s *fwd) +{ +#ifdef CONFIG_NET_IPv4 +#ifdef CONFIG_NET_IPv6 + if (conn->domain == PF_INET) +#endif + { +#if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) + return (arp_find(fwd->f_hdr.ipv4.l2.destipaddr) != NULL); +#else + return true; +#endif + } +#endif /* CONFIG_NET_IPv4 */ + +#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NET_IPv4 + else +#endif + { +#if !defined(CONFIG_NET_ICMPv6_NEIGHBOR) + return (neighbor_findentry(fwd->f_hdr.ipv6.l2.destipaddr) != NULL); +#else + return true; +#endif + } +#endif /* CONFIG_NET_IPv6 */ +} + +#else /* CONFIG_NET_ETHERNET */ +# define udp_forward_addrchk(r) (true) +#endif /* CONFIG_NET_ETHERNET */ + +/**************************************************************************** + * Name: udp_dropstats + * + * Description: + * Update statistics for a dropped packet. + * + * Input Parameters: + * fwd - The forwarding state structure + * + * Returned Value: + * None + * + ****************************************************************************/ + +#ifdef CONFIG_NET_STATISTICS +static void udp_dropstats(FAR struct forward_s *fwd) +{ + /* Increment the count of dropped UDP packets */ + + g_netstats.udp.drop++; + + /* Increment the count of dropped IPv4 or IPv6 packets */ + +#ifdef CONFIG_NET_IPv4 +#ifdef CONFIG_NET_IPv6 + if ((fwd->f_hdr.ipv4.l2.vhl & IP_VERSION_MASK) == IPv4_VERSION) +#endif + { + g_netstats.ipv4.drop++; + } +#endif +#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NET_IPv4 + else +#endif + { + g_netstats.ipv6.drop++; + } +#endif +} +#else +# define udp_dropstats(ipv6) +#endif + +/**************************************************************************** + * Name: udp_forward_interrupt + * + * Description: + * This function is called from the interrupt level to perform the actual + * send operation when polled by the lower, device interfacing layer. + * + * Parameters: + * dev The structure of the network driver that caused the interrupt + * conn An instance of the UDP connection structure cast to void * + * pvpriv An instance of struct forward_s cast to void* + * flags Set of events describing why the callback was invoked + * + * Returned Value: + * Modified value of the input flags + * + * Assumptions: + * The network is locked + * + ****************************************************************************/ + +static uint16_t udp_forward_interrupt(FAR struct net_driver_s *dev, + FAR void *conn, FAR void *pvpriv, + uint16_t flags) +{ + FAR struct forward_s *fwd = (FAR struct forward_s *)pvpriv; + + ninfo("flags: %04x\n", flags); + DEBUGASSERT(fwd != NULL); + + /* Make sure that this is from the forwarding device */ + + if (dev == fwd->f_dev) + { + /* If the network device has gone down, then we will have terminate + * the wait now with an error. + */ + + if ((flags & NETDEV_DOWN) != 0) + { + /* Terminate the transfer with an error. */ + + nwarn("WARNING: Network is down... Dropping\n"); + udp_dropstats(fwd); + } + + /* Check if the outgoing packet is available. It may have been claimed + * by a sendto interrupt serving a different thread -OR- if the output + * buffer currently contains unprocessed incoming data. In these cases + * we will just have to wait for the next polling cycle. + */ + + else if (dev->d_sndlen > 0 || (flags & UDP_NEWDATA) != 0) + { + /* Another thread has beat us sending data or the buffer is busy, + * Wait for the next polling cycle and check again. + */ + + return flags; + } + + /* It looks like we are good to forward the data */ + + else + { +#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6) + /* If both IPv4 and IPv6 support are enabled, then we will need to + * select which one to use when generating the outgoing packet. + * If only one domain is selected, then the setup is already in + * place and we need do nothing. + */ + + forward_ipselect(dev, fwd); +#endif + /* Copy the user data into d_appdata and send it. */ + + devif_forward(fwd); + + /* Check if the destination IP address is in the ARP or Neighbor + * table. If not, then the send won't actually make it out... it + * will be replaced with an ARP request or Neighbor Solicitation. + */ + + if (!udp_forward_addrchk(fwd)) + { + return flags; + } + } + + /* Free the allocated callback structure */ + + fwd->f_cb->flags = 0; + fwd->f_cb->priv = NULL; + fwd->f_cb->event = NULL; + + udp_callback_free(dev, &fwd->f_conn.udp, fwd->f_cb); + + /* Free any IOBs */ + + if (fwd->f_iob != NULL) + { + iob_free_chain(fwd->f_iob); + } + + /* And release the forwarding state structure */ + + ip_forward_free(fwd); + } + + return flags; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: udp_forward * * Description: * Called by the IP forwarding logic when an UDP packet is received on @@ -76,23 +342,26 @@ * ****************************************************************************/ -#if defined(CONFIG_NET_IPv6) && defined(CONFIG_NETDEV_MULTINIC) -int udp_ipv6_dev_forward(FAR struct forward_s *fwd) +int udp_forward(FAR struct forward_s *fwd) { - /* Set up to send the packet when the selected device polls for TX data. */ + DEBUGASSERT(fwd != NULL && fwd->f_dev != NULL); - /* Notify the forwarding device that TX data is available */ + /* Set up the callback in the connection */ -#warning Missing logic + fwd->f_cb = udp_callback_alloc(fwd->f_dev, &fwd->f_conn.udp); + if (fwd->f_cb != NULL) + { + fwd->f_cb->flags = (UDP_POLL | NETDEV_DOWN); + fwd->f_cb->priv = (FAR void *)fwd; + fwd->f_cb->event = udp_forward_interrupt; - /* REVISIT: For Ethernet we may have to fix up the Ethernet header: - * - source MAC, the MAC of the current device. - * - dest MAC, the MAC associated with the destination IPv6 adress. - * This will involve ICMPv6 and Neighbor Discovery. - */ + /* Notify the device driver of the availability of TX data */ - nwarn("WARNING: UPD/ICMPv6 packet forwarding not yet supported\n"); - return -ENOSYS; + netdev_txnotify_dev(fwd->f_dev); + return OK; + } + + return -EBUSY; } -#endif /* CONFIG_NET_IPv6 && CONFIG_NETDEV_MULTINIC */ -#endif /* CONFIG_NET && CONFIG_NET_IPFORWARD && CONFIG_NET_UDP */ + +#endif /* CONFIG_NET_IPFORWARD && CONFIG_NET_UDP && CONFIG_NETDEV_MULTINIC */ diff --git a/net/udp/udp_psock_sendto.c b/net/udp/udp_psock_sendto.c index 616d1d3b47e..dfc1aaa2e43 100644 --- a/net/udp/udp_psock_sendto.c +++ b/net/udp/udp_psock_sendto.c @@ -126,7 +126,7 @@ struct sendto_s * TRUE:timeout FALSE:no timeout * * Assumptions: - * Running at the interrupt level + * The network is locked * ****************************************************************************/ @@ -170,7 +170,7 @@ static inline int send_timeout(FAR struct sendto_s *pstate) * None * * Assumptions: - * Running at the interrupt level + * The network is locked * ****************************************************************************/ @@ -216,7 +216,7 @@ static inline void sendto_ipselect(FAR struct net_driver_s *dev, * Modified value of the input flags * * Assumptions: - * Running at the interrupt level + * The network is locked * ****************************************************************************/