How to re-lock bootlader

bionemesis

Senior Member
Mar 16, 2010
136
24
0
Calgary
Just wanted to make a complete post of how I just did this, as it combines information from 3 different posts.

Step 1: Download the latest factory image and extract the ZIP file to a folder of your choice.
Step 2: Boot the phone into fastboot mode and run the following against the files extracted from the ZIP file:

Code:
fastboot flash partition gpt.bin
fastboot flash bootloader bootloader.img
fastboot flash logo logo.bin
fastboot flash boot boot.img
fastboot flash recovery recovery.img
fastboot flash dsp adspso.bin
fastboot flash oem oem.img
fastboot flash system system.img_sparsechunk.0
fastboot flash system system.img_sparsechunk.1
fastboot flash system system.img_sparsechunk.2
fastboot flash system system.img_sparsechunk.3
fastboot flash system system.img_sparsechunk.4
fastboot flash system system.img_sparsechunk.5
fastboot flash system system.img_sparsechunk.6
fastboot flash system system.img_sparsechunk.7
fastboot flash system system.img_sparsechunk.8
fastboot flash system system.img_sparsechunk.9
fastboot flash system system.img_sparsechunk.10
fastboot flash system system.img_sparsechunk.11
fastboot flash system system.img_sparsechunk.12
fastboot flash system system.img_sparsechunk.13
fastboot flash system system.img_sparsechunk.14
fastboot flash system system.img_sparsechunk.15
fastboot flash system system.img_sparsechunk.16
fastboot flash system system.img_sparsechunk.17
fastboot flash modem NON-HLOS.bin
fastboot erase modemst1
fastboot erase modemst2
fastboot flash fsg fsg.mbn
fastboot erase cache
fastboot erase userdata
fastboot erase customize
fastboot erase clogo
fastboot reboot
Please note that the second last one (fastboot erase clogo) will likely fail.

Step 3: Boot into your phone and walk through the wizard just enough to get to the home screen. Don't bother signing in with your account, just skip everything.
Step 4: Boot your phone into fastboot mode again.
Step 5: Run the following:

Code:
fastboot flash boot boot.img
fastboot flash oem oem.img
fastboot flash system system.img_sparsechunk.0
fastboot flash system system.img_sparsechunk.1
fastboot flash system system.img_sparsechunk.2
fastboot flash system system.img_sparsechunk.3
fastboot flash system system.img_sparsechunk.4
fastboot flash system system.img_sparsechunk.5
fastboot flash system system.img_sparsechunk.6
fastboot flash system system.img_sparsechunk.7
fastboot flash system system.img_sparsechunk.8
fastboot flash system system.img_sparsechunk.9
fastboot flash system system.img_sparsechunk.10
fastboot flash system system.img_sparsechunk.11
fastboot flash system system.img_sparsechunk.12
fastboot flash system system.img_sparsechunk.13
fastboot flash system system.img_sparsechunk.14
fastboot flash system system.img_sparsechunk.15
fastboot flash system system.img_sparsechunk.16
fastboot flash system system.img_sparsechunk.17
fastboot oem lock
And that's it! Your phone will automatically reboot after the last command a re-locked bootloader awaits.
 
Last edited:

Spaniard89

Member
Aug 24, 2016
14
5
0
Just wanted to make a complete post of how I just did this, as it combines information from 3 different posts.

Step 1: Download the latest factory image and extract the ZIP file to a folder of your choice.
Step 2: Boot the phone into fastboot mode and run the following against the files extracted from the ZIP file:

