blob: 779700fc02e730d420d01a0b9c17c811d676db78 [file] [log] [blame]
Vishal Bhoj9a67d912016-06-09 10:02:07 +01001#!/bin/sh
2# Generate partition table for HiKey eMMC
3#
4# tiny: for testing purpose.
5# aosp: 10 entries (same as linux with userdata).
6# linux: 9 entries (same as aosp without userdata).
Mark Salyzyn97ae2202017-05-26 14:56:52 -07007# swap: 10 entries (similar to aosp, drop reserved, 1.5G of swap).
Vishal Bhoj9a67d912016-06-09 10:02:07 +01008
9PTABLE=${PTABLE:-aosp}
10SECTOR_SIZE=512
11TEMP_FILE=$(mktemp /tmp/${PTABLE}.XXXXXX)
12
13case ${PTABLE} in
14 tiny)
15 SECTOR_NUMBER=81920
16 ;;
17 aosp-4g|linux-4g)
18 SECTOR_NUMBER=7471104
19 ;;
Mark Salyzyn97ae2202017-05-26 14:56:52 -070020 aosp-8g|linux-8g|swap-8g)
Vishal Bhoj9a67d912016-06-09 10:02:07 +010021 SECTOR_NUMBER=15269888
22 ;;
23esac
24
25BK_PTABLE_LBA=$(expr ${SECTOR_NUMBER} - 33)
26echo ${BK_PTABLE_LBA}
27
28# get the partition table
29case ${PTABLE} in
30 tiny)
Mark Salyzyn8f4583c2017-07-07 14:45:31 -070031 dd if=/dev/zero of=${TEMP_FILE} conv=sparse bs=${SECTOR_SIZE} count=${SECTOR_NUMBER}
Vishal Bhoj9a67d912016-06-09 10:02:07 +010032 sgdisk -U -R -v ${TEMP_FILE}
33 sgdisk -n 1:2048:4095 -t 1:0700 -u 1:F9F21F01-A8D4-5F0E-9746-594869AEC3E4 -c 1:"vrl" -p ${TEMP_FILE}
34 sgdisk -n 2:4096:6143 -t 2:0700 -u 2:F9F21F02-A8D4-5F04-9746-594869AEC3E4 -c 2:"vrl_backup" -p ${TEMP_FILE}
35 ;;
36 aosp*)
Mark Salyzyn8f4583c2017-07-07 14:45:31 -070037 dd if=/dev/zero of=${TEMP_FILE} conv=sparse bs=${SECTOR_SIZE} count=${SECTOR_NUMBER}
Vishal Bhoj9a67d912016-06-09 10:02:07 +010038 sgdisk -U 2CB85345-6A91-4043-8203-723F0D28FBE8 -v ${TEMP_FILE}
39 #[1: vrl: 1M-2M]
40 sgdisk -n 1:0:+1M -t 1:0700 -u 1:496847AB-56A1-4CD5-A1AD-47F4ACF055C9 -c 1:"vrl" ${TEMP_FILE}
41 #[2: vrl_backup: 2M-3M]
42 sgdisk -n 2:0:+1M -t 2:0700 -u 2:61A36FC1-8EFB-4899-84D8-B61642EFA723 -c 2:"vrl_backup" ${TEMP_FILE}
43 #[3: mcuimage: 3M-4M]
44 sgdisk -n 3:0:+1M -t 3:0700 -u 3:65007411-962D-4781-9B2C-51DD7DF22CC3 -c 3:"mcuimage" ${TEMP_FILE}
45 #[4: fastboot: 4M-12M]
46 sgdisk -n 4:0:+8M -t 4:EF02 -u 4:496847AB-56A1-4CD5-A1AD-47F4ACF055C9 -c 4:"fastboot" ${TEMP_FILE}
47 #[5: nvme: 12M-14M]
48 sgdisk -n 5:0:+2M -t 5:0700 -u 5:00354BCD-BBCB-4CB3-B5AE-CDEFCB5DAC43 -c 5:"nvme" ${TEMP_FILE}
49 #[6: boot: 14M-78M]
50 sgdisk -n 6:0:+64M -t 6:EF00 -u 6:5C0F213C-17E1-4149-88C8-8B50FB4EC70E -c 6:"boot" ${TEMP_FILE}
51 #[7: reserved: 78M-334M]
52 sgdisk -n 7:0:+256M -t 7:0700 -u 7:BED8EBDC-298E-4A7A-B1F1-2500D98453B7 -c 7:"reserved" ${TEMP_FILE}
53 #[8: cache: 334M-590M]
54 sgdisk -n 8:0:+256M -t 8:8301 -u 8:A092C620-D178-4CA7-B540-C4E26BD6D2E2 -c 8:"cache" ${TEMP_FILE}
55 #[9: system: 590M-2126M]
56 sgdisk -n 9:0:+1536M -t 9:8300 -u 9:FC56E345-2E8E-49AE-B2F8-5B9D263FE377 -c 9:"system" ${TEMP_FILE}
57 #[10: userdata: 2126M-End]
58 sgdisk -n -E -t 10:8300 -u 10:064111F6-463B-4CE1-876B-13F3684CE164 -c 10:"userdata" -p ${TEMP_FILE}
59 ;;
60 linux*)
Mark Salyzyn8f4583c2017-07-07 14:45:31 -070061 dd if=/dev/zero of=${TEMP_FILE} conv=sparse bs=${SECTOR_SIZE} count=${SECTOR_NUMBER}
Vishal Bhoj9a67d912016-06-09 10:02:07 +010062 sgdisk -U 2CB85345-6A91-4043-8203-723F0D28FBE8 -v ${TEMP_FILE}
63 #[1: vrl: 1M-2M]
64 sgdisk -n 1:0:+1M -t 1:0700 -u 1:496847AB-56A1-4CD5-A1AD-47F4ACF055C9 -c 1:"vrl" ${TEMP_FILE}
65 #[2: vrl_backup: 2M-3M]
66 sgdisk -n 2:0:+1M -t 2:0700 -u 2:61A36FC1-8EFB-4899-84D8-B61642EFA723 -c 2:"vrl_backup" ${TEMP_FILE}
67 #[3: mcuimage: 3M-4M]
68 sgdisk -n 3:0:+1M -t 3:0700 -u 3:65007411-962D-4781-9B2C-51DD7DF22CC3 -c 3:"mcuimage" ${TEMP_FILE}
69 #[4: fastboot: 4M-12M]
70 sgdisk -n 4:0:+8M -t 4:EF02 -u 4:496847AB-56A1-4CD5-A1AD-47F4ACF055C9 -c 4:"fastboot" ${TEMP_FILE}
71 #[5: nvme: 12M-14M]
72 sgdisk -n 5:0:+2M -t 5:0700 -u 5:00354BCD-BBCB-4CB3-B5AE-CDEFCB5DAC43 -c 5:"nvme" ${TEMP_FILE}
73 #[6: boot: 14M-78M]
74 sgdisk -n 6:0:+64M -t 6:EF00 -u 6:5C0F213C-17E1-4149-88C8-8B50FB4EC70E -c 6:"boot" ${TEMP_FILE}
75 #[7: reserved: 78M-334M]
76 sgdisk -n 7:0:+256M -t 7:0700 -u 7:BED8EBDC-298E-4A7A-B1F1-2500D98453B7 -c 7:"reserved" ${TEMP_FILE}
77 #[8: cache: 334M-590M]
78 sgdisk -n 8:0:+256M -t 8:8301 -u 8:A092C620-D178-4CA7-B540-C4E26BD6D2E2 -c 8:"cache" ${TEMP_FILE}
79 #[9: system: 590M-End]
80 sgdisk -n -E -t 9:8300 -u 9:FC56E345-2E8E-49AE-B2F8-5B9D263FE377 -c 9:"system" ${TEMP_FILE}
81 ;;
Mark Salyzyn97ae2202017-05-26 14:56:52 -070082 swap*)
Mark Salyzyn8f4583c2017-07-07 14:45:31 -070083 dd if=/dev/zero of=${TEMP_FILE} conv=sparse bs=${SECTOR_SIZE} count=${SECTOR_NUMBER}
Mark Salyzyn97ae2202017-05-26 14:56:52 -070084 sgdisk -U 2CB85345-6A91-4043-8203-723F0D28FBE8 -v ${TEMP_FILE}
85 #[1: vrl: 1M-2M]
86 sgdisk -n 1:0:+1M -t 1:0700 -u 1:496847AB-56A1-4CD5-A1AD-47F4ACF055C9 -c 1:"vrl" ${TEMP_FILE}
87 #[2: vrl_backup: 2M-3M]
88 sgdisk -n 2:0:+1M -t 2:0700 -u 2:61A36FC1-8EFB-4899-84D8-B61642EFA723 -c 2:"vrl_backup" ${TEMP_FILE}
89 #[3: mcuimage: 3M-4M]
90 sgdisk -n 3:0:+1M -t 3:0700 -u 3:65007411-962D-4781-9B2C-51DD7DF22CC3 -c 3:"mcuimage" ${TEMP_FILE}
91 #[4: fastboot: 4M-12M]
92 sgdisk -n 4:0:+8M -t 4:EF02 -u 4:496847AB-56A1-4CD5-A1AD-47F4ACF055C9 -c 4:"fastboot" ${TEMP_FILE}
93 #[5: nvme: 12M-14M]
94 sgdisk -n 5:0:+2M -t 5:0700 -u 5:00354BCD-BBCB-4CB3-B5AE-CDEFCB5DAC43 -c 5:"nvme" ${TEMP_FILE}
95 #[6: boot: 14M-78M]
96 sgdisk -n 6:0:+64M -t 6:EF00 -u 6:5C0F213C-17E1-4149-88C8-8B50FB4EC70E -c 6:"boot" ${TEMP_FILE}
97 #[7: cache: 78M-384M]
98 sgdisk -n 7:0:+256M -t 7:8301 -u 7:A092C620-D178-4CA7-B540-C4E26BD6D2E2 -c 7:"cache" ${TEMP_FILE}
99 #[8: swap: 384M-1920M]
100 sgdisk -n 8:0:+1536M -t 8:8200 -u 8:FC56E344-2E8E-49AE-B2F8-5B9D263FE377 -c 8:"swap" ${TEMP_FILE}
101 #[9: system: 1920M-3556M]
102 sgdisk -n 9:0:+1536M -t 9:8300 -u 9:FC56E345-2E8E-49AE-B2F8-5B9D263FE377 -c 9:"system" ${TEMP_FILE}
103 #[10: userdata: 3556M-End]
104 sgdisk -n -E -t 10:8300 -u 10:064111F6-463B-4CE1-876B-13F3684CE164 -c 10:"userdata" -p ${TEMP_FILE}
105 ;;
Vishal Bhoj9a67d912016-06-09 10:02:07 +0100106esac
107
108# get the main and the backup parts of the partition table
Mark Salyzyn8f4583c2017-07-07 14:45:31 -0700109dd if=${TEMP_FILE} of=prm_ptable.img conv=sparse bs=${SECTOR_SIZE} count=34
110dd if=${TEMP_FILE} of=sec_ptable.img conv=sparse skip=${BK_PTABLE_LBA} bs=${SECTOR_SIZE} count=33
Vishal Bhoj9a67d912016-06-09 10:02:07 +0100111
112rm -f ${TEMP_FILE}