scripts: tizen: sd_fusing_xu4: Fix start position of extended partitions
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Mon, 18 Nov 2019 05:45:46 +0000 (14:45 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 20 Oct 2020 06:13:48 +0000 (15:13 +0900)
Older version sfdisk than 2.26 does not align the start and end
of partitions to block, and it breaks the size of paritions less
than requested. Fix start position of extended partitions by
calculation to guarantee the requested size.

Change-Id: I2e5a6c72550f71f213c2d7352b537c1b12d13670
Ref: http://man7.org/linux/man-pages/man8/sfdisk.8.html
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
scripts/tizen/sd_fusing_xu4.sh

index f3aa5ddd3ce38a9cc5668e5e1dfa631862b564ce..dbc9d466aaac94f3c2b86c34a30c96705a6a2258 100755 (executable)
@@ -211,7 +211,7 @@ function mkpart_3 () {
        if [ $sfdisk_new == 1 ]; then
                local -r EXTEND_SZ=8
        else
-               local -r EXTEND_SZ=4
+               local -r EXTEND_SZ=10
        fi
 
        let "USER_SZ = $SIZE_MB - $BOOT_SZ - $ROOTFS_SZ - $DATA_SZ - $MODULE_SZ - $EXTEND_SZ - $RAMDISK_SZ"
@@ -260,14 +260,19 @@ function mkpart_3 () {
                ,${RAMDISK_SZ}MiB,,-
                __EOF__
        else
+               # 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"
+               let "RAMDISK_START = $MODULE_START + $MODULE_SZ + 1"
+
                sfdisk --in-order --Linux --unit M $DISK <<-__EOF__
                4,$BOOT_SZ,0xE,*
                ,$ROOTFS_SZ,,-
                ,$DATA_SZ,,-
                ,,E,-
-               ,$USER_SZ,,-
-               ,$MODULE_SZ,,-
-               ,$RAMDISK_SZ,,-
+               $USER_START,$USER_SZ,,-
+               $MODULE_START,$MODULE_SZ,,-
+               $RAMDISK_START,$RAMDISK_SZ,,-
                __EOF__
        fi