These are the instructions to flash stock ROM (firmware) on Google Nexus Device using the Windows Computer.
Requirements: Your Google Nexus device should have at least 20-30 percent of battery to perform the flashing process.
Step 1: Download and install Google Nexus USB drivers on your computer.
Step 2: Download and install Minimal ADB and fastboot tool on your computer.
Step 3: Download the Google Nexus Stock ROM for your device.
Step 4: After Downloading the firmware, you need to extract it on your computer. After extracting you will be able to see the following files:
Step 5: Now, enable USB Debugging on your Nexus Device. To enable USB Debugging: Open Settings > Developers Option > USB Debugging > Tick to enable.
(Developers Option is hidden for Android 4.2.2 or above, to show this option Go to Settings > About Phone > Built Number (Tap on it for 5-8 times).
Step 6: Now, Power off your Google Nexus Device.
Step 7: Now, you need to boot your device into the fastboot mode. For that press and hold Volume Down + Power for 7-10 seconds until fastboot mode is enabled.
Step 8: Now, connect your Nexus Device to the computer using the data cable.
Step 9: Now, you need to unlock the bootloader (it can be locked later). To unlock the bootloader, Open MAF32.exe or py_cmd.exe from the Minimal ADB and fastboot folder (C:Program Files\Minimal ADB and Fastboot).
Step 10: Once, Command Window is launched, Give the following command: fastboot oem unlock
Step 11: Now, you will be able to see warning message on your device screen, Using your Volume UP button Select Yes to Continue.
Step 12: Now, as your device bootloader is unlocked you can flash the firmware. To flash the firmware, Go to the extracted files and open flash-all.bat
Step 13: Now, flashing process will begin, and it will hardly take 5-10 minutes to complete.
Step 14: To lock the bootloader again, Open py_cmd.exe from the Minimal ADB and fastboot folder (C:Program FilesMinimal ADB and Fastboot). And give the following command: fastboot oem lock
[*] Caution: Flashing the Stock firmware will delete your personal data, so take a backup of your personal data before proceeding.
[*] Google Nexus Pixel Stock Firmware: If you are looking for the original firmware for your device then head over to Download Google Nexus Pixel Stock Firmware for all devices page.
[*] Google Nexus Pixel USB Driver: If you are looking for the original USB Driver for your device then head over to Download Google Nexus Pixel USB Driver for all devices page.
[*] Credits: The above flashing instruction is provided by Google at the Factory Image for Nexus Device page. We made the instructions more noob friendly.