Closed techyminati closed 2 months ago
owing 2 changed files with 118 additions and 48 deletions.
 Split Unified
  79
mtkclient/Library/mtk_dalegacy.py
@@ -14,6 +14,36 @@
from mtkclient.config.payloads import pathconfig
from mtkclient.Library.legacy_ext import legacyext
from mtkclient.config.mtk_config import Mtk_Config
from queue import Queue
from threading import Thread, Event

rq = Queue()
wq = Queue()

def writedata(filename,rq,event):
 pos=0
 with open(filename, "wb") as wf:
 while True:
 if event.is_set():
 break
 data = rq.get()
 pos+=len(data)
 wf.write(data)
 rq.task_done()

def readdata(filename,wq,pagesize,event):
 pos=0
 with open(filename, "rb") as rf:
 bytestoread=os.stat(filename).st_size
 while bytestoread>0:
 if event.is_set():
 break
 data = rf.read(pagesize)
 size = len(data)
 wq.put(data)
 pos += size
 bytestoread-=size
 wq.task_done()


class norinfo:
@@ -1097,8 +1127,8 @@ def upload(self):
 if speed[0] == 0: # 1 = USB High Speed, 2= USB Ultra high speed
 self.info("Reconnecting to preloader")
 self.set_usb_cmd()
 self.mtk.port.close(reset=False)
 time.sleep(1)
 self.mtk.port.close(reset=True)
 time.sleep(2)
 while not self.mtk.port.cdc.connect():
 self.info("Waiting for reconnection")
 time.sleep(0.5)
@@ -1173,7 +1203,7 @@ def check_usb_cmd(self):
 return None

 def set_usb_cmd(self):
 if self.usbwrite(self.Cmd.USB_SETUP_PORT): # 72
 if self.usbwrite(self.Cmd.USB_SETUP_PORT): # 70
 if self.usbwrite(b"\x01"): # USB_HIGH_SPEED
 res = self.usbread(1)
 if len(res) > 0:
@@ -1262,7 +1292,7 @@ def sdmmc_write_image(self, addr, length, filename, display=True):
 self.usbwrite(b"\x08") # EMMC_PART_USER
 self.usbwrite(pack(">Q", addr))
 self.usbwrite(pack(">Q", length))
 self.usbwrite(b"\x08") # index 8
 self.usbwrite(b"\x06") # index 8
 self.usbwrite(b"\x03")
 packetsize = unpack(">I", self.usbread(4))[0]
 ack = unpack(">B", self.usbread(1))[0]
@@ -1366,6 +1396,7 @@ def get_parttype(self, length, parttype):
 return length, parttype

 def readflash(self, addr, length, filename, parttype=None, display=True):
 global rq
 self.mtk.daloader.progress.clear()
 length, parttype = self.get_parttype(length, parttype)
 self.check_usb_cmd()
@@ -1409,24 +1440,28 @@ def readflash(self, addr, length, filename, parttype=None, display=True):
 if display:
 self.mtk.daloader.progress.show_progress("Read", 0, length, display)
 if filename != "":
 with open(filename, "wb") as wf:
 bytestoread = length
 while bytestoread > 0:
 size = bytestoread
 if bytestoread > packetsize:
 size = packetsize
 wf.write(self.usbread(size))
 bytestoread -= size
 checksum = unpack(">H", self.usbread(1) + self.usbread(1))[0]
 self.debug("Checksum: %04X" % checksum)
 self.usbwrite(self.Rsp.ACK)
 if length > bytestoread:
 rpos = length - bytestoread
 else:
 rpos = 0
 self.mtk.daloader.progress.show_progress("Read", rpos, length, display)
 self.mtk.daloader.progress.show_progress("Read", length, length, display)
 return True
 event = Event()
 worker = Thread(target=writedata, args=(filename, rq, event), daemon=True)
 worker.start()
 bytestoread = length
 while bytestoread > 0:
 size = bytestoread
 if bytestoread > packetsize:
 size = packetsize
 data=self.usbread(size)
 bytestoread -= len(data)
 rq.put(data)
 checksum = unpack(">H", self.usbread(1) + self.usbread(1))[0]
 self.debug("Checksum: %04X" % checksum)
 self.usbwrite(self.Rsp.ACK)
 if length > bytestoread:
 rpos = length - bytestoread
 else:
 rpos = 0
 self.mtk.daloader.progress.show_progress("Read", rpos, length, display)
 self.mtk.daloader.progress.show_pro
