Guide: Relock bootloader with custom rom on oneplus 5/5t - OnePlus 5 Guides, News, & Discussion

Oneplus 5/5T bootloader included with 5.1.5 firmware allows booting self-signed recoveries and kernels. In short, you generate signing keys; sign recovery and kernel from your current custom rom (kernel could be signed on the phone); transfer recovery on your phone; apply boot signer for kernel; and relock bootloader. This guide borrows from Chainfire's guide and customizes it for our device.
PROS:
1. Virtually total protection of your data, especially if encrypted
2. Inability to flash another recovery, even stock recovery (if OEM unlock allowed is unchecked)
3. Inability to flash another kernel, including stock kernel, (again if OEM unlock is unchecked)
4. Inability to unlock bootloader in fastboot, see above
5. Total inability to flash anything in fastboot. The only access to the phone is through TWRP
6. You can still change/update roms, backup/restore data to your liking
7. You get a different boot warning screen: 'your phone has loaded a different operating system' with a fingerprint (four rows of numbers). Write them down and compare once in a while: if the numbers are different, someone (and I am talking a sophisticated adversary) tempered with your phone
CONS:
1. You would have to set up things once
2. When changing or updating roms, one extra step is required - flashing Chainfire's modified Verified boot signer zip to resign kernel (right after Magisk and before reboot).
The key generation and signing is based on Android source directions and Chainfire's thread about relocking bootloaders with custom roms. So, credit for that goes to him
THESE ARE INSTRUCTIONS FOR LINUX. I am sure there is a way to do the same on Windows
Preliminary steps:
Remember, if you are not on 5.1.5, you may have problems. For example, my own rom, Jaguar Oreo, requires 5.1.4 firmware. I did all the steps and everything worked, except that TWRP couldn't de-crypt. However, I went ahead and flashed 5.1.5 firmware and the rom is working fine. So, I re-did all the steps and now de-cryption works too. This may or may not be the case with your favorite rom, if it is not on 5.1.5.
1. Create a directory on your PC named, let's say, Bootkeys.
2. Get Chainfire's Bootsignature.jar from here: https://forum.xda-developers.com/attachment.php?attachmentid=4136392&d=1493804209 and VerifiedBootsigner.zip from here: https://forum.xda-developers.com/attachment.php?attachmentid=4164411&d=1496000476 and put both files in that newly created directory
3. Get your favorite TWRP (I use Blue_Spark) and put it also in that directory
4. Key Generation:
Run the following code one line at a time from PC terminal opened in your newly created directory. Skip the lines with "#" sign, these are for comments only.
Code:
# private key
openssl genrsa -f4 -out custom.pem 2048
openssl pkcs8 -in custom.pem -topk8 -outform DER -out custom.pk8 -nocrypt
# public key
openssl req -new -x509 -sha256 -key custom.pem -out custom.x509.pem
openssl x509 -outform DER -in custom.x509.pem -out custom.x509.der
You don't need to use pem files and can delete them after key generation.
5. Signing:
Rename your TWRP into recovery.img and run the following code one line at a time from the same terminal
Code:
java -jar BootSignature.jar /recovery recovery.img custom.pk8 custom.x509.der recovery_signed.img
java -jar BootSignature.jar -verify recovery_signed.img
Your recovery is signed (first command) and verified (second command - the output should be 'signature valid').
6. Open Verifiedbootsigner-v8.zip you downloaded from Chainfire's thread with your PC's archive manager (don't have to unzip it). Grab your newly generated keys custom.pk8 and custom.x509.der and put them into the opened zip. Make sure the files are there and close archive manager
7. Now back to the phone. Flash your newly signed 'recovery_signed.img' (not original 'recovery.img') to the phone via fastboot or in your existing TWRP. Reboot in your new recovery.
8. Now, format the phone - you have to type 'yes'; next, format separately system/cache/dalvik/data/SD. Reboot the phone into TWRP again.
9. Transfer your favorite Rom, No verity (only if your rom is force-encrypt) and Verifiedbootsigner to your SD card. Remember. You must be decrypted to relock. Locking bootloader on encrypted device will destroy encryption key. Once bootloader is locked and everything is working, you can encrypt.
10. Flash the rom, No verity (only if your rom is force-encrypt) and Verifiedbootsigner. Reboot and make sure you are NOT encrypted (in Settings/Security). (If encrypted, stop and return to step 8: you either haven't formatted to factory reset or your no verity didn't work).
Now, back to TWRP: most likely your data is gone, so, re-transfer the rom and and Verifiedbootsigner to internal SD
Now, you are ready for the FUN PART: re-locking:
11. Boot in fastboot and execute fastboot oem lock
12. Reboot. You will get a yellow warning: 'Your phone loaded a different operating system". The first boot may throw you into TWRP. Just reboot normally again
13. Now, you can do whatever you want, including Gapps and Magisk. Everything should operate normally. Just remember, every time after flashing Magisk/update/change rom, you MUST reflash Verifiedbootsigner, as the last step and before reboot, even if during flashing, the script tells you kernel is signed. Follow the script and press volume down to sign again

Screenshots

And you have already done it, right?
Sounds fun tbh, will try for sure.

Now, that I have locked bootloader on my Oneplus 5, and made sure that everything is working including encryption, I have disabled OEM unlock within developer settings. When I put the phone in fastboot and try 'fastboot oem unlock', I get a response 'FAILED (remote: Flashing Unlock is not allowed'. Since the bootloader is locked, no one can put another self-signed recovery or kernel via fastboot or otherwise, as it can only be done with unlocked bootloader. They can start the phone and get to my recovery, but data cannot be mounted and adb sideload wouldn't work either. They can try to press cancel at password prompt, but TWRP can't format unmounted data. The only way to proceed is to flash stock recovery via adb or full stock. In any event, my data is wiped.

Will this work if the phone is decrypted (using no verity)?

optimumpro said:
Now, that I have locked bootloader on my Oneplus 5, and made sure that everything is working including encryption, I have disabled OEM unlock within developer settings. When I put the phone in fastboot and try 'fastboot oem unlock', I get a response 'FAILED (remote: Flashing Unlock is not allowed'. Since the bootloader is locked, no one can put another self-signed recovery or kernel via fastboot or otherwise, as it can only be done with unlocked bootloader. They can start the phone and get to my recovery, but data cannot be mounted and adb sideload wouldn't work either. They can try to press cancel at password prompt, but TWRP can't format unmounted data. The only way to proceed is to flash stock recovery via adb or full stock. In any event, my data is wiped.
Click to expand...
Click to collapse
But in any case, the OEM unlock from dev option can be turned on, and then surely one can get through, right?
Also, did you go bootloader locked post encrypting, I mean is this the last step?
For my guidance, can you tell me, the sequence (number wise please), how to go encrypted?
Btw, any snapshot of bootloader failure?

obol2 said:
Will this work if the phone is decrypted (using no verity)?
Click to expand...
Click to collapse
I dont think, cause it is encrypted.

vdbhb59 said:
But in any case, the OEM unlock from dev option can be turned on, and then surely one can get through, right?
Also, did you go bootloader locked post encrypting, I mean is this the last step?
For my guidance, can you tell me, the sequence (number wise please), how to go encrypted?
Btw, any snapshot of bootloader failure?
Click to expand...
Click to collapse
obol2 said:
Will this work if the phone is decrypted (using no verity)?
Click to expand...
Click to collapse
Guys. Read 9-10 in the OP. Everything about encryption is there.

optimumpro said:
Guys. Read 9-10 in the OP. Everything about encryption is there.
Also, OEM option isn't available on custom roms. But you can modify build.prop for it to show up. Once everything is working, you can set oem unlock not allowed and remove the entry from build.prop.
Click to expand...
Click to collapse
Oops, my bad. I get your point.
Will try over the weekend. BTW, are you going for a release in the next 2-3 days? Then, I will clean flash once that is out.

vdbhb59 said:
Oops, my bad. I get your point.
Will try over the weekend. BTW, are you going for a release in the next 2-3 days? Then, I will clean flash once that is out.
Click to expand...
Click to collapse
I will update the rom once October security patches become available.

optimumpro said:
Screenshots
Click to expand...
Click to collapse
Thanks for the guide, I will try this when a new open beta comes out.
This might be really useful for those who have upgraded their devices from Widevine L3 to L1 by OnePlus, only to be disappointed that after unlocking the bootloader, L1 breaks.
One question tho, although right now I'm encrypted, I do not have that dialogue "To start Android, enter your password" with a black background when booting. Normally when I reboot, I get to my lockscreen with my wallpaper etc. and when I try to unlock the device, there's a small scrolling text saying "Unlock your device to access your apps..." or something around those lines. This seems like a bit different encryption than the one I have. Any clue on why's that? (fyi, I am 100% encrypted, TWRP asks me for my password to decrypt data)

david19au said:
Thanks for the guide, I will try this when a new open beta comes out.
This might be really useful for those who have upgraded their devices from Widevine L3 to L1 by OnePlus, only to be disappointed that after unlocking the bootloader, L1 breaks.
One question tho, although right now I'm encrypted, I do not have that dialogue "To start Android, enter your password" with a black background when booting. Normally when I reboot, I get to my lockscreen with my wallpaper etc. and when I try to unlock the device, there's a small scrolling text saying "Unlock your device to access your apps..." or something around those lines. This seems like a bit different encryption than the one I have. Any clue on why's that? (fyi, I am 100% encrypted, TWRP asks me for my password to decrypt data)
Click to expand...
Click to collapse
That's because you are encrypted with FBE. My rom has FDE, and it is not forced. So, if you are force-encrypted, you need to flash 'no verity', as stated in the guide. You must be de-crypted to relock. Then, if you want to be encrypted, reflash your rom without 'no verity'.

optimumpro said:
That's because you are encrypted with FBE. My rom has FDE, and it is not forced. So, if you are force-encrypted, you need to flash 'no verity', as stated in the guide. You must be de-crypted to relock. Then, if you want to be encrypted, reflash your rom without 'no verity'.
Click to expand...
Click to collapse
Ohh, I see. Thanks for the swift answer!
I have two more questions: if I want to update my recovery, I need to keep the generated keys and with those keys I need to sign the recovery.img again, right? And do you have any guides on generating the keys while on Windows? Or do I have to be on Linux to generate the keys using those commands?

david19au said:
Ohh, I see. Thanks for the swift answer!
I have two more questions: if I want to update my recovery, I need to keep the generated keys and with those keys I need to sign the recovery.img again, right? And do you have any guides on generating the keys while on Windows? Or do I have to be on Linux to generate the keys using those commands?
Click to expand...
Click to collapse
Every time another recovery or kernel are installed, you need to sign. Only kernel could be signed on the phone. Your keys are supposed to be on your PC.
Haven't been using Windows for 10 years. So, can't help you.

optimumpro said:
Every time another recovery or kernel are installed, you need to sign. Only kernel could be signed on the phone. Your keys are supposed to be on your PC.
Haven't been using Windows for 10 years. So, can't help you.
Click to expand...
Click to collapse
I have a Linux VM just in case this happens but maybe you should mention it in your thread as most users here use Windows.

Additional experience having a custom rom on locked bootloader:
It appears that nothing, not even stock kernel or recovery, could be flashed via fastboot, if 'oem unlock allowed' is unchecked in Developer's settings. I tried to flash stock recovery via fastboot and got a response: 'remote flashing is not allowed', and fastboot is remote flashing. So, the only access to the phone is TWRP and unless data is mounted (via entering password/pin), not much could be done there either.

optimumpro said:
Additional experience having a custom rom on locked bootloader:
It appears that nothing, not even stock kernel or recovery, could be flashed via fastboot, if 'oem unlock allowed' is unchecked in Developer's settings. I tried to flash stock recovery via fastboot and got a response: 'remote flashing is not allowed', and fastboot is remote flashing. So, the only access to the phone is TWRP and unless data is mounted (via entering password/pin), not much could be done there either.
Click to expand...
Click to collapse
So, the only way around is by OEM unlock checked? This is good. Fully encrypted and hope it does work, especially for me. I will do a clean flash tomorrow. Can you share in the other thread just for me the exact steps for going Encrypted?
Once more please..

vdbhb59 said:
So, the only way around is by OEM unlock checked? This is good. Fully encrypted and hope it does work, especially for me. I will do a clean flash tomorrow. Can you share in the other thread just for me the exact steps for going Encrypted?
Once more please..
Click to expand...
Click to collapse
So, were you able to encrypt on Jaguar?
Regarding locking bootloader: just remember, you have to be de-crypted when re-locking. Otherwise, encryption key will be automatically erased, and you will have to do everything from start.

optimumpro said:
So, were you able to encrypt on Jaguar?
Regarding locking bootloader: just remember, you have to be de-crypted when re-locking. Otherwise, encryption key will be automatically erased, and you will have to do everything from start.
Click to expand...
Click to collapse
Ohh, so in that case a bit confused. If I Encrypt Jaguar, then locking bootloader will be done how? Sorry if it is a stupid question.

vdbhb59 said:
Ohh, so in that case a bit confused. If I Encrypt Jaguar, then locking bootloader will be done how? Sorry if it is a stupid question.
Click to expand...
Click to collapse
Whatever rom you have, if you are encrypted (whether FDE or FBE), you must wipe encryption by doing factory reset in TWRP before re-locking. Otherwise, when you re-lock, your encryption key will be wiped, but encryption will stay, so, the phone will be useless. You can do encryption later, when you are successfully re-locked.

Related

[How to]: going from China ROM to a working, rooted international ROM (2016/06/20)

Hey guys,
I recently purchased a Mi5 in China and had a hellish experience trying to get a working rooted international ROM on it even though I am definitely not a noob at android. I found out that most issues I had were result of small/stupid mistakes that can be easily avoided with the proper knowledge, so I decided to write a super quick how to on the process for anyone that might need it in the future. There are similar guides out there, and I will refer to some (all credit goes to original posters) but I found that most are incomplete/not updated/plain wrong. Please also note that this guide is updated to June 20th, newer ROM versions might require different steps.
This how to assumes you are familiar with the standard ROM flashing process, in case anyone needs a more detailed explaination of some of the steps, you can reply or search XDA elsewhere, most of the stuff has been mentioned here and there before.
1. Check that your hardware is ok (dial *#*#64663#*#* in dialer, you will enter hardware test mode, check every single item carefully)
2. Request a bootloader unlock from Xiaomi, unlock the bootloader: follow instructions here http://forum.xda-developers.com/mi-5/how-to/unlocking-xiaomi-mi-5-bootloader-t3336243
3. Now that Your bootloader is unlocked, you have 3 main options for working ROMs: Xiaomi's Global Stable, Xiaomi's Global Dev, Xiaomi.eu's unofficial Stable. If you want to play it safe, I suggest to go with the Xiaomi's Global Stable, otherwise choose Xiaomi.eu's unofficial Stable. I did not test extensively all three, so this is just a general recommendation.
4. In any case, you will need to use the official Xiaomi's flashing tool (Miflash) to do your first ROM flash. Just follow the process here: http://en.miui.com/a-234.html and you'll have flashed your new ROM. In case you want to flash Xiaomi.eu's unofficial Stable, follow the same process but get the flashable ROM here: https://xiaomi.eu/community/threads/xiaomi-eu-multilang-rom-for-xiaomi-mi5-unlocked-bl-only-released.31231/
5. Boot into your newly flashed ROM, check once again that hardware is ok (see step 1.). Please also see step 10b for a tidbit of additional info if You're in China.
6. Reboot into bootloader, boot (only boot, no need to install) TWRP, which you can find here as part of Xiaomi.eu's thread above in step 4. inside a zip packaged with a modded bootloader image. do NOT install the modded bootloader image. Also, this is the only version of TWRP that I found working for my device. There are a couple more versions from chinese developers (cofface, ganfan), but booting either resulted in blank screen.
7. Once you are in TWRP, the recovery will ask you for a decryption password, just press cancel, then "Swipe to allow modifications"
8. Sideload (you cannot install from internal storage since you will not be able to access it at the moment) the latest SuperSU stable, which you can find here: http://forum.xda-developers.com/showthread.php?t=1538053. Please note that you WILL need the latest version, anything earlier might just get you a bootloop. And please do NOT format /Data to make it accessible to TWRP as that will also likely result in bootloop. Just sideload whatever you need.
9. Do NOT wipe Dalvik or Cache, reboot into System.
10. Congrats, You're done. Have a beer/coffee/tea and pat yourself on the back.
10b. In case You're in China, and this is Your first Android 5.0+ ROM, you will happen into a "bug" (it's not really a bug, but a result of China's Great Firewall), where whenever you connect to a Wifi, the phone will think you have no internet access and that will cause a whole host of issues (won't reconnect automatically, will try to default to 4G etc.). If so, just enable ADB Debugging and type adb shell "settings put global captive_portal_server httpstat.us/204" . That will mostly solve it (you might still get some weird result with some APs, but toggling Wifi should solve the problem for that AP forever.
Lazer Bear said:
6. Reboot into bootloader, boot (only boot, no need to install) TWRP, which you can find here as part of Xiaomi.eu's thread above in step 4. inside a zip packaged with a modded bootloader image. do NOT install the modded bootloader image. Also, this is the only version of TWRP that I found working for my device. There are a couple more versions from chinese developers (cofface, ganfan), but booting either resulted in blank screen.
Click to expand...
Click to collapse
How do you boot into twrp without flashing it? fastboot boot recovery.img doesn't work for me.. the command was successfull, downloading to the phone, then it's telling me booting, but the phone stay in fastboot.. thx
m_adnan said:
How do you boot into twrp without flashing it? fastboot boot recovery.img doesn't work for me.. the command was successfull, downloading to the phone, then it's telling me booting, but the phone stay in fastboot.. thx
Click to expand...
Click to collapse
After it says booting, does the screen light up? If so please check wether "adb devices" and "fastboot devices" return anything. If adb returns "recovery" or if both return empty, you're likely bumping into my same issue where the recovery won't boot (to me this happened regardless of whether I flashed or booted it). Are you using the specific recovery version from my point 6?
Lazer Bear said:
After it says booting, does the screen light up? If so please check wether "adb devices" and "fastboot devices" return anything. If adb returns "recovery" or if both return empty, you're likely bumping into my same issue where the recovery won't boot (to me this happened regardless of whether I flashed or booted it). Are you using the specific recovery version from my point 6?
Click to expand...
Click to collapse
no, nothing happens on the screen, it stays in fb mode without any reaction. adb and fb devices doesn't return any device connected.. if i do an fb reboot it told me "waiting for any device" so the only option to get it run again is to power off.. yes of course, it's the recovery.img with the modified boot.img..
Lazer Bear said:
After it says booting, does the screen light up? If so please check wether "adb devices" and "fastboot devices" return anything. If adb returns "recovery" or if both return empty, you're likely bumping into my same issue where the recovery won't boot (to me this happened regardless of whether I flashed or booted it). Are you using the specific recovery version from my point 6?
Click to expand...
Click to collapse
i want only to inform you, i get it to work.. the problem was my rom, miui 8.. for miui 8 you will need a new version of twrp, which you can download here: https://yadi.sk/d/oj6Z-0u7sXdw6 after that, i was able to boot to the twrp recovery without flashing it, so i keept everything original like it was and was able to sideload the supersu and get root without to format my data.. when you start the recovery it came in chinese, but when you click on the right button you can choose your language.. that's it.. thank you for you support dude!!
Is it only way to switch from chinese ROM to official global ROM to have unlocked bootloader? If it is, is there any other way of unlocking it, waiting 15 days to get permission seems ridiculous.
Lovely step by step guide. But, any idea if it will wipe the user data and/or internal sdcard when moving from the chinese to international version?

[A2017U][TWRP System Image] Stock System Image of B20 for full stock restore and OTAs

THIS APPLIES ONLY TO THE A2017U VARIANT, DO NOT USE THIS FILE ON OTHER VERSIONS
Disclaimer - don't blame me if something goes wrong
As title says, this is a full stock unmodified B20 TWRP system image. It kan be used in addition to stock boot and recovery images to restore the US A7 to conditions which will be like stock and allow to flash upcoming OTA. This was tested by @jkuczera here http://forum.xda-developers.com/showthread.php?t=3459107
Link to system image
https://cloud.swehes.com/index.php/s/31V7GgihohBCdfy
If you are BL unlocked, you will need to lock it before flashing old recovery and boot (this may not be necessary to get MR2 to flash, depending on what it checks, but the phone might not boot, unknown). This will make your phone verify boot, recovery and /system again, so flash TWRP from tenfar's thread to be able boot after relocking since his is signed
To restore, unzip the file above to TWRP folder on the SD Card, then in TWRP under mount points unmount /system and put check mark on mount system as read-only. The read-only part is important so that TWRP does not modify the /system apon exit. You can then restore boot, recovery and system image.
Another partition, fastboot, was altered if you applied B20_boot, but so far no OTA has check it so it should be fine as is. Chance is it will be just overwritten by next OTA, but in case that changes, info will be added. This step is more risky since it involves using dd command and has to be applied carefully.
EDIT: looks like @Unjustified Dev posted new build that will flash fastboot image http://forum.xda-developers.com/showpost.php?p=68677272&postcount=133
You should then boot to stock recovery and factory wipe
In case you did not dump your boot and recovery, they can be found in @rczrider's post here
http://forum.xda-developers.com/axon-7/development/untouched-b20-boot-recovery-files-t3443818
Thanks to @swehes for providing the space on his cloud for this file, @rczrider for rest of the files and @jkuczera for trying this all out
So you need TWRP for this, but will this overwrite the TWRP recovery and make it truly stock?
imp3r10 said:
So you need TWRP for this, but will this overwrite the TWRP recovery and make it truly stock?
Click to expand...
Click to collapse
Indeed and before rebooting , you MUST Wipe Data + Internal Storage, cuz you are flashing new boot and system and will get in conflicts if there no wipe.
Just for clarity sake these are the steps I need to take to get back to B20 from B20_Boot?
1. fastboot oem lock
2. put system image from OP's post AND stock_boot_backup.img AND stock_recovery_backup.img from rczrider's post into TWRP folder.
3. in TWRP unmount /system and check mark on mount system as read only.
4. Flash boot, recovery, and system image.
5. Wipe Data and Internal Storage.
6. Profit?
runderekrun said:
Just for clarity sake these are the steps I need to take to get back to B20 from B20_Boot?
1. fastboot oem lock
2. put system image from OP's post AND stock_boot_backup.img AND stock_recovery_backup.img from rczrider's post into TWRP folder.
3. in TWRP unmount /system and check mark on mount system as read only.
4. Flash boot, recovery, and system image.
5. Wipe Data and Internal Storage.
6. Profit?
Click to expand...
Click to collapse
Pretty much. I would reboot to stock recovery after and factory wipe from there. you might wan't to flash fastboot from B20 OTA for extra profit but seems like it's a moot point so far if you have seen the Unjustified Devs trick for BL unlock via TWRP
peramikic said:
Pretty much. I would reboot to stock recovery after and factory wipe from there. you might wan't to flash fastboot from B20 OTA for extra profit but seems like it's a moot point so far if you have seen the Unjustified Devs trick for BL unlock via TWRP
Click to expand...
Click to collapse
Thanks.
I'm having to do a warranty replacement on my device so i'll probably want to do the fastboot flash. Any idea where to get a fastboot image?
runderekrun said:
I'm having to do a warranty replacement on my device so i'll probably want to do the fastboot flash. Any idea where to get a fastboot image?
Click to expand...
Click to collapse
Step 6 to pull your own: http://forum.xda-developers.com/axon-7/how-to/guide-how-to-unlock-bootloader-stay-t3461165
Or you can download the one I pulled from my device (it can be found in the Mega folder linked in the OP): http://forum.xda-developers.com/axon-7/development/untouched-b20-boot-recovery-files-t3443818
And as option 3 it's inside the B18toB20 OTA file floating somewhere around here
Alright I tried this and something went wrong.
First thing I did was copy all the files where they needed to be. Then I booted into fastboot and did a "fastboot oem lock".
Then my device would do nothing. I would boot up to the ZTE logo then go black a second later. I tried to force into recovery by selecting recovery in fastboot but same thing, ZTE logo then blackness.
I got it back by getting into fastboot and performing a "fastboot oem unlock" again. All it did was wipe data.
What did I do wrong? I thought I am supposed to lock bootloader first before I restore system and flash recover and boot????
runderekrun said:
Alright I tried this and something went wrong.
First thing I did was copy all the files where they needed to be. Then I booted into fastboot and did a "fastboot oem lock".
Then my device would do nothing. I would boot up to the ZTE logo then go black a second later. I tried to force into recovery by selecting recovery in fastboot but same thing, ZTE logo then blackness.
I got it back by getting into fastboot and performing a "fastboot oem unlock" again. All it did was wipe data.
What did I do wrong? I thought I am supposed to lock bootloader first before I restore system and flash recover and boot????
Click to expand...
Click to collapse
Ok so if you modified boot, system or recovery in anyway then after BL lock it will not boot since it will fail secure boot, so you need to load the signed TWRP from tenfar's thread via EDL after locking. That will let you run TWRP with locked BL. Although ig you just want stock for upcoming OTA, then you might be good staying unlocked. If for return, then you should lock it
peramikic said:
Ok so if you modified boot, system or recovery in anyway then after BL lock it will not boot since it will fail secure boot, so you need to load the signed TWRP from tenfar's thread via EDL after locking. That will let you run TWRP with locked BL. Although ig you just want stock for upcoming OTA, then you might be good staying unlocked. If for return, then you should lock it
Click to expand...
Click to collapse
I apologize if I am fundamentaly not understanding this but wouldn't it be easier to flash system, boot, recovery, and fastboot back to stock via my current twrp THEN relock bootloader?
runderekrun said:
I apologize if I am fundamentaly not understanding this but wouldn't it be easier to flash system, boot, recovery, and fastboot back to stock via my current twrp THEN relock bootloader?
Click to expand...
Click to collapse
Yeah, now that we know fastboot will work even on stock boot that will work as well. The only thing you won't be able to do is flash back the B20 fastboot image that way, but enough to pass OTA most likely. The long way you can revert the fastboot image as well. I only wanted to post the image to begin with, but then wrote out instruction as they rolled around in my head. This will change soon anyways so a proper write-up will happen, just not by me, Documentation was never my forte
My BL is unlocked from ZTE right now, If I want to get CM for future but also want upcoming update from ZTE? What are the exact steps that I need to follow to get future OTA but also keep the BL unlocked for future CM? Please help as I'm confused with all these instructions.
peramikic said:
THIS APPLIES ONLY TO THE A2017U VARIANT, DO NOT USE THIS FILE ON OTHER VERSIONS
Disclaimer - don't blame me if something goes wrong
As title says, this is a full stock unmodified B20 TWRP system image. It kan be used in addition to stock boot and recovery images to restore the US A7 to conditions which will be like stock and allow to flash upcoming OTA. This was tested by @jkuczera here http://forum.xda-developers.com/showthread.php?t=3459107
Link to system image
https://cloud.swehes.com/index.php/s/31V7GgihohBCdfy
If you are BL unlocked, you will need to lock it before flashing old recovery and boot (this may not be necessary to get MR2 to flash, depending on what it checks, but the phone might not boot, unknown). This will make your phone verify boot, recovery and /system again, so flash TWRP from tenfar's thread to be able boot after relocking since his is signed
To restore, unzip the file above to TWRP folder on the SD Card, then in TWRP under mount points unmount /system and put check mark on mount system as read-only. The read-only part is important so that TWRP does not modify the /system apon exit. You can then restore boot, recovery and system image.
Another partition, fastboot, was altered if you applied B20_boot, but so far no OTA has check it so it should be fine as is. Chance is it will be just overwritten by next OTA, but in case that changes, info will be added. This step is more risky since it involves using dd command and has to be applied carefully.
EDIT: looks like @Unjustified Dev posted new build that will flash fastboot image http://forum.xda-developers.com/showpost.php?p=68677272&postcount=133
You should then boot to stock recovery and factory wipe
In case you did not dump your boot and recovery, they can be found in @rczrider's post here
http://forum.xda-developers.com/axon-7/development/untouched-b20-boot-recovery-files-t3443818
Thanks to @swehes for providing the space on his cloud for this file, @rczrider for rest of the files and @jkuczera for trying this all out
Click to expand...
Click to collapse
Can someone please explain exactly how to do this. I have an unofficial twrp on my phone and the bootloader is unlocked but after i tried to flash super su it got stuck on bootloop so I wiped every thing and I also accidentally wiped my os too. So now I don't have an os and I want to go back to stock. Can someone please explain step by step on how to fix this? I just got the phone.
seby1234 said:
Can someone please explain exactly how to do this. I have an unofficial twrp on my phone and the bootloader is unlocked but after i tried to flash super su it got stuck on bootloop so I wiped every thing and I also accidentally wiped my os too. So now I don't have an os and I want to go back to stock. Can someone please explain step by step on how to fix this? I just got the phone.
Click to expand...
Click to collapse
All right I'm no expert either but I'll try to make this as straightforward as possible.
1) Format your SD card as exFAT. This is important as otherwise you will not be able to transfer the system image to your SD card since it is 6GB. To do this you can just plug it in to your PC, right click, Format and then select exFAT from the dropdown.
2) Download tenfar's tool for B20, rczrider's boot and recovery backup, and the system image backup from the link in the OP.
3) Create a new folder in /external_sd/TWRP/BACKUPS/serial_number/.Move the stock_boot_backup and stock_recovery backup into the folder.
4) Using a program such as 7zip, extract the 6GB system image file and move it to the same folder.
6) Go to into fastboot mode. Before you do anything you have to relock the bootloader otherwise the system will be modified and you want to be 100? stock. Execute 'fastboot oem lock'. You should then boot to a black screen.
7) Unzip tenfar's tool. Go to the unzipped folder, then hold down shift+right click and select 'Open command window here'. Execute 'axon7root.exe -p [COMPORT #] -r. To figure out your com port #, go to Device Manager, then go to down to where it says "Qualcomm Loader..." and your com port number is the number at the end. So for example if your com port number is 5, you should execute axon7root.exe -p 5 -r. Allow the program to do its thing.
5) Boot into TWRP. Do not swipe to allow modifications. Once in TWRP, go to "Install", "Install Image" at the bottom right hand corner, and then navigate to the stock_recovery_backup in the folder that you moved it to to. Select it and then choose the Recovery partition to flash it to. Do the same thing for stock_boot_backup.
6) Once you have flashed boot and recovery, go to the main menu, then "Restore" and then Restore the system image backup.
7) Go to wipe and then slide to factory reset. Finally, reboot system.
Hope that helps! If you have any questions, feel free to ask me.
rczrider's stock boot and recovery thread
http://forum.xda-developers.com/axon-7/development/untouched-b20-boot-recovery-files-t3443818/page7
tenfar's tool thread: http://forum.xda-developers.com/axo...xon-7-root-bootloader-unlokced-t3441204/page1
Has anyone who requested the bootloader unlock from ZTE (and mistakenly installed it) returned to stock and been able to get OTA's? I followed this guide and seemed to have returned to stock fine but the only OTA I can get now is the bootloader unlock OTA. I've downloaded and discarded it several times but that is the only one I can get. Anyone know of a way to bypass this OTA and get the new MR2 that was just released? I want to get OTA's until the custom roms start flowing.
Thanks!
shifuharris said:
Has anyone who requested the bootloader unlock from ZTE (and mistakenly installed it) returned to stock and been able to get OTA's? I followed this guide and seemed to have returned to stock fine but the only OTA I can get now is the bootloader unlock OTA. I've downloaded and discarded it several times but that is the only one I can get. Anyone know of a way to bypass this OTA and get the new MR2 that was just released? I want to get OTA's until the custom roms start flowing.
Thanks!
Click to expand...
Click to collapse
From what I can tell, once you apply for official bootloader unlock, your IMEI is placed on a list that will not get any future OTA updates set to it.
However, the OTA for B20 to B27 has been uploaded here: https://mega.nz/#F!kYtRAJjJ!5tD1zPpo0nw2tJwhANA9pQ
Try flashing that via stock recovery.
Quick question for anyone who might know.
The Link to system image which is : https://cloud.swehes.com/index.php/s/31V7GgihohBCdfy has the following;
1. system_image.emmc.win
2. system_image.emmc.win.md5
Am I suppose to rename system_image.emmc.win to system_image.emmc.img and load?
it's not as clear that's why I ask but I ended up downloading rczrider system.img and reflashed via TWRP since I was a bit confused.
Thanks!
***************
I simply just went into TWRP backed up by boot so it would create a directory that contains the info I needed copied the system_image.emmc.win and system_image.emmc.win.md5 and restored.
xtermmin said:
From what I can tell, once you apply for official bootloader unlock, your IMEI is placed on a list that will not get any future OTA updates set to it.
However, the OTA for B20 to B27 has been uploaded here: https://mega.nz/#F!kYtRAJjJ!5tD1zPpo0nw2tJwhANA9pQ
Try flashing that via stock recovery.
Click to expand...
Click to collapse
I suspected as much. I downloaded the update and tried to flash it via the stock recovery using the update for ADB option but it fails saying that the package is not a ks package. Booooo. I really wanted this MR becasue they addressed the weak cell signal which I think contributes significantly to my battery drain. Not sure if there are any alternatives to get the update installed. Not very a happy about the ceased OTA's due to the bootloader unlock. Thinking the new Nexus (or whatever they are going to call them) is looking pretty good at the moment.
shifuharris said:
I suspected as much. I downloaded the update and tried to flash it via the stock recovery using the update for ADB option but it fails saying that the package is not a ks package. Booooo. I really wanted this MR becasue they addressed the weak cell signal which I think contributes significantly to my battery drain. Not sure if there are any alternatives to get the update installed. Not very a happy about the ceased OTA's due to the bootloader unlock. Thinking the new Nexus (or whatever they are going to call them) is looking pretty good at the moment.
Click to expand...
Click to collapse
Try the microSD card method instead.
First, make sure OEM Unlocking is checked in developer settings, rename the OTA to "update.zip", put on microSD, boot into stock recovery, and choose update from microSD.

