summaryrefslogtreecommitdiff
path: root/recipes-images/images/files/library
diff options
context:
space:
mode:
authorSanchayan Maity <maitysanchayan@gmail.com>2017-07-26 17:21:39 +0530
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2017-10-03 18:23:32 +0200
commit8b2eca579bfcdfda28e26733de395c8a107080c3 (patch)
treebf22919d771eca3050aac3e6980a13029e8da974 /recipes-images/images/files/library
parentcdb49a617b21e104de23471f29d6c99d3a420610 (diff)
recipes-images: images: Use ext4 by default for iMX6 modules
Use ext4 by default for iMX6 modules. Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com> Acked-by: Max Krummenacher <max.krummenacher@toradex.com>
Diffstat (limited to 'recipes-images/images/files/library')
-rwxr-xr-xrecipes-images/images/files/library/genext4fs.sh80
-rw-r--r--recipes-images/images/files/library/imx6/flash_blk.scr2
-rw-r--r--recipes-images/images/files/library/imx6/flash_eth.scr2
-rwxr-xr-xrecipes-images/images/files/library/imx6/update.sh12
4 files changed, 88 insertions, 8 deletions
diff --git a/recipes-images/images/files/library/genext4fs.sh b/recipes-images/images/files/library/genext4fs.sh
new file mode 100755
index 0000000..9ce6735
--- /dev/null
+++ b/recipes-images/images/files/library/genext4fs.sh
@@ -0,0 +1,80 @@
+#!/bin/sh
+#creates a file containing a ext4 binary blob of the content of the ../rootfs folder
+
+# sometimes we need the binary echo, not the shell builtin
+ECHO=`which echo`
+
+MOUNTPOINT="mnt/tdx-rootfs"
+
+Usage()
+{
+ echo "creates a file containing a ext4 binary blob. Output file name taken from command line"
+ echo "Usage: genext4fs.sh [OPTION]... dest_file_name"
+ echo "-h : Prints this message"
+ echo "-b : Sets the partition size in MBytes, default 256"
+ echo "-d : Selects the directory which contains the partition content, default ../rootfs"
+ echo ""
+}
+
+PARTITIONSIZE=256
+SRCPATH=../rootfs
+
+while getopts "b:d:h" Option ; do
+ case $Option in
+ h) Usage
+ # Exit if only usage (-h) was specfied.
+ if [[ "$#" -eq "1" ]] ; then
+ exit 10
+ fi
+ exit 0
+ ;;
+ b) PARTITIONSIZE=$OPTARG
+ ;;
+ d) SRCPATH=$OPTARG
+ ;;
+ esac
+done
+#adjust the commandline arg for the now used options
+shift $(($OPTIND - 1))
+
+#create the file used for the loopbackdevice and format it for ext4
+#answer y to "is not a block special device"
+dd if=/dev/zero of=$@ bs=1024k count=$PARTITIONSIZE
+mkfs.ext4 -F -L rootfs $@
+#disable fsck checks based on mount count or time interval
+tune2fs -c 0 -i 0 $@
+
+#prepare mountpoint for the loopdevice
+sudo mkdir -p $MOUNTPOINT
+sudo umount $MOUNTPOINT &> /dev/null
+sudo rm -rf $MOUNTPOINT/*
+#mount the file as a loopdevice
+#there seems to be a race between mkfs.ext4 not yet finished and mount already trying to mount, so try until it works
+MOUNTED=0
+while [ "$MOUNTED" -eq "0" ] ; do
+ sync
+ sleep 1
+ sudo mount $@ $MOUNTPOINT/ -o loop -t ext4
+ MOUNTED=`mount | grep -c "$MOUNTPOINT"`
+done
+#extract rootfs into the file
+sudo cp -a $SRCPATH/* $MOUNTPOINT
+if [ "$?" -ne "0" ] ; then
+ $ECHO -e "\033[1mCopying the rootfs failed.\033[0m"
+ echo "Check for error messages from cp"
+ sudo rm $@
+ exit 1
+fi
+
+#unmount again
+sudo umount $MOUNTPOINT
+
+#if the mounting was unsuccesful all rootfs data now still is in MOUNTPOINT, and $@ contains an empty fs
+#delete $@ in that case to fail early
+sync
+FAILED=`ls $MOUNTPOINT | wc -l`
+if [ "$FAILED" -ne "0" ] ; then
+ $ECHO -e "\033[1mMounting the loopdevice $@ failed.\033[0m"
+ sudo rm $@
+ exit 1
+fi
diff --git a/recipes-images/images/files/library/imx6/flash_blk.scr b/recipes-images/images/files/library/imx6/flash_blk.scr
index 2a905ac..6df7797 100644
--- a/recipes-images/images/files/library/imx6/flash_blk.scr
+++ b/recipes-images/images/files/library/imx6/flash_blk.scr
@@ -17,7 +17,7 @@ setenv migrate_configblock 'run check_configblock; mmc dev 0 0 && mmc read ${loa
setenv migrate_uboot_old 'setenv uboot_hwpart 0; run update_spl && run update_uboot_bin; setenv uboot_hwpart 1'
setenv migrate_uboot 'run update_spl && run update_uboot_bin && mmc bootbus 0 2 1 2 && mmc partconf 0 1 1 0'
-setenv cp_file_chunk 'load ${interface} ${drive}:1 ${loadaddr} ${board_name}/root.ext3-${filenum} || setenv filesize 0; run set_blkcnt; mmc dev 0 0 && mmc write ${loadaddr} ${blkstart} ${blkcnt}'
+setenv cp_file_chunk 'load ${interface} ${drive}:1 ${loadaddr} ${board_name}/root.ext4-${filenum} || setenv filesize 0; run set_blkcnt; mmc dev 0 0 && mmc write ${loadaddr} ${blkstart} ${blkcnt}'
setenv update_spl 'load ${interface} ${drive}:1 ${loadaddr} ${board_name}/SPL && run set_blkcnt && mmc dev 0 ${uboot_hwpart} && mmc write ${loadaddr} 2 ${blkcnt}'
setenv update_uboot_bin 'load ${interface} ${drive}:1 ${loadaddr} ${board_name}/u-boot.imx-spl && run set_blkcnt && mmc dev 0 ${uboot_hwpart} && mmc write ${loadaddr} 8a ${blkcnt}'
diff --git a/recipes-images/images/files/library/imx6/flash_eth.scr b/recipes-images/images/files/library/imx6/flash_eth.scr
index 4866e5c..75ee572 100644
--- a/recipes-images/images/files/library/imx6/flash_eth.scr
+++ b/recipes-images/images/files/library/imx6/flash_eth.scr
@@ -15,7 +15,7 @@ setenv migrate_configblock 'run check_configblock; mmc dev 0 0 && mmc read ${loa
setenv migrate_uboot_old 'setenv uboot_hwpart 0; run update_spl && run update_uboot_bin; setenv uboot_hwpart 1'
setenv migrate_uboot 'run update_spl && run update_uboot_bin && mmc bootbus 0 2 1 2 && mmc partconf 0 1 1 0'
-setenv cp_file_chunk 'tftpboot ${loadaddr} ${board_name}/root.ext3-${filenum} || setenv filesize 0; run set_blkcnt; mmc dev 0 0 && mmc write ${loadaddr} ${blkstart} ${blkcnt}'
+setenv cp_file_chunk 'tftpboot ${loadaddr} ${board_name}/root.ext4-${filenum} || setenv filesize 0; run set_blkcnt; mmc dev 0 0 && mmc write ${loadaddr} ${blkstart} ${blkcnt}'
setenv update_spl 'tftpboot ${loadaddr} ${board_name}/SPL && run set_blkcnt && mmc dev 0 ${uboot_hwpart} && mmc write ${loadaddr} 2 ${blkcnt}'
setenv update_uboot_bin 'tftpboot ${loadaddr} ${board_name}/u-boot.imx-spl && run set_blkcnt && mmc dev 0 ${uboot_hwpart} && mmc write ${loadaddr} 8a ${blkcnt}'
diff --git a/recipes-images/images/files/library/imx6/update.sh b/recipes-images/images/files/library/imx6/update.sh
index 5d9384f..fb9510d 100755
--- a/recipes-images/images/files/library/imx6/update.sh
+++ b/recipes-images/images/files/library/imx6/update.sh
@@ -131,7 +131,7 @@ case "$MODTYPE" in
"apalis-imx6")
# assumed minimal eMMC size [in sectors of 512]
EMMC_SIZE=$(expr 1024 \* 3500 \* 2)
- IMAGEFILE=root.ext3
+ IMAGEFILE=root.ext4
KERNEL_DEVICETREE="imx6q-apalis-eval.dtb imx6q-apalis_v1_0-eval.dtb \
imx6q-apalis-ixora.dtb imx6q-apalis_v1_0-ixora.dtb \
imx6q-apalis-ixora-v1.1.dtb"
@@ -141,7 +141,7 @@ case "$MODTYPE" in
"colibri-imx6")
# assumed minimal eMMC size [in sectors of 512]
EMMC_SIZE=$(expr 1024 \* 3500 \* 2)
- IMAGEFILE=root.ext3
+ IMAGEFILE=root.ext4
KERNEL_DEVICETREE="imx6dl-colibri-eval-v3.dtb imx6dl-colibri-cam-eval-v3.dtb imx6dl-colibri-aster.dtb"
LOCPATH="imx_flash"
OUT_DIR="$OUT_DIR/colibri_imx6"
@@ -184,7 +184,7 @@ fi
MCOPY=`command -v mcopy` || { echo >&2 "Program mcopy not available. Aborting."; exit 1; }
PARTED=`command -v parted` || PARTED=`sudo -s command -v parted` || { echo >&2 "Program parted not available. Aborting."; exit 1; }
MKFSVFAT=`command -v mkfs.fat` || MKFSVFAT=`sudo -s command -v mkfs.fat` || { echo >&2 "Program mkfs.fat not available. Aborting."; exit 1; }
-MKFSEXT3=`command -v mkfs.ext3` || MKFSEXT3=`sudo -s command -v mkfs.ext3` || { echo >&2 "Program mkfs.ext3 not available. Aborting."; exit 1; }
+MKFSEXT4=`command -v mkfs.ext4` || MKFSEXT4=`sudo -s command -v mkfs.ext4` || { echo >&2 "Program mkfs.ext4 not available. Aborting."; exit 1; }
dd --help >/dev/null 2>&1 || { echo >&2 "Program dd not available. Aborting."; exit 1; }
#Install trap to write a sensible message in case any of the commands below
@@ -247,7 +247,7 @@ ${PARTED} -s ${BINARIES}/mbr.bin mklabel msdos
${PARTED} -a none -s ${BINARIES}/mbr.bin unit s mkpart primary fat32 ${BOOT_START} $(expr ${ROOTFS_START} - 1 )
# the partition spans to the end of the disk, even though the fs size will be smaller
# on the target the fs is then grown to the full size
-${PARTED} -a none -s ${BINARIES}/mbr.bin unit s mkpart primary ext2 ${ROOTFS_START} $(expr ${EMMC_SIZE} \- ${ROOTFS_START} \- 1)
+${PARTED} -a none -s ${BINARIES}/mbr.bin unit s mkpart primary ext4 ${ROOTFS_START} $(expr ${EMMC_SIZE} \- ${ROOTFS_START} \- 1)
${PARTED} -s ${BINARIES}/mbr.bin unit s print
# get the size of the VFAT partition
BOOT_BLOCKS=$(LC_ALL=C ${PARTED} -s ${BINARIES}/mbr.bin unit b print \
@@ -293,7 +293,7 @@ NUMBER_OF_FILES=`sudo find ${ROOTFSPATH} | wc -l`
EXT_SIZE=`sudo du -DsB1 ${ROOTFSPATH} | awk -v min=$MIN_PARTITION_FREE_SIZE -v f=${NUMBER_OF_FILES} \
'{rootfs_size=$1+f*512;rootfs_size=int(rootfs_size/1024/985); print (rootfs_size+min) }'`
rm -f ${BINARIES}/${IMAGEFILE}
-sudo $LOCPATH/genext3fs.sh -d rootfs -b ${EXT_SIZE} ${BINARIES}/${IMAGEFILE} || exit 1
+sudo $LOCPATH/genext4fs.sh -d rootfs -b ${EXT_SIZE} ${BINARIES}/${IMAGEFILE} || exit 1
#copy to $OUT_DIR
@@ -304,7 +304,7 @@ sudo cp ${BINARIES}/fwd_eth.img "$OUT_DIR/../flash_eth.img"
sudo cp ${BINARIES}/fwd_mmc.img "$OUT_DIR/../flash_mmc.img"
if [ "$SPLIT" -ge 1 ] ; then
-sudo split -a 3 -b `expr 64 \* 1024 \* 1024` --numeric-suffixes=100 ${BINARIES}/${IMAGEFILE} "$OUT_DIR/root.ext3-"
+sudo split -a 3 -b `expr 64 \* 1024 \* 1024` --numeric-suffixes=100 ${BINARIES}/${IMAGEFILE} "$OUT_DIR/root.ext4-"
fi
#cleanup intermediate files