Configuration Settings

The availability of the above commands depends upon features that may or may not be enabled in the NuttX configuration file. The following table indicates the dependency of each command on NuttX configuration settings. General configuration settings are discussed in the NuttX Porting Guide. Configuration settings specific to NSH as discussed at the bottom of this document.

Note that in addition to general NuttX configuration settings, each NSH command can be individually disabled via the settings in the rightmost column. All of these settings make the configuration of NSH potentially complex but also allow it to squeeze into very small memory footprints.

Command Dependencies on Configuration Settings

Command

Depends on Configuration

Can Be Disabled with

[

! CONFIG_NSH_DISABLESCRIPT

CONFIG_NSH_DISABLE_TEST

addroute

CONFIG_NET && CONFIG_NET_ROUTE

CONFIG_NSH_DISABLE_ADDROUTE

arp

CONFIG_NET && CONFIG_NET_ARP

CONFIG_NSH_DISABLE_ARP

base64dec

CONFIG_NETUTILS_CODECS && CONFIG_CODECS_BASE64

CONFIG_NSH_DISABLE_BASE64DEC

base64enc

CONFIG_NETUTILS_CODECS && CONFIG_CODECS_BASE64

CONFIG_NSH_DISABLE_BASE64ENC

basename

.

CONFIG_NSH_DISABLE_BASENAME

break

! CONFIG_NSH_DISABLESCRIPT && ! CONFIG_NSH_DISABLE_LOOPS

.

cat

CONFIG_NSH_DISABLE_CAT

.

cd

! CONFIG_DISABLE_ENVIRON

CONFIG_NSH_DISABLE_CD

cmp

CONFIG_NSH_DISABLE_CMP

.

cp

CONFIG_NSH_DISABLE_CP

.

date

CONFIG_NSH_DISABLE_DATE

.

dd

CONFIG_NSH_DISABLE_DD

.

delroute

CONFIG_NET && CONFIG_NET_ROUTE

CONFIG_NSH_DISABLE_DELROUTE

df

! CONFIG_DISABLE_MOUNTPOINT

CONFIG_NSH_DISABLE_DF

dirname

CONFIG_NSH_DISABLE_DIRNAME

.

dmesg

CONFIG_RAMLOG_SYSLOG

CONFIG_NSH_DISABLE_DMESG

echo

CONFIG_NSH_DISABLE_ECHO

.

env

CONFIG_FS_PROCFS && ! CONFIG_DISABLE_ENVIRON &&
! CONFIG_PROCFS_EXCLUDE_ENVIRON

CONFIG_NSH_DISABLE_ENV

exec

CONFIG_NSH_DISABLE_EXEC

.

exit

CONFIG_NSH_DISABLE_EXIT

.

export

CONFIG_NSH_VARS && ! CONFIG_DISABLE_ENVIRON

CONFIG_NSH_DISABLE_EXPORT

free

CONFIG_NSH_DISABLE_FREE

.

get

CONFIG_NET && CONFIG_NET_UDP && MTU >= 584

CONFIG_NSH_DISABLE_GET

help 6

CONFIG_NSH_DISABLE_HELP

.

hexdump

CONFIG_NSH_DISABLE_HEXDUMP

.

ifconfig

CONFIG_NET && CONFIG_FS_PROCFS && ! CONFIG_FS_PROCFS_EXCLUDE_NET

CONFIG_NSH_DISABLE_IFCONFIG

ifdown

CONFIG_NET && CONFIG_FS_PROCFS && ! CONFIG_FS_PROCFS_EXCLUDE_NET

CONFIG_NSH_DISABLE_IFUPDOWN

ifup

CONFIG_NET && CONFIG_FS_PROCFS && ! CONFIG_FS_PROCFS_EXCLUDE_NET

CONFIG_NSH_DISABLE_IFUPDOWN

insmod

CONFIG_MODULE

CONFIG_NSH_DISABLE_MODCMDS

irqinfo

! CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_PROCFS &&
CONFIG_SCHED_IRQMONITOR

.

kill

CONFIG_NSH_DISABLE_KILL

.

losetup

! CONFIG_DISABLE_MOUNTPOINT && CONFIG_DEV_LOOP

CONFIG_NSH_DISABLE_LOSETUP

ln

CONFIG_PSEUDOFS_SOFTLINKS

CONFIG_NSH_DISABLE_LN

ls

CONFIG_NSH_DISABLE_LS

.

lsmod

CONFIG_MODULE && CONFIG_FS_PROCFS &&
! CONFIG_FS_PROCFS_EXCLUDE_MODULE

CONFIG_NSH_DISABLE_MODCMDS

md5

CONFIG_NETUTILS_CODECS && CONFIG_CODECS_HASH_MD5

CONFIG_NSH_DISABLE_MD5

mb,mh,mw

.

CONFIG_NSH_DISABLE_MB,
CONFIG_NSH_DISABLE_MH,
CONFIG_NSH_DISABLE_MW

mkdir

(! CONFIG_DISABLE_MOUNTPOINT || ! CONFIG_DISABLE_PSEUDOFS_OPERATIONS)

CONFIG_NSH_DISABLE_MKDIR

mkfatfs

! CONFIG_DISABLE_MOUNTPOINT && CONFIG_FSUTILS_MKFATFS

CONFIG_NSH_DISABLE_MKFATFS

mkfifo

CONFIG_PIPES && CONFIG_DEV_FIFO_SIZE > 0

CONFIG_NSH_DISABLE_MKFIFO

mkrd

! CONFIG_DISABLE_MOUNTPOINT

CONFIG_NSH_DISABLE_MKRD

mount

! CONFIG_DISABLE_MOUNTPOINT

CONFIG_NSH_DISABLE_MOUNT

mv

! CONFIG_DISABLE_MOUNTPOINT || ! CONFIG_DISABLE_PSEUDOFS_OPERATIONS

CONFIG_NSH_DISABLE_MV

nfsmount

! CONFIG_DISABLE_MOUNTPOINT && CONFIG_NET && CONFIG_NFS

CONFIG_NSH_DISABLE_NFSMOUNT

nslookup

CONFIG_LIBC_NETDB && CONFIG_NETDB_DNSCLIENT

CONFIG_NSH_DISABLE_NSLOOKUP

passwd

! CONFIG_DISABLE_MOUNTPOINT && CONFIG_NSH_LOGIN_PASSWD

CONFIG_NSH_DISABLE_PASSWD

pmconfig

CONFIG_PM

CONFIG_NSH_DISABLE_PMCONFIG

poweroff

CONFIG_BOARDCTL_POWEROFF

CONFIG_NSH_DISABLE_POWEROFF

ps

CONFIG_FS_PROCFS && ! CONFIG_FS_PROCFS_EXCLUDE_PROC

CONFIG_NSH_DISABLE_PS

put

CONFIG_NET && CONFIG_NET_UDP && MTU >= 558 4, 5

CONFIG_NSH_DISABLE_PUT

pwd

! CONFIG_DISABLE_ENVIRON

CONFIG_NSH_DISABLE_PWD

readlink

CONFIG_PSEUDOFS_SOFTLINKS

CONFIG_NSH_DISABLE_READLINK

reboot

CONFIG_BOARD_RESET

CONFIG_NSH_DISABLE_REBOOT

rm

! CONFIG_DISABLE_MOUNTPOINT || ! CONFIG_DISABLE_PSEUDOFS_OPERATIONS

CONFIG_NSH_DISABLE_RM

rmdir

! CONFIG_DISABLE_MOUNTPOINT |! CONFIG_DISABLE_PSEUDOFS_OPERATIONS

CONFIG_NSH_DISABLE_RMDIR

rmmod

CONFIG_MODULE

CONFIG_NSH_DISABLE_MODCMDS

route

CONFIG_FS_PROCFS && CONFIG_FS_PROCFS_EXCLUDE_NET &&
! CONFIG_FS_PROCFS_EXCLUDE_ROUTE && CONFIG_NET_ROUTE &&
! CONFIG_NSH_DISABLE_ROUTE &&
(CONFIG_NET_IPv4 |CONFIG_NET_IPv6)

CONFIG_NSH_DISABLE_ROUTE

rptun

CONFIG_RPTUN

CONFIG_NSH_DISABLE_RPTUN

set

CONFIG_NSH_VARS || ! CONFIG_DISABLE_ENVIRON

CONFIG_NSH_DISABLE_SET

shutdown

CONFIG_BOARDCTL_POWEROFF || CONFIG_BOARD_RESET

CONFIG_NSH_DISABLE_SHUTDOWN

sleep

.

CONFIG_NSH_DISABLE_SLEEP

source

CONFIG_FILE_STREAM && ! CONFIG_NSH_DISABLESCRIPT

CONFIG_NSH_DISABLE_SOURCE

telnetd

CONFIG_NSH_TELNET

CONFIG_NSH_DISABLE_TELNETD

test

! CONFIG_NSH_DISABLESCRIPT

CONFIG_NSH_DISABLE_TEST

time

.

CONFIG_NSH_DISABLE_TIME

truncate

! CONFIG_DISABLE_MOUNTPOINT

CONFIG_NSH_DISABLE_TRUNCATE

umount

! CONFIG_DISABLE_MOUNTPOINT

CONFIG_NSH_DISABLE_UMOUNT

uname

.

CONFIG_NSH_DISABLE_UNAME

unset

CONFIG_NSH_VARS || ! CONFIG_DISABLE_ENVIRON

CONFIG_NSH_DISABLE_UNSET

urldecode

! CONFIG_NETUTILS_CODECS && CONFIG_CODECS_URLCODE

CONFIG_NSH_DISABLE_URLDECODE

urlencode

! CONFIG_NETUTILS_CODECS && CONFIG_CODECS_URLCODE

CONFIG_NSH_DISABLE_URLENCODE

useradd

! CONFIG_DISABLE_MOUNTPOINT && CONFIG_NSH_LOGIN_PASSWD

CONFIG_NSH_DISABLE_USERADD

userdel

! CONFIG_DISABLE_MOUNTPOINT && CONFIG_NSH_LOGIN_PASSWD

CONFIG_NSH_DISABLE_USERDEL

usleep

.

CONFIG_NSH_DISABLE_USLEEP

wget

CONFIG_NET && CONFIG_NET_TCP

CONFIG_NSH_DISABLE_WGET

xd

.

CONFIG_NSH_DISABLE_XD

4(1,2)

Because of hardware padding, the actual required packet size may be larger

5

Special TFTP server start-up options will probably be required to permit creation of files for the correct operation of the put command.

6

Verbose help output can be suppressed by defining CONFIG_NSH_HELP_TERSE. In that case, the help command is still available but will be slightly smaller.

Built-In Command Dependencies on Configuration Settings

All built-in applications require that support for NSH built-in applications has been enabled. This support is enabled with CONFIG_BUILTIN=y and CONFIG_NSH_BUILTIN_APPS=y.

Command

Depends on Configuration

ping

CONFIG_NET && CONFIG_NET_ICMP && CONFIG_NET_ICMP_SOCKET && CONFIG_SYSTEM_PING

ping6

CONFIG_NET && CONFIG_NET_ICMPv6 && CONFIG_NET_ICMPv6_SOCKET && CONFIG_SYSTEM_PING6

NSH-Specific Configuration Settings

The behavior of NSH can be modified with the following settings in the boards/<arch>/<chip>/<board>/defconfig file:

Configuration

Description

CONFIG_NSH_READLINE

Selects the minimal implementation of readline(). This minimal implementation provides on backspace for command line editing. It expects some minimal VT100 command support from the terminal.

CONFIG_NSH_CLE

Selects the more extensive, EMACS-like command line editor. Select this option only if (1) you don’t mind a modest increase in the FLASH footprint, and (2) you work with a terminal that supports extensive VT100 editing commands. Selecting this option will add probably 1.5-2KB to the FLASH footprint.

CONFIG_NSH_BUILTIN_APPS

Support external registered, “builtin” applications that can be executed from the NSH command line (see apps/README.txt for more information). This required CONFIG_BUILTIN to enable NuttX support for “builtin” applications.

CONFIG_NSH_FILEIOSIZE

Size of a static I/O buffer used for file access (ignored if there is no file system). Default is 1024.

CONFIG_NSH_STRERROR

strerror(errno) makes more readable output but strerror() is very large and will not be used unless this setting is y. This setting depends upon the strerror() having been enabled with CONFIG_LIBC_STRERROR.

CONFIG_NSH_LINELEN

The maximum length of one command line and of one output line. Default: 80

CONFIG_NSH_DISABLE_SEMICOLON

By default, you can enter multiple NSH commands on a line with each command separated by a semicolon. You can disable this feature to save a little memory on FLASH challenged platforms. Default: n

CONFIG_NSH_CMDPARMS

If selected, then the output from commands, from file applications, and from NSH built-in commands can be used as arguments to other commands. The entity to be executed is identified by enclosing the command line in back quotes. For example:

set FOO `myprogram $BAR`

will execute the program named myprogram passing it the value of the environment variable BAR. The value of the environment variable FOO is then set output of myprogram on stdout. Because this feature commits significant resources, it is disabled by default. The CONFIG_NSH_CMDPARMS interim output will be retained in a temporary file. Full path to a directory where temporary files can be created is taken from CONFIG_LIBC_TMPDIR and it defaults to /tmp if CONFIG_LIBC_TMPDIR is not set.

CONFIG_NSH_MAXARGUMENTS

The maximum number of NSH command arguments. Default: 6

CONFIG_NSH_ARGCAT

Support concatenation of strings with environment variables or command output. For example:

set FOO XYZ
set BAR 123
set FOOBAR ABC_${FOO}_${BAR}

would set the environment variable FOO to XYZ, BAR to 123 and FOOBAR to ABC_XYZ_123. If CONFIG_NSH_ARGCAT is not selected, then a slightly small FLASH footprint results but then also only simple environment variables like $FOO can be used on the command line.

CONFIG_NSH_VARS

By default, there are no internal NSH variables. NSH will use OS environment variables for all variable storage. If this option, NSH will also support local NSH variables. These variables are, for the most part, transparent and work just like the OS environment variables. The difference is that when you create new tasks, all of environment variables are inherited by the created tasks. NSH local variables are not. If this option is enabled (and CONFIG_DISABLE_ENVIRON is not), then a new command called ‘export’ is enabled. The export command works very must like the set command except that is operates on environment variables. When CONFIG_NSH_VARS is enabled, there are changes in the behavior of certain commands. See following table.

CONFIG_NSH_QUOTE

Enables back-slash quoting of certain characters within the command. This option is useful for the case where an NSH script is used to dynamically generate a new NSH script. In that case, commands must be treated as simple text strings without interpretation of any special characters. Special characters such as $, `, ", and others must be retained intact as part of the test string. This option is currently only available is CONFIG_NSH_ARGCAT is also selected.

CONFIG_NSH_NESTDEPTH

The maximum number of nested if-then[-else]-fi <#conditional>`__ sequences that are permissible. Default: 3

CONFIG_NSH_DISABLESCRIPT

This can be set to y to suppress support for scripting. This setting disables the `sh <#cmdsh>`__, `test <#cmdtest>`__, and `[ <#cmtest>`__ commands and the `if-then[-else]-fi <#conditional>`__ construct. This would only be set on systems where a minimal footprint is a necessity and scripting is not.

CONFIG_NSH_DISABLE_ITEF

If scripting is enabled, then then this option can be selected to suppress support for if-then-else-fi sequences in scripts. This would only be set on systems where some minimal scripting is required but if-then-else-fi is not.

CONFIG_NSH_DISABLE_LOOPS

If scripting is enabled, then then this option can be selected suppress support for while-do-done and until-do-done sequences in scripts. This would only be set on systems where some minimal scripting is required but looping is not.

CONFIG_NSH_DISABLEBG

This can be set to y to suppress support for background commands. This setting disables the `nice <#cmdoverview>`__ command prefix and the `& <#cmdoverview>`__ command suffix. This would only be set on systems where a minimal footprint is a necessity and background command execution is not.

CONFIG_NSH_MMCSDMINOR

If the architecture supports an MMC/SD slot and if the NSH architecture specific logic is present, this option will provide the MMC/SD minor number, i.e., the MMC/SD block driver will be registered as /dev/mmcsdN where N is the minor number. Default is zero.

CONFIG_NSH_ROMFSETC

Mount a ROMFS file system at /etc and provide a startup script at /etc/init.d/rcS. The default startup script will mount a FAT FS RAMDISK at /tmp but the logic is easily extensible.

CONFIG_NSH_CONSOLE

If CONFIG_NSH_CONSOLE is set to y, then a serial console front-end is selected.

Normally, the serial console device is a UART and RS-232 interface. However, if CONFIG_USBDEV is defined, then a USB serial device may, instead, be used if the one of the following are defined:

  • CONFIG_PL2303 and CONFIG_PL2303_CONSOLE. Sets up the Prolifics PL2303 emulation as a console device at /dev/console.

  • CONFIG_CDCACM and CONFIG_CDCACM_CONSOLE. Sets up the CDC/ACM serial device as a console device at /dev/console.

  • CONFIG_NSH_USBCONSOLE. If defined, then an arbitrary USB device may be used to as the NSH console. In this case, CONFIG_NSH_USBCONDEV must be defined to indicate which USB device to use as the console. The advantage of using a device other that /dev/console is that normal debug output can then use /dev/console while NSH uses CONFIG_NSH_USBCONDEV.

    CONFIG_NSH_USBCONDEV. If CONFIG_NSH_USBCONSOLE is set to ‘y’, then CONFIG_NSH_USBCONDEV must also be set to select the USB device used to support the NSH console. This should be set to the quoted name of a readable/write-able USB driver such as: CONFIG_NSH_USBCONDEV="/dev/ttyACM0".

If there are more than one USB slots, then a USB device minor number may also need to be provided:

  • CONFIG_NSH_UBSDEV_MINOR: The minor device number of the USB device. Default: 0

If USB tracing is enabled (CONFIG_USBDEV_TRACE), then NSH will initialize USB tracing as requested by the following. Default: Only USB errors are traced.

  • CONFIG_NSH_USBDEV_TRACEINIT: Show initialization events

  • CONFIG_NSH_USBDEV_TRACECLASS: Show class driver events

  • CONFIG_NSH_USBDEV_TRACETRANSFERS: Show data transfer events

  • CONFIG_NSH_USBDEV_TRACECONTROLLER: Show controller events

  • CONFIG_NSH_USBDEV_TRACEINTERRUPTS: Show interrupt-related events.

CONFIG_NSH_ALTCONDEV and

If CONFIG_NSH_CONSOLE is set CONFIG_NSH_CONDEV to y, then CONFIG_NSH_ALTCONDEV may also be selected to enable use of an alternate character device to support the NSH console. If CONFIG_NSH_ALTCONDEV is selected, then CONFIG_NSH_CONDEV holds the quoted name of a readable/write-able character driver such as: CONFIG_NSH_CONDEV="/dev/ttyS1". This is useful, for example, to separate the NSH command line from the system console when the system console is used to provide debug output. Default: stdin and stdout (probably “/dev/console”)

  • NOTE 1: When any other device other than /dev/console is used for a user interface, (1) linefeeds (\n) will not be expanded to carriage return / linefeeds (\r\n). You will need to configure your terminal program to account for this. And (2) input is not automatically echoed so you will have to turn local echo on.

  • NOTE 2: This option forces the console of all sessions to use NSH_CONDEV. Hence, this option only makes sense for a system that supports only a single session. This option is, in particular, incompatible with Telnet sessions because each Telnet session must use a different console device.

CONFIG_NSH_TELNET

If CONFIG_NSH_TELNET is set to y, then a TELNET server front-end is selected. When this option is provided, you may log into NuttX remotely using telnet in order to access NSH.

CONFIG_NSH_ARCHINIT

Set CONFIG_NSH_ARCHINIT if your board provides architecture specific initialization via the board-specific function board_app_initialize(). This function will be called early in NSH initialization to allow board logic to do such things as configure MMC/SD slots.

CMD

w/o CONFIG_NSH_VARS

w/CONFIG_NSH_VARS

set <a> <b>

Set environment variable <a> to <b>

Set NSH variable <a> to <b> (Unless the NSH variable has been promoted via export, in which case the env ironment variable of the same name is set to <b>).

set

Causes an error.

Lists all NSH variables.

unset <a>

Unsets environment variable <a>

Unsets both environment variable and NSH variable with and name <a>

export <a> <b>

Causes an error,

Unsets NSH variable <a>. Sets environment variable <a> to <b>.

export <a>

Causes an error.

Sets environment variable <a> to the value of NSH variable <a> (or “” if the NSH variable has not been set). Unsets NSH local variable <a>.

env

Lists all environment variables

Lists all environment variables (only)

If Telnet is selected for the NSH console, then we must configure the resources used by the Telnet daemon and by the Telnet clients.

Configuration

Description

CONFIG_NSH_TELNETD_PORT

The telnet daemon will listen on this TCP port number for connections. Default: 23

CONFIG_NSH_TELNETD_DAEMONPRIO

Priority of the Telnet daemon. Default: SCHED_PRIORITY_DEFAULT

CONFIG_NSH_TELNETD_DAEMONSTACKSIZE

Stack size allocated for the Telnet daemon. Default: 2048

CONFIG_NSH_TELNETD_CLIENTPRIO

Priority of the Telnet client. Default: SCHED_PRIORITY_DEFAULT

CONFIG_NSH_TELNETD_CLIENTSTACKSIZE

Stack size allocated for the Telnet client. Default: 2048

One or both of CONFIG_NSH_CONSOLE and CONFIG_NSH_TELNET must be defined. If CONFIG_NSH_TELNET is selected, then there some other configuration settings that apply:

Configuration

Description

CONFIG_NET=y

Of course, networking must be enabled.

CONFIG_NSOCKET_DESCRIPTORS

And, of course, you must allocate some socket descriptors.

CONFIG_NET_TCP=y

TCP/IP support is required for telnet (as well as various other TCP-related configuration settings).

CONFIG_NSH_IOBUFFER_SIZE

Determines the size of the I/O buffer to use for sending/ receiving TELNET commands/responses

CONFIG_NSH_DHCPC

Obtain the IP address via DHCP.

CONFIG_NSH_IPADDR

If CONFIG_NSH_DHCPC is NOT set, then the static IP address must be provided.

CONFIG_NSH_DRIPADDR

Default router IP address

CONFIG_NSH_NETMASK

Network mask

CONFIG_NSH_NOMAC

Set if your Ethernet hardware has no built-in MAC address. If set, a bogus MAC will be assigned.

CONFIG_NSH_MAX_ROUNDTRIP

This is the maximum round trip for a response to a ICMP ECHO request. It is in units of deciseconds. The default is 20 (2 seconds).

If you use DHCPC, then some special configuration network options are required. These include:

Configuration

Description

CONFIG_NET=y

Of course, networking must be enabled.

CONFIG_NSOCKET_DESCRIPTORS

And, of course, you must allocate some socket descriptors.

CONFIG_NET_UDP=y

UDP support is required for DHCP (as well as various other UDP-related configuration settings).

CONFIG_NET_BROADCAST=y

UDP broadcast support is needed.

CONFIG_NET_ETH_PKTSIZE=650 (or larger)

Per RFC2131 (p. 9), the DHCP client must be prepared to receive DHCP messages of up to 576 bytes (excluding Ethernet, IP, or UDP headers and FCS). NOTE: Note that the actual MTU setting will depend upon the specific link protocol. Here Ethernet is indicated.

If CONFIG_NSH_ROMFSETC is selected, then the following additional configuration setting apply:

Configuration

Description

CONFIG_NSH_ARCHROMFS

May be defined to specify an alternative ROMFS image that can be found at boards/<arch>/<chip>/<board>/include/nsh_romfsimg.h.

CONFIG_NSH_ROMFSMOUNTPT

The default mountpoint for the ROMFS volume is "/etc", but that can be changed with this setting. This must be a absolute path beginning with ‘/’ and enclosed in quotes.

CONFIG_NSH_INITSCRIPT

This is the relative path to the startup script within the mountpoint. The default is "init.d/rcS". This is a relative path and must not start with ‘/’ but must be enclosed in quotes.

CONFIG_NSH_ROMFSDEVNO

This is the minor number of the ROMFS block device. The default is ‘0’ corresponding to /dev/ram0.

CONFIG_NSH_ROMFSSECTSIZE

This is the sector size to use with the ROMFS volume. Since the default volume is very small, this defaults to 64 but should be increased if the ROMFS volume were to be become large. Any value selected must be a power of 2.

When the default rcS file used when CONFIG_NSH_ROMFSETC is selected, it will mount a FAT FS under /tmp. The following selections describe that FAT FS.

Configuration

Description

CONFIG_NSH_FATDEVNO

This is the minor number of the FAT FS block device. The default is ‘1’ corresponding to /dev/ram1.

CONFIG_NSH_FATSECTSIZE

This is the sector size use with the FAT FS. Default is 512.