From e563d470aa9d55ea4d64c4680e8046b93a2eb815 Mon Sep 17 00:00:00 2001 From: Junghoon Kim Date: Mon, 18 May 2020 15:22:47 +0900 Subject: [PATCH] scripts: sd_fusing_xu4.sh: Improve the image flashing performance The current dd of the pv combination degrades the flashing performance due to the pipe overhead and is also bad to see due to the duplicate output. This can be improved by the use of direct mode with progress status. Change-Id: Id682683e892181cc2608d1ba811d4ddb847048da Signed-off-by: Junghoon Kim --- scripts/tizen/sd_fusing_xu4.sh | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/scripts/tizen/sd_fusing_xu4.sh b/scripts/tizen/sd_fusing_xu4.sh index a3fbe69..6b374c9 100755 --- a/scripts/tizen/sd_fusing_xu4.sh +++ b/scripts/tizen/sd_fusing_xu4.sh @@ -2,6 +2,7 @@ declare FORMAT="" declare DEVICE="" +declare -i OLD_DD=0 # Binaires array for fusing declare -a FUSING_BINARY_ARRAY @@ -60,6 +61,23 @@ function print_message () { tput sgr 0 } +function check_ddversion () { + # NOTE + # before coreutils dd 8.24, dd doesn't support "status=progress" + # and the option causes fusing failure. For backward compatibility, + # do not use the option for old dd + local version=`dd --version | head -1 | awk '{print $3}'` + local major=${version%%.*} + local version=${version:`expr index $version .`} + local minor=${version%%.*} + + if [ $major -lt 8 ]; then + OLD_DD=1 + elif [ $major -eq 8 -a $minor -lt 24 ]; then + OLD_DD=1 + fi +} + function add_fusing_entry () { local name=$1 local offset=$2 @@ -115,10 +133,15 @@ function fusing_image () { fi local -r input_size=`du -b $fusing_img | awk '{print $1}'` + local -r input_size_mb=`expr $input_size / 1024 / 1024` - print_message 2 "[Fusing $1]" - - dd if=$fusing_img | pv -s $input_size | dd of=$device seek=$seek bs=$bs + print_message 2 "[Fusing $1 ($input_size_mb MiB)]" + umount $device + if [ $OLD_DD == 1 ]; then + dd if=$fusing_img | pv -s $input_size | dd of=$device seek=$seek bs=$bs + else + dd if=$fusing_img of=$device seek=$seek bs=$bs status=progress oflag=direct + fi if [ $(basename $fusing_img) == "u-boot-mmc.bin" ];then add_fusing_entry "u-boot" $seek 2048 @@ -365,7 +388,7 @@ function check_device () { function print_logo () { echo "" - echo "[Odroid-XU3/4 downloader version 1.2]" + echo "[Odroid-XU3/4 downloader version 1.3]" echo "This version also supports Tizen 4.0." echo "" } @@ -414,4 +437,5 @@ done check_args check_device check_partition_format +check_ddversion fuse_image -- 2.7.4