Unlocking and Re-locking the HTC M8 bootloader

1. Introduction

Unlocking the Android bootloader allows for the installation of a custom Android OS — known as a ROM — to the device. Android OSes are read-only, hence the term ROM — read-only memory. The bootloader determines which software, including which ROM, is to be run when the device is powered on.

Based on the guide provided by HTC, this guide provides some additional details along with edits and illustrations for further clarity. For downloadable code, you may need to follow along in the HTC step-by-step instructions. This guide has been tested with, and is specific to, the HTC One M8 handset with Android version 6.0.

Device – Enable fastboot mode

2. Power off your device. Press and hold the Volume Down button and then simultaneously press and hold the Power button for several seconds. This will launch the device into bootloader mode.

3. The Volume buttons are used to make selections in the bootloader screen. Highlight “fastboot” and then press the Power button. A label FASTBOOT should now appear highlighted in red on the device screen.

4. Connect your device to your computer with a USB cable. The FASTBOOT label should now read FASTBOOT USB.

Bootloader screen “HBOOT”Bootloader screen “FASTBOOT USB”

Desktop – Generating a token

5. Using Terminal (MacOS) from your desktop, issue the following command.

Shell

1

2

3

fastboot-mac oem get_identifier_token

6. A code block will be generated. Copy this text, including the lines “<<<< Identifier Token Start >>>>” and “<<<<< Identifier Token End >>>>”. Omit any line prefixes, such as “INFO.” On device SH45FWM01420 (I nicknamed this device “sapphire”), the code block was as follows.

HTC Web Site – Requesting the unlock binary

Desktop – Flashing the unlock binary

8. An unlock code binary file will be sent to you by email. It will be an attachment named Unlock_code.bin. Save this file to your desktop alongside your earlier fastboot files.

9. Using Terminal (MacOS) from your desktop, issue the following command.

Shell

1

2

3

fastboot-mac flash unlocktoken Unlock_code.bin

Device – Confirm

10. Your device should now display a disclaimer. Use the Volume buttons to select and press the Power button to confirm your selection.

If you select Yes, your device will be reset to its factory default settings and your bootloader will be unlocked. This step will erase all user data and third-party apps from the Internal Storage.

If you select No, your device will reboot and no modifications will have been made.

3. Relocking the bootloader

(Steps 1 through 3 below are identical to steps 2 through 4 above.)

1. Power off your device. Press and hold the Volume Down button and then simultaneously press and hold the Power button for several seconds. This will launch the device into bootloader mode.

2. The Volume buttons are used to make selections in the bootloader screen. Highlight “fastboot” and then press the Power button. A label FASTBOOT should now appear highlighted in red on the device screen.

3. Connect your device to your computer with a USB cable. The FASTBOOT label should now read FASTBOOT USB.

4. Use the following command in Terminal for MacOS.

Shell

1

2

3

fastboot-mac oem lock

5. Note: This will not restore the factory default lock, but will simply re-lock the bootloader so no further changes can be made. If you want to unlock your bootloader again, simply reinstate FASTBOOT USB mode (steps 2 through 4 for unlocking), then repeat step 9 for unlocking with your original unlock key file.