MTK-bypass / bypass_utility

MIT License
488 stars 118 forks source link

usb.core.USBError: [Errno 5] Input/Output Error with disconnected battery #63

Open saper opened 2 years ago

saper commented 2 years ago

Running bypass utility commit 87a2541820ad22e7cc00d0bd51a3a8faff6c21ef and exploits_collection at https://github.com/MTK-bypass/exploits_collection/commit/5efcfbbc9c0c51b088c91965c5bbd7417821a995

Because sometimes trying to flash the device (Xiaomi Redmi 9 aka lancelot) in the unusable state (USB device does not get recognized at all), I have tried to disconnect the internal battery.

Without battery, the python tool behaves as follows:

(venv) PS D:\mtk\bypass_utility> python .\main.py
[2021-11-11 02:37:20.201729] Waiting for device
[2021-11-11 02:37:35.653905] Found device = 0e8d:0003

[2021-11-11 02:37:36.444424] Device hw code: 0x707
[2021-11-11 02:37:36.492641] Device hw sub code: 0x8a00
[2021-11-11 02:37:36.515264] Device hw version: 0xca00
[2021-11-11 02:37:36.530893] Device sw version: 0x0
[2021-11-11 02:37:36.546514] Device secure boot: True
[2021-11-11 02:37:36.562134] Device serial link authorization: True
[2021-11-11 02:37:36.577761] Device download agent authorization: True

[2021-11-11 02:37:36.624635] Disabling watchdog timer
Traceback (most recent call last):
  File "D:\mtk\bypass_utility\main.py", line 237, in <module>
    main()
  File "D:\mtk\bypass_utility\main.py", line 49, in main
    device.write32(config.watchdog_address, 0x22000064)
  File "D:\mtk\bypass_utility\src\device.py", line 234, in write32
    self.echo(0xD4)
  File "D:\mtk\bypass_utility\src\device.py", line 175, in echo
    self.write(words, size)
  File "D:\mtk\bypass_utility\src\device.py", line 226, in write
    self.ep_out.write(data[offset:][:self.ep_out.wMaxPacketSize if len(data) - offset > self.ep_out.wMaxPacketSize else len(data) - offset], self.timeout * 1000)
  File "D:\mtk\venv\lib\site-packages\usb\core.py", line 408, in write
    return self.device.write(self, data, timeout)
  File "D:\mtk\venv\lib\site-packages\usb\core.py", line 989, in write
    return fn(
  File "D:\mtk\venv\lib\site-packages\usb\backend\libusb1.py", line 837, in bulk_write
    return self.__write(self.lib.libusb_bulk_transfer,
  File "D:\mtk\venv\lib\site-packages\usb\backend\libusb1.py", line 938, in __write
    _check(retval)
  File "D:\mtk\venv\lib\site-packages\usb\backend\libusb1.py", line 604, in _check
    raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 5] Input/Output Error

The device appears for some time as the MTK virtual COM port but after error 5 the device manager is flashing few times.

With a battery I sometimes get the exploit to work (but reading the flash does not).

Any way to get it working without battery maybe?