diff options
-rw-r--r-- | utils/meizu_dfu/README | 3 | ||||
-rw-r--r-- | utils/meizu_dfu/meizu_dfu.c | 104 |
2 files changed, 60 insertions, 47 deletions
diff --git a/utils/meizu_dfu/README b/utils/meizu_dfu/README index 027e82d890..c96870b369 100644 --- a/utils/meizu_dfu/README +++ b/utils/meizu_dfu/README | |||
@@ -1,10 +1,9 @@ | |||
1 | |||
2 | Meizu DFU tool for Linux | 1 | Meizu DFU tool for Linux |
3 | 2 | ||
4 | This tool can restore the firmware on M3, M6 SP, M6 TP and M6 SL. | 3 | This tool can restore the firmware on M3, M6 SP, M6 TP and M6 SL. |
4 | It can also run a single provided file from RAM. | ||
5 | 5 | ||
6 | Notes: | 6 | Notes: |
7 | 1. SST39VF800.dfu is taken from the official dfu tool provided by Meizu. | 7 | 1. SST39VF800.dfu is taken from the official dfu tool provided by Meizu. |
8 | 2. updateNAND_BE_070831.dfu is taken from the unofficial dfu tool for M6 SL. | 8 | 2. updateNAND_BE_070831.dfu is taken from the unofficial dfu tool for M6 SL. |
9 | 3. To compile, just run `make'. | 9 | 3. To compile, just run `make'. |
10 | |||
diff --git a/utils/meizu_dfu/meizu_dfu.c b/utils/meizu_dfu/meizu_dfu.c index 1658c4d1e8..36f38478bc 100644 --- a/utils/meizu_dfu/meizu_dfu.c +++ b/utils/meizu_dfu/meizu_dfu.c | |||
@@ -43,9 +43,9 @@ | |||
43 | 43 | ||
44 | void usage() | 44 | void usage() |
45 | { | 45 | { |
46 | fprintf(stderr, "usage: meizu_dfu m3 <SST39VF800.dfu> <M3.EBN>\n"); | 46 | fprintf(stderr, "usage: meizu_dfu m3 [SST39VF800.dfu] <M3.EBN>\n"); |
47 | fprintf(stderr, " meizu_dfu m6 <SST39VF800.dfu> <M6.EBN>\n"); | 47 | fprintf(stderr, " meizu_dfu m6 [SST39VF800.dfu] <M6.EBN>\n"); |
48 | fprintf(stderr, " meizu_dfu m6sl <updateNAND_BE_070831.dfu> <M6SL.EBN>\n"); | 48 | fprintf(stderr, " meizu_dfu m6sl [updateNAND_BE_070831.dfu] <M6SL.EBN>\n"); |
49 | exit(1); | 49 | exit(1); |
50 | } | 50 | } |
51 | 51 | ||
@@ -328,18 +328,21 @@ void dfu_m3_m6(char *file1, char *file2) | |||
328 | memcpy(attr1.suf_sig, "RON", 3); | 328 | memcpy(attr1.suf_sig, "RON", 3); |
329 | attr1.suf_len = 0x10; | 329 | attr1.suf_len = 0x10; |
330 | 330 | ||
331 | attr2.delay = 1000; | ||
332 | attr2.pre_off = 0x20; | ||
333 | attr2.pre_sig = 0x44465543; | ||
334 | attr2.suf_dev = 0x0100; | ||
335 | attr2.suf_prod = 0x0140; | ||
336 | attr2.suf_ven = 0x0419; | ||
337 | attr2.suf_dfu = 0x0100; | ||
338 | memcpy(attr2.suf_sig, "UFD", 3); | ||
339 | attr2.suf_len = 0x10; | ||
340 | |||
341 | init_img(&img1, file1, &attr1); | 331 | init_img(&img1, file1, &attr1); |
342 | init_img(&img2, file2, &attr2); | 332 | |
333 | if (file2) { | ||
334 | attr2.delay = 1000; | ||
335 | attr2.pre_off = 0x20; | ||
336 | attr2.pre_sig = 0x44465543; | ||
337 | attr2.suf_dev = 0x0100; | ||
338 | attr2.suf_prod = 0x0140; | ||
339 | attr2.suf_ven = 0x0419; | ||
340 | attr2.suf_dfu = 0x0100; | ||
341 | memcpy(attr2.suf_sig, "UFD", 3); | ||
342 | attr2.suf_len = 0x10; | ||
343 | |||
344 | init_img(&img2, file2, &attr2); | ||
345 | } | ||
343 | 346 | ||
344 | device = usb_dev_open(USB_VID_SAMSUNG, USB_PID_M3_M6); | 347 | device = usb_dev_open(USB_VID_SAMSUNG, USB_PID_M3_M6); |
345 | // usb_mimic_windows(); | 348 | // usb_mimic_windows(); |
@@ -347,14 +350,17 @@ void dfu_m3_m6(char *file1, char *file2) | |||
347 | get_cpu(device); | 350 | get_cpu(device); |
348 | send_file(device, &img1); | 351 | send_file(device, &img1); |
349 | 352 | ||
350 | printf("Wait a sec (literally)..."); | 353 | if (file2) { |
351 | sleep(1); | 354 | printf("Wait a sec (literally)..."); |
352 | printf(" OK\n"); | 355 | sleep(1); |
356 | printf(" OK\n"); | ||
357 | |||
358 | clear_status(device); | ||
359 | get_cpu(device); | ||
360 | send_file(device, &img2); | ||
361 | dfu_detach(device); | ||
362 | } | ||
353 | 363 | ||
354 | clear_status(device); | ||
355 | get_cpu(device); | ||
356 | send_file(device, &img2); | ||
357 | dfu_detach(device); | ||
358 | usb_dev_close(device); | 364 | usb_dev_close(device); |
359 | } | 365 | } |
360 | 366 | ||
@@ -374,51 +380,59 @@ void dfu_m6sl(char *file1, char *file2) | |||
374 | memcpy(attr1.suf_sig, "UFD", 3); | 380 | memcpy(attr1.suf_sig, "UFD", 3); |
375 | attr1.suf_len = 0x10; | 381 | attr1.suf_len = 0x10; |
376 | 382 | ||
377 | attr2.delay = 1000; | ||
378 | attr2.pre_off = 0x20; | ||
379 | attr2.pre_sig = 0x44465543; | ||
380 | attr2.suf_dev = 0x0100; | ||
381 | attr2.suf_prod = 0x0140; | ||
382 | attr2.suf_ven = 0x0419; | ||
383 | attr2.suf_dfu = 0x0100; | ||
384 | memcpy(attr2.suf_sig, "UFD", 3); | ||
385 | attr2.suf_len = 0x10; | ||
386 | |||
387 | init_img(&img1, file1, &attr1); | 383 | init_img(&img1, file1, &attr1); |
388 | init_img(&img2, file2, &attr2); | 384 | |
385 | if (file2) { | ||
386 | attr2.delay = 1000; | ||
387 | attr2.pre_off = 0x20; | ||
388 | attr2.pre_sig = 0x44465543; | ||
389 | attr2.suf_dev = 0x0100; | ||
390 | attr2.suf_prod = 0x0140; | ||
391 | attr2.suf_ven = 0x0419; | ||
392 | attr2.suf_dfu = 0x0100; | ||
393 | memcpy(attr2.suf_sig, "UFD", 3); | ||
394 | attr2.suf_len = 0x10; | ||
395 | |||
396 | init_img(&img2, file2, &attr2); | ||
397 | } | ||
389 | 398 | ||
390 | device = usb_dev_open(USB_VID_SAMSUNG, USB_PID_M6SL); | 399 | device = usb_dev_open(USB_VID_SAMSUNG, USB_PID_M6SL); |
391 | get_cpu(device); | 400 | get_cpu(device); |
392 | get_cpu(device); | 401 | get_cpu(device); |
393 | send_file(device, &img1); | 402 | send_file(device, &img1); |
394 | 403 | ||
395 | printf("Wait a sec (literally)..."); | 404 | if (file2) { |
396 | sleep(1); | 405 | printf("Wait a sec (literally)..."); |
397 | printf(" OK\n"); | 406 | sleep(1); |
398 | usb_dev_close(device); | 407 | printf(" OK\n"); |
408 | usb_dev_close(device); | ||
409 | |||
410 | device = usb_dev_open(USB_VID_SAMSUNG, USB_PID_M6SL); | ||
411 | get_cpu(device); | ||
412 | get_cpu(device); | ||
413 | send_file(device, &img2); | ||
414 | dfu_detach(device); | ||
415 | } | ||
399 | 416 | ||
400 | device = usb_dev_open(USB_VID_SAMSUNG, USB_PID_M6SL); | ||
401 | get_cpu(device); | ||
402 | get_cpu(device); | ||
403 | send_file(device, &img2); | ||
404 | dfu_detach(device); | ||
405 | usb_dev_close(device); | 417 | usb_dev_close(device); |
406 | } | 418 | } |
407 | 419 | ||
408 | 420 | ||
409 | int main(int argc, char **argv) | 421 | int main(int argc, char **argv) |
410 | { | 422 | { |
411 | if (argc != 4) | 423 | if (argc < 3 || argc > 4) |
412 | usage(); | 424 | usage(); |
413 | 425 | ||
414 | setvbuf(stdout, NULL, _IONBF, 0); | 426 | setvbuf(stdout, NULL, _IONBF, 0); |
415 | 427 | ||
428 | char *second_file = (argc == 4) ? argv[3] : NULL; | ||
429 | |||
416 | if (!strcmp(argv[1], "m3")) | 430 | if (!strcmp(argv[1], "m3")) |
417 | dfu_m3_m6(argv[2], argv[3]); | 431 | dfu_m3_m6(argv[2], second_file); |
418 | else if (!strcmp(argv[1], "m6")) | 432 | else if (!strcmp(argv[1], "m6")) |
419 | dfu_m3_m6(argv[2], argv[3]); | 433 | dfu_m3_m6(argv[2], second_file); |
420 | else if (!strcmp(argv[1], "m6sl")) | 434 | else if (!strcmp(argv[1], "m6sl")) |
421 | dfu_m6sl(argv[2], argv[3]); | 435 | dfu_m6sl(argv[2], second_file); |
422 | else | 436 | else |
423 | usage(); | 437 | usage(); |
424 | 438 | ||