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 cmdtable 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 cmdbottom 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 Add a Routing Table Entry

CONFIG_NET && CONFIG_NET_ROUTE

CONFIG_NSH_DISABLE_ADDROUTE

arp Access the ARP table

CONFIG_NET && CONFIG_NET_ARP

CONFIG_NSH_DISABLE_ARP

base64dec Base64 Decode

CONFIG_NETUTILS_CODECS && CONFIG_CODECS_BASE64

CONFIG_NSH_DISABLE_BASE64DEC

base64enc Base64 Encode

CONFIG_NETUTILS_CODECS && CONFIG_CODECS_BASE64

CONFIG_NSH_DISABLE_BASE64ENC

basename Extract Base File/Directory Name

.

CONFIG_NSH_DISABLE_BASENAME

break Terminate a Loop

! CONFIG_NSH_DISABLESCRIPT && ! CONFIG_NSH_DISABLE_LOOPS

.

cat Concatenate Files

CONFIG_NSH_DISABLE_CAT

.

cd Change Current Working Directory

! CONFIG_DISABLE_ENVIRON

CONFIG_NSH_DISABLE_CD

cmp Compare Files

CONFIG_NSH_DISABLE_CMP

.

cp Copy Files

CONFIG_NSH_DISABLE_CP

.

date Show or set the date and time

CONFIG_NSH_DISABLE_DATE

.

dd Copy and Convert Files

CONFIG_NSH_DISABLE_DD

.

delroute Delete a Routing Table Entry

CONFIG_NET && CONFIG_NET_ROUTE

CONFIG_NSH_DISABLE_DELROUTE

df Show Volume Status

! CONFIG_DISABLE_MOUNTPOINT

CONFIG_NSH_DISABLE_DF

dirname Extract Path to a File/Directory

CONFIG_NSH_DISABLE_DIRNAME

.

dmesg Dump Buffered SYSLOG Output

CONFIG_RAMLOG_SYSLOG

CONFIG_NSH_DISABLE_DMESG

echo Echo Strings and Variables

CONFIG_NSH_DISABLE_ECHO

.

env Show Environment Variables

CONFIG_FS_PROCFS && ! CONFIG_DISABLE_ENVIRON &&
! CONFIG_PROCFS_EXCLUDE_ENVIRON

CONFIG_NSH_DISABLE_ENV

exec Execute User Code

CONFIG_NSH_DISABLE_EXEC

.

exit Exit NSH

CONFIG_NSH_DISABLE_EXIT

.

export Set an Environment Variable

CONFIG_NSH_VARS && ! CONFIG_DISABLE_ENVIRON

CONFIG_NSH_DISABLE_EXPORT

free Show Memory Manager Status

CONFIG_NSH_DISABLE_FREE

.

get Get File Via TFTP

CONFIG_NET && CONFIG_NET_UDP && MTU >= 58[4]

CONFIG_NSH_DISABLE_GET

help Show Usage Command Usage [6]

CONFIG_NSH_DISABLE_HELP

.

hexdump Hexadecimal Dump of File or Device

CONFIG_NSH_DISABLE_HEXDUMP

.

ifconfig Manage Network Configuration

CONFIG_NET && CONFIG_FS_PROCFS && ! CONFIG_FS_PROCFS_EXCLUDE_NET

CONFIG_NSH_DISABLE_IFCONFIG

ifdown Take a network down

CONFIG_NET && CONFIG_FS_PROCFS && ! CONFIG_FS_PROCFS_EXCLUDE_NET

CONFIG_NSH_DISABLE_IFUPDOWN

ifup Bring a network up

CONFIG_NET && CONFIG_FS_PROCFS && ! CONFIG_FS_PROCFS_EXCLUDE_NET

CONFIG_NSH_DISABLE_IFUPDOWN

insmod Install an OS module

CONFIG_MODULE

CONFIG_NSH_DISABLE_MODCMDS

irqinfo Show Interrupt Status

! CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_PROCFS &&
CONFIG_SCHED_IRQMONITOR

.

