From 0c7804b74dcec7d746e95425157bd6afc1435de6 Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 22 Mar 2012 00:51:01 +0000 Subject: NFS update + make some examples configurable as NSH built-ins git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4501 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 4 ++ apps/examples/Makefile | 6 +++ apps/examples/README.txt | 5 ++ apps/examples/hello/Makefile | 18 +++++-- apps/examples/hello/main.c | 14 ++++-- apps/examples/ostest/Makefile | 14 +++++- apps/examples/ostest/main.c | 30 +++++++---- apps/vsn/Makefile | 6 +-- apps/vsn/hello/Makefile | 114 ------------------------------------------ apps/vsn/hello/README.txt | 5 -- apps/vsn/hello/hello.c | 75 --------------------------- 11 files changed, 75 insertions(+), 216 deletions(-) delete mode 100644 apps/vsn/hello/Makefile delete mode 100644 apps/vsn/hello/README.txt delete mode 100644 apps/vsn/hello/hello.c (limited to 'apps') diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index ae4e5ec54..1fd91b3a2 100755 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -208,3 +208,7 @@ * apps/examples/can: Add conditional compilation so that the test can be configured to only send messages or to only receive messages. This will let the test work in other modes than simple loopback testing. + * apps/examples/hello and apps/examples/ostest: Can now be built as NSH + built-int functions. + * vsn/hello: Removed. The modified apps/examples/hello is enough "Hello, + World!" diff --git a/apps/examples/Makefile b/apps/examples/Makefile index 95ad5c991..4cf2a700d 100644 --- a/apps/examples/Makefile +++ b/apps/examples/Makefile @@ -59,6 +59,9 @@ ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) CNTXTDIRS += adc can cdcacm composite ftpd dhcpd nettest qencoder telnetd endif +ifeq ($(CONFIG_EXAMPLES_HELLO_BUILTIN),y) +CNTXTDIRS += hello +endif ifeq ($(CONFIG_EXAMPLES_HELLOXX_BUILTIN),y) CNTXTDIRS += helloxx endif @@ -80,6 +83,9 @@ endif ifeq ($(CONFIG_EXAMPLES_NXTEXT_BUILTIN),y) CNTXTDIRS += nxtext endif +ifeq ($(CONFIG_EXAMPLES_OSTEST_BUILTIN),y) +CNTXTDIRS += ostest +endif ifeq ($(CONFIG_EXAMPLES_TIFF_BUILTIN),y) CNTXTDIRS += tiff endif diff --git a/apps/examples/README.txt b/apps/examples/README.txt index 54cbec978..b037b9501 100644 --- a/apps/examples/README.txt +++ b/apps/examples/README.txt @@ -384,6 +384,9 @@ examples/hello than examples/null with a single printf statement. Really useful only for bringing up new NuttX architectures. + * CONFIG_EXAMPLES_HELLO_BUILTIN + Build the "Hello, World" example as an NSH built-in application. + examples/helloxx ^^^^^^^^^^^^^^^^ @@ -848,6 +851,8 @@ examples/ostest The behavior of the ostest can be modified with the following settings in the configs//defconfig file: + * CONFIG_EXAMPLES_OSTEST_BUILTIN + Build the OS test example as an NSH built-in application. * CONFIG_EXAMPLES_OSTEST_LOOPS Used to control the number of executions of the test. If undefined, the test executes one time. If defined to be diff --git a/apps/examples/hello/Makefile b/apps/examples/hello/Makefile index 0798c5f90..9c3cda894 100644 --- a/apps/examples/hello/Makefile +++ b/apps/examples/hello/Makefile @@ -1,8 +1,8 @@ ############################################################################ # apps/examples/hello/Makefile # -# Copyright (C) 2008, 2010-2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt +# Copyright (C) 2008, 2010-2012 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 @@ -37,6 +37,12 @@ -include $(TOPDIR)/Make.defs include $(APPDIR)/Make.defs +# Hello, World! built-in application info + +APPNAME = hello +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 2048 + # Hello, World! Example ASRCS = @@ -75,7 +81,13 @@ $(COBJS): %$(OBJEXT): %.c done ; ) @touch .built -context: +.context: +ifeq ($(CONFIG_EXAMPLES_HELLO_BUILTIN),y) + $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) + @touch $@ +endif + +context: .context .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/hello/main.c b/apps/examples/hello/main.c index 308603f33..7934dc34b 100644 --- a/apps/examples/hello/main.c +++ b/apps/examples/hello/main.c @@ -1,8 +1,8 @@ /**************************************************************************** * examples/hello/main.c * - * Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008, 2011-2012 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 @@ -53,10 +53,16 @@ ****************************************************************************/ /**************************************************************************** - * user_start + * user_start/hello_main ****************************************************************************/ -int user_start(int argc, char *argv[]) +#ifdef CONFIG_EXAMPLES_HELLO_BUILTIN +# define MAIN_NAME hello_main +#else +# define MAIN_NAME user_start +#endif + +int MAIN_NAME(int argc, char *argv[]) { printf("Hello, World!!\n"); return 0; diff --git a/apps/examples/ostest/Makefile b/apps/examples/ostest/Makefile index 45eef5ff6..eab1db8b3 100644 --- a/apps/examples/ostest/Makefile +++ b/apps/examples/ostest/Makefile @@ -37,6 +37,12 @@ -include $(TOPDIR)/Make.defs include $(APPDIR)/Make.defs +# ostest built-in application info + +APPNAME = ostest +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 2048 + # NuttX OS Test ASRCS = @@ -119,7 +125,13 @@ $(COBJS): %$(OBJEXT): %.c done ; ) @touch .built -context: +.context: +ifeq ($(CONFIG_EXAMPLES_OSTEST_BUILTIN),y) + $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) + @touch $@ +endif + +context: .context .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/ostest/main.c b/apps/examples/ostest/main.c index f48bca377..7d63c0ff4 100644 --- a/apps/examples/ostest/main.c +++ b/apps/examples/ostest/main.c @@ -458,10 +458,18 @@ static void stdio_test(void) ****************************************************************************/ /**************************************************************************** - * user_start + * user_start/ostest_main ****************************************************************************/ -int user_start(int argc, char *argv[]) +#ifdef CONFIG_EXAMPLES_OSTEST_BUILTIN +# define MAIN_NAME ostest_main +# define MAIN_STRING "ostest_main: " +#else +# define MAIN_NAME user_start +# define MAIN_STRING "user_start: " +#endif + +int MAIN_NAME(int argc, char *argv[]) { int result; @@ -484,19 +492,19 @@ int user_start(int argc, char *argv[]) /* Set up some environment variables */ #ifndef CONFIG_DISABLE_ENVIRON - printf("user_start: putenv(%s)\n", g_putenv_value); + printf(MAIN_STRING "putenv(%s)\n", g_putenv_value); putenv(g_putenv_value); /* Varaible1=BadValue3 */ - printf("user_start: setenv(%s, %s, TRUE)\n", g_var1_name, g_var1_value); + printf(MAIN_STRING "setenv(%s, %s, TRUE)\n", g_var1_name, g_var1_value); setenv(g_var1_name, g_var1_value, TRUE); /* Variable1=GoodValue1 */ - printf("user_start: setenv(%s, %s, FALSE)\n", g_var2_name, g_bad_value1); + printf(MAIN_STRING "setenv(%s, %s, FALSE)\n", g_var2_name, g_bad_value1); setenv(g_var2_name, g_bad_value1, FALSE); /* Variable2=BadValue1 */ - printf("user_start: setenv(%s, %s, TRUE)\n", g_var2_name, g_var2_value); + printf(MAIN_STRING "setenv(%s, %s, TRUE)\n", g_var2_name, g_var2_value); setenv(g_var2_name, g_var2_value, TRUE); /* Variable2=GoodValue2 */ - printf("user_start: setenv(%s, %s, FALSE)\n", g_var3_name, g_var3_name); + printf(MAIN_STRING "setenv(%s, %s, FALSE)\n", g_var3_name, g_var3_name); setenv(g_var3_name, g_var3_value, FALSE); /* Variable3=GoodValue3 */ - printf("user_start: setenv(%s, %s, FALSE)\n", g_var3_name, g_var3_name); + printf(MAIN_STRING "setenv(%s, %s, FALSE)\n", g_var3_name, g_var3_name); setenv(g_var3_name, g_bad_value2, FALSE); /* Variable3=GoodValue3 */ show_environment(true, true, true); #endif @@ -510,13 +518,13 @@ int user_start(int argc, char *argv[]) #endif if (result == ERROR) { - printf("user_start: ERROR Failed to start user_main\n"); + printf(MAIN_STRING "ERROR Failed to start user_main\n"); } else { - printf("user_start: Started user_main at PID=%d\n", result); + printf(MAIN_STRING "Started user_main at PID=%d\n", result); } - printf("user_start: Exitting\n"); + printf(MAIN_STRING "Exitting\n"); return 0; } diff --git a/apps/vsn/Makefile b/apps/vsn/Makefile index 5e9aa843c..21901d96d 100644 --- a/apps/vsn/Makefile +++ b/apps/vsn/Makefile @@ -1,8 +1,8 @@ ############################################################################ # apps/vsn/Makefile # -# Copyright (C) 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt +# Copyright (C) 2011-2012 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 @@ -37,7 +37,7 @@ # Sub-directories -SUBDIRS = hello poweroff ramtron sdcard sysinfo +SUBDIRS = poweroff ramtron sdcard sysinfo all: nothing .PHONY: nothing context depend clean distclean diff --git a/apps/vsn/hello/Makefile b/apps/vsn/hello/Makefile deleted file mode 100644 index 23e8890c2..000000000 --- a/apps/vsn/hello/Makefile +++ /dev/null @@ -1,114 +0,0 @@ -############################################################################ -# Makefile -# -# Copyright (C) 2011 Uros Platise. All rights reserved. -# Author: Uros Platise -# 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. -# -############################################################################ - -# TODO, this makefile should run make under the app dirs, instead of -# sourcing the Make.defs! - --include $(TOPDIR)/.config --include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs - -ifeq ($(WINTOOL),y) -INCDIROPT = -w -endif - -# Hello Application -# TODO: appname can be automatically extracted from the directory name - -APPNAME = hello -PRIORITY = SCHED_PRIORITY_DEFAULT -STACKSIZE = 768 - -ASRCS = -CSRCS = hello.c - -AOBJS = $(ASRCS:.S=$(OBJEXT)) -COBJS = $(CSRCS:.c=$(OBJEXT)) - -SRCS = $(ASRCS) $(CSRCS) -OBJS = $(AOBJS) $(COBJS) - -ifeq ($(WINTOOL),y) - BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" -else - BIN = "$(APPDIR)/libapps$(LIBEXT)" -endif - -ROOTDEPPATH = --dep-path . - -# Common build - -VPATH = - -all: .built -.PHONY: context depend clean distclean - -$(AOBJS): %$(OBJEXT): %.S - $(call ASSEMBLE, $<, $@) - -$(COBJS): %$(OBJEXT): %.c - $(call COMPILE, $<, $@) - -.built: $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $(BIN), $${obj}); \ - done ; ) - @touch .built - -# Register application - -.context: - $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) - @touch $@ - -context: .context - -# Create dependencies - -.depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep - @touch $@ - -depend: .depend - -clean: - @rm -f *.o *~ .*.swp .built - $(call CLEAN) - -distclean: clean - @rm -f .context Make.dep .depend - --include Make.dep diff --git a/apps/vsn/hello/README.txt b/apps/vsn/hello/README.txt deleted file mode 100644 index 531c4d193..000000000 --- a/apps/vsn/hello/README.txt +++ /dev/null @@ -1,5 +0,0 @@ - -This application provides Hello Builtin Application skeleton - - Source: NuttX - Date: 13. March 2011 diff --git a/apps/vsn/hello/hello.c b/apps/vsn/hello/hello.c deleted file mode 100644 index fb94d0ea9..000000000 --- a/apps/vsn/hello/hello.c +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** - * hello/hello.c - * - * Copyright (C) 2011 Uros Platise. All rights reserved. - * Author: Uros Platise - * - * 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 -#include - - -void memtest(void) -{ - char *p; - int i, j; - - for (i=0; i<1000; i++) { - p = malloc(40000); - if (!p) { - printf("No memory\n"); - break; - } - for (j=0; j<40000; j++) p[j] = 0; - free(p); - } -} - - -/** Example of a standalone application - */ -int hello_main(int argc, char *argv[]) -{ - int i; - - printf("Hello Builtin Application\n" - "Found argc=%d arguments and are as follows:\n", argc); - - // note that stdout is bufferred and that fflush() and is called on exit. - fflush(stdout); - - for (i=0; i