Unlock code after factory reset

MaEdCo

Senior Member
Jul 27, 2011
184
13
0
Hello, my phone was stolen a year ago, and now the police recover it, so I do a factory reset, then login with my MI account but it keeps me asking a code to unlock after factory reset that I don't have, I try to log in also with my Gmail account linked to the device but still keeps me asking a code to unlock, I try with the xiaomi chat support but no luck, they told me that write an email to account-service at xiaomi.com , but I've been waiting a week and still no answer, so I hope someone helps me, thanks a lot
 

Attachments

Last edited:

drnightshadow

Senior Member
Dec 4, 2008
628
309
93
Hello, my phone was stolen a year ago, and now the police recover it, so I do a factory reset, then login with my MI account but it keeps me asking a code to unlock after factory reset that I don't have, I try to log in also with my Gmail account linked to the device but still keeps me asking a code to unlock, I try with the xiaomi chat support but no luck, they told me that write an email to account-service at xiaomi.com , but I've been waiting a week and still no answer, so I hope someone helps me, thanks a lot
Search on XDA forum, how to flash persist partition. It will delete all mi accounts, etc.
Or do factory reset under recovery, thats easier.
Good luck.
 
Last edited:
  • Like
Reactions: MaEdCo

MaEdCo

Senior Member
Jul 27, 2011
184
13
0
Search on XDA forum, how to flash persist partition. It will delete all mi accounts, etc.
Or do factory reset under recovery, thats easier.
Good luck.
So I go for this option, find how to do that, I have to download all the fastboot ROM MIU10 that is the version already installed on the phone, just the get the persist.img file of my phone, then install adb tools, then I get the "Press any key to shut down" error on fastboot, switch to USB 3.0 port to USB 2.0 port and run this bat file:

try this solution:
use a USB 2 port
create a new txt file,write code in the { } below
{
@Echo off
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\18D1D00D0100" /v "osvc" /t REG_BINARY /d "0000" /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\18D1D00D0100" /v "SkipContainerIdQuery" /t REG_BINARY /d "01000000" /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\18D1D00D0100" /v "SkipBOSDescriptorQuery" /t REG_BINARY /d "01000000" /f


pause
}
then save this file and rename it as a .bat file
right click and run as administrator.
after that the issue can be fixed
then:

Code:
C:\WINDOWS\system32>fastboot erase persist.img
erasing 'persist.img'...
FAILED (remote: Anti-rollback check failed)
finished. total time: 0.004s
then

Code:
C:\WINDOWS\system32>fastboot getvar anti
anti: 4
finished. total time: 0.001s
then read this topic:

https://forum.xda-developers.com/redmi-note-5-pro/how-to/index-everything-anti-roll-t3816219

Code:
C:\adb>fastboot flash antirbpass dummy.img
target reported max download size of 536870912 bytes
sending 'antirbpass' (8 KB)...
OKAY [  0.004s]
writing 'antirbpass'...
OKAY [  0.001s]
finished. total time: 0.009s

C:\adb>fastboot flash recovery twrp-3.2.3-2-whyred.img
target reported max download size of 536870912 bytes
sending 'recovery' (36616 KB)...
OKAY [  0.797s]
writing 'recovery'...
FAILED (remote: Flashing is not allowed in Lock State)
finished. total time: 0.802s

C:\adb>fastboot oem unlock
...
FAILED (remote: Token Verify Failed, Reboot the device
)
finished. total time: 0.003s
then try to unlock through MiFlash Utility and I get:
In the Developer options, go to the “Mi Unlock Status” and tap on “Add account and device” in order to authorize Xiaomi to unlock the device associated with the account.
but I can't do that 'cause it keeps me asking a code after factory reset


Or do factory reset under recovery, thats easier.
Good luck.
could you please elaborate?
 

drnightshadow

