Rooting and ROMing Your Android Phone

A l33t haxxor, yesterday
This post is primarily for myself, as I always forget the exact order that is required when I want to root and install a new ROM on an Android phone. My recent experience flashing my old HTC made me have to relearn all this stuff.

The most common reason anyone flashes their phone is because the OEM (Samsung, Nokia, HTC, etc) has not released the latest version of Android, and has no plan to. So your older phone is stuck using Android 6.0 or whatever, and you'd like the new stuff.

First things first, you need to have a working phone. If there are hardware problems, flashing a new ROM won't fix them. Also, make sure your phone is unlocked, i.e. not locked to a single carrier. Many newer phones come unlocked, and so long as your phone is paid off, you can request your carrier to unlock it for you. Flashing your ROM will void your warranty, so if you brick your device it's all on you!

Also, you should make sure you know exactly which model phone you have. Often, the phone manufacturer will release different variants of the model- sometimes based on the geographical region, sometimes based on what carrier the phone was sold through. If you own a T-Mobile variant of a phone, for example, this might be slightly different than the Verizon version.

Software to Download

1. Download and install the Android platform tools on your computer.

2. Install device drivers for your phone. Most modern phones will install the drivers automatically when you plug it in. In the case of my HTC One M8, I installed the HTC Sync Manager software on Windows, which includes the drivers.

3. Download a custom recovery image. Recovery is a small platform that runs on your phone independently of your OS, and it allows servicing of the OS partitions. Your phone includes a recovery program from the OEM, but it may not be available to you or include all the features you want. Use TWRP if in doubt. Just download the recovery image that is appropriate for your device.

4. Download the custom ROM you want to install. How do you know which one you want? There are often several ROMs in active development for any particular phone. Go to https://forum.xda-developers.com/ and search for your specific device type, and then look in the subforum called Android Development. I recommend going with LineageOS, which brings the latest Android version and some nice features, without too much extra nonsense.

5. Download the correct version of the Google apps, depending on the ROM you want to install. Most of the time, the ROM developer will provide a link to the right package, but if not, go to OpenGApps.org and find the right one.

Preparing The Installation

You've installed the Android platform tools on your computer, as well as the device drivers. Plug in your phone to your computer and copy the ROM and GApps files to the internal storage. If you have an SD card in your phone, copy these two files there.

Now, put your phone into developer mode. Go to Settings > About Phone (if your phone is Android 7 or earlier) or Settings > System > About Phone. Tap the build number 7 times, and this will enable developer settings. Go to Settings > Developer Options and enable USB debugging. This allows your phone to be controlled via the Android platform tools you installed on your PC.

Copy the custom recovery image to the folder where the Android platform tools resides. On Windows, this folder is hidden from Windows Explorer, so bash this into the address bar: C:\users\\appdata\local\Android\Sdk\platform-tools. Make sure you see the program adb.exe and fastboot.exe in this folder. The custom recovery image may called be something like twrp-3.2.1-08.img. You can rename this file to just twrp.img, to make things easier. 

The final step before you can start is to learn how to boot your phone into HBoot, which is just a loading program that allows you to boot into other modes, including Fastboot, recovery, or the OS. On many phones, you start with the phone turned off, and you hold down the Volume Down button and press and hold the Power button. This starts the phone and immediately takes you to a screen that looks like this:

Once in HBoot, you can use the volume up and down buttons to scroll through the options, and select the one you want using the Power button. If you get to this screen and you just want to restart the phone without making any changes, you will select Fastboot and then Restart.

S-On

This section only applies primarily to older HTC phones. HTC decided that it wanted to prevent users from flashing new firmware or recovery programs, so they included a security feature that prevents this. Older HTC phones, such as the Incredible and Desire, can use a program called Unrevoked to set the phone into S-Off mode, which will allow flashing. Newer HTC devices like my One M8 must use a program called Sunshine, which costs $25. You download this program directly to your phone and run it there. There is a non-zero chance that these programs will either not work or brick your phone, so beware. Please check the XDA Forums for your device, and ask questions if you are unsure if you need to do this.

Installation

Now comes the exciting part. You understand that what you do may brick your phone and render it worthless. The frisson of danger is palpable!

I. Install Recovery

Open the folder where the Android platform tools was installed. You should see ADB.exe and Fastboot.exe in this folder. You've already moved your recovery image to this folder, so now you will open a command window and enter:

adb reboot bootloader

The phone will reboot to the bootloader. Now, enter the following command:

fastboot flash recovery twrp.img

Replace "twrp.img" with the name of the recovery image you downloaded. Finally:

fastboot reboot

This will restart the phone. If all goes according to plan, you should now have your custom recovery application loaded on the phone.

II. Install custom ROM and GApps

Unplug your phone from your computer, and boot into the HBoot menu. Use the volume keys to select Recovery, and press the Power button to select it. TWRP or ClockworkMod Recovery or whatever custom recovery program you installed will load.

Follow the instructions for your recovery program to install the ROM and GApps on your phone. Do NOT reboot the phone between installing the ROM and GApps! If you do this, you may run into issues.

Reboot your phone, and you should load into the new custom ROM.

Troubleshooting

In general, if you successfully flash a new ROM, but it boots and you run into weird freezing or other behavior, solving the problem is as simple as wiping the cache. To do this, you boot into HBoot, go back into Recovery, and use the tools there to wipe the cache and something called Dalvik. Here's a great guide (a bit out of date, but still mostly correct) to doing this with TWRP.

Comments

Popular posts from this blog

The Fat Man - A Story

Brooks Brothers, RIP?

Something about The Carpenters