Amit Pundir | e4ca84a | 2021-05-26 14:30:57 +0530 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | INSTALLER_DIR="`dirname ${0}`" |
| 4 | |
| 5 | FIRMWARE_DIR="rb5-bootloader-ufs-aosp" |
| 6 | |
| 7 | # for cases that don't run "lunch rb5-userdebug" |
| 8 | if [ -z "${ANDROID_BUILD_TOP}" ]; then |
| 9 | ANDROID_BUILD_TOP=${INSTALLER_DIR}/../../../../../ |
| 10 | ANDROID_PRODUCT_OUT="${ANDROID_BUILD_TOP}/out/target/product/rb5" |
| 11 | fi |
| 12 | |
| 13 | if [ ! -d "${ANDROID_PRODUCT_OUT}" ]; then |
| 14 | echo "FLASH-ALL-AOSP: error in locating out/target directory, check if it exist" |
| 15 | exit |
| 16 | fi |
| 17 | |
| 18 | echo "android out dir:${ANDROID_PRODUCT_OUT}" |
| 19 | |
| 20 | # TODO: Pull one-time recovery/qdl path out of standard install |
| 21 | # Flash bootloader firmware files |
| 22 | if [ ! -d "${INSTALLER_DIR}/${FIRMWARE_DIR}/" ]; then |
| 23 | echo "FLASH-ALL-AOSP: No firmware directory? Make sure binaries have been provided" |
| 24 | exit |
| 25 | fi |
| 26 | |
| 27 | pushd "${INSTALLER_DIR}/${FIRMWARE_DIR}" > /dev/null |
| 28 | ./flashall |
| 29 | popd > /dev/null |
| 30 | |
| 31 | echo "FLASH-ALL-AOSP: Flash boot img" |
| 32 | fastboot flash boot "${ANDROID_PRODUCT_OUT}"/boot.img |
| 33 | echo "FLASH-ALL-AOSP: Flash super/dynamic image" |
| 34 | fastboot flash super "${ANDROID_PRODUCT_OUT}"/super.img |
| 35 | echo "FLASH-ALL-AOSP: Flash userdata image" |
| 36 | fastboot flash userdata "${ANDROID_PRODUCT_OUT}"/userdata.img |
| 37 | echo "FLASH-ALL-AOSP: Flash vendor_boot image" |
| 38 | fastboot flash vendor_boot "${ANDROID_PRODUCT_OUT}"/vendor_boot.img |
| 39 | echo "FLASH-ALL-AOSP: Formatting metadata" |
| 40 | fastboot format:ext4 metadata |
| 41 | |
| 42 | fastboot reboot |
| 43 | |
| 44 | echo "FLASH-ALL-AOSP: Updating lt9611uxc firmware version" |
| 45 | adb wait-for-device |
| 46 | VERSION=`adb shell su 0 cat /sys/bus/i2c/devices/5-002b/lt9611uxc_firmware` |
| 47 | if [ "$VERSION" -lt "43" ] ; then |
| 48 | echo "FLASH-ALL-AOSP: lt9611uxc 5-002b: Updating firmware... May take up to 120 seconds. Do not switch off the device" |
| 49 | adb shell "echo 1 | su 0 tee /sys/bus/i2c/devices/5-002b/lt9611uxc_firmware > /dev/null" |
| 50 | echo "FLASH-ALL-AOSP: lt9611uxc 5-002b: Firmware updates successfully" |
| 51 | echo "FLASH-ALL-AOSP: Rebooting" |
| 52 | adb reboot |
| 53 | fi |
| 54 | echo "FLASH-ALL-AOSP: Done" |