• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3INSTALLER_DIR="`dirname ${0}`"
4ECHO_PREFIX="=== "
5
6# for cases that don't run "lunch hikey960-userdebug"
7if [ -z "${ANDROID_BUILD_TOP}" ]; then
8    ANDROID_BUILD_TOP=${INSTALLER_DIR}/../../../../../
9    ANDROID_PRODUCT_OUT="${ANDROID_BUILD_TOP}/out/target/product/hikey960"
10fi
11
12if [ ! -d "${ANDROID_PRODUCT_OUT}" ]; then
13    echo ${ECHO_PREFIX}"error in locating out directory, check if it exist"
14    exit
15fi
16
17echo ${ECHO_PREFIX}"android out dir:${ANDROID_PRODUCT_OUT}"
18
19function check_partition_table_version () {
20	fastboot erase reserved
21	if [ $? -eq 0 ]
22	then
23		IS_PTABLE_1MB_ALIGNED=true
24	else
25		IS_PTABLE_1MB_ALIGNED=false
26	fi
27}
28
29function flashing_atf_uefi () {
30	fastboot flash ptable "${INSTALLER_DIR}"/prm_ptable.img
31	fastboot flash xloader "${INSTALLER_DIR}"/hisi-sec_xloader.img
32	fastboot reboot-bootloader
33
34	fastboot flash fastboot "${INSTALLER_DIR}"/l-loader.bin
35	fastboot flash fip "${INSTALLER_DIR}"/fip.bin
36	fastboot flash nvme "${INSTALLER_DIR}"/hisi-nvme.img
37	fastboot flash fw_lpm3   "${INSTALLER_DIR}"/hisi-lpm3.img
38	fastboot flash trustfirmware   "${INSTALLER_DIR}"/hisi-bl31.bin
39	fastboot reboot-bootloader
40
41	fastboot flash ptable "${INSTALLER_DIR}"/prm_ptable.img
42	fastboot flash xloader "${INSTALLER_DIR}"/hisi-sec_xloader.img
43	fastboot flash fastboot "${INSTALLER_DIR}"/l-loader.bin
44	fastboot flash fip "${INSTALLER_DIR}"/fip.bin
45
46	fastboot flash boot "${ANDROID_PRODUCT_OUT}"/boot.img
47	fastboot flash system "${ANDROID_PRODUCT_OUT}"/system.img
48	fastboot flash vendor "${ANDROID_PRODUCT_OUT}"/vendor.img
49	fastboot flash cache "${ANDROID_PRODUCT_OUT}"/cache.img
50	fastboot flash userdata "${ANDROID_PRODUCT_OUT}"/userdata.img
51}
52
53function upgrading_ptable_1mb_aligned () {
54	fastboot flash xloader "${INSTALLER_DIR}"/hisi-sec_xloader.img
55	fastboot flash ptable "${INSTALLER_DIR}"/hisi-ptable.img
56	fastboot flash fastboot "${INSTALLER_DIR}"/hisi-fastboot.img
57	fastboot reboot-bootloader
58}
59
60echo ${ECHO_PREFIX}"Checking partition table version..."
61check_partition_table_version
62
63if [ "${IS_PTABLE_1MB_ALIGNED}" == "true" ]
64then
65	echo ${ECHO_PREFIX}"Partition table is 1MB aligned. Flashing ATF/UEFI..."
66	flashing_atf_uefi
67else
68	echo ${ECHO_PREFIX}"Partition table is 512KB aligned."
69	echo ${ECHO_PREFIX}"Upgrading to 1MB aligned version..."
70	upgrading_ptable_1mb_aligned
71	echo ${ECHO_PREFIX}"Flasing ATF/UEFI..."
72	flashing_atf_uefi
73	echo ${ECHO_PREFIX}"Done"
74fi
75
76fastboot reboot
77