In this tutorial, we will show you how to flash Stock Firmware via Fastboot Commands on any Android device. The everyday general users are more than contained when they receive an OTA on their Android device. They just hit the Install button, and if the device has an A/B partition, they continue with their work while the installation process is being carried out in the background in the inactive slot. Once that is done, they simply reboot their device to switch slots and enjoy the new update. Samsung device owners are a little bit less lucky and they have to wait for a few minutes until the installation is done.
But anyway, the only effort that the user has to exert in all of these is simply hitting the Install button in the initial phase and the Reboot button in the latter half. However, with the open-source nature of Android, things aren’t so plain and simple. Most of the users go ahead and try out tons of customizations and tweaks. These include the ability to flash custom ROMs, a custom recovery like TWRP, unlock their device bootloader, try out Build. Prop Tweaks, flashing mods from Magisk, and Frameworks of Xposed among others.
And while executing the above steps, there’s always a possibility of things going south. Just a slight miss-step and you will end up with a bootloop or a soft-bricked device. The worst-case scenario will lead to a hard-brick, in which case you will have to take up the EDL Mode route to repair your device. All in all, as and when you end up messing up your device, the first thing that comes to your mind is flashing the stock firmware to make it work back again.
But unfortunately, things in a bricked or boot-looped device works in a slightly different way. Since you cannot access the Android system, you cannot simply install the stock ROM in the “normal” way. Fortunately, there still exists a handy way of doing so. You could still flash the stock firmware of any Android device using fastboot commands. The process is applicable for near about every device running on any chipset (Exynos, Snapdragon, or MediaTek) and of any OEM. So without further ado, here are all the required instructions set.
Editor’s Choice
- How to Install OTA Updates in Rooted Android Device
- How to Permanently Install TWRP without TWRP ZIP File (only using TWRP.img file)
- Root Android Devices Without TWRP Recovery
- [GUIDE] Flash ROMs/Magisk/TWRP/Kernels on A/B Partition Devices
Table of Contents
How to Flash Stock Firmware via Fastboot Commands
We are breaking down the entire instructions into simpler steps. Make sure to follow them in the same manner. Droidwin and its members wouldn’t be held responsible in case of a thermonuclear war, your alarm doesn’t wake you up, or if anything happens to your device and data by performing the below steps.
STEP 1: Download Android SDK Platform Tools
First and foremost, you will have to install the Android SDK Platform Tools on your PC. This is the official ADB and Fastboot binary provided by Google and is the only recommended one. So download it and then extract it to any convenient location on your PC. Doing so will give you the platform-tools folder, which will be used throughout this guide.
STEP 2: Boot your device to Fastboot Mode
Next up, you will have to boot your device to Fastboot, or as some OEMs like to call, the Bootloader menu. There are two ways of doing so- via hardware key combinations or using ADB Commands. If your device is in a perfectly working condition, then you could use either of the two methods (though we would recommend opting for the Fastboot Commands).
![How to Flash Stock Firmware via Fastboot Commands (2) How to Flash Stock Firmware via Fastboot Commands (2)](https://i0.wp.com/droidwin.com/wp-content/uploads/2020/05/fastboot-mode-xiaomi-device.jpg)
On the other hand, if your device is stuck in the bootloop/softbrick state and you cannot access the OS, then you have no choice but to go with the hardware key combination method. So without any further ado, let’s check out both these methods (For detailed instructions, you should also refer to our guide on How to Boot any Android Device to Fastboot Mode).
Method 1: When the Device is working normally
If your device is working well and good, then it is advised that you opt for this ADB Command method to boot your device to Fastboot Mode. This is because it is the universal method that works across all Android devices.
- To begin with, enable USB Debugging on your device. Head over to Settings > About Phone > Tap on Build Number 7 times (MIUI Number in case of Xiaomi devices) > Go back to Settings > System > Advanced > Developer Options > Enable USB Debugging.
- Then head over to the platform-tools folder, type in CMD in the address bar, and hit Enter. This will launch the Command Prompt.
- Type in the following command in the CMD window to boot your device to Fastboot Mode
adb reboot bootloader
- To verify the Fastboot connection, type in the below command and you should get back the device ID.
fastboot devices
Method 2: When Device is Stuck in Bootloop/Bricked
If you cannot access the OS, then you wouldn’t be able to enable USB Debugging. As a result, you wouldn’t be able to execute the adb reboot bootloader command and you would instead have to opt for the hardware key combinations. Now, there doesn’t exist any universal method to do so, but here are the generic instructions that work for most devices:
- To begin with, you will have to power off your device. For that, long-press the Power menu for around 5-6 seconds. This should force-shutdown the device.
- However, if that doesn’t happen, then you will have to wait for the battery to drain out. As soon as that happens, connect your device to the charger and move over to the next step.
- Once the device powers off, press and hold the Power and Volume Up Keys (or Power and Volume Down keys in some devices) and your device should be booted to Fastboot Mode.
STEP 3: Download and Extract Stock Firmware
The next step involves downloading the stock firmware. For that, you could refer to your device’s software download page. There might be other third-party sites as well, but they don’t usually have the updated software package. So the official one is the recommended one. Once you have downloaded it, extract it inside the folder where the Android SDK Platform Tools are installed.
That is, extract it inside the platform-tools folder. However, nowadays, most OEMs pack their firmware under separate packages. For example, OnePlus and Asus use the payload.bin file, Realme and Oppo use OZIP, LG uses KDZ or DZ format, and so on. So please refer to our below-linked guide to extract the firmware corresponding to your device:
- How to Extract payload.bin and get the stock boot image file
- How to Extract KDZ, TOT, or DZ LG Firmware
- Extract Fastboot Images from Realme/Oppo OZIP Firmware
- How to Extract Sony Boot.sin and get the Stock Firmware Files
- How to Extract Motorola PAC Firmware using SPD Flash Tool
Once you have extracted the firmware and got hold of the Fastboot IMG files, proceed with the below manual steps or directly jump over to the list of device-specific Fastboot commands section: Fastboot Command Sheet For Various Android Devices.
Don’t Miss
- [GUIDE] Flash ROMs/Magisk/TWRP/Kernels on A/B Partition Devices
- Everything About Magisk- Manager, Modules, and More
- How to Install TWRP Recovery on Android
- How to Fix FAILED (remote: unknown command) Error
STEP 4: Flash Stock Firmware via Fastboot
NOTE: This is a manual method to create the Fastboot Commands for your device. Carrying it out would require your precious time, in some cases, even up to 30 minutes. However, if you don’t have much time in hand, then I have also automated the process for most of the Android devices and have also created a sample Fastboot Commands sheet that covers most of the devices. So you could also refer to that as well if you don’t wish to manually carry out this task as of now. Here’s the direct link for both these guides:
- First of all, some OEMs (like Pixel and Xiaomi) make it pretty easy for the end-users and they add a flash-all.bat file (see below image). If the stock ROM that you have extracted has one as well, then simply double click on that file and wait for the process to finish.
- But the thing is not all OEMs are so generous, and if your smartphone falls into the latter category, then you will have to flash the stock firmware via Fastboot Commands.
- For that, extract all the contents of the stock firmware that you have downloaded inside the platform-tools folder.
- Then connect your device (that has been booted to fastboot mode) to the PC via USB cable. As mentioned before, if it has the flash-all.bat file, then simply execute that.
- If it doesn’t have one, then look out for the XML files. There should be something along the lines of servicefile.xml, flashfile.xml, or other similar names. The focus shouldn’t be on the names but rather the contents of that file (see next point).
- In this regard, the XML file holds the file name, type and more importantly the partitions of each of the file that is part of the stock firmware. We could then use this to manually create the fastboot commands and hence flash the stock firmware via it.
- Let’s understand it with the help of an example. Here are two lines from one of the device’s XML files (see below image):
<step MD5="ff8711c8eb5c7fd7559bd79d74b1f4d8" partition="modem_a" operation="flash" filename="modem.bin"/><step MD5="f31b2994072f47907504776a64bcd842" partition="vbmeta_a" operation="flash" filename="vbmeta.img"/>
- This is enough for us to understand that the modem.bin file has to be flashed in the modem_a partition whereas the vbmeta.img will be flashed in the vbmeta_a slot. This is an example of a dual-slot A/B Partition device, hence you are seeing the ‘a’ keyword in the partition name. Moving on, the flash command for the above two files will then be:
fastboot flash modem_a modem.binfastboot flash vbmeta_a vbmeta.img.
- Likewise, you could create the fastboot commands for all the stock firmware files using the below syntax:
fastboot flash partition-name file-name-with-extension
- Once you have created the fastboot command list, head over to the platform-tools folder. Type in CMD in the address bar, and hit Enter. This will launch the Command Prompt.
- Now copy-paste all the fastboot commands one by one. It is highly recommended to execute the commands in the same order as mentioned in the XML file, otherwise, it might lead to brick issues.
- Once you have executed all the commands, enter the below code to boot your device to Android system:
fastboot reboot
That is it. You have successfully flashed the stock firmware manually via the fastboot commands. A huge kudos to you as you have created the entire code-sheet yourself. With that said, we get it that not all OEMs are so developer-friendly, and as a result, you might face issues getting your hand with the XML file. If that is the case, then below we have attached a few sample fastboot commands to flash stock firmware files, that may come in handy.
If that doesn’t work out, the comments section is all yours. Drop-in your device name, the firmware version, and the region as well. If possible please download the entire firmware and send us the screenshot of the same (upload to Imgur, Google Photos, etc and share the link with us in the comments). We will try our best to create the fastboot commands for your device’s stock firmware and then share it with you, either on your email or right here in the comments section.
Unbrick Samsung Devices via Odin
If you have a Samsung device, then you wouldn’t be able to unbrick it via Fastboot Commands. Rather you would need the Odin Tool installed on your PC. After that, you need to download the firmware via Frija Tool or SamMobile site and load it to Odin.
Finally, you will have to boot your device to Download Mode and then flash the firmware via Odin. All this has been explained in our detailed guide, do refer to it: Unbrick Samsung | Flash Stock Firmware via Odin.
Fastboot Unbrick Commands Guides For Various Android Devices
Here is a sample fastboot command sheet. I tried to write down the commands for all frequently used files. The below commands are for A/B partition devices, if your device just has a single partition, you will have to ignore the ‘a’ or ‘b’ keywords. For example, fastboot flash dtb_a dtb.img will change to fastboot flash dtb dtb.img.
Fastboot Commands to Unbrick Pixel Devices
- Restore Pixel/XL to Stock Firmware via Fastboot | Unbrick it
- How to Restore Pixel 2/XL to Stock Firmware via Fastboot | Unbrick it
- Restore Pixel 3/3 XL/3a/3a XL to Stock Firmware via Fastboot | Unbrick it
- Restore Pixel 4/XL/4a to Stock Firmware via Fastboot | Unbrick it
- How to Restore Google Pixel 5 to Stock Firmware via Fastboot | Unbrick it
- How to Flash Pixel 5A Firmware via Fastboot Commands | Unbrick It
- How to Unbrick Google Pixel 6/Pro via Fastboot Commands
Fastboot Commands to Unbrick OnePlus Devices
- Restore OnePlus 6/6T to Stock via Fastboot Commands
- Restore OnePlus 7/7T/7T Pro to Stock via Fastboot Commands
- How to Restore OnePlus 8/8T/8 Pro to Stock via Fastboot Commands
- Restore OnePlus Nord to Stock via Fastboot Commands
- How to Unbrick OnePlus 9/Pro via Fastboot Commands
- How to Unbrick OnePlus Nord N10 5G via Fastboot Commands
Fastboot Commands to Unbrick Xiaomi/Redmi/Mi/Poco Devices
- How to UnbrickXiaomi Mi A1via Fastboot Commands
- How to UnbrickXiaomi Mi A2via Fastboot Commands
- Unbrick Xiaomi Mi A3via Fastboot Commands
- How to UnbrickRedmi Note 7/7Svia Fastboot Commands
- How to UnbrickRedmi Note 7 Provia Fastboot Commands
- Unbrick Redmi Note 8via Fastboot Commands
- How to UnbrickRedmi Note 8 Provia Fastboot Commands
- How to UnbrickRedmi Note 9via Fastboot Commands
- Unbrick Redmi Note 9 Provia Fastboot Commands
- Unbrick Redmi Note 10 Pro/Pro Max via Fastboot Commands
- How to Unbrick Redmi K20/Pro via Fastboot Commands
- Unbrick POCO X2 (phoenixin) via Fastboot Commands
- How to Unbrick Redmi Note 11 via Fastboot Commands
- Unbrick Redmi Note 11 Pro/Pro+ via Fastboot Commands
- How to Unbrick Redmi K40 via Fastboot Commands
- Unbrick Poco X3 Pro via Fastboot Commands
- How to Unbrick Poco F3 via Fastboot Commands
- How to Unbrick Poco M4 Pro via Fastboot Commands
Unbrick Realme Devices via Fastboot Commands
- How to Unbrick Realme X50/ X50 Pro via Fastboot Commands
- Unbrick Realme X3 SuperZoom via Fastboot Commands
- How to Unbrick Realme X2/X2 Pro via Fastboot Commands
- How to Unbrick Realme XT via Fastboot Commands
- Unbrick Realme C11 via Fastboot Commands
- How to Unbrick Realme 6 Pro via Fastboot Commands
- How to Unbrick Realme 5 Pro/5s/5i via Fastboot Commands
- Unbrick Realme 3 Pro via Fastboot Commands
- How to Unbrick Realme 1 via Fastboot Commands
- How to Unbrick Realme 6/6I/6S via SP Flash Tool | Bring it back from Dead
Unbrick Oppo Devices via Fastboot Commands
- How to Unbrick any Oppo Reno Device via Fastboot Commands
- How to Unbrick Oppo Find X Series via Fastboot Commands
- Unbrick Oppo A series via Fastboot Commands
- How to Unbrick Oppo F Series via Fastboot Commands
- How to Unbrick Oppo R Series via Fastboot Commands
Fastboot Commands to Unbrick Motorola Devices
- How to Install Stock Firmware on Motorola G8 Power Lite via Fastboot Commands
- Install Stock Firmware on Motorola G Stylus via Fastboot Commands
- Install Stock Firmware on Motorola G8 Power via Fastboot Commands
- How to Install Stock Firmware on Motorola One Macro via Fastboot Commands
- Install Stock Firmware on Motorola One Zoom via Fastboot Commands
- How to Flash or Install Stock Firmware on Motorola One Hyper via Fastboot Commands
- How to Install Stock Firmware on Motorola One Vision via Fastboot Commands
- Install Stock Firmware via Fastboot Commands on Motorola One Action.
- How to Unbrick Moto G7/ G7 Plus via Fastboot Commands
- How to Unbrick Moto G9 Play via Fastboot Commands
If your device is not part of this list, then please let me know in the comments section below. In the meantime, you could also make use of the below command sheet. Just extract your device’s firmware inside the platform-tools and verify the files that it has. Then use the commands for those sets of files from here.
Fastboot Commands Sheet to Flash Stock Firmware
Here is a sample fastboot command sheet. I tried to write down the commands for all frequently used files. These commands are not for any particular device nor in any particular order. It could come in handy if you wish to flash a file but aren’t sure of that file’s associated fastboot command. Likewise, you could also just download the stock firmware, and rather than extracting and creating the fastboot commands from the XML File, you could refer to the fastboot commands from below and then flash the files using these commands.
Moreover, if you want to flash a file to both the partition, then make sure to specify the partition in the commands as well. For example, if you wish to flash the boot.img to Partition A and B, then the command will be fastboot flash boot_a boot.img and fastboot flash boot_b boot.img. Likewise, you may modify the rest of the commands accordingly, if required. Or ask me via the comments section below.
fastboot flash gpt PGPTfastboot flash preloader preloader.binfastboot flash lk_a lk.imgfastboot flash tee_a tee.imgfastboot flash md1img_a md1img.imgfastboot erase nvdatafastboot flash spmfw_a spmfw.imgfastboot flash scp_a scp.imgfastboot flash sspm_a sspm.imgfastboot flash cam_vpu1_a cam_vpu1.imgfastboot flash cam_vpu2_a cam_vpu2.imgfastboot flash cam_vpu3_a cam_vpu3.imgfastboot flash vbmeta_a vbmeta.imgfastboot flash oem_a oem.imgfastboot flash logo_a logo.binfastboot flash boot_a boot.imgfastboot flash dtb_a dtb.imgfastboot flash dtbo_a dtbo.imgfastboot flash system_a system.img_sparsechunk.0fastboot flash system_a system.img_sparsechunk.1fastboot flash system_a system.img_sparsechunk.2fastboot flash system_a system.img_sparsechunk.3fastboot flash system_a system.img_sparsechunk.4fastboot flash system_a system.img_sparsechunk.5fastboot flash system_a system.img_sparsechunk.6fastboot flash system_a system.img_sparsechunk.7fastboot flash system_a system.img_sparsechunk.8fastboot flash system_a system.img_sparsechunk.9fastboot flash system_b system_other.img_sparsechunk.0fastboot flash system_b system_other.img_sparsechunk.1fastboot flash vendor_a vendor.img_sparsechunk.0fastboot flash vendor_a vendor.img_sparsechunk.1fastboot flash abl abl.imgfastboot flash aop aop.imgfastboot flash bluetooth bluetooth.imgfastboot flash devcfg devcfg.imgfastboot flash dsp dsp.imgfastboot flash featenabler featenabler.imgfastboot flash hyp hyp.imgfastboot flash imagefv imagefv.imgfastboot flash keymaster keymaster.imgfastboot flash multiimgoem multiimgoem.imgfastboot flash qupfw qupfw.imgfastboot flash tz tz.imgfastboot flash uefisecapp uefisecapp.imgfastboot flash xbl xbl.imgfastboot flash xbl_config xbl_config.imgfastboot flash product product.imgfastboot flash system system.imgfastboot flash system_ext system_ext.imgfastboot flash vendor vendor.imgfastboot flash odm odm.imgfastboot flash boot boot.imgfastboot flash cpucp cpucp.imgfastboot flash dtbo dtbo.imgfastboot flash modem modem.imgfastboot flash oplusstanvbk oplusstanvbk.imgfastboot flash oplus_sec oplus_sec.imgfastboot flash qweslicstore qweslicstore.imgfastboot flash shrm shrm.imgfastboot flash splash splash.imgfastboot flash vbmeta vbmeta.imgfastboot flash vbmeta_vendor vbmeta_vendor.imgfastboot flash vbmeta_system vbmeta_system.imgfastboot flash vendor_boot vendor_boot.imgfastboot flash vm-bootsys vm-bootsys.imgfastboot flash xbl xbl.elffastboot flash xblbak xbl.elffastboot flash xbl_config xbl_config.elffastboot flash xbl_configbak xbl_config.elffastboot flash abl abl.elffastboot flash ablbak abl.elffastboot flash tz tz.mbnfastboot flash tzbak tz.mbnfastboot flash hyp hyp.mbnfastboot flash hypbak hyp.mbnfastboot flash devcfg devcfg.mbnfastboot flash devcfgbak devcfg.mbnfastboot flash storsec storsec.mbnfastboot flash bluetooth BTFM.binfastboot flash cmnlib cmnlib.mbnfastboot flash cmnlibbak cmnlib.mbnfastboot flash cmnlib64 cmnlib64.mbnfastboot flash cmnlib64bak cmnlib64.mbnfastboot flash modem NON-HLOS.binfastboot flash dsp dspso.binfastboot erase metadatafastboot flash metadata metadata.imgfastboot flash keymaster km41.mbnfastboot flash keymasterbak km41.mbnfastboot flash logo logo.imgfastboot flash misc misc.imgfastboot flash aop aop.mbnfastboot flash aopbak aop.mbnfastboot flash qupfw qupv3fw.elffastboot flash qupfwbak qupv3fw.elffastboot flash imagefv imagefv.elffastboot flash uefisecapp uefi_sec.mbnfastboot flash uefisecappbak uefi_sec.mbnfastboot flash multiimgoem multi_image.mbnfastboot flash super super.imgfastboot flash vbmeta vbmeta.imgfastboot flash vbmeta_system vbmeta_system.imgfastboot flash dtbo dtbo.imgfastboot flash cache cache.imgfastboot flash userdata userdata.imgfastboot flash recovery recovery.imgfastboot erase secdatafastboot flash cust cust.imgfastboot flash boot boot.img
So this is all from this guide on how to flash stock firmware via fastboot commands. Feel free to drop your queries in the comments section below!
FAQ: Other Methods to Flash Stock Firmware on Android
Apart from the Fastboot Commands method that we have just concluded, there do exist a couple of other methods through which you could flash the stock firmware on your Android device. These are the ADB Sideload and OEM-specific Tool methods. In the ADB Sideload method, you don’t even need to unlock the device’s bootloader and in most cases, it wouldn’t even wipe your data.
![How to Flash Stock Firmware via Fastboot Commands (12) How to Flash Stock Firmware via Fastboot Commands (12)](https://i0.wp.com/droidwin.com/wp-content/uploads/2020/07/adb-sideload-flash-stock-firmware-via-fastboot-commands.jpg)
However, this method is known to work mostly in the stock environment, such as when you are installing OTA updates on your stock device. Though you could still try out this method in bootloop or bricked device, the only prerequisite is that you should boot your device to Stock Recovery or TWRP Recovery. So if you are willing to try out this method, then you may check out our comprehensive tutorial on How to Use ADB Sideload in Android [Stock and TWRP Recovery].
![How to Flash Stock Firmware via Fastboot Commands (13) How to Flash Stock Firmware via Fastboot Commands (13)](https://i0.wp.com/droidwin.com/wp-content/uploads/2020/07/adb-sideload-twrp-flash-stock-firmware-via-fastboot-commands.jpg)
The other method to flash firmware is via OEM-specific Flash Tool. These include the likes of Mi Flash Tool for Xiaomi devices or Android Flash Tool for Pixel devices. All the tools, irrespective of the device you own, would require your device’s bootloader to be unlocked. This is because these tools will be flashing the partition files to their slots via Fastboot Commands (something that we did manually in the Fastboot Commands method).
And whenever there is flashing takes place, you need to have an unlocked bootloader. Moreover, these tools could also be used in custom development. So you could use these tools to fix bootloop or soft-bricked devices. To try it out, you could refer to our guides corresponding to your devices:
- How to Flash Firmware on Pixel via Android Flash Tool
- Install MIUI Fastboot ROM in Xiaomi, Mi, Redmi, Poco Devices
- Unbrick Motorola and Fix Start-Up Failed without using Lenovo Motorola Smart Assistant