From 28aba6b79a16d995659a2e46fe1a4be615de5c9b Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Mon, 7 Aug 2017 17:27:44 +0530 Subject: recipes-images: images: Use ext4 by default for TK1 modules Use ext4 by default for TK1 modules. Signed-off-by: Sanchayan Maity Acked-by: Max Krummenacher --- .../apalis-tk1-mainline_bin/flash_blk.scr | 2 +- .../apalis-tk1-mainline_bin/flash_eth.scr | 2 +- .../tegra-uboot-flasher/genext3fs.sh | 80 ---------------------- .../tegra-uboot-flasher/genext4fs.sh | 80 ++++++++++++++++++++++ .../files/apalis-tk1/apalis-tk1_bin/flash_blk.scr | 2 +- .../files/apalis-tk1/apalis-tk1_bin/flash_eth.scr | 2 +- .../apalis-tk1/tegra-uboot-flasher/genext4fs.sh | 1 + .../images/files/library/tegra/update.sh | 19 ++++- 8 files changed, 101 insertions(+), 87 deletions(-) delete mode 100755 recipes-images/images/files/apalis-tk1-mainline/tegra-uboot-flasher/genext3fs.sh create mode 100755 recipes-images/images/files/apalis-tk1-mainline/tegra-uboot-flasher/genext4fs.sh create mode 120000 recipes-images/images/files/apalis-tk1/tegra-uboot-flasher/genext4fs.sh diff --git a/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/flash_blk.scr b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/flash_blk.scr index 42e93b7..2aef05f 100644 --- a/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/flash_blk.scr +++ b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/flash_blk.scr @@ -11,7 +11,7 @@ setenv check_2 'setenv conf_blk_offset 0xfff; mmc read ${loadaddr} ${conf_blk_of setenv check_3 'setenv conf_blk_offset 0x7ff; mmc read ${loadaddr} ${conf_blk_offset} 1' setenv check_configblock 'setexpr toradex_oui_addr ${loadaddr} + 8; mmc dev 0 1; run check_1 || run check_2 || run check_3; crc32 -v ${toradex_oui_addr} 3 94305232' -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_uboot 'load ${interface} ${drive}:1 ${loadaddr} ${board_name}/${board_name}.img && run set_blkcnt && mmc dev 0 1 && mmc write ${loadaddr} 0x0 ${blkcnt}' diff --git a/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/flash_eth.scr b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/flash_eth.scr index 3442e3c..27bab62 100644 --- a/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/flash_eth.scr +++ b/recipes-images/images/files/apalis-tk1-mainline/apalis-tk1-mainline_bin/flash_eth.scr @@ -8,7 +8,7 @@ setenv check_2 'setenv conf_blk_offset 0xfff; mmc read ${loadaddr} ${conf_blk_of setenv check_3 'setenv conf_blk_offset 0x7ff; mmc read ${loadaddr} ${conf_blk_offset} 1' setenv check_configblock 'setexpr toradex_oui_addr ${loadaddr} + 8; mmc dev 0 1; run check_1 || run check_2 || run check_3; crc32 -v ${toradex_oui_addr} 3 94305232' -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_uboot 'tftpboot ${loadaddr} ${board_name}/${board_name}.img && run set_blkcnt && mmc dev 0 1 && mmc write ${loadaddr} 0x0 ${blkcnt}' diff --git a/recipes-images/images/files/apalis-tk1-mainline/tegra-uboot-flasher/genext3fs.sh b/recipes-images/images/files/apalis-tk1-mainline/tegra-uboot-flasher/genext3fs.sh deleted file mode 100755 index 93c2b60..0000000 --- a/recipes-images/images/files/apalis-tk1-mainline/tegra-uboot-flasher/genext3fs.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh -#creates a file containing a ext3 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 ext3 binary blob. Output file name taken from command line" - echo "Usage: genext3fs.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 ext3 -#answer y to "is not a block special device" -dd if=/dev/zero of=$@ bs=1024k count=$PARTITIONSIZE -mkfs.ext3 -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.ext3 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 ext3 - MOUNTED=`mount | grep -c "$MOUNTPOINT"` -done -#extract rootfs into the file -sudo cp -rpP $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/apalis-tk1-mainline/tegra-uboot-flasher/genext4fs.sh b/recipes-images/images/files/apalis-tk1-mainline/tegra-uboot-flasher/genext4fs.sh new file mode 100755 index 0000000..56e79f5 --- /dev/null +++ b/recipes-images/images/files/apalis-tk1-mainline/tegra-uboot-flasher/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 -rpP $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/apalis-tk1/apalis-tk1_bin/flash_blk.scr b/recipes-images/images/files/apalis-tk1/apalis-tk1_bin/flash_blk.scr index 42e93b7..2aef05f 100644 --- a/recipes-images/images/files/apalis-tk1/apalis-tk1_bin/flash_blk.scr +++ b/recipes-images/images/files/apalis-tk1/apalis-tk1_bin/flash_blk.scr @@ -11,7 +11,7 @@ setenv check_2 'setenv conf_blk_offset 0xfff; mmc read ${loadaddr} ${conf_blk_of setenv check_3 'setenv conf_blk_offset 0x7ff; mmc read ${loadaddr} ${conf_blk_offset} 1' setenv check_configblock 'setexpr toradex_oui_addr ${loadaddr} + 8; mmc dev 0 1; run check_1 || run check_2 || run check_3; crc32 -v ${toradex_oui_addr} 3 94305232' -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_uboot 'load ${interface} ${drive}:1 ${loadaddr} ${board_name}/${board_name}.img && run set_blkcnt && mmc dev 0 1 && mmc write ${loadaddr} 0x0 ${blkcnt}' diff --git a/recipes-images/images/files/apalis-tk1/apalis-tk1_bin/flash_eth.scr b/recipes-images/images/files/apalis-tk1/apalis-tk1_bin/flash_eth.scr index 3442e3c..27bab62 100644 --- a/recipes-images/images/files/apalis-tk1/apalis-tk1_bin/flash_eth.scr +++ b/recipes-images/images/files/apalis-tk1/apalis-tk1_bin/flash_eth.scr @@ -8,7 +8,7 @@ setenv check_2 'setenv conf_blk_offset 0xfff; mmc read ${loadaddr} ${conf_blk_of setenv check_3 'setenv conf_blk_offset 0x7ff; mmc read ${loadaddr} ${conf_blk_offset} 1' setenv check_configblock 'setexpr toradex_oui_addr ${loadaddr} + 8; mmc dev 0 1; run check_1 || run check_2 || run check_3; crc32 -v ${toradex_oui_addr} 3 94305232' -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_uboot 'tftpboot ${loadaddr} ${board_name}/${board_name}.img && run set_blkcnt && mmc dev 0 1 && mmc write ${loadaddr} 0x0 ${blkcnt}' diff --git a/recipes-images/images/files/apalis-tk1/tegra-uboot-flasher/genext4fs.sh b/recipes-images/images/files/apalis-tk1/tegra-uboot-flasher/genext4fs.sh new file mode 120000 index 0000000..f7eeef9 --- /dev/null +++ b/recipes-images/images/files/apalis-tk1/tegra-uboot-flasher/genext4fs.sh @@ -0,0 +1 @@ +../../library/genext4fs.sh \ No newline at end of file diff --git a/recipes-images/images/files/library/tegra/update.sh b/recipes-images/images/files/library/tegra/update.sh index e740bb6..27e4fe6 100755 --- a/recipes-images/images/files/library/tegra/update.sh +++ b/recipes-images/images/files/library/tegra/update.sh @@ -211,7 +211,7 @@ case "$MODTYPE" in CBOOT_IMAGE_TARGET=tegra124 # assumed minimal eMMC size [in sectors of 512] EMMC_SIZE=$(expr 1024 \* 15020 \* 2) - IMAGEFILE=root.ext3 + IMAGEFILE=root.ext4 KERNEL_DEVICETREE="tegra124-apalis-eval.dtb" LOCPATH="tegra-uboot-flasher" OUT_DIR="$OUT_DIR/apalis-tk1" @@ -300,6 +300,7 @@ MCOPY=`command -v mcopy` || { echo >&2 "Program mcopy not available. Aborting." 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; } CBOOT_CNT=`tegra-uboot-flasher/cbootimage -h | grep -c outputimage || true` @@ -394,7 +395,11 @@ else ${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) + if [ "${MODTYPE}" = "apalis-tk1" ] || [ "${MODTYPE}" = "apalis-tk1-mainline" ] ; then + ${PARTED} -a none -s ${BINARIES}/mbr.bin unit s mkpart primary ext4 ${ROOTFS_START} $(expr ${EMMC_SIZE} \- ${ROOTFS_START} \- 1) + else + ${PARTED} -a none -s ${BINARIES}/mbr.bin unit s mkpart primary ext2 ${ROOTFS_START} $(expr ${EMMC_SIZE} \- ${ROOTFS_START} \- 1) + fi ${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 \ @@ -441,7 +446,11 @@ else '{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 + if [ "${MODTYPE}" = "apalis-tk1" ] || [ "${MODTYPE}" = "apalis-tk1-mainline" ] ; then + sudo $LOCPATH/genext4fs.sh -d rootfs -b ${EXT_SIZE} ${BINARIES}/${IMAGEFILE} || exit 1 + else + sudo $LOCPATH/genext3fs.sh -d rootfs -b ${EXT_SIZE} ${BINARIES}/${IMAGEFILE} || exit 1 + fi fi fi @@ -457,6 +466,10 @@ if [ "${IMAGEFILE}" = "root.ext3" ] ; then if [ "$SPLIT" -ge 1 ] ; then sudo split -a 3 -b `expr 64 \* 1024 \* 1024` --numeric-suffixes=100 ${IMAGEFILE} "$OUT_DIR/root.ext3-" fi +elif [ "${IMAGEFILE}" = "root.ext4" ] ; then + if [ "$SPLIT" -ge 1 ] ; then + sudo split -a 3 -b `expr 64 \* 1024 \* 1024` --numeric-suffixes=100 ${IMAGEFILE} "$OUT_DIR/root.ext4-" + fi else sudo cp ${IMAGEFILE}* "$OUT_DIR" fi -- cgit v1.2.3