diff options
-rw-r--r-- | utils/meizu_dfu/meizu_dfu.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/utils/meizu_dfu/meizu_dfu.c b/utils/meizu_dfu/meizu_dfu.c index 86c53c2d12..b7b1c43ef7 100644 --- a/utils/meizu_dfu/meizu_dfu.c +++ b/utils/meizu_dfu/meizu_dfu.c | |||
@@ -74,7 +74,7 @@ typedef struct { | |||
74 | 74 | ||
75 | #define USB_VID_SAMSUNG 0x0419 | 75 | #define USB_VID_SAMSUNG 0x0419 |
76 | #define USB_PID_M6SL 0x0145 | 76 | #define USB_PID_M6SL 0x0145 |
77 | #define USB_PID_M6 0x0141 | 77 | #define USB_PID_M3_M6 0x0141 |
78 | 78 | ||
79 | void init_img(image_data_t *img, const char *filename, image_attr_t *attr) | 79 | void init_img(image_data_t *img, const char *filename, image_attr_t *attr) |
80 | { | 80 | { |
@@ -130,7 +130,6 @@ usb_dev_handle *usb_dev_open(uint16_t dfu_vid, uint16_t dfu_pid) | |||
130 | usb_dev_handle *device; | 130 | usb_dev_handle *device; |
131 | 131 | ||
132 | printf("USB initialization..."); | 132 | printf("USB initialization..."); |
133 | fflush(stdout); | ||
134 | 133 | ||
135 | usb_init(); | 134 | usb_init(); |
136 | usb_find_busses(); | 135 | usb_find_busses(); |
@@ -176,7 +175,6 @@ void usb_mimic_windows(usb_dev_handle *device) | |||
176 | void usb_dev_close(usb_dev_handle *device) | 175 | void usb_dev_close(usb_dev_handle *device) |
177 | { | 176 | { |
178 | printf("Releasing interface..."); | 177 | printf("Releasing interface..."); |
179 | fflush(stdout); | ||
180 | 178 | ||
181 | usb_release_interface(device, 0); | 179 | usb_release_interface(device, 0); |
182 | 180 | ||
@@ -200,7 +198,6 @@ void get_cpu(usb_dev_handle *device) | |||
200 | int len; | 198 | int len; |
201 | 199 | ||
202 | printf("GET CPU"); | 200 | printf("GET CPU"); |
203 | fflush(stdout); | ||
204 | 201 | ||
205 | // check for "S5L8700 Rev.1" | 202 | // check for "S5L8700 Rev.1" |
206 | len = usb_control_msg(device, req_out_if, 0xff, 0x0002, 0, data, 0x003f, DFU_TIMEOUT); | 203 | len = usb_control_msg(device, req_out_if, 0xff, 0x0002, 0, data, 0x003f, DFU_TIMEOUT); |
@@ -222,7 +219,6 @@ void send_file(usb_dev_handle *device, image_data_t *img) | |||
222 | int len, idx, writelen, i; | 219 | int len, idx, writelen, i; |
223 | 220 | ||
224 | printf("Sending %s... ", img->name); | 221 | printf("Sending %s... ", img->name); |
225 | fflush(stdout); | ||
226 | 222 | ||
227 | len = img->len; | 223 | len = img->len; |
228 | data = img->data; | 224 | data = img->data; |
@@ -235,7 +231,6 @@ void send_file(usb_dev_handle *device, image_data_t *img) | |||
235 | while (dfu_ret[4] != 0x05) | 231 | while (dfu_ret[4] != 0x05) |
236 | usb_control_msg(device, req_in_if, DFU_GETSTATUS, 0, 0, dfu_ret, 6, DFU_TIMEOUT); | 232 | usb_control_msg(device, req_in_if, DFU_GETSTATUS, 0, 0, dfu_ret, 6, DFU_TIMEOUT); |
237 | printf("#"); | 233 | printf("#"); |
238 | fflush(stdout); | ||
239 | } | 234 | } |
240 | 235 | ||
241 | usb_control_msg(device, req_out_if, DFU_DOWNLOAD, idx, 0, NULL, 0, DFU_TIMEOUT); | 236 | usb_control_msg(device, req_out_if, DFU_DOWNLOAD, idx, 0, NULL, 0, DFU_TIMEOUT); |
@@ -244,7 +239,6 @@ void send_file(usb_dev_handle *device, image_data_t *img) | |||
244 | usb_control_msg(device, req_in_if, DFU_GETSTATUS, 0, 0, dfu_ret, 6, DFU_TIMEOUT); | 239 | usb_control_msg(device, req_in_if, DFU_GETSTATUS, 0, 0, dfu_ret, 6, DFU_TIMEOUT); |
245 | 240 | ||
246 | printf(" OK\n"); | 241 | printf(" OK\n"); |
247 | fflush(stdout); | ||
248 | } | 242 | } |
249 | 243 | ||
250 | void clear_status(usb_dev_handle *device) | 244 | void clear_status(usb_dev_handle *device) |
@@ -254,7 +248,6 @@ void clear_status(usb_dev_handle *device) | |||
254 | int usb_out_if = USB_ENDPOINT_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE; | 248 | int usb_out_if = USB_ENDPOINT_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE; |
255 | 249 | ||
256 | printf("Clearing status..."); | 250 | printf("Clearing status..."); |
257 | fflush(stdout); | ||
258 | 251 | ||
259 | dfu_ret[4] = 0x00; | 252 | dfu_ret[4] = 0x00; |
260 | while (dfu_ret[4] != 0x08) | 253 | while (dfu_ret[4] != 0x08) |
@@ -271,7 +264,6 @@ void dfu_detach(usb_dev_handle *device) | |||
271 | int usb_out_oth = USB_ENDPOINT_OUT | USB_TYPE_CLASS | USB_RECIP_OTHER; | 264 | int usb_out_oth = USB_ENDPOINT_OUT | USB_TYPE_CLASS | USB_RECIP_OTHER; |
272 | 265 | ||
273 | printf("Detaching..."); | 266 | printf("Detaching..."); |
274 | fflush(stdout); | ||
275 | 267 | ||
276 | usb_control_msg(device, usb_in_oth, DFU_DETACH, 0x0000, 3, usb_ret, 4, DFU_TIMEOUT); | 268 | usb_control_msg(device, usb_in_oth, DFU_DETACH, 0x0000, 3, usb_ret, 4, DFU_TIMEOUT); |
277 | usb_control_msg(device, usb_out_oth, DFU_DOWNLOAD, 0x0010, 3, NULL, 0, DFU_TIMEOUT); | 269 | usb_control_msg(device, usb_out_oth, DFU_DOWNLOAD, 0x0010, 3, NULL, 0, DFU_TIMEOUT); |
@@ -313,14 +305,13 @@ void dfu_m3_m6(char *file1, char *file2) | |||
313 | init_img(&img1, file1, &attr1); | 305 | init_img(&img1, file1, &attr1); |
314 | init_img(&img2, file2, &attr2); | 306 | init_img(&img2, file2, &attr2); |
315 | 307 | ||
316 | device = usb_dev_open(USB_VID_SAMSUNG, USB_PID_M6); | 308 | device = usb_dev_open(USB_VID_SAMSUNG, USB_PID_M3_M6); |
317 | // usb_mimic_windows(); | 309 | // usb_mimic_windows(); |
318 | get_cpu(device); | 310 | get_cpu(device); |
319 | get_cpu(device); | 311 | get_cpu(device); |
320 | send_file(device, &img1); | 312 | send_file(device, &img1); |
321 | 313 | ||
322 | printf("Wait a sec (literally)..."); | 314 | printf("Wait a sec (literally)..."); |
323 | fflush(stdout); | ||
324 | sleep(1); | 315 | sleep(1); |
325 | printf(" OK\n"); | 316 | printf(" OK\n"); |
326 | 317 | ||
@@ -366,7 +357,6 @@ void dfu_m6sl(char *file1, char *file2) | |||
366 | send_file(device, &img1); | 357 | send_file(device, &img1); |
367 | 358 | ||
368 | printf("Wait a sec (literally)..."); | 359 | printf("Wait a sec (literally)..."); |
369 | fflush(stdout); | ||
370 | sleep(1); | 360 | sleep(1); |
371 | printf(" OK\n"); | 361 | printf(" OK\n"); |
372 | usb_dev_close(device); | 362 | usb_dev_close(device); |
@@ -385,6 +375,8 @@ int main(int argc, char **argv) | |||
385 | if (argc != 4) | 375 | if (argc != 4) |
386 | usage(); | 376 | usage(); |
387 | 377 | ||
378 | setvbuf(stdout, NULL, _IONBF, 0); | ||
379 | |||
388 | if (!strcmp(argv[1], "m3")) | 380 | if (!strcmp(argv[1], "m3")) |
389 | dfu_m3_m6(argv[2], argv[3]); | 381 | dfu_m3_m6(argv[2], argv[3]); |
390 | else if (!strcmp(argv[1], "m6")) | 382 | else if (!strcmp(argv[1], "m6")) |