tools/mkromfsimg.sh: Include an option in mkromfsimg.sh to ignore FAT/RAMDISK. This permits you to build tiny systems with ROMFS but with the rather large FAT FS support.

This commit is contained in:
Alan Carvalho de Assis
2018-04-14 15:24:04 -06:00
committed by Gregory Nutt
parent 1d8fd9e034
commit f45ec5c695
+31 -4
View File
@@ -2,7 +2,7 @@
############################################################################ ############################################################################
# tools/mkromfsimg.sh # tools/mkromfsimg.sh
# #
# Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved. # Copyright (C) 2008, 2011, 2018 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org> # Author: Gregory Nutt <gnutt@nuttx.org>
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@@ -45,8 +45,19 @@ headerfile=nsh_romfsimg.h
# Get the input parameters # Get the input parameters
nofat=$1
usefat=true
topdir=$2
usage="USAGE: $0 [-nofat] <topdir>"
# Verify if we have the optional "-nofat"
if [ "$nofat" == "-nofat" ]; then
echo "We will not mount a FAT/RAMDISK!"
usefat=false
else
topdir=$1 topdir=$1
usage="USAGE: $0 <topdir>" fi
if [ -z "$topdir" -o ! -d "$topdir" ]; then if [ -z "$topdir" -o ! -d "$topdir" ]; then
echo "The full path to the NuttX base directory must be provided on the command line" echo "The full path to the NuttX base directory must be provided on the command line"
@@ -75,11 +86,16 @@ romfsmpt=`grep CONFIG_NSH_ROMFSMOUNTPT= $topdir/.config | cut -d'=' -f2`
initscript=`grep CONFIG_NSH_INITSCRIPT= $topdir/.config | cut -d'=' -f2` initscript=`grep CONFIG_NSH_INITSCRIPT= $topdir/.config | cut -d'=' -f2`
romfsdevno=`grep CONFIG_NSH_ROMFSDEVNO= $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` romfssectsize=`grep CONFIG_NSH_ROMFSSECTSIZE= $topdir/.config | cut -d'=' -f2`
# 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` fatfs=`grep CONFIG_FS_FAT= $topdir/.config | cut -d'=' -f2`
fatdevno=`grep CONFIG_NSH_FATDEVNO= $topdir/.config | cut -d'=' -f2` fatdevno=`grep CONFIG_NSH_FATDEVNO= $topdir/.config | cut -d'=' -f2`
fatsectsize=`grep CONFIG_NSH_FATSECTSIZE= $topdir/.config | cut -d'=' -f2` fatsectsize=`grep CONFIG_NSH_FATSECTSIZE= $topdir/.config | cut -d'=' -f2`
fatnsectors=`grep CONFIG_NSH_FATNSECTORS= $topdir/.config | cut -d'=' -f2` fatnsectors=`grep CONFIG_NSH_FATNSECTORS= $topdir/.config | cut -d'=' -f2`
fatmpt=`grep CONFIG_NSH_FATMOUNTPT= $topdir/.config | cut -d'=' -f2` fatmpt=`grep CONFIG_NSH_FATMOUNTPT= $topdir/.config | cut -d'=' -f2`
fi
# The following settings are required for general ROMFS support # The following settings are required for general ROMFS support
# #
@@ -129,9 +145,9 @@ if [ "X$romfs" != "Xy" ]; then
exit 0 exit 0
fi fi
# The options in the default rcS.template also require FAT FS support # If it is the default rcS.template, then it also requires FAT FS support
if [ "X$fatfs" != "Xy" ]; then if [ "$usefat" = true -a "X$fatfs" != "Xy" ]; then
echo "FAT FS support is disabled in the NuttX configuration" echo "FAT FS support is disabled in the NuttX configuration"
echo "Set CONFIG_FS_FAT=y to continue" echo "Set CONFIG_FS_FAT=y to continue"
exit 0 exit 0
@@ -160,6 +176,10 @@ if [ -z "$romfssectsize" ]; then
romfssectsize=64 romfssectsize=64
fi fi
# If FAT FS is a requirement
if [ "$usefat" = true ]; then
# Supply defaults for all un-defined FAT FS settings # Supply defaults for all un-defined FAT FS settings
if [ -z "$fatdevno" ]; then if [ -z "$fatdevno" ]; then
@@ -174,6 +194,7 @@ fi
if [ -z "$fatmpt" ]; then if [ -z "$fatmpt" ]; then
fatmpt="/tmp" fatmpt="/tmp"
fi fi
fi
# Verify the mountpoint. Verify that it is an absolute path but not /, /dev, # Verify the mountpoint. Verify that it is an absolute path but not /, /dev,
# /., /./*, /.., or /../* # /., /./*, /.., or /../*
@@ -238,11 +259,17 @@ if [ ! -r $rcstemplate ]; then
exit 1 exit 1
fi fi
# If we are using FAT FS with RAMDISK we need to setup it
if [ "$usefat" = true ]; then
cat $rcstemplate | \ cat $rcstemplate | \
sed -e "s,XXXMKRDMINORXXX,$fatdevno,g" | \ sed -e "s,XXXMKRDMINORXXX,$fatdevno,g" | \
sed -e "s,XXMKRDSECTORSIZEXXX,$fatsectsize,g" | \ sed -e "s,XXMKRDSECTORSIZEXXX,$fatsectsize,g" | \
sed -e "s,XXMKRDBLOCKSXXX,$fatnsectors,g" | \ sed -e "s,XXMKRDBLOCKSXXX,$fatnsectors,g" | \
sed -e "s,XXXRDMOUNTPOINTXXX,$fatmpt,g" >$rcsfile sed -e "s,XXXRDMOUNTPOINTXXX,$fatmpt,g" >$rcsfile
else
cp $rcstemplate $rcsfile
fi
# And install it at the specified relative location # And install it at the specified relative location