blob: 6b6b56bb41821aec8b12b4438f3a6db43abfbe2e [file] [log] [blame]
Dmitry Shmidt5d080802017-04-11 14:20:03 -07001#!/bin/bash
2
3INSTALLER_DIR="`dirname ${0}`"
John Stultz7f18a532021-04-06 02:40:34 +00004ECHO_PREFIX="=== "
Dmitry Shmidt5d080802017-04-11 14:20:03 -07005
Amit Pundire0b34ce2023-10-19 18:29:28 +05306# for cases that don't run "lunch linaro_hikey960-userdebug"
Dmitry Shmidt5d080802017-04-11 14:20:03 -07007if [ -z "${ANDROID_BUILD_TOP}" ]; then
Amit Pundir697d5662023-10-19 13:09:12 +05308 ANDROID_BUILD_TOP=${INSTALLER_DIR}/../../../../../
Amit Pundire0b34ce2023-10-19 18:29:28 +05309 ANDROID_PRODUCT_OUT="${ANDROID_BUILD_TOP}/out/target/product/linaro_hikey960"
Dmitry Shmidt5d080802017-04-11 14:20:03 -070010fi
11
12if [ ! -d "${ANDROID_PRODUCT_OUT}" ]; then
John Stultz7f18a532021-04-06 02:40:34 +000013 echo ${ECHO_PREFIX}"error in locating out directory, check if it exist"
Dmitry Shmidt5d080802017-04-11 14:20:03 -070014 exit
15fi
16
John Stultz7f18a532021-04-06 02:40:34 +000017echo ${ECHO_PREFIX}"android out dir:${ANDROID_PRODUCT_OUT}"
Dmitry Shmidt5d080802017-04-11 14:20:03 -070018
John Stultz7f18a532021-04-06 02:40:34 +000019function 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 () {
Amit Pundir697d5662023-10-19 13:09:12 +053030 fastboot flash ptable "${INSTALLER_DIR}"/prm_ptable.img
31 fastboot flash xloader "${INSTALLER_DIR}"/hisi-sec_xloader.img
John Stultz7f18a532021-04-06 02:40:34 +000032 fastboot reboot-bootloader
33
Amit Pundir697d5662023-10-19 13:09:12 +053034 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
John Stultz7f18a532021-04-06 02:40:34 +000039 fastboot reboot-bootloader
40
Amit Pundir697d5662023-10-19 13:09:12 +053041 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
John Stultz7f18a532021-04-06 02:40:34 +000045
46 fastboot flash boot "${ANDROID_PRODUCT_OUT}"/boot.img
47 fastboot flash super "${ANDROID_PRODUCT_OUT}"/super.img
John Stultz38d4c1e2021-05-21 17:15:19 +000048 fastboot flash userdata "${ANDROID_PRODUCT_OUT}"/userdata.img
John Stultz7f18a532021-04-06 02:40:34 +000049 fastboot format cache
50}
51
52function upgrading_ptable_1mb_aligned () {
Amit Pundir697d5662023-10-19 13:09:12 +053053 fastboot flash xloader "${INSTALLER_DIR}"/hisi-sec_xloader.img
54 fastboot flash ptable "${INSTALLER_DIR}"/hisi-ptable.img
55 fastboot flash fastboot "${INSTALLER_DIR}"/hisi-fastboot.img
John Stultz7f18a532021-04-06 02:40:34 +000056 fastboot reboot-bootloader
57}
58
59echo ${ECHO_PREFIX}"Checking partition table version..."
60check_partition_table_version
61
62if [ "${IS_PTABLE_1MB_ALIGNED}" == "true" ]
63then
64 echo ${ECHO_PREFIX}"Partition table is 1MB aligned. Flashing ATF/UEFI..."
65 flashing_atf_uefi
66else
67 echo ${ECHO_PREFIX}"Partition table is 512KB aligned."
68 echo ${ECHO_PREFIX}"Upgrading to 1MB aligned version..."
69 upgrading_ptable_1mb_aligned
70 echo ${ECHO_PREFIX}"Flashing ATF/UEFI..."
71 flashing_atf_uefi
72 echo ${ECHO_PREFIX}"Done"
73fi
74
John Stultzb71a9ef2017-11-21 10:26:53 -080075fastboot reboot