Vishal Bhoj | ca1fbcd | 2015-12-16 00:25:24 +0530 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | if [ $# -eq 0 ] |
| 3 | then |
| 4 | echo "Provide the right /dev/ttyUSBX specific to recovery device" |
| 5 | exit |
| 6 | fi |
| 7 | |
Vishal Bhoj | 2df2ca7 | 2016-07-12 17:14:56 +0100 | [diff] [blame] | 8 | if [ ! -e "${1}" ] |
Vishal Bhoj | ca1fbcd | 2015-12-16 00:25:24 +0530 | [diff] [blame] | 9 | then |
Vishal Bhoj | 2df2ca7 | 2016-07-12 17:14:56 +0100 | [diff] [blame] | 10 | echo "device: ${1} does not exist" |
Vishal Bhoj | ca1fbcd | 2015-12-16 00:25:24 +0530 | [diff] [blame] | 11 | exit |
| 12 | fi |
Vishal Bhoj | 2df2ca7 | 2016-07-12 17:14:56 +0100 | [diff] [blame] | 13 | DEVICE_PORT="${1}" |
Dmitry Shmidt | 06cb4cd | 2016-01-27 11:00:33 -0800 | [diff] [blame] | 14 | PTABLE=ptable-aosp-8g.img |
| 15 | if [ $# -gt 1 ] |
| 16 | then |
Vishal Bhoj | 2df2ca7 | 2016-07-12 17:14:56 +0100 | [diff] [blame] | 17 | if [ "${2}" == '4g' ] |
Dmitry Shmidt | 06cb4cd | 2016-01-27 11:00:33 -0800 | [diff] [blame] | 18 | then |
| 19 | PTABLE=ptable-aosp-4g.img |
| 20 | fi |
| 21 | fi |
| 22 | |
Vishal Bhoj | 2df2ca7 | 2016-07-12 17:14:56 +0100 | [diff] [blame] | 23 | INSTALLER_DIR="`dirname ${0}`" |
| 24 | FIRMWARE_DIR="${INSTALLER_DIR}" |
| 25 | |
Yongqin Liu | 74aa066 | 2016-07-16 20:46:52 +0800 | [diff] [blame] | 26 | # for cases that not run "lunch hikey-userdebu" |
| 27 | if [ -z "${ANDROID_BUILD_TOP}" ]; then |
| 28 | ANDROID_BUILD_TOP=${INSTALLER_DIR}/../../../../ |
| 29 | ANDROID_PRODUCT_OUT="${ANDROID_BUILD_TOP}/out/target/product/hikey" |
| 30 | fi |
| 31 | |
Vishal Bhoj | 2df2ca7 | 2016-07-12 17:14:56 +0100 | [diff] [blame] | 32 | if [ -z "${DIST_DIR}" ]; then |
| 33 | DIST_DIR="${ANDROID_BUILD_TOP}"/out/dist |
| 34 | fi |
Satish Patel | dc91c89 | 2016-03-28 10:03:21 +0530 | [diff] [blame] | 35 | |
| 36 | #get out directory path |
| 37 | while [ $# -ne 0 ]; do |
Vishal Bhoj | 2df2ca7 | 2016-07-12 17:14:56 +0100 | [diff] [blame] | 38 | case "${1}" in |
| 39 | --out) OUT_IMGDIR=${2};shift;; |
| 40 | --use-compiled-binaries) FIRMWARE_DIR="${DIST_DIR}";shift;; |
Satish Patel | dc91c89 | 2016-03-28 10:03:21 +0530 | [diff] [blame] | 41 | esac |
| 42 | shift |
| 43 | done |
| 44 | |
Vishal Bhoj | 2df2ca7 | 2016-07-12 17:14:56 +0100 | [diff] [blame] | 45 | if [[ "${FIRMWARE_DIR}" == "${DIST_DIR}" && ! -e "${DIST_DIR}"/fip.bin && ! -e "${DIST_DIR}"/l-loader.bin ]]; then |
| 46 | echo "No binaries found at ${DIST_DIR}. Please build the bootloader first" |
| 47 | exit |
| 48 | fi |
| 49 | |
| 50 | if [ -z "${OUT_IMGDIR}" ]; then |
| 51 | if [ ! -z "${ANDROID_PRODUCT_OUT}" ]; then |
| 52 | OUT_IMGDIR="${ANDROID_PRODUCT_OUT}" |
Satish Patel | dc91c89 | 2016-03-28 10:03:21 +0530 | [diff] [blame] | 53 | fi |
| 54 | fi |
| 55 | |
Vishal Bhoj | 2df2ca7 | 2016-07-12 17:14:56 +0100 | [diff] [blame] | 56 | if [ ! -d "${OUT_IMGDIR}" ]; then |
Satish Patel | dc91c89 | 2016-03-28 10:03:21 +0530 | [diff] [blame] | 57 | echo "error in locating out directory, check if it exist" |
| 58 | exit |
| 59 | fi |
Satish Patel | dc91c89 | 2016-03-28 10:03:21 +0530 | [diff] [blame] | 60 | |
Vishal Bhoj | 2df2ca7 | 2016-07-12 17:14:56 +0100 | [diff] [blame] | 61 | echo "android out dir:${OUT_IMGDIR}" |
| 62 | |
| 63 | sudo python "${INSTALLER_DIR}"/hisi-idt.py --img1="${FIRMWARE_DIR}"/l-loader.bin -d "${DEVICE_PORT}" |
| 64 | fastboot flash ptable "${INSTALLER_DIR}"/"${PTABLE}" |
| 65 | fastboot flash fastboot "${FIRMWARE_DIR}"/fip.bin |
| 66 | fastboot flash nvme "${INSTALLER_DIR}"/nvme.img |
| 67 | fastboot flash boot "${OUT_IMGDIR}"/boot.img |
| 68 | fastboot flash system "${OUT_IMGDIR}"/system.img |
| 69 | fastboot flash cache "${OUT_IMGDIR}"/cache.img |
| 70 | fastboot flash userdata "${OUT_IMGDIR}"/userdata.img |