[Moto G5S Plus Questions & Answers] aanand342000:
I recently flashed PixelExperience rom on my moto g5s plus. Soon, i needed to revert to the stock rom for something. While flashing the firmware, i was way too careless and accidentally flashed the firmware for G5 plus [POTTER_RETAIL_8.1.0_OPS28.85-17_cid50_subsidy-DEFAULT_regulatory-DEFAULT_CFC.xml]. As expected, i wasn't able to boot into my phone, but fastboot and TWRP were still accessible. Then I proceeded to flash the appropriate firmware for my device [SANDERS_OPS28.65-36_cid50_subsidy-DEFAULT_regulatory-DEFAULT_CFC.xml].

The following were the results:

fastboot getvar max-sparse-size
max-sparse-size: 268435456
finished. total time: 0.001s

fastboot oem fb_mode_set
...
OKAY [ 0.001s]
finished. total time: 0.002s

fastboot flash partition gpt.bin
target reported max download size of 534773760 bytes
sending 'partition' (45 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) Cancelling 'gpt.default.xml'
FAILED (remote failure)
finished. total time: 0.073s

fastboot flash bootloader bootloader.img
target reported max download size of 534773760 bytes
sending 'bootloader' (5115 KB)...
OKAY [ 0.160s]
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.456s]
finished. total time: 0.617s

fastboot flash modem NON-HLOS.bin
target reported max download size of 534773760 bytes
sending 'modem' (71925 KB)...
OKAY [ 2.189s]
writing 'modem'...
OKAY [ 0.732s]
finished. total time: 2.923s

fastboot flash fsg fsg.mbn
target reported max download size of 534773760 bytes
sending 'fsg' (3024 KB)...
OKAY [ 0.092s]
writing 'fsg'...
OKAY [ 0.089s]
finished. total time: 0.182s

fastboot erase modemst1
erasing 'modemst1'...
OKAY [ 0.028s]
finished. total time: 0.028s

fastboot erase modemst2
erasing 'modemst2'...
OKAY [ 0.027s]
finished. total time: 0.028s

fastboot flash dsp adspso.bin
target reported max download size of 534773760 bytes
sending 'dsp' (16384 KB)...
OKAY [ 0.503s]
writing 'dsp'...
OKAY [ 0.193s]
finished. total time: 0.697s

fastboot flash logo logo.bin
target reported max download size of 534773760 bytes
sending 'logo' (2192 KB)...
OKAY [ 0.067s]
writing 'logo'...
OKAY [ 0.082s]
finished. total time: 0.149s

fastboot flash boot boot.img
target reported max download size of 534773760 bytes
sending 'boot' (16384 KB)...
OKAY [ 0.509s]
writing 'boot'...
(bootloader) Image signed with key bad key
OKAY [ 0.272s]
finished. total time: 0.785s

fastboot flash recovery recovery.img
target reported max download size of 534773760 bytes
sending 'recovery' (20580 KB)...
OKAY [ 0.627s]
writing 'recovery'...
(bootloader) Image signed with key bad key
OKAY [ 0.361s]
finished. total time: 0.991s

fastboot flash system system.img_sparsechunk.0
target reported max download size of 534773760 bytes
sending 'system' (256355 KB)...
OKAY [ 7.792s]
writing 'system'...
(bootloader) Preflash validation failed
FAILED (remote failure)
finished. total time: 7.822s

fastboot flash system system.img_sparsechunk.1
target reported max download size of 534773760 bytes
sending 'system' (262115 KB)...
OKAY [ 8.010s]
writing 'system'...
OKAY [ 2.077s]
finished. total time: 10.088s

fastboot flash system system.img_sparsechunk.2
target reported max download size of 534773760 bytes
sending 'system' (259034 KB)...
OKAY [ 7.872s]
writing 'system'...
OKAY [ 2.189s]
finished. total time: 10.061s

fastboot flash system system.img_sparsechunk.3
target reported max download size of 534773760 bytes
sending 'system' (262013 KB)...
OKAY [ 8.007s]
writing 'system'...
OKAY [ 2.252s]
finished. total time: 10.258s

fastboot flash system system.img_sparsechunk.4
target reported max download size of 534773760 bytes
sending 'system' (262142 KB)...
OKAY [ 7.993s]
writing 'system'...
OKAY [ 2.110s]
finished. total time: 10.103s

fastboot flash system system.img_sparsechunk.5
target reported max download size of 534773760 bytes
sending 'system' (262140 KB)...
OKAY [ 7.950s]
writing 'system'...
OKAY [ 1.926s]
finished. total time: 9.878s

fastboot flash system system.img_sparsechunk.6
target reported max download size of 534773760 bytes
sending 'system' (259637 KB)...
OKAY [ 7.918s]
writing 'system'...
OKAY [ 1.951s]
finished. total time: 9.869s

fastboot flash system system.img_sparsechunk.7
target reported max download size of 534773760 bytes
sending 'system' (240915 KB)...
OKAY [ 7.374s]
writing 'system'...
OKAY [ 2.454s]
finished. total time: 9.829s

fastboot flash system system.img_sparsechunk.8
target reported max download size of 534773760 bytes
sending 'system' (262142 KB)...
OKAY [ 7.939s]
writing 'system'...
OKAY [ 2.325s]
finished. total time: 10.265s

fastboot flash system system.img_sparsechunk.9
target reported max download size of 534773760 bytes
sending 'system' (233189 KB)...
OKAY [ 7.049s]
writing 'system'...
(bootloader) Invalid sparse image data
(bootloader) Failed to flash sparse image
FAILED (remote failure)
finished. total time: 7.398s

fastboot flash system system.img_sparsechunk.10
target reported max download size of 534773760 bytes
sending 'system' (65436 KB)...
OKAY [ 1.964s]
writing 'system'...
(bootloader) Invalid sparse image data
(bootloader) Failed to flash sparse image
FAILED (remote failure)
finished. total time: 1.972s

fastboot flash oem oem.img
target reported max download size of 534773760 bytes
sending 'oem' (145482 KB)...
OKAY [ 4.325s]
writing 'oem'...
(bootloader) Preflash validation failed
FAILED (remote failure)
finished. total time: 4.331s

fastboot erase cache
erasing 'cache'...
OKAY [ 0.014s]
finished. total time: 0.014s

fastboot erase userdata
erasing 'userdata'...
OKAY [ 0.153s]
finished. total time: 0.153s

fastboot erase DDR
erasing 'DDR'...
OKAY [ 0.003s]
finished. total time: 0.003s

fastboot oem fb_mode_clear
...
OKAY [ 0.003s]
finished. total time: 0.003s

fastboot reboot
rebooting...

On rebooting, the message about unlocked bootloader just keeps on looping. Left it for more than hour, nothing happenend.

I still have access to fastboot and TWRP but not adb. I am unable to flash any custom ROM through TWRP, also, data and cache can't be mounted(which actually is the reason for my inability to flash any custom ROMS). Can anyone help me with this?

Also, i apologize in advance for any mistakes with my post, as this is my first post on xda. Really in need of some help!