Senior Member
Dec 4, 2008
628
309
93
So I go for this option, find how to do that, I have to download all the fastboot ROM MIU10 that is the version already installed on the phone, just the get the persist.img file of my phone, then install adb tools, then I get the "Press any key to shut down" error on fastboot, switch to USB 3.0 port to USB 2.0 port and run this bat file:



then:



then



then read this topic:

https://forum.xda-developers.com/redmi-note-5-pro/how-to/index-everything-anti-roll-t3816219



then try to unlock through MiFlash Utility and I get: but I can't do that 'cause it keeps me asking a code after factory reset




could you please elaborate?
Try here
https://forum.xda-developers.com/re.../tutorial-fix-sensors-wifi-bluetooth-t3823622
 
  • Like
Reactions: MaEdCo

drnightshadow

Senior Member
Dec 4, 2008
628
309
93
I guess you did not read my whole post, I have the Bootloader locked and I do not have Twrp installed

so I can not do the steps you mention
You can patch original MIUI fastboot ROM to overwrite persist partition... yeah you need to figure it out how to do it... unlock bootloader is a must to do so....
Ok, can you try to boot it in recovery mode (vol + POWER I think or try vol - and power) and than do factory reset...
Its a long time ago I have same problem (cca 2,5 years ago and it was my phone who locked me out)...
Ill check my repos on my PC tomorrow at work if I still have all the info how I did it. Solution I found is on XDA forums.
Stay tuned...ill try to help you out ....
 
Last edited:
  • Like
Reactions: MaEdCo

MaEdCo

Senior Member
Jul 27, 2011
184
13
0
You can patch original MIUI fastboot ROM to overwrite persist partition... yeah you need to figure it out how to do it... unlock bootloader is a must to do so....
trust me I read a lot but still I do not how to unlock the bootloader
Ok, can you try to boot it in recovery mode (vol + POWER I think or try vol - and power) and than do factory reset...
thats what I did on first place, boot on recovery mode (stock recovery) and then factory reset, wipe all data, and then the phone ask me for a code
Its a long time ago I have same problem (cca 2,5 years ago and it was my phone who locked me out)...
Ill check my repos on my PC tomorrow at work if I still have all the info how I did it. Solution I found is on XDA forums.
Stay tuned...ill try to help you out ....
I hope so, thanks
 

drnightshadow

Senior Member
Dec 4, 2008
628
309
93
trust me I read a lot but still I do not how to unlock the bootloader


thats what I did on first place, boot on recovery mode (stock recovery) and then factory reset, wipe all data, and then the phone ask me for a code


I hope so, thanks
Ok I think I remembered something... you are saying bootloader is locked and for flashing you need code...
read this MIFLASH METOD
https://forum.xda-developers.com/redmi-note-5-pro/how-to/fix-arb-bricked-device-qfil-t3841780
But that's just 1st step... download patch and ROM...In your case.. BE CAREFUL!!! DOWNLOAD ABR 4 ROMS ONLY!!!!
Edit 1: You can also read this ,I linked tread just because of video in 2nd post
https://forum.xda-developers.com/re...ccessful-redmi-note-5-pro-bypass-edl-t3843173
I'll remember... yes I will :laugh:
Edit 2: Than you need also patch xml to flash persist partition.. will find this to
damn it I'm old lool.
Edit 3: Ha ha I found it
https://forum.xda-developers.com/redmi-note-5-pro/how-to/remove-mi-account-redmi-phone-t4063921
that's 2nd step.
Now all you need to do is flashing MIUI ROM(patched/modified) with MI FLASH TOOL... I would recommend for 1st try only step 2 (last link) and if it wont work than combine 1st and 2nd step.
Good luck and stay safe.
 
Last edited:
  • Like
Reactions: MaEdCo

MaEdCo

