2019-08-10 17:57:26 +02:00
|
|
|
#!/usr/bin/env bash
|
2008-09-11 23:54:23 +02:00
|
|
|
############################################################################
|
2011-03-08 01:27:35 +01:00
|
|
|
# tools/mkromfsimg.sh
|
2008-09-11 23:54:23 +02:00
|
|
|
#
|
2021-02-18 13:48:10 +01:00
|
|
|
# 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
|
2008-09-11 23:54:23 +02:00
|
|
|
#
|
2021-02-18 13:48:10 +01:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2008-09-11 23:54:23 +02:00
|
|
|
#
|
2021-02-18 13:48:10 +01:00
|
|
|
# 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.
|
2008-09-11 23:54:23 +02:00
|
|
|
#
|
|
|
|
############################################################################
|
|
|
|
|
|
|
|
# Environmental stuff
|
|
|
|
|
|
|
|
wd=`pwd`
|
|
|
|
workingdir=$wd/img
|
2022-04-15 15:56:00 +02:00
|
|
|
rcsysinitfile=rc.sysinit
|
|
|
|
rcsysinittemplate=$rcsysinitfile.template
|
2008-09-11 23:54:23 +02:00
|
|
|
rcsfile=rcS
|
|
|
|
rcstemplate=$rcsfile.template
|
|
|
|
romfsimg=romfs.img
|
sched: move etc romfs mount from nsh to sched/init
Usually the startup script is placed under /etc. The contents of the etc directory
are compiled and linked with Nuttx binary in the form of romfs. After startup,
it will be mounted by Nsh.
etc is generated by the different boards, that use genromfs and xxd tools to generate
and compile it into the Nuttx, for example: boards/arm/at32/at32f437-mini/tool/mkromfs.sh
The more common method is etc image generated from the content in the corresponding
board/arch/board/board/src/etc directory, and added by Makefile for example:
boards/sim/sim/sim/src/etc.
But in kernel/protected mode, Nuttx kernel and apps are run in different privileged/
non-privileged mode or the isolated binarys, so as that nsh should use syscall to
access Nuttx kernel by exported API. In this scenario, nsh can not mount the etc image
content, because that is generated in board and as a part of Nuttx kernel.
changes:
- move etc romfs mount from nsh to Nuttx, but keep the script to parse and execute.
- move and rename the related CONFIG, move customized nsh_romfsimg.h to etc_romfs.c
in boards, and no need declaration for romfs_img/romfs_img_len.
This commit changes and updates all configurations in Nuttx arch/board as much as possible,
but if any missing, please refer to the following simple guide:
- rename CONFIG_NSH_ROMFSETC to CONFIG_ETC_ROMFS, and delete CONFIG_NSH_ARCHROMFS in defconfig
- rename the etc romfs mount configs, for example CONFIG_NSH_FATDEVNO to CONFIG_ETC_FATDEVNO
- move customized nsh_romfsimg.h to etc_romfs.c in board/arch/board/board/src and no need
declaration for romfs_img/romfs_img_len.
- delete default nsh_romfsimg.h, if ROMFSETC is enabled, should generate and compile etc_romfs.c
in board/arch/board/board/src.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-11-26 04:51:46 +01:00
|
|
|
headerfile=etc_romfs.c
|
2008-09-11 23:54:23 +02:00
|
|
|
|
|
|
|
# Get the input parameters
|
|
|
|
|
2018-04-14 23:24:04 +02:00
|
|
|
nofat=$1
|
|
|
|
usefat=true
|
|
|
|
topdir=$2
|
2022-04-15 15:56:00 +02:00
|
|
|
rcsysinit_fname=$3
|
|
|
|
rcs_fname=$4
|
|
|
|
usage="USAGE: $0 [-nofat] <topdir> [rcsysinitfile] [<rcsfile>]"
|
2018-04-14 23:24:04 +02:00
|
|
|
|
|
|
|
# Verify if we have the optional "-nofat"
|
|
|
|
|
|
|
|
if [ "$nofat" == "-nofat" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "We will not mount a FAT/RAMDISK!"
|
|
|
|
usefat=false
|
2018-04-14 23:24:04 +02:00
|
|
|
else
|
2020-01-05 17:29:59 +01:00
|
|
|
topdir=$1
|
2022-04-15 15:56:00 +02:00
|
|
|
rcsysinit_fname=$2
|
|
|
|
rcs_fname=$3
|
2018-04-14 23:24:04 +02:00
|
|
|
fi
|
2008-09-11 23:54:23 +02:00
|
|
|
|
|
|
|
if [ -z "$topdir" -o ! -d "$topdir" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "The full path to the NuttX base directory must be provided on the command line"
|
|
|
|
echo $usage
|
|
|
|
exit 1
|
2008-09-11 23:54:23 +02:00
|
|
|
fi
|
|
|
|
|
2022-04-15 15:56:00 +02:00
|
|
|
# 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
|
2021-09-12 23:38:50 +02:00
|
|
|
|
|
|
|
if [ ! -z "$rcs_fname" ]; then
|
|
|
|
rcstemplate=$rcs_fname
|
|
|
|
echo "Target template is $rcstemplate"
|
|
|
|
fi
|
|
|
|
|
2008-09-11 23:54:23 +02:00
|
|
|
# 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
|
2020-02-23 09:50:23 +01:00
|
|
|
# and source-able by scripts. Unfortunately,there are too many syntactic difference
|
2008-09-11 23:54:23 +02:00
|
|
|
# to make that practical
|
|
|
|
|
|
|
|
if [ ! -r $topdir/.config ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "No readable file at $topdir/.config"
|
|
|
|
echo "Has NuttX been configured?"
|
|
|
|
exit 1
|
2008-09-11 23:54:23 +02:00
|
|
|
fi
|
|
|
|
|
sched: move etc romfs mount from nsh to sched/init
Usually the startup script is placed under /etc. The contents of the etc directory
are compiled and linked with Nuttx binary in the form of romfs. After startup,
it will be mounted by Nsh.
etc is generated by the different boards, that use genromfs and xxd tools to generate
and compile it into the Nuttx, for example: boards/arm/at32/at32f437-mini/tool/mkromfs.sh
The more common method is etc image generated from the content in the corresponding
board/arch/board/board/src/etc directory, and added by Makefile for example:
boards/sim/sim/sim/src/etc.
But in kernel/protected mode, Nuttx kernel and apps are run in different privileged/
non-privileged mode or the isolated binarys, so as that nsh should use syscall to
access Nuttx kernel by exported API. In this scenario, nsh can not mount the etc image
content, because that is generated in board and as a part of Nuttx kernel.
changes:
- move etc romfs mount from nsh to Nuttx, but keep the script to parse and execute.
- move and rename the related CONFIG, move customized nsh_romfsimg.h to etc_romfs.c
in boards, and no need declaration for romfs_img/romfs_img_len.
This commit changes and updates all configurations in Nuttx arch/board as much as possible,
but if any missing, please refer to the following simple guide:
- rename CONFIG_NSH_ROMFSETC to CONFIG_ETC_ROMFS, and delete CONFIG_NSH_ARCHROMFS in defconfig
- rename the etc romfs mount configs, for example CONFIG_NSH_FATDEVNO to CONFIG_ETC_FATDEVNO
- move customized nsh_romfsimg.h to etc_romfs.c in board/arch/board/board/src and no need
declaration for romfs_img/romfs_img_len.
- delete default nsh_romfsimg.h, if ROMFSETC is enabled, should generate and compile etc_romfs.c
in board/arch/board/board/src.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-11-26 04:51:46 +01:00
|
|
|
romfsetc=`grep CONFIG_ETC_ROMFS= $topdir/.config | cut -d'=' -f2`
|
2008-09-11 23:54:23 +02:00
|
|
|
disablempt=`grep CONFIG_DISABLE_MOUNTPOINT= $topdir/.config | cut -d'=' -f2`
|
2011-03-18 21:35:31 +01:00
|
|
|
disablescript=`grep CONFIG_NSH_DISABLESCRIPT= $topdir/.config | cut -d'=' -f2`
|
2008-09-11 23:54:23 +02:00
|
|
|
devconsole=`grep CONFIG_DEV_CONSOLE= $topdir/.config | cut -d'=' -f2`
|
|
|
|
romfs=`grep CONFIG_FS_ROMFS= $topdir/.config | cut -d'=' -f2`
|
sched: move etc romfs mount from nsh to sched/init
Usually the startup script is placed under /etc. The contents of the etc directory
are compiled and linked with Nuttx binary in the form of romfs. After startup,
it will be mounted by Nsh.
etc is generated by the different boards, that use genromfs and xxd tools to generate
and compile it into the Nuttx, for example: boards/arm/at32/at32f437-mini/tool/mkromfs.sh
The more common method is etc image generated from the content in the corresponding
board/arch/board/board/src/etc directory, and added by Makefile for example:
boards/sim/sim/sim/src/etc.
But in kernel/protected mode, Nuttx kernel and apps are run in different privileged/
non-privileged mode or the isolated binarys, so as that nsh should use syscall to
access Nuttx kernel by exported API. In this scenario, nsh can not mount the etc image
content, because that is generated in board and as a part of Nuttx kernel.
changes:
- move etc romfs mount from nsh to Nuttx, but keep the script to parse and execute.
- move and rename the related CONFIG, move customized nsh_romfsimg.h to etc_romfs.c
in boards, and no need declaration for romfs_img/romfs_img_len.
This commit changes and updates all configurations in Nuttx arch/board as much as possible,
but if any missing, please refer to the following simple guide:
- rename CONFIG_NSH_ROMFSETC to CONFIG_ETC_ROMFS, and delete CONFIG_NSH_ARCHROMFS in defconfig
- rename the etc romfs mount configs, for example CONFIG_NSH_FATDEVNO to CONFIG_ETC_FATDEVNO
- move customized nsh_romfsimg.h to etc_romfs.c in board/arch/board/board/src and no need
declaration for romfs_img/romfs_img_len.
- delete default nsh_romfsimg.h, if ROMFSETC is enabled, should generate and compile etc_romfs.c
in board/arch/board/board/src.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-11-26 04:51:46 +01:00
|
|
|
romfsmpt=`grep CONFIG_ETC_ROMFSMOUNTPT= $topdir/.config | cut -d'=' -f2`
|
2011-03-18 21:35:31 +01:00
|
|
|
initscript=`grep CONFIG_NSH_INITSCRIPT= $topdir/.config | cut -d'=' -f2`
|
2022-04-15 15:56:00 +02:00
|
|
|
sysinitscript=`grep CONFIG_NSH_SYSINITSCRIPT= $topdir/.config | cut -d'=' -f2`
|
sched: move etc romfs mount from nsh to sched/init
Usually the startup script is placed under /etc. The contents of the etc directory
are compiled and linked with Nuttx binary in the form of romfs. After startup,
it will be mounted by Nsh.
etc is generated by the different boards, that use genromfs and xxd tools to generate
and compile it into the Nuttx, for example: boards/arm/at32/at32f437-mini/tool/mkromfs.sh
The more common method is etc image generated from the content in the corresponding
board/arch/board/board/src/etc directory, and added by Makefile for example:
boards/sim/sim/sim/src/etc.
But in kernel/protected mode, Nuttx kernel and apps are run in different privileged/
non-privileged mode or the isolated binarys, so as that nsh should use syscall to
access Nuttx kernel by exported API. In this scenario, nsh can not mount the etc image
content, because that is generated in board and as a part of Nuttx kernel.
changes:
- move etc romfs mount from nsh to Nuttx, but keep the script to parse and execute.
- move and rename the related CONFIG, move customized nsh_romfsimg.h to etc_romfs.c
in boards, and no need declaration for romfs_img/romfs_img_len.
This commit changes and updates all configurations in Nuttx arch/board as much as possible,
but if any missing, please refer to the following simple guide:
- rename CONFIG_NSH_ROMFSETC to CONFIG_ETC_ROMFS, and delete CONFIG_NSH_ARCHROMFS in defconfig
- rename the etc romfs mount configs, for example CONFIG_NSH_FATDEVNO to CONFIG_ETC_FATDEVNO
- move customized nsh_romfsimg.h to etc_romfs.c in board/arch/board/board/src and no need
declaration for romfs_img/romfs_img_len.
- delete default nsh_romfsimg.h, if ROMFSETC is enabled, should generate and compile etc_romfs.c
in board/arch/board/board/src.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-11-26 04:51:46 +01:00
|
|
|
romfsdevno=`grep CONFIG_ETC_ROMFSDEVNO= $topdir/.config | cut -d'=' -f2`
|
|
|
|
romfssectsize=`grep CONFIG_ETC_ROMFSSECTSIZE= $topdir/.config | cut -d'=' -f2`
|
2018-04-14 23:24:04 +02:00
|
|
|
|
|
|
|
# If we disabled FAT FS requirement, we don't need to check it
|
|
|
|
|
|
|
|
if [ "$usefat" = true ]; then
|
|
|
|
fatfs=`grep CONFIG_FS_FAT= $topdir/.config | cut -d'=' -f2`
|
sched: move etc romfs mount from nsh to sched/init
Usually the startup script is placed under /etc. The contents of the etc directory
are compiled and linked with Nuttx binary in the form of romfs. After startup,
it will be mounted by Nsh.
etc is generated by the different boards, that use genromfs and xxd tools to generate
and compile it into the Nuttx, for example: boards/arm/at32/at32f437-mini/tool/mkromfs.sh
The more common method is etc image generated from the content in the corresponding
board/arch/board/board/src/etc directory, and added by Makefile for example:
boards/sim/sim/sim/src/etc.
But in kernel/protected mode, Nuttx kernel and apps are run in different privileged/
non-privileged mode or the isolated binarys, so as that nsh should use syscall to
access Nuttx kernel by exported API. In this scenario, nsh can not mount the etc image
content, because that is generated in board and as a part of Nuttx kernel.
changes:
- move etc romfs mount from nsh to Nuttx, but keep the script to parse and execute.
- move and rename the related CONFIG, move customized nsh_romfsimg.h to etc_romfs.c
in boards, and no need declaration for romfs_img/romfs_img_len.
This commit changes and updates all configurations in Nuttx arch/board as much as possible,
but if any missing, please refer to the following simple guide:
- rename CONFIG_NSH_ROMFSETC to CONFIG_ETC_ROMFS, and delete CONFIG_NSH_ARCHROMFS in defconfig
- rename the etc romfs mount configs, for example CONFIG_NSH_FATDEVNO to CONFIG_ETC_FATDEVNO
- move customized nsh_romfsimg.h to etc_romfs.c in board/arch/board/board/src and no need
declaration for romfs_img/romfs_img_len.
- delete default nsh_romfsimg.h, if ROMFSETC is enabled, should generate and compile etc_romfs.c
in board/arch/board/board/src.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-11-26 04:51:46 +01:00
|
|
|
fatdevno=`grep CONFIG_ETC_FATDEVNO= $topdir/.config | cut -d'=' -f2`
|
|
|
|
fatsectsize=`grep CONFIG_ETC_FATSECTSIZE= $topdir/.config | cut -d'=' -f2`
|
|
|
|
fatnsectors=`grep CONFIG_ETC_FATNSECTORS= $topdir/.config | cut -d'=' -f2`
|
|
|
|
fatmpt=`grep CONFIG_ETC_FATMOUNTPT= $topdir/.config | cut -d'=' -f2`
|
2018-04-14 23:24:04 +02:00
|
|
|
fi
|
2008-09-11 23:54:23 +02:00
|
|
|
|
|
|
|
# The following settings are required for general ROMFS support
|
|
|
|
#
|
|
|
|
# Mountpoint support must be enabled
|
|
|
|
|
|
|
|
if [ "X$disablempt" = "Xy" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "Mountpoint support is required for this feature"
|
|
|
|
echo "Set CONFIG_DISABLE_MOUNTPOINT=n to continue"
|
|
|
|
exit 1
|
2008-09-11 23:54:23 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Scripting support must be enabled
|
|
|
|
|
|
|
|
if [ "X$disablescript" = "Xy" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "NSH scripting support is required for this feature"
|
|
|
|
echo "Set CONFIG_NSH_DISABLESCRIPT=n to continue"
|
|
|
|
exit 1
|
2008-09-11 23:54:23 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# ROMFS support is required, of course
|
|
|
|
|
|
|
|
if [ "X$romfs" != "Xy" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "ROMFS support is disabled in the NuttX configuration"
|
|
|
|
echo "Set CONFIG_FS_ROMFS=y to continue"
|
|
|
|
exit 0
|
2008-09-11 23:54:23 +02:00
|
|
|
fi
|
|
|
|
|
2018-04-14 23:24:04 +02:00
|
|
|
# If it is the default rcS.template, then it also requires FAT FS support
|
2008-09-11 23:54:23 +02:00
|
|
|
|
2018-04-14 23:24:04 +02:00
|
|
|
if [ "$usefat" = true -a "X$fatfs" != "Xy" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "FAT FS support is disabled in the NuttX configuration"
|
|
|
|
echo "Set CONFIG_FS_FAT=y to continue"
|
|
|
|
exit 0
|
2008-09-11 23:54:23 +02:00
|
|
|
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
|
2022-01-19 10:20:34 +01:00
|
|
|
romfsmpt=\"/etc\"
|
2008-09-11 23:54:23 +02:00
|
|
|
fi
|
|
|
|
if [ -z "$initscript" ]; then
|
2022-01-19 10:20:34 +01:00
|
|
|
initscript=\"init.d/rcS\"
|
2008-09-11 23:54:23 +02:00
|
|
|
fi
|
2022-04-15 15:56:00 +02:00
|
|
|
if [ -z "$sysinitscript" ]; then
|
|
|
|
sysinitscript=\"init.d/rc.sysinit\"
|
|
|
|
fi
|
2008-09-11 23:54:23 +02:00
|
|
|
if [ -z "$romfsdevno" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
romfsdevno=0
|
2008-09-11 23:54:23 +02:00
|
|
|
fi
|
|
|
|
if [ -z "$romfssectsize" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
romfssectsize=64
|
2008-09-11 23:54:23 +02:00
|
|
|
fi
|
|
|
|
|
2018-04-14 23:24:04 +02:00
|
|
|
# If FAT FS is a requirement
|
2008-09-11 23:54:23 +02:00
|
|
|
|
2018-04-14 23:24:04 +02:00
|
|
|
if [ "$usefat" = true ]; then
|
|
|
|
|
|
|
|
# Supply defaults for all un-defined FAT FS settings
|
|
|
|
|
|
|
|
if [ -z "$fatdevno" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
fatdevno=1
|
2018-04-14 23:24:04 +02:00
|
|
|
fi
|
|
|
|
if [ -z "$fatsectsize" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
fatsectsize=512
|
2018-04-14 23:24:04 +02:00
|
|
|
fi
|
|
|
|
if [ -z "$fatnsectors" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
fatnsectors=1024
|
2018-04-14 23:24:04 +02:00
|
|
|
fi
|
|
|
|
if [ -z "$fatmpt" ]; then
|
2022-01-19 10:20:34 +01:00
|
|
|
fatmpt=\"/tmp\"
|
2018-04-14 23:24:04 +02:00
|
|
|
fi
|
2008-09-11 23:54:23 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Verify the mountpoint. Verify that it is an absolute path but not /, /dev,
|
|
|
|
# /., /./*, /.., or /../*
|
|
|
|
|
|
|
|
if [ ${romfsmpt:0:1} != "\"" ]; then
|
sched: move etc romfs mount from nsh to sched/init
Usually the startup script is placed under /etc. The contents of the etc directory
are compiled and linked with Nuttx binary in the form of romfs. After startup,
it will be mounted by Nsh.
etc is generated by the different boards, that use genromfs and xxd tools to generate
and compile it into the Nuttx, for example: boards/arm/at32/at32f437-mini/tool/mkromfs.sh
The more common method is etc image generated from the content in the corresponding
board/arch/board/board/src/etc directory, and added by Makefile for example:
boards/sim/sim/sim/src/etc.
But in kernel/protected mode, Nuttx kernel and apps are run in different privileged/
non-privileged mode or the isolated binarys, so as that nsh should use syscall to
access Nuttx kernel by exported API. In this scenario, nsh can not mount the etc image
content, because that is generated in board and as a part of Nuttx kernel.
changes:
- move etc romfs mount from nsh to Nuttx, but keep the script to parse and execute.
- move and rename the related CONFIG, move customized nsh_romfsimg.h to etc_romfs.c
in boards, and no need declaration for romfs_img/romfs_img_len.
This commit changes and updates all configurations in Nuttx arch/board as much as possible,
but if any missing, please refer to the following simple guide:
- rename CONFIG_NSH_ROMFSETC to CONFIG_ETC_ROMFS, and delete CONFIG_NSH_ARCHROMFS in defconfig
- rename the etc romfs mount configs, for example CONFIG_NSH_FATDEVNO to CONFIG_ETC_FATDEVNO
- move customized nsh_romfsimg.h to etc_romfs.c in board/arch/board/board/src and no need
declaration for romfs_img/romfs_img_len.
- delete default nsh_romfsimg.h, if ROMFSETC is enabled, should generate and compile etc_romfs.c
in board/arch/board/board/src.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-11-26 04:51:46 +01:00
|
|
|
echo "CONFIG_ETC_ROMFSMOUNTPT must be a string"
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "Change it so that it is enclosed in quotes."
|
|
|
|
exit 1
|
2008-09-11 23:54:23 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
uromfsmpt=`echo $romfsmpt | sed -e "s/\"//g"`
|
|
|
|
|
|
|
|
if [ ${uromfsmpt:0:1} != "/" ]; then
|
sched: move etc romfs mount from nsh to sched/init
Usually the startup script is placed under /etc. The contents of the etc directory
are compiled and linked with Nuttx binary in the form of romfs. After startup,
it will be mounted by Nsh.
etc is generated by the different boards, that use genromfs and xxd tools to generate
and compile it into the Nuttx, for example: boards/arm/at32/at32f437-mini/tool/mkromfs.sh
The more common method is etc image generated from the content in the corresponding
board/arch/board/board/src/etc directory, and added by Makefile for example:
boards/sim/sim/sim/src/etc.
But in kernel/protected mode, Nuttx kernel and apps are run in different privileged/
non-privileged mode or the isolated binarys, so as that nsh should use syscall to
access Nuttx kernel by exported API. In this scenario, nsh can not mount the etc image
content, because that is generated in board and as a part of Nuttx kernel.
changes:
- move etc romfs mount from nsh to Nuttx, but keep the script to parse and execute.
- move and rename the related CONFIG, move customized nsh_romfsimg.h to etc_romfs.c
in boards, and no need declaration for romfs_img/romfs_img_len.
This commit changes and updates all configurations in Nuttx arch/board as much as possible,
but if any missing, please refer to the following simple guide:
- rename CONFIG_NSH_ROMFSETC to CONFIG_ETC_ROMFS, and delete CONFIG_NSH_ARCHROMFS in defconfig
- rename the etc romfs mount configs, for example CONFIG_NSH_FATDEVNO to CONFIG_ETC_FATDEVNO
- move customized nsh_romfsimg.h to etc_romfs.c in board/arch/board/board/src and no need
declaration for romfs_img/romfs_img_len.
- delete default nsh_romfsimg.h, if ROMFSETC is enabled, should generate and compile etc_romfs.c
in board/arch/board/board/src.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-11-26 04:51:46 +01:00
|
|
|
echo "CONFIG_ETC_ROMFSMOUNTPT must be an absolute path in the target FS"
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "Change it so that it begins with the character '/'. Eg. /etc"
|
|
|
|
exit 1
|
2008-09-11 23:54:23 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
tmpdir=$uromfsmpt
|
|
|
|
while [ ${tmpdir:0:1} == "/" ]; do
|
2020-01-05 17:29:59 +01:00
|
|
|
tmpdir=${tmpdir:1}
|
2008-09-11 23:54:23 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
if [ -z "$tmpdir" -o "X$tmpdir" = "Xdev" -o "X$tmpdir" = "." -o \
|
|
|
|
${tmpdir:0:2} = "./" -o "X$tmpdir" = ".." -o ${tmpdir:0:3} = "../" ]; then
|
sched: move etc romfs mount from nsh to sched/init
Usually the startup script is placed under /etc. The contents of the etc directory
are compiled and linked with Nuttx binary in the form of romfs. After startup,
it will be mounted by Nsh.
etc is generated by the different boards, that use genromfs and xxd tools to generate
and compile it into the Nuttx, for example: boards/arm/at32/at32f437-mini/tool/mkromfs.sh
The more common method is etc image generated from the content in the corresponding
board/arch/board/board/src/etc directory, and added by Makefile for example:
boards/sim/sim/sim/src/etc.
But in kernel/protected mode, Nuttx kernel and apps are run in different privileged/
non-privileged mode or the isolated binarys, so as that nsh should use syscall to
access Nuttx kernel by exported API. In this scenario, nsh can not mount the etc image
content, because that is generated in board and as a part of Nuttx kernel.
changes:
- move etc romfs mount from nsh to Nuttx, but keep the script to parse and execute.
- move and rename the related CONFIG, move customized nsh_romfsimg.h to etc_romfs.c
in boards, and no need declaration for romfs_img/romfs_img_len.
This commit changes and updates all configurations in Nuttx arch/board as much as possible,
but if any missing, please refer to the following simple guide:
- rename CONFIG_NSH_ROMFSETC to CONFIG_ETC_ROMFS, and delete CONFIG_NSH_ARCHROMFS in defconfig
- rename the etc romfs mount configs, for example CONFIG_NSH_FATDEVNO to CONFIG_ETC_FATDEVNO
- move customized nsh_romfsimg.h to etc_romfs.c in board/arch/board/board/src and no need
declaration for romfs_img/romfs_img_len.
- delete default nsh_romfsimg.h, if ROMFSETC is enabled, should generate and compile etc_romfs.c
in board/arch/board/board/src.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-11-26 04:51:46 +01:00
|
|
|
echo "Invalid CONFIG_ETC_ROMFSMOUNTPT selection."
|
2020-01-05 17:29:59 +01:00
|
|
|
exit 1
|
2008-09-11 23:54:23 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Verify that the path to the init file is a relative path and not ., ./*, .., or ../*
|
|
|
|
|
|
|
|
if [ ${initscript:0:1} != "\"" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "CONFIG_NSH_INITSCRIPT must be a string"
|
|
|
|
echo "Change it so that it is enclosed in quotes."
|
|
|
|
exit 1
|
2008-09-11 23:54:23 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
uinitscript=`echo $initscript | sed -e "s/\"//g"`
|
|
|
|
|
|
|
|
if [ ${uinitscript:0:1} == "/" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "CONFIG_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
|
2008-09-11 23:54:23 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "X$uinitscript" = "." -o ${uinitscript:0:2} = "./" -o \
|
|
|
|
"X$uinitscript" = ".." -o ${uinitscript:0:3} = "../" ]; then
|
2020-01-05 17:29:59 +01:00
|
|
|
echo "Invalid CONFIG_NSH_INITSCRIPT selection. Must not begin with . or .."
|
|
|
|
exit 1
|
2008-09-11 23:54:23 +02:00
|
|
|
fi
|
|
|
|
|
2022-04-15 15:56:00 +02:00
|
|
|
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
|
|
|
|
|
2008-09-11 23:54:23 +02:00
|
|
|
# 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; }
|
|
|
|
|
2022-04-15 15:56:00 +02:00
|
|
|
# Create the rc.sysinit file from the rc.sysinit.template
|
2008-09-11 23:54:23 +02:00
|
|
|
|
2022-04-15 15:56:00 +02:00
|
|
|
if [ ! -r $rcsysinittemplate ]; then
|
|
|
|
echo "$rcsysinittemplate does not exist"
|
2020-01-05 17:29:59 +01:00
|
|
|
rmdir $workingdir
|
|
|
|
exit 1
|
2008-09-11 23:54:23 +02:00
|
|
|
fi
|
|
|
|
|
2018-04-14 23:24:04 +02:00
|
|
|
# If we are using FAT FS with RAMDISK we need to setup it
|
|
|
|
|
|
|
|
if [ "$usefat" = true ]; then
|
2022-04-15 15:56:00 +02:00
|
|
|
cat $rcsysinittemplate | \
|
2018-04-14 23:24:04 +02:00
|
|
|
sed -e "s,XXXMKRDMINORXXX,$fatdevno,g" | \
|
|
|
|
sed -e "s,XXMKRDSECTORSIZEXXX,$fatsectsize,g" | \
|
|
|
|
sed -e "s,XXMKRDBLOCKSXXX,$fatnsectors,g" | \
|
2022-04-15 15:56:00 +02:00
|
|
|
sed -e "s,XXXRDMOUNTPOINTXXX,$fatmpt,g" >$rcsysinitfile
|
2018-04-14 23:24:04 +02:00
|
|
|
else
|
2022-04-15 15:56:00 +02:00
|
|
|
cp $rcsysinittemplate $rcsysinitfile
|
2018-04-14 23:24:04 +02:00
|
|
|
fi
|
2008-09-11 23:54:23 +02:00
|
|
|
|
2022-04-15 15:56:00 +02:00
|
|
|
# Create the rcS file from the rcS.template
|
|
|
|
|
|
|
|
if [ ! -r $rcstemplate ]; then
|
|
|
|
echo "$rcstemplate does not exist"
|
|
|
|
rmdir $workingdir
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cp $rcstemplate $rcsfile
|
|
|
|
|
2008-09-11 23:54:23 +02:00
|
|
|
# And install it at the specified relative location
|
|
|
|
|
2014-10-15 20:25:47 +02:00
|
|
|
# Fix for BSD install without -D option
|
|
|
|
mkdir -p $workingdir/$uinitscript
|
|
|
|
rmdir $workingdir/$uinitscript
|
|
|
|
|
2022-04-15 15:56:00 +02:00
|
|
|
install -m 0755 $rcsysinitfile $workingdir/$usysinitscript || \
|
|
|
|
{ echo "Failed to install $rcsysinitfile at $workingdir/$usysinitscript"; rm -f $rcsysinitfile; exit 1; }
|
|
|
|
rm -f $rcsysinitfile
|
|
|
|
|
2014-10-15 20:25:47 +02:00
|
|
|
install -m 0755 $rcsfile $workingdir/$uinitscript || \
|
2008-09-11 23:54:23 +02:00
|
|
|
{ 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
|
|
|
|
|
2022-01-27 14:21:52 +01:00
|
|
|
echo '#include <nuttx/compiler.h>' >${headerfile}
|
|
|
|
xxd -i ${romfsimg} | sed 's/^unsigned char/const unsigned char aligned_data(4)/g' >>${headerfile} || \
|
2019-10-08 05:52:55 +02:00
|
|
|
{ echo "ERROR: xxd of $< failed" ; rm -f $romfsimg; exit 1 ; }
|
2008-09-11 23:54:23 +02:00
|
|
|
rm -f $romfsimg
|