-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow flashing all partitions with this tool
- Loading branch information
Showing
4 changed files
with
50 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python3.7 | ||
|
||
from adb.fastboot import FastbootCommands, FastbootRemoteFailure, FastbootStateMismatch, FastbootInvalidResponse | ||
from adb.adb_commands import AdbCommands | ||
from adb.usb_exceptions import * | ||
import time | ||
|
||
def info_cb(msg): | ||
if msg.header == b"FAIL": | ||
print(msg) | ||
raise RuntimeException("Flash Failed") | ||
print(msg) | ||
|
||
def progress_cb(current, total): | ||
print("flashing current img "+str(100*current/total)) | ||
|
||
def flash(parts): | ||
fdev = FastbootCommands() | ||
while True: | ||
try: | ||
fdev.ConnectDevice() | ||
break | ||
except DeviceNotFoundError: | ||
time.sleep(10) | ||
# For faster flashing we take advantage of "ultraflash" which lets you stream the image | ||
for partition, file in parts.items(): | ||
# File must be a filename, not a file() | ||
fdev._SimpleCommand(b'ultraflash', arg=partition, info_cb=info_cb, timeout_ms=0) | ||
fdev.Download(file, info_cb=info_cb, progress_callback=progress_cb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters