summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-09-11 21:54:23 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-09-11 21:54:23 +0000
commit97d11b18c99ba683fbe91fc3ad5d9b897de27c81 (patch)
tree221d07773f3a6dfb6f566eacf2c97e15e77e935f
parentc89a814396a9e542f05bc8b204b0b6c00dc1bf83 (diff)
downloadnuttx-97d11b18c99ba683fbe91fc3ad5d9b897de27c81.tar.gz
nuttx-97d11b18c99ba683fbe91fc3ad5d9b897de27c81.tar.bz2
nuttx-97d11b18c99ba683fbe91fc3ad5d9b897de27c81.zip
Add /etc via ROMFS and /tmp via FAT FS to NSH
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@910 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/configs/ntosd-dm320/nsh/defconfig47
-rw-r--r--nuttx/configs/xtrs/nsh/defconfig47
-rw-r--r--nuttx/configs/z80sim/nsh/defconfig47
-rw-r--r--nuttx/examples/nsh/Makefile4
-rw-r--r--nuttx/examples/nsh/README.txt50
-rwxr-xr-xnuttx/examples/nsh/mkromfsimg.sh261
-rw-r--r--nuttx/examples/nsh/nsh.h52
-rw-r--r--nuttx/examples/nsh/nsh_fscmds.c43
-rw-r--r--nuttx/examples/nsh/nsh_main.c8
-rw-r--r--nuttx/examples/nsh/nsh_romfsetc.c116
-rw-r--r--nuttx/examples/nsh/nsh_romfsimg.h89
-rw-r--r--nuttx/examples/nsh/nsh_serial.c10
-rw-r--r--nuttx/examples/nsh/nsh_telnetd.c6
-rw-r--r--nuttx/examples/nsh/rcS.template5
14 files changed, 769 insertions, 16 deletions
diff --git a/nuttx/configs/ntosd-dm320/nsh/defconfig b/nuttx/configs/ntosd-dm320/nsh/defconfig
index 737135103..67e06a284 100644
--- a/nuttx/configs/ntosd-dm320/nsh/defconfig
+++ b/nuttx/configs/ntosd-dm320/nsh/defconfig
@@ -337,16 +337,59 @@ CONFIG_EXAMPLES_OSTEST_STACKSIZE=8192
#
# Settings for examples/nsh
+#
+# CONFIG_EXAMPLES_NSH_FILEIOSIZE - Size of a static I/O buffer
+# CONFIG_EXAMPLES_NSH_STRERROR - Use strerror(errno)
+# CONFIG_EXAMPLES_NSH_LINELEN - Maximum length of one command line
+# CONFIG_EXAMPLES_NSH_STACKSIZE - Stack size to use for new threads.
+# CONFIG_EXAMPLES_NSH_NESTDEPTH - Max number of nested if-then[-else]-fi
+# CONFIG_EXAMPLES_NSH_DISABLESCRIPT - Disable scripting support
+# CONFIG_EXAMPLES_NSH_DISABLEBG - Disable background commands
+# CONFIG_EXAMPLES_NSH_ROMFSETC - Use startup script in /etc
+# CONFIG_EXAMPLES_NSH_CONSOLE - Use serial console front end
+# CONFIG_EXAMPLES_NSH_TELNET - Use telnetd console front end
+#
+# If CONFIG_EXAMPLES_NSH_TELNET is selected:
+# CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE -- Telnetd I/O buffer size
+# CONFIG_EXAMPLES_NSH_DHCPC - Obtain address using DHCP
+# CONFIG_EXAMPLES_NSH_IPADDR - Provides static IP address
+# CONFIG_EXAMPLES_NSH_DRIPADDR - Provides static router IP address
+# CONFIG_EXAMPLES_NSH_NETMASK - Provides static network mask
+# CONFIG_EXAMPLES_NSH_NOMAC - Use a bogus MAC address
+#
+# If CONFIG_EXAMPLES_NSH_ROMFSETC is selected:
+# CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT - ROMFS mountpoint
+# CONFIG_EXAMPLES_NSH_INITSCRIPT - Relative path to init script
+# CONFIG_EXAMPLES_NSH_ROMFSDEVNO - ROMFS RAM device minor
+# CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE - ROMF sector size
+# CONFIG_EXAMPLES_NSH_FATDEVNO - FAT FS RAM device minor
+# CONFIG_EXAMPLES_NSH_FATSECTSIZE - FAT FS sector size
+# CONFIG_EXAMPLES_NSH_FATNSECTORS - FAT FS number of sectors
+# CONFIG_EXAMPLES_NSH_FATMOUNTPT - FAT FS mountpoint
+CONFIG_EXAMPLES_NSH_FILEIOSIZE=1024
+CONFIG_EXAMPLES_NSH_STRERROR=n
+CONFIG_EXAMPLES_NSH_LINELEN=80
+CONFIG_EXAMPLES_NSH_STACKSIZE=4096
+CONFIG_EXAMPLES_NSH_NESTDEPTH=3
+CONFIG_EXAMPLES_NSH_DISABLESCRIPT=n
+CONFIG_EXAMPLES_NSH_DISABLEBG=n
+CONFIG_EXAMPLES_NSH_ROMFSETC=y
CONFIG_EXAMPLES_NSH_CONSOLE=y
CONFIG_EXAMPLES_NSH_TELNET=y
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
-CONFIG_EXAMPLES_NSH_CMD_SIZE=40
-CONFIG_EXAMPLES_NSH_STACKSIZE=4096
CONFIG_EXAMPLES_NSH_DHCPC=n
CONFIG_EXAMPLES_NSH_NOMAC=n
CONFIG_EXAMPLES_NSH_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_EXAMPLES_NSH_DRIPADDR=(10<<24|0<<16|0<<8|1)
CONFIG_EXAMPLES_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
+CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT="/etc"
+CONFIG_EXAMPLES_NSH_INITSCRIPT="init.d/rcS"
+CONFIG_EXAMPLES_NSH_ROMFSDEVNO=0
+CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE=64
+CONFIG_EXAMPLES_NSH_FATDEVNO=1
+CONFIG_EXAMPLES_NSH_FATSECTSIZE=512
+CONFIG_EXAMPLES_NSH_FATNSECTORS=1024
+CONFIG_EXAMPLES_NSH_FATMOUNTPT=/tmp
#
# Settings for examples/mount
diff --git a/nuttx/configs/xtrs/nsh/defconfig b/nuttx/configs/xtrs/nsh/defconfig
index 05a7f1e40..6d82c52ba 100644
--- a/nuttx/configs/xtrs/nsh/defconfig
+++ b/nuttx/configs/xtrs/nsh/defconfig
@@ -289,16 +289,59 @@ CONFIG_NET_RESOLV_ENTRIES=4
#
# Settings for examples/nsh
+#
+# CONFIG_EXAMPLES_NSH_FILEIOSIZE - Size of a static I/O buffer
+# CONFIG_EXAMPLES_NSH_STRERROR - Use strerror(errno)
+# CONFIG_EXAMPLES_NSH_LINELEN - Maximum length of one command line
+# CONFIG_EXAMPLES_NSH_STACKSIZE - Stack size to use for new threads.
+# CONFIG_EXAMPLES_NSH_NESTDEPTH - Max number of nested if-then[-else]-fi
+# CONFIG_EXAMPLES_NSH_DISABLESCRIPT - Disable scripting support
+# CONFIG_EXAMPLES_NSH_DISABLEBG - Disable background commands
+# CONFIG_EXAMPLES_NSH_ROMFSETC - Use startup script in /etc
+# CONFIG_EXAMPLES_NSH_CONSOLE - Use serial console front end
+# CONFIG_EXAMPLES_NSH_TELNET - Use telnetd console front end
+#
+# If CONFIG_EXAMPLES_NSH_TELNET is selected:
+# CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE -- Telnetd I/O buffer size
+# CONFIG_EXAMPLES_NSH_DHCPC - Obtain address using DHCP
+# CONFIG_EXAMPLES_NSH_IPADDR - Provides static IP address
+# CONFIG_EXAMPLES_NSH_DRIPADDR - Provides static router IP address
+# CONFIG_EXAMPLES_NSH_NETMASK - Provides static network mask
+# CONFIG_EXAMPLES_NSH_NOMAC - Use a bogus MAC address
+#
+# If CONFIG_EXAMPLES_NSH_ROMFSETC is selected:
+# CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT - ROMFS mountpoint
+# CONFIG_EXAMPLES_NSH_INITSCRIPT - Relative path to init script
+# CONFIG_EXAMPLES_NSH_ROMFSDEVNO - ROMFS RAM device minor
+# CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE - ROMF sector size
+# CONFIG_EXAMPLES_NSH_FATDEVNO - FAT FS RAM device minor
+# CONFIG_EXAMPLES_NSH_FATSECTSIZE - FAT FS sector size
+# CONFIG_EXAMPLES_NSH_FATNSECTORS - FAT FS number of sectors
+# CONFIG_EXAMPLES_NSH_FATMOUNTPT - FAT FS mountpoint
+CONFIG_EXAMPLES_NSH_FILEIOSIZE=1024
+CONFIG_EXAMPLES_NSH_STRERROR=n
+CONFIG_EXAMPLES_NSH_LINELEN=40
+CONFIG_EXAMPLES_NSH_STACKSIZE=1024
+CONFIG_EXAMPLES_NSH_NESTDEPTH=3
+CONFIG_EXAMPLES_NSH_DISABLESCRIPT=n
+CONFIG_EXAMPLES_NSH_DISABLEBG=n
+CONFIG_EXAMPLES_NSH_ROMFSETC=n
CONFIG_EXAMPLES_NSH_CONSOLE=y
CONFIG_EXAMPLES_NSH_TELNET=n
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
-CONFIG_EXAMPLES_NSH_CMD_SIZE=40
-CONFIG_EXAMPLES_NSH_STACKSIZE=1024
CONFIG_EXAMPLES_NSH_DHCPC=n
CONFIG_EXAMPLES_NSH_NOMAC=n
CONFIG_EXAMPLES_NSH_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_EXAMPLES_NSH_DRIPADDR=(10<<24|0<<16|0<<8|1)
CONFIG_EXAMPLES_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
+CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT="/etc"
+CONFIG_EXAMPLES_NSH_INITSCRIPT="init.d/rcS"
+CONFIG_EXAMPLES_NSH_ROMFSDEVNO=0
+CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE=64
+CONFIG_EXAMPLES_NSH_FATDEVNO=1
+CONFIG_EXAMPLES_NSH_FATSECTSIZE=512
+CONFIG_EXAMPLES_NSH_FATNSECTORS=1024
+CONFIG_EXAMPLES_NSH_FATMOUNTPT=/tmp
#
# Stack and heap information
diff --git a/nuttx/configs/z80sim/nsh/defconfig b/nuttx/configs/z80sim/nsh/defconfig
index 2fc1e10de..ea9f1d5de 100644
--- a/nuttx/configs/z80sim/nsh/defconfig
+++ b/nuttx/configs/z80sim/nsh/defconfig
@@ -280,16 +280,59 @@ CONFIG_NET_RESOLV_ENTRIES=4
#
# Settings for examples/nsh
+#
+# CONFIG_EXAMPLES_NSH_FILEIOSIZE - Size of a static I/O buffer
+# CONFIG_EXAMPLES_NSH_STRERROR - Use strerror(errno)
+# CONFIG_EXAMPLES_NSH_LINELEN - Maximum length of one command line
+# CONFIG_EXAMPLES_NSH_STACKSIZE - Stack size to use for new threads.
+# CONFIG_EXAMPLES_NSH_NESTDEPTH - Max number of nested if-then[-else]-fi
+# CONFIG_EXAMPLES_NSH_DISABLESCRIPT - Disable scripting support
+# CONFIG_EXAMPLES_NSH_DISABLEBG - Disable background commands
+# CONFIG_EXAMPLES_NSH_ROMFSETC - Use startup script in /etc
+# CONFIG_EXAMPLES_NSH_CONSOLE - Use serial console front end
+# CONFIG_EXAMPLES_NSH_TELNET - Use telnetd console front end
+#
+# If CONFIG_EXAMPLES_NSH_TELNET is selected:
+# CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE -- Telnetd I/O buffer size
+# CONFIG_EXAMPLES_NSH_DHCPC - Obtain address using DHCP
+# CONFIG_EXAMPLES_NSH_IPADDR - Provides static IP address
+# CONFIG_EXAMPLES_NSH_DRIPADDR - Provides static router IP address
+# CONFIG_EXAMPLES_NSH_NETMASK - Provides static network mask
+# CONFIG_EXAMPLES_NSH_NOMAC - Use a bogus MAC address
+#
+# If CONFIG_EXAMPLES_NSH_ROMFSETC is selected:
+# CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT - ROMFS mountpoint
+# CONFIG_EXAMPLES_NSH_INITSCRIPT - Relative path to init script
+# CONFIG_EXAMPLES_NSH_ROMFSDEVNO - ROMFS RAM device minor
+# CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE - ROMF sector size
+# CONFIG_EXAMPLES_NSH_FATDEVNO - FAT FS RAM device minor
+# CONFIG_EXAMPLES_NSH_FATSECTSIZE - FAT FS sector size
+# CONFIG_EXAMPLES_NSH_FATNSECTORS - FAT FS number of sectors
+# CONFIG_EXAMPLES_NSH_FATMOUNTPT - FAT FS mountpoint
+CONFIG_EXAMPLES_NSH_FILEIOSIZE=1024
+CONFIG_EXAMPLES_NSH_STRERROR=n
+CONFIG_EXAMPLES_NSH_LINELEN=40
+CONFIG_EXAMPLES_NSH_STACKSIZE=1024
+CONFIG_EXAMPLES_NSH_NESTDEPTH=3
+CONFIG_EXAMPLES_NSH_DISABLESCRIPT=n
+CONFIG_EXAMPLES_NSH_DISABLEBG=n
+CONFIG_EXAMPLES_NSH_ROMFSETC=n
CONFIG_EXAMPLES_NSH_CONSOLE=y
CONFIG_EXAMPLES_NSH_TELNET=n
CONFIG_EXAMPLES_NSH_IOBUFFER_SIZE=512
-CONFIG_EXAMPLES_NSH_CMD_SIZE=40
-CONFIG_EXAMPLES_NSH_STACKSIZE=1024
CONFIG_EXAMPLES_NSH_DHCPC=n
CONFIG_EXAMPLES_NSH_NOMAC=n
CONFIG_EXAMPLES_NSH_IPADDR=(10<<24|0<<16|0<<8|2)
CONFIG_EXAMPLES_NSH_DRIPADDR=(10<<24|0<<16|0<<8|1)
CONFIG_EXAMPLES_NSH_NETMASK=(255<<24|255<<16|255<<8|0)
+CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT="/etc"
+CONFIG_EXAMPLES_NSH_INITSCRIPT="init.d/rcS"
+CONFIG_EXAMPLES_NSH_ROMFSDEVNO=0
+CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE=64
+CONFIG_EXAMPLES_NSH_FATDEVNO=1
+CONFIG_EXAMPLES_NSH_FATSECTSIZE=512
+CONFIG_EXAMPLES_NSH_FATNSECTORS=1024
+CONFIG_EXAMPLES_NSH_FATMOUNTPT=/tmp
#
# Stack and heap information
diff --git a/nuttx/examples/nsh/Makefile b/nuttx/examples/nsh/Makefile
index 8e308d43f..b8fa7ae73 100644
--- a/nuttx/examples/nsh/Makefile
+++ b/nuttx/examples/nsh/Makefile
@@ -39,6 +39,10 @@
ASRCS =
CSRCS = nsh_main.c nsh_fscmds.c nsh_proccmds.c nsh_envcmds.c nsh_dbgcmds.c
+ifeq ($(CONFIG_EXAMPLES_NSH_ROMFSETC),y)
+CSRCS += nsh_romfsetc.c
+endif
+
ifeq ($(CONFIG_NET),y)
CSRCS += nsh_netcmds.c
endif
diff --git a/nuttx/examples/nsh/README.txt b/nuttx/examples/nsh/README.txt
index 31ec155cd..7a904ecce 100644
--- a/nuttx/examples/nsh/README.txt
+++ b/nuttx/examples/nsh/README.txt
@@ -634,7 +634,7 @@ NSH-Specific Configuration Settings
* 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.
* CONFIG_EXAMPLES_NSH_STRERROR
strerror(errno) makes more readable output but strerror() is
@@ -666,6 +666,11 @@ NSH-Specific Configuration Settings
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
If CONFIG_EXAMPLES_NSH_CONSOLE is set to 'y', then a serial
console front-end is selected.
@@ -701,3 +706,46 @@ NSH-Specific Configuration Settings
Set if your ethernet hardware has no built-in MAC address.
If set, a bogus MAC will be assigned.
+ If CONFIG_EXAMPLES_NSH_ROMFSETC is selected, then the following additional
+ configuration setting apply:
+
+ * 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 '/'.
+
+ * 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 '/'.
+
+ * 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.
+
+ * 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.
+
+ * CONFIG_EXAMPLES_NSH_FATNSECTORS
+ This is the number of sectors to use with the FAT FS. Defalt is
+ 1024. The amount of memory used by the FAT FS will be
+ CONFIG_EXAMPLES_NSH_FATSECTSIZE * CONFIG_EXAMPLES_NSH_FATNSECTORS
+ bytes.
+
+ * CONFIG_EXAMPLES_NSH_FATMOUNTPT
+ This is the location where the FAT FS will be mounted. Default
+ is /tmp.
diff --git a/nuttx/examples/nsh/mkromfsimg.sh b/nuttx/examples/nsh/mkromfsimg.sh
new file mode 100755
index 000000000..53f573179
--- /dev/null
+++ b/nuttx/examples/nsh/mkromfsimg.sh
@@ -0,0 +1,261 @@
+#!/bin/bash
+############################################################################
+# examples/nsh/mkromfsimg.sh
+#
+# Copyright (C) 2008 Gregory Nutt. All rights reserved.
+# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+# used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+# Environmental stuff
+
+wd=`pwd`
+workingdir=$wd/img
+rcsfile=rcS
+rcstemplate=$rcsfile.template
+romfsimg=romfs.img
+headerfile=nsh_romfsimg.h
+
+# Get the input parameters
+
+topdir=$1
+usage="USAGE: $0 <topdir>"
+
+if [ -z "$topdir" -o ! -d "$topdir" ]; then
+ echo "The full path to the NuttX base directory must be provided on the command line"
+ echo $usage
+ exit 1
+fi
+
+# Extract all values from the .config in the $topdir that contains all of the NuttX
+# configuration settings. The .config file was intended to be include-able by makefiles
+# and source-able by scripts. Unfortunately,there are too many syntactic differents
+# to make that practical
+
+if [ ! -r $topdir/.config ]; then
+ echo "No readable file at $topdir/.config"
+ echo "Has NuttX been configured?"
+ exit 1
+fi
+
+romfsetc=`grep CONFIG_EXAMPLES_NSH_ROMFSETC= $topdir/.config | cut -d'=' -f2`
+disablempt=`grep CONFIG_DISABLE_MOUNTPOINT= $topdir/.config | cut -d'=' -f2`
+disablescript=`grep CONFIG_EXAMPLES_NSH_DISABLESCRIPT= $topdir/.config | cut -d'=' -f2`
+ndescriptors=`grep CONFIG_NFILE_DESCRIPTORS= $topdir/.config | cut -d'=' -f2`
+devconsole=`grep CONFIG_DEV_CONSOLE= $topdir/.config | cut -d'=' -f2`
+romfs=`grep CONFIG_FS_ROMFS= $topdir/.config | cut -d'=' -f2`
+romfsmpt=`grep CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT= $topdir/.config | cut -d'=' -f2`
+initscript=`grep CONFIG_EXAMPLES_NSH_INITSCRIPT= $topdir/.config | cut -d'=' -f2`
+romfsdevno=`grep CONFIG_EXAMPLES_NSH_ROMFSDEVNO= $topdir/.config | cut -d'=' -f2`
+romfssectsize=`grep CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE= $topdir/.config | cut -d'=' -f2`
+fatfs=`grep CONFIG_FS_FAT= $topdir/.config | cut -d'=' -f2`
+fatdevno=`grep CONFIG_EXAMPLES_NSH_FATDEVNO= $topdir/.config | cut -d'=' -f2`
+fatsectsize=`grep CONFIG_EXAMPLES_NSH_FATSECTSIZE= $topdir/.config | cut -d'=' -f2`
+fatnsectors=`grep CONFIG_EXAMPLES_NSH_FATNSECTORS= $topdir/.config | cut -d'=' -f2`
+fatmpt=`grep CONFIG_EXAMPLES_NSH_FATMOUNTPT= $topdir/.config | cut -d'=' -f2`
+
+# The following settings are required for general ROMFS support
+#
+# Mountpoint support must be enabled
+
+if [ "X$disablempt" = "Xy" ]; then
+ echo "Mountpoint support is required for this feature"
+ echo "Set CONFIG_DISABLE_MOUNTPOINT=n to continue"
+ exit 1
+fi
+
+# Scripting support must be enabled
+
+if [ "X$disablescript" = "Xy" ]; then
+ echo "NSH scripting support is required for this feature"
+ echo "Set CONFIG_EXAMPLES_NSH_DISABLESCRIPT=n to continue"
+ exit 1
+fi
+
+# We need at least 2 file descriptors 1 for the ROMFS mount and one for
+# FAT mount performed in rcS. That still wouldn't be enough to to do much
+# with NSH
+
+if [ -z "$ndescriptors" -o "$ndescriptors" -lt 2 ]; then
+ echo "No file descriptors have been allocated"
+ if [ "X$devconsole" = "Xy" ]; then
+ echo "Set CONFIG_NFILE_DESCRIPTORS to value greater than 4"
+ else
+ echo "Set CONFIG_NFILE_DESCRIPTORS to value greater than 1"
+ fi
+ exit 1
+fi
+
+# If a console is enabled, then three more file descriptors are required
+# for stdin, stdout, and stderr
+
+if [ "X$devconsole" = "Xy" -a "$ndescriptors" -lt 5 ]; then
+ echo "Insufficient file descriptors have been allocated"
+ echo "Set CONFIG_NFILE_DESCRIPTORS to value greater than 4"
+fi
+
+# ROMFS support is required, of course
+
+if [ "X$romfs" != "Xy" ]; then
+ echo "ROMFS support is disabled in the NuttX configuration"
+ echo "Set CONFIG_FS_ROMFS=y to continue"
+ exit 0
+fi
+
+# The options in the default rcS.template also require FAT FS support
+
+if [ "X$fatfs" != "Xy" ]; then
+ echo "FAT FS support is disabled in the NuttX configuration"
+ echo "Set CONFIG_FS_FAT=y to continue"
+ exit 0
+fi
+
+# Verify that genromfs has been installed
+
+genromfs -h 1>/dev/null 2>&1 || { \
+ echo "Host executable genromfs not available in PATH"; \
+ echo "You may need to download in from http://romfs.sourceforge.net/"; \
+ exit 1; \
+}
+
+# Supply defaults for all un-defined ROMFS settings
+
+if [ -z "$romfsmpt" ]; then
+ romfsmpt="/etc"
+fi
+if [ -z "$initscript" ]; then
+ initscript="init.d/rcS"
+fi
+if [ -z "$romfsdevno" ]; then
+ romfsdevno=0
+fi
+if [ -z "$romfssectsize" ]; then
+ romfssectsize=64
+fi
+
+# Supply defaults for all un-defined FAT FS settings
+
+if [ -z "$fatdevno" ]; then
+ fatdevno=1
+fi
+if [ -z "$fatsectsize" ]; then
+ fatsectsize=512
+fi
+if [ -z "$fatnsectors" ]; then
+ fatnsectors=1024
+fi
+if [ -z "$fatmpt" ]; then
+ fatmpt="/tmp"
+fi
+
+# Verify the mountpoint. Verify that it is an absolute path but not /, /dev,
+# /., /./*, /.., or /../*
+
+if [ ${romfsmpt:0:1} != "\"" ]; then
+ echo "CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT must be a string"
+ echo "Change it so that it is enclosed in quotes."
+ exit 1
+fi
+
+uromfsmpt=`echo $romfsmpt | sed -e "s/\"//g"`
+
+if [ ${uromfsmpt:0:1} != "/" ]; then
+ echo "CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT must be an absolute path in the target FS"
+ echo "Change it so that it begins with the character '/'. Eg. /etc"
+ exit 1
+fi
+
+tmpdir=$uromfsmpt
+while [ ${tmpdir:0:1} == "/" ]; do
+ tmpdir=${tmpdir:1}
+done
+
+if [ -z "$tmpdir" -o "X$tmpdir" = "Xdev" -o "X$tmpdir" = "." -o \
+ ${tmpdir:0:2} = "./" -o "X$tmpdir" = ".." -o ${tmpdir:0:3} = "../" ]; then
+ echo "Invalid CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT selection."
+ exit 1
+fi
+
+# Verify that the path to the init file is a relative path and not ., ./*, .., or ../*
+
+if [ ${initscript:0:1} != "\"" ]; then
+ echo "CONFIG_EXAMPLES_NSH_INITSCRIPT must be a string"
+ echo "Change it so that it is enclosed in quotes."
+ exit 1
+fi
+
+uinitscript=`echo $initscript | sed -e "s/\"//g"`
+
+if [ ${uinitscript:0:1} == "/" ]; then
+ echo "CONFIG_EXAMPLES_NSH_INITSCRIPT must be an relative path in under $romfsmpt"
+ echo "Change it so that it begins with the character '/'. Eg. init.d/rcS. "
+ exit 1
+fi
+
+if [ "X$uinitscript" = "." -o ${uinitscript:0:2} = "./" -o \
+ "X$uinitscript" = ".." -o ${uinitscript:0:3} = "../" ]; then
+ echo "Invalid CONFIG_EXAMPLES_NSH_INITSCRIPT selection. Must not begin with . or .."
+ exit 1
+fi
+
+# Create a working directory
+
+rm -rf $workingdir || { echo "Failed to remove the old $workingdir"; exit 1; }
+mkdir -p $workingdir || { echo "Failed to created the new $workingdir"; exit 1; }
+
+# Create the rcS file from the rcS.template
+
+if [ ! -r $rcstemplate ]; then
+ echo "$rcstemplete does not exist"
+ rmdir $workingdir
+ exit 1
+fi
+
+cat $rcstemplate | \
+ sed -e "s,XXXMKRDMINORXXX,$fatdevno,g" | \
+ sed -e "s,XXMKRDSECTORSIZEXXX,$fatsectsize,g" | \
+ sed -e "s,XXMKRDBLOCKSXXX,$fatnsectors,g" | \
+ sed -e "s,XXXRDMOUNTPOUNTXXX,$fatmpt,g" >$rcsfile
+
+# And install it at the specified relative location
+
+install -D --mode=0755 $rcsfile $workingdir/$uinitscript || \
+ { echo "Failed to install $rcsfile at $workingdir/$uinitscript"; rm -f $rcsfile; exit 1; }
+rm -f $rcsfile
+
+# Now we are ready to make the ROMFS image
+
+genromfs -f $romfsimg -d $workingdir -V "NSHInitVol" || { echo "genromfs failed" ; exit 1 ; }
+rm -rf $workingdir || { echo "Failed to remove the old $workingdir"; exit 1; }
+
+# And, finally, create the header file
+
+xxd -i $romfsimg >$headerfile || { echo "xxd of $< failed" ; rm -f $romfsimg; exit 1 ; }
+rm -f $romfsimg
diff --git a/nuttx/examples/nsh/nsh.h b/nuttx/examples/nsh/nsh.h
index e35084ead..7626a4e3c 100644
--- a/nuttx/examples/nsh/nsh.h
+++ b/nuttx/examples/nsh/nsh.h
@@ -64,6 +64,49 @@
# error "No NSH front end defined"
#endif
+/* Verify support for ROMFS /etc directory support options */
+
+#ifdef CONFIG_EXAMPLES_NSH_ROMFSETC
+# ifdef CONFIG_DISABLE_MOUNTPOINT
+# error "Mountpoint support is disabled"
+# undef CONFIG_EXAMPLES_NSH_ROMFSETC
+# endif
+# if CONFIG_NFILE_DESCRIPTORS < 4
+# error "Not enough file descriptors"
+# undef CONFIG_EXAMPLES_NSH_ROMFSETC
+# endif
+# ifndef CONFIG_FS_ROMFS
+# error "ROMFS support not enabled"
+# undef CONFIG_EXAMPLES_NSH_ROMFSETC
+# endif
+# ifndef CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT
+# define CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT "/etc"
+# endif
+# ifdef CONFIG_EXAMPLES_NSH_INIT
+# ifndef CONFIG_EXAMPLES_NSH_INITSCRIPT
+# define CONFIG_EXAMPLES_NSH_INITSCRIPT "init.d/rcS"
+# endif
+# endif
+# undef NSH_INITPATH
+# define NSH_INITPATH CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT "/" CONFIG_EXAMPLES_NSH_INITSCRIPT
+# ifndef CONFIG_EXAMPLES_NSH_ROMFSDEVNO
+# define CONFIG_EXAMPLES_NSH_ROMFSDEVNO 0
+# endif
+# ifndef CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE
+# define CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE 64
+# endif
+# define NSECTORS(b) (((b)+CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE-1)/CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE)
+# define STR_RAMDEVNO(m) #m
+# define MKMOUNT_DEVNAME(m) "/dev/ram" STR_RAMDEVNO(m)
+# define MOUNT_DEVNAME MKMOUNT_DEVNAME(CONFIG_EXAMPLES_NSH_ROMFSDEVNO)
+#else
+# undef CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT
+# undef CONFIG_EXAMPLES_NSH_INIT
+# undef CONFIG_EXAMPLES_NSH_INITSCRIPT
+# undef CONFIG_EXAMPLES_NSH_ROMFSDEVNO
+# undef CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE
+#endif
+
/* This is the maximum number of arguments that will be accepted for a command */
#define NSH_MAX_ARGUMENTS 6
@@ -237,6 +280,15 @@ extern const char g_fmtinternalerror[];
* Public Function Prototypes
****************************************************************************/
+/* Initialization */
+
+#ifdef CONFIG_EXAMPLES_NSH_ROMFSETC
+extern int nsh_romfsetc(void);
+#endif
+#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0 && !defined(CONFIG_EXAMPLES_NSH_DISABLESCRIPT)
+extern int nsh_script(FAR struct nsh_vtbl_s *vtbl, const char *cmd, const char *path);
+#endif
+
/* Message handler */
extern int nsh_parse(FAR struct nsh_vtbl_s *vtbl, char *cmdline);
diff --git a/nuttx/examples/nsh/nsh_fscmds.c b/nuttx/examples/nsh/nsh_fscmds.c
index d38d9b720..33d1ae6d2 100644
--- a/nuttx/examples/nsh/nsh_fscmds.c
+++ b/nuttx/examples/nsh/nsh_fscmds.c
@@ -218,6 +218,17 @@ static int foreach_direntry(FAR struct nsh_vtbl_s *vtbl, const char *cmd, const
#endif
/****************************************************************************
+ * Name: ls_specialdir
+ ****************************************************************************/
+
+static inline int ls_specialdir(const char *dir)
+{
+ /* '.' and '..' directories are not listed like normal directories */
+
+ return (strcmp(dir, ".") == 0 || strcmp(dir, "..") == 0);
+}
+
+/****************************************************************************
* Name: ls_handler
****************************************************************************/
@@ -322,7 +333,7 @@ static int ls_handler(FAR struct nsh_vtbl_s *vtbl, const char *dirpath, struct d
nsh_output(vtbl, " %s", entryp->d_name);
#endif
- if (DIRENT_ISDIRECTORY(entryp->d_type))
+ if (DIRENT_ISDIRECTORY(entryp->d_type) && !ls_specialdir(entryp->d_name))
{
nsh_output(vtbl, "/\n");
}
@@ -339,12 +350,14 @@ static int ls_handler(FAR struct nsh_vtbl_s *vtbl, const char *dirpath, struct d
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
-static int ls_recursive(FAR struct nsh_vtbl_s *vtbl, const char *dirpath, struct dirent *entryp, void *pvarg)
+static int ls_recursive(FAR struct nsh_vtbl_s *vtbl, const char *dirpath,
+ struct dirent *entryp, void *pvarg)
{
int ret = OK;
- /* Is this entry a directory? */
- if (DIRENT_ISDIRECTORY(entryp->d_type))
+ /* Is this entry a directory (and not one of the special directories, . and ..)? */
+
+ if (DIRENT_ISDIRECTORY(entryp->d_type) && !ls_specialdir(entryp->d_name))
{
/* Yes.. */
@@ -354,6 +367,9 @@ static int ls_recursive(FAR struct nsh_vtbl_s *vtbl, const char *dirpath, struct
/* List the directory contents */
nsh_output(vtbl, "%s:\n", newpath);
+
+ /* Traverse the directory */
+
ret = foreach_direntry(vtbl, "ls", newpath, ls_handler, pvarg);
if (ret == 0)
{
@@ -1002,11 +1018,11 @@ int cmd_rmdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
#endif
/****************************************************************************
- * Name: cmd_sh
+ * Name: nsh_script
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0 && !defined(CONFIG_EXAMPLES_NSH_DISABLESCRIPT)
-int cmd_sh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
+int nsh_script(FAR struct nsh_vtbl_s *vtbl, const char *cmd, const char *path)
{
char *fullpath;
FILE *stream;
@@ -1016,7 +1032,7 @@ int cmd_sh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
/* The path to the script may be relative to the current working directory */
- fullpath = nsh_getfullpath(vtbl, argv[1]);
+ fullpath = nsh_getfullpath(vtbl, path);
if (!fullpath)
{
return ERROR;
@@ -1032,7 +1048,7 @@ int cmd_sh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
stream = fopen(fullpath, "r");
if (!stream)
{
- nsh_output(vtbl, g_fmtcmdfailed, argv[0], "fopen", NSH_ERRNO);
+ nsh_output(vtbl, g_fmtcmdfailed, cmd, "fopen", NSH_ERRNO);
nsh_freefullpath(fullpath);
return ERROR;
}
@@ -1067,6 +1083,17 @@ int cmd_sh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
#endif
/****************************************************************************
+ * Name: cmd_sh
+ ****************************************************************************/
+
+#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0 && !defined(CONFIG_EXAMPLES_NSH_DISABLESCRIPT)
+int cmd_sh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
+{
+ return nsh_script(vtbl, argv[0], argv[1]);
+}
+#endif
+
+/****************************************************************************
* Name: cmd_umount
****************************************************************************/
diff --git a/nuttx/examples/nsh/nsh_main.c b/nuttx/examples/nsh/nsh_main.c
index c893d2902..20204d902 100644
--- a/nuttx/examples/nsh/nsh_main.c
+++ b/nuttx/examples/nsh/nsh_main.c
@@ -218,7 +218,7 @@ static const struct cmdmap_s g_cmdmap[] =
* Public Data
****************************************************************************/
-const char g_nshgreeting[] = "NuttShell (NSH)\n";
+const char g_nshgreeting[] = "\nNuttShell (NSH)\n";
const char g_nshprompt[] = "nsh> ";
const char g_nshsyntax[] = "nsh: %s: syntax error\n";
const char g_fmtargrequired[] = "nsh: %s: missing required argument(s)\n";
@@ -853,6 +853,12 @@ int user_start(int argc, char *argv[])
int ret;
#endif
+ /* Mount the /etc filesystem */
+
+#ifdef CONFIG_EXAMPLES_NSH_ROMFSETC
+ (void)nsh_romfsetc();
+#endif
+
/* Set the priority of this task to something in the middle so that 'nice'
* can both raise and lower the priority.
*/
diff --git a/nuttx/examples/nsh/nsh_romfsetc.c b/nuttx/examples/nsh/nsh_romfsetc.c
new file mode 100644
index 000000000..0370a00bb
--- /dev/null
+++ b/nuttx/examples/nsh/nsh_romfsetc.c
@@ -0,0 +1,116 @@
+/****************************************************************************
+ * examples/nsh/nsh_romfsetc.c
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <sys/mount.h>
+#include <debug.h>
+#include <errno.h>
+
+#include <nuttx/ramdisk.h>
+
+#include "nsh.h"
+
+#ifdef CONFIG_EXAMPLES_NSH_ROMFSETC
+
+#include "nsh_romfsimg.h"
+
+/****************************************************************************
+ * Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nsh_romfsetc
+ ****************************************************************************/
+
+int nsh_romfsetc(void)
+{
+ int ret;
+
+ /* Create a ROM disk for the /etc filesystem */
+
+ ret = romdisk_register(CONFIG_EXAMPLES_NSH_ROMFSDEVNO, romfs_img,
+ NSECTORS(romfs_img_len), CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE);
+ if (ret < 0)
+ {
+ dbg("nsh: romdisk_register failed: %d\n", -ret);
+ return ERROR;
+ }
+
+ /* Mount the file system */
+
+ vdbg("Mounting ROMFS filesystem at target=%s with source=%s\n",
+ CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT, MOUNT_DEVNAME);
+
+ ret = mount(MOUNT_DEVNAME, CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT, "romfs", MS_RDONLY, NULL);
+ if (ret < 0)
+ {
+ dbg("nsh: mount(%s,%s,romfs) failed: %s\n",
+ MOUNT_DEVNAME, CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT, errno);
+ return ERROR;
+ }
+ return OK;
+}
+
+#endif /* CONFIG_EXAMPLES_NSH_ROMFSETC */ \ No newline at end of file
diff --git a/nuttx/examples/nsh/nsh_romfsimg.h b/nuttx/examples/nsh/nsh_romfsimg.h
new file mode 100644
index 000000000..49b0ad166
--- /dev/null
+++ b/nuttx/examples/nsh/nsh_romfsimg.h
@@ -0,0 +1,89 @@
+unsigned char romfs_img[] = {
+ 0x2d, 0x72, 0x6f, 0x6d, 0x31, 0x66, 0x73, 0x2d, 0x00, 0x00, 0x01, 0x50,
+ 0x9f, 0x13, 0x82, 0x87, 0x4e, 0x53, 0x48, 0x49, 0x6e, 0x69, 0x74, 0x56,
+ 0x6f, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49,
+ 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0xd1, 0xff, 0xff, 0x97,
+ 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x20,
+ 0x00, 0x00, 0x00, 0x00, 0xd1, 0xd1, 0xff, 0x80, 0x2e, 0x2e, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
+ 0x68, 0x2d, 0x96, 0x03, 0x69, 0x6e, 0x69, 0x74, 0x2e, 0x64, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0,
+ 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0xd1, 0xff, 0xff, 0x00,
+ 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3a, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x6e, 0x8d, 0x9c, 0xab, 0x58, 0x72, 0x63, 0x53, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x23, 0x20, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x20, 0x61, 0x20, 0x52,
+ 0x41, 0x4d, 0x44, 0x49, 0x53, 0x4b, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6d,
+ 0x6f, 0x75, 0x6e, 0x74, 0x20, 0x69, 0x74, 0x20, 0x61, 0x74, 0x20, 0x2f,
+ 0x74, 0x6d, 0x70, 0x0a, 0x0a, 0x6d, 0x6b, 0x72, 0x64, 0x20, 0x2d, 0x6d,
+ 0x20, 0x32, 0x20, 0x2d, 0x73, 0x20, 0x35, 0x31, 0x32, 0x20, 0x31, 0x30,
+ 0x32, 0x34, 0x0a, 0x6d, 0x6b, 0x66, 0x61, 0x74, 0x66, 0x73, 0x20, 0x2f,
+ 0x64, 0x65, 0x76, 0x2f, 0x72, 0x61, 0x6d, 0x32, 0x0a, 0x6d, 0x6f, 0x75,
+ 0x6e, 0x74, 0x20, 0x2d, 0x74, 0x20, 0x76, 0x66, 0x61, 0x74, 0x20, 0x2f,
+ 0x64, 0x65, 0x76, 0x2f, 0x72, 0x61, 0x6d, 0x32, 0x20, 0x2f, 0x74, 0x6d,
+ 0x70, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
+ 0x00, 0x00, 0x00, 0x00, 0xd1, 0xd1, 0xff, 0xe0, 0x2e, 0x2e, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
+};
+unsigned int romfs_img_len = 1024;
diff --git a/nuttx/examples/nsh/nsh_serial.c b/nuttx/examples/nsh/nsh_serial.c
index 94ebca267..90107bb67 100644
--- a/nuttx/examples/nsh/nsh_serial.c
+++ b/nuttx/examples/nsh/nsh_serial.c
@@ -333,9 +333,19 @@ int nsh_consolemain(int argc, char *argv[])
{
FAR struct serial_s *pstate = nsh_allocstruct();
+ /* Present a greeting */
+
printf(g_nshgreeting);
fflush(pstate->ss_stream);
+ /* Execute the startup script */
+
+#ifdef CONFIG_EXAMPLES_NSH_ROMFSETC
+ (void)nsh_script(&pstate->ss_vtbl, "init", NSH_INITPATH);
+#endif
+
+ /* Then enter the command line parsing loop */
+
for (;;)
{
/* Display the prompt string */
diff --git a/nuttx/examples/nsh/nsh_telnetd.c b/nuttx/examples/nsh/nsh_telnetd.c
index dd679cf39..5e0fa7d4d 100644
--- a/nuttx/examples/nsh/nsh_telnetd.c
+++ b/nuttx/examples/nsh/nsh_telnetd.c
@@ -478,6 +478,12 @@ static void *nsh_connection(void *arg)
nsh_output(&pstate->tn_vtbl, g_nshgreeting);
+ /* Execute the startup script */
+
+#if defined(CONFIG_EXAMPLES_NSH_ROMFSETC) && !defined(CONFIG_EXAMPLES_NSH_CONSOLE)
+ (void)nsh_script(&pstate->tn_vtbl, "init", NSH_INITPATH);
+#endif
+
/* Loop processing each TELNET command */
do
diff --git a/nuttx/examples/nsh/rcS.template b/nuttx/examples/nsh/rcS.template
new file mode 100644
index 000000000..996f37fb1
--- /dev/null
+++ b/nuttx/examples/nsh/rcS.template
@@ -0,0 +1,5 @@
+# Create a RAMDISK and mount it at XXXRDMOUNTPOUNTXXX
+
+mkrd -m XXXMKRDMINORXXX -s XXMKRDSECTORSIZEXXX XXMKRDBLOCKSXXX
+mkfatfs /dev/ramXXXMKRDMINORXXX
+mount -t vfat /dev/ramXXXMKRDMINORXXX XXXRDMOUNTPOUNTXXX