[Pie/Oreo/Nougat] How to root your Z2 [ALL]

Since no guide has been updated with information on official TWRP for root and backup reasons, I thought I'd create one.
DISCLAIMER:
To do this method requires you to unlock your bootloader. Your warranty is now void. This method assumes you have basic knowledge of ADB and Fastboot commands and know how to recover your device if you accidentally type a wrong command and now boot to TWRP and can't boot to system. If you cannot recover from this, Read up on guides to "return to stock" and familiarize yourself on how to recover your device should something go wrong.
There are two methods for root. You can flash TWRP to your boot image to be able to reboot to TWRP without a PC, or just a temp boot so you can just have root and not TWRP. I'll put in brackets the minor differences.
1: Get ready
Download latest build of TWRP img file from their website.(Previous link is to their instructions and device specific patches, download page is HERE.) {download the latest zip if you want to flash TWRP}
Download what you want on your phone (SU, Magisk, etc)
2:
Hook phone up to your PC, be sure you have latest adb/fastboot drivers. (I do not support windows related questions. If you have latest drivers, you'll have no issue with the below commands, Linux just works for this kind of thing)
3:
Navigate to your directory that has that img downloaded. (windows, shift right click and say "open command prompt here")
Type the below commands, and terminal output should be similar: (I.E. this is a copy/paste of terminal)
Main thing to remember is "Fastboot boot {filename}.img"
Code:
[email protected]:~$ adb reboot bootloader
[email protected]:~$ cd Downloads
[email protected]:~/Downloads$ fastboot boot twrp-3.2.1-1-nash.img
downloading 'boot.img'...
OKAY [ 0.841s]
booting...
OKAY [ 5.135s]
finished. total time: 5.976s
[email protected]:~/Downloads$
BE SURE TO DO BOOT AND NOT FLASH!!! (If you ask why you can no longer boot to system, I'll let you know you missed this line.)
5:
You're now in TWRP!
It will ask you for your password. This is your PIN or password to unlock your phone. Enter it.
TWRP has now decrypted your storage to read the zip file(s) you put on your phone!
Go to install and navigate to your directory where you put that file
Install Magisk/SU/TWRP/whatever you please.
(Note: some root zips require a factory reset)
6:
Reboot!
You're Done congratulations!
Attached are images if they help you see you're doing the right thing.
Special thanks @erfanoabdi @invisiblek @npjohnson @joemossjr @jbats
Without the above people a lot of what's above woudn't have been possible for this device specifically. Also, thanks to everyone who pitched in to get a device over to invisiblek. Leaps and bounds have been done since that donation. And thanks to the other devs who have invested in this phone and their time to help out.
(Quoted from Nathan Chance)
Quite a few people have asked to donate to me in the past and I have turned them down. I am not in this for the money, this is my hobby, something I truly enjoy. If you truly want to donate to something (it is not expected in the slightest), I recommend an entity like the Open Source Initiative, the Free Software Foundation, XDA, or any one of the people I have thanked in the OP. Additionally, you are free to copy any and all of my work; the only thing I request is that you not ask for donations as well (though I can't really enforce this lol). Thank you.
Random issues post:
SU does some wonky edits to the ramdisk. It is highly suggested to flash Magisk for root.
Some have reported needing to wipe data after flashing Magisk. If you can't boot after flashing Magisk, just go back into recovery (can be twrp or stock) and wipe data/factory reset to boot again.
Note: we do not have a recovery partition. Never flash the img file! Download the flashable zip if you want twrp on your phone and flash per OP instructions.
Awesome thanks
I get into a bootloop and right back into TWRP using this method. I got the failed to mount data invalid argument. I got rid of this by formating data in TWRP. Now I get failed to mount system device or resource busy when I attempt to flash Magisk.
Bootloop.
I am on TMO running the latest 27.1 Oreo
droidgreg said:
I get into a bootloop and right back into TWRP using this method. I got the failed to mount data invalid argument. I got rid of this by formating data in TWRP. Now I get failed to mount system device or resource busy when I attempt to flash Magisk.
Bootloop.
I am on TMO running the latest 27.1 Oreo
Click to expand...
Click to collapse
Be sure to mount system under the "mount" button
I need the OCX27.1 oreo. I did a return to stock flashall to OCX27 and now reflashed TWRP and Magisk and boots fine but I lost baseband and IMEI
Added warning to OP that some root zips require a data wipe.
I apologize in advance for asking a question that may have an obvious answer, but will this work for the Verizon variant of the Z2 Force? I'm not interested in trying out different ROMs just yet, but I would like to be able to remove adds, bloatware, and go back to using FoxFi the way it was meant to be used, specifically as a wireless hotspot. I can use the hotspot feature built into the phone, but it caps at 15 gigs & gets reduced to low, low speed after. Thanks in advance. Oh, and I should mention I'm currently running Oreo.
will4958 said:
I apologize in advance for asking a question that may have an obvious answer, but will this work for the Verizon variant of the Z2 Force? I'm not interested in trying out different ROMs just yet, but I would like to be able to remove adds, bloatware, and go back to using FoxFi the way it was meant to be used, specifically as a wireless hotspot. I can use the hotspot feature built into the phone, but it caps at 15 gigs & gets reduced to low, low speed after. Thanks in advance. Oh, and I should mention I'm currently running Oreo.
Click to expand...
Click to collapse
This guide assumes you can unlock your bootloader. Since Verizon and AT&T feel they have a right to lock down their devices, this guide won't work. That is why I voted with my wallet and left Vz after my M7 due to them putting phone OEM's privates in a vice and forced them to lock out those carrier variants.
Has this method been tested with OCX27.1 Oreo on TMO?
droidgreg said:
Has this method been tested with OCX27.1 Oreo on TMO?
Click to expand...
Click to collapse
It probably hasn't been tested, but it should work in theory.
Uzephi said:
It probably hasn't been tested, but it should work in theory.
Click to expand...
Click to collapse
I was on 27.1 when I attempted to root and got into a bootloop and lost my baseband when I flashall back to stock OCX27. I have a feeling 27.1 update isn't compatible with this method and cannot be downgraded to even OCX 27 Oreo
so no go on 27.1 twrp? I have root on 27.1 TMO obtained post update. Obtained by fastbooting the nash twrp and running magisk 16.zip. No needing to format data or anything
I was just wondering about the installable twrp zip. I am coming from samsung development so all this A/B partitioning and some of the other partitions are new to me.
As soon as I can get twrp on the phone and feel comfortable recovering. The kernels and roms will start coming.
Feels strange not having odin to save my ass
droidgreg said:
Has this method been tested with OCX27.1 Oreo on TMO?
Click to expand...
Click to collapse
tested and working
mattlowry said:
tested and working
Click to expand...
Click to collapse
Have you actually flashed installer.zip to install TWRP or just booted TWRP and only flash magisk or SU for root without installing TWRP?
I fastboot booted the twrp. I didn't try the installer. What is it?
Doesn't work for me, i've done every step whitout problems but after installing SU and reboot, it wont boot anymore, stays in Moto logo.
luponcooper said:
Doesn't work for me, i've done every step whitout problems but after installing SU and reboot, it wont boot anymore, stays in Moto logo.
Click to expand...
Click to collapse
I'll put a warning about SU then. It also causes other stuff to not flash right. Suggested root is magisk for our device. Reflash your boot.img from the flash all and reroot with magisk then wipe data (wiping might not be needed, I never had to but some people have needed to).
Uzephi said:
I'll put a warning about SU then. It also causes other stuff to not flash right. Suggested root is magisk for our device. Reflash your boot.img from the flash all and reroot with magisk then wipe data (wiping might not be needed, I never had to but some people have needed to).
Click to expand...
Click to collapse
Thanks a lot uzephi for answering.
I have the 6gb ram and 64gb model, XT1789-05. I try whit no succes to install Magisk (Error1) so i made a factory reset but still doesn't boot, stays in M logo.
Im super noob, can you guide me? i dont know how to recover the boot.img.
excuse my english.

installing Magisk on Xiaomi A2 fails

First I unlocked the boot loader, although I doubt that’s needed for installing Magisk:
A2/Android (Oreo 8.1): Enabled developer options, enabled unlocking of boot loader, enabled debugging via USB.
PC/Linux: $ adb reboot bootloader
A2 boots into boot loader.
PC/Linux: $ fastboot oem unlock
Then I tried installing Magisk:
A2/Android: Re-enabled developer options, enabled debugging via USB, disabled automatic system updates (just in case, for later).
PC/Linux: $ adb reboot recovery
A2/Android: On the dialog asking for permission to allow USB debugging, selected to always allow from this computer and hit OK.
A2 displays screen with lying robot, saying No command. I held power, pressed volume-up once, released power.
A2 boots into recovery.
A2/Recovery: Selected Apply update from ADB.
PC/Linux:
$ adb sideload Magisk-v16.0.zip
Total xfer: 1.01x
A2/Recovery: Error message failed to verify whole-file signature
PC/Linux: Checked the zip file. It can be unzipped just fine, so it’s OK.
What else can I try?
PS: I do have detailed screen shots of the critical steps, but I don’t find an option to upload them to the forum.
You can't sideload the Magisk zip on a stock recovery. If you don't have a custom recovery installed you'll have to patch the boot image first with the Manager and then flash the patched image manually with fastboot. Check the installation instructions in the release thread.
Didgeridoohan said:
You can't sideload the Magisk zip on a stock recovery.
Click to expand...
Click to collapse
Thanks!
If you don't have a custom recovery installed you'll have to patch the boot image first with the Manager and then flash the patched image manually with fastboot. Check the installation instructions in the release thread.
Click to expand...
Click to collapse
Tried that, but did something extremely stupid in the process, knowing full on that this could cause an issue (I assumed things are easy to fix in case something goes wrong):
I did not run any system updates, leaving the Android 8.1 ROM at V9.6.5.0. (no problem so far)
I downloaded V9.6.10.0 of the ROM, and had Magisk patch the included boot.img to create patched_boot.img (still no problem)
I flashed patched_boot.img onto my A2. Now the device did not boot anymore. It hung at the loader animation showing a horizontal bar with varying colors.
To get the A2 to boot again, I obtained V9.6.9.0 of the ROM, I flashed the included boot.img, and I cleared the cache. Unfortunately, while the device boots into Android now, I cannot enable WLAN. It simply doesn’t work. Again, no surprise: V9.6.9.0 ≠ V9.6.5.0
Not being able to find the V9.6.5.0 ROM, I got the idea to update the half broken A2 to the latest ROM, i.e. V9.6.10.0. But how, without WLAN? Well, I found out that it is possible to use the WLAN connection of another Android device via Bluetooth. This is what I used, and I had to be very patient – it’s dog slow. Anyhow, I waited, and the installer started to do its job. The download succeeded, but the installation failed.
Phew, for now I’m out of options, and I’ve a non functioning device.
In another thread on the XDA Forums, I did find an unofficial dump of V9.6.5.0. But 1. I’m hesitant to install from unofficial dumps, and 2. the dump does not include a boot.img. Instead it includes one big payload.bin. Don’t know what to make out of that.
The alternative could be to install either V9.6.10.O or V9.6.9.O manually, possibly by flashing each partition image individually from fastboot. I don’t know, however, if that is a great idea.
PS: Sorry about the confusion with all those numbers.
Oh man... Flashing an update manually (each partition should work fine) is probably a good idea at this point.
Didgeridoohan said:
Oh man... Flashing an update manually (each partition should work fine) is probably a good idea at this point.
Click to expand...
Click to collapse
Went ahead with that. In fact, included in the full ROM archive are scripts for doing the update, sorted by an increasing number of steps performed:
flash_all_except_data.sh
flash_all.sh
flash_all_lock.sh
flash_all_lock_crc.sh
The last one also flashes CRC check sums into crclist and sparsecrclist. Included is a script to generate these check sums form the image files: flash_gen_crc_list.py
Here’s how I got back to a system that boots up fine:
PC/Linux: $ tar xfz jasmine_global_images_V9.6.10.0.ODIMIFE_20180731.0000.00_8.1_2aeda83301.tgz
PC/Linux: $ cd jasmine_global_images_V9.6.10.0.ODIMIFE_8.1
PC/Linux: $ fastboot flashing unlock
(reboot)
PC/Linux: $ fastboot flashing unlock_critical
(possibly reboot again)
PC/Linux: $ ./flash_all_lock_crc.sh
(went through smoothly, flashing CRC possibly not necessary)
Following this success, I did another attempt at installing Magisk:
PC/Linux: $ cp ../patched_boot.img images/boot.img
(created with Magisk Manager from the V9.6.10.0 boot.img)
PC/Linux: $ python2.7 flash_gen_crc_list.py
(thought it’s a good idea, but doesn’t help – see below)
PC/Linux: $ fastboot flashing unlock
(reboot)
PC/Linux: $ fastboot flashing unlock_critical
(possibly reboot again)
PC/Linux: $ ./flash_all_lock_crc.sh
(went through smoothly, flashing CRC possibly not necessary)
Unfortunately, upon reboot I get:
Code:
<!>
Your device is corrupt. It can’t be trusted
and will not boot
Visit this link on another device:
g.co/ABH
Eventually the device doesn’t show the message anymore, instead hanging permanently at a androidone logo.
Not locking the boot loader after flashing solves the issue, but: For security reasons, I don’t want to use a device with an unlocked boot loader!
Any idea?
Uh-oh! Now it seems like I eclipsed my previous stupidity.
In the Android developer settings, I disabled OEM unlocking. Then I rebooted the device, locked the boot loader: fastboot oem lock This was still possible.
As result, I get the aforementioned error message:
Code:
<!>
Your device is corrupt. It can’t be trusted
and will not boot
Visit this link on another device:
g.co/ABH
But now I cannot unlock the device anymore. fastboot oem unlock gives: FAILED (remote: Flashing Unlock is not allowed)
Bricked for good, right? :crying:
Oh... I saw your first message about getting things working (post #5), but I didn't have time to answer (work, work, work).
Now I wished I would have had the time, since I would have posted that you should never lock your bootloader on a modded device. The risk of something going wrong and not being able to unlock the bootloader again is too great...
If you're lucky there's still some kind of hack available that you can use, but you'd have to take that in your device's forum, where they know the device best.
That sucks... I hope you get things sorted. Good luck.
Didgeridoohan said:
Now I wished I would have had the time, […]
Click to expand...
Click to collapse
Don’t worry. I like to take systems to their limit.
[…] since I would have posted that you should never lock your bootloader on a modded device.
Click to expand...
Click to collapse
For security reasons, I don’t like the idea of leaving the boot loader open. While I understand that – due to encryption – it’s not possible to access my data, I assume it would be feasible to modify boot.img to install a rootkit in a few minutes. Just the thought of this being possible makes me uncomfortable and not trust the device for productivity use.
I wonder if I would also get the your device is corrupt message with Lineage installed.
If you're lucky there's still some kind of hack available
Click to expand...
Click to collapse
Yes, I’m betting on that, or perhaps the Xiaomi Mi Flash Tool can be used. (looking for an official download location)
feklee said:
I wonder if I would also get the your device is corrupt message with Lineage installed.
Click to expand...
Click to collapse
Did you preserve dm-verity when you patched the boot image? That sounds like dm-verity complaining...
Didgeridoohan said:
Did you preserve dm-verity when you patched the boot image? That sounds like dm-verity complaining...
Click to expand...
Click to collapse
No:
I’m almost certain that I did not enable dm-verity.
The device is corrupt message appears right after the reboot following ./flash_all_lock.sh or ./flash_all_lock_crc.sh, i.e. without any setup by Magisk Manager, and dm-verity is disabled by default.
BTW I got around to trying Xiaomi Mi Flash Tool, but it’s useless: It seems to be simply an ugly GUI for the fastboot commands. It cannot flash a device in locked state. In the end I was able to revive the device by opening it and using the test point method. Phew, gotta be more careful the next time…

Question Help: your device is corrupted and cannot be trusted and will not boot

Situation:
I tried rooting my phone. I extracted the boot.img with payloaddumper from the latest android 11 Zenfone 8 image from the Asus website (the same version I have on my phone). I patched that image file with Magisk. Flashed that file to my phone with fastboot which succeeded. But after rebooting this is the message I get:
"Your device is corrupted and cannot be trusted and will not boot" and than a link to g.co/ABH
There is no option to "press power to continue" as seen on other screenshots of this problem on YouTube. So I am stuck. I cannot enter recovery. It tries to boot a few times but than stays at the "start" screen while booting.
What I tried to fix this:
Internet states that I have to disable DM check with: adb reboot "dm-verity enforcing". But ADB does not see my device. Fastboot does! So I tried flashing back the original/unpatched boot.img but the result stays the same.
Question:
What can I do to fix this? Also flash Vendor_boot.img? At this moment I rather not do too much but wait for advice/tips in this forum.
And a few "stupid" questions:
- When trying to root the method described here in this forum..... does the bootloader have to be unlocked? My is not.
- IF the bootloader has to be open.... I know I have to use an Asus tool.... but is there a way to do it with ADB/Fastboot?
- When it is necessary to flash my whole device.... is there a way to save my data? (for example flash trwp first and back up data to a thumbdrive)
Any help much appreciated!
>>does the bootloader have to be unlocked
Yes
>>but is there a way to do it with ADB/Fastboot?
No. Only to relock. Or at least I haven't seen such method.
>>When it is necessary to flash my whole device
What do you mean?
>>is there a way to save my data?
If you have root and mean apps data - Swift backup. For me it is failed to restore only few apps (banking + Signal messenger) all other apps are ok.
dron39 said:
>>does the bootloader have to be unlocked
Yes
Click to expand...
Click to collapse
Ok.... bummer..... the device was not unlocked....... So NOT being unlocked did not prevent the flashing I guess. And a locked bootloader is preventing disabling the DM check?
dron39 said:
>>When it is necessary to flash my whole device
What do you mean?
Click to expand...
Click to collapse
If undoing my flash/error (= no unlocked bootloader) is not possible. I have to do a complete reflash I guess. So that would wipe all data. I was wondering if I could flash only parts of the system so some partitions would be spared (so I could save some data..... or install TWRP and maybe save some data)
dron39 said:
>>is there a way to save my data?
If you have root and mean apps data - Swift backup. For me it is failed to restore only few apps (banking + Signal messenger) all other apps are ok.
Click to expand...
Click to collapse
Root was the goal. But that did not happen yet because of the locked bootloader as I understand it now. So no root = no backup/saving data?
If I download the last OTA update my phone recieved, extract boot.img from it and flash that to my phone with fastboot will that restore my phone to a bootable state? If not,what will?

Categories

Resources