[Moto G5S  Guides, News, & Discussion] rizwan.mahai:
Successfully Flashed on XT1795

I was on an XT1795 Indian Variant with a TWRP, unlocked bootloader and baseband version M8937_18000.295.03.33R MONTANA_INDIASDS_CUST and Bulid Number NPP26.102-19

The reason why I had to flash the stock firmware was :

1. The display was unresponsive most of the times, I think it is a hardware problem so I am thinking of taking it to a service center after relocking the bootloader.

2. By mistake I updated an OTA software update, after it finished installing my device was only booting in TWRP. So each time I had to correctly boot the device I had to go into bootloader menu and select the START option from there.

Now I had flashed MONTANA_NPP26.102-49_cid50_subsidy-DEFAULT_regulatory-DEFAULT_CFC.xml firmware.

While there was a bad key error while flashing boot.img and recovery.img the device booted up with unlocked bootloader warning and and an Android logo with Error msg. Then I turned of the device and it restarted fine.

Here is the flashing logcat

C:\Users\Rizwan\Desktop\ADB>fastboot devices
ZY3228V9V2 fastboot

C:\Users\Rizwan\Desktop\ADB>mfastboot getvar max-sparse-size
max-sparse-size: 268435456
finished. total time: 0.016s

C:\Users\Rizwan\Desktop\ADB>mfastboot oem fb_mode_set
...
OKAY [ 0.016s]
finished. total time: 0.016s

C:\Users\Rizwan\Desktop\ADB>mfastboot flash partition gpt.bin
target max-sparse-size: 256MB
sending 'partition' (45 KB)...
OKAY [ 0.031s]
writing 'partition'...
(bootloader) Validating 'gpt.default.xml'
(bootloader) Committing 'gpt.default.xml'
(bootloader) - flashing 'gpt_main0.bin' to 'partition:0'
(bootloader) Flashing primary GPT image...
(bootloader) Flashing backup GPT image...
OKAY [ 0.156s]
finished. total time: 0.203s

C:\Users\Rizwan\Desktop\ADB>mfastboot flash bootloader bootloader.img
target max-sparse-size: 256MB
sending 'bootloader' (5179 KB)...
OKAY [ 0.172s]
writing 'bootloader'...
(bootloader) Validating 'bootloader.default.xml'
(bootloader) Committing 'bootloader.default.xml'
(bootloader) - flashing 'emmc_appsboot.mbn' to 'aboot'
(bootloader) - flashing 'rpm.mbn' to 'rpm'
(bootloader) - flashing 'tz.mbn' to 'tz'
(bootloader) - flashing 'devcfg.mbn' to 'devcfg'
(bootloader) - flashing 'cmnlib.mbn' to 'cmnlib'
(bootloader) - flashing 'cmnlib64.mbn' to 'cmnlib64'
(bootloader) - flashing 'keymaster.mbn' to 'keymaster'
(bootloader) - flashing 'prov.mbn' to 'prov'
(bootloader) - flashing 'sbl1.mbn' to 'sbl1'
OKAY [ 0.936s]
finished. total time: 1.108s

C:\Users\Rizwan\Desktop\ADB>mfastboot flash modem NON-HLOS.bin
target max-sparse-size: 256MB
sending 'modem' (66916 KB)...
OKAY [ 2.153s]
writing 'modem'...
OKAY [ 1.076s]
finished. total time: 3.229s

C:\Users\Rizwan\Desktop\ADB>mfastboot flash fsg fsg.mbn
target max-sparse-size: 256MB
sending 'fsg' (3120 KB)...
OKAY [ 0.109s]
writing 'fsg'...
OKAY [ 0.140s]
finished. total time: 0.250s

C:\Users\Rizwan\Desktop\ADB>mfastboot flash dsp adspso.bin
target max-sparse-size: 256MB
sending 'dsp' (16384 KB)...
OKAY [ 0.530s]
writing 'dsp'...
OKAY [ 0.312s]
finished. total time: 0.842s

C:\Users\Rizwan\Desktop\ADB>mfastboot flash logo logo.bin
target max-sparse-size: 256MB
sending 'logo' (2195 KB)...
OKAY [ 0.078s]
writing 'logo'...
OKAY [ 0.125s]
finished. total time: 0.218s

C:\Users\Rizwan\Desktop\ADB>mfastboot flash boot boot.img
target max-sparse-size: 256MB
sending 'boot' (16384 KB)...
OKAY [ 0.546s]
writing 'boot'...
(bootloader) Image signed with key bad key
OKAY [ 0.858s]
finished. total time: 1.404s

C:\Users\Rizwan\Desktop\ADB>mfastboot flash recovery recovery.img
target max-sparse-size: 256MB
sending 'recovery' (16484 KB)...
OKAY [ 0.530s]
writing 'recovery'...
(bootloader) Image signed with key bad key
OKAY [ 0.655s]
finished. total time: 1.186s

C:\Users\Rizwan\Desktop\ADB>mfastboot flash system system.img_sparsechunk.0
target max-sparse-size: 256MB
Sparse-Flash is enabled!
sending sparse 'system' (256418 KB)...
OKAY [ 9.407s]
writing 'system'...
OKAY [ 4.290s]
sending sparse 'system' (256830 KB)...
OKAY [ 9.422s]
writing 'system'...
OKAY [ 3.385s]
finished. total time: 26.520s

C:\Users\Rizwan\Desktop\ADB>mfastboot flash system system.img_sparsechunk.1
target max-sparse-size: 256MB
Sparse-Flash is enabled!
sending sparse 'system' (256524 KB)...
OKAY [ 9.391s]
writing 'system'...
OKAY [ 3.448s]
sending sparse 'system' (255793 KB)...
OKAY [ 9.454s]
writing 'system'...
OKAY [ 3.682s]
finished. total time: 25.974s

C:\Users\Rizwan\Desktop\ADB>mfastboot flash system system.img_sparsechunk.2
target max-sparse-size: 256MB
Sparse-Flash is enabled!
sending sparse 'system' (256862 KB)...
OKAY [ 9.422s]
writing 'system'...
OKAY [ 3.416s]
sending sparse 'system' (262005 KB)...
OKAY [ 10.156s]
writing 'system'...
OKAY [ 4.774s]
sending sparse 'system' (5345 KB)...
OKAY [ 0.203s]
writing 'system'...
OKAY [ 0.156s]
finished. total time: 28.142s

C:\Users\Rizwan\Desktop\ADB>mfastboot flash system system.img_sparsechunk.3
target max-sparse-size: 256MB
Sparse-Flash is enabled!
sending sparse 'system' (234486 KB)...
OKAY [ 8.658s]
writing 'system'...
OKAY [ 3.338s]
sending sparse 'system' (256995 KB)...
OKAY [ 9.376s]
writing 'system'...
OKAY [ 3.385s]
sending sparse 'system' (24716 KB)...
OKAY [ 0.920s]
writing 'system'...
OKAY [ 0.343s]
finished. total time: 26.021s

C:\Users\Rizwan\Desktop\ADB>mfastboot flash system system.img_sparsechunk.4
target max-sparse-size: 256MB
Sparse-Flash is enabled!
sending sparse 'system' (258876 KB)...
OKAY [ 9.469s]
writing 'system'...
OKAY [ 3.619s]
sending sparse 'system' (260930 KB)...
OKAY [ 9.734s]
writing 'system'...
OKAY [ 3.697s]
sending sparse 'system' (3344 KB)...
OKAY [ 0.125s]
writing 'system'...
OKAY [ 0.078s]
finished. total time: 26.754s

C:\Users\Rizwan\Desktop\ADB>mfastboot flash system system.img_sparsechunk.5
target max-sparse-size: 256MB
Sparse-Flash is enabled!
sending sparse 'system' (260921 KB)...
OKAY [ 9.859s]
writing 'system'...
OKAY [ 4.352s]
sending sparse 'system' (157621 KB)...
OKAY [ 5.803s]
writing 'system'...
OKAY [ 2.387s]
finished. total time: 22.402s

C:\Users\Rizwan\Desktop\ADB>mfastboot flash oem oem.img
target max-sparse-size: 256MB
Sparse-Flash is enabled!
sending sparse 'oem' (234198 KB)...
OKAY [ 8.642s]
writing 'oem'...
OKAY [ 4.493s]
sending sparse 'oem' (242310 KB)...
OKAY [ 8.845s]
writing 'oem'...
OKAY [ 9.578s]
finished. total time: 31.574s

C:\Users\Rizwan\Desktop\ADB>mfastboot erase cache
erasing 'cache'...
OKAY [ 0.016s]
finished. total time: 0.016s

C:\Users\Rizwan\Desktop\ADB>mfastboot erase userdata
erasing 'userdata'...
OKAY [ 4.571s]
finished. total time: 4.571s

C:\Users\Rizwan\Desktop\ADB>mfastboot erase DDR
erasing 'DDR'...
OKAY [ 0.000s]
finished. total time: 0.000s

C:\Users\Rizwan\Desktop\ADB>mfastboot oem fb_mode_clear
...
OKAY [ 0.000s]
finished. total time: 0.000s

C:\Users\Rizwan\Desktop\ADB>mfastboot reboot
rebooting...

finished. total time: -0.000s

C:\Users\Rizwan\Desktop\ADB>

After the flashing to my surprise the device is still on Indian baseband M8937_34.10.03.48R MONTANA_INDIADSDS_CUST and Build Number NPP26.102-49

Now I have to relock the bootloader. I will edit this post if I get into some problems.

Thanks for the guide.

UPDATE 1 :

How do I relock the bootloader now ?

If I use

fastboot oem lock

command, it shows

INFOStill require signed boot.img