kill Send a signal to a task

CONFIG_NSH_DISABLE_KILL

.

losetup Setup/teardown the Loop Device

! CONFIG_DISABLE_MOUNTPOINT && CONFIG_DEV_LOOP

CONFIG_NSH_DISABLE_LOSETUP

ln Link to a File or Directory

CONFIG_PSEUDOFS_SOFTLINKS

CONFIG_NSH_DISABLE_LN

ls List Directory Contents

CONFIG_NSH_DISABLE_LS

.

lsmod Show information about installed OS modules

CONFIG_MODULE && CONFIG_FS_PROCFS &&
! CONFIG_FS_PROCFS_EXCLUDE_MODULE

CONFIG_NSH_DISABLE_MODCMDS

md5 Calculate MD5

CONFIG_NETUTILS_CODECS && CONFIG_CODECS_HASH_MD5

CONFIG_NSH_DISABLE_MD5

mb, mh, and mw Access Memory

.

CONFIG_NSH_DISABLE_MB,
CONFIG_NSH_DISABLE_MH,
CONFIG_NSH_DISABLE_MW

mkdir Create a Directory

(! CONFIG_DISABLE_MOUNTPOINT || ! CONFIG_DISABLE_PSEUDOFS_OPERATIONS)

CONFIG_NSH_DISABLE_MKDIR

mkfatfs Create a FAT File System

! CONFIG_DISABLE_MOUNTPOINT && CONFIG_FSUTILS_MKFATFS

CONFIG_NSH_DISABLE_MKFATFS

mkfifo Create a FIFO

CONFIG_PIPES && CONFIG_DEV_FIFO_SIZE > 0

CONFIG_NSH_DISABLE_MKFIFO

mkrd Create a RAMDISK

! CONFIG_DISABLE_MOUNTPOINT

CONFIG_NSH_DISABLE_MKRD

mount Mount a File System

! CONFIG_DISABLE_MOUNTPOINT

CONFIG_NSH_DISABLE_MOUNT

mv Rename a File

! CONFIG_DISABLE_MOUNTPOINT || ! CONFIG_DISABLE_PSEUDOFS_OPERATIONS

CONFIG_NSH_DISABLE_MV

nfsmount Mount an NFS file system

! CONFIG_DISABLE_MOUNTPOINT && CONFIG_NET && CONFIG_NFS

CONFIG_NSH_DISABLE_NFSMOUNT

nslookup Lookup a network address

CONFIG_LIBC_NETDB && CONFIG_NETDB_DNSCLIENT

CONFIG_NSH_DISABLE_NSLOOKUP

passwd Change a User’s Password

! CONFIG_DISABLE_MOUNTPOINT && CONFIG_NSH_LOGIN_PASSWD

CONFIG_NSH_DISABLE_PASSWD

pmconfig Manage Power Management Subsystem

CONFIG_PM

CONFIG_NSH_DISABLE_PMCONFIG

poweroff Shut the system down

CONFIG_BOARDCTL_POWEROFF

CONFIG_NSH_DISABLE_POWEROFF

ps Show Current Tasks and Threads

CONFIG_FS_PROCFS && ! CONFIG_FS_PROCFS_EXCLUDE_PROC

CONFIG_NSH_DISABLE_PS

put Send File Via TFTP

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

CONFIG_NSH_DISABLE_PUT

pwd Show Current Working Directory

! CONFIG_DISABLE_ENVIRON

CONFIG_NSH_DISABLE_PWD

readlink Show target of a link

CONFIG_PSEUDOFS_SOFTLINKS

CONFIG_NSH_DISABLE_READLINK

reboot Reboot the system

CONFIG_BOARD_RESET

CONFIG_NSH_DISABLE_REBOOT

rm Remove a File

! CONFIG_DISABLE_MOUNTPOINT || ! CONFIG_DISABLE_PSEUDOFS_OPERATIONS

CONFIG_NSH_DISABLE_RM

rmdir Remove a Directory

! CONFIG_DISABLE_MOUNTPOINT |! CONFIG_DISABLE_PSEUDOFS_OPERATIONS

