Step 1: Download the Factory image from above links.
Step 2: Make sure you have setup ADB and Fastboot on your PC.
Step 3: Boot your device into bootloader (Fastboot mode).
Step 4: Navigate to the location where you have placed the factory image file on PC and extract it to get all the files like system, bootloader, etc along with the flashall.bat file as well.
Step 5: Run the flash-all.bat . Wait for the process to complete.
If you use Linux or Mac OS, then run the flash-all.sh file and follow the instructions. But first, open the flash-all.sh file and verify if the files start with “./” prefix for Mac and “sudo” for Linux. If not, then add a prefix to every file.
Step 6: Once done, reboot the device into system either manually or using the command:
Flashing Stock Recovery
For ADB and Fastboot download the quick ADB and Fastboot Installer from here
Boot in Fastboot mode again
Unzip the file fastboot optstockrecovery.7z
Copy its content to the folder where Minimal ADB and Fastboot os installed (right-click on its icon > Open file location).
Flash the recovery with
fastboot flash recovery optstockrecovery.img