sunnuntai 31. joulukuuta 2017

Rooting LG Leon with Android 6.0

Disclaimer: This post is for information purposes only. It is not a guide but a log of what I did to root the phone. Rooting may result in loss of data or brick your device, everything is done at your own risk. I'm not a developer, I do not know the details of how rooting works, and I cannot help if something goes wrong during the process.

Introduction

I have a LG Leon phone, which is a low-end Android phone. It has limited storage space and also other limitations, like not being able to store applications on SD card. It constantly runs out of storage space so I wanted to root the device to be able to delete non important stock apps and also to do other things, like maybe move apps from internal storage to SD card.
The phone model is LG-H340n, software versions Android 6.0, V20a-EUR-XX  .

Rooting process

I found a forum thread describing the process for this phone and Android version (post here). Other guides were for earlier Android versions or using Kingroot. I've heard some bad words about Kingroot so I didn't want to use that, this new guide was with TWRP and SuperSU which were familiar to me. This process is a copy of the guide with some changes I needed to do to get it to work. Thanks to users hokutojm and Wolftein for the process.

Prerequirements

  1. Back'd-up everything, since failing the process may result in factory result or bricked device
  2. Enabled developer mode by tapping Settings -> General -> About phone -> Software Info -> Build number about 8 times. 
  3. Now in Settings -> General -> Developer options checked Enable OEM unlock and USB debugging
  4. Connected the phone to computer with USB cable, then tapped the notification for more USB options. From the USB PC connection screen selected the 3 dot menu and Install PC drivers. This made the phone to show up as a disc drive in Windows My Computer. Double clicking on that installed the LG USB drivers.
  5. Python is needed, I had 2.7 already installed so I used that and it worked.
  6. Downloaded LGLAF python scripts and unzipped them to C:\LG\. I had to modify the lglaf.py script according to this bug report to make it work, otherwise it would hang on read. I also replaced name.endswith('ANDNETDIAG1'): with name.endswith('DIAG1'): in lglaf.py.
  7. Downloaded TWRP recovery with the correct partition size (Recovery.bin wiped out + TWRP 3.1.0). I used this file since according to the posts it works better than using the stock TWRP binary from the site or from the download site. Put the img file in the same folder where lglaf was unzipped.
  8. Downloaded Custom Android Bootloader, more info in this thread. Put the aboot.bin to same folder where lglaf was unzipped.
  9. Downloaded latest SuperSU and copied the zip file to the root folder of an SD card. I did not use the same SD card which was used for backup just to be sure that the data was safe. Put the SD card to the phone.

 

 Dangerous parts

  1. Turned off the phone. Then while pressing the Volume up button connected the phone to PC with USB cable. Kept the Volume up pressed until Firmware Update screen showed up.
  2. Now in Windows' Command prompt (cmd) browsed to where lglaf was unzipped.
  3. First I tried running
    python partitions.py --debug –list
    This resulted in a long list of partition names and offsets, which indicated that the communication was working properly.
  4. Run following commands to dump the original partitions:
    python partitions.py --dump aboot.old aboot
    python partitions.py --dump recovery.old recovery
    Commands resulted in the script giving this kind of information on success:
    2017-12-30 22:15:26,241 partitions: INFO: Wrote 2096640 bytes to aboot.old
  5. Replace the partitions with the custom ones:
    python partitions.py --wipe recovery
    python partitions.py --restore twrp-3.1.0-0-c50.img recovery
    python partitions.py --wipe aboot
    python partitions.py --restore aboot.bin aboot
  6. Turned off the phone by running
     python lglaf.py --debug -c "!CTRL POFF"
    and then disconnecting the USB cable.
  7. Next step was to enter download mode again. It was VERY IMPORTANT to PREVENT THE PHONE FROM BOOTING. If it rebooted and started android, all the changes were reverted and continuing wiped the phone. This happened to me. So now back to download mode by pressing Volume up and connecting USB cable.
  8. Run
    python partitions.py --dump recovery.new recovery
    to dump the newly flashed recovery partition.
  9. Compared the recovery image the the flashed on with fc /b recovery.new twrp-3.1.0-0-c50.img The files must match, otherwise the flashing failed and continuing would result in factory reset. fc displayed
    Comparing files recovery.new and TWRP-3.1.0-0-C50.IMG
    FC: TWRP-3.1.0-0-C50.IMG longer than recovery.new

    which indicates that files are identical, except for length (I don't know why the length is different)
  10. Again turn off by running following command and disconnecting USB cable
    lglaf.py --debug -c "!CTRL POFF"
  11. Next up was booting into factory reset menu, failing this would revert all changes again. Factory reset menu was reached by powering up pressing Volume down and power button, and as soon as LG logo appeared, released the buttons and re-pressed them again until menu was displayed.
  12. In the menu factory reset was selected and confirmed, but instead of reset the TWRP would boot up.
  13. In TWRP I followed this guide to install SuperSU:
    1. Selected Allow modifications
    2. In TWRP ->  Advanced -> Terminal wrote the following command:
      echo "SYSTEMLESS=true" > /data/.supersu
    3.  In TWRP -> Advanced -> File manager checked that there was indeed .supersu file in /data/
    4. Installed SuperSU from memory card with TWRP -> Install and browsing to the external SD and selected the zip file. Confirmed flashing, wiped cache/dalvik and then rebooted. I opted not to install the applications, but I don't quite know what those were anyways...
  14. After the phone rebooted, I was root! Now just to restore backups since I first failed the procedure...

Ei kommentteja:

Lähetä kommentti