forked from 900supersport/rkKitchen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflash.py
More file actions
232 lines (182 loc) · 7.01 KB
/
Copy pathflash.py
File metadata and controls
232 lines (182 loc) · 7.01 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
#!/usr/bin/python
#
#
# FreakTabKitchen www.freaktab.com
#
# Copyright 2013 Brian Mahoney brian@mahoneybrian.wanadoo.co.uk
#
# <version>2.0.1</version>
#
############################################################################
#
# FreakTabKitchen is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# FreakTabKitchen is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with FreakTabKitchen. If not, see <http://www.gnu.org/licenses/>.
#
############################################################################
import os
import logging
import rominfo
from kitchenUI import mymenu
from utils import logerror
from parameter import parse_parameter, parse_parameter_by_file, repairparams
# try:
#
# except Exception as e:
# logerror('flash::parse_parameter ',e,1)
def flash_menu():
'''display flash menu and process results'''
try:
ri = rominfo.rominfo
my_menu = dict([
('a1', 'flash misc'),
('b2', 'flash kernel'),
('c3', 'flash boot'),
('e4', 'flash recovery'),
('g5', 'flash system'),
('h6', 'flash parameters'),
('i7', 'clear cache'),
('j8', 'clear userdata'),
('k9', 'reboot'),
('pp', 'Pull ROM'),
('t=', '='),
('vm', 'main menu'),
('z=', '=')
])
choice = mymenu(my_menu,'Enter selection :',checkvalid = True)
if choice in ('1'):
flash_singleimage('working/misc.img',ri.misc.flashdata())
elif choice in ('2'):
flash_singleimage('working/kernel.img',ri.kernel.flashdata())
elif choice in ('3'):
flash_singleimage('working/boot.img',ri.boot.flashdata())
elif choice in ('4'):
flash_singleimage('working/recovery.img',ri.recovery.flashdata())
elif choice in ('5'):
flash_singleimage('working/system.img',ri.system.flashdata())
elif choice in ('6'):
flash_parameters()
elif choice in ('7'):
flash_clear('cache')
elif choice in ('8'):
flash_clear('userdata')
elif choice in ('9'):
flash_reboot()
elif choice in ('Pp'):
pullROM()
elif choice in('Rr'):
repairparams()
else:
pass
if choice not in ('m','M'):
flash_menu()
except Exception as e:
logerror('flash::flash_menu ',e,1)
def flash_parameters():
'''flash parameters to tab
create a signed version then flash as follows
rkflashtool w 0x0 0x20 working/parameters_crc
rkflashtool w 0x400 0x20 working/parameters_crc
rkflashtool w 0x800 0x20 working/parameters_crc
rkflashtool w 0xc00 0x20 working/parameters_crc
rkflashtool w 0x1000 0x20 working/parameters_crc
rkflashtool w 0x1400 0x20 working/parameters_crc
rkflashtool w 0x1800 0x20 working/parameters_crc
rkflashtool w 0x1c00 0x20 working/parameters_crc
'''
try:
os.remove('working/parameters_crc')
except:
pass
try:
path ='rkcrc'
os.system(path + ' -p working/parameter working/parameters_crc')
flash_singleimage('working/parameters_crc','0x0 0x20')
flash_singleimage_noprompt('working/parameters_crc','0x400 0x20')
flash_singleimage_noprompt('working/parameters_crc','0x800 0x20')
flash_singleimage_noprompt('working/parameters_crc','0xc00 0x20')
flash_singleimage_noprompt('working/parameters_crc','0x1000 0x20')
flash_singleimage_noprompt('working/parameters_crc','0x1400 0x20')
flash_singleimage_noprompt('working/parameters_crc','0x1800 0x20')
flash_singleimage_noprompt('working/parameters_crc','0x1c00 0x20')
os.remove('working/parameters_crc')
raw_input('press enter to continue')
except Exception as e:
logerror('flash::flash_parameters ',e,1)
def flash_clear(image):
'''clear-format and image'''
print 'to be implemented clear ' + image
def flash_reboot():
'''reboot the device'''
try:
s = 'sudo rkflashtool b '
print s
os.system(s)
except Exception as e:
logerror('flash::flash_reboot ',e,1)
def flash_singleimage_worker(image,params,prompt):
'''flash a single image'''
try:
s = 'sudo rkflashtool w ' + params + ' <' + image
if prompt == 1:
print s
r = raw_input('press f to flash ')
if r == 'f':
os.system(s)
raw_input('press enter to continue')
else:
os.system(s)
except Exception as e:
logerror('flash::flash_singleimage_worker ',e,1)
def flash_singleimage_noprompt(image,params):
'''flash an image without prompt'''
flash_singleimage_worker(image,params,0)
def flash_singleimage(image,params):
'''flash an image with prompt'''
flash_singleimage_worker(image,params,1)
#read methods
def pullROM():
'''read parameters from tab
rkflashtool r 0x1c00 0x20 working/parameters_read
'''
try:
#check_make_folder('read')
ri = rominfo.rominfo
read_singleimage('read/parameter','0x0 0x20')
parse_parameter_by_file('read/parameter')
#read_singleimage('read/misc.img',ri.misc.flashdata())
read_singleimage('read/kernel.img',ri.kernel.flashdata())
read_singleimage('read/boot.img',ri.boot.flashdata())
read_singleimage('read/backup.img',ri.backup.flashdata())
read_singleimage('read/recovery.img',ri.recovery.flashdata())
read_singleimage('read/system.img',ri.system.flashdata())
raw_input('press enter to continue')
except Exception as e:
logerror('flash::pullROM ',e,1)
def read_singleimage(image,params):
read_singleimage_worker(image,params,1)
def read_singleimage_noprompt(image,params):
read_singleimage_worker(image,params,0)
def read_singleimage_worker(image,params,prompt):
'''read a single image'''
try:
s = 'sudo rkflashtool r ' + params + ' >' + image
if prompt == 1:
print s
r = raw_input('press r to read ')
if r == 'r':
os.system(s)
#raw_input('press enter to continue')
else:
os.system(s)
except Exception as e:
logerror('flash::read_singleimage_worker ',e,1)