diff --git a/examples/nettest/Kconfig b/examples/nettest/Kconfig index 285965787..67aef0954 100644 --- a/examples/nettest/Kconfig +++ b/examples/nettest/Kconfig @@ -36,17 +36,9 @@ config EXAMPLES_NETTEST_LOOPBACK Perform the test using the local loopback device. In this case, both the client and the server reside on the target. -if EXAMPLES_NETTEST_LOOPBACK +# No server if loopback; No second target if loopback -config EXAMPLES_NETTEST_SERVER_STACKSIZE - int "Server stack size" - default 2048 - -config EXAMPLES_NETTEST_SERVER_PRIORITY - int "Server priority" - default 100 - -endif # EXAMPLES_NETTEST_LOOPBACK +if !EXAMPLES_NETTEST_LOOPBACK config EXAMPLES_NETTEST_SERVER1 bool "Target1 is server" @@ -56,6 +48,51 @@ config EXAMPLES_NETTEST_SERVER1 Select to use the host as the client side of the test. Default: The target is the client side of the test +config EXAMPLES_NETTEST_TARGET2 + bool "Second endpoint is a target" + default n + ---help--- + By default, the host PC is configured as the second endpoint of the + NETTEST. If this option is selected, then the second endpoint + will be built into the FLASH image as well. This means that you + can use two target boards to run the test with no host PC + involvement. + +if EXAMPLES_NETTEST_TARGET2 + +config EXAMPLES_NETTEST_PROGNAME2 + string "Target2 program name" + default "udpserver" if !EXAMPLES_NETTEST_SERVER2 + default "udpclient" if EXAMPLES_NETTEST_SERVER2 + depends on BUILD_KERNEL + ---help--- + This is the name of the Target2 program that will be use when the + NSH ELF program is installed. + +config EXAMPLES_NETTEST_PRIORITY2 + int "Target2 task priority" + default 100 + +config EXAMPLES_NETTEST_STACKSIZE2 + int "Target2 stack size" + default 2048 + +endif # EXAMPLES_NETTEST_TARGET2 + +config EXAMPLES_NETTEST_DAEMON_STACKSIZE + int "Server daemon stack size" + default 2048 + +config EXAMPLES_NETTEST_DEAMON_PRIORITY + int "Server daemon priority" + default 100 + +endif # EXAMPLES_NETTEST_LOOPBACK + +config EXAMPLES_NETTEST_DEVNAME + string "Network device" + default "eth0" + config EXAMPLES_NETTEST_PERFORMANCE bool "Test for Performance" default n @@ -78,6 +115,8 @@ config EXAMPLES_NETTEST_IPv6 endchoice # IP Domain +# No hardware initialization if loopback + config EXAMPLES_NETTEST_INIT bool "Initialize network" default n if NSH_BUILTIN_APPS @@ -114,6 +153,8 @@ config EXAMPLES_NETTEST_NETMASK endif # EXAMPLES_NETTEST_INIT +# No server if loopback + if !EXAMPLES_NETTEST_LOOPBACK config EXAMPLES_NETTEST_SERVERIP @@ -385,9 +426,11 @@ config EXAMPLES_NETTEST_IPv6NETMASK_8 endif # NET_ICMPv6_AUTOCONF endif # EXAMPLES_NETTEST_INIT +# Addresses are well known if loopback is used. + if !EXAMPLES_NETTEST_LOOPBACK || !NET_LOOPBACK -comment "Client IPv6 address" +comment "Server IPv6 address" config EXAMPLES_NETTEST_SERVERIPv6ADDR_1 hex "[0]" diff --git a/examples/nettest/Makefile b/examples/nettest/Makefile index ef65292d1..b082fe532 100644 --- a/examples/nettest/Makefile +++ b/examples/nettest/Makefile @@ -82,12 +82,51 @@ STACKSIZE1 = $(CONFIG_EXAMPLES_NETTEST_STACKSIZE1) # Target 2 +ifeq ($(CONFIG_EXAMPLES_NETTEST_TARGET2),y) + +TARG2_CSRCS = +ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER1),y) +TARG2_CSRCS += nettest_client.c +else +TARG2_CSRCS += nettest_server.c +endif +TARG2_MAINSRC = nettest_target2.c + +TARG2_COBJS = $(TARG2_CCRCS:.c=$(OBJEXT)) +TARG2_MAINOBJ = $(TARG2_MAINSRC:.c=$(OBJEXT)) + # Target 2 Application Info -# Target common +ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER1),y) +CONFIG_EXAMPLES_NETTEST_PROGNAME2 ?= tcpclient +APPNAME2 = tcpclient +else +CONFIG_EXAMPLES_NETTEST_PROGNAME2 ?= tcpserver +APPNAME2 = tcpserver +endif +CONFIG_EXAMPLES_NETTEST_PRIORITY2 ?= 100 +CONFIG_EXAMPLES_NETTEST_STACKSIZE2 ?= 2048 + +PROGNAME2 = $(CONFIG_EXAMPLES_NETTEST_PROGNAME2) +PRIORITY2 = $(CONFIG_EXAMPLES_NETTEST_PRIORITY2) +STACKSIZE2 = $(CONFIG_EXAMPLES_NETTEST_STACKSIZE2) + +endif + +# All targets + +TARG_SRCS = $(TARG1_CRCS) $(TARG1_MAINSRC) $(TARG2_CSRCS) $(TARG2_MAINSRC) $(TARGCMN_CSRCS) +TARG_OBJS = $(TARG1_COBJS) $(TARG2_COBJS) $(TARGCMN_COBJS) ifneq ($(CONFIG_BUILD_KERNEL),y) - TARG_OBJS += $(TARG1_MAINOBJ) + TARG_OBJS += $(TARG1_MAINOBJ) $(TARG2_MAINOBJ) +endif + +ifeq ($(CONFIG_EXAMPLES_NETTEST_TARGET2),y) +MAINNAME1 = nettest1_main +MAINNAME2 = nettest2_main +else +MAINNAME1 = nettest_main endif ifeq ($(CONFIG_WINDOWS_NATIVE),y) @@ -102,7 +141,9 @@ endif # Host +ifneq ($(CONFIG_EXAMPLES_NETTEST_TARGET2),y) ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) + HOSTCFLAGS += -DNETTEST_HOST=1 ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y) HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_SERVER=1 -DCONFIG_EXAMPLES_NETTEST_SERVERIP="$(CONFIG_EXAMPLES_NETTEST_SERVERIP)" @@ -122,6 +163,8 @@ ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) HOSTOBJEXT ?= hobj HOST_OBJS = $(HOST_SRCS:.c=.$(HOSTOBJEXT)) + +endif endif ifeq ($(WINTOOL),y) @@ -142,20 +185,28 @@ all: .built $(HOST_BIN) $(TARG1_COBJS) $(TARG1_MAINOBJ) $(TARGCMN_COBJS) : %$(OBJEXT): %.c $(call COMPILE, $<, $@) +ifneq ($(CONFIG_EXAMPLES_UDP_TARGET2),y) ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) + $(HOST_OBJS): %.$(HOSTOBJEXT): %.c @echo "CC: $<" $(Q) $(HOSTCC) -c $(HOSTCFLAGS) $< -o $@ + +endif endif config.h: $(TOPDIR)/include/nuttx/config.h @echo "CP: $<" $(Q) cp $< $@ +ifneq ($(CONFIG_EXAMPLES_UDP_TARGET2),y) ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) + $(HOST_BIN): config.h $(HOST_OBJS) @echo "LD: $@" $(Q) $(HOSTCC) $(HOSTLDFLAGS) $(HOST_OBJS) -o $@ + +endif endif .built: config.h $(TARG_OBJS) @@ -177,9 +228,17 @@ endif ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat: $(DEPCONFIG) Makefile - $(call REGISTER,$(APPNAME1),$(PRIORITY1),$(STACKSIZE1),$(APPNAME1)_main) + $(call REGISTER,$(APPNAME1),$(PRIORITY1),$(STACKSIZE1),$(MAINNAME1)) +ifeq ($(CONFIG_EXAMPLES_UDP_TARGET2),y) +$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat: $(DEPCONFIG) Makefile + $(call REGISTER,$(APPNAME2),$(PRIORITY2),$(STACKSIZE2),$(MAINNAME2)) + +context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat \ + $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat +else context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat +endif else context: endif @@ -191,9 +250,11 @@ endif depend: .depend clean: +ifneq ($(CONFIG_EXAMPLES_UDP_TARGET2),y) ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y) $(call DELFILE, *.$(HOSTOBJEXT)) $(call DELFILE, $(HOST_BIN)) +endif endif $(call DELFILE, .built) $(call DELFILE, *.dSYM) diff --git a/examples/nettest/nettest_target1.c b/examples/nettest/nettest_target1.c index 784e7e76e..0a5d968dc 100644 --- a/examples/nettest/nettest_target1.c +++ b/examples/nettest/nettest_target1.c @@ -57,8 +57,10 @@ * nettest_main ****************************************************************************/ -#ifdef CONFIG_BUILD_KERNEL +#if defined(CONFIG_BUILD_KERNEL) int main(int argc, FAR char *argv[]) +#elif defined(CONFIG_EXAMPLES_NETTEST_TARGET2) +int nettest1_main(int argc, char *argv[]) #else int nettest_main(int argc, char *argv[]) #endif @@ -83,8 +85,8 @@ int nettest_main(int argc, char *argv[]) #if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) /* Then perform the server side of the test on a child task */ - child = task_create("Nettest Child", CONFIG_EXAMPLES_NETTEST_SERVER_PRIORITY, - CONFIG_EXAMPLES_NETTEST_SERVER_STACKSIZE, server_child, + child = task_create("Nettest Child", CONFIG_EXAMPLES_NETTEST_DAEMON_PRIORITY, + CONFIG_EXAMPLES_NETTEST_DAEMON_STACKSIZE, server_child, NULL); if (child < 0) { diff --git a/examples/nettest/nettest_target2.c b/examples/nettest/nettest_target2.c index 660a424fd..aa246b3c9 100644 --- a/examples/nettest/nettest_target2.c +++ b/examples/nettest/nettest_target2.c @@ -38,7 +38,7 @@ ****************************************************************************/ #include "config.h" - +#include #include "nettest.h" /**************************************************************************** diff --git a/examples/nettest/target_netinit.c b/examples/nettest/target_netinit.c index e5c84518e..78193737b 100644 --- a/examples/nettest/target_netinit.c +++ b/examples/nettest/target_netinit.c @@ -53,6 +53,16 @@ #ifdef CONFIG_EXAMPLES_NETTEST_INIT +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_EXAMPLES_NETTEST_DEVNAME +# define DEVNAME CONFIG_EXAMPLES_NETTEST_DEVNAME +#else +# define DEVNAME "eth0" +#endif + /**************************************************************************** * Private Data ****************************************************************************/ @@ -126,37 +136,37 @@ void nettest_initialize(void) mac[3] = 0xad; mac[4] = 0xbe; mac[5] = 0xef; - netlib_setmacaddr("eth0", mac); + netlib_setmacaddr(DEVNAME, mac); #endif #ifdef CONFIG_EXAMPLES_NETTEST_IPv6 #ifdef CONFIG_NET_ICMPv6_AUTOCONF /* Perform ICMPv6 auto-configuration */ - netlib_icmpv6_autoconfiguration("eth0"); + netlib_icmpv6_autoconfiguration(DEVNAME); #else /* CONFIG_NET_ICMPv6_AUTOCONF */ /* Set up our fixed host address */ - netlib_set_ipv6addr("eth0", + netlib_set_ipv6addr(DEVNAME, (FAR const struct in6_addr *)g_ipv6_hostaddr); /* Set up the default router address */ - netlib_set_dripv6addr("eth0", + netlib_set_dripv6addr(DEVNAME, (FAR const struct in6_addr *)g_ipv6_draddr); /* Setup the subnet mask */ - netlib_set_ipv6netmask("eth0", + netlib_set_ipv6netmask(DEVNAME, (FAR const struct in6_addr *)g_ipv6_netmask); /* New versions of netlib_set_ipvXaddr will not bring the network up, * So ensure the network is really up at this point. */ - netlib_ifup("eth0"); + netlib_ifup(DEVNAME); #endif /* CONFIG_NET_ICMPv6_AUTOCONF */ #else /* CONFIG_EXAMPLES_NETTEST_IPv6 */ @@ -164,17 +174,17 @@ void nettest_initialize(void) /* Set up our host address */ addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_IPADDR); - netlib_set_ipv4addr("eth0", &addr); + netlib_set_ipv4addr(DEVNAME, &addr); /* Set up the default router address */ addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_DRIPADDR); - netlib_set_dripv4addr("eth0", &addr); + netlib_set_dripv4addr(DEVNAME, &addr); /* Setup the subnet mask */ addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_NETMASK); - netlib_set_ipv4netmask("eth0", &addr); + netlib_set_ipv4netmask(DEVNAME, &addr); #endif /* CONFIG_EXAMPLES_NETTEST_IPv6 */ } diff --git a/examples/udp/Kconfig b/examples/udp/Kconfig index 851094d9a..ba81ca0de 100644 --- a/examples/udp/Kconfig +++ b/examples/udp/Kconfig @@ -42,7 +42,7 @@ config EXAMPLES_UDP_TARGET2 By default, the host PC is configured as the second endpoint of the UDP test. If this option is selected, then the second endpoint will be built into the FLASH image as well. This means that you - can use two target boards to run the test with not host PC + can use two target boards to run the test with no host PC involvement. if EXAMPLES_UDP_TARGET2 diff --git a/examples/udp/Makefile b/examples/udp/Makefile index f4a7e2994..902d34d66 100644 --- a/examples/udp/Makefile +++ b/examples/udp/Makefile @@ -77,15 +77,15 @@ STACKSIZE1 = $(CONFIG_EXAMPLES_UDP_STACKSIZE1) ifeq ($(CONFIG_EXAMPLES_UDP_TARGET2),y) -TARG2_CRCS = +TARG2_CSRCS = ifeq ($(CONFIG_EXAMPLES_UDP_SERVER1),y) -TARG2_CRCS += udp_client.c +TARG2_CSRCS += udp_client.c else -TARG2_CRCS += udp_server.c +TARG2_CSRCS += udp_server.c endif TARG2_MAINSRC = udp_target2.c -TARG2_COBJS = $(TARG2_CRCS:.c=$(OBJEXT)) +TARG2_COBJS = $(TARG2_CSRCS:.c=$(OBJEXT)) TARG2_MAINOBJ = $(TARG2_MAINSRC:.c=$(OBJEXT)) ifeq ($(CONFIG_EXAMPLES_UDP_SERVER1),y) @@ -104,7 +104,7 @@ STACKSIZE2 = $(CONFIG_EXAMPLES_UDP_STACKSIZE2) endif -TARG_SRCS = $(TARG1_CRCS) $(TARG1_MAINSRC) $(TARG2_CRCS) $(TARG2_MAINSRC) $(TARGCMN_CSRCS) +TARG_SRCS = $(TARG1_CRCS) $(TARG1_MAINSRC) $(TARG2_CSRCS) $(TARG2_MAINSRC) $(TARGCMN_CSRCS) TARG_OBJS = $(TARG1_COBJS) $(TARG2_COBJS) $(TARGCMN_COBJS) ifneq ($(CONFIG_BUILD_KERNEL),y)