summaryrefslogtreecommitdiff
path: root/apps/examples
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-03-22 00:51:01 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-03-22 00:51:01 +0000
commit0c7804b74dcec7d746e95425157bd6afc1435de6 (patch)
treef1012156c3adfa9214f97d33ca5c8e0fea1402fd /apps/examples
parent68d6dcf76ee0aa13cd6dd0d6f9b07f2d8fdf64d4 (diff)
downloadnuttx-0c7804b74dcec7d746e95425157bd6afc1435de6.tar.gz
nuttx-0c7804b74dcec7d746e95425157bd6afc1435de6.tar.bz2
nuttx-0c7804b74dcec7d746e95425157bd6afc1435de6.zip
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
Diffstat (limited to 'apps/examples')
-rw-r--r--apps/examples/Makefile6
-rw-r--r--apps/examples/README.txt5
-rw-r--r--apps/examples/hello/Makefile18
-rw-r--r--apps/examples/hello/main.c14
-rw-r--r--apps/examples/ostest/Makefile14
-rw-r--r--apps/examples/ostest/main.c30
6 files changed, 68 insertions, 19 deletions
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/<board-name>/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 <spudmonkey@racsa.co.cr>
+# Copyright (C) 2008, 2010-2012 Gregory Nutt. All rights reserved.
+# Author: Gregory Nutt <gnutt@nuttx.org>
#
# 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 <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2008, 2011-2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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;
}