-
Notifications
You must be signed in to change notification settings - Fork 245
Expand file tree
/
Copy pathFlashToolConsole
More file actions
253 lines (230 loc) · 7.09 KB
/
FlashToolConsole
File metadata and controls
253 lines (230 loc) · 7.09 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#!/bin/sh
export BASEDIR=$(dirname $0)
export system64=$(uname -m)
export OS=$(uname -s)
cd $BASEDIR
rootandudevcheck() {
if [ "$(whoami)" != "root" ]
then
export HASRULES="false"
if test -d /etc/udev/rules.d
then
if grep -rl "0fce" /etc/udev/rules.d >/dev/null
then
export HASRULES="true"
fi
fi
if test "$HASRULES" = "true"
then
echo "Not running as root but Sony/SonyEriccson Vendor ID found on your udev rules"
echo "if Flashing didn't work well, run flashtool as root"
else
echo "Not running as root and there is no Sony/SonyEriccson Vendor ID on your udev rules"
echo "The user must be granted access to adb/flashmode/fastboot"
echo "If you are unsure what to do, run flashtool as root"
exit 1
fi
else
echo "Running as root."
fi
}
show_help() {
echo Usage : FlashToolConsole [OPTIONS]
echo
echo MANDATORY :
echo ' --action=flash|imei|extract'
echo ' --file=/path/to/file.ftf (only when action=flash)'
echo ' /path/to/file.sin (only when action=extract)'
echo
echo
echo OPTIONAL :
echo ' --wipedata=yes|no (only when action=flash)'
echo ' --wipecache=yes|no (only when action=flash)'
echo ' --baseband=yes|no (only when action=flash)'
echo ' --system=yes|no (only when action=flash)'
echo ' --kernel=yes|no (only when action=flash)'
exit 0
}
if test $# -eq 0
then
show_help;
fi
while test $# != 0
do
case $1 in
--*=*)
ac_option=`expr "X$1" : 'X\([^=]*\)='`
ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
ac_shift=:
;;
*)
ac_option=$1
ac_optarg=$2
ac_shift=shift
;;
esac
case $ac_option in
-a | --action)
export p_action=$ac_optarg;;
-f | --file)
export p_file=$ac_optarg;;
--wipedata)
export p_data=$ac_optarg;;
--wipecache)
export p_cache=$ac_optarg;;
--baseband)
export p_baseband=$ac_optarg;;
--system)
export p_system=$ac_optarg;;
--kernel)
export p_kernel=$ac_optarg;;
-h | --help)
show_help;;
*)
show_help;;
esac
shift
done
case $p_action in
flash | imei | extract)
;;
*)
show_help;;
esac
if [ "$p_action" = "flash" ]
then
if test -z "$p_file"
then
echo --file is mandatory when --action=flash
exit 1
fi
if [ -e $p_file ]
then
if test -z $p_data
then
p_data=$(echo yes)
fi
if test -z $p_cache
then
p_cache=$(echo yes)
fi
if test -z $p_system
then
p_system=$(echo yes)
fi
if test -z $p_kernel
then
p_kernel=$(echo yes)
fi
if test -z $p_baseband
then
p_baseband=$(echo yes)
fi
else
echo $p_file does not exist.
exit 1
fi
fi
if [ "$p_action" = "extract" ]
then
if test -z "$p_file"
then
echo --file is mandatory when --action=flash
exit 1
fi
if [ ! -e $p_file ]
then
echo $p_file does not exist.
exit 1
fi
fi
if test "$OS" = "Linux"
then
if test "${system64}" = "x86_64"
then
export JAVA_HOME=./x10flasher_lib/linjre64
else
export JAVA_HOME=./x10flasher_lib/linjre32
fi
echo "Used java home : ${JAVA_HOME}"
ISJAVA64=$($JAVA_HOME/bin/java -version 2>&1|grep 64-Bit|wc -l)
CP=$(ls ./x10flasher_lib/*jar|xargs|tr ' ' ':')
if test $ISJAVA64 -gt 0
then
UDEV=$(ldd x10flasher_lib/linux/lib64/udev/libusbx-1.0.so.0.1.0 |grep found|wc -l)
if test $UDEV -gt 0
then
export LD_LIBRARY_PATH=./x10flasher_lib/linux/lib64/udev1
else
export LD_LIBRARY_PATH=./x10flasher_lib/linux/lib64/udev
fi
SWT=$(ls ./x10flasher_lib/swtlin/x86_64/*jar|xargs|tr ' ' ':')
else
UDEV=$(ldd x10flasher_lib/linux/lib32/udev/libusbx-1.0.so.0.1.0 |grep found|wc -l)
if test $UDEV -gt 0
then
export LD_LIBRARY_PATH=./x10flasher_lib/linux/lib32/udev1
else
export LD_LIBRARY_PATH=./x10flasher_lib/linux/lib32/udev
fi
SWT=$(ls ./x10flasher_lib/swtlin/x86/*jar|xargs|tr ' ' ':')
fi
case $p_action in
flash)
$JAVA_HOME/bin/java -classpath ./x10flasher.jar:${CP}:${SWT} \
-Xms128m -Xmx512m -Duser.country=US -Duser.language=en \
-Djsse.enableSNIExtension=false gui.Main -console \
--action=flash --file=$p_file --wipedata=$p_data --wipecache=$p_cache \
--baseband=$p_baseband --system=$p_system --kernel=$p_kernel
;;
extract)
$JAVA_HOME/bin/java -classpath ./x10flasher.jar:${CP}:${SWT} \
-Xms128m -Xmx512m -Duser.country=US -Duser.language=en \
-Djsse.enableSNIExtension=false gui.Main -console \
--action=extract --file=$p_file
;;
imei)
$JAVA_HOME/bin/java -classpath ./x10flasher.jar:${CP}:${SWT} \
-Xms128m -Xmx512m -Duser.country=US -Duser.language=en \
-Djsse.enableSNIExtension=false gui.Main -console \
--action=imei
esac
else
if test "${system64}" = "x86_64"
then
export JAVA_HOME=./x10flasher_lib/macjre64
else
export JAVA_HOME=./x10flasher_lib/macjre32
fi
echo "Used java home : ${JAVA_HOME}"
ISJAVA64=$($JAVA_HOME/bin/java -version 2>&1|grep 64-Bit|wc -l)
CP=$(ls ./x10flasher_lib/*jar|xargs|tr ' ' ':')
if test $ISJAVA64 -gt 0
then
export DYLD_LIBRARY_PATH=./x10flasher_lib/mac/lib64:$DYLD_LIBRARY_PATH
SWT=./x10flasher_lib/swtmac/swt64.jar
else
export DYLD_LIBRARY_PATH=./x10flasher_lib/mac/lib32:$DYLD_LIBRARY_PATH
SWT=./x10flasher_lib/swtmac/swt32.jar
fi
case $p_action in
flash)
$JAVA_HOME/bin/java -XstartOnFirstThread -classpath ./x10flasher.jar:${CP}:${SWT} \
-Xms128m -Xmx512m -Duser.country=US -Duser.language=en \
-Djsse.enableSNIExtension=false gui.Main -console \
--action=flash --file=$p_file --wipedata=$p_data --wipecache=$p_cache \
--baseband=$p_baseband --system=$p_system --kernel=$p_kernel
;;
extract)
$JAVA_HOME/bin/java -XstartOnFirstThread -classpath ./x10flasher.jar:${CP}:${SWT} \
-Xms128m -Xmx512m -Duser.country=US -Duser.language=en \
-Djsse.enableSNIExtension=false gui.Main \
--action=extract --file=$p_file
;;
imei)
$JAVA_HOME/bin/java -XstartOnFirstThread -classpath ./x10flasher.jar:${CP}:${SWT} \
-Xms128m -Xmx512m -Duser.country=US -Duser.language=en \
-Djsse.enableSNIExtension=false gui.Main \
--action=imei
esac
fi