scripts: tizen: sd_fusing_rpi: use delete option about newer sfdisk
authorJaehoon Chung <jh80.chung@samsung.com>
Fri, 1 Oct 2021 03:09:25 +0000 (12:09 +0900)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Tue, 16 Nov 2021 12:00:22 +0000 (13:00 +0100)
Use delete option before format.
It's more stable than using dd.

Change-Id: Ic77b543f49e7633027cbcf524c7c7a76a474d04e
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
scripts/tizen/sd_fusing_rpi3.sh

index 16bab27..4b38aa7 100755 (executable)
@@ -165,11 +165,18 @@ function mkpart_3 () {
        if [ $major -gt 2 ];  then
                sfdisk_new=1
        else
-               if [ $major -eq 2 -a $minor -ge 26 ];  then
+               if [ $major -eq 2 -a $minor -ge 28 ];  then
                        sfdisk_new=1
                fi
        fi
 
+       if [ $sfdisk_new == 0 ]; then
+               echo "$(tput setaf 3)$(tput bold)NOTICE: Your sfidk ${version[0]}.${version[1]}  version is too old. It can do unstable behavior!"
+               tput sgr 0
+               echo ""
+
+       fi
+
        local -r DISK=$DEVICE
        local -r SIZE=`sfdisk -s $DISK`
        local -r SIZE_MB=$((SIZE >> 10))
@@ -225,10 +232,11 @@ function mkpart_3 () {
                umount $mnt
        done
 
-       echo "Remove partition table..."
-       dd if=/dev/zero of=$DISK bs=512 count=16 conv=notrunc
 
        if [ $sfdisk_new == 1 ]; then
+               echo "Remove partition table..."
+               sfdisk --delete $DISK
+
                sfdisk $DISK <<-__EOF__
                4MiB,${BOOT_SZ}MiB,0xE,*
                8MiB,${ROOTFS_SZ}MiB,,-
@@ -243,6 +251,9 @@ function mkpart_3 () {
                ,${RESERVED2_SZ}MiB,,-
                __EOF__
        else
+               echo "Remove partition table..."
+               dd if=/dev/zero of=$DISK bs=512 count=16 conv=notrunc
+
                # calculate start positions for alignment for extended partitions
                let "USER_START = 4 + $BOOT_SZ + $ROOTFS_SZ + $DATA_SZ + 1"
                let "MODULE_START = $USER_START + $USER_SZ + 1"