apps/system/nsh: Move apps/examples/nsh to apps/system/nsh. It has become so entrenched that it is hardly an example these days. May as well formalized it as a system task.
This commit is contained in:
parent
e3e911555a
commit
8de513e36b
@ -995,62 +995,6 @@ examples/nrf24l01_term
|
||||
|
||||
CONFIG_NSH_BUILTIN_APPS - Built as an NSH built-in applications.
|
||||
|
||||
examples/nsh
|
||||
^^^^^^^^^^^^
|
||||
|
||||
Basic Configuration
|
||||
-------------------
|
||||
This directory provides an example of how to configure and use
|
||||
the NuttShell (NSH) application. NSH is a simple shell
|
||||
application. NSH is described in its own README located at
|
||||
apps/nshlib/README.txt. This function is enabled with:
|
||||
|
||||
CONFIG_EXAMPLES_NSH=y
|
||||
|
||||
Applications using this example will need to provide an defconfig
|
||||
file in the configuration directory with instruction to build
|
||||
the NSH library like:
|
||||
|
||||
CONFIG_NSH_LIBRARY=y
|
||||
|
||||
Other Configuration Requirements
|
||||
--------------------------------
|
||||
NOTE: If the NSH serial console is used, then following is also
|
||||
required to build the readline() library:
|
||||
|
||||
CONFIG_SYSTEM_READLINE=y
|
||||
|
||||
And if networking is included:
|
||||
|
||||
CONFIG_NETUTILS_NETLIB=y
|
||||
CONFIG_NETUTILS_DHCPC=y
|
||||
CONFIG_NETDB_DNSCLIENT=y
|
||||
CONFIG_NETUTILS_TFTPC=y
|
||||
CONFIG_NETUTILS_WEBCLIENT=y
|
||||
|
||||
If the Telnet console is enabled, then the defconfig file should
|
||||
also include:
|
||||
|
||||
CONFIG_NETUTILS_TELNETD=y
|
||||
|
||||
Also if the Telnet console is enabled, make sure that you have the
|
||||
following set in the NuttX configuration file or else the performance
|
||||
will be very bad (because there will be only one character per TCP
|
||||
transfer):
|
||||
|
||||
CONFIG_STDIO_BUFFER_SIZE - Some value >= 64
|
||||
CONFIG_STDIO_LINEBUFFER=y
|
||||
|
||||
C++ Support
|
||||
-----------
|
||||
If CONFIG_HAVE_CXX=y and CONFIG_HAVE_CXXINITIALIZE=y, then this NSH
|
||||
example can be configured to initialize C++ constructors when it
|
||||
is started. NSH does not use C++ and, by default, assumes that
|
||||
constructors are initialized elsewhere. However, you can force
|
||||
NSH to initialize constructors by setting:
|
||||
|
||||
CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y
|
||||
|
||||
examples/nx
|
||||
^^^^^^^^^^^
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
config EXAMPLES_NSH
|
||||
config SYSTEM_NSH
|
||||
bool "NuttShell (NSH) example"
|
||||
default n
|
||||
select NSH_LIBRARY
|
||||
@ -11,9 +11,9 @@ config EXAMPLES_NSH
|
||||
---help---
|
||||
Enable the NuttShell (NSH) example
|
||||
|
||||
if EXAMPLES_NSH
|
||||
if SYSTEM_NSH
|
||||
|
||||
config EXAMPLES_NSH_SYMTAB
|
||||
config SYSTEM_NSH_SYMTAB
|
||||
bool "Register symbol table"
|
||||
default n
|
||||
depends on LIBC_EXECFUNCS && LIB_BOARDCTL && !EXECFUNCS_HAVE_SYMTAB
|
||||
@ -38,8 +38,9 @@ config EXAMPLES_NSH_SYMTAB
|
||||
of the necessary symbols in place. Otherwise, you probably do *not*
|
||||
want this option!
|
||||
|
||||
if EXAMPLES_NSH_SYMTAB
|
||||
config EXAMPLES_NSH_SYMTAB_ARRAYNAME
|
||||
if SYSTEM_NSH_SYMTAB
|
||||
|
||||
config SYSTEM_NSH_SYMTAB_ARRAYNAME
|
||||
string "Symbol table used by exec[l|v]"
|
||||
default "g_exports"
|
||||
---help---
|
||||
@ -48,7 +49,7 @@ config EXAMPLES_NSH_SYMTAB_ARRAYNAME
|
||||
code, and (2) the number of symbols in that table. This selection
|
||||
provides the name of that symbol table.
|
||||
|
||||
config EXAMPLES_NSH_SYMTAB_COUNTNAME
|
||||
config SYSTEM_NSH_SYMTAB_COUNTNAME
|
||||
string "Variable holding the number of symbols"
|
||||
default "g_nexports"
|
||||
---help---
|
||||
@ -58,9 +59,9 @@ config EXAMPLES_NSH_SYMTAB_COUNTNAME
|
||||
provides the name of 'int' variable that holds the number of symbol
|
||||
in the table.
|
||||
|
||||
endif # EXAMPLES_NSH_SYMTAB
|
||||
endif # SYSTEM_NSH_SYMTAB
|
||||
|
||||
config EXAMPLES_NSH_PROGNAME
|
||||
config SYSTEM_NSH_PROGNAME
|
||||
string "Program name"
|
||||
default "nsh"
|
||||
depends on BUILD_KERNEL
|
||||
@ -68,7 +69,7 @@ config EXAMPLES_NSH_PROGNAME
|
||||
This is the name of the program that will be use when the NSH ELF
|
||||
program is installed.
|
||||
|
||||
config EXAMPLES_NSH_CXXINITIALIZE
|
||||
config SYSTEM_NSH_CXXINITIALIZE
|
||||
bool "C++ Initialization"
|
||||
default n
|
||||
depends on HAVE_CXX && HAVE_CXXINITIALIZE
|
@ -34,6 +34,6 @@
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_NSH),y)
|
||||
ifeq ($(CONFIG_SYSTEM_NSH),y)
|
||||
CONFIGURED_APPS += examples/nsh
|
||||
endif
|
@ -43,7 +43,7 @@ ASRCS =
|
||||
CSRCS =
|
||||
MAINSRC = nsh_main.c
|
||||
|
||||
CONFIG_EXAMPLES_NSH_PROGNAME ?= nsh$(EXEEXT)
|
||||
PROGNAME = $(CONFIG_EXAMPLES_NSH_PROGNAME)
|
||||
CONFIG_SYSTEM_NSH_PROGNAME ?= nsh$(EXEEXT)
|
||||
PROGNAME = $(CONFIG_SYSTEM_NSH_PROGNAME)
|
||||
|
||||
include $(APPDIR)/Application.mk
|
55
system/nsh/README.txt
Normal file
55
system/nsh/README.txt
Normal file
@ -0,0 +1,55 @@
|
||||
README
|
||||
======
|
||||
|
||||
Basic Configuration
|
||||
-------------------
|
||||
This directory provides an example of how to configure and use
|
||||
the NuttShell (NSH) application. NSH is a simple shell
|
||||
application. NSH is described in its own README located at
|
||||
apps/nshlib/README.txt. This function is enabled with:
|
||||
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
|
||||
Applications using this example will need to provide an defconfig
|
||||
file in the configuration directory with instruction to build
|
||||
the NSH library like:
|
||||
|
||||
CONFIG_NSH_LIBRARY=y
|
||||
|
||||
Other Configuration Requirements
|
||||
--------------------------------
|
||||
NOTE: If the NSH serial console is used, then following is also
|
||||
required to build the readline() library:
|
||||
|
||||
CONFIG_SYSTEM_READLINE=y
|
||||
|
||||
And if networking is included:
|
||||
|
||||
CONFIG_NETUTILS_NETLIB=y
|
||||
CONFIG_NETUTILS_DHCPC=y
|
||||
CONFIG_NETDB_DNSCLIENT=y
|
||||
CONFIG_NETUTILS_TFTPC=y
|
||||
CONFIG_NETUTILS_WEBCLIENT=y
|
||||
|
||||
If the Telnet console is enabled, then the defconfig file should
|
||||
also include:
|
||||
|
||||
CONFIG_NETUTILS_TELNETD=y
|
||||
|
||||
Also if the Telnet console is enabled, make sure that you have the
|
||||
following set in the NuttX configuration file or else the performance
|
||||
will be very bad (because there will be only one character per TCP
|
||||
transfer):
|
||||
|
||||
CONFIG_STDIO_BUFFER_SIZE - Some value >= 64
|
||||
CONFIG_STDIO_LINEBUFFER=y
|
||||
|
||||
C++ Support
|
||||
-----------
|
||||
If CONFIG_HAVE_CXX=y and CONFIG_HAVE_CXXINITIALIZE=y, then this NSH
|
||||
example can be configured to initialize C++ constructors when it
|
||||
is started. NSH does not use C++ and, by default, assumes that
|
||||
constructors are initialized elsewhere. However, you can force
|
||||
NSH to initialize constructors by setting:
|
||||
|
||||
CONFIG_SYSTEM_NSH_CXXINITIALIZE=y
|
@ -74,7 +74,7 @@
|
||||
|
||||
#if !defined(CONFIG_LIBC_EXECFUNCS)
|
||||
# undef HAVE_DUMMY_SYMTAB
|
||||
# undef CONFIG_EXAMPLES_NSH_SYMTAB
|
||||
# undef CONFIG_SYSTEM_NSH_SYMTAB
|
||||
#endif
|
||||
|
||||
/* boardctl() support is also required for application-space symbol table
|
||||
@ -83,7 +83,7 @@
|
||||
|
||||
#if !defined(CONFIG_LIB_BOARDCTL) || !defined(CONFIG_BOARDCTL_APP_SYMTAB)
|
||||
# undef HAVE_DUMMY_SYMTAB
|
||||
# undef CONFIG_EXAMPLES_NSH_SYMTAB
|
||||
# undef CONFIG_SYSTEM_NSH_SYMTAB
|
||||
#endif
|
||||
|
||||
/* If a symbol table is provided by board-specific logic, then we do not
|
||||
@ -92,14 +92,14 @@
|
||||
|
||||
#ifdef CONFIG_EXECFUNCS_HAVE_SYMTAB
|
||||
# undef HAVE_DUMMY_SYMTAB
|
||||
# undef CONFIG_EXAMPLES_NSH_SYMTAB
|
||||
# undef CONFIG_SYSTEM_NSH_SYMTAB
|
||||
#endif
|
||||
|
||||
/* If we are going to use the application-space symbol table, then suppress
|
||||
* the dummy symbol table.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_NSH_SYMTAB)
|
||||
#if defined(CONFIG_SYSTEM_NSH_SYMTAB)
|
||||
# undef HAVE_DUMMY_SYMTAB
|
||||
#endif
|
||||
|
||||
@ -109,7 +109,7 @@
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_FS_BINFS) && !defined(HAVE_DUMMY_SYMTAB) && \
|
||||
!defined(CONFIG_EXAMPLES_NSH_SYMTAB) && \
|
||||
!defined(CONFIG_SYSTEM_NSH_SYMTAB) && \
|
||||
!defined(CONFIG_EXECFUNCS_HAVE_SYMTAB)
|
||||
# warning "Prequisites not met for BINFS symbol table"
|
||||
#endif
|
||||
@ -117,7 +117,7 @@
|
||||
/* C++ initialization requires CXX initializer support */
|
||||
|
||||
#if !defined(CONFIG_HAVE_CXX) || !defined(CONFIG_HAVE_CXXINITIALIZE)
|
||||
# undef CONFIG_EXAMPLES_NSH_CXXINITIALIZE
|
||||
# undef CONFIG_SYSTEM_NSH_CXXINITIALIZE
|
||||
#endif
|
||||
|
||||
/* The NSH telnet console requires networking support (and TCP/IP) */
|
||||
@ -153,10 +153,10 @@
|
||||
|
||||
static const struct symtab_s g_dummy_symtab[1]; /* Wasted memory! */
|
||||
|
||||
#elif defined(CONFIG_EXAMPLES_NSH_SYMTAB)
|
||||
#elif defined(CONFIG_SYSTEM_NSH_SYMTAB)
|
||||
|
||||
extern const struct symtab_s CONFIG_EXAMPLES_NSH_SYMTAB_ARRAYNAME[];
|
||||
extern const int CONFIG_EXAMPLES_NSH_SYMTAB_COUNTNAME;
|
||||
extern const struct symtab_s CONFIG_SYSTEM_NSH_SYMTAB_ARRAYNAME[];
|
||||
extern const int CONFIG_SYSTEM_NSH_SYMTAB_COUNTNAME;
|
||||
|
||||
#endif
|
||||
|
||||
@ -174,28 +174,28 @@ int main(int argc, FAR char *argv[])
|
||||
int nsh_main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
#if defined(HAVE_DUMMY_SYMTAB) || defined (CONFIG_EXAMPLES_NSH_SYMTAB)
|
||||
#if defined(HAVE_DUMMY_SYMTAB) || defined (CONFIG_SYSTEM_NSH_SYMTAB)
|
||||
struct boardioc_symtab_s symdesc;
|
||||
#endif
|
||||
int exitval = 0;
|
||||
int ret;
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE)
|
||||
#if defined(CONFIG_SYSTEM_NSH_CXXINITIALIZE)
|
||||
/* Call all C++ static constructors */
|
||||
|
||||
up_cxxinitialize();
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_DUMMY_SYMTAB) || defined (CONFIG_EXAMPLES_NSH_SYMTAB)
|
||||
#if defined(HAVE_DUMMY_SYMTAB) || defined (CONFIG_SYSTEM_NSH_SYMTAB)
|
||||
#if defined(HAVE_DUMMY_SYMTAB)
|
||||
/* Make sure that we are using our symbol table */
|
||||
|
||||
symdesc.symtab = (FAR struct symtab_s *)g_dummy_symtab; /* Discard 'const' */
|
||||
symdesc.nsymbols = 0;
|
||||
|
||||
#else /* if defined(CONFIG_EXAMPLES_NSH_SYMTAB) */
|
||||
symdesc.symtab = (FAR struct symtab_s *)CONFIG_EXAMPLES_NSH_SYMTAB_ARRAYNAME; /* Discard 'const' */
|
||||
symdesc.nsymbols = CONFIG_EXAMPLES_NSH_SYMTAB_COUNTNAME;
|
||||
#else /* if defined(CONFIG_SYSTEM_NSH_SYMTAB) */
|
||||
symdesc.symtab = (FAR struct symtab_s *)CONFIG_SYSTEM_NSH_SYMTAB_ARRAYNAME; /* Discard 'const' */
|
||||
symdesc.nsymbols = CONFIG_SYSTEM_NSH_SYMTAB_COUNTNAME;
|
||||
#endif
|
||||
|
||||
(void)boardctl(BOARDIOC_APP_SYMTAB, (uintptr_t)&symdesc);
|
@ -17,7 +17,7 @@ if SYSTEM_POPEN
|
||||
|
||||
config SYSTEM_POPEN_SHPATH
|
||||
string "Path to shell command"
|
||||
default "/bin/sh"
|
||||
default "/bin/nsh"
|
||||
depends on BUILD_KERNEL
|
||||
---help---
|
||||
This is the full path to the program in a mounted file system that
|
||||
|
@ -16,7 +16,7 @@ if SYSTEM_SYSTEM
|
||||
|
||||
config SYSTEM_SYSTEM_SHPATH
|
||||
string "Path to shell command"
|
||||
default "/bin/sh"
|
||||
default "/bin/nsh"
|
||||
depends on BUILD_KERNEL
|
||||
---help---
|
||||
This is the full path to the program in a mounted file system that
|
||||
|
Loading…
x
Reference in New Issue
Block a user