pip3 install -r requirements.txt ─╯ WARNING: The directory '/root/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag. Requirement already satisfied: wheel>=0.37.1 in /usr/lib/python3/dist-packages (from -r requirements.txt (line 1)) (0.37.1) Requirement already satisfied: pyusb>=1.2.1 in /usr/local/lib/python3.10/dist-packages/pyusb-1.2.1-py3.10.egg (from -r requirements.txt (line 2)) (1.2.1) Requirement already satisfied: pycryptodome>=3.15.0 in /usr/local/lib/python3.10/dist-packages/pycryptodome-3.16.0-py3.10-linux-aarch64.egg (from -r requirements.txt (line 3)) (3.16.0) Collecting pycryptodomex Downloading pycryptodomex-3.16.0-cp35-abi3-manylinux2014_aarch64.whl (2.1 MB) ━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 1.4 MB/s eta 0:00:00 Requirement already satisfied: colorama>=0.4.4 in /usr/local/lib/python3.10/dist-packages/colorama-0.4.6-py3.10.egg (from -r requirements.txt (line 5)) (0.4.6) Requirement already satisfied: usb>=0.0.83.dev0 in /usr/local/lib/python3.10/dist-packages/usb-0.0.83.dev0-py3.10.egg (from -r requirements.txt (line 6)) (0.0.83.dev0) ERROR: Could not find a version that satisfies the requirement shiboken6>=6.4.0.1 (from versions: none) ERROR: No matching distribution found for shiboken6>=6.4.0.1
pip3 install -r requirements.txt ─╯ WARNING: The directory '/root/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag. Requirement already satisfied: wheel>=0.37.1 in /usr/lib/python3/dist-packages (from -r requirements.txt (line 1)) (0.37.1) Requirement already satisfied: pyusb>=1.2.1 in /usr/local/lib/python3.10/dist-packages/pyusb-1.2.1-py3.10.egg (from -r requirements.txt (line 2)) (1.2.1) Requirement already satisfied: pycryptodome>=3.15.0 in /usr/local/lib/python3.10/dist-packages/pycryptodome-3.16.0-py3.10-linux-aarch64.egg (from -r requirements.txt (line 3)) (3.16.0) Collecting pycryptodomex Downloading pycryptodomex-3.16.0-cp35-abi3-manylinux2014_aarch64.whl (2.1 MB) ━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 1.4 MB/s eta 0:00:00 Requirement already satisfied: colorama>=0.4.4 in /usr/local/lib/python3.10/dist-packages/colorama-0.4.6-py3.10.egg (from -r requirements.txt (line 5)) (0.4.6) Requirement already satisfied: usb>=0.0.83.dev0 in /usr/local/lib/python3.10/dist-packages/usb-0.0.83.dev0-py3.10.egg (from -r requirements.txt (line 6)) (0.0.83.dev0) ERROR: Could not find a version that satisfies the requirement shiboken6>=6.4.0.1 (from versions: none) ERROR: No matching distribution found for shiboken6>=6.4.0.1
How to install this MTK tool
This step is wrong, why ❓
Stale issue message
Hi, I've realme 8 5G/Narzo 30 5G, the device is stuck in brom mode and i can see
OPLUS Preloader
in Device Manager, butmtk fails with following logs
Looks like realme/OPLUS has locked down brom completely on realmeUI4/ColorOS 13
The device uses MediaTek Dimensity 700 (MT6833) SoC, currently on stock Android T fw.
mtkclient used to work on Android R & S fw but it does not on T firmware now.
Would be huge help if you can look into that @bkerler . Thank you in advance