diff --git a/examples/README.txt b/examples/README.txt index 4b1a1d751..6a65075e8 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -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 ^^^^^^^^^^^ diff --git a/examples/nsh/.gitignore b/system/nsh/.gitignore similarity index 100% rename from examples/nsh/.gitignore rename to system/nsh/.gitignore diff --git a/examples/nsh/Kconfig b/system/nsh/Kconfig similarity index 90% rename from examples/nsh/Kconfig rename to system/nsh/Kconfig index 92168c9f3..323fc45b4 100644 --- a/examples/nsh/Kconfig +++ b/system/nsh/Kconfig @@ -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 diff --git a/examples/nsh/Make.defs b/system/nsh/Make.defs similarity index 98% rename from examples/nsh/Make.defs rename to system/nsh/Make.defs index 78e4bb213..e1b020e2b 100644 --- a/examples/nsh/Make.defs +++ b/system/nsh/Make.defs @@ -34,6 +34,6 @@ # ############################################################################ -ifeq ($(CONFIG_EXAMPLES_NSH),y) +ifeq ($(CONFIG_SYSTEM_NSH),y) CONFIGURED_APPS += examples/nsh endif diff --git a/examples/nsh/Makefile b/system/nsh/Makefile similarity index 95% rename from examples/nsh/Makefile rename to system/nsh/Makefile index 679babd35..03641aab8 100644 --- a/examples/nsh/Makefile +++ b/system/nsh/Makefile @@ -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 diff --git a/system/nsh/README.txt b/system/nsh/README.txt new file mode 100644 index 000000000..1a49ed8d3 --- /dev/null +++ b/system/nsh/README.txt @@ -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 diff --git a/examples/nsh/nsh_main.c b/system/nsh/nsh_main.c similarity index 90% rename from examples/nsh/nsh_main.c rename to system/nsh/nsh_main.c index c45022019..afcc5ad65 100644 --- a/examples/nsh/nsh_main.c +++ b/system/nsh/nsh_main.c @@ -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); diff --git a/system/popen/Kconfig b/system/popen/Kconfig index 108531979..d709fb79f 100644 --- a/system/popen/Kconfig +++ b/system/popen/Kconfig @@ -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 diff --git a/system/system/Kconfig b/system/system/Kconfig index 45ab7fb6c..9dcfc428f 100644 --- a/system/system/Kconfig +++ b/system/system/Kconfig @@ -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