I have a HTC One (m7u) which originally came with HTC Sense OS, As I am a fan of stock android, I had it converted to a Google Play Edition HTC One when it was released.
Recently I noticed a purple tint in low light pictures taken by my HTC One, I did some research and I found out it is a hardware issue and camera should be replaced by HTC. I still had warranty but as I had done extensive modifications to my phone, it was possible that HTC refuses to repair it under warranty. so I decided to revert it back to stock sense and it took me around 12 hours to figure out how to do this properly. so I am writing this guide to help others who may have the same issues.
HTC One is one of the most complex devices I’ve ever worked with when you want to tweak it. It comes with a locked boot-loader which you need to unlock with a cryptographic key obtained from HTC. other than that , it has a security lock which you can turn on or off (known by s-on & s-off). I will not go into great details of these features as there are a lot of resources about them on Internet.
Lets get to reverting back your HTC One to stock ROM. My assumption is that you have a phone with unlocked bootloader and s-off and a non-stock ROM on it (Google Play Edition in my case).
Before we get to flashing things into your phone, you should check your current phone mid (model id) and cid (custom id). there is a chance that the custom ROM which you have flashed into your phone has changed your phone mid and cid and stock ROM will not install on your phone unless you revert them back into original values.
In order to check your phone mid and cid, reboot your phone into boot-loader mode by adb with following command (I assume you know how to work with adb and fastboot, if you dont just google for it and learn it) :
adb reboot bootloader
after phone is in bootloader mode, issue the following command :
fastboot getvar all
here is the output for me :
(bootloader) version: 0.5 (bootloader) version-bootloader: 1.54.0000 (bootloader) version-baseband: 4T.21.3218.21 (bootloader) version-cpld: None (bootloader) version-microp: None (bootloader) version-main: 3.62.1700.1 (bootloader) version-misc: PVT SHIP S-OFF (bootloader) serialno: XXXX (bootloader) imei: XXXX (bootloader) meid: 00000000000000 (bootloader) product: m7_u (bootloader) platform: HBOOT-8064 (bootloader) modelid: PN0712000 (bootloader) cidnum: GOOGL001 (bootloader) battery-status: good (bootloader) battery-voltage: 4338mV (bootloader) partition-layout: Generic (bootloader) security: off (bootloader) build-mode: SHIP (bootloader) boot-mode: FASTBOOT (bootloader) commitno-bootloader: dirty-0e82187e (bootloader) hbootpreupdate: 11 (bootloader) gencheckpt: 0
These are important information :
(bootloader) version-bootloader: 1.54.0000 : bootloader is 1.54 , so it will not work with revone tool to lock the bootloader again. we need bootloader 1.44 to Lock it completely.
(bootloader) product: m7_u : the phone variation is m7u (GSM Only) and not m7ul (GSM & LTE). it is important when you want to choose the stock ROM.
(bootloader) modelid: PN0712000 : PN0712000 is Google Play Edition model which is different from my phone stock. I need to revert it back to original before I can flash the stock ROM.
(bootloader) cidnum: GOOGL001 : GOOGL001 is Google Play Edition custom id which is different from my phone stock. I need to revert it back to original before I can flash the stock ROM.
(bootloader) security: off : my phone is in s-off state. I need to make it s-on.
Now we have to change modelid and cid to original values. you can find your phone modelid on the back of your phone. it starts with PN so it is easy to find and there are only a few possible values based on the region of the phone.
There are 3 ways to change modelid of your phone :
1.Flashing an Engineering bootloader on your phone and changing modelid through fastboot commands (NOT RECOMMENDED)
2.Change modelid through adb, explained here : http://forum.xda-developers.com/showthread.php?t=2490792
3.Change modelid through TWRP/CWM recovery, explained here : http://forum.xda-developers.com/showthread.php?t=2535365
After changing the modelid reboot into bootloader and confirm it has been changed properly.
Fortunately changing cid is much easier and can be done through a single command in boot-loader mode (change YOURCID to your stock cid value) :
fastboot oem writecid YOURCID
Note : CID is also dependent on the region and your phone carrier, if you dont know your stock cid, your best bet is to search on forums like xda-developers where many users around the world have shared their modelid and cid and carrier names.
After changing the cid reboot into bootloader and confirm it has been changed properly.
Now that we have proper mid and cid, we can relock bootloader and flash stock ROM. in order to relock bootloader issue the following command while you are in bootloader mode :
fastboot oem lock
Note : Please note your boot-loader has changed into RELOCKED state which shows you had voided your warranty ! we will fix it later using revone tool.
You can find the proper ROM for your htc one on this website : http://www.htc1guru.com/downloads/ruu-zip-downloads/
the ruu zip is pretty large and is approximately 1GB. download the ruu zip for your device and place it inside your adb folder and rename it to ruu.zip
reboot into HTC RUU mode (Rom Update Utility) while you are in boot-loader mode :
fastboot oem rebootRUU
You can recognize the RUU mode by a black screen and a silver htc logo in center.
After you are in RUU mode issue the following command TWICE :
fastboot flash zip ruu.zip
It is important to issue the command twice because first time it updates the bootloader and reboots into RUU mode again ready for ROM to be flashed.
If you have done every step correctly , your stock ROM should be flashed into your device now and you can see the progress on screen.
When flashing is over and you get a success message , it is time to reboot the device :
Your phone should boot into stock ROM now. it may take a while as this is like the first boot of the phone. but there is still two steps to be done :
1. Locking bootloader (it is in Relocked state now)
2. Turning Security ON (S-ON)
In order to Lock the bootloader like original we will use a tool called revone.
Please read this guide on how to use revone to Lock your bootloader : http://forum.xda-developers.com/showthread.php?t=2497712
Note 1 : Revone will not work on hboot 1.54 or above, if by any chance you have boot-loader 1.54 or higher, you need to downgrade your hboot to version 1.44.
Note 2 : You may need to run revone more than once to work. for me personally it took two tries to get a success message.
After you got a success massage from revone , reboot back into bootloader and make sure your bootloader is in Locked state.
The last step is to turn the security on, it is very easy, just run the following command in bootloader :
fastboot oem writesecureflag 3
Now your device is 100% back to stock and you can return it for warranty 🙂 just reboot the phone and install all the official OTA updates.