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