1#!/bin/bash
2
3INSTALLER_DIR="`dirname ${0}`"
4
5QDL="`readlink -f ${INSTALLER_DIR}/qdl`"
6FIRMWARE_DIR="dragonboard-845c-bootloader-ufs-aosp"
7
8# for cases that don't run "lunch db845c-userdebug"
9if [ -z "${ANDROID_BUILD_TOP}" ]; then
10    ANDROID_BUILD_TOP=${INSTALLER_DIR}/../../../../../
11    ANDROID_PRODUCT_OUT="${ANDROID_BUILD_TOP}/out/target/product/db845c"
12fi
13
14if [ ! -d "${ANDROID_PRODUCT_OUT}" ]; then
15    echo "RECOVERY: error in locating out directory, check if it exist"
16    exit
17fi
18
19echo "android out dir:${ANDROID_PRODUCT_OUT}"
20
21# TODO: Pull one-time recovery/qdl path out of standard install
22# Flash bootloader firmware files
23if [ ! -d "${INSTALLER_DIR}/${FIRMWARE_DIR}/" ]; then
24    echo "RECOVERY: No firmware directory? Make sure binaries have been provided"
25    exit
26fi
27
28pushd "${INSTALLER_DIR}/${FIRMWARE_DIR}" > /dev/null
29sudo "${QDL}" prog_firehose_ddr.elf rawprogram[012345].xml patch[012345].xml
30popd > /dev/null
31
32echo
33echo
34echo "RECOVERY: Please boot the db845c into fastboot mode, and use the flash-all-aosp.sh script!"
35echo
36