CONFIG_NSH_DISABLE_RMDIR

rmmod Remove on OS Module

CONFIG_MODULE

CONFIG_NSH_DISABLE_MODCMDS

route Show routing table

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 Start/Stop the OpenAMP RPC Tunnel

CONFIG_RPTUN

CONFIG_NSH_DISABLE_RPTUN

set Set a Variable

CONFIG_NSH_VARS || ! CONFIG_DISABLE_ENVIRON

CONFIG_NSH_DISABLE_SET

shutdown Shut the system down

CONFIG_BOARDCTL_POWEROFF || CONFIG_BOARD_RESET

CONFIG_NSH_DISABLE_SHUTDOWN

sleep Wait for Seconds

.

CONFIG_NSH_DISABLE_SLEEP

cmdsource

CONFIG_FILE_STREAM && ! CONFIG_NSH_DISABLESCRIPT

CONFIG_NSH_DISABLE_SOURCE

telnetd Time Start the Telnet Daemon

CONFIG_NSH_TELNET && CONFIG_SYSTEM_TELNETD

test Evaluate Expression

! CONFIG_NSH_DISABLESCRIPT

CONFIG_NSH_DISABLE_TEST

time Time execution of another command

.

CONFIG_NSH_DISABLE_TIME

truncate Set the Size of a File

! CONFIG_DISABLE_MOUNTPOINT

CONFIG_NSH_DISABLE_TRUNCATE

umount Unmount a File System

! CONFIG_DISABLE_MOUNTPOINT

CONFIG_NSH_DISABLE_UMOUNT

uname Print system information

.

CONFIG_NSH_DISABLE_UNAME

unset Unset an Environment Variable

CONFIG_NSH_VARS || ! CONFIG_DISABLE_ENVIRON

CONFIG_NSH_DISABLE_UNSET

urldecode URL Decode

! CONFIG_NETUTILS_CODECS && CONFIG_CODECS_URLCODE

CONFIG_NSH_DISABLE_URLDECODE

urlencode URL Encode

! CONFIG_NETUTILS_CODECS && CONFIG_CODECS_URLCODE

CONFIG_NSH_DISABLE_URLENCODE

useradd Add a New User

! CONFIG_DISABLE_MOUNTPOINT && CONFIG_NSH_LOGIN_PASSWD

CONFIG_NSH_DISABLE_USERADD

userdel Delete a user

! CONFIG_DISABLE_MOUNTPOINT && CONFIG_NSH_LOGIN_PASSWD

CONFIG_NSH_DISABLE_USERDEL

usleep Wait for Microseconds

.

CONFIG_NSH_DISABLE_USLEEP

wget Get File Via HTTP

CONFIG_NET && CONFIG_NET_TCP

CONFIG_NSH_DISABLE_WGET

xd Hexadecimal Dump of Memory

.

CONFIG_NSH_DISABLE_XD

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 cmdtable.

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_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_SYSTEM_TELNETD_PORT

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

CONFIG_SYSTEM_TELNETD_PRIORITY

Priority of the Telnet daemon. Default: SCHED_PRIORITY_DEFAULT

CONFIG_SYSTEM_TELNETD_STACKSIZE

Stack size allocated for the Telnet daemon. Default: 2048

CONFIG_SYSTEM_TELNETD_SESSION_PRIORITY

Priority of the Telnet client. Default: SCHED_PRIORITY_DEFAULT

CONFIG_SYSTEM_TELNETD_SESSION_STACKSIZE

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_NET_TCP=y

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

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_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_ETC_ROMFS is selected, then the following additional configuration setting apply:

Configuration

Description

CONFIG_NSH_SYSINITSCRIPT

This is the relative path to the system init script within the mountpoint. The default is "init.d/rc.sysinit". This is a relative path and must not start with ‘/’ but must be 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.

Common Problems

Problem:

The function 'readline' is undefined.

Usual Cause:

  • The following is missing from your defconfig file:

    CONFIG_SYSTEM_READLINE=y