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

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
topdir=$1 nofat=$1
usage="USAGE: $0 <topdir>" 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
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`
fatfs=`grep CONFIG_FS_FAT= $topdir/.config | cut -d'=' -f2`
fatdevno=`grep CONFIG_NSH_FATDEVNO= $topdir/.config | cut -d'=' -f2` # If we disabled FAT FS requirement, we don't need to check it
fatsectsize=`grep CONFIG_NSH_FATSECTSIZE= $topdir/.config | cut -d'=' -f2`
fatnsectors=`grep CONFIG_NSH_FATNSECTORS= $topdir/.config | cut -d'=' -f2` if [ "$usefat" = true ]; then
fatmpt=`grep CONFIG_NSH_FATMOUNTPT= $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`
fatsectsize=`grep CONFIG_NSH_FATSECTSIZE= $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`
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,19 +176,24 @@ if [ -z "$romfssectsize" ]; then
romfssectsize=64 romfssectsize=64
fi fi
# Supply defaults for all un-defined FAT FS settings # If FAT FS is a requirement
if [ -z "$fatdevno" ]; then if [ "$usefat" = true ]; then
fatdevno=1
fi # Supply defaults for all un-defined FAT FS settings
if [ -z "$fatsectsize" ]; then
fatsectsize=512 if [ -z "$fatdevno" ]; then
fi fatdevno=1
if [ -z "$fatnsectors" ]; then fi
fatnsectors=1024 if [ -z "$fatsectsize" ]; then
fi fatsectsize=512
if [ -z "$fatmpt" ]; then fi
fatmpt="/tmp" if [ -z "$fatnsectors" ]; then
fatnsectors=1024
fi
if [ -z "$fatmpt" ]; then
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,
@ -238,11 +259,17 @@ if [ ! -r $rcstemplate ]; then
exit 1 exit 1
fi fi
cat $rcstemplate | \ # If we are using FAT FS with RAMDISK we need to setup it
sed -e "s,XXXMKRDMINORXXX,$fatdevno,g" | \
sed -e "s,XXMKRDSECTORSIZEXXX,$fatsectsize,g" | \ if [ "$usefat" = true ]; then
sed -e "s,XXMKRDBLOCKSXXX,$fatnsectors,g" | \ cat $rcstemplate | \
sed -e "s,XXXRDMOUNTPOINTXXX,$fatmpt,g" >$rcsfile 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
# And install it at the specified relative location # And install it at the specified relative location