Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MTK Bootseq: enter alternative boot modes in MediaTek-based smartphones
#!/usr/bin/env python3
# Simple script to enter the necessary boot mode in the MT6572-based (etc) phones
# Depends on pyserial, otherwise fully cross-platform
# Usage: python3 mtk-bootseq.py [MODECMD] [port]
# e.g. python3 mtk-bootseq.py FASTBOOT /dev/tty.usbmodem14200
# and then connect the cable and repeatedly short-press the power on key
# Supported commands depend on the device and its preloader. Here's the list for Sigma S3500 sKai:
# FASTBOOT enters fastboot mode
# METAMETA enters MAUI META mode
# FACTFACT enters (Chinese) factory menu
# FACTORYM enters ATE Signaling Test
# ADVEMETA does normal boot (probably something else as well)
import sys
import time
from serial import Serial
BOOTSEQ = bytes(sys.argv[1], "ascii")
DEVICE = sys.argv[2]
CONFIRM = b"READY" + BOOTSEQ[:-4:-1]
while True:
try:
s = Serial(DEVICE, 115200)
sys.stdout.write("\n")
break
except OSError as e:
sys.stdout.write("."); sys.stdout.flush()
time.sleep(0.1)
while True:
s.write(BOOTSEQ)
resp = s.read(8)
print(resp)
if resp == CONFIRM:
break
print("Boot sequence sent")
@etmatrix

This comment has been minimized.

Copy link

@etmatrix etmatrix commented Oct 5, 2020

Thank you for share! It's works also on MT6739.
Now I can put in meta mode in linux and run ModemMeta on virtualbox windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment