diff --git a/ChangeLog b/ChangeLog
index 7ed1a3ed64..fca27df5fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -465,3 +465,5 @@
0.3.15 2008-xx-xx Gregory Nutt
* Added support for ROMFS filesystem.
* Added a simple test the ROMFS filesystem (examples/romfs)
+ * NSH: Use ROMFS to provide an option for a start-up script at /etc/init.d/rcS
+
diff --git a/Documentation/NuttShell.html b/Documentation/NuttShell.html
index d25d6d8c43..c017d6eca8 100644
--- a/Documentation/NuttShell.html
+++ b/Documentation/NuttShell.html
@@ -67,6 +67,12 @@
1.6 Environment Variables
+
+
|
+
+ 1.7 NSH Start-Up Script
+ |
+
 |
@@ -470,6 +476,129 @@ fi
+
+
+
+ NSH Start-Up Script.
+ NSH supports options to provide a start up script for NSH. In general
+ this capability is enabled with CONFIG_EXAMPLES_NSH_ROMFSETC
, but has
+ several other related configuration options as described with the
+ NSH-specific configuration settings.
+ This capability also depends on:
+
+ CONFIG_DISABLE_MOUNTPOINT
not set
+ CONFIG_NFILE_DESCRIPTORS
< 4
+ CONFIG_FS_ROMFS
enabled
+
+
+
+
+ Default Start-Up Behavior.
+ 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.
+
+
+ In this default case, enabling CONFIG_EXAMPLES_NSH_ROMFSETC
will cause
+ NSH to behave as follows at NSH startup time:
+
+ -
+ NSH will create a read-only RAM disk (a ROM disk), containing a tiny
+ ROMFS filesystem containing the following:
+
+`--init.d/
+ `-- rcS
+
+ Where rcS is the NSH start-up script.
+
+
+ NSH will then mount the ROMFS filesystem at /etc
, resulting in:
+
+|--dev/
+| `-- ram0
+`--etc/
+ `--init.d/
+ `-- rcS
+
+
+
+ By default, the contents of rcS script are:
+
+# Create a RAMDISK and mount it at XXXRDMOUNTPOUNTXXX
+
+mkrd -m 1 -s 512 1024
+mkfatfs /dev/ram1
+mount -t vfat /dev/ram1 /tmp
+
+
+
+ NSH will execute the script at /etc/init.d/rcS
at start-up (before the
+ first NSH prompt. After execution of the script, the root FS will look
+ like:
+
+|--dev/
+| |-- ram0
+| `-- ram1
+|--etc/
+| `--init.d/
+| `-- rcS
+`--tmp/
+
+
+
+
+
+ Modifying the ROMFS Image.
+ The contents of the /etc
directory are retained in the file
+ examples/nsh/nsh_romfsimg.h
. In order to modify the start-up
+ behavior, there are three things to study:
+
+ -
+ Configuration Options.
+ The additional
CONFIG_EXAMPLES_NSH_ROMFSETC
configuration options
+ discussed with the other NSH-specific configuration settings.
+
+ -
+
+ mkromfsimg.sh
Script.
+ The script examples/nsh/mkromfsimg.sh
creates nsh_romfsimg.h
.
+ It is not automatically executed. If you want to change the
+ configuration settings associated with creating and mounting
+ the /tmp
directory, then it will be necessary to re-generate
+ this header file using the mkromfsimg.sh
script.
+
+
+ The behavior of this script depends upon three things:
+
+ - The configuration settings then installed configuration.
+
- The
genromfs tool (available from http://romfs.sourceforge.net).
+ - The file
examples/nsh/rcS.template
.
+
+
+
+ -
+
rcS.template
.
+ The file examples/nsh/rcS.template
contains the general form
+ of the rcS
file; configurated values are plugged into this
+ template file to produce the final rcS
file.
+
+
+
+
+ All of the startup-behavior is contained in rcS.template
. The
+ role of mkromfsimg.sh
is to (1) apply the specific configuration
+ settings to rcS.template
to create the final rcS
, and (2) to
+ generate the header file nsh_romfsimg.h
containg the ROMFS
+ file system image.
+
+
@@ -1641,7 +1770,7 @@ nsh>
| CONFIG_EXAMPLES_NSH_FILEIOSIZE |
Size of a static I/O buffer used for file access (ignored if
- there is no filesystem).
+ there is no filesystem). Default is 1024.
|
@@ -1691,6 +1820,15 @@ nsh>
where a minimal footprint is a necessity and background command execution is not.
+
+ CONFIG_EXAMPLES_NSH_ROMFSETC |
+
+ Mount a ROMFS filesystem 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_EXAMPLES_NSH_CONSOLE |
@@ -1720,6 +1858,7 @@ nsh>
| Configuration |
Description |
+
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE |
Determines the size of the I/O buffer to use for sending/
@@ -1760,6 +1899,76 @@ nsh>
|
+
+ If CONFIG_EXAMPLES_NSH_ROMFSETC
is selected, then the following additional
+ configuration setting apply:
+
+
+
+
+ Configuration |
+ Description |
+
+
+ CONFIG_EXAMPLES_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_EXAMPLES_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_EXAMPLES_NSH_ROMFSDEVNO |
+
+ This is the minor number of the ROMFS block device. The default is
+ '0 ' corresponding to /dev/ram0 .
+ |
+
+
+ CONFIG_EXAMPLES_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_EXAMPLES_NSH_ROMFSETC
is
+ selected, it will mount a FAT FS under /tmp
. The following selections
+ describe that FAT FS.
+
+
+
+
+ Configuration |
+ Description |
+
+
+ CONFIG_EXAMPLES_NSH_FATDEVNO |
+
+ This is the minor number of the FAT FS block device. The default is
+ '1 ' corresponding to /dev/ram1 .
+ |
+
+
+ CONFIG_EXAMPLES_NSH_FATSECTSIZE |
+
+ This is the sector size use with the FAT FS. Default is 512.
+ |
+
+
+
@@ -1785,13 +1994,22 @@ nsh>
CONFIG_EXAMPLES_NSH_DISABLEBG
CONFIG_EXAMPLES_NSH_DISABLESCRIPT
CONFIG_EXAMPLES_NSH_DRIPADDR
+ CONFIG_EXAMPLES_NSH_FATDEVNO
+ CONFIG_EXAMPLES_NSH_FATMOUNTPT
+ CONFIG_EXAMPLES_NSH_FATNSECTORS
+ CONFIG_EXAMPLES_NSH_FATSECTSIZE
CONFIG_EXAMPLES_NSH_FILEIOSIZE
+ CONFIG_EXAMPLES_NSH_INITSCRIPT
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE
CONFIG_EXAMPLES_NSH_IPADDR
CONFIG_EXAMPLES_NSH_LINELEN
CONFIG_EXAMPLES_NSH_NESTDEPTH
CONFIG_EXAMPLES_NSH_NETMASK
CONFIG_EXAMPLES_NSH_NOMAC
+ CONFIG_EXAMPLES_NSH_ROMFSDEVNO
+ CONFIG_EXAMPLES_NSH_ROMFSETC
+ CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT
+ CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE
CONFIG_EXAMPLES_NSH_STACKSIZE
CONFIG_EXAMPLES_NSH_STRERROR
CONFIG_EXAMPLES_NSH_TELNET
@@ -1802,11 +2020,12 @@ nsh>
Current working directory
echo
Environment Variables
+ /etc/init.d/rcS
+ |
+
exec
exit
get
- |
-
Greeting
help
if-then[-else]-fi
@@ -1837,6 +2056,7 @@ nsh>
sh
Simple commands
sleep
+ start-up script
test
umount
unset
diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html
index 62068e2c2e..3ee7c80b71 100644
--- a/Documentation/NuttX.html
+++ b/Documentation/NuttX.html
@@ -8,7 +8,7 @@
|
NuttX RTOS
- Last Updated: September 10, 2008
+ Last Updated: September 11, 2008
|
@@ -1099,6 +1099,7 @@ buildroot-0.1.0 2007-03-09 <spudmonkey@racsa.co.cr>
nuttx-0.3.15 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
* Added support for ROMFS filesystem.
* Added a simple test the ROMFS filesystem (examples/romfs)
+ * NSH: Use ROMFS to provide an option for a start-up script at /etc/init.d/rcS
pascal-0.1.3 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
diff --git a/examples/nsh/README.txt b/examples/nsh/README.txt
index 7a904ecce9..c2182e91d1 100644
--- a/examples/nsh/README.txt
+++ b/examples/nsh/README.txt
@@ -9,7 +9,8 @@ examples/nsh
- Conditional Command Execution
- Built-In Variables
- Current Working Directory
- Environment Variables:
+ Environment Variables
+ - NSH Start-Up Script
- Simple Commands
- NSH Configuration Settings
Command Dependencies on Configuration Settings
@@ -94,6 +95,99 @@ Current Working Directory
PWD - The current working directory
OLDPWD - The previous working directory
+NSH Start-Up Script
+^^^^^^^^^^^^^^^^^^^
+
+NSH supports options to provide a start up script for NSH. In general
+this capability is enabled with CONFIG_EXAMPLES_NSH_ROMFSETC, but has
+several other related configuration options as described in the final
+section of this README. This capability also depends on:
+
+ - CONFIG_DISABLE_MOUNTPOINT not set
+ - CONFIG_NFILE_DESCRIPTORS < 4
+ - CONFIG_FS_ROMFS
+
+Default Start-Up Behavior
+-------------------------
+
+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.
+
+In this default case, enabling CONFIG_EXAMPLES_NSH_ROMFSETC will cause
+NSH to behave as follows at NSH startup time:
+
+- NSH will create a read-only RAM disk (a ROM disk), containing a tiny
+ ROMFS filesystem containing the following:
+
+ |--init.d/
+ `-- rcS
+
+ Where rcS is the NSH start-up script
+
+- NSH will then mount the ROMFS filesystem at /etc, resulting in:
+
+ |--dev/
+ | `-- ram0
+ `--etc/
+ `--init.d/
+ `-- rcS
+
+- By default, the contents of rcS script are:
+
+ # Create a RAMDISK and mount it at XXXRDMOUNTPOUNTXXX
+
+ mkrd -m 1 -s 512 1024
+ mkfatfs /dev/ram1
+ mount -t vfat /dev/ram1 /tmp
+
+- NSH will execute the script at /etc/init.d/rcS at start-up (before the
+ first NSH prompt. After execution of the script, the root FS will look
+ like:
+
+ |--dev/
+ | |-- ram0
+ | `-- ram1
+ |--etc/
+ | `--init.d/
+ | `-- rcS
+ `--tmp/
+
+Modifying the ROMFS Image
+-------------------------
+
+The contents of the /etc directory are retained in the file
+examples/nsh/nsh_romfsimg.h. In order to modify the start-up
+behavior, there are three things to study:
+
+1. Configuration Options.
+ The additional CONFIG_EXAMPLES_NSH_ROMFSETC configuration options
+ discussed in the final section of this README.
+
+2. mkromfsimg.sh Script.
+ The script examples/nsh/mkromfsimg.sh creates nsh_romfsimg.h.
+ It is not automatically executed. If you want to change the
+ configuration settings associated with creating and mounting
+ the /tmp directory, then it will be necessary to re-generate
+ this header file using the mkromfsimg.sh script.
+
+ The behavior of this script depends upon three things:
+
+ - The configuration settings then installed configuration.
+ - The genromfs tool (available from http://romfs.sourceforge.net).
+ - The file examples/nsh/rcS.template.
+
+3. rcS.template.
+ The file examples/nsh/rcS.template contains the general form
+ of the rcS file; configurated values are plugged into this
+ template file to produce the final rcS file.
+
+All of the startup-behavior is contained in rcS.template. The
+role of mkromfsimg.sh is to (1) apply the specific configuration
+settings to rcS.template to create the final rcS, and (2) to
+generate the header file nsh_romfsimg.h containg the ROMFS
+file system image.
Simple Commands
^^^^^^^^^^^^^^^