add apps/ dir
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3360 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
commit
94e0282c22
122
Makefile
Normal file
122
Makefile
Normal file
@ -0,0 +1,122 @@
|
||||
############################################################################
|
||||
# apps/Makefile
|
||||
#
|
||||
# Copyright (C) 2011 Uros Platise. All rights reserved.
|
||||
# Author: Uros Platise <uros.platise@isotel.eu>
|
||||
# Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# 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)/Make.defs
|
||||
|
||||
ifeq ($(WINTOOL),y)
|
||||
INCDIROPT = -w
|
||||
endif
|
||||
|
||||
# Application Directories
|
||||
|
||||
BUILTIN_APPS_DIR =
|
||||
BUILTIN_APPS_BUILT =
|
||||
|
||||
ifeq ($(CONFIG_BUILTIN_APPS_NUTTX),y)
|
||||
|
||||
|
||||
# Individual application: HELLO
|
||||
|
||||
ifeq ($(CONFIG_BUILTIN_APPS_HELLO),y)
|
||||
|
||||
BUILTIN_APPS_DIR += hello
|
||||
|
||||
# we use a non-existing .built_always to guarantee that Makefile
|
||||
# always walks into the sub-directories and asks for build
|
||||
BUILTIN_APPS_BUILT += hello/.built_always
|
||||
|
||||
hello/libhello$(LIBEXT):
|
||||
@$(MAKE) -C hello TOPDIR="$(TOPDIR)" libhello$(LIBEXT)
|
||||
|
||||
endif
|
||||
|
||||
# end of application list
|
||||
|
||||
endif
|
||||
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
ASRCS =
|
||||
CSRCS = exec_nuttapp.c
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
BIN = libapps$(LIBEXT)
|
||||
|
||||
VPATH =
|
||||
|
||||
all: $(BIN)
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
$(BUILTIN_APPS_BUILT):
|
||||
@for dir in $(BUILTIN_APPS_DIR) ; do \
|
||||
$(MAKE) -C $$dir TOPDIR="$(TOPDIR)" ; \
|
||||
done
|
||||
|
||||
$(BIN): $(OBJS) $(BUILTIN_APPS_BUILT)
|
||||
@( for obj in $(OBJS) ; do \
|
||||
$(call ARCHIVE, $@, $${obj}); \
|
||||
done ; )
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
@$(MKDEP) $(ROOTDEPPATH) \
|
||||
$(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
@touch $@
|
||||
echo "/* List of application requirements, generated during make depend. */" > exec_nuttapp_list.h
|
||||
echo "/* List of application entry points, generated during make depend. */" > exec_nuttapp_proto.h
|
||||
@for dir in $(BUILTIN_APPS_DIR) ; do \
|
||||
$(MAKE) -C $$dir TOPDIR="$(TOPDIR)" depend ; \
|
||||
done
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
@rm -f $(BIN) *~ .*.swp *.o libapps.a
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
@rm -f Make.dep .depend
|
||||
|
||||
-include Make.dep
|
62
README
Normal file
62
README
Normal file
@ -0,0 +1,62 @@
|
||||
|
||||
Application Folder
|
||||
==================
|
||||
|
||||
This folder provides various applications that can be enabled in the .config
|
||||
file and further provides frame-work to include external user applications
|
||||
from the ../apps directory.
|
||||
|
||||
Application entry points with their requirements are gathered together in
|
||||
this folder, in two files:
|
||||
- exec_nuttapp_proto.h Entry points, prototype function
|
||||
- exec_nuttapp_list.h Application specific information and requirements
|
||||
|
||||
Application information is collected during the make .depend process.
|
||||
|
||||
To execute an application function:
|
||||
exec_nuttapp() is defined in the include/nuttx/nuttapp.h
|
||||
|
||||
Further, builtin applications may be accessed via pseudo file-system found
|
||||
under the nuttx/drivers/sbin directory.
|
||||
|
||||
NuttShell provides transparent method of invoking the command, when the
|
||||
following option is enabled (regardless of sbin pseudo file system):
|
||||
CONFIG_EXAMPLES_NSH_BUILTIN_APPS=y
|
||||
|
||||
To select which application to be included in the build process set your
|
||||
preferences the .config file as:
|
||||
|
||||
To include applications under the nuttx apps directory:
|
||||
CONFIG_BUILTIN_APPS_NUTTX=y/n
|
||||
|
||||
where each application can be controlled as:
|
||||
CONFIG_BUILTIN_APPS_<NAME>=y/n
|
||||
|
||||
To include applications under the user ../apps directory:
|
||||
CONFIG_BUILTIN_APPS_USER=y/n
|
||||
|
||||
When the user defines an option:
|
||||
CONFIG_BUILTIN_APP_START=<application name>
|
||||
|
||||
then after initialization of the NuttX OS it starts this application
|
||||
using the exec_nuttapp() method.
|
||||
|
||||
Application skeleton can be found under the hello sub-directory,
|
||||
which shows how an application can be added to the project. One must
|
||||
define:
|
||||
1. create sub-directory as: appname
|
||||
2. provide entry point: appname_main()
|
||||
3. set the requirements in the file: Makefile, specially the lines:
|
||||
APPNAME = appname
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = 768
|
||||
ASRCS = asm source file list as a.asm b.asm ...
|
||||
CSRCS = C source file list as foo1.c foo2.c ..
|
||||
|
||||
4. add enable/disable option in the top file in this directory as:
|
||||
ifeq CONFIG_BUILTIN_APPS_<NAME>
|
||||
...
|
||||
|
||||
To include user (external) application create an application under
|
||||
../apps directory and steps 1. - 3. The last 4. step is not needed, as,
|
||||
all applications under ../apps becomes a part of the build process.
|
117
exec_nuttapp.c
Normal file
117
exec_nuttapp.c
Normal file
@ -0,0 +1,117 @@
|
||||
/****************************************************************************
|
||||
* drivers/sbin/exec_nuttapp.c
|
||||
*
|
||||
* Copyright (C) 2011 Uros Platise. All rights reserved.
|
||||
* Author: Uros Platise <uros.platise@isotel.eu>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
#include <nuttx/nuttapp.h>
|
||||
#include <sched.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/* Load builtin function prototypes */
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#include "exec_nuttapp_proto.h"
|
||||
|
||||
static const struct nuttapp_s nuttapps[] = {
|
||||
# include "exec_nuttapp_list.h"
|
||||
{.name=NULL}
|
||||
};
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int exec_nuttapp(FAR const char *appname, FAR const char *argv[])
|
||||
{
|
||||
int i, ret = ERROR;
|
||||
|
||||
// Not sure what to do with exports and nexports ... as found in exec
|
||||
// FAR const struct symtab_s *exports, int nexports
|
||||
// so they are ommited in the args list.
|
||||
|
||||
for (i=0; nuttapps[i].name; i++)
|
||||
{
|
||||
if ( !strcmp(nuttapps[i].name, appname) )
|
||||
{
|
||||
#ifndef CONFIG_CUSTOM_STACK
|
||||
ret = task_create(nuttapps[i].name, nuttapps[i].priority,
|
||||
nuttapps[i].stacksize, nuttapps[i].main, &argv[1]);
|
||||
#else
|
||||
ret = task_create(nuttapps[i].name, nuttapps[i].priority, nuttapps[i].main, &argv[1]);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
errno = ENOENT;
|
||||
return ret;
|
||||
}
|
2
exec_nuttapp_list.h
Normal file
2
exec_nuttapp_list.h
Normal file
@ -0,0 +1,2 @@
|
||||
/* List of application requirements, generated during make depend. */
|
||||
{ .name = "hello", .priority = SCHED_PRIORITY_DEFAULT, .stacksize = 768, .main = hello_main },
|
2
exec_nuttapp_proto.h
Normal file
2
exec_nuttapp_proto.h
Normal file
@ -0,0 +1,2 @@
|
||||
/* List of application entry points, generated during make depend. */
|
||||
EXTERN int hello_main(int argc, char *argv[]);
|
103
hello/Makefile
Normal file
103
hello/Makefile
Normal file
@ -0,0 +1,103 @@
|
||||
############################################################################
|
||||
# Makefile
|
||||
#
|
||||
# Copyright (C) 2011 Uros Platise. All rights reserved.
|
||||
# Author: Uros Platise <uros.platise@isotel.eu>
|
||||
# Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# 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)/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)
|
||||
|
||||
BIN = ../libapps$(LIBEXT)
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
|
||||
# Common build
|
||||
|
||||
VPATH =
|
||||
|
||||
all: .built
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
$(BIN): $(OBJS)
|
||||
@( for obj in $(OBJS) ; do \
|
||||
$(call ARCHIVE, $@, $${obj}); \
|
||||
done ; )
|
||||
@touch .built
|
||||
|
||||
.built: $(BIN)
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
@$(MKDEP) $(ROOTDEPPATH) \
|
||||
$(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
@touch $@
|
||||
echo "{ .name = \""$(APPNAME)"\", .priority = "$(PRIORITY)", .stacksize = "$(STACKSIZE)", .main = "$(APPNAME)"_main }," >> ../exec_nuttapp_list.h
|
||||
echo "EXTERN int "$(APPNAME)"_main(int argc, char *argv[]);" >> ../exec_nuttapp_proto.h
|
||||
|
||||
# Register application
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
@rm -f $(BIN) *.o *~ .*.swp .built
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
@rm -f Make.dep .depend
|
||||
|
||||
-include Make.dep
|
47
hello/hello.c
Normal file
47
hello/hello.c
Normal file
@ -0,0 +1,47 @@
|
||||
/****************************************************************************
|
||||
* hello/hello.c
|
||||
*
|
||||
* Copyright (C) 2011 Uros Platise. All rights reserved.
|
||||
* Author: Uros Platise <uros.platise@isotel.eu>
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
|
||||
|
||||
/** Example of a standalone application
|
||||
*/
|
||||
int hello_main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
printf("Hello Builtin Application\nFound argc=%d arguments and are as follows:\n", argc);
|
||||
for (i=0; i<argc; i++) printf("%s\n", argv[i]);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user