Friday 30 December 2016

Android 6.0 on HTC ONE M7

The Internet offers quite a lot of step by step instructions on how to flash an Android device with a different ROM (Firmware). The most of them tell you how to do it and are really well for a defined device and a defined software. I'm a developer and I like to have some more options. I don't want to write a general flashing manual. The aim is to share some useful information about flashing.

Introduction

Don't try to flash a device you need every day, because if the flash doesn't work you won't be able to go back. Not every device is suitable for flashing: a popular device will be easier to flash as a less sold high customized one.

I decided to use a second hand HTC ONE M7 which I did buy for my daughter in the past. The original installation was done using Android 5.1.1 and I want to update it to Android 6 Marshmallow.

Prerequisites

To do the work I need a personal computer or a Mac with a free USB 2 compliant port. I mostly use a Windows 10 PC so I will describe how to do the work on this platform. On a Mac it would work in a similar way, but I would need the Mac version of the software I use on the PC.

The M7 has to work correctly and be connectable to the PC using a USB cable. As soon as the M7 connects to the PC a local drive containing the HTC Sync Manager appears into the file explorer. This manager has to be installed on the PC and is required even after flashing to connect the M7 with the PC. I update the HTC Sync Manager to the last version found on the HTC Home Page. With this new version of the HTC Sync Manager the M7 doesn't seem to connect to the PC, but the drivers required for the flashing works perfectly.

The connection mode selected on the device has always to be the USB Debug.

I'm a developer so I already installed the Android Studio, the Android SDK and a Oracle Java SDK. If you don't need Android Studio, you can download the basic Android command line tools.

After the download you have to unpack the zipped software somewhere on your local disk.

Go to <android_sdk>\tools\bin folder, press and Hold the SHIFT button on your keyboard and, at the same time, right-click on the folder’s white space. Select ‘open command window here’ and wait for the Windows Command Prompt window to load.

Execute sdkmanager "platforms;android-25". At the end of the download you should see the folder <android_sdk>\platform-tools.

For more information refer to the sdkmanager documentation.

On my PC the plattform-tools are located under C:\Users\<user>\Local\Android\sdk\plattform-tools.


Preparing the Device

Preparing the device for flashing is a vendor and/or device specific process so this section is not helpful if you have a different device. The very good support by HTC was a reason for the choice of the M7 as candidate for flashing.

The M7 is locked, so it is impossible to change anything on it until it is unlocked. HTC supports the unlock process on the development page.

What you need to know in advance is that you need a developer account on HTCDEV to be able to unlock your device.

The boot loader unlock process works well but on step 4 and 5 don't use the fastboot.exe of HTC, because it requires dependencies you probably didn't configure on your PC.

Go to <android_sdk>\platform-tools folder, press and Hold the SHIFT button on your keyboard and, at the same time, right-click on the folder’s white space. Select ‘open command window here’ and wait for the Windows Command Prompt window to load.

The fastboot.exe is already there ready to use.

At the end of the process my M7 works exactly as before.

Recovery

The recovery is the process that allow the owner of the device to perform a factory reset of the device. Generally is a very simple procedure which isn't suitable to support the installation of a different ROM. To gain more control over the M7 I decide to replace the original recovery by a well known software. I like TWRP by Team Win. TWRP is a kind of mini Android with touch commands. It connects  the the internal memory of the device with my PC.

The procedure described in this section may be applied to many devices, but the software itself is device specific. The way to enter the recovery is also device specific. The most part of the vendors publish the information about the recovery in a manual or on the WEB. The general procedure is:

  1. Switch off the device
  2. Press the volume down and the power buttons (in this sequence) and hold them until some text appears on the display.
  3. Use the volume to choose an option
  4. Use the power button to enter the sub menu or execute the option

Again the M7 is a good canditade because there is a TWRP version available. I use the last version [now is 3.0.0-2 for the M7 GSM] to install my M7.

The M7 has to be started and connected to the PC. The image file [twrp-3.0.0-2-m7.img] as to be copied to <android_sdk>\platform-tools.

Go to <android_sdk>\platform-tools folder, press and Hold the SHIFT button on your keyboard and, at the same time, right-click on the folder’s white space. Select ‘open command window here’ and wait for the Windows Command Prompt window to load.

Execute fastboot flash recovery twrp-3.0.0-2-m7.img and then fastboot reboot Be patient the M7 takes sometimes to be ready again. At the end the M7 works again as nothing did happen and the connection to the PC still works.

Check the TWRP

Before I go ahead with the flashing I need to be sure the TWRP works as I expect.

The display after step 2

  1. I switch off the device and connect the USB cable to the PC.
  2. I press the volume down and the power buttons holding both until a white screen appears.
  3. I release the buttons and then press shortly the volume down button again: the blue cursor moves from FASTBOOT to RECOVERY.
  4. Now I press shortly the power button.
The TWRP home screen on the HTC One M7 display


The first time TWRP screen appears on the phone display, I need to allow changes to be done, then the TWRP home screen appears on the mobile device and my PC displays a new device called MTP Device. Clicking on the icon I can access the internal memory of the M7.

NOTICE: if you are copying a large file from/to the device, while connected to the PC using the TWRP, you have to disable the screen timeout, because, if the phone goes to sleep, the connection gets lost. Tap on settings and then then on the middle icon of the icon bar.

Backup the Original ROM

The TWRP allow the backup of the entire device. The easiest way is to perform the backup on the device itself and move the backup to the PC. The backup of the original ROM was out of scope, so I don't know for sure if the cycle backup and restore works. I will try this functions later to quickly switch from a ROM to another.

Android 6 Marshmallow


Now I need a M7 compatible Android 6 ROM. On XDADEVELOPERS I found a list of projects building Android ROMs which are also available for the M7. The M7 seems to be a good candidate for a successful flashing because of the choice between 18 different ROMs. I don't know any of these project. I try the number 5, OwnROM first.

Common Flashing Steps

The steps to flash a different ROM are generally the same for most mobile devices.

I need the software to install: at least two ZIP files. The first contains the ROM and is device specific, the second contains the Google Apps and is device independent. Since I want a rooted device I need a third ZIP file containing the superuser software which is also device specific.

The Google Apps may be downloaded from Open GApps. This is a great service/project, I may choose between some different distributions. I choose the standard stock distribution because the M7 has enough internal memory.

The Superuser (root) is mostly provided by SuperSU

Now the software is on the PC an I can start flashing:

  1. I power down the device and connect the USB cable
  2. I start the device entering the recovery (TWRP)
  3. I tap on Wipe
  4. I tap on format data and confirm the execution
  5. I go back on the main screen
  6. Now I go to the PC an copy the 2 (3) ZIP files to the internal memory of the MTP device
  7. I go back to the device and tap to Install
  8. I select the ROM file, the SuperSU file and the GApps file in this order.
  9. I start the flashing
  10. At the end I wipe the Dalwik cache
  11. I tap on reboot

The M7 starts using the new ROM. After sometimes the Android first time configuration wizard appears. Now I have to configure the phone as it were a new one.



No comments:

Post a Comment