blob: 7cf477585d5da24cc51c3f854a721612ff84f482 [file] [log] [blame]
Vishal Bhojca1fbcd2015-12-16 00:25:24 +05301#!/bin/bash
2if [ $# -eq 0 ]
3 then
4 echo "Provide the right /dev/ttyUSBX specific to recovery device"
5 exit
6fi
7
Vishal Bhoj2df2ca72016-07-12 17:14:56 +01008if [ ! -e "${1}" ]
Vishal Bhojca1fbcd2015-12-16 00:25:24 +05309 then
Vishal Bhoj2df2ca72016-07-12 17:14:56 +010010 echo "device: ${1} does not exist"
Vishal Bhojca1fbcd2015-12-16 00:25:24 +053011 exit
12fi
Vishal Bhoj2df2ca72016-07-12 17:14:56 +010013DEVICE_PORT="${1}"
Dmitry Shmidt06cb4cd2016-01-27 11:00:33 -080014PTABLE=ptable-aosp-8g.img
15if [ $# -gt 1 ]
16 then
Vishal Bhoj2df2ca72016-07-12 17:14:56 +010017 if [ "${2}" == '4g' ]
Dmitry Shmidt06cb4cd2016-01-27 11:00:33 -080018 then
19 PTABLE=ptable-aosp-4g.img
20 fi
21fi
22
Vishal Bhoj2df2ca72016-07-12 17:14:56 +010023INSTALLER_DIR="`dirname ${0}`"
24FIRMWARE_DIR="${INSTALLER_DIR}"
25
26if [ -z "${DIST_DIR}" ]; then
27 DIST_DIR="${ANDROID_BUILD_TOP}"/out/dist
28fi
Satish Pateldc91c892016-03-28 10:03:21 +053029
30#get out directory path
31while [ $# -ne 0 ]; do
Vishal Bhoj2df2ca72016-07-12 17:14:56 +010032 case "${1}" in
33 --out) OUT_IMGDIR=${2};shift;;
34 --use-compiled-binaries) FIRMWARE_DIR="${DIST_DIR}";shift;;
Satish Pateldc91c892016-03-28 10:03:21 +053035 esac
36 shift
37done
38
Vishal Bhoj2df2ca72016-07-12 17:14:56 +010039if [[ "${FIRMWARE_DIR}" == "${DIST_DIR}" && ! -e "${DIST_DIR}"/fip.bin && ! -e "${DIST_DIR}"/l-loader.bin ]]; then
40 echo "No binaries found at ${DIST_DIR}. Please build the bootloader first"
41 exit
42fi
43
44if [ -z "${OUT_IMGDIR}" ]; then
45 if [ ! -z "${ANDROID_PRODUCT_OUT}" ]; then
46 OUT_IMGDIR="${ANDROID_PRODUCT_OUT}"
Satish Pateldc91c892016-03-28 10:03:21 +053047 fi
48fi
49
Vishal Bhoj2df2ca72016-07-12 17:14:56 +010050if [ ! -d "${OUT_IMGDIR}" ]; then
Satish Pateldc91c892016-03-28 10:03:21 +053051 echo "error in locating out directory, check if it exist"
52 exit
53fi
Satish Pateldc91c892016-03-28 10:03:21 +053054
Vishal Bhoj2df2ca72016-07-12 17:14:56 +010055echo "android out dir:${OUT_IMGDIR}"
56
57sudo python "${INSTALLER_DIR}"/hisi-idt.py --img1="${FIRMWARE_DIR}"/l-loader.bin -d "${DEVICE_PORT}"
58fastboot flash ptable "${INSTALLER_DIR}"/"${PTABLE}"
59fastboot flash fastboot "${FIRMWARE_DIR}"/fip.bin
60fastboot flash nvme "${INSTALLER_DIR}"/nvme.img
61fastboot flash boot "${OUT_IMGDIR}"/boot.img
62fastboot flash system "${OUT_IMGDIR}"/system.img
63fastboot flash cache "${OUT_IMGDIR}"/cache.img
64fastboot flash userdata "${OUT_IMGDIR}"/userdata.img