Code:
fastboot flash partition gpt.bin
fastboot flash bootloader bootloader.img
fastboot flash logo logo.bin
fastboot flash boot boot.img
fastboot flash recovery recovery.img
fastboot flash dsp adspso.bin
fastboot flash oem oem.img
fastboot flash system system.img_sparsechunk.0
fastboot flash system system.img_sparsechunk.1
fastboot flash system system.img_sparsechunk.2
fastboot flash system system.img_sparsechunk.3
fastboot flash system system.img_sparsechunk.4
fastboot flash system system.img_sparsechunk.5
fastboot flash system system.img_sparsechunk.6
fastboot flash system system.img_sparsechunk.7
fastboot flash system system.img_sparsechunk.8
fastboot flash system system.img_sparsechunk.9
fastboot flash system system.img_sparsechunk.10
fastboot flash system system.img_sparsechunk.11
fastboot flash system system.img_sparsechunk.12
fastboot flash system system.img_sparsechunk.13
fastboot flash system system.img_sparsechunk.14
fastboot flash system system.img_sparsechunk.15
fastboot flash system system.img_sparsechunk.16
fastboot flash system system.img_sparsechunk.17
fastboot flash modem NON-HLOS.bin
fastboot erase modemst1
fastboot erase modemst2
fastboot flash fsg fsg.mbn
fastboot erase cache
fastboot erase userdata
fastboot erase customize
fastboot erase clogo
fastboot reboot
Please note that the second last one (fastboot erase clogo) will likely fail.

Step 3: Boot into your phone and walk through the wizard just enough to get to the home screen. Don't bother signing in with your account, just skip everything.
Step 4: Boot your phone into fastboot mode again.
Step 5: Run the following:

Code:
fastboot flash boot boot.img
fastboot flash oem oem.img
fastboot flash system system.img_sparsechunk.0
fastboot flash system system.img_sparsechunk.1
fastboot flash system system.img_sparsechunk.2
fastboot flash system system.img_sparsechunk.3
fastboot flash system system.img_sparsechunk.4
fastboot flash system system.img_sparsechunk.5
fastboot flash system system.img_sparsechunk.6
fastboot flash system system.img_sparsechunk.7
fastboot flash system system.img_sparsechunk.8
fastboot flash system system.img_sparsechunk.9
fastboot flash system system.img_sparsechunk.10
fastboot flash system system.img_sparsechunk.11
fastboot flash system system.img_sparsechunk.12
fastboot flash system system.img_sparsechunk.13
fastboot flash system system.img_sparsechunk.14
fastboot flash system system.img_sparsechunk.15
fastboot flash system system.img_sparsechunk.16
fastboot flash system system.img_sparsechunk.17
fastboot oem lock
And that's it! Your phone will automatically reboot after the last command a re-locked bootloader awaits.

In the step 5, following has to be executed first:
Code:
fastboot oem lock begin
fastboot oem lock begin
 

jmc86

Member
May 6, 2010
7
0
0
In the step 5, following has to be executed first:
Code:
fastboot oem lock begin
fastboot oem lock begin

just tried this and was stuck with "still require signed boot.img" until after step 3 I turned on developer options and usb debugging on. I was then able to lock bootloader.
 

edzilla

Senior Member
Jan 14, 2007
175
12
0
Just wanted to make a complete post of how I just did this, as it combines information from 3 different posts.

Step 1: Download the latest factory image and extract the ZIP file to a folder of your choice.
Step 2: Boot the phone into fastboot mode and run the following against the files extracted from the ZIP file:

Code:
fastboot flash partition gpt.bin
fastboot flash bootloader bootloader.img
fastboot flash logo logo.bin
fastboot flash boot boot.img
fastboot flash recovery recovery.img
fastboot flash dsp adspso.bin
fastboot flash oem oem.img
fastboot flash system system.img_sparsechunk.0
fastboot flash system system.img_sparsechunk.1
fastboot flash system system.img_sparsechunk.2
fastboot flash system system.img_sparsechunk.3
fastboot flash system system.img_sparsechunk.4
fastboot flash system system.img_sparsechunk.5
fastboot flash system system.img_sparsechunk.6
fastboot flash system system.img_sparsechunk.7
fastboot flash system system.img_sparsechunk.8
fastboot flash system system.img_sparsechunk.9
fastboot flash system system.img_sparsechunk.10
fastboot flash system system.img_sparsechunk.11
fastboot flash system system.img_sparsechunk.12
fastboot flash system system.img_sparsechunk.13
fastboot flash system system.img_sparsechunk.14
fastboot flash system system.img_sparsechunk.15
fastboot flash system system.img_sparsechunk.16
fastboot flash system system.img_sparsechunk.17
fastboot flash modem NON-HLOS.bin
fastboot erase modemst1
fastboot erase modemst2
fastboot flash fsg fsg.mbn
fastboot erase cache
fastboot erase userdata
fastboot erase customize
fastboot erase clogo
fastboot reboot
Please note that the second last one (fastboot erase clogo) will likely fail.

Step 3: Boot into your phone and walk through the wizard just enough to get to the home screen. Don't bother signing in with your account, just skip everything.
Step 4: Boot your phone into fastboot mode again.
Step 5: Run the following:

Code:
fastboot flash boot boot.img
fastboot flash oem oem.img
fastboot flash system system.img_sparsechunk.0
fastboot flash system system.img_sparsechunk.1
fastboot flash system system.img_sparsechunk.2
fastboot flash system system.img_sparsechunk.3
fastboot flash system system.img_sparsechunk.4
fastboot flash system system.img_sparsechunk.5
fastboot flash system system.img_sparsechunk.6
fastboot flash system system.img_sparsechunk.7
fastboot flash system system.img_sparsechunk.8
fastboot flash system system.img_sparsechunk.9
fastboot flash system system.img_sparsechunk.10
fastboot flash system system.img_sparsechunk.11
fastboot flash system system.img_sparsechunk.12
fastboot flash system system.img_sparsechunk.13
fastboot flash system system.img_sparsechunk.14
fastboot flash system system.img_sparsechunk.15
fastboot flash system system.img_sparsechunk.16
fastboot flash system system.img_sparsechunk.17
fastboot oem lock
And that's it! Your phone will automatically reboot after the last command a re-locked bootloader awaits.
I agree with the other posters here.
I had to:
at the end of step 3:
go to developers options and turn on USB debugging.
Before step 5:
Code:
fastboot oem lock begin
fastboot oem lock begin
After that phone is back to locked
 

knjigo

Senior Member
Apr 17, 2009
148
12
0
Split
I get error at the first line (flashing gpt.bin)

"Preflash validation failed"
"Security downgrade"

I get this with the latest firmware that I found.
Should I just ignore this message and keep going?
 

knjigo

Senior Member
Apr 17, 2009
148
12
0
Split
Always skip gpt and bootloader flashing. It won't work.
Yes i skipped these.

Tried to flash this one XT1650-03_GRIFFIN_RETEU-EMEA_MPL24.246-17_cid50_subsidy-DEFAULT_regulatory-03_CFC_EMEA.xml

i get error at boot.img also (not signed or corrupt)

As result, i have bootloop.

It stuck at warning about unlocked bootloader, and thats all. It started again.

---------- Post added at 04:21 PM ---------- Previous post was at 03:55 PM ----------

I flashed retbr image with no problem.
Started the phone. Worked everything fine.
then i started the last step with

fastboot oem lock begin (twice)
after that i get error on everything i tried to flash

like this:

(bootloader) Security version downgrade
(bootloader) Image boot failed validation
(bootloader) Preflash validation failed
FAILED (remote failure)
 

Loader009

Senior Member
Jul 6, 2012
711
197
63
If you had once stock Nougat on the Moto Z, you can't flash Marshmallow. (MPL indicates a Marshmallow ROM)

Look for a Nougat ROM, you can also flash RETBR on RETEU devices (did this already).

edit: Dunno on your current problem, never relocked the bootloader.
 

m0ritz

Senior Member
Sep 15, 2011
62
8
0
Okay since my build number is: NPLS26.118-20-5-3 I downloaded "XT1650-03_GRIFFIN_RETAIL_7.1.1_NPLS26.118-20-5-3_cid50_subsidy-DEFAULT_regulatory-DEFAULT_CFC.xml.zip" ... I followed the flash instructions on here but
fastboot flash partition gpt.bin
fastboot flash bootloader bootloader.img

will not work I always get an error message:

C:\Program Files (x86)\Minimal ADB and Fastboot>fastboot flash partition gpt.bin
(bootloader) slot-count: not found
(bootloader) slot-suffixes: not found
(bootloader) slot-suffixes: not found
(bootloader) has-slot:partition: not found
target reported max download size of 536870912 bytes
sending 'partition' (142 KB)...
OKAY [ 0.007s]
writing 'partition'...
(bootloader) Validating 'gpt.default.xml'
(bootloader) Security version downgrade
(bootloader) Image primary_gpt failed validation
(bootloader) Preflash validation failed
(bootloader) Security version downgrade
(bootloader) Image primary_gpt failed validation
(bootloader) Preflash validation failed
(bootloader) Security version downgrade
(bootloader) Image primary_gpt failed validation
(bootloader) Preflash validation failed
(bootloader) Security version downgrade
(bootloader) Image primary_gpt failed validation
(bootloader) Preflash validation failed
(bootloader) Cancelling 'gpt.default.xml'
FAILED (remote failure)
finished. total time: 0.190s

C:\Program Files (x86)\Minimal ADB and Fastboot>fastboot flash bootloader bootloader.img
(bootloader) slot-count: not found
(bootloader) slot-suffixes: not found
(bootloader) slot-suffixes: not found
(bootloader) has-slot:bootloader: not found
target reported max download size of 536870912 bytes
sending 'bootloader' (7792 KB)...
OKAY [ 0.236s]
writing 'bootloader'...
(bootloader) Validating 'bootloader.default.xml'
(bootloader) Security version downgrade
(bootloader) Image aboot failed validation
(bootloader) Preflash validation failed
(bootloader) Security version downgrade
(bootloader) Image pmic failed validation
(bootloader) Preflash validation failed
(bootloader) Cancelling 'bootloader.default.xml'
FAILED (remote failure)
finished. total time: 0.520s
and nothing works ... The phone will normaly start - bootloader still unlocked.

And since that does not work, anything after
fastboot oem lock begin
fastboot oem lock begin
does not work either.
 

angourakis

Senior Member
Aug 16, 2010
225
116
0
São Paulo
It means you had an updated version on your phone and now you're trying to restore an older version.
I advise you to wait until an updated version is available or you risk bricking your device.

PS: Now that I read your version, you may try with this one: https://rsdsecure-cloud.motorola.co...ubsidy-DEFAULT_regulatory-DEFAULT_CFC.xml.zip
It's the November patch

Okay since my build number is: NPLS26.118-20-5-3 I downloaded "XT1650-03_GRIFFIN_RETAIL_7.1.1_NPLS26.118-20-5-3_cid50_subsidy-DEFAULT_regulatory-DEFAULT_CFC.xml.zip" ... I followed the flash instructions on here but
fastboot flash partition gpt.bin
fastboot flash bootloader bootloader.img

will not work I always get an error message:



and nothing works ... The phone will normaly start - bootloader still unlocked.

And since that does not work, anything after
fastboot oem lock begin
fastboot oem lock begin
does not work either.
 

m0ritz

Senior Member
Sep 15, 2011
62
8
0
It means you had an updated version on your phone and now you're trying to restore an older version.
I advise you to wait until an updated version is available or you risk bricking your device.

PS: Now that I read your version, you may try with this one: https://rsdsecure-cloud.motorola.co...ubsidy-DEFAULT_regulatory-DEFAULT_CFC.xml.zip
It's the November patch
Thank you for the idea, I tired that version before but sadly I have since updated to the newest security patch so no luck for me.
Could you inform me when a new version is uploaded if you have time for it?