From 8f66f424602e26f0a43a62beaa3c2aec7775c890 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 8 Mar 2011 00:27:35 +0000 Subject: Add support for platoform specific ROMFS startup files git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3350 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/Documentation/NuttShell.html | 31 ++-- nuttx/Makefile | 9 +- nuttx/configs/qemu-i486/ostest/Make.defs | 8 + nuttx/configs/qemu-i486/ostest/setenv.sh | 8 +- nuttx/configs/vsn/include/nsh_romfsimg.h | 89 +++++++++++ nuttx/configs/vsn/include/rcS.template | 10 ++ nuttx/configs/vsn/nsh/Make.defs | 4 + nuttx/configs/vsn/nsh/defconfig | 3 + nuttx/examples/nsh/README.txt | 25 ++- nuttx/examples/nsh/mkromfsimg.sh | 261 ------------------------------- nuttx/examples/nsh/nsh_romfsetc.c | 12 +- nuttx/tools/README.txt | 6 + nuttx/tools/mkromfsimg.sh | 261 +++++++++++++++++++++++++++++++ 13 files changed, 444 insertions(+), 283 deletions(-) create mode 100755 nuttx/configs/vsn/include/nsh_romfsimg.h create mode 100755 nuttx/configs/vsn/include/rcS.template delete mode 100755 nuttx/examples/nsh/mkromfsimg.sh create mode 100755 nuttx/tools/mkromfsimg.sh diff --git a/nuttx/Documentation/NuttShell.html b/nuttx/Documentation/NuttShell.html index 87e8592e9..e03aadc7f 100644 --- a/nuttx/Documentation/NuttShell.html +++ b/nuttx/Documentation/NuttShell.html @@ -8,7 +8,7 @@

NuttShell (NSH)

-

Last Updated: March 1, 2011

+

Last Updated: March 7, 2011

@@ -580,9 +580,8 @@ mount -t vfat /dev/ram1 /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: + The contents of the /etc directory are retained in the file examples/nsh/nsh_romfsimg.h OR, if CONFIG_EXAMPLES_NSH_ARCHROMFS is defined, include/arch/board/rcs.template). + In order to modify the start-up behavior, there are three things to study:

  1. Configuration Options. @@ -591,30 +590,37 @@ mount -t vfat /dev/ram1 /tmp
  2. - mkromfsimg.sh Script. - The script examples/nsh/mkromfsimg.sh creates nsh_romfsimg.h. + tools/mkromfsimg.sh Script. + The script tools/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. + this header file using the tools/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. +
    • The file examples/nsh/rcS.template + (OR, if CONFIG_EXAMPLES_NSH_ARCHROMFS is defined include/arch/board/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 + of the rcS file; configured values are plugged into this template file to produce the final rcS file.

+

+ NOTE: + examples/nsh/rcS.template generates the standard, default nsh_romfsimg.h file. + If CONFIG_EXAMPLES_NSH_ARCHROMFS is defined in the NuttX configuration file, then a custom, board-specific nsh_romfsimg.h file residing in configs/<board>/include will be used. + NOTE when the OS is configured, include/arch/board will be linked to configs/<board>/include. +

All of the startup-behavior is contained in rcS.template. The role of mkromfsimg.sh is to (1) apply the specific configuration @@ -2254,6 +2260,12 @@ nsh> Configuration Description + + CONFIG_EXAMPLES_NSH_ARCHROMFS + + May be defined to specify an alternative ROMFS image that can be found at configs/<board>/include/nsh_romfsimg.h. + + CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT @@ -2353,6 +2365,7 @@ nsh>

  • CONFIG_EXAMPLES_NSH_NOMAC
  • CONFIG_EXAMPLES_NSH_ROMFSDEVNO
  • CONFIG_EXAMPLES_NSH_ROMFSETC
  • +
  • CONFIG_EXAMPLES_NSH_ARCHROMFS
  • CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT
  • CONFIG_EXAMPLES_NSH_ROMFSSECTSIZE
  • CONFIG_EXAMPLES_NSH_STACKSIZE
  • diff --git a/nuttx/Makefile b/nuttx/Makefile index 7b71b7298..00a7c60b1 100644 --- a/nuttx/Makefile +++ b/nuttx/Makefile @@ -1,7 +1,7 @@ ############################################################################ # Makefile # -# Copyright (C) 2007-2010 Gregory Nutt. All rights reserved. +# Copyright (C) 2007-2011 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -309,6 +309,13 @@ ifeq ($(CONFIG_RAW_BINARY),y) @$(OBJCOPY) $(OBJCOPYARGS) -O binary $(NUTTX)$(EXEEXT) $(NUTTX)$(EXEEXT).bin endif +# This is a helper target that will rebuild NuttX and download it to the +# target system in one step. It will generate an error an error if the +# DOWNLOAD command is not defined in platform Make.defs file. + +download: $(BIN) + $(call DOWNLOAD, $@) + depend: @for dir in $(MAKEDIRS) ; do \ $(MAKE) -C $$dir TOPDIR="$(TOPDIR)" depend ; \ diff --git a/nuttx/configs/qemu-i486/ostest/Make.defs b/nuttx/configs/qemu-i486/ostest/Make.defs index c27cac0ef..14efb3f32 100644 --- a/nuttx/configs/qemu-i486/ostest/Make.defs +++ b/nuttx/configs/qemu-i486/ostest/Make.defs @@ -65,7 +65,15 @@ ARCHPICFLAGS = -fpic ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow ARCHDEFINES = +# We have to use a cross-development toolchain under Cygwin because the native +# Cygwin toolchains don't generate ELF binaries. + +ifeq ($(HOSTOS),Cygwin) +CROSSDEV = i486-elf- +else CROSSDEV = +endif + CC = $(CROSSDEV)gcc CPP = $(CROSSDEV)gcc -E LD = $(CROSSDEV)ld diff --git a/nuttx/configs/qemu-i486/ostest/setenv.sh b/nuttx/configs/qemu-i486/ostest/setenv.sh index 9386b9822..df098332a 100755 --- a/nuttx/configs/qemu-i486/ostest/setenv.sh +++ b/nuttx/configs/qemu-i486/ostest/setenv.sh @@ -39,8 +39,10 @@ fi if [ -z ${PATH_ORIG} ]; then export PATH_ORIG=${PATH}; fi -# Define the following if you are using anything other than the system GCC -#export NUTTX_BIN= -#export PATH=${NUTTX_BIN}:/sbin:/usr/sbin:${PATH_ORIG} +# Uncomment and modify the following if you are using anything other +# than the system GCC +# WD=`pwd` +# export BUILDROOT_BIN="${WD}/../../buildroot/build_i486/staging_dir/bin" +# export PATH="${BUILDROOT_BIN}:/sbin:/usr/sbin:${PATH_ORIG}" echo "PATH : ${PATH}" diff --git a/nuttx/configs/vsn/include/nsh_romfsimg.h b/nuttx/configs/vsn/include/nsh_romfsimg.h new file mode 100755 index 000000000..102d2a144 --- /dev/null +++ b/nuttx/configs/vsn/include/nsh_romfsimg.h @@ -0,0 +1,89 @@ +unsigned char romfs_img[] = { + 0x2d, 0x72, 0x6f, 0x6d, 0x31, 0x66, 0x73, 0x2d, 0x00, 0x00, 0x01, 0xf0, + 0x38, 0x85, 0x3a, 0x23, 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, 0x20, 0x00, 0x00, 0x00, 0x00, 0xd1, 0xd1, 0xff, 0x40, + 0x2e, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x60, + 0x00, 0x00, 0x00, 0x00, 0xd1, 0xff, 0xfe, 0xe0, 0x2e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0f, + 0x8d, 0x9c, 0xab, 0xe7, 0x72, 0x63, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x63, 0x68, 0x6f, + 0x20, 0x22, 0x56, 0x53, 0x4e, 0x20, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x20, + 0x31, 0x2e, 0x32, 0x2c, 0x20, 0x77, 0x77, 0x77, 0x2e, 0x6e, 0x65, 0x74, + 0x63, 0x6c, 0x61, 0x6d, 0x70, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x22, 0x0a, + 0x0a, 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, 0x23, 0x6d, 0x6b, 0x72, 0x64, 0x20, 0x2d, + 0x6d, 0x20, 0x31, 0x20, 0x2d, 0x73, 0x20, 0x35, 0x31, 0x32, 0x20, 0x34, + 0x30, 0x0a, 0x23, 0x6d, 0x6b, 0x66, 0x61, 0x74, 0x66, 0x73, 0x20, 0x2f, + 0x64, 0x65, 0x76, 0x2f, 0x72, 0x61, 0x6d, 0x31, 0x0a, 0x23, 0x6d, 0x6f, + 0x75, 0x6e, 0x74, 0x20, 0x2d, 0x74, 0x20, 0x76, 0x66, 0x61, 0x74, 0x20, + 0x2f, 0x64, 0x65, 0x76, 0x2f, 0x72, 0x61, 0x6d, 0x31, 0x20, 0x2f, 0x74, + 0x6d, 0x70, 0x0a, 0x0a, 0x65, 0x63, 0x68, 0x6f, 0x20, 0x22, 0x4d, 0x6f, + 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x46, 0x52, 0x41, 0x4d, 0x20, + 0x74, 0x6f, 0x20, 0x2f, 0x75, 0x73, 0x72, 0x20, 0x61, 0x6e, 0x64, 0x20, + 0x53, 0x44, 0x63, 0x61, 0x72, 0x64, 0x20, 0x74, 0x6f, 0x20, 0x2f, 0x73, + 0x64, 0x63, 0x61, 0x72, 0x64, 0x22, 0x0a, 0x6d, 0x6f, 0x75, 0x6e, 0x74, + 0x20, 0x2d, 0x74, 0x20, 0x76, 0x66, 0x61, 0x74, 0x20, 0x2f, 0x64, 0x65, + 0x76, 0x2f, 0x6d, 0x74, 0x64, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x30, 0x20, + 0x2f, 0x75, 0x73, 0x72, 0x0a, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x20, 0x2d, + 0x74, 0x20, 0x76, 0x66, 0x61, 0x74, 0x20, 0x2f, 0x64, 0x65, 0x76, 0x2f, + 0x6d, 0x6d, 0x63, 0x73, 0x64, 0x30, 0x20, 0x2f, 0x73, 0x64, 0x63, 0x61, + 0x72, 0x64, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 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/configs/vsn/include/rcS.template b/nuttx/configs/vsn/include/rcS.template new file mode 100755 index 000000000..83005bd40 --- /dev/null +++ b/nuttx/configs/vsn/include/rcS.template @@ -0,0 +1,10 @@ +echo "VSN Board 1.2, www.netclamps.com" + +# Create a RAMDISK and mount it at XXXRDMOUNTPOUNTXXX +#mkrd -m XXXMKRDMINORXXX -s XXMKRDSECTORSIZEXXX XXMKRDBLOCKSXXX +#mkfatfs /dev/ramXXXMKRDMINORXXX +#mount -t vfat /dev/ramXXXMKRDMINORXXX XXXRDMOUNTPOUNTXXX + +echo "Mounting FRAM to /usr and SDcard to /sdcard" +mount -t vfat /dev/mtdblock0 /usr +mount -t vfat /dev/mmcsd0 /sdcard diff --git a/nuttx/configs/vsn/nsh/Make.defs b/nuttx/configs/vsn/nsh/Make.defs index d343a07c8..1bdc55d09 100644 --- a/nuttx/configs/vsn/nsh/Make.defs +++ b/nuttx/configs/vsn/nsh/Make.defs @@ -167,6 +167,10 @@ define CLEAN @rm -f *.o *.a endef +define DOWNLOAD + @armst /dev/ttyUSB0 nuttx.srec +endef + HOSTCC = gcc HOSTINCLUDES = -I. HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe diff --git a/nuttx/configs/vsn/nsh/defconfig b/nuttx/configs/vsn/nsh/defconfig index a1eb5ed94..0f1d946b5 100755 --- a/nuttx/configs/vsn/nsh/defconfig +++ b/nuttx/configs/vsn/nsh/defconfig @@ -716,6 +716,8 @@ CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 # CONFIG_EXAMPLES_NSH_NOMAC - Use a bogus MAC address # # If CONFIG_EXAMPLES_NSH_ROMFSETC is selected: +# CONFIG_EXAMPLES_NSH_ARCHROMFS - May be defined to specify an alternative +# ROMFS image that can be found at configs//include/nsh_romfsimg.h. # CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT - ROMFS mountpoint # CONFIG_EXAMPLES_NSH_INITSCRIPT - Relative path to init script # CONFIG_EXAMPLES_NSH_ROMFSDEVNO - ROMFS RAM device minor @@ -742,6 +744,7 @@ 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_ARCHROMFS=y CONFIG_EXAMPLES_NSH_ROMFSMOUNTPT="/etc" CONFIG_EXAMPLES_NSH_INITSCRIPT="init.d/rcS" CONFIG_EXAMPLES_NSH_ROMFSDEVNO=0 diff --git a/nuttx/examples/nsh/README.txt b/nuttx/examples/nsh/README.txt index ee3a42de2..ab44cbaeb 100644 --- a/nuttx/examples/nsh/README.txt +++ b/nuttx/examples/nsh/README.txt @@ -159,15 +159,16 @@ 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: +examples/nsh/nsh_romfsimg.h (OR, if CONFIG_EXAMPLES_NSH_ARCHROMFS +is defined, include/arch/board/rcs.template). 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. +2. tools/mkromfsimg.sh Script. + The script tools/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 @@ -175,15 +176,25 @@ behavior, there are three things to study: The behavior of this script depends upon three things: - - The configuration settings then installed configuration. + - The configuration settings of the installed NuttX configuration. - The genromfs tool (available from http://romfs.sourceforge.net). - - The file examples/nsh/rcS.template. + - The file examples/nsh/rcS.template (OR, if + CONFIG_EXAMPLES_NSH_ARCHROMFS is defined, include/arch/board/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 + of the rcS file; configured values are plugged into this template file to produce the final rcS file. +NOTE: + + examples/nsh/rcS.template generates the standard, default + nsh_romfsimg.h file. If CONFIG_EXAMPLES_NSH_ARCHROMFS is defined + in the NuttX configuration file, then a custom, board-specific + nsh_romfsimg.h file residing in configs//include will be + used. NOTE when the OS is configured, include/arch/board will + be linked to configs//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 diff --git a/nuttx/examples/nsh/mkromfsimg.sh b/nuttx/examples/nsh/mkromfsimg.sh deleted file mode 100755 index 53f573179..000000000 --- a/nuttx/examples/nsh/mkromfsimg.sh +++ /dev/null @@ -1,261 +0,0 @@ -#!/bin/bash -############################################################################ -# examples/nsh/mkromfsimg.sh -# -# Copyright (C) 2008 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt -# -# 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 " - -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_romfsetc.c b/nuttx/examples/nsh/nsh_romfsetc.c index d16da0a7a..482a3618c 100644 --- a/nuttx/examples/nsh/nsh_romfsetc.c +++ b/nuttx/examples/nsh/nsh_romfsetc.c @@ -1,7 +1,7 @@ /**************************************************************************** * examples/nsh/nsh_romfsetc.c * - * Copyright (C) 2008-2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -49,7 +49,15 @@ #ifdef CONFIG_EXAMPLES_NSH_ROMFSETC -#include "nsh_romfsimg.h" +/* Should we use the default ROMFS image? Or a custom, board-specific + * ROMFS image? + */ + +#ifdef CONFIG_EXAMPLES_NSH_ARCHROMFS +# include +#else +# include "nsh_romfsimg.h" +#endif /**************************************************************************** * Definitions diff --git a/nuttx/tools/README.txt b/nuttx/tools/README.txt index ea13db9a0..c62c18fb0 100755 --- a/nuttx/tools/README.txt +++ b/nuttx/tools/README.txt @@ -31,6 +31,12 @@ mkconfig.c into include/nuttx/config.h. config.h is a another version of the NuttX configuration that can be included by C files. +mkromfsimg.sh + + This script may be used to automate the generate of a ROMFS file system + image. It accepts an rcS script "template" and generates and image that + may be mounted under /etc in the NuttX pseudo file system. + Makefile.mkconfig This is the makefile that is used to make the mkconfig program from diff --git a/nuttx/tools/mkromfsimg.sh b/nuttx/tools/mkromfsimg.sh new file mode 100755 index 000000000..5e742f47d --- /dev/null +++ b/nuttx/tools/mkromfsimg.sh @@ -0,0 +1,261 @@ +#!/bin/bash +############################################################################ +# tools/mkromfsimg.sh +# +# Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# 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 " + +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 -- cgit v1.2.3