scripts: tizen: sd_fusing_rpi3: update the rpi3 script
authorJaehoon Chung <jh80.chung@samsung.com>
Thu, 14 Oct 2021 23:11:37 +0000 (08:11 +0900)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Tue, 16 Nov 2021 12:00:22 +0000 (13:00 +0100)
To prevent wrong operation, check the result whether format is succeed
or not. If it's failed, exit this script.
And if there is already "mnt_tmp" directory, remove it to clear the
previous status.

It's changed the location to remove a partition table with dd command
with count is changed  from 16 to 32.
Because  it seems that partition table doesn't clear.

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

index 0bd2bee..f38f40d 100755 (executable)
@@ -236,13 +236,12 @@ function mkpart_3 () {
                umount $mnt
        done
 
+       echo "Remove partition table..."
+       dd if=/dev/zero of=$DISK bs=512 count=32 conv=notrunc
 
        if [ $sfdisk_new == 1 ]; then
-               echo "Remove partition table..."
                if [ $support_delete == 1 ]; then
                        sfdisk --delete $DISK
-               else
-                       dd if=/dev/zero of=$DISK bs=512 count=16 conv=notrunc
                fi
 
                sfdisk $DISK <<-__EOF__
@@ -259,9 +258,6 @@ 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"
@@ -290,6 +286,10 @@ function mkpart_3 () {
                local PART=/dev/`lsblk ${DISK} -o TYPE,KNAME | grep part | awk '{ print $2 }' | grep -G "[a-z]${PART_TABLE[$idx * ${PART_TABLE_COL} + 1]}\$"`
                if [ "${PART_TABLE[$idx * ${PART_TABLE_COL} + 4]}" == "vfat" ]; then
                        mkfs.vfat -F 16 ${PART} -n ${PART_TABLE[$idx * ${PART_TABLE_COL} + 3]}
+                       if [ $? -eq 1 ]; then
+                               echo "Failed to format as FAT filesystem"
+                               exit -1
+                       fi
                elif [ "${PART_TABLE[$idx * ${PART_TABLE_COL} + 4]}" == "ext4" ]; then
                        mkfs.ext4 -q ${PART} -L ${PART_TABLE[$idx * ${PART_TABLE_COL} + 3]} -F
                else
@@ -302,6 +302,10 @@ function mkpart_3 () {
 
        # create "reboot-param.bin" file in inform partition for passing reboot parameter
        # It should be done only once upon partition format.
+       if [ -d mnt_tmp ]; then
+               echo "Remove the existing mnt_tmp directory!!"
+               rm -rf mnt_tmp
+       fi
        mkdir mnt_tmp
        mount -t ext4 ${PART9} ./mnt_tmp
        touch ./mnt_tmp/reboot-param.bin
@@ -394,7 +398,7 @@ function check_device () {
 
 function print_logo () {
        echo ""
-       echo "Raspberry Pi downloader, version 2.1.1"
+       echo "Raspberry Pi downloader, version 2.2.1"
        echo ""
 }