Vishal Bhoj | 82c8071 | 2015-12-15 21:13:33 +0530 | [diff] [blame^] | 1 | #!/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). |
| 7 | |
| 8 | PTABLE=${PTABLE:-aosp} |
| 9 | SECTOR_SIZE=512 |
| 10 | TEMP_FILE=$(mktemp /tmp/${PTABLE}.XXXXXX) |
| 11 | |
| 12 | case ${PTABLE} in |
| 13 | tiny) |
| 14 | SECTOR_NUMBER=81920 |
| 15 | ;; |
| 16 | aosp-4g|linux-4g) |
| 17 | SECTOR_NUMBER=7471104 |
| 18 | ;; |
| 19 | aosp-8g|linux-8g) |
| 20 | SECTOR_NUMBER=15269888 |
| 21 | ;; |
| 22 | esac |
| 23 | |
| 24 | BK_PTABLE_LBA=$(expr ${SECTOR_NUMBER} - 33) |
| 25 | echo ${BK_PTABLE_LBA} |
| 26 | |
| 27 | # get the partition table |
| 28 | case ${PTABLE} in |
| 29 | tiny) |
| 30 | dd if=/dev/zero of=${TEMP_FILE} bs=${SECTOR_SIZE} count=${SECTOR_NUMBER} |
| 31 | sgdisk -U -R -v ${TEMP_FILE} |
| 32 | sgdisk -n 1:2048:4095 -t 1:0700 -u 1:F9F21F01-A8D4-5F0E-9746-594869AEC3E4 -c 1:"vrl" -p ${TEMP_FILE} |
| 33 | sgdisk -n 2:4096:6143 -t 2:0700 -u 2:F9F21F02-A8D4-5F04-9746-594869AEC3E4 -c 2:"vrl_backup" -p ${TEMP_FILE} |
| 34 | ;; |
| 35 | aosp*) |
| 36 | dd if=/dev/zero of=${TEMP_FILE} bs=${SECTOR_SIZE} count=${SECTOR_NUMBER} |
| 37 | sgdisk -U 2CB85345-6A91-4043-8203-723F0D28FBE8 -v ${TEMP_FILE} |
| 38 | #[1: vrl: 1M-2M] |
| 39 | sgdisk -n 1:0:+1M -t 1:0700 -u 1:496847AB-56A1-4CD5-A1AD-47F4ACF055C9 -c 1:"vrl" ${TEMP_FILE} |
| 40 | #[2: vrl_backup: 2M-3M] |
| 41 | sgdisk -n 2:0:+1M -t 2:0700 -u 2:61A36FC1-8EFB-4899-84D8-B61642EFA723 -c 2:"vrl_backup" ${TEMP_FILE} |
| 42 | #[3: mcuimage: 3M-4M] |
| 43 | sgdisk -n 3:0:+1M -t 3:0700 -u 3:65007411-962D-4781-9B2C-51DD7DF22CC3 -c 3:"mcuimage" ${TEMP_FILE} |
| 44 | #[4: fastboot: 4M-12M] |
| 45 | sgdisk -n 4:0:+8M -t 4:EF02 -u 4:496847AB-56A1-4CD5-A1AD-47F4ACF055C9 -c 4:"fastboot" ${TEMP_FILE} |
| 46 | #[5: nvme: 12M-14M] |
| 47 | sgdisk -n 5:0:+2M -t 5:0700 -u 5:00354BCD-BBCB-4CB3-B5AE-CDEFCB5DAC43 -c 5:"nvme" ${TEMP_FILE} |
| 48 | #[6: boot: 14M-78M] |
| 49 | sgdisk -n 6:0:+64M -t 6:EF00 -u 6:5C0F213C-17E1-4149-88C8-8B50FB4EC70E -c 6:"boot" ${TEMP_FILE} |
| 50 | #[7: reserved: 78M-334M] |
| 51 | sgdisk -n 7:0:+256M -t 7:0700 -u 7:BED8EBDC-298E-4A7A-B1F1-2500D98453B7 -c 7:"reserved" ${TEMP_FILE} |
| 52 | #[8: cache: 334M-590M] |
| 53 | sgdisk -n 8:0:+256M -t 8:8301 -u 8:A092C620-D178-4CA7-B540-C4E26BD6D2E2 -c 8:"cache" ${TEMP_FILE} |
| 54 | #[9: system: 590M-2126M] |
| 55 | sgdisk -n 9:0:+1536M -t 9:8300 -u 9:FC56E345-2E8E-49AE-B2F8-5B9D263FE377 -c 9:"system" ${TEMP_FILE} |
| 56 | #[10: userdata: 2126M-End] |
| 57 | sgdisk -n -E -t 10:8300 -u 10:064111F6-463B-4CE1-876B-13F3684CE164 -c 10:"userdata" -p ${TEMP_FILE} |
| 58 | ;; |
| 59 | linux*) |
| 60 | dd if=/dev/zero of=${TEMP_FILE} bs=${SECTOR_SIZE} count=${SECTOR_NUMBER} |
| 61 | sgdisk -U 2CB85345-6A91-4043-8203-723F0D28FBE8 -v ${TEMP_FILE} |
| 62 | #[1: vrl: 1M-2M] |
| 63 | sgdisk -n 1:0:+1M -t 1:0700 -u 1:496847AB-56A1-4CD5-A1AD-47F4ACF055C9 -c 1:"vrl" ${TEMP_FILE} |
| 64 | #[2: vrl_backup: 2M-3M] |
| 65 | sgdisk -n 2:0:+1M -t 2:0700 -u 2:61A36FC1-8EFB-4899-84D8-B61642EFA723 -c 2:"vrl_backup" ${TEMP_FILE} |
| 66 | #[3: mcuimage: 3M-4M] |
| 67 | sgdisk -n 3:0:+1M -t 3:0700 -u 3:65007411-962D-4781-9B2C-51DD7DF22CC3 -c 3:"mcuimage" ${TEMP_FILE} |
| 68 | #[4: fastboot: 4M-12M] |
| 69 | sgdisk -n 4:0:+8M -t 4:EF02 -u 4:496847AB-56A1-4CD5-A1AD-47F4ACF055C9 -c 4:"fastboot" ${TEMP_FILE} |
| 70 | #[5: nvme: 12M-14M] |
| 71 | sgdisk -n 5:0:+2M -t 5:0700 -u 5:00354BCD-BBCB-4CB3-B5AE-CDEFCB5DAC43 -c 5:"nvme" ${TEMP_FILE} |
| 72 | #[6: boot: 14M-78M] |
| 73 | sgdisk -n 6:0:+64M -t 6:EF00 -u 6:5C0F213C-17E1-4149-88C8-8B50FB4EC70E -c 6:"boot" ${TEMP_FILE} |
| 74 | #[7: reserved: 78M-334M] |
| 75 | sgdisk -n 7:0:+256M -t 7:0700 -u 7:BED8EBDC-298E-4A7A-B1F1-2500D98453B7 -c 7:"reserved" ${TEMP_FILE} |
| 76 | #[8: cache: 334M-590M] |
| 77 | sgdisk -n 8:0:+256M -t 8:8301 -u 8:A092C620-D178-4CA7-B540-C4E26BD6D2E2 -c 8:"cache" ${TEMP_FILE} |
| 78 | #[9: system: 590M-End] |
| 79 | sgdisk -n -E -t 9:8300 -u 9:FC56E345-2E8E-49AE-B2F8-5B9D263FE377 -c 9:"system" ${TEMP_FILE} |
| 80 | ;; |
| 81 | esac |
| 82 | |
| 83 | # get the main and the backup parts of the partition table |
| 84 | dd if=${TEMP_FILE} of=prm_ptable.img bs=${SECTOR_SIZE} count=34 |
| 85 | dd if=${TEMP_FILE} of=sec_ptable.img skip=${BK_PTABLE_LBA} bs=${SECTOR_SIZE} count=33 |
| 86 | |
| 87 | rm -f ${TEMP_FILE} |