Python-based toolchain to unlock MediaTek Android tablet bootloader, extract stock firmware, flash custom TWRP recovery, and apply Magisk root
- Project Overview
- Prerequisites
- Installation & Setup
- Usage
- Resources & References
- Workflow Diagram
- Scripts
- License
Government-issued MediaTek tablets often ship with locked bootloaders, restricted firmware, and disabled developer options. This proof-of-concept demonstrates how to:
- Communicate with the MTK BootROM via Python
- Unlock and dump stock firmware partitions
- Compile and flash a custom TWRP recovery
- Apply a Magisk root patch
- Host OS: Windows 11 (tested)
- Python: 3.9.x (avoid 3.10+)
- Tools:
adb
,fastboot
,pyusb
(Docker optional)
- MediaTek USB VCOM Drivers: Download
- MediaTek Windows USB Drivers: mtkusbdriver.com
- MediaTek CDC Drivers: Download
- USBDK (alternative framework): AndroidFileHost
-
Install USB Drivers (from the links above).
-
Install Python 3.9.x, ensuring Add Python to PATH is checked during setup.
-
Verify pip:
pip --version
-
Download MTKClient:
- Clone or download bkerler/mtkclient
- Extract the folder to a known location
-
Open Command Prompt in the MTKClient folder:
- In File Explorer, navigate to the MTKClient folder
- Type
cmd
in the address bar and press Enter
-
Install Python dependencies:
pip install -r requirements.txt
-
Power off your tablet completely.
-
Open Command Prompt inside the MTKClient folder.
-
Run the following command to erase key partitions:
python mtk.py e metadata,userdata,md_udc
⚠️ Warning: This command wipes all data on the device, including apps, user files, and settings. Make sure to back up anything important before proceeding. -
Enter BROM mode:
- Press and hold Volume Up + Volume Down + Power
- While holding, connect the USB cable
- The device should be automatically detected
-
Unlock the secure config for rooting:
python mtk.py da seccfg unlock
Run the extraction script to dump system.img
, boot.img
, and other partitions:
scripts\extract_rom.bat
-
Build and patch recovery with Magisk:
scripts\patch_recovery.bat
-
Flash the custom recovery and reboot:
fastboot flash recovery recovery\custom-recovery.img fastboot reboot
- Hovatek MTK Unlock Guide (command reference): https://www.hovatek.com/forum/thread-40300.html
- MTKClient (Python MediaTek tool): https://github.com/bkerler/mtkclient
- Universal Android Debloater (post-root cleanup): https://github.com/0x192/universal-android-debloater
scripts/mtk.py
— Python tool for BootROM communication and partition unlockingscripts/extract_rom.bat
— Batch script to dumpsystem.img
,boot.img
, and other partitions viaadb
/fastboot
This project is licensed under the MIT License. See LICENSE for details.