etc romfs
The ROMFS image is the contents of the /etc directory, including the start-up script
contains any command support by Nuttx, and other customized contents needed.
Configuration
CONFIG_NSH_ROMFS /* 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". */
CONFIG_ETC_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_ETC_ROMFSDEVNO /* This is the minor number of the ROMFS block device. The default is '0'
corresponding to "/dev/ram0". */
CONFIG_ETC_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. */
This capability also depends on:
CONFIG_DISABLE_MOUNTPOINT /* If mount point support is disabled, then you cannot mount any file systems. */
CONFIG_FS_ROMFS /* This option enables ROMFS file system support. */
Start up Scripts
Start-Up Script. The start-up script contains any command support by Nuttx (i.e., that you see when you enter ‘nsh> help’). 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_ETC_ROMFS will cause Nuttx to
behave as follows at Nuttx start-up time:
Nuttx will create a read-only RAM disk (a ROM disk), containing a tiny ROMFS file system containing the following:
`--init.d/ `-- rcS `-- rc.sysinitWhere
rcSis the start-up script. Whererc.sysinitis the system-init script.Nuttx will then mount the ROMFS file system at
/etc, resulting in:|--dev/ | `-- ram0 `--etc/ `--init.d/ `-- rcS `-- rc.sysinitBy default, the contents of
rc.sysinitscript are:# Create a RAMDISK and mount it at /tmp mkrd -m 1 -s 512 1024 mkfatfs /dev/ram1 mount -t vfat /dev/ram1 /tmpNSH will execute the script at
/etc/init.d/rc.sysinitat system init (before the first NSH prompt). After execution of the script, the root FS will look like:|--dev/ | |-- ram0 | `-- ram1 |--etc/ | `--init.d/ | `-- rcS | `-- rc.sysinit `--tmp/
Example Configurations. Here are some configurations that have
CONFIG_ETC_ROMFS=y in the NuttX configuration file. They might
provide useful examples:
boards/arm/stm32/hymini-stm32v/nsh2
boards/arm/dm320/ntosd-dm320/nsh
boards/sim/sim/sim/nsh
boards/sim/sim/sim/nsh2
boards/sim/sim/sim/nx
boards/sim/sim/sim/nx11
boards/sim/sim/sim/touchscreen
In most of these cases, the configuration sets up the default
/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.
Customizing Start up Scripts
In order to modify the start-up behavior, there are three things to study:
Configuration Options. The additional
CONFIG_ETC_ROMFSconfiguration options discussed with Configuration
tools/mkromfsimg.shScript. The scripttools/mkromfsimg.shcreatesetc_romfs.c. It is not automatically executed. If you want to change the configuration settings associated with creating and mounting the/tmpdirectory, then it will be necessary to re-generate this header file using thetools/mkromfsimg.shscript.The behavior of this script depends upon several things:
The configuration settings then installed configuration.
The
genromfstool(available from http://romfs.sourceforge.net) or included within the NuttX buildroot toolchain. There is also a snapshot available in the NuttX tools repository here.The
xxdtool that is used to generate the C header files (xxd is a normal part of a complete Linux or Cygwin installation, usually as part of thevipackage).The file
include/arch/board/rc.sysinit.templateand the fileinclude/arch/board/rcs.template
rc.sysinit.template. The fileapps/nshlib/rc.sysinit.templatecontains the general form of therc.sysinitfile; configured values are plugged into this template file to produce the finalrc.sysinitfile.
rcS.template. The fileapps/nshlib/rcS.templatecontains the general form of thercSfile; configured values are plugged into this template file to produce the finalrcSfile.To generate a custom
rc.sysinitandrcSfile a copy ofrc.sysinit.templateandrcS.templateneeds to be placed attools/and changed according to the desired start-up behaviour. Runningtools/mkromfsimg.hcreatesetc_romfs.cwhich needs to be copied toarch/board/srcand compiled in Makefile
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 source file etc_romfs.c containing the ROMFS file
system image. To do this, mkromfsimg.sh uses two tools that must be
installed in your system:
The
genromfstool that is used to generate the ROMFS file system image.The
xxdtool that is used to create the C header file.
Customizing ROMFS Image
The ROMFS image can be generated from the content in the corresponding
board/arch/board/board/src/etc directory, and added by Makefile.
Example Configurations. Here are some configurations that have
CONFIG_ETC_ROMFS=y in the NuttX configuration file. They might
provide useful examples:
boards/risc-v/bl808/ox64/src/etc
boards/risc-v/qemu-rv/rv-virt/src/etc
boards/risc-v/esp32c3/esp32c3-devkit/src/etc
boards/risc-v/k230/canmv230/src/etc
boards/risc-v/jh7110/star64/src/etc
boards/arm64/rk3399/nanopi_m4/src/etc
boards/sim/sim/sim/src/etc