[One (M8) General] djibe89:
[GUIDE/TUTORIAL/HOWTO] HTC One M8 from Stock to Android 13 / LineageOS 20

[GUIDE/TUTORIAL/HOWTO] HTC One M8 any version (single SIM: m8ul, m8vzw and m8spr or dual SIM: m8dug and m8dwg) stock to Android 13 / LineageOS 20

This detailed step-by-step guide helps you transform your HTC One M8 (any version) to a powerful one with Android 13.

Make sure you have the One M8 model, in Android, go to Settings > About phone and check the model.

Read all my tutorials at https://github.com/djibe/Android-tutorials

CHANGELOG

v6. Upgrade to Android 13, update pack

v6. Moved to Android 12

v5. Moved to Android 11, improve readability, update pack

v4. Prepare for Android 11, Updated pack with latest TWRP

v3. Updated pack with latest Magisk

v2.1. Drop ADB 15 sec installer and use latest adb and fastboot.

v2. Update pack and tutorial for TWRP 3.4.0-1

v1. Initial release

1) DOWNLOAD

- djibe HTC One M8 pack (~40 Mo) : https://bit.ly/djibe-onem8-pack

(includes HTC USB Drivers, recovery TWRP 3.6.1_9-0 for all m8, Magisk Root, PlayIntegrityFix, adb & fastboot.exe).

Unzip the djibe folder from the zip on root folder of C:\ drive.

- ROM Unofficial LineageOS 20: https://xdaforums.com/t/rom-13-0-unofficial-m8-m8d-lineageos-20-0-stable.4496405/

Download latest build here (compatible with all M8 single/double SIMs variants): https://androidfilehost.com/?w=files&flid=336214&sort_by=date&sort_dir=DESC

# M8 GPe partition layout is no longer supported. The device must first be converted to Sense firmware, otherwise installation will fail.

# Android 13 is incoming

+ BitGapps 13 ARM64 (Mini or other): https://bitgapps.io

+ Charge phone to 100%

+ MicroSD card formatted in FAT32

+ Copy ROM + Google Apps + both Magisk files on microSD card + PlayIntegrityFix. Insert it in phone.

WARNING. This tutorial uses Microsoft Windows.

WARNING. Warranty is now void.

WARNING. Read carefully the sentences starting with ###.

2) BACKUP DATA AND INSTALL DRIVERS

Disable Antivirus.

Install drivers from my pack:

right click on HTCDriver.exe > click on Run as administrator and continue the setup.

Connect HTC One (while phone on) to PC, let drivers install.

In Windows explorer, HTC One should be available.

### If not make sure phone connection is in File transfer mode (see Android notifications).

### Phone is still not visible in Windows Explorer ? See fix at end of tutorial.

Collect all personal photos, videos, etc ... and backup these on PC.

Use an app like Backupyourmobile/SMS Backup & Restore to backup texts, contacts, etc.

Check that backup is located on microSD card.

Then copy the backup on your PC.

Disconnect phone.

Check that you have the latest official updates.

### If your phone is Simlocked/carrier locked/Network locked, don't go further.

Visit official website of your network carrier (or call their support) to retrieve your desimlock code.

Ask them for details on how to remove simlock.

How do I know my phone is simlocked ? When you insert a SIM card from another operator, network is inaccessible.

Only a stock ROM can remove simlock.

To go back from custom ROM to stock, see dedicated section at the end of tutorial.

3) UNLOCK BOOTLOADER

In Android, go to Settings > About > Software information > More.

Tap 7 times on Build number. It unlocks Developer options.

Go back to the About menu, you can see the new Developer options menu.

Tap on it, accept the warning.

Toggle on the USB debugging option.

Connect phone, a message appears on phone : Allow USB debugging?

check Always allow and confirm by tapping on OK.

Now, open a Windows command on my "flash" folder (hold Shift + right click on folder -> Open a windows command here).

### Then navigate to my flash folder (if it is on desktop) with this command :

cd /d C:\djibe\flash

Enter command :

adb devices

, confirm by pressing Enter.

Command returns :

List of devices attached
HT35****** device

### If no device is found, uninstall and reinstall properly the drivers while antivirus is off. Or see fix at the end of this tuto.

### Or start fresh on another PC.

Now type :

adb reboot bootloader

Phone restarts in Fastboot mode. Wait till phone screen is blank in fastboot mode.

Type:

fastboot devices

Command returns :

HT35**** fastboot

### You may have to fix drivers again (see fix at the end of tuto)

Type:

fastboot getvar all

Bootloader must be in version 3.19 (Thx @sterphles)

Type:

fastboot oem get_identifier_token

, confirm by pressing Enter.

Command returns multiple lines.

Select with your mouse all the lines from

<<<< Identifier Token Start >>>>

(included)

to the line

<<<<< Identifier token end >>>>>

(included).

Now on keyboard copy (Ctrl + C combo), then open Notepad.

In Notepad, paste those lines (Ctrl + V combo).

Now manually remove all the (bootloader) strings from each line.

Your notepad should now look like this :

<<<< Identifier Token Start >>>>

37A5DBF4FE5F0D9F4425E54AA91AFDBF

2A20E9C67C3BB4FAE60263F76BDEC6AC

847BF9FFB11DAEA4AB88AC8710435449

9BC12E93DF4C54FFE3D064C4C810C49A

2CDAF2E0CD3A164FED4A568CB0FD2AC6

C01AA991733D949C00987062D691DE91

8AA1C97CEBC3ACE83FECE75A1D03CE72

62414C7DC36A73AFCBF433E1EBE2EDC7

E272F73309632D3EF8C86E472B65E8EF

37E46B52FE3F94FC69D1854CA3DE6F48

C3E10001B233A70B1EAF35134F51FCC6

353E0CC98534E6E60A241A7063D0BE2F

A5B752E75C1C47E6F739BDBE67D024DA

3292A14278247557632639802722A86C

E61424F7666AE085AA9905096FEED1AD

5ECBBD867544E95ABDDA277690B8CB55

<<<<< Identifier Token End >>>>>

Now visit this website : https://www.htcdev.com/bootloader/

Register on the site. Confirm registration with your email.

In the select menu, chose HTC One (M8), click Begin unlock Bootloader button.

Agree to legal terms.

Next page, go to the bottom and click continue to step 5.

In the bottom of this page, in the lower textarea "My Device Identifier Token",

copy and paste the multiple lines you just edited (my example is just above).

Click Submit.

HTC tells you : Token Submitted Successfully.

Open your mailbox (associated to your HTC account).

Copy the Unlock_code.bin file attached to email in my "flash" folder you unzipped.

In Windows command, type :

fastboot flash unlocktoken Unlock_code.bin

, confirm with Enter.

Command should return :

unlock token check successfully

Back to phone, press Volume+ to select "Yes, unlock bootloader", then Power button to confirm flash.

Now wait while phone is going to Factory reset.

Don't let Android restart by holding both Power + Volume- to enter bootloader immediately.

FASTBOOT menu is overlined in red.

4) FLASH TWRP RECOVERY

Using the same Windows command prompt, enter :

fastboot devices

to make sure phone is still available.

Then

fastboot flash recovery twrp-3.6.1_9-0-m8.img

Command returns :

finished. total time: x.xxxxs

Now on phone, press Volume- to highlight HBOOT, confirm with Power button.

You are back to the bootloader screen (UNLOCKED is written on top line), press Volume- to navigate to RECOVERY, and confirm with Power button.

Phone reboots in TWRP recovery.

5) BACKUP STOCK SYSTEM

In TWRP, check Never show this screen and Swipe to Allow Modifications.

You land on TWRP Home screen.

Always make a backup of your stock system. We never know when a weird bug will decapitate the system.

Go to Backup menu, select all partitions and Backup to microSD card.

Backup the generated TWRP folder content from your microSD card to PC.

6) WIPE PARTITIONS

Back to Home menu, go to Wipe > Advanced wipe.

Select Dalvik / ART Cache, Cache, System, Data, Internal Storage then Swipe to Wipe, go back to Wipe menu.

### Don't wipe SDcard

7) FLASH ROM, ROOT/MAGISK AND GAPPS

Back to Home screen, tap on Install > choose lineage*.zip,

(if you don't see the files, tap on Select Storage and make sure Micro SDCard is active)

then Add more Zips -> Magisk*.zip,

then Add more Zips -> bitgapps*.zip,

then Swipe to confirm Flash.

Wait for operation to end (can be long).

When completed successfully, tap on Reboot.

Tap on Do not install when TWRP asks for the app install.

Wait during long first boot.

Don't connect to Android account.

8) ROOT WITH MAGISK (OPTIONAL)

### Only if you flashed Magisk via TWRP recovery

Do not connect to Google account.

Magisk root starts with Android.

You can manage permissions and extra modules with Magisk Manager app.

Open Files app > Install Magisk.apk.

Then in Magisk goto Settings > Hide magisk app and give it a name, switch Zygisk option ON.

Go to Modules Tab > Install from Storage: PlayIntegrityFix.

Go to Developer options to disable Android debugging (ADB).

Reboot phone.

You can use yasnac app to check Safetynet passes.

Now you can setup your Google account.

8) You can use Backupyourmobile to restore data,

use GPS Status & Toolbox app to enhance GPS fix.

That's it.

Enjoy,

djibe

THANKS to TWRP team, LineageOS team, tarkzim, ckpv5, alray, 🅱️, Flyhalf205, icxj1, R1ghtC, gimmeitorilltell, All M8 contributors.

##################################################

A) Fastboot devices doesn't show any device connected

Install HTC USB drivers

Reboot PC

Open Windows Device Manager (Windows + R shortcut on keyboard > devmgmt.msc > hit Enter)

Search for phone at Other devices submenu > Device is named Android 1.0 or My_HTC

### If it is My_HTC > select it > right click > Uninstall. Disconnect phone. Reconnect phone. Now recognised as Android 1.0.

Select device Android 1.0 > right click > Update Driver

Search locally for driver > Show a list

Select ASUS Android Device.

Manufacturer: select Google, Inc. and set driver to Android Bootloader Interface

Confirm install.

B) Go back to stock from a custom ROM with a HTC One M8

- Either restore your TWRP backup with TWRP recovery

- Or restore a community TWRP backup with TWRP recovery (https://forum.xda-developers.com/htc-one-m8/help/tutorial-how-to-stock-stock-twrp-t3086860 see posts 2 & 3)

### With S-ON and keep device Unlocked

To find suitable backup for device, boot phone in Bootloader mode (Power + Volume-)

Look at your hboot version (hboot 3.19.0000 is most frequent)

Launch a fastboot command:

fastboot getvar all

Make sure IMEI is a valid number.

Look at your CID and MID values. Try to find exact same TWRP backups for your phone.

### Flash only exact model versions.

Then wipe all partitions and restore the correct TWRP backup an angel made for you.

- If TWRP restore fails, start with these posts :

You will need a Rom Update Utility (RUU) for your exact model version.

This is compatible with S-ON, will need to relock your Bootloader (save your Unlock_code.bin +++) and need original recovery

https://forum.xda-developers.com/htc-one-m8/help/tutorial-how-to-stock-stock-twrp-t3086860

https://forum.xda-developers.com/htc-one-m8/general/guide-restore-european-htc-one-m8-to-t3072235

C) No IMEI visible and no cellphone network detected with HTC One M8

Composing *#06# shows an empty IMEI dialog window.

or Settings > About phone > IMEI. IMEI: Unknown, IMEI SV: Unknown

Refer to B) tutorial to get back to stock.