This Wiki page describes current and planned features for the NuttX NuttShell (NSH). Think of this page as a roadmap. Most of the features have been implemented and incorporated into NSH; others are just ideas that are being tossed around (noted as NOT implemented). The NSH document will be updated as new features are included.
There currently are be three ways to execute applications from NSH:
The current implementation of NSH allows for the execution of “named” or “builtin” applications. The applications are simply task entry points in the common FLASH image that have names assigned to them. Simply entering that name from the NSH command line will cause the associated application to run.
See the NSH documentation for further details.
NuttShell (NSH) NuttX-6.24 nsh> hello Hello, World!! nsh>
This functionality depends on these configuration settings:
CONFIG_BUILTIN=y: Enables NuttX support for builtin applications, and
CONFIG_NSH_BUILTIN_APPS=y: Enables NSH support for builtin applications
In additional to other configuration needed by NSH.
NuttX supports running applications that reside on a file system as well. The standard interfaces used to do this include:
Execution of applications on a file system is currently supported by Nuttx. This feature is enabled with:
CONFIG_LIBC_EXECFUNCS=y: Enable support for
CONFIG_NSH_FILE_APPS=y: Enable execution of programs in a file system by NSH.
When this feature is enabled, you will be able to do the following:
NuttShell (NSH) NuttX-6.24 nsh> mount -t vfat /dev/mmcsd0 /mnt/sdcard nsh> ls -l /mnt/sdcard /mnt/sdcard: -rw-r--r-- 198 hello nsh> /mnt/sdcard/hello Hello, World!! nsh>
Notice that the absolute path to the
hello program was used. This can be simplified by setting the following in your configuration:
CONFIG_BINFMT_EXEPATH=y: Enable use of the path variable to find executable programs.
Then, the example becomes:
NuttShell (NSH) NuttX-6.24 nsh> mount -t vfat /dev/mmcsd0 /mnt/sdcard nsh> ls -l /mnt/sdcard /mnt/sdcard: -rw-r--r-- 198 hello nsh> set PATH /mnt/sdcard nsh> hello Hello, World!! nsh>
One final simplification: The initial PATH variable can be configured so that the PATH to your executable programs is already defined when NSH starts. This is down with:
This functionality is already in place.
NuttX supports a virtual file system (VFS) that may used to manage namespaces. Linux uses its VFS to manage nearly all named objects (pipes, locks, message queues, etc.). And it is a good policy for NuttX to do this too. NuttX already does this for things like drivers and mountpoints. Why not extend this mechanism to handle named, builtin applications too?
The following configuration options are planned:
CONFIG_BUILTIN=y: Will still be needed to enable NuttX support for builtin applications, and
CONFIG_NSH_BUILTIN_APPS=y: Will still be needed enable to stimulate programs to register themselves as builtin applications.
And in addition:
CONFIG_FS_BINFS=y: Enable the BINFS file system that is used to access builtin applications as files,
CONFIG_LIBC_EXECFUNCS=y: Enable support for
CONFIG_NSH_FILE_APPS=y: Enable execution of programs in a file system by NSH,
CONFIG_BINFMT_EXEPATH=y: Enable the (optional) use of the path variable to find executable programs, and
CONFIG_PATH_INITIAL=”/mnt/sdcard:/bin”: Optional initial value of the PATH variable.
When this feature is enable, will will be able to do this (where myapplication is the name of some, arbitrary “built-in” application):
NuttShell (NSH) NuttX-6.24 nsh> mount -t binfs /bin nsh> ls -l /bin /bin: -rw-r--r-- 0 myapplication nsh> echo $PATH /mnt/sdcard:/bin nsh> myapplication ... and your FLASH based application runs ... nsh>
BINFS, like any file system, could be mounted by an startup script at
But since BINFS may be used in many configurations that don't otherwise need a startup script, perhaps some configurations would be helpful:
CONFIG_NSH_AUTOMOUNT_BINFS=y: Automatically mount the BINFS file system on startup (NOT implemented)
CONFIG_NSH_BINFS_MOUNTPOINT=”/bin”: The BINFS mountpoint (NOT implemented).
Or perhaps a better thing to do would just be to make it easier to add a startup script?
In the longer term, I would like to see an option to move most of the larger NSH commands out of RAM and built them as standalone programs that can reside, for example, on an SD card (NOT implemented).