| <html> |
| <head> |
| <title>NuttShell</title> |
| </head> |
| <body background="backgd.gif"> |
| <hr><hr> |
| <table width ="100%"> |
| <tr align="center" bgcolor="#e4e4e4"> |
| <td> |
| <h1><big><font color="#3c34ec"><i>NuttShell (NSH)</i></font></big></h1> |
| <p>Last Updated: July 06, 2010</p> |
| </td> |
| </tr> |
| </table> |
| <hr><hr> |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <h1>Table of Contents</h1> |
| </td> |
| </tr> |
| </table> |
| |
| <center><table width ="80%"> |
| <tr> |
| <td> |
| <table> |
| <tr> |
| <td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td> |
| <td> |
| <a href="#overview">1.0 Overview</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#frontend">1.1 Console/NSH Front End</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdoverview">1.2 Command Overview</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#conditional">1.3 Conditional Command Execution</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#builtinvars">1.4 Built-In Variables</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#currentwd">1.5 Current Working Directory</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#environvars">1.6 Environment Variables</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#startupscript">1.7 NSH Start-Up Script</a> |
| </td> |
| </tr> |
| |
| <tr> |
| <td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td> |
| <td> |
| <a href="#commands">2.0 Commands</a>. |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdtest">2.1 Evaluate Expression (test)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdcat">2.2 Concatenate Files (cat)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdcd">2.3 Change Current Working Directory (cd)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdcp">2.4 Copy Files (cp)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmddd">2.5 Copy and Convert Files (dd)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdecho">2.6 Echo Strings and Variables (echo)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdexec">2.7 Execute User Code (exec)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdget">2.8 Get File Via TFTP (get)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdexit">2.9 Exit NSH (exit)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdhelp">2.10 Show Usage Command Usage (help)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdifconfig">2.11 Show Network Configuration (ifconfig)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdlosetup">2.12 Setup/teardown the Loop Device (losetup)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdls">2.13 List Directory Contents (ls)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdmbhw">2.14 Access Memory (mb, mh, and mw)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdmem">2.15 Show Memory Manager Status (mem)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdps">2.16 Show Current Tasks and Threads (ps)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdmkdir">2.17 Create a Directory (mkdir)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdmkfatfs">2.18 Create a FAT Filesystem (mkfatfs)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdmkfifo">2.19 Create a FIFO (mkfifo)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdmkrd">2.20 Create a RAMDISK (mkrd)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdmount">2.21 Mount a File System (mount)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdping">2.22 Check Network Peer (ping)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdput">2.23 Send File Via TFTP (put)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdpwd">2.24 Show Current Working Directory (pwd)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdrm">2.25 Remove a File (rm)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdrmdir">2.26 Remove a Directory (rmdir)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdset">2.27 Set an Environment Variable (set)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdsh">2.28 Execute an NSH Script (sh)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdsleep">2.29 Wait for Seconds (sleep)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdunmount">2.30 Unmount a File System (umount)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdunset">2.31 Unset an Environment Variable (unset)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdusleep">2.32 Wait for Microseconds (usleep)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdwget">2.33 Get File Via HTTP (wget)</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmdxd">2.34 Hexadecimal Dump (xd)</a> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td> |
| <td> |
| <a href="#configuration">3.0 Configuration Settings</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#cmddependencies">3.1 Command Dependencies on Configuration Settings</a> |
| </td> |
| </tr> |
| <tr> |
| <td><br></td> |
| <td> |
| <a href="#nshconfiguration">3.2 NSH-Specific Configuration Settings</a> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td> |
| <td> |
| <a href="#index">Index</a> |
| </td> |
| </table> |
| </td> |
| </tr> |
| </table></center> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="overview"><h1>1.0 Overview</h1></a> |
| </td> |
| </tr> |
| </table> |
| |
| <p> |
| The <code>examples/nsh</code> sub-directory contains the NuttShell (NSH). |
| NSH is a simple shell application for NuttX. |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="frontend"><h2>1.1 Console/NSH Front End</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <p> |
| Using settings in the configuration file, NSH may be configured to |
| use either the serial stdin/out or a telnet connection as the console |
| or BOTH. When NSH is started, you will see the following welcome on |
| either console: |
| <ul><pre> |
| NuttShell (NSH) |
| nsh> |
| </pre></ul> |
| <code>nsh></code> is the NSH prompt and indicates that you may enter a command |
| from the console. |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdoverview"><h2>1.2 Command Overview</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <p> |
| <b>Simple, Re-directed, and Background Commands</b>. |
| The NuttShell (NSH) is a simple shell application. |
| NSH supports the following commands forms: |
| </p> |
| <ul><table> |
| <tr> |
| <td>Simple command:</td> |
| <td><code><cmd></code></td> |
| </tr> |
| <tr> |
| <td>Command with re-directed output:</td> |
| <td><code> |
| <cmd> > <file><br> |
| <cmd> >> <file> |
| </code></td> |
| </tr> |
| <tr> |
| <td>Background command:</td> |
| <td><code><cmd> &</code></td> |
| </tr> |
| <tr> |
| <td>Re-directed background command:</td> |
| <td><code> |
| <cmd> > <file> &<br> |
| <cmd> >> <file> & |
| </code></td> |
| </tr> |
| </table></ul> |
| <p>Where:</p> |
| <ul><table> |
| <tr> |
| <td><code><cmd></code></td> |
| <td> |
| is any one of the simple commands listed later. |
| </td> |
| </tr> |
| <tr> |
| <td><code><file></code></td> |
| <td> |
| is the full or relative path to any writable object |
| in the filesystem name space (file or character driver). |
| Such objects will be referred to simply as files throughout |
| this document. |
| </td> |
| </tr> |
| </table></ul> |
| <p> |
| <b><big><code>nice</code></big>'d Background Commands</b> |
| NSH executes at the mid-priority (128). Backgrounded commands can |
| be made to execute at higher or lower priorities using <code>nice</code>: |
| </p> |
| <ul><code> |
| [nice [-d <niceness>>]] <cmd> [> <file>|>> <file>] [&] |
| </code></ul> |
| <p> |
| Where <code><niceness></code> is any value between -20 and 19 where lower |
| (more negative values) correspond to higher priorities. |
| The default niceness is 10. |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="conditional"><h2>1.3 Conditional Command Execution</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <p> |
| An <code>if-then[-else]-fi</code> construct is also supported in order to |
| support conditional execution of commands. This works from the |
| command line but is primarily intended for use within NSH scripts |
| (see the <a href="#cmdsh"><code>sh</code></a> commnd). The syntax is as follows: |
| </p> |
| <ul><pre> |
| if <cmd> |
| then |
| [sequence of <cmd>] |
| else |
| [sequence of <cmd>] |
| fi |
| </pre></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="builtinvars"><h2>1.4 Built-In Variables</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <ul><table> |
| <tr> |
| <td valign="top"><b><code>$?</code></b></td> |
| <td> |
| The result of the last simple command execution. |
| On backgrounded commands, this variable holds only the result of spawning the background command. |
| </td> |
| </tr> |
| </table></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="currentwd"><h2>1.5 Current Working Directory</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <p> |
| <b><code>cd</code> and <code>pwd</code></b>. |
| All path arguments to commands may be either an absolute path or a |
| path relative to the current working directory. The current working |
| directory is set using the <a href="#cmdcd"><code>cd</code></a> command and can be queried either |
| by using the <a href="#cmdpwd"><code>pwd</code></a> command or by |
| using the <a href="#cmdecho"><code>echo</code></a> <a href="#environvars"><code>$PWD</code></a> |
| command. |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="environvars"><h2>1.6 Environment Variables</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <p> |
| <b>Environment Variables:</b> |
| </p> |
| <ul><table> |
| <tr> |
| <td><b><code>PWD</code></b></td><td>The current working directory</td> |
| </tr> |
| <tr> |
| <td><b><code>OLDPWD</code></b></td><td>The previous working directory</td> |
| </tr> |
| </table></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="startupscript"><h2>1.7 NSH Start-Up Scrip</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <p> |
| <b>NSH Start-Up Script</b>. |
| NSH supports options to provide a start up script for NSH. In general |
| this capability is enabled with <code>CONFIG_EXAMPLES_NSH_ROMFSETC</code>, but has |
| several other related configuration options as described with the |
| <a href="#nshconfiguration">NSH-specific configuration settings</a>. |
| This capability also depends on: |
| <ul> |
| <li><code>CONFIG_DISABLE_MOUNTPOINT</code> not set |
| <li><code>CONFIG_NFILE_DESCRIPTORS</code> < 4 |
| <li><code>CONFIG_FS_ROMFS</code> enabled |
| </ul> |
| </p> |
| |
| <p> |
| <b>Default Start-Up Behavior</b>. |
| The implementation that is provided is intended to provide great flexibility |
| for the use of Start-Up files. This paragraph will discuss the general |
| behavior when all of the configuration options are set to the default |
| values. |
| </p> |
| <p> |
| In this default case, enabling <code>CONFIG_EXAMPLES_NSH_ROMFSETC</code> will cause |
| NSH to behave as follows at NSH startup time: |
| <ul> |
| <li> |
| NSH will create a read-only RAM disk (a ROM disk), containing a tiny |
| ROMFS filesystem containing the following: |
| <ul><pre> |
| `--init.d/ |
| `-- rcS |
| </pre></ul> |
| Where rcS is the NSH start-up script. |
| </li> |
| <li> |
| NSH will then mount the ROMFS filesystem at <code>/etc</code>, resulting in: |
| <ul><pre> |
| |--dev/ |
| | `-- ram0 |
| `--etc/ |
| `--init.d/ |
| `-- rcS |
| </pre></ul> |
| </li> |
| <li> |
| By default, the contents of rcS script are: |
| <ul><pre> |
| # Create a RAMDISK and mount it at XXXRDMOUNTPOUNTXXX |
| |
| mkrd -m 1 -s 512 1024 |
| mkfatfs /dev/ram1 |
| mount -t vfat /dev/ram1 /tmp |
| </pre></ul> |
| </li> |
| <li> |
| NSH will execute the script at <code>/etc/init.d/rcS</code> at start-up (before the |
| first NSH prompt. After execution of the script, the root FS will look |
| like: |
| <ul><pre> |
| |--dev/ |
| | |-- ram0 |
| | `-- ram1 |
| |--etc/ |
| | `--init.d/ |
| | `-- rcS |
| `--tmp/ |
| </pre></ul> |
| </li> |
| </ul> |
| </p> |
| <p> |
| <b>Modifying the ROMFS Image</b>. |
| The contents of the <code>/etc</code> directory are retained in the file |
| <code>examples/nsh/nsh_romfsimg.h</code>. In order to modify the start-up |
| behavior, there are three things to study: |
| <ol> |
| <li> |
| <b>Configuration Options.</b> |
| The additional <code>CONFIG_EXAMPLES_NSH_ROMFSETC</code> configuration options |
| discussed with the other <a href="#nshconfiguration">NSH-specific configuration settings</a>. |
| </li> |
| <li> |
| <p> |
| <b><code>mkromfsimg.sh</code> Script</b>. |
| The script <code>examples/nsh/mkromfsimg.sh</code> creates <code>nsh_romfsimg.h</code>. |
| It is not automatically executed. If you want to change the |
| configuration settings associated with creating and mounting |
| the <code>/tmp</code> directory, then it will be necessary to re-generate |
| this header file using the <code>mkromfsimg.sh</code> script. |
| </p> |
| <p> |
| The behavior of this script depends upon three things: |
| <ul> |
| <li>The configuration settings then installed configuration. |
| <li>The <code>genromfs<code> tool (available from <a href="http://romfs.sourceforge.net">http://romfs.sourceforge.net</a>). |
| <li>The file <code>examples/nsh/rcS.template</code>. |
| </ul> |
| </p> |
| </li> |
| <li> |
| <b><code>rcS.template</code></b>. |
| The file <code>examples/nsh/rcS.template</code> contains the general form |
| of the <code>rcS</code> file; configurated values are plugged into this |
| template file to produce the final <code>rcS</code> file. |
| </li> |
| </ol> |
| </p> |
| <p> |
| All of the startup-behavior is contained in <code>rcS.template</code>. The |
| role of <code>mkromfsimg.sh</code> is to (1) apply the specific configuration |
| settings to <code>rcS.template</code> to create the final <code>rcS</code>, and (2) to |
| generate the header file <code>nsh_romfsimg.h</code> containg the ROMFS |
| file system image. |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="commands"><h1>2.0 Commands</h1></a> |
| </td> |
| </tr> |
| </table> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdtest"><h2>2.1 Evaluate Expression (test)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| [ <expression> ] |
| test <expression> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| These are two alternative forms of the same command. They support |
| evaluation of a boolean expression which sets <a href="#builtinvars"><code>$?</code></a>. |
| This command is used most frequently as the conditional command following the |
| <code>if</code> in the <a href="#conditional"><code>if-then[-else]-fi</code></a> construct. |
| </p> |
| <p><b>Expression Syntax:</b></p> |
| <ul> |
| <p> |
| expression = simple-expression | !expression | expression -o expression | expression -a expression |
| </p> |
| <p> |
| simple-expression = unary-expression | binary-expression |
| </p> |
| <p> |
| unary-expression = string-unary | file-unary |
| </p> |
| <p> |
| string-unary = -n string | -z string |
| </p> |
| <p> |
| file-unary = -b file | -c file | -d file | -e file | -f file | -r file | -s file | -w file |
| </p> |
| <p> |
| binary-expression = string-binary | numeric-binary |
| </p> |
| <p> |
| string-binary = string = string | string == string | string != string |
| </p> |
| <p> |
| numeric-binary = integer -eq integer | integer -ge integer | integer -gt integer | integer -le integer | |
| integer -lt integer | integer -ne integer |
| </p> |
| </ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdcat"><h2>2.2 Concatenate Files (cat)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| cat <code><path></code> [<code><path></code> [<code><path></code> ...]] |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| This command copies and concatentates all of the files at <code><path></code> |
| to the console (or to another file if the output is redirected). |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdcd"><h2>2.3 Change Current Working Directory (cd)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| cd [<dir-path>|-|~|..] |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Changes the current working directory (<code>PWD</code>). Also sets the |
| previous working directory environment variable (<code>OLDPWD</code>). |
| <p> |
| <p><b>Forms:</b></p> |
| <ul><table> |
| <tr> |
| <td><b><code>cd <dir-path></code></b></td> |
| <td>sets the current working directory to <code><dir-path></code>.</td> |
| </tr> |
| <tr> |
| <td><b><code>cd -</code></b></td> |
| <td>sets the current working directory to the previous |
| working directory ($<a href="#environvars"><code>OLDPWD</code></a>). |
| Equivalent to <code><a href="#cmdcd">cd</a> $<a href="#environvars">OLDPWD</a></code>.</td> |
| </tr> |
| <tr> |
| <td><b><code>cd</code> or <b><code>cd ~</code></b></td> |
| <td>set the current working directory to the 'home' |
| directory. The <i>home</i> directory can be configured by setting |
| <code>CONFIG_LIB_HOMEDIR</code> in the configuration file. The default |
| <i>home</i> directory is <code>/</code>.</td> |
| </tr> |
| <tr> |
| <td><b><code>cd ..</code></td> |
| <td>sets the current working directory to the parent directory.</td> |
| </tr> |
| </table></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdcp"><h2>2.4 Copy Files (cp)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| cp <source-path> <dest-path> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Copy of the contents of the file at <code><source-path></code> to the location |
| in the filesystem indicated by <code><dest-path></code>. |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmddd"><h2>2.5 Copy and Convert Files (dd)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| dd if=<infile> of=<outfile> [bs=<sectsize>] [count=<sectors>] [skip=<sectors>] |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Copy blocks from <infile> to <outfile>. |
| <infile> or <outfile> may be the path to a standard file, a character device, or a block device. |
| Examples follow: |
| </p> |
| <ol> |
| <li> |
| Read from character device, write to regular file. |
| This will create a new file of the specified size filled with zero. |
| <ul><pre> |
| nsh> ls -l /dev |
| /dev: |
| crw-rw-rw- 0 zero |
| nsh> dd if=/dev/zero of=/tmp/zeros bs=64 count=16 |
| nsh> ls -l /tmp |
| /tmp: |
| -rw-rw-rw- 1024 ZEROS |
| </pre></ul> |
| </li> |
| <li> |
| Read from character device, write to block device. |
| This will fill the entire block device with zeros. |
| </li> |
| <ul><pre> |
| nsh> ls -l /dev |
| /dev: |
| brw-rw-rw- 0 ram0 |
| crw-rw-rw- 0 zero |
| nsh> dd if=/dev/zero of=/dev/ram0 |
| </pre></ul> |
| </li> |
| <li> |
| Read from a block devic, write to a character device. This |
| will read the entire block device and dump the contents in |
| the bit bucket. |
| </li> |
| <ul><pre> |
| nsh> ls -l /dev |
| /dev: |
| crw-rw-rw- 0 null |
| brw-rw-rw- 0 ram0 |
| nsh> dd if=/dev/ram0 of=/dev/null |
| </pre></ul> |
| </li> |
| </ol> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdecho"><h2>2.6 Echo Strings and Variables (echo)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| echo [<string|$name> [<string|$name>...]] |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Copy the sequence of strings and expanded environment variables to |
| console output (or to a file if the output is re-directed). |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdexec"><h2>2.7 Execute User Code (exec)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| exec <hex-address> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Execute the user logic at address <code><hex-address></code>. NSH will pause |
| until the execution unless the user logic is executed in background |
| via <code><a href="#cmdexec">exec</a> <hex-address> &</code>. |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdget"><h2>2.8 Get File Via TFTP (get)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| get [-b|-n] [-f <local-path>] -h <ip-address> <remote-path> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Copy the file at <code><remote-address></code> from the host whose IP address is |
| identified by <code><ip-address></code>. |
| </p> |
| <p><b>Other options:</b></p> |
| <ul><table> |
| <tr> |
| <td><b><code>-f <local-path></code></b></td> |
| <td> |
| The file will be saved relative to the current working directory |
| unless <code><local-path></code> is provided. |
| </td> |
| </tr> |
| <tr> |
| <td><b><code>-b|-n</code></b></td> |
| <td> |
| Selects either binary ("octect") or test ("netascii") transfer |
| mode. Default: text. |
| </td> |
| </tr> |
| </table></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdexit"><h2>2.9 Exit NSH (exit)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| exit |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Exit NSH. Only useful for the serial front end if you have started some other tasks (perhaps |
| using the <code><a href="#cmdexec">exec</a></code> command) and you would like to have NSH out of the |
| way. For the telnet front-end, <code>exit</code> terminates the telenet session. |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdhelp"><h2>2.10 Show Usage Command Usage (help)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| help |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Presents summary information about each command to console. |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdifconfig"><h2>2.11 Show Network Configuration (ifconfig)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| ifconfig |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Show the current configuration of the network, for example: |
| </p> |
| <ul><pre> |
| nsh> ifconfig |
| eth0 HWaddr 00:18:11:80:10:06 |
| IPaddr:10.0.0.2 DRaddr:10.0.0.1 Mask:255.255.255.0 |
| </pre></ul> |
| <p> |
| if uIP statistics are enabled (<code>CONFIG_NET_STATISTICS</code>), then |
| this command will also show the detailed state of uIP. |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdlosetup"><h2>2.12 Setup/teardown the Loop Device (losetup)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax 1:</b></p> |
| <ul><pre> |
| losetup [-o <offset>] [-r] <dev-path> <file-path> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Setup the loop device at <dev-path> to access the file at <file-path> as a block device. |
| In the following example a 256Kb file is created (<code>dd</code>) and <code>losetup</code> is |
| used to make the file accessible as a block device. |
| A FAT file system is created (<code>mkfatfs</code>) and mounted (<code>mount</code>). |
| Files can then be managed on the loop-mounted file. |
| <ul><pre> |
| nsh> dd if=/dev/zero of=/tmp/image bs=512 count=512 |
| nsh> ls -l /tmp |
| /tmp: |
| -rw-rw-rw- 262144 IMAGE |
| nsh> losetup /dev/loop0 /tmp/image |
| nsh> ls -l /dev |
| /dev: |
| brw-rw-rw- 0 loop0 |
| nsh> mkfatfs /dev/loop0 |
| nsh> mount -t vfat /dev/loop0 /mnt/example |
| nsh> ls -l /mnt |
| ls -l /mnt |
| /mnt: |
| drw-rw-rw- 0 example/ |
| nsh> echo "This is a test" >/mnt/example/atest.txt |
| nsh> ls -l /mnt/example |
| /mnt/example: |
| -rw-rw-rw- 16 ATEST.TXT |
| nsh> cat /mnt/example/atest.txt |
| This is a test |
| nsh> |
| </pre></ul> |
| </p> |
| |
| <a <p><b>Command Syntax 2:</b></p> |
| <ul><pre> |
| losetup d <dev-path> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Teardown the setup for the loop device at <dev-path>. |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdls"><h2>2.13 List Directory Contents (ls)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| ls [-lRs] <dir-path> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Show the contents of the directory at <code><dir-path></code>. NOTE: |
| <code><dir-path></code> must refer to a directory and no other filesystem |
| object. |
| </p> |
| <p><b>Options:</b></p> |
| <ul><table> |
| <tr> |
| <td><b><code>-R</code></b></td> |
| <td>Show the constents of specified directory and all of its |
| sub-directories.</td> |
| </tr> |
| <tr> |
| <td><b><code>-s</code></b></td> |
| <td>Show the size of the files along with the filenames in the |
| listing</td> |
| </tr> |
| <tr> |
| <td><b><code>-l</code></b></td> |
| <td>Show size and mode information along with the filenames |
| in the listing.</td> |
| </tr> |
| </table></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdmbhw"><h2>2.14 Access Memory (mb, mh, and mw)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| mb <hex-address>[=<hex-value>][ <hex-byte-count>] |
| mh <hex-address>[=<hex-value>][ <hex-byte-count>] |
| mw <hex-address>[=<hex-value>][ <hex-byte-count>] |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Access memory using byte size access (mb), 16-bit accesses (mh), |
| or 32-bit access (mw). In each case, |
| </p> |
| <ul><table> |
| <tr> |
| <td><code><hex-address></code>.</td> |
| <td>Specifies the address to be accessed. The current |
| value at that address will always be read and displayed. |
| </tr> |
| <tr> |
| <td><code><hex-address>=<hex-value></code>.</td> |
| <td>Read the value, then write <code><hex-value></code> |
| to the location. |
| </tr> |
| <tr> |
| <td><code><hex-byte-count></code>.</td> |
| <td>Perform the mb, mh, or mw operation on a total |
| of <code><hex-byte-count></code> bytes, increment the <code><hex-address></code> appropriately |
| after each access |
| </tr> |
| </table></ul> |
| <p><b>Example:</b><p> |
| <ul><pre> |
| nsh> mh 0 16 |
| 0 = 0x0c1e |
| 2 = 0x0100 |
| 4 = 0x0c1e |
| 6 = 0x0110 |
| 8 = 0x0c1e |
| a = 0x0120 |
| c = 0x0c1e |
| e = 0x0130 |
| 10 = 0x0c1e |
| 12 = 0x0140 |
| 14 = 0x0c1e |
| nsh> |
| </pre></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdmem"><h2>2.15 Show Memory Manager Status (mem)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| mem |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Show the current state of the memory allocator. For example, |
| </p> |
| <ul><pre> |
| nsh> mem |
| arena: fe2560 |
| ordblks: 1 |
| mxordblk: fdc3e0 |
| uordblks: 6180 |
| fordblks: fdc3e0 |
| nsh> |
| </pre></ul> |
| <p><b>Where:</b></p> |
| <ul><table> |
| <tr> |
| <td><b><code>arena</code></b></td> |
| <td>This is the total size of memory allocated for use by malloc in bytes.</td> |
| </tr> |
| <tr> |
| <td><b><code>ordblks</code></b></td> |
| <td>This is the number of free (not in use) chunks.</td> |
| </tr> |
| <tr> |
| <td><b><code>mxordblk</code></b></td> |
| <td>Size of the largest free (not in use) chunk.</td> |
| </tr> |
| <tr> |
| <td><b><code>uordblks</code></b></td> |
| <td>This is the total size of memory occupied by chunks handed out by malloc.</td> |
| </tr> |
| <tr> |
| <td><b><code>fordblks</code></b></td> |
| <td>This is the total size of memory occupied by free (not in use) chunks.</td> |
| </tr> |
| </table></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdps"><h2>2.16 Show Current Tasks and Threads (ps)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| ps |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Show the currently active threads and tasks. For example, |
| </p> |
| <ul><pre> |
| nsh> ps |
| PID PRI SCHD TYPE NP STATE NAME |
| 0 0 FIFO TASK READY Idle Task() |
| 1 128 RR TASK RUNNING init() |
| 2 128 FIFO TASK WAITSEM nsh_telnetmain() |
| 3 100 RR PTHREAD WAITSEM <pthread>(21) |
| nsh> |
| </pre></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdmkdir"><h2>2.17 Create a Directory (mkdir)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| mkdir <path> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Create the directory at <code><path></code>. |
| All components of of <code><path></code> except the final directory name must exist on a mounted file |
| system; the final directory must not. |
| </p> |
| <p> |
| <b>Limited to Mounted File Systems</b>. |
| Recall that NuttX uses a <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a> for its root file |
| system. |
| The <code>mkdir</code> command can only be used to create directories in volumes set up with the |
| <a href="#cmdmount"><code>mount</code></a> command; it cannot be used to create directories in the <i>pseudo</i> filesystem. |
| </p> |
| <p><b>Example:</b></p> |
| <ul><pre> |
| nsh> mkdir /mnt/fs/tmp |
| nsh> ls -l /mnt/fs |
| /mnt/fs: |
| drw-rw-rw- 0 TESTDIR/ |
| drw-rw-rw- 0 TMP/ |
| nsh> |
| </pre></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdmkfatfs"><h2>2.18 Create a FAT Filesystem (mkfatfs)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| mkfatfs <path> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Format a fat file system on the block device specified by <code><path></code>. |
| NSH provides this command to access the <a href="mkfatfs"><code>mkfatfs()</code></a> NuttX API. |
| This block device must reside in the NuttX <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a> and |
| must have been created by some call to <code>register_blockdriver()</code> (see <code>include/nuttx/fs.h</code>). |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdmkfifo"><h2>2.19 Create a FIFO (mkfifo)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| mkfifo <path> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Creates a FIFO character device anywhere in the pseudo file system, creating |
| whatever psuedo directories that may be needed to complete the <code><path></code>. |
| By convention, however, device drivers are place in the standard <code>/dev</code> directory. |
| After it is created, the FIFO device may be used as any other device driver. |
| NSH provides this command to access the <a href="NuttxUserGuide.html#mkfifo"><code>mkfifo()</code></a> NuttX API. |
| </p> |
| <p><b>Example</b></p> |
| <ul><pre> |
| nsh> ls -l /dev |
| /dev: |
| crw-rw-rw- 0 console |
| crw-rw-rw- 0 null |
| brw-rw-rw- 0 ram0 |
| nsh> mkfifo /dev/fifo |
| nsh> ls -l /dev |
| ls -l /dev |
| /dev: |
| crw-rw-rw- 0 console |
| crw-rw-rw- 0 fifo |
| crw-rw-rw- 0 null |
| brw-rw-rw- 0 ram0 |
| nsh> |
| </pre></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdmkrd"><h2>2.20 Create a RAMDISK (mkrd)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| mkrd [-m <minor>] [-s <sector-size>] <nsectors> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Create a ramdisk consisting of <code><nsectors></code>, each of size |
| <code><sector-size></code> (or 512 bytes if <code><sector-size></code> is not specified. |
| The ramdisk will be registered as <code>/dev/ram<n></code> (if <code><n></code> is not |
| specified, mkrd will attempt to register the ramdisk as <code>/dev/ram0</code>. |
| </p> |
| <p><b>Example</b></p> |
| <ul><pre> |
| nsh> ls /dev |
| /dev: |
| console |
| null |
| ttyS0 |
| ttyS1 |
| nsh> mkrd 1024 |
| nsh> ls /dev |
| /dev: |
| console |
| null |
| ram0 |
| ttyS0 |
| ttyS1 |
| nsh> |
| </pre></ul> |
| <p> |
| Once the ramdisk has been created, it may be formatted using |
| the <code>mkfatfs</code> command and mounted using the <code>mount</code> command. |
| </p> |
| <p><b>Example</b></p> |
| <ul><pre> |
| nsh> mkrd 1024 |
| nsh> mkfatfs /dev/ram0 |
| nsh> mount -t vfat /dev/ram0 /tmp |
| nsh> ls /tmp |
| /tmp: |
| nsh> |
| </pre></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdmount"><h2>2.21 Mount a File System (mount)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| mount -t <fstype> <block-device> <code><dir-path></code> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| The 'm ount' command mounts a file system in the NuttX psuedo |
| filesystem. 'mount' performs a three way associating, binding: |
| </p> |
| <ol> |
| <li><b>File system.</b> |
| The '-t <code><fstype></code>' option identifies the type of |
| file system that has been formatted on the <code><block-device></code>. |
| As of this writing, <code>vfat</code> is the only supported value for <code><fstype></code> |
| </li> |
| <li><b>Block Device.</b> |
| The <code><block-device></code> argument is the full or relative |
| path to a block driver inode in the <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a>. |
| By convention, this is a name under the <code>/dev</code> sub-directory. |
| This <code><block-device></code> must have been previously formatted with the same file system |
| type as specified by <code><fstype></code> |
| </li> |
| <li><b>Mount Point.</b> |
| The mount point, <code><dir-path></code>, is the location in the |
| <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a> where the mounted volume will appear. |
| This mount point can only reside in the NuttX <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a>. |
| By convention, this mount point is a subdirectory under <code>/mnt</code>. |
| The mount command will create whatever psuedo directories that may be needed to complete the |
| full path but the full path must not already exist. |
| </li> |
| </ol> |
| <p> |
| After the volume has been mounted in the NuttX |
| <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a>, |
| it may be access in the same way as other objects in thefile system. |
| </p> |
| <p><b>Example</b></p> |
| <ul><pre> |
| nsh> ls -l /dev |
| /dev: |
| crw-rw-rw- 0 console |
| crw-rw-rw- 0 null |
| brw-rw-rw- 0 ram0 |
| nsh> ls /mnt |
| nsh: ls: no such directory: /mnt |
| nsh> mount -t vfat /dev/ram0 /mnt/fs |
| nsh> ls -l /mnt/fs/testdir |
| /mnt/fs/testdir: |
| -rw-rw-rw- 15 TESTFILE.TXT |
| nsh> echo "This is a test" >/mnt/fs/testdir/example.txt |
| nsh> ls -l /mnt/fs/testdir |
| /mnt/fs/testdir: |
| -rw-rw-rw- 15 TESTFILE.TXT |
| -rw-rw-rw- 16 EXAMPLE.TXT |
| nsh> cat /mnt/fs/testdir/example.txt |
| This is a test |
| nsh> |
| </pre></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdping"><h2>2.22 Check Network Peer (ping)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| ping [-c <count>] [-i <interval>] <ip-address> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Test the network communication with a remote peer. Example, |
| </p> |
| <ul><pre> |
| nsh> 10.0.0.1 |
| PING 10.0.0.1 56 bytes of data |
| 56 bytes from 10.0.0.1: icmp_seq=1 time=0 ms |
| 56 bytes from 10.0.0.1: icmp_seq=2 time=0 ms |
| 56 bytes from 10.0.0.1: icmp_seq=3 time=0 ms |
| 56 bytes from 10.0.0.1: icmp_seq=4 time=0 ms |
| 56 bytes from 10.0.0.1: icmp_seq=5 time=0 ms |
| 56 bytes from 10.0.0.1: icmp_seq=6 time=0 ms |
| 56 bytes from 10.0.0.1: icmp_seq=7 time=0 ms |
| 56 bytes from 10.0.0.1: icmp_seq=8 time=0 ms |
| 56 bytes from 10.0.0.1: icmp_seq=9 time=0 ms |
| 56 bytes from 10.0.0.1: icmp_seq=10 time=0 ms |
| 10 packets transmitted, 10 received, 0% packet loss, time 10190 ms |
| nsh> |
| </pre></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdput"><h2>2.23 Send File Via TFTP (put)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| put [-b|-n] [-f <remote-path>] -h <ip-address> <local-path> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Copy the file at <code><local-address></code> to the host whose IP address is |
| identified by <code><ip-address></code>. |
| </p> |
| <p><b>Other options:</b></p> |
| <ul><table> |
| <tr> |
| <td><b><code>-f <remote-path></code></b></td> |
| <td> |
| The file will be saved relative with the same name on the host |
| unless <code><remote-path></code> is provided. |
| </td> |
| </tr> |
| <tr> |
| <td><b><code>-b|-n</code></b></td> |
| <td> |
| Selects either binary ("octect") or test ("netascii") transfer |
| mode. Default: text. |
| </td> |
| </tr> |
| </table></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdpwd"><h2>2.24 Show Current Working Directory (pwd)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| pwd |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Show the current working directory. |
| </p> |
| <ul><pre> |
| nsh> cd /dev |
| nsh> pwd |
| /dev |
| nsh> |
| </pre></ul> |
| |
| <p>Same as <code><a href="#cmdecho">echo</a> <a href="#environvars">$PWD</a></code>.</p> |
| <ul><pre> |
| nsh> echo $PWD |
| /dev |
| nsh> |
| </pre></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdrm"><h2>2.25 Remove a File (rm)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| rm <file-path> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Remove the specified <code><file-path></code> name from the mounted file system. |
| Recall that NuttX uses a <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a> for its root file |
| system. |
| The <code>rm</code> command can only be used to remove (unlink) files in volumes set up with the |
| <a href="#cmdmount"><code>mount</code></a> command; |
| it cannot be used to remove names in the <i>pseudo</i> filesystem. |
| </p> |
| <p><b>Example:</b></p> |
| <ul><pre> |
| nsh> ls /mnt/fs/testdir |
| /mnt/fs/testdir: |
| TESTFILE.TXT |
| EXAMPLE.TXT |
| nsh> rm /mnt/fs/testdir/example.txt |
| nsh> ls /mnt/fs/testdir |
| /mnt/fs/testdir: |
| TESTFILE.TXT |
| nsh> |
| </pre></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdrmdir"><h2>2.26 Remove a Directory (rmdir)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| rmdir <dir-path> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Remove the specified <code><dir-path></code> directory from the mounted file system. |
| Recall that NuttX uses a <a href="NuttxUserGuide.html#FileSystemOverview"><i>pseudo</i> filesystem</a> for its root file |
| system. |
| The <code>rmdir</code> command can only be used to remove directories from volumes set up with the |
| <a href="#cmdmount"><code>mount</code></a> command; |
| it cannot be used to remove directories from the <i>pseudo</i> filesystem. |
| </p> |
| <p><b>Example:</b></p> |
| <ul><pre> |
| nsh> mkdir /mnt/fs/tmp |
| nsh> ls -l /mnt/fs |
| /mnt/fs: |
| drw-rw-rw- 0 TESTDIR/ |
| drw-rw-rw- 0 TMP/ |
| nsh> rmdir /mnt/fs/tmp |
| nsh> ls -l /mnt/fs |
| /mnt/fs: |
| drw-rw-rw- 0 TESTDIR/ |
| nsh> |
| </pre></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdset"><h2>2.27 Set an Environment Variable (set)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| set <name> <value> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Set the environment variable <code><name></code> to the string <code><value></code>. |
| For example, |
| </p> |
| <ul><pre> |
| nsh> echo $foobar |
| |
| nsh> set foobar foovalue |
| nsh> echo $foobar |
| foovalue |
| nsh> |
| </pre></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdsh"><h2>2.28 Execute an NSH Script (sh)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| sh <script-path> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Execute the sequence of NSH commands in the file referred |
| to by <code><script-path>. |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdsleep"><h2>2.29 Wait for Seconds (sleep)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| sleep <sec> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Pause execution (sleep) for <code><sec></code> seconds. |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdunmount"><h2>2.30 Unmount a File System (umount)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| umount <dir-path> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Un-mount the file system at mount point <code><dir-path></code>. |
| The <code>umount</code> command can only be used to un-mount volumes previously mounted using |
| <a href="#cmdmount"><code>mount</code></a> command. |
| </p> |
| <p><b>Example:</b></p> |
| <ul><pre> |
| nsh> ls /mnt/fs |
| /mnt/fs: |
| TESTDIR/ |
| nsh> umount /mnt/fs |
| nsh> ls /mnt/fs |
| /mnt/fs: |
| nsh: ls: no such directory: /mnt/fs |
| nsh> |
| </pre></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdunset"><h2>2.31 Unset an Environment Variable (unset)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| unset <name> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Remove the value associated with the environment variable |
| <code><name>. Example: |
| </p> |
| <ul><pre> |
| nsh> echo $foobar |
| foovalue |
| nsh> unset foobar |
| nsh> echo $foobar |
| |
| nsh> |
| </pre></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdusleep"><h2>2.32 Wait for Microseconds (usleep)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| usleep <usec> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Pause execution (sleep) of <code><usec></code> microseconds. |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdwget">2.33 Get File Via HTTP (wget)</a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| wget [-o <local-path>] <url> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Use HTTP to copy the file at <code><url></code> to the current directory. |
| </p> |
| <p><b>Options:</b></p> |
| <ul><table> |
| <tr> |
| <td><b><code>-o <local-path></code></b></td> |
| <td> |
| The file will be saved relative to the current working directory |
| and with the same name as on the HTTP server unless <code><local-path></code> is provided. |
| </td> |
| </tr> |
| </table></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmdxd"><h2>2.34 Hexadecimal dump (xd)</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <a <p><b>Command Syntax:</b></p> |
| <ul><pre> |
| xd <hex-address> <byte-count> |
| </pre></ul> |
| <p> |
| <b>Synopsis</b>. |
| Dump <code><byte-count></code> bytes of data from address <code><hex-address></code>. |
| </p> |
| <p><b>Example:</b></p> |
| <ul><pre> |
| nsh> xd 410e0 512 |
| Hex dump: |
| 0000: 00 00 00 00 9c 9d 03 00 00 00 00 01 11 01 10 06 ................ |
| 0010: 12 01 11 01 25 08 13 0b 03 08 1b 08 00 00 02 24 ....%..........$ |
| ... |
| 01f0: 08 3a 0b 3b 0b 49 13 00 00 04 13 01 01 13 03 08 .:.;.I.......... |
| nsh> |
| </pre></ul> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="configuration"><h1>3.0 Configuration Settings</h1></a> |
| </td> |
| </tr> |
| </table> |
| |
| <p> |
| The availability of the above commands depends upon features that |
| may or may not be enabled in the NuttX configuration file. The |
| following <a href="#cmddependencies">table</a> indicates the dependency of each command on NuttX |
| configuration settings. General configuration settings are discussed |
| in the <a href="NuttxPortingGuide.html">NuttX Porting Guide.</a> |
| Configuration settings specific to NSH as discussed at the <a href="#nshconfiguration">bottom</a> of this document. |
| </p> |
| |
| <p> |
| Note that in addition to general NuttX configuation 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. |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="cmddependencies"><h2>3.1 Command Dependencies on Configuration Settings</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <center><p>Table. Command Dependencies on Configuration Settings</p> |
| <table width="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <th align="left" width="25%">Command</th> |
| <th align="left">Depends on Configuration</th> |
| <th align="left">Can Be Disabled with</th> |
| </tr> |
| <tr> |
| <td><b><code>[</code></b></td> |
| <td>!<code>CONFIG_EXAMPLES_NSH_DISABLESCRIPT</code></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_TEST</code></td> |
| </tr> |
| <tr> |
| <td><b><code>cat</code></b></td> |
| <td><code>CONFIG_NFILE_DESCRIPTORS</code> > 0</td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_CAT</code></td> |
| </tr> |
| <tr> |
| <td><b><code>cd</code></b></td> |
| <td>!<code>CONFIG_DISABLE_ENVIRON</code> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0</td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_CD</code></td> |
| </tr> |
| <tr> |
| <td><b><code>cp</code></b></td> |
| <td><code>CONFIG_NFILE_DESCRIPTORS</code> > 0</td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_CP</code></td> |
| </tr> |
| <tr> |
| <td><b><code>dd</code></b></td> |
| <td><code>CONFIG_NFILE_DESCRIPTORS</code> > 0</td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_DD</code></td> |
| </tr> |
| <tr> |
| <td><b><code>echo</code></b></td> |
| <td><br></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_ECHO</code></td> |
| </tr> |
| <tr> |
| <td><b><code>exec</code></b></td> |
| <td><br></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_EXEC</code></td> |
| </tr> |
| <tr> |
| <td><b><code>exit</code></b></td> |
| <td><br></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_EXIT</code></td> |
| </tr> |
| <tr> |
| <td><b><code>get</code></b></td> |
| <td><code>CONFIG_NET</code> && <code>CONFIG_NET_UDP</code> && |
| <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <code>CONFIG_NET_BUFSIZE</code> >= 558<sup>1</sup></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_GET</code></td> |
| </tr> |
| <tr> |
| <td><b><code>help</code></b></td> |
| <td><br></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_HELP</code></td> |
| </tr> |
| <tr> |
| <td><b><code>ifconfig</code></b></td> |
| <td><code>CONFIG_NET</code></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG</code></td> |
| </tr> |
| <tr> |
| <td><b><code>losetup</code></b></td> |
| <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0</td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_LOSETUP</code></td> |
| </tr> |
| <tr> |
| <td><b><code>ls</code></b></td> |
| <td><code>CONFIG_NFILE_DESCRIPTORS</code> > 0</td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_LS</code></td> |
| </tr> |
| <tr> |
| <td><b><code>mb,mh,mw</code></b></td> |
| <td><br></td> |
| <td> |
| <code>CONFIG_EXAMPLES_NSH_DISABLE_MB</code>,<br> |
| <code>CONFIG_EXAMPLES_NSH_DISABLE_MH</code>,<br> |
| <code>CONFIG_EXAMPLES_NSH_DISABLE_MW</code> |
| </td> |
| </tr> |
| <tr> |
| <td><b><code>mem</code></b></td> |
| <td><br></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_MEM</code></td> |
| </tr> |
| <tr> |
| <td><b><code>mkdir</code></b></td> |
| <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <code>CONFIG_FS_WRITABLE</code><sup>4</sup></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_MKDIR</code></td> |
| </tr> |
| <tr> |
| <td><b><code>mkfatfs</code></b></td> |
| <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <code>CONFIG_FS_FAT</code></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_MKFATFS</code></td> |
| </tr> |
| <tr> |
| <td><b><code>mkfifo</code></b></td> |
| <td><code>CONFIG_NFILE_DESCRIPTORS</code> > 0</td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_MKFIFO</code></td> |
| </tr> |
| <tr> |
| <td><b><code>mkrd</code></b></td> |
| <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <code>CONFIG_FS_WRITABLE</code><sup>4</sup></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_MKRD</code></td> |
| </tr> |
| <tr> |
| <td><b><code>mount</code></b></td> |
| <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <code>CONFIG_FS_READABLE</code><sup>3</sup></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_MOUNT</code></td> |
| </tr> |
| <tr> |
| <td><b><code>ping</code></b></td> |
| <td><code>CONFIG_NET</code> && <code>CONFIG_NET_ICMP</code> && |
| <code>CONFIG_NET_ICMP_PING</code> && !<code>CONFIG_DISABLE_CLOCK</code> && |
| !<code>CONFIG_DISABLE_SIGNALS</code></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_PING</code></td> |
| </tr> |
| <tr> |
| <td><b><code>ps</code></b></td> |
| <td><br></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_PS</code></td> |
| </tr> |
| <tr> |
| <td><b><code>put</code></b></td> |
| <td><code>CONFIG_NET</code> && <code>CONFIG_NET_UDP</code> && |
| <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <code>CONFIG_NET_BUFSIZE</code> >= 558<sup>1,2</sup></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_PUT</code></td> |
| </tr> |
| <tr> |
| <td><b><code>pwd</code></b></td> |
| <td>!<code>CONFIG_DISABLE_ENVIRON</code> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0</td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_PWD</code></td> |
| </tr> |
| <tr> |
| <td><b><code>rm</code></b></td> |
| <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <code>CONFIG_FS_WRITABLE</code><sup>4</sup></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_RM</code></td> |
| </tr> |
| <tr> |
| <td><b><code>rmdir</code></b></td> |
| <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <code>CONFIG_FS_WRITABLE</code><sup>4</sup></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_RMDIR</code></td> |
| </tr> |
| <tr> |
| <td><b><code>set</code></b></td> |
| <td>!<code>CONFIG_DISABLE_ENVIRON</code></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_SET</code></td> |
| </tr> |
| <tr> |
| <td><b><code>sh</code></b></td> |
| <td><code>CONFIG_NFILE_DESCRIPTORS > 0 && <code>CONFIG_NFILE_STREAMS > 0 && !<code>CONFIG_EXAMPLES_NSH_DISABLESCRIPT</code></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_SH</code></td> |
| </tr> |
| <tr> |
| <td><b><code>sleep</code></b></td> |
| <td>!<code>CONFIG_DISABLE_SIGNALS</code></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_SLEEP</code></td> |
| </tr> |
| <tr> |
| <td><b><code>test</code></b></td> |
| <td>!<code>CONFIG_EXAMPLES_NSH_DISABLESCRIPT</code></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_TEST</code></td> |
| </tr> |
| <tr> |
| <td><b><code>umount</code></b></td> |
| <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> && <code>CONFIG_NFILE_DESCRIPTORS</code> > 0 && <code>CONFIG_FS_READABLE</code><sup>3</sup></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_UMOUNT</code></td> |
| </tr> |
| <tr> |
| <td><b><code>unset</code></b></td> |
| <td>!<code>CONFIG_DISABLE_ENVIRON</code></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_UNSET</code></td> |
| </tr> |
| <tr> |
| <td><b><code>usleep</code></b></td> |
| <td>!<code>CONFIG_DISABLE_SIGNALS</code></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_USLEEP</code></td> |
| </tr> |
| <tr> |
| <td><b><code>wget</code></b></td> |
| <td><code>CONFIG_NET</code> && <code>CONFIG_NET_TCP</code> && |
| <code>CONFIG_NFILE_DESCRIPTORS</code> > 0</td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_WGET</code></td> |
| </tr> |
| <tr> |
| <td><b><code>xd</code></b></td> |
| <td><br></td> |
| <td><code>CONFIG_EXAMPLES_NSH_DISABLE_XD</code></td> |
| </tr> |
| </table></center> |
| |
| <p><sup>1</sup><small> |
| Because of hardware padding, the actual required packet size may be larger</small><br> |
| <sup>2</sup><small> |
| Special TFTP server start-up optionss will probably be required to permit |
| creation of files for the correct operation of the <code>put</code> command.</small><br> |
| <sup>3</sup><small> |
| <code>CONFIG_FS_READABLE</code> is not a user configuration but is set automatically |
| if any readable filesystem is selected. At present, this is either <code>CONFIG_FS_FAT</code> |
| or <code>CONFIG_FS_ROMFS</code>.</small><br> |
| <sup>4</sup><small> |
| <code>CONFIG_FS_WRITABLE</code> is not a user configuration but is set automatically |
| if any writable filesystem is selected. At present, this is only <code>CONFIG_FS_FAT</code>.</small><br> |
| </p> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="nshconfiguration"><h2>3.2 NSH-Specific Configuration Settings</h2></a> |
| </td> |
| </tr> |
| </table> |
| |
| <p> |
| The behavior of NSH can be modified with the following settings in |
| the <code>configs/<board-name>/defconfig</code> file: |
| </p> |
| |
| <center><table width="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <th align="left" width="25%">Configuration</th> |
| <th align="left">Description</th> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_FILEIOSIZE</code></b></td> |
| <td> |
| Size of a static I/O buffer used for file access (ignored if |
| there is no filesystem). Default is 1024. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_STRERROR</code></b></td> |
| <td> |
| strerror(errno) makes more readable output but strerror() is |
| very large and will not be used unless this setting is <i>y</i> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_LINELEN</code></b></td> |
| <td> |
| The maximum length of one command line and of one output line. |
| Default: 80 |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_STACKSIZE</code></b></td> |
| <td> |
| The stack size to use when spawning new threads or tasks. Such |
| new threads are generated when a command is executed in background |
| or as new TELNET connections are established. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_NESTDEPTH</code></b></td> |
| <td> |
| The maximum number of nested <a href="#conditional"><code>if-then[-else]-fi</code></a> sequences that |
| are permissable. Default: 3 |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_DISABLESCRIPT</code></b></td> |
| <td> |
| This can be set to <i>y</i> to suppress support for scripting. This |
| setting disables the <a href="#cmdsh"><code>sh</code></a>, <a href="#cmdtest"><code>test</code></a>, and <a href="#cmtest"><code>[</code></a> commands and the |
| <a href="#conditional"><code>if-then[-else]-fi</code></a> construct. This would only be set on systems |
| where a minimal footprint is a necessity and scripting is not. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_DISABLEBG</code></b></td> |
| <td> |
| This can be set to <i>y</i> to suppress support for background |
| commands. This setting disables the <a href="#cmdoverview"><code>nice</code></a> command prefix and |
| the <a href="#cmdoverview"><code>&</code></a> command suffix. This would only be set on systems |
| where a minimal footprint is a necessity and background command execution is not. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_MMCSDMINOR</code></b></td> |
| <td> |
| 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 <code>/dev/mmcsd</code><i>N</i> where <i>N</i> is the minor number. |
| Default is zero. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_ROMFSETC</code></b></td> |
| <td> |
| Mount a ROMFS filesystem at <code>/etc</code> and provide a startup script |
| at <code>/etc/init.d/rcS</code>. The default startup script will mount |
| a FAT FS RAMDISK at <code>/tmp</code> but the logic is |
| <a href="#startupscript">easily extensible</a>. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_CONSOLE</code></b></td> |
| <td> |
| If <code>CONFIG_EXAMPLES_NSH_CONSOLE</code>is set to <i>y</i>, then a serial |
| console front-end is selected. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_TELNET</code></b></td> |
| <td> |
| If <code>CONFIG_EXAMPLES_NSH_TELNET</code> is set to <i>y</i>, then a TELENET |
| server front-end is selected. When this option is provided, |
| you may log into NuttX remotely using telnet in order to |
| access NSH. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_ARCHINIT</code></b></td> |
| <td> |
| Set <code>CONFIG_EXAMPLES_NSH_ARCHINIT</code> if your board provides architecture |
| specific initialization via the board-specific function <code>nsh_archinitialize()</code>. |
| This function will be called early in NSH initialization to allow board logic to |
| do such things as configure MMC/SD slots. |
| </td> |
| </tr> |
| </table></center> |
| |
| <p> |
| One or both of <code>CONFIG_EXAMPLES_NSH_CONSOLE</code> and <code>CONFIG_EXAMPLES_NSH_TELNET</code> |
| must be defined. If <code>CONFIG_EXAMPLES_NSH_TELNET</code> is selected, then there some |
| other configuration settings that apply: |
| </p> |
| |
| <center><table width="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <th align="left" width="25%">Configuration</th> |
| <th align="left">Description</th> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_NET=y</code></b></td> |
| <td> |
| Of course, networking must be enabled. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_NSOCKET_DESCRIPTORS</code></b></td> |
| <td> |
| And, of course, you must allocate some socket descriptors. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_NET_TCP=y</code></b></td> |
| <td> |
| TCP/IP support is required for telnet (as well as various other TCP-related configuration settings). |
| </td> |
| </tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE</code></b></td> |
| <td> |
| Determines the size of the I/O buffer to use for sending/ |
| receiving TELNET commands/reponses |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_DHCPC</code></b></td> |
| <td> |
| Obtain the IP address via DHCP. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_IPADDR</code></b></td> |
| <td> |
| If <code>CONFIG_EXAMPLES_NSH_DHCPC</code> is NOT set, then the static IP |
| address must be provided. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_DRIPADDR</code></b></td> |
| <td> |
| Default router IP address |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_NETMASK</code></b></td> |
| <td> |
| Network mask |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_NOMAC</code></b></td> |
| <td> |
| Set if your ethernet hardware has no built-in MAC address. |
| If set, a bogus MAC will be assigned. |
| </td> |
| </tr> |
| </table></center> |
| |
| <p> |
| If you use DHCPC, then some special configuration network options are |
| required. These include: |
| </p> |
| |
| <center><table width="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <th align="left" width="25%">Configuration</th> |
| <th align="left">Description</th> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_NET=y</code></b></td> |
| <td> |
| Of course, networking must be enabled. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_NSOCKET_DESCRIPTORS</code></b></td> |
| <td> |
| And, of course, you must allocate some socket descriptors. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_NET_UDP=y</code></b></td> |
| <td> |
| UDP support is required for DHCP (as well as various other UDP-related configuration settings). |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_NET_BROADCAST=y</code></b></td> |
| <td> |
| UDP broadcast support is needed. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_NET_BUFSIZE=650</code></b> (or larger)</td> |
| <td> |
| 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). |
| </td> |
| </tr> |
| </table></center> |
| |
| <p> |
| If <code>CONFIG_EXAMPLES_NSH_ROMFSETC</code> is selected, then the following additional |
| configuration setting apply: |
| </p> |
| |
| <center><table width="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <th align="left" width="25%">Configuration</th> |
| <th align="left">Description</th> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT</code></b></td> |
| <td> |
| The default mountpoint for the ROMFS volume is <code>"/etc"</code>, but that |
| can be changed with this setting. This must be a absolute path |
| beginning with '<code>/</code>' and enclosed in quotes. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_INITSCRIPT</code></b></td> |
| <td> |
| This is the relative path to the startup script within the mountpoint. |
| The default is <code>"init.d/rcS"</code>. This is a relative path and must not |
| start with '<code>/</code>' but must be enclosed in quotes. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_ROMFSDEVNO</code></b></td> |
| <td> |
| This is the minor number of the ROMFS block device. The default is |
| '<code>0</code>' corresponding to <code>/dev/ram0</code>. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE</code></b></td> |
| <td> |
| 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. |
| </td> |
| </tr> |
| </table></center> |
| |
| <p> |
| When the default <code>rcS</code> file used when <code>CONFIG_EXAMPLES_NSH_ROMFSETC</code> is |
| selected, it will mount a FAT FS under <code>/tmp</code>. The following selections |
| describe that FAT FS. |
| </p> |
| |
| <center><table width="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <th align="left" width="25%">Configuration</th> |
| <th align="left">Description</th> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_FATDEVNO</code></b></td> |
| <td> |
| This is the minor number of the FAT FS block device. The default is |
| '<code>1</code>' corresponding to <code>/dev/ram1</code>. |
| </td> |
| </tr> |
| <tr> |
| <td valign="top"><b><code>CONFIG_EXAMPLES_NSH_FATSECTSIZE</code></b></td> |
| <td> |
| This is the sector size use with the FAT FS. Default is 512. |
| </td> |
| </tr> |
| </table></center> |
| |
| <table width ="100%"> |
| <tr bgcolor="#e4e4e4"> |
| <td> |
| <a name="index"><h1>Index</h1></a> |
| </td> |
| </tr> |
| </table> |
| |
| <table width="100%"> |
| <tr><td width="50%"> |
| <ul> |
| <li><a href="#builtinvars"><code>$?</code></a></li> |
| <li><a href="#cmdtest"><code>[</code></a></li> |
| <li><a href="#cmdoverview">Background commands</a></li> |
| <li><a href="#cmdoverview">Background command priority</a></li> |
| <li><a href="#builtinvars">Built-in variables</a></li> |
| <li><a href="#cmdcat"><code>cat</code></a></li> |
| <li><a href="#cmdcd"><code>cd</code></a></li> |
| <li><a href="#commands">Command summaries</a></li> |
| <li><a href="#conditional">Conditional command execution</a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_CONSOLE</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_DHCPC</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_DISABLEBG</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_DISABLESCRIPT</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_DRIPADDR</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_FATDEVNO</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_FATMOUNTPT</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_FATNSECTORS</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_FATSECTSIZE</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_FILEIOSIZE</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_INITSCRIPT</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_IPADDR</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_LINELEN</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_NESTDEPTH</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_NETMASK</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_NOMAC</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_ROMFSDEVNO</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_ROMFSETC</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_STACKSIZE</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_STRERROR</code></a></li> |
| <li><a href="#nshconfiguration"><code>CONFIG_EXAMPLES_NSH_TELNET</code></a></li> |
| <li><a href="#configuration">Configuration settings</a></li> |
| <li><a href="#cmddependencies">Configuration settings, command dependencies</a></li> |
| <li><a href="#nshconfiguration">Configuration settings, NSH-specific</a></li> |
| <li><a href="#cmdcp"><code>cp</code></a></li> |
| <li><a href="#currentwd">Current working directory</a></li> |
| <li><a href="#cmddd"><code>dd</code></a></li> |
| <li><a href="#cmdecho"><code>echo</code></a></li> |
| <li><a href="#environvars">Environment Variables</a></li> |
| <li><a href="#startupscript"><code>/etc/init.d/rcS</code></a> |
| </ul></td> |
| <td></ul> |
| <li><a href="#cmdexec"><code>exec</code></a></li> |
| <li><a href="#cmdexit"><code>exit</code></a></li> |
| <li><a href="#cmdget"><code>get</code></a></li> |
| <li><a href="#frontend">Greeting</a></li> |
| <li><a href="#cmdhelp"><code>help</code></a></li> |
| <li><a href="#conditional"><code>if-then[-else]-fi</code></a></li> |
| <li><a href="#cmdifconfig"><code>ifconfig</code></a></li> |
| <li><a href="#cmdlosetup"><code>losetup</code></a></li> |
| <li><a href="#cmdls">ls</code></a></li> |
| <li><a href="#cmdmbhw"><code>mb</code></a></li> |
| <li><a href="#cmdmbhw"><code>mh</code></a></li> |
| <li><a href="#cmdmbhw"><code>mw</code></a></li> |
| <li><a href="#cmdmem"><code>mem</code></a></li> |
| <li><a href="#cmdmkdir"><code>mkdir</code></a></li> |
| <li><a href="#cmdmkfatfs"><code>mkfatfs</code></a></li> |
| <li><a href="#cmdmkfifo"><code>mkfifo</code></a></li> |
| <li><a href="#cmdmkrd"><code>mkrd</code></a></li> |
| <li><a href="#cmdmount"><code>mount</code></a></li> |
| <li><a href="#cmdoverview"><code>nice</code></a></li> |
| <li><a href="#environvars"><code>OLDPWD</code></a></li> |
| <li><a href="#overview">Overview</a></li> |
| <li><a href="#cmdping"><code>ping</code></a></li> |
| <li><a href="#frontend">Prompt</a></li> |
| <li><a href="#cmdps"><code>ps</code></a></li> |
| <li><a href="#cmdput"><code>put</code></a></li> |
| <li><a href="#cmdpwd"><code>pwd</code></a></li> |
| <li><a href="#environvars"><code>PWD</code></a></li> |
| <li><a href="#cmdoverview">Re-directed commands</a></li> |
| <li><a href="#cmdrm"><code>rm</code></a></li> |
| <li><a href="#cmdrmdir"><code>rmdir</code></a></li> |
| <li><a href="#cmdset"><code>set</code></a></li> |
| <li><a href="#cmdsh"><code>sh</code></a></li> |
| <li><a href="#cmdoverview">Simple commands</a></li> |
| <li><a href="#cmdsleep"><code>sleep</code></a></li> |
| <li><a href="#startupscript">start-up script</a> |
| <li><a href="#cmdtest"><code>test</code></a></li> |
| <li><a href="#cmdunmount"><code>umount</code></a></li> |
| <li><a href="#cmdunset"><code>unset</code></a></li> |
| <li><a href="#cmdusleep"><code>usleep</code></a></li> |
| <li><a href="#cmdwget"><code>wget</code></a></li> |
| <li><a href="#cmdxd"><code>xd</code></a></li> |
| </ul></td> |
| </tr></table> |
| |
| </body> |
| </html> |