Senior Member
Jul 27, 2011
184
13
0
Ok I think I remembered something... you are saying bootloader is locked and for flashing you need code...
read this MIFLASH METOD
https://forum.xda-developers.com/redmi-note-5-pro/how-to/fix-arb-bricked-device-qfil-t3841780
But that's just 1st step... download patch and ROM...In your case.. BE CAREFUL!!! DOWNLOAD ABR 4 ROMS ONLY!!!!
Edit 1: You can also read this ,I linked tread just because of video in 2nd post
https://forum.xda-developers.com/re...ccessful-redmi-note-5-pro-bypass-edl-t3843173
I'll remember... yes I will :laugh:
Edit 2: Than you need also patch xml to flash persist partition.. will find this to
damn it I'm old lool.
Edit 3: Ha ha I found it
https://forum.xda-developers.com/redmi-note-5-pro/how-to/remove-mi-account-redmi-phone-t4063921
that's 2nd step.
Now all you need to do is flashing MIUI ROM(patched/modified) with MI FLASH TOOL... I would recommend for 1st try only step 2 (last link) and if it wont work than combine 1st and 2nd step.
Good luck and stay safe.
thanks a lot, but can not find the patch0.xml file on the post

I use the Mi Flash Tool 2018 and the 10.3 fastboot room, patched with edited rawprogram0.xml file and prog_emmc_firehose_Sdm660_ddr file

and I get this:

Flash xbl error
 

Attachments

drnightshadow

Senior Member
Dec 4, 2008
628
309
93
thanks a lot, but can not find the patch0.xml file on the post

I use the Mi Flash Tool 2018 and the 10.3 fastboot room, patched with edited rawprogram0.xml file and prog_emmc_firehose_Sdm660_ddr file

and I get this:

Flash xbl error
Ohh, that bootloader error :rolleyes:
Reset device and try again (try multiple times)
Yah I had some weird errors to. Sometimes its working on a 1st try and sometimes in a xxx times.
Just one question.. was your phone opened ? Check it really close... if it was than EDL mode was used.
Hope you'll solve this soon.
Edit 1: patch0.XML is for QFIL METHOD. I never used it.
Good luck!
 
Last edited:
  • Like
Reactions: MaEdCo

MaEdCo

Senior Member
Jul 27, 2011
184
13
0
Ohh, that bootloader error :rolleyes:
Reset device and try again (try multiple times)
Yah I had some weird errors to. Sometimes its working on a 1st try and sometimes in a xxx times.
Just one question.. was your phone opened ? Check it really close... if it was than EDL mode was used.
Hope you'll solve this soon.
Edit 1: patch0.XML is for QFIL METHOD. I never used it.
Good luck!

so I tried multiple times with Mi Flash Tool with no luck

si I tried with the QFIL Method, after a lot of reading, finally get to do the test point, and with this method I was able to flash the MIUI 9 rom with the persist.img file, but still the phone is locked:crying: so strange, I believe the old persist.img file was erased but it is not :(
 

drnightshadow

Senior Member
Dec 4, 2008
628
309
93
so I tried multiple times with Mi Flash Tool with no luck

si I tried with the QFIL Method, after a lot of reading, finally get to do the test point, and with this method I was able to flash the MIUI 9 rom with the persist.img file, but still the phone is locked:crying: so strange, I believe the old persist.img file was erased but it is not :(
So you used EDL MODE... did you flashed with MI Flasher? If you used QFIL it's just for reviving the phone.
Use patched(persist) ROM with MI Flasher and use EDL mode.
 
  • Like
Reactions: MaEdCo

MaEdCo

Senior Member
Jul 27, 2011
184
13
0
So you used EDL MODE... did you flashed with MI Flasher? If you used QFIL it's just for reviving the phone.
Use patched(persist) ROM with MI Flasher and use EDL mode.
so if EDL Mode is do the test point, and wait the pc detects it as qualcom loader and some COM port yes

yes I also used Mi Flash Tool from 2018, yes I used the patched ROM with the persist.img file and still the same, the phone is locked, keeps me asking the MI Accounts credentials and then the unlock code after factory reset:(