1#!/bin/bash
2INSTALLER_DIR="`dirname ${0}`"
3
4# for cases that don't run "lunch db845c-userdebug"
5if [ -z "${ANDROID_BUILD_TOP}" ]; then
6    ANDROID_BUILD_TOP="`readlink -f ${INSTALLER_DIR}/../../../../../`"
7    ANDROID_PRODUCT_OUT="${ANDROID_BUILD_TOP}/out/target/product/db845c"
8fi
9
10if [ ! -d "${ANDROID_PRODUCT_OUT}" ]; then
11    echo "FLASH-ALL-AOSP: error in locating ${ANDROID_PRODUCT_OUT}/ directory, check if it exist"
12    exit
13fi
14
15. "${ANDROID_BUILD_TOP}/device/linaro/dragonboard/vendor-package-ver.sh"
16
17FIRMWARE_DIR="${ANDROID_BUILD_TOP}/vendor/linaro/db845c/${EXPECTED_LINARO_VENDOR_VERSION}"
18
19# TODO: Pull one-time recovery/qdl path out of standard install
20# Flash bootloader firmware files
21if [ ! -d "${FIRMWARE_DIR}/" ]; then
22    echo "FLASH-ALL-AOSP: Missing vendor firmware package?"
23    echo "                Make sure the vendor binaries have been downloaded from"
24    echo "                ${VND_PKG_URL}"
25    echo "                and extracted to $ANDROID_BUILD_TOP."
26    exit
27fi
28
29pushd "${FIRMWARE_DIR}/dragonboard-845c-bootloader-ufs-aosp" > /dev/null
30echo "FLASH-ALL-AOSP: Flash bootloader images"
31./flashall
32popd > /dev/null
33
34# Set HDMI monitor output
35echo "FLASH-ALL-AOSP: Set HDMI monitor output"
36fastboot oem select-display-panel foobar
37fastboot reboot bootloader
38
39echo "android out dir:${ANDROID_PRODUCT_OUT}"
40
41# Slot _a is already marked as active by bootloader but just in case..
42echo "FLASH-ALL-AOSP: Mark _a slot as active"
43fastboot set_active a
44echo "FLASH-ALL-AOSP: Flash boot img"
45fastboot flash boot "${ANDROID_PRODUCT_OUT}"/boot.img
46echo "FLASH-ALL-AOSP: Flash super/dynamic image"
47fastboot flash super "${ANDROID_PRODUCT_OUT}"/super.img
48echo "FLASH-ALL-AOSP: Flash userdata image"
49fastboot flash userdata "${ANDROID_PRODUCT_OUT}"/userdata.img
50echo "FLASH-ALL-AOSP: Flash vendor_boot image"
51fastboot flash vendor_boot "${ANDROID_PRODUCT_OUT}"/vendor_boot.img
52echo "FLASH-ALL-AOSP: Formatting metadata"
53fastboot format:ext4 metadata
54
55echo "FLASH-ALL-AOSP: Rebooting"
56fastboot reboot
57