Dmitry Shmidt | 5d08080 | 2017-04-11 14:20:03 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | INSTALLER_DIR="`dirname ${0}`" |
John Stultz | 7f18a53 | 2021-04-06 02:40:34 +0000 | [diff] [blame] | 4 | ECHO_PREFIX="=== " |
Dmitry Shmidt | 5d08080 | 2017-04-11 14:20:03 -0700 | [diff] [blame] | 5 | |
Amit Pundir | e0b34ce | 2023-10-19 18:29:28 +0530 | [diff] [blame] | 6 | # for cases that don't run "lunch linaro_hikey960-userdebug" |
Dmitry Shmidt | 5d08080 | 2017-04-11 14:20:03 -0700 | [diff] [blame] | 7 | if [ -z "${ANDROID_BUILD_TOP}" ]; then |
Amit Pundir | 697d566 | 2023-10-19 13:09:12 +0530 | [diff] [blame] | 8 | ANDROID_BUILD_TOP=${INSTALLER_DIR}/../../../../../ |
Amit Pundir | e0b34ce | 2023-10-19 18:29:28 +0530 | [diff] [blame] | 9 | ANDROID_PRODUCT_OUT="${ANDROID_BUILD_TOP}/out/target/product/linaro_hikey960" |
Dmitry Shmidt | 5d08080 | 2017-04-11 14:20:03 -0700 | [diff] [blame] | 10 | fi |
| 11 | |
| 12 | if [ ! -d "${ANDROID_PRODUCT_OUT}" ]; then |
John Stultz | 7f18a53 | 2021-04-06 02:40:34 +0000 | [diff] [blame] | 13 | echo ${ECHO_PREFIX}"error in locating out directory, check if it exist" |
Dmitry Shmidt | 5d08080 | 2017-04-11 14:20:03 -0700 | [diff] [blame] | 14 | exit |
| 15 | fi |
| 16 | |
John Stultz | 7f18a53 | 2021-04-06 02:40:34 +0000 | [diff] [blame] | 17 | echo ${ECHO_PREFIX}"android out dir:${ANDROID_PRODUCT_OUT}" |
Dmitry Shmidt | 5d08080 | 2017-04-11 14:20:03 -0700 | [diff] [blame] | 18 | |
John Stultz | 7f18a53 | 2021-04-06 02:40:34 +0000 | [diff] [blame] | 19 | function 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 | |
| 29 | function flashing_atf_uefi () { |
Amit Pundir | 697d566 | 2023-10-19 13:09:12 +0530 | [diff] [blame] | 30 | fastboot flash ptable "${INSTALLER_DIR}"/prm_ptable.img |
| 31 | fastboot flash xloader "${INSTALLER_DIR}"/hisi-sec_xloader.img |
John Stultz | 7f18a53 | 2021-04-06 02:40:34 +0000 | [diff] [blame] | 32 | fastboot reboot-bootloader |
| 33 | |
Amit Pundir | 697d566 | 2023-10-19 13:09:12 +0530 | [diff] [blame] | 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 |
John Stultz | 7f18a53 | 2021-04-06 02:40:34 +0000 | [diff] [blame] | 39 | fastboot reboot-bootloader |
| 40 | |
Amit Pundir | 697d566 | 2023-10-19 13:09:12 +0530 | [diff] [blame] | 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 |
John Stultz | 7f18a53 | 2021-04-06 02:40:34 +0000 | [diff] [blame] | 45 | |
| 46 | fastboot flash boot "${ANDROID_PRODUCT_OUT}"/boot.img |
| 47 | fastboot flash super "${ANDROID_PRODUCT_OUT}"/super.img |
John Stultz | 38d4c1e | 2021-05-21 17:15:19 +0000 | [diff] [blame] | 48 | fastboot flash userdata "${ANDROID_PRODUCT_OUT}"/userdata.img |
John Stultz | 7f18a53 | 2021-04-06 02:40:34 +0000 | [diff] [blame] | 49 | fastboot format cache |
| 50 | } |
| 51 | |
| 52 | function upgrading_ptable_1mb_aligned () { |
Amit Pundir | 697d566 | 2023-10-19 13:09:12 +0530 | [diff] [blame] | 53 | 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 Stultz | 7f18a53 | 2021-04-06 02:40:34 +0000 | [diff] [blame] | 56 | fastboot reboot-bootloader |
| 57 | } |
| 58 | |
| 59 | echo ${ECHO_PREFIX}"Checking partition table version..." |
| 60 | check_partition_table_version |
| 61 | |
| 62 | if [ "${IS_PTABLE_1MB_ALIGNED}" == "true" ] |
| 63 | then |
| 64 | echo ${ECHO_PREFIX}"Partition table is 1MB aligned. Flashing ATF/UEFI..." |
| 65 | flashing_atf_uefi |
| 66 | else |
| 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" |
| 73 | fi |
| 74 | |
John Stultz | b71a9ef | 2017-11-21 10:26:53 -0800 | [diff] [blame] | 75 | fastboot reboot |