Many Android manufacturers, including Google (for its Pixel devices), Motorola, and BQ, distribute their official factory firmware in a package that includes a flashing script. This script, typically named flash-all.bat
for Windows or flash-all.sh
for macOS/Linux, automates the process of flashing all the necessary partition images (like boot, system, recovery, etc.) to your device via fastboot.
This method is one of the most reliable ways to restore a device to its factory state, unbrick a soft-bricked phone, or revert from a custom ROM to the official software. This guide will walk you through the entire process, from setting up your computer to running the script and successfully restoring your device.
Prerequisites and Critical Warnings
Data Deletion: This process requires unlocking the bootloader, which will perform a mandatory factory reset and completely erase all data on your device. Back up everything important before you start.
Compatibility: Only use the official firmware package that is specifically designed for your exact device model. Using the wrong firmware will likely brick your device.
Battery Level: Ensure your phone is charged to at least 60% to prevent it from shutting down during the flashing process.
Required Downloads and Tools
Before you begin, you need to prepare your computer and download the necessary files.
- Android SDK Platform-Tools: This is Google’s official package containing ADB and Fastboot. Download the latest version for your operating system from the official Android developer website.
- Device-Specific USB Drivers: Your computer needs the correct drivers to communicate with your phone in fastboot mode.
- For Google Pixel/Nexus devices, use the Google USB Driver.
- For Motorola devices, get them from the Motorola support site.
- For other brands like BQ, the Qualcomm Drivers are often required.
- The Correct Firmware Package: Download the official firmware for your device model from a trusted source. This should be a
.zip
file containing multiple.img
files and theflash-all
script.
Step-by-Step Flashing Instructions
Follow these steps in order. Do not skip any part of the process.
Step 1: Set Up ADB and Fastboot on Your PC
- Extract the Platform-Tools zip file to a simple location, like
C:\platform-tools
. - For ease of use, you should add this folder to your system’s PATH environment variable. This allows you to run
adb
andfastboot
commands from any command prompt window.
Step 2: Enable USB Debugging and OEM Unlocking on Your Phone
- Go to Settings > About phone.
- Scroll down and tap on the “Build number” seven times until you see a message that says, “You are now a developer!”
- Go back to the main Settings menu, and you will find a new “Developer options” menu.
- Inside Developer options, find and enable “OEM unlocking” and “USB debugging”. A confirmation pop-up will appear for each; accept them.
Step 3: Unlock the Bootloader
- Turn off your phone completely.
- Boot your phone into Fastboot/Bootloader mode. The key combination is usually Volume Down + Power Button held together.
- Connect your phone to your computer with a high-quality USB cable.
- Open a Command Prompt (or Terminal on Mac/Linux) and type
fastboot devices
. You should see your device’s serial number, which confirms the connection. - To unlock the bootloader, type one of the following commands (the exact command varies by manufacturer):
- For most modern devices (Pixel, newer Motorola):
fastboot flashing unlock
- For older devices (Nexus, some BQ):
fastboot oem unlock
orfastboot oem unlock-go
- For most modern devices (Pixel, newer Motorola):
- A confirmation screen will appear on your phone. Use the volume keys to select “Yes” or “Unlock the bootloader” and press the power button. This will wipe your device. Your phone will reboot after this.
Step 4: Flash the Firmware Using the Script
- After the bootloader is unlocked, power off your phone and boot it back into Fastboot mode using the same key combination (e.g., Volume Down + Power).
- Connect the phone to your PC again.
- Extract the firmware
.zip
file you downloaded into a simple folder path (e.g.,C:\firmware\my_device
). - Open the extracted firmware folder. You will see a list of
.img
files and the script. - For Windows: Simply double-click the
flash-all.bat
file. - For macOS/Linux: Open a terminal inside the firmware folder and run the command
./flash-all.sh
. - A command window will open and you will see the script executing a series of
fastboot flash...
commands. Do not close the window or disconnect the device. - Once the process is complete, the script will often automatically reboot your phone.
Troubleshooting Common Problems
- “fastboot is not recognized as an internal or external command”
- This means you haven’t set up the Platform-Tools PATH correctly, or your command prompt is not open in the platform-tools folder. Open your command prompt directly inside the folder where `fastboot.exe` is located.
- Fastboot is stuck on “waiting for device”
- This is the most common issue and is almost always driver-related. Your PC is not recognizing the phone in fastboot mode.
- Ensure you have installed the correct USB drivers for your brand.
- Try a different USB cable and port (use a USB 2.0 port on the back of your computer if possible).
- Open Device Manager on Windows and check for any devices with a yellow exclamation mark. If you see one, manually update the driver by pointing it to the driver files you downloaded.
- The script fails with an error like “FAILED (remote: partition is locked)”
- This means your bootloader is not unlocked. You must successfully complete Step 3 before attempting to run the flash script.
Conclusion
Using the official fastboot script is a safe and thorough way to restore your Android device to its factory software. While it seems complex at first, following the steps carefully—installing drivers, unlocking the bootloader, and running the script—will ensure a successful flash. This method is perfect for fixing persistent software bugs, resolving bootloops, and getting a clean start on your device.