-
Notifications
You must be signed in to change notification settings - Fork 0
/
flash_device.sh
executable file
·81 lines (75 loc) · 2.16 KB
/
flash_device.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color
print() {
printf "$1 $2 ${NC}\n"
}
bin=`which fastboot | awk '{ print \$1 }'`
if [ -z $bin ]; then
echo Could not locate your fastboot binary. Try placing it in your \$PATH.
exit 1
fi
cat <<HEADER
Created by Georgii Savatkov
Script to flash your device with full firmware
-
Version: 1.0 FastBoot Type: Fastboot
-
Have fun! Tested on Moto X 2 Gen.
-
Press any key to start fastboot erase, or Ctrl+C to abort!
HEADER
read
echo '[Running Commands...]'
echo '[Checking for phone...]'
devs=`$bin devices | grep fastboot | wc -l`
if [ $devs -ge 1 ]; then
ser=`$bin devices | awk '{ print \$1 }'`
echo -e "\nI was able to find a device with fastboot serial of $ser\n"
echo Any key to continue, or Ctrl+C to abort
read
print $NC "Flashing partition..."
$bin flash partition ./gpt.bin
print $GREEN "Done" # done
print $NC "Flashing motoboot..."
$bin flash motoboot ./motoboot.img
print $GREEN "Done" #done
print $NC "Rebooting device..."
$bin reboot-bootloader
print $GREEN "Done" #done
print $NC "Flashing logo..."
$bin flash logo ./logo.bin
print $GREEN "Done" #done
print $NC "Flashing boot..."
$bin flash boot ./boot.img
print $GREEN "Done" #done
print $NC "Flashing recovery..."
$bin flash recovery ./recovery.img
print $GREEN "Done" #done
echo "Flashing system..."
for i in {0..8}
do
/Users/george/Downloads/mfastboot-v2/mfastboot flash system ./system.img_sparsechunk.$i
print $GREEN "Done" #done
done
print $GREEN "Done" #done
print $NC "Erasing previous bands..."
$bin erase modemst1
$bin erase modemst2
print $GREEN "Done" #done
$bin flash fsg ./fsg.mbn
print $GREEN "Done" #done
$bin flash modem ./NON-HLOS.bin
print $GREEN "Done" #done
$bin erase userdata
$bin erase cache
print $GREEN "Done" #done
print $NC "Rebooting device..." #reboot
$bin reboot
print $GREEN "Done! Have fun, your device is ready" #done
exit 0
else
print $RED "Didn't detect a phone in fastboot mode, exiting"
exit 1
fi