boards/sim: support rc.sysinit
Follow: http://glennastory.net/boot/sysinit.html This is first script that init runs is rc.sysinit. This script does serval initialization tasks about basic service. The boot sequence currently provided to the board level is: board_earlyinitialize-> board_lateinitialize(Peripherals driver, core driver, ...)-> run rcS script(mount fs, run service) -> board_appinitialize-> After this patch: The boot sequence currently provided to the board level is: board_earlyinitialize-> board_lateinitialize(core driver,...)-> run rc.sysinit script(mount fs, run core service) -> board_appinitialize(Peripherals driver)-> run rcS script(run other service)-> So, Peripheral drivers can do more with the file system and core services. Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
c29a3b7bd8
commit
de1c184e6c
@ -298,9 +298,10 @@ Configuration Description
|
||||
registered as ``/dev/mmcsd``\ *N* where *N* is the minor number.
|
||||
Default is zero.
|
||||
|
||||
``CONFIG_NSH_ROMFSETC`` Mount a ROMFS file system at ``/etc`` and provide a startup
|
||||
script at ``/etc/init.d/rcS``.
|
||||
The default startup script will mount a FAT FS RAMDISK at
|
||||
``CONFIG_NSH_ROMFSETC`` Mount a ROMFS file system at ``/etc`` and provide a system init
|
||||
script at ``/etc/init.d.rc.sysinit`` and a startup script at
|
||||
``/etc/init.d/rcS``.
|
||||
The default system init script will mount a FAT FS RAMDISK at
|
||||
``/tmp`` but the logic is `easily extensible <#startupscript>`__.
|
||||
|
||||
``CONFIG_NSH_CONSOLE`` If ``CONFIG_NSH_CONSOLE`` is set to *y*, then a serial console
|
||||
@ -462,6 +463,9 @@ Configuration Description
|
||||
``CONFIG_NSH_ROMFSMOUNTPT`` The default mountpoint for the ROMFS volume is ``"/etc"``,
|
||||
but that can be changed with this setting. This must be a
|
||||
absolute path beginning with '``/``' and enclosed in quotes.
|
||||
``CONFIG_NSH_SYSINITSCRIPT`` This is the relative path to the system init script within the
|
||||
mountpoint. The default is ``"init.d/rc.sysinit"``. This is a relative
|
||||
path and must not start with '``/``' but must be enclosed in quotes.
|
||||
``CONFIG_NSH_INITSCRIPT`` This is the relative path to the startup script within the
|
||||
mountpoint. The default is ``"init.d/rcS"``. This is a relative
|
||||
path and must not start with '``/``' but must be enclosed in quotes.
|
||||
@ -473,7 +477,7 @@ Configuration Description
|
||||
Any value selected must be a power of 2.
|
||||
============================== ==============================================================
|
||||
|
||||
When the default ``rcS`` file used when ``CONFIG_NSH_ROMFSETC`` is
|
||||
When the default ``rc.sysinit`` file used when ``CONFIG_NSH_ROMFSETC`` is
|
||||
selected, it will mount a FAT FS under ``/tmp``. The following
|
||||
selections describe that FAT FS.
|
||||
|
||||
|
@ -46,18 +46,18 @@ does the following:
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The NSH initialization function, ``nsh_initialize()``, be found in
|
||||
``apps/nshlib/nsh_init.c``. It does only three things:
|
||||
``apps/nshlib/nsh_init.c``. It does only four things:
|
||||
|
||||
#. ``nsh_romfsetc()``: If so configured, it executes an NSH start-up
|
||||
script that can be found at ``/etc/init.d/rcS`` in the target file
|
||||
system. The ``nsh_romfsetc()`` function can be found in
|
||||
``apps/nshlib/nsh_romfsetc.c``. This function will (1) register a
|
||||
ROMFS file system, then (2) mount the ROMFS file system. ``/etc`` is
|
||||
the default location where a read-only, ROMFS file system is mounted
|
||||
by ``nsh_romfsetc()``.
|
||||
#. ``nsh_romfsetc()``: If so configured, it executes NSH system init and
|
||||
start-up script that can be found at ``/etc/init.d/rc.sysinit`` and
|
||||
``/etc/init.d/rcS`` in the target file system. The ``nsh_romfsetc()``
|
||||
function can be found in ``apps/nshlib/nsh_romfsetc.c``.
|
||||
This function will (1) register a ROMFS file system, then (2) mount
|
||||
the ROMFS file system. ``/etc`` is the default location where a
|
||||
read-only, ROMFS file system is mounted by ``nsh_romfsetc()``.
|
||||
|
||||
The ROMFS image is, itself, just built into the firmware. By default,
|
||||
this ``rcS`` start-up script contains the following logic::
|
||||
this ``rc.sysinit`` system init script contains the following logic::
|
||||
|
||||
# Create a RAMDISK and mount it at XXXRDMOUNTPOINTXXX
|
||||
|
||||
@ -79,7 +79,7 @@ The NSH initialization function, ``nsh_initialize()``, be found in
|
||||
- ``XXXRDMOUNTPOINTXXX`` will become the configured mount point.
|
||||
Default: ``/etc``
|
||||
|
||||
By default, the substituted values would yield an ``rcS`` file like::
|
||||
By default, the substituted values would yield an ``rc.sysinit`` file like::
|
||||
|
||||
# Create a RAMDISK and mount it at /tmp
|
||||
|
||||
@ -96,8 +96,8 @@ The NSH initialization function, ``nsh_initialize()``, be found in
|
||||
|
||||
- Mount the FAT file system at a configured mountpoint, ``/tmp``.
|
||||
|
||||
This ``rcS`` template file can be found at
|
||||
``apps/nshlib/rcS.template``. The resulting ROMFS file system can be
|
||||
This ``rc.sysinit.template`` template file can be found at
|
||||
``apps/nshlib/rc.sysinit.template``. The resulting ROMFS file system can be
|
||||
found in ``apps/nshlib/nsh_romfsimg.h``.
|
||||
|
||||
#. ``board_app_initialize()``: Next any architecture-specific NSH
|
||||
@ -110,6 +110,13 @@ The NSH initialization function, ``nsh_initialize()``, be found in
|
||||
#. ``nsh_netinit()``: The ``nsh_netinit()`` function can be found in
|
||||
``apps/nshlib/nsh_netinit.c``.
|
||||
|
||||
#. The start-up script ``rcS`` is executed after the system-init script
|
||||
to startup some application and other system service.
|
||||
|
||||
This ``rcS`` template file can be found at
|
||||
``apps/nshlib/rcS.template``. The resulting ROMFS file system can be
|
||||
found in ``apps/nshlib/nsh_romfsimg.h``.
|
||||
|
||||
NSH Commands
|
||||
************
|
||||
|
||||
|
@ -61,8 +61,10 @@ behave as follows at NSH start-up time:
|
||||
|
||||
`--init.d/
|
||||
`-- rcS
|
||||
`-- rc.sysinit
|
||||
|
||||
Where ``rcS`` is the NSH start-up script.
|
||||
Where ``rc.sysinit`` is the NSH system-init script.
|
||||
|
||||
- NSH will then mount the ROMFS file system at ``/etc``, resulting in::
|
||||
|
||||
@ -71,8 +73,9 @@ behave as follows at NSH start-up time:
|
||||
`--etc/
|
||||
`--init.d/
|
||||
`-- rcS
|
||||
`-- rc.sysinit
|
||||
|
||||
- By default, the contents of ``rcS`` script are::
|
||||
- By default, the contents of ``rc.sysinit`` script are::
|
||||
|
||||
# Create a RAMDISK and mount it at /tmp
|
||||
|
||||
@ -80,9 +83,9 @@ behave as follows at NSH start-up time:
|
||||
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::
|
||||
- NSH will execute the script at ``/etc/init.d/rc.sysinit`` at system
|
||||
init (before the first NSH prompt). After execution of the script,
|
||||
the root FS will look like::
|
||||
|
||||
|--dev/
|
||||
| |-- ram0
|
||||
@ -90,6 +93,7 @@ behave as follows at NSH start-up time:
|
||||
|--etc/
|
||||
| `--init.d/
|
||||
| `-- rcS
|
||||
| `-- rc.sysinit
|
||||
`--tmp/
|
||||
|
||||
**Example Configurations**. Here are some configurations that have
|
||||
@ -105,15 +109,16 @@ provide useful examples:
|
||||
- ``boards/sim/sim/sim/touchscreen``
|
||||
|
||||
In most of these cases, the configuration sets up the *default*
|
||||
``/etc/init.d/rcS`` script. The default script is here:
|
||||
``apps/nshlib/rcS.template``. (The funny values in the template like
|
||||
``XXXMKRDMINORXXX`` get replaced via ``sed`` at build time). This
|
||||
``/etc/init.d/rc.sysinit`` and ``/etc/init.d/rcS`` script. The default
|
||||
script is here: ``apps/nshlib/rc.sysinit.template`` and
|
||||
``apps/nshlib/rcS.template``. (The funny values in the rc.sysinit.template
|
||||
like ``XXXMKRDMINORXXX`` get replaced via ``sed`` at build time). This
|
||||
default configuration creates a ramdisk and mounts it at ``/tmp`` as
|
||||
discussed above.
|
||||
|
||||
If that default behavior is not what you want, then you can provide your
|
||||
own custom ``rcS`` script by defining ``CONFIG_NSH_ARCHROMFS=y`` in the
|
||||
configuration file.
|
||||
own custom ``rc.sysinit`` and ``rcS`` script by defining
|
||||
``CONFIG_NSH_ARCHROMFS=y`` in the configuration file.
|
||||
|
||||
**Modifying the ROMFS Image**. The contents of the ``/etc`` directory
|
||||
are retained in the file ``apps/nshlib/nsh_romfsimg.h`` OR, if
|
||||
@ -146,21 +151,34 @@ behavior, there are three things to study:
|
||||
is a normal part of a complete Linux or Cygwin installation,
|
||||
usually as part of the ``vi`` package).
|
||||
|
||||
#. The file ``apps/nshlib/rcS.template`` (OR, if
|
||||
#. The file ``apps/nshlib/rc.sysinit.template`` (OR, if
|
||||
``CONFIG_NSH_ARCHROMFS`` is defined
|
||||
``include/arch/board/rc.sysinit.template``.
|
||||
|
||||
The file ``apps/nshlib/rcS.template`` (OR, if
|
||||
``CONFIG_NSH_ARCHROMFS`` is defined
|
||||
``include/arch/board/rcs.template``.
|
||||
|
||||
#. ``rcS.template``. The file ``apps/nshlib/rcS.template`` contains the
|
||||
#. ``rc.sysinit.template``. The file ``apps/nshlib/rc.sysinit.template``
|
||||
contains the general form of the ``rc.sysinit`` file; configured values
|
||||
are plugged into this template file to produce the final ``rc.sysinit`` file.
|
||||
|
||||
``rcS.template``. The file ``apps/nshlib/rcS.template`` contains the
|
||||
general form of the ``rcS`` file; configured values are plugged into
|
||||
this template file to produce the final ``rcS`` file.
|
||||
|
||||
To generate a custom ``rcS`` file a copy of ``rcS.template`` needs to
|
||||
To generate a custom ``rc.sysinit`` and ``rcS`` file a copy of
|
||||
``rc.sysinit.template`` and ``rcS.template`` needs to
|
||||
be placed at ``tools/`` and changed according to the desired start-up
|
||||
behaviour. Running ``tools/mkromfsimg.h`` creates ``nsh_romfsimg.h``
|
||||
which needs to be copied to ``apps/nshlib`` OR if
|
||||
``CONFIG_NSH_ARCHROMFS`` is defined to
|
||||
``boards/<arch>/<chip>/<board>/include``.
|
||||
|
||||
``rc.sysinit.template``. The default ``rc.sysinit.template``,
|
||||
``apps/nshlib/rc.sysinit.template``, generates the standard, default
|
||||
``apps/nshlib/nsh_romfsimg.h`` file.
|
||||
|
||||
``rcS.template``. The default ``rcS.template``,
|
||||
``apps/nshlib/rcS.template``, generates the standard, default
|
||||
``apps/nshlib/nsh_romfsimg.h`` file.
|
||||
@ -171,10 +189,11 @@ then a custom, board-specific ``nsh_romfsimg.h`` file residing in
|
||||
is configured, ``include/arch/board`` will be linked to
|
||||
``boards/<arch>/<chip>/<board>/include``.
|
||||
|
||||
All of the startup-behavior is contained in ``rcS.template``. The role
|
||||
of ``mkromfsimg.sh`` script 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`` containing the ROMFS file
|
||||
All of the startup-behavior is contained in ``rc.sysinit.template`` and
|
||||
``rcS.template``. The role of ``mkromfsimg.sh`` script is to (1) apply
|
||||
the specific configuration settings to ``rc.sysinit.template`` to create
|
||||
the final ``rc.sysinit``, and ``rcS.template`` to create the final ``rcS``,
|
||||
and (2) to generate the header file ``nsh_romfsimg.h`` containing the ROMFS file
|
||||
system image. To do this, ``mkromfsimg.sh`` uses two tools that must be
|
||||
installed in your system:
|
||||
|
||||
|
@ -164,9 +164,11 @@ and containing the password file, ``passwd`` like::
|
||||
/etc/init.d:
|
||||
dr-xr-xr-x 0 ..
|
||||
-r--r--r-- 110 rcS
|
||||
-r--r--r-- 110 rc.sysinit
|
||||
nsh>
|
||||
|
||||
Where ``/etc/init.d/rcS`` is the start-up script; ``/etc/passwd`` is a
|
||||
Where ``/etc/init.d/rc.sysinit`` is the system init script and
|
||||
``/etc/init.d/rcS`` is the start-up script; ``/etc/passwd`` is a
|
||||
the password file. Note that here we assume that you are already using a
|
||||
start-up script. We can then piggyback the passwd file into the ``/etc``
|
||||
file system already mounted for the NSH start up file as described above
|
||||
|
@ -276,8 +276,10 @@ NSH to behave as follows at NSH startup time:
|
||||
|
||||
`--init.d/
|
||||
`-- rcS
|
||||
`-- rc.sysinit
|
||||
|
||||
Where rcS is the NSH start-up script.
|
||||
Where rc.sysinit is the NSH system init script.
|
||||
|
||||
- NSH will then mount the ROMFS file system at ``/etc``,
|
||||
resulting in::
|
||||
@ -287,8 +289,9 @@ NSH to behave as follows at NSH startup time:
|
||||
`--etc/
|
||||
`--init.d/
|
||||
`-- rcS
|
||||
`-- rc.sysinit
|
||||
|
||||
- By default, the contents of rcS script are::
|
||||
- By default, the contents of rc.sysinit script are::
|
||||
|
||||
# Create a RAMDISK and mount it at XXXRDMOUNTPOINTXXX
|
||||
|
||||
@ -296,9 +299,9 @@ NSH to behave as follows at NSH startup time:
|
||||
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::
|
||||
- NSH will execute the script at ``/etc/init.d/rc.sysinit`` at
|
||||
system init script(before the first NSH prompt). After
|
||||
execution of the script, the root FS will look like::
|
||||
|
||||
|--dev/
|
||||
| |-- ram0
|
||||
@ -306,6 +309,7 @@ NSH to behave as follows at NSH startup time:
|
||||
|--etc/
|
||||
| `--init.d/
|
||||
| `-- rcS
|
||||
| `-- rc.sysinit
|
||||
`--tmp/
|
||||
|
||||
**Modifying the ROMFS Image**. The contents of the ``/etc``
|
||||
@ -330,28 +334,37 @@ start-up behavior, there are three things to study:
|
||||
- The configuration settings then installed configuration.
|
||||
- The ``genromfs`` tool (available from
|
||||
http://romfs.sourceforge.net).
|
||||
- The file ``apps/nshlib/rcS.template`` (OR, if
|
||||
- The file ``apps/nshlib/rc.sysinit.template`` (OR, if
|
||||
``CONFIG_NSH_ARCHROMFS`` is defined
|
||||
``include/arch/board/rc.sysinit.template``.
|
||||
The file ``apps/nshlib/rcS.template`` (OR, if
|
||||
``CONFIG_NSH_ARCHROMFS`` is defined
|
||||
``include/arch/board/rcs.template``.
|
||||
|
||||
#. ``rcS.template``: The file ``apps/nshlib/rcS.template``
|
||||
#. ``rc.sysinit.template``: The file ``apps/nshlib/rc.sysinit.template``
|
||||
contains the general form of the ``rc.sysinit`` file; configured
|
||||
values are plugged into this template file to produce the final
|
||||
``rc.sysinit`` file.
|
||||
|
||||
``rcS.template``: The file ``apps/nshlib/rcS.template``
|
||||
contains the general form of the ``rcS`` file; configured
|
||||
values are plugged into this template file to produce the final
|
||||
``rcS`` file.
|
||||
|
||||
.. note::
|
||||
``apps/nshlib/rcS.template`` generates the standard,
|
||||
default ``nsh_romfsimg.h`` file. If ``CONFIG_NSH_ARCHROMFS`` is
|
||||
defined in the NuttX configuration file, then a custom,
|
||||
board-specific ``nsh_romfsimg.h`` file residing in the
|
||||
``boards/<arch>/<chip>/<board>/include`` directory will be used.
|
||||
NOTE when the OS is configured, ``include/arch/board`` will be
|
||||
``apps/nshlib/rcS.template`` and ``apps/nshlib/rc.sysinit.template``
|
||||
generates the standard, default ``nsh_romfsimg.h`` file.
|
||||
If ``CONFIG_NSH_ARCHROMFS`` is defined in the NuttX configuration
|
||||
file, then a custom, board-specific ``nsh_romfsimg.h`` file residing
|
||||
in the ``boards/<arch>/<chip>/<board>/include`` directory will be
|
||||
used. NOTE when the OS is configured, ``include/arch/board`` will be
|
||||
linked to ``boards/<arch>/<chip>/<board>/include``.
|
||||
|
||||
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``
|
||||
All of the startup-behavior is contained in ``rc.sysinit.template``
|
||||
and ``rcS.template``. The role of ``mkromfsimg.sh`` is to (1) apply
|
||||
the specific configuration settings to ``rc.sysinit.template`` to create
|
||||
the final ``rc.sysinit``, and ``rc.sysinit.template`` to create the final
|
||||
``rcS`` and (2) to generate the header file ``nsh_romfsimg.h``
|
||||
containing the ROMFS file system image.
|
||||
|
||||
**Further Information**. See the section on `Customizing the
|
||||
|
12
boards/arm/sama5/sama5d4-ek/include/rc.sysinit.template
Normal file
12
boards/arm/sama5/sama5d4-ek/include/rc.sysinit.template
Normal file
@ -0,0 +1,12 @@
|
||||
# Mount the procfs file system at /proc
|
||||
|
||||
mount -t procfs /proc
|
||||
echo "rc.sysinit: Mounted /proc"
|
||||
|
||||
# Create a RAMDISK at /dev/ram1, size 0.5MiB, format it with a FAT
|
||||
# file system and mount it at /tmp
|
||||
|
||||
mkrd -m 1 -s 512 1024
|
||||
mkfatfs /dev/ram1
|
||||
mount -t vfat /dev/ram1 /tmp
|
||||
echo "rc.sysinit: Mounted /tmp"
|
@ -1,12 +0,0 @@
|
||||
# Mount the procfs file system at /proc
|
||||
|
||||
mount -t procfs /proc
|
||||
echo "rcS: Mounted /proc"
|
||||
|
||||
# Create a RAMDISK at /dev/ram1, size 0.5MiB, format it with a FAT
|
||||
# file system and mount it at /tmp
|
||||
|
||||
mkrd -m 1 -s 512 1024
|
||||
mkfatfs /dev/ram1
|
||||
mount -t vfat /dev/ram1 /tmp
|
||||
echo "rcS: Mounted /tmp"
|
@ -0,0 +1,2 @@
|
||||
# sample rc.sysinit file; you must run tools/genromfs <nuttx dir> from within this
|
||||
# location to convert this file to nsh_romfsimg.h for inclusion in the build
|
@ -0,0 +1,2 @@
|
||||
# sample rc.sysinit file; you must run tools/genromfs <nuttx dir> from within this
|
||||
# location to convert this file to nsh_romfsimg.h for inclusion in the build
|
@ -3,13 +3,13 @@ README
|
||||
|
||||
Overview
|
||||
--------
|
||||
This directory contains logic to support a custom ROMFS start-up script.
|
||||
This startup script is used by by the NSH when it starts provided that
|
||||
CONFIG_NSH_ARCHROMFS=y. The script provides a ROMFS volume that will be
|
||||
mounted at /etc and will look like this at run-time:
|
||||
This directory contains logic to support a custom ROMFS system-init script
|
||||
and start-up script. These scripts are used by by the NSH when it starts
|
||||
provided that CONFIG_NSH_ARCHROMFS=y. These scripts provide a ROMFS volume
|
||||
that will be mounted at /etc and will look like this at run-time:
|
||||
|
||||
NuttShell (NSH) NuttX-8.2
|
||||
nsh> ls -l /etc
|
||||
nsh> ls -Rl /etc
|
||||
/etc:
|
||||
dr-xr-xr-x 0 .
|
||||
-r--r--r-- 20 group
|
||||
@ -18,10 +18,11 @@ README
|
||||
/etc/init.d:
|
||||
dr-xr-xr-x 0 ..
|
||||
-r--r--r-- 110 rcS
|
||||
-r--r--r-- 110 rc.sysinit
|
||||
nsh>
|
||||
|
||||
/etc/init.d/rcS is the start-up script; /etc/passwd is a the password
|
||||
file. It supports a single user:
|
||||
/etc/init.d/rc.sysinit is system init script; /etc/init.d/rcS is the start-up
|
||||
script; /etc/passwd is a the password file. It supports a single user:
|
||||
|
||||
USERNAME: admin
|
||||
PASSWORD: Adminstrator
|
||||
|
@ -3,10 +3,10 @@ README
|
||||
|
||||
Overview
|
||||
--------
|
||||
This directory contains logic to support a custom ROMFS start-up script.
|
||||
This startup script is used by by the NSH when it starts provided that
|
||||
CONFIG_NSH_ARCHROMFS=y. The script provides a ROMFS volume that will be
|
||||
mounted at /etc and will look like this at run-time:
|
||||
This directory contains logic to support a custom ROMFS system-init script
|
||||
and start-up script. These scripts are used by by the NSH when it starts
|
||||
provided that CONFIG_NSH_ARCHROMFS=y. These scripts provide a ROMFS volume
|
||||
that will be mounted at /etc and will look like this at run-time:
|
||||
|
||||
NuttShell (NSH) NuttX-8.2
|
||||
nsh> ls -l /etc
|
||||
@ -18,10 +18,11 @@ README
|
||||
/etc/init.d:
|
||||
dr-xr-xr-x 0 ..
|
||||
-r--r--r-- 110 rcS
|
||||
-r--r--r-- 110 rc.sysinit
|
||||
nsh>
|
||||
|
||||
/etc/init.d/rcS is the start-up script; /etc/passwd is a the password
|
||||
file. It supports a single user:
|
||||
/etc/init.d/rc.sysinit is system init script; /etc/init.d/rcS is the start-up
|
||||
script; /etc/passwd is a the password file. It supports a single user:
|
||||
|
||||
USERNAME: admin
|
||||
PASSWORD: Adminstrator
|
||||
|
@ -108,7 +108,7 @@ endif
|
||||
|
||||
ifeq ($(CONFIG_NSH_ROMFSETC),y)
|
||||
ifneq ($(CONFIG_NSH_CUSTOMROMFS),y)
|
||||
RCSRCS = etc/init.d/rcS
|
||||
RCSRCS = etc/init.d/rc.sysinit etc/init.d/rcS
|
||||
RCRAWS = etc/group etc/passwd
|
||||
endif
|
||||
endif
|
||||
|
@ -3,10 +3,10 @@ README
|
||||
|
||||
Overview
|
||||
--------
|
||||
This directory contains logic to support a custom ROMFS start-up script.
|
||||
This startup script is used by by the NSH when it starts provided that
|
||||
CONFIG_NSH_ARCHROMFS=y. The script provides a ROMFS volume that will be
|
||||
mounted at /etc and will look like this at run-time:
|
||||
This directory contains logic to support a custom ROMFS system-init script
|
||||
and start-up script. These scripts are used by by the NSH when it starts
|
||||
provided that CONFIG_NSH_ARCHROMFS=y. These scripts provide a ROMFS volume
|
||||
that will be mounted at /etc and will look like this at run-time:
|
||||
|
||||
NuttShell (NSH) NuttX-10.1.0-RC1
|
||||
MOTD: username=admin password=Administrator
|
||||
@ -19,10 +19,11 @@ README
|
||||
/etc/init.d:
|
||||
dr-xr-xr-x 0 ..
|
||||
-r--r--r-- 110 rcS
|
||||
-r--r--r-- 110 rc.sysinit
|
||||
nsh>
|
||||
|
||||
/etc/init.d/rcS is the start-up script; /etc/passwd is a the password
|
||||
file. It supports a single user:
|
||||
/etc/init.d/rc.sysinit is system init script; /etc/init.d/rcS is the start-up
|
||||
script; /etc/passwd is a the password file. It supports a single user:
|
||||
|
||||
USERNAME: admin
|
||||
PASSWORD: Administrator
|
||||
|
@ -0,0 +1,36 @@
|
||||
/****************************************************************************
|
||||
* boards/risc-v/esp32c3/esp32c3-devkit/src/etc/init.d/rc.sysinit
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#define CONCAT_(x, y) x##y
|
||||
#define CONCAT(x, y) CONCAT_(x, y)
|
||||
|
||||
#ifdef CONFIG_NSH_ROMFSETC
|
||||
#ifdef CONFIG_FS_FAT
|
||||
|
||||
/* Create a RAMDISK and mount it at /tmp */
|
||||
|
||||
mkrd -m CONFIG_NSH_FATDEVNO -s CONFIG_NSH_FATSECTSIZE CONFIG_NSH_FATNSECTORS
|
||||
mkfatfs CONCAT(/dev/ram, CONFIG_NSH_FATDEVNO)
|
||||
mount -t vfat CONCAT(/dev/ram, CONFIG_NSH_FATDEVNO) CONFIG_NSH_FATMOUNTPT
|
||||
|
||||
#endif /* CONFIG_FS_FAT */
|
||||
#endif /* CONFIG_NSH_ROMFSETC */
|
@ -17,20 +17,3 @@
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#define CONCAT_(x, y) x##y
|
||||
#define CONCAT(x, y) CONCAT_(x, y)
|
||||
|
||||
#ifdef CONFIG_NSH_ROMFSETC
|
||||
#ifdef CONFIG_FS_FAT
|
||||
|
||||
/* Create a RAMDISK and mount it at /tmp */
|
||||
|
||||
mkrd -m CONFIG_NSH_FATDEVNO -s CONFIG_NSH_FATSECTSIZE CONFIG_NSH_FATNSECTORS
|
||||
mkfatfs CONCAT(/dev/ram, CONFIG_NSH_FATDEVNO)
|
||||
mount -t vfat CONCAT(/dev/ram, CONFIG_NSH_FATDEVNO) CONFIG_NSH_FATMOUNTPT
|
||||
|
||||
#endif /* CONFIG_FS_FAT */
|
||||
#endif /* CONFIG_NSH_ROMFSETC */
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
include $(TOPDIR)/Make.defs
|
||||
|
||||
RCSRCS = etc/init.d/rcS
|
||||
RCSRCS = etc/init.d/rc.sysinit etc/init.d/rcS
|
||||
|
||||
CSRCS = qemu_rv_appinit.c
|
||||
|
||||
|
19
boards/risc-v/qemu-rv/rv-virt/src/etc/init.d/rc.sysinit
Normal file
19
boards/risc-v/qemu-rv/rv-virt/src/etc/init.d/rc.sysinit
Normal file
@ -0,0 +1,19 @@
|
||||
/****************************************************************************
|
||||
* boards/risc-v/qemu-rv/rv-virt/src/etc/init.d/rc.sysinit
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
@ -0,0 +1,19 @@
|
||||
/****************************************************************************
|
||||
* boards/risc-v/qemu-rv/rv-virt/src/etc/init.d/rcS
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
@ -54,7 +54,7 @@ endif
|
||||
|
||||
ifeq ($(CONFIG_NSH_ROMFSETC),y)
|
||||
ifneq ($(CONFIG_NSH_CUSTOMROMFS),y)
|
||||
RCSRCS = etc/init.d/rcS
|
||||
RCSRCS = etc/init.d/rc.sysinit etc/init.d/rcS
|
||||
RCRAWS = etc/group etc/passwd
|
||||
endif
|
||||
endif
|
||||
|
@ -3,10 +3,10 @@ README
|
||||
|
||||
Overview
|
||||
--------
|
||||
This directory contains logic to support a custom ROMFS start-up script.
|
||||
This startup script is used by by the NSH when it starts provided that
|
||||
CONFIG_NSH_ARCHROMFS=y. The script provides a ROMFS volume that will be
|
||||
mounted at /etc and will look like this at run-time:
|
||||
This directory contains logic to support a custom ROMFS system-init script
|
||||
and start-up script. These scripts are used by by the NSH when it starts
|
||||
provided that CONFIG_NSH_ARCHROMFS=y. These scripts provide a ROMFS volume
|
||||
that will be mounted at /etc and will look like this at run-time:
|
||||
|
||||
NuttShell (NSH) NuttX-7.31
|
||||
MOTD: username=admin password=Administrator
|
||||
@ -19,10 +19,11 @@ README
|
||||
/etc/init.d:
|
||||
dr-xr-xr-x 0 ..
|
||||
-r--r--r-- 110 rcS
|
||||
-r--r--r-- 110 rc.sysinit
|
||||
nsh>
|
||||
|
||||
/etc/init.d/rcS is the start-up script; /etc/passwd is a the password
|
||||
file. It supports a single user:
|
||||
/etc/init.d/rc.sysinit is system init script; /etc/init.d/rcS is the start-up
|
||||
script; /etc/passwd is a the password file. It supports a single user:
|
||||
|
||||
USERNAME: admin
|
||||
PASSWORD: Administrator
|
||||
|
36
boards/sim/sim/sim/src/etc/init.d/rc.sysinit
Normal file
36
boards/sim/sim/sim/src/etc/init.d/rc.sysinit
Normal file
@ -0,0 +1,36 @@
|
||||
/****************************************************************************
|
||||
* boards/sim/sim/sim/src/etc/init.d/rc.sysinit
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#define CONCAT_(x, y) x##y
|
||||
#define CONCAT(x, y) CONCAT_(x, y)
|
||||
|
||||
#ifdef CONFIG_NSH_ROMFSETC
|
||||
#ifdef CONFIG_FS_FAT
|
||||
|
||||
/* Create a RAMDISK and mount it at /tmp */
|
||||
|
||||
mkrd -m CONFIG_NSH_FATDEVNO -s CONFIG_NSH_FATSECTSIZE CONFIG_NSH_FATNSECTORS
|
||||
mkfatfs CONCAT(/dev/ram, CONFIG_NSH_FATDEVNO)
|
||||
mount -t vfat CONCAT(/dev/ram, CONFIG_NSH_FATDEVNO) CONFIG_NSH_FATMOUNTPT
|
||||
|
||||
#endif /* CONFIG_FS_FAT */
|
||||
#endif /* CONFIG_NSH_ROMFSETC */
|
@ -17,20 +17,3 @@
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#define CONCAT_(x, y) x##y
|
||||
#define CONCAT(x, y) CONCAT_(x, y)
|
||||
|
||||
#ifdef CONFIG_NSH_ROMFSETC
|
||||
#ifdef CONFIG_FS_FAT
|
||||
|
||||
/* Create a RAMDISK and mount it at /tmp */
|
||||
|
||||
mkrd -m CONFIG_NSH_FATDEVNO -s CONFIG_NSH_FATSECTSIZE CONFIG_NSH_FATNSECTORS
|
||||
mkfatfs CONCAT(/dev/ram, CONFIG_NSH_FATDEVNO)
|
||||
mount -t vfat CONCAT(/dev/ram, CONFIG_NSH_FATDEVNO) CONFIG_NSH_FATMOUNTPT
|
||||
|
||||
#endif /* CONFIG_FS_FAT */
|
||||
#endif /* CONFIG_NSH_ROMFSETC */
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
wd=`pwd`
|
||||
workingdir=$wd/img
|
||||
rcsysinitfile=rc.sysinit
|
||||
rcsysinittemplate=$rcsysinitfile.template
|
||||
rcsfile=rcS
|
||||
rcstemplate=$rcsfile.template
|
||||
romfsimg=romfs.img
|
||||
@ -33,8 +35,9 @@ headerfile=nsh_romfsimg.h
|
||||
nofat=$1
|
||||
usefat=true
|
||||
topdir=$2
|
||||
rcs_fname=$3
|
||||
usage="USAGE: $0 [-nofat] <topdir> [<rcsfile>]"
|
||||
rcsysinit_fname=$3
|
||||
rcs_fname=$4
|
||||
usage="USAGE: $0 [-nofat] <topdir> [rcsysinitfile] [<rcsfile>]"
|
||||
|
||||
# Verify if we have the optional "-nofat"
|
||||
|
||||
@ -43,7 +46,8 @@ if [ "$nofat" == "-nofat" ]; then
|
||||
usefat=false
|
||||
else
|
||||
topdir=$1
|
||||
rcs_fname=$2
|
||||
rcsysinit_fname=$2
|
||||
rcs_fname=$3
|
||||
fi
|
||||
|
||||
if [ -z "$topdir" -o ! -d "$topdir" ]; then
|
||||
@ -52,7 +56,12 @@ if [ -z "$topdir" -o ! -d "$topdir" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verify if we have the optional "rcs_fname"
|
||||
# Verify if we have the optional "rcsysinit_fname" and "rcs_fname"
|
||||
|
||||
if [ ! -z "$rcsysinit_fname" ]; then
|
||||
rcsysinittemplate=$rcsysinit_fname
|
||||
echo "Target template is $rcsysinittemplate"
|
||||
fi
|
||||
|
||||
if [ ! -z "$rcs_fname" ]; then
|
||||
rcstemplate=$rcs_fname
|
||||
@ -77,6 +86,7 @@ devconsole=`grep CONFIG_DEV_CONSOLE= $topdir/.config | cut -d'=' -f2`
|
||||
romfs=`grep CONFIG_FS_ROMFS= $topdir/.config | cut -d'=' -f2`
|
||||
romfsmpt=`grep CONFIG_NSH_ROMFSMOUNTPT= $topdir/.config | cut -d'=' -f2`
|
||||
initscript=`grep CONFIG_NSH_INITSCRIPT= $topdir/.config | cut -d'=' -f2`
|
||||
sysinitscript=`grep CONFIG_NSH_SYSINITSCRIPT= $topdir/.config | cut -d'=' -f2`
|
||||
romfsdevno=`grep CONFIG_NSH_ROMFSDEVNO= $topdir/.config | cut -d'=' -f2`
|
||||
romfssectsize=`grep CONFIG_NSH_ROMFSSECTSIZE= $topdir/.config | cut -d'=' -f2`
|
||||
|
||||
@ -140,6 +150,9 @@ fi
|
||||
if [ -z "$initscript" ]; then
|
||||
initscript=\"init.d/rcS\"
|
||||
fi
|
||||
if [ -z "$sysinitscript" ]; then
|
||||
sysinitscript=\"init.d/rc.sysinit\"
|
||||
fi
|
||||
if [ -z "$romfsdevno" ]; then
|
||||
romfsdevno=0
|
||||
fi
|
||||
@ -217,11 +230,51 @@ if [ "X$uinitscript" = "." -o ${uinitscript:0:2} = "./" -o \
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ${sysinitscript:0:1} != "\"" ]; then
|
||||
echo "CONFIG_NSH_SYSINITSCRIPT must be a string"
|
||||
echo "Change it so that it is enclosed in quotes."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
usysinitscript=`echo $sysinitscript | sed -e "s/\"//g"`
|
||||
|
||||
if [ ${usysinitscript:0:1} == "/" ]; then
|
||||
echo "CONFIG_NSH_SYSINITSCRIPT must be an relative path in under $romfsmpt"
|
||||
echo "Change it so that it begins with the character '/'. Eg. init.d/rc.sysinit. "
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "X$usysinitscript" = "." -o ${usysinitscript:0:2} = "./" -o \
|
||||
"X$usysinitscript" = ".." -o ${usysinitscript:0:3} = "../" ]; then
|
||||
echo "Invalid CONFIG_NSH_SYSINITSCRIPT 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 rc.sysinit file from the rc.sysinit.template
|
||||
|
||||
if [ ! -r $rcsysinittemplate ]; then
|
||||
echo "$rcsysinittemplate does not exist"
|
||||
rmdir $workingdir
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If we are using FAT FS with RAMDISK we need to setup it
|
||||
|
||||
if [ "$usefat" = true ]; then
|
||||
cat $rcsysinittemplate | \
|
||||
sed -e "s,XXXMKRDMINORXXX,$fatdevno,g" | \
|
||||
sed -e "s,XXMKRDSECTORSIZEXXX,$fatsectsize,g" | \
|
||||
sed -e "s,XXMKRDBLOCKSXXX,$fatnsectors,g" | \
|
||||
sed -e "s,XXXRDMOUNTPOINTXXX,$fatmpt,g" >$rcsysinitfile
|
||||
else
|
||||
cp $rcsysinittemplate $rcsysinitfile
|
||||
fi
|
||||
|
||||
# Create the rcS file from the rcS.template
|
||||
|
||||
if [ ! -r $rcstemplate ]; then
|
||||
@ -230,17 +283,7 @@ if [ ! -r $rcstemplate ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If we are using FAT FS with RAMDISK we need to setup it
|
||||
|
||||
if [ "$usefat" = true ]; then
|
||||
cat $rcstemplate | \
|
||||
sed -e "s,XXXMKRDMINORXXX,$fatdevno,g" | \
|
||||
sed -e "s,XXMKRDSECTORSIZEXXX,$fatsectsize,g" | \
|
||||
sed -e "s,XXMKRDBLOCKSXXX,$fatnsectors,g" | \
|
||||
sed -e "s,XXXRDMOUNTPOINTXXX,$fatmpt,g" >$rcsfile
|
||||
else
|
||||
cp $rcstemplate $rcsfile
|
||||
fi
|
||||
cp $rcstemplate $rcsfile
|
||||
|
||||
# And install it at the specified relative location
|
||||
|
||||
@ -248,6 +291,10 @@ fi
|
||||
mkdir -p $workingdir/$uinitscript
|
||||
rmdir $workingdir/$uinitscript
|
||||
|
||||
install -m 0755 $rcsysinitfile $workingdir/$usysinitscript || \
|
||||
{ echo "Failed to install $rcsysinitfile at $workingdir/$usysinitscript"; rm -f $rcsysinitfile; exit 1; }
|
||||
rm -f $rcsysinitfile
|
||||
|
||||
install -m 0755 $rcsfile $workingdir/$uinitscript || \
|
||||
{ echo "Failed to install $rcsfile at $workingdir/$uinitscript"; rm -f $rcsfile; exit 1; }
|
||||
rm -f $rcsfile
|
||||
|
Loading…
Reference in New Issue
Block a user