[Miscellaneous Android Development] Inside 4ndroid:
Root & TWRP Lenovo Tab 2 A8-50F (MT8161)

Ok so this is a in depth tutorial on obtaining root and installing twrp for the device in the title. Anything in "quotes" eg, type in cmd "adb devices" quotes should be ignored. This guide is for those who know what root is and know there way around windows and Linux. If you did something wrong i am not liable and maybe you should have read things before trying.

EDIT: for those of you who want to root in one or two clicks i have added support for this device in the ZEUS TOOLKIT wich will root without installing custom recovery.. LINK >> http://xdaforums.com/showthread.php?t=2644166

REQUIREMENTS/DOWNLOADS:

-Windows PC & Linux (Ubuntu. virtual box would be fine although i have my pc dual booting both os's)

-Driver Signing Disabled on Windows 7 and above

-Device Drivers

-SpFlash Tool (including scatter file)

-Adb Tools

-TWRP + SuperSU Files

-Insecure Boot.img

LINK FOR ALL REQUIRED FILES >>

DOWNLOAD

<< DOWNLAOAD AND EXTRACT TO DESKTOP

Downlaod all of the above and extract/move everything to a folder which for this guide i will assume will be called ROOT on your DESKTOP

SOME READING:

The Lenovo Tab 2 A8-50F is a rather locked down device with the ability to reflash the stock rom on every reboot if required. In this guide you can only do things in a specific order to be able to get it rooted and stop the stock recovery reflashing. It took me a few times of (soft)bricking my device before i could get it sorted to a stable rooted system with twrp installed. TWRP recovery was not built from source by me personally (it was obtained from a russian website) although i have had to modify the TWRP image as it was boot looping but its sorted and working now. So roughly this is how things are going to go, we will use SpFlash tool to readback the system partition, then use linux to modify a file in the system.img the use SpFlashtool to refalsh the modified system.img. Then we are going to unlock the bootloader and then flash an insecure boot.img along with twrp and then root using chainfire's latest binarys.

THE GUIDE:

STEP 1 - installing the drivers

For this i will assume you you have already got adb driver installed if not please google it i personally used googles generic adb driver.

Please make sure you have disabled driver signing for windows "GO HERE". Now open device manager and right click on your pc's name at the top of the list and select add legacy hardware > click next > check "install the hardaware that i manually select from a list (advance)" and click next > highlight "show all devices" and click next > click "have Disk" > click "browse" > browse to the desktop\root\MTK Drivers all windows\ and choose the folder to match your windows installation and then choose the 32bit or 64bit driver file depending on your windows install > click open > click ok > highlight "MTK USB PORT" > click next > click next > if a warning pops up click install anyway > click finish. Your drivers are now installed for spflash tool to recognise your device.

STEP 2 - backing up system partition

Make sure your device is truned off and disconnected from your computer. Open SPFlash Tool form "Desktop\ROOT\SPFlash_tool\flash_tool.exe" > click "scatter-loading button > browse to "Desktop\Root\ and open MT6735_Android_scatter.txt > click the readback tab > click add > double click the entry which is now listed >browse to "Desktop\Root" and in the filename box type "system.img" > click save > check "HEX" > for region select EMMC_USER > for start address type "0xb000000" > for length type "0x74000000" > click ok > click readback. now with your device turned off connect the usb and the SPFlash tool will begin to backup your system partition to "Desktop\Root\system.img" wait until its finished and continue to the next step.

STEP 3 - editing the system.img

Now we have the system.img transfer it via usb (or whatever means) to your ubuntu machine place system.img in your ~/Home/ folder eg. ~/Home/System.img now open a terminal by pressing CTRL + T > type "mkdir output" press enter > now type "sudo mount -t ext4 -o loop system.img output/" press enter > type your sudo password > press enter > type " cd output" press enter > type "sudo mv recovery-from-boot.p recovery-from-boot.bak" press enter > type "cd" press enter > type "sudo umount output/" press enter. The system.img has now been modified and can be transfered back to windows. Goto next step.

STEP 4 - unlocking bootloader

With device booted to android and usb debugging enabled open cmd prompt and type "cd C:\Users\robert\Desktop\ROOT\adb" > (replace "robert" with your username) press enter > type "adb reboot bootloader". Your device will now reboot into fastboot mode when it displays "fastboot mode in the bottom left of the screen type into cmd "fastboot oem unlock" > press enter > screen will change and ask you to confirm do this by pressing vol+ > wait and when a screen with three boot options appears DO NOTHING and go to next step.

STEP 5 - flashing insecure boot.img

Now you should have the ability to flash the boot. Type into cmd "fastboot flash boot boot.img" the device will let you know it is done and when it is done flashing just type into cmd "fastboot reboot" and let the device fully boot and goto the next step.

STEP 6 - flashing modified system.img

now open SPFlash tool again it should have remembered the scatterfile if not reload the scatter file. In the main window of the download tab make sure ONLY system is checked then in the location colum click the space in line with system and browse to your modified system.img and click open. At this point before doing anything make sure your device is turned off and not connected to the computer in any way. Now click Download in SPFlash tool then connect your device via usb while turned off and the tool will begin flashing the system.img wait until it is finished and a green tick appears in flash tool and if your device does not boot automatically then unplug it and reboot it wait until it fully rebooted and goto next step. You can close flash tool for now.

STEP 7 - flashing TWRP recovery

with your devfice now booted with a custom boot and system image open cmd prompt and type "cd C:\Users\robert\Desktop\ROOT\adb" > (replace "robert" with your username) press enter > type "adb reboot bootloader" > press enter your device will boot into fastboot mode again when it has type "fastboot flash recovery recovery.img" > press enter > when its done type "fastboot reboot" > press enter now wait for the device to fully boot and goto next step

STEP 8 - flashing Supersu by Chainfire

Now your device has rebooted it will be missing the super user app and all binary's so open file explorer on your computer and copy the SuperSU-v2.46.zip from the ROOT folder on the desktop to the download folder on your device after doing that open cmd prompt and type "cd C:\Users\robert\Desktop\ROOT\adb" > (replace "robert" with your username) press enter > type "adb reboot recovery" > press enter. Your device will now reboot into TWRP recovery check the little box and swipe the arrow at the bottom to continue now touch install > touch Download > touch SuperSU-v2.46.zip and finally swipe to install. when it is finished reboot. Hey presto one rooted device with a fully working twrp. reboot and download busybox from play store and install as some programs like system app remover need some binarys from busybox.

After following the above steps you will have a fully rooted device wich can be backed up via twrp and flashed via twrp. now i have figured this out, i think its someone elses turn to build a rom for it :) preferably Cyanogenmod :P Thanks for reading this guide and all the best luck with your new rooted device. please remember to click thanks.

​