So, you've unlocked your bootloader and are enjoying some rooted goodness on your phone. You then realise you've got an issue with the phone and forgot to make a backup of your stock ROM! Not to fear, this guide is for you! This will reset the phone back to it's out-the-box state, locked bootloader and all, running the latest ZNH2KAS3P0 build so you can return it for RMA/sell it. This also works to go back to CM13.1.2 from Oxygen OS.
It's recommended that you have adb/fastboot in your System Path. This makes it easier to run commands as you don't always have to 'in' your adb/fastboot folder to run the commands. This guide should help you with this but if you don't want to do this, please copy/extract any files into your adb/fastboot folder before continuing...
1. Download the factory image
Cyanogen released the factory image for the OPO but didn't include any batch files to automate the process. I've repackaged the images into two seperate ZIPs:
ZNH2KAS3P0 16GB: DOWNLOAD
ZNH2KAS3P0 64GB: DOWNLOAD
*** These ZIPs are not flashable so cannot be flashed via TWRP ***
2. Extract the factory image
Using your favourite file extraction program to extract the package to your Desktop (I use 7-ZIP). *** Remember, if you don't have adb/fastboot in your Path, extract the image into your adb/fastboot folder ***
3. Flash the factory image
Once you've unlocked the bootloader, and rebooted the phone, turn the phone off and back on into fastboot mode and reconnect it to the PC. You can now run the flash-all.bat (Windows) or flash-all.sh (Linux) file. These automate the flashing process. Once complete, the phone will reboot.
*** Some users have had issues using the script in Linux so in these cases extract the ZIP file and flash each IMG individually ***
fastboot flash modem NON-HLOS.bin
fastboot flash sbl1 sbl1.mbn
fastboot flash dbi sdi.mbn
fastboot flash aboot emmc_appsboot.mbn
fastboot flash rpm rpm.mbn
fastboot flash tz tz.mbn
fastboot flash LOGO logo.bin
fastboot flash oppostanvbk static_nvbk.bin
fastboot flash recovery recovery.img
fastboot flash system system.img
fastboot flash boot boot.img
fastboot flash cache cache.img
fastboot flash userdata userdata.img (the filename is the same in both ZIPs so make sure you're using the right one for your device)
4. Reset the tamper flag/lock the bootloader
There is a flag/bit on the phone that is triggered when you unlock the bootloader and even relocking it won't change this flag back to standard. Luckily, @Mnt-XDA has a script that you can flash which resets these flags so OP/anyone else is none the wiser! To do this, read and follow THIS thread
5. Reboot the phone
Says it all really - you're done!
Change your battery. I faced the same issue and after changing battery the issue is gone completely.
fastboot: error: Couldn't parse partition size '0x'.
fastboot flash boot boot.img
fastboot flash:raw boot boot.img