scripts: sd_fusing_rpi4: add initialize_parameter function
authorJaehoon Chung <jh80.chung@samsung.com>
Wed, 12 Oct 2022 01:25:57 +0000 (10:25 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Mon, 17 Oct 2022 01:03:57 +0000 (10:03 +0900)
Add initialize_parameter function to clear previous values.
When flash the image without format, its value is remaining with
previous value.

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

index 9f71443..bd904ad 100755 (executable)
@@ -201,12 +201,42 @@ function fuse_image_tarball () {
        eval sync
 }
 
+function initialize_parameter () {
+       # create "reboot-param.bin" file in inform partition for passing reboot parameter
+       # It should be done only once upon partition format.
+       local -r DISK=$DEVICE
+       local -r PART9=/dev/`lsblk ${DISK} -o TYPE,KNAME | grep part | awk '{ print $2 }' | grep -G "[a-z]9\$"`
+
+       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
+       echo "norm" > ./mnt_tmp/reboot-param.bin
+       echo "norm" > ./mnt_tmp/reboot-param.info
+       echo "a" > ./mnt_tmp/partition-ab.info
+       echo "1" > ./mnt_tmp/partition-ab-cloned.info
+       echo "0" > ./mnt_tmp/upgrade-status.info
+
+       # To check the status of partition. (default "ok")
+       echo "ok" > ./mnt_tmp/partition-a-status.info
+       echo "ok" > ./mnt_tmp/partition-b-status.info
+
+       sync
+       umount ./mnt_tmp
+       rmdir mnt_tmp
+}
+
 function fuse_image () {
 
        if [ "$FUSING_BINARY_NUM" == 0 ]; then
                return
        fi
 
+       # Clear preivous values before flashing image
+       initialize_parameter
+
        for ((fuse_idx = 0 ; fuse_idx < $FUSING_BINARY_NUM ; fuse_idx++))
        do
                local filename=${FUSING_BINARY_ARRAY[fuse_idx]}
@@ -382,27 +412,8 @@ function mkpart_3 () {
        local -r PART9=/dev/`lsblk ${DISK} -o TYPE,KNAME | grep part | awk '{ print $2 }' | grep -G "[a-z]9\$"`
        mkfs.ext4 -q ${PART9} -L $INFORM -F -O ^metadata_csum
 
-       # 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
-       echo "norm" > ./mnt_tmp/reboot-param.bin
-       echo "norm" > ./mnt_tmp/reboot-param.info
-       echo "a" > ./mnt_tmp/partition-ab.info
-       echo "1" > ./mnt_tmp/partition-ab-cloned.info
-       echo "0" > ./mnt_tmp/upgrade-status.info
-
-       # To check the status of partition. (default "ok")
-       echo "ok" > ./mnt_tmp/partition-a-status.info
-       echo "ok" > ./mnt_tmp/partition-b-status.info
-
-       sync
-       umount ./mnt_tmp
-       rmdir mnt_tmp
+       # initialize value of parameters
+       initialize_parameter
 
        local -r PART17=/dev/`lsblk ${DISK} -o TYPE,KNAME | grep part | awk '{ print $2 }' | grep -G "[a-z]17\$"`
        mkfs.ext4 -q ${PART17} -L $RESERVED0 -F
@@ -501,7 +512,7 @@ function check_device () {
 
 function print_logo () {
        echo ""
-       echo "Raspberry Pi4 downloader, version 1.0.8"
+       echo "Raspberry Pi4 downloader, version 1.0.9"
        echo ""
 }