flash-edl: block host qcserial driver and remove sleep after Fastboot EDL kick
This commit is contained in:
+20
-18
@@ -110,12 +110,15 @@ def _fb_upgrade_lk2nd_and_edl(fb_dev):
|
||||
time.sleep(0.3)
|
||||
_fb_send_edl(new_fb)
|
||||
usb.util.dispose_resources(new_fb)
|
||||
time.sleep(1.0)
|
||||
return
|
||||
time.sleep(0.5)
|
||||
|
||||
|
||||
_fb_edl_kicked = False
|
||||
|
||||
|
||||
def try_kick_into_edl():
|
||||
global _fb_edl_kicked
|
||||
try:
|
||||
res = subprocess.run(
|
||||
["adb", "get-state"],
|
||||
@@ -127,7 +130,6 @@ def try_kick_into_edl():
|
||||
if res.returncode == 0 and "device" in res.stdout:
|
||||
print("[*] Detected device in ADB mode. Sending 'adb reboot edl'...")
|
||||
subprocess.run(["adb", "reboot", "edl"], timeout=5)
|
||||
time.sleep(1)
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
@@ -136,13 +138,13 @@ def try_kick_into_edl():
|
||||
try:
|
||||
fb_dev = usb.core.find(idVendor=0x18D1, idProduct=0xD00D)
|
||||
if fb_dev is not None:
|
||||
print("[*] Detected device in Fastboot mode (18d1:d00d). Sending 'oem reboot-edl'...")
|
||||
_fb_send_edl(fb_dev)
|
||||
usb.util.dispose_resources(fb_dev)
|
||||
time.sleep(1.5)
|
||||
fb_still = usb.core.find(idVendor=0x18D1, idProduct=0xD00D)
|
||||
if fb_still is not None:
|
||||
_fb_upgrade_lk2nd_and_edl(fb_still)
|
||||
if not _fb_edl_kicked:
|
||||
_fb_edl_kicked = True
|
||||
print("[*] Detected device in Fastboot mode (18d1:d00d). Sending 'oem reboot-edl'...")
|
||||
_fb_send_edl(fb_dev)
|
||||
usb.util.dispose_resources(fb_dev)
|
||||
else:
|
||||
_fb_upgrade_lk2nd_and_edl(fb_dev)
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
@@ -160,15 +162,12 @@ def try_kick_into_edl():
|
||||
rc = subprocess.run(["fastboot", "oem", "reboot-edl"], timeout=5)
|
||||
if rc.returncode != 0:
|
||||
subprocess.run(["fastboot", "oem", "edl"], timeout=5)
|
||||
time.sleep(1)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def wait_for_edl_usb(vid, pid, device_label, timeout_sec=0):
|
||||
cdc = usb_class(vid=vid, pid=pid)
|
||||
try_kick_into_edl()
|
||||
|
||||
print(
|
||||
f"[*] Waiting for {device_label} in EDL mode "
|
||||
f"(USB {vid:04x}:{pid:04x} Qualcomm QDLoader 9008)..."
|
||||
@@ -179,6 +178,8 @@ def wait_for_edl_usb(vid, pid, device_label, timeout_sec=0):
|
||||
print(" 3) Plug in via an EDL deep-flash cable")
|
||||
print(" 4) Run 'adb reboot edl' or 'fastboot oem reboot-edl'")
|
||||
|
||||
try_kick_into_edl()
|
||||
|
||||
start_ts = time.time()
|
||||
dots = 0
|
||||
while not cdc.connected:
|
||||
@@ -191,7 +192,7 @@ def wait_for_edl_usb(vid, pid, device_label, timeout_sec=0):
|
||||
"Please run via sudo (e.g. sudo ./flash-edl.sh)."
|
||||
)
|
||||
sys.exit(1)
|
||||
time.sleep(0.5)
|
||||
time.sleep(0.05)
|
||||
continue
|
||||
|
||||
if cdc.connected:
|
||||
@@ -206,15 +207,16 @@ def wait_for_edl_usb(vid, pid, device_label, timeout_sec=0):
|
||||
print(f"[!] Timed out after {timeout_sec} seconds waiting for EDL device.")
|
||||
sys.exit(1)
|
||||
|
||||
if dots > 0 and dots % 10 == 0:
|
||||
if dots > 0 and dots % 100 == 0:
|
||||
try_kick_into_edl()
|
||||
|
||||
sys.stdout.write(".")
|
||||
sys.stdout.flush()
|
||||
if dots % 20 == 0:
|
||||
sys.stdout.write(".")
|
||||
sys.stdout.flush()
|
||||
dots += 1
|
||||
if dots % 40 == 0:
|
||||
if dots % 800 == 0:
|
||||
sys.stdout.write("\n")
|
||||
time.sleep(1)
|
||||
time.sleep(0.05)
|
||||
|
||||
return cdc
|
||||
|
||||
|
||||
Reference in New Issue
Block a user