In this guide, we will show you how to restore your OnePlus 6/6T device to stock OxygenOS by flashing the Stock ROM via Fastboot Commands. First off, we will show you how to convert the extract the payload.bin file from Stock ROM and get hold of all the partition IMG files (such as boot.img, system.img, etc). After this, we will flash all these files individually via Fastboot commands. Upon successful execution of these commands, your device will be back to stock ROM, unrooted, and without any custom binary installed (such as root or TWRP Recovery). Furthermore, the below instructions will also help you out in case it is stuck your device is stuck in the bootloop or soft brick.
OnePlus devices have always to be stand out among the crowds when it comes to custom development. However, it is with its sixth iteration that the OEM was well and truly highlighted. Up to this date, the device is receiving quite active support in custom development. With tons of custom ROMs, the ability to flash custom kernels, or a custom recovery like TWRP, well goodies are in order. Along the same lines, you could also root your device. This could be done directly via TWRP or without TWRP– by flashing the patched boot,img file. Once you do so, you could then flash Magisk Modules, Xposed Frameworks, Substratum Themes, among others.
However, all these tweaks do bring in some associated risks as well. If not done correctly, then it might lead to a few issues. The most general ones include the device getting into a boot-looped or a soft-brick. If that ever happens to your device, then you have landed at the right place. Given here are the detailed instructions to restore your OnePlus 6/6T device to stock OxygenOS by flashing the Stock ROM via Fastboot Commands. Follow along for the detailed instructions.
- How to Install OxygenOS OTA on Rooted OnePlus devices
- Download Stable Android 11 OxygenOS 11 for OnePlus 8/ 8 Pro
- How to Extract Stock Boot.img from OnePlus OxygenOS Stock ROM
Unbrick | Restore: OnePlus 6/6T to Stock via Fastboot Commands
Before we list out the instructions, there are a few requirements that you need to qualify. Make sure to go through them and only then proceed with the unbrick steps.
- Create a complete device backup, if possible. This is because we will have to wipe off all the data from your device via the fastboot-w command later on. So a backup beforehand is of utmost importance. Since most of you might be stuck in fastboot, it might be a tough job to do. But if your device is up and running, then please create a backup beforehand.
- Next up, install the Android SDK Platform Tools on your PC. This will provide you with the necessary ADB and Fastboot binary files.
These were the required files. You may now proceed ahead with the steps to restore your OnePlus 6/6T device to stock OxygenOS by flashing the Stock ROM via Fastboot Commands.
STEP 1: Boot OnePlus 6/6T to Fastboot Methods [3 Methods]
First and foremost, you will have to boot your OnePlus 6 device to Fastboot Mode. This could be done via 3 different methods, depending on the scenario you are facing as of now:
- If your device is soft-bricked, well then it might already be booted to Fastboot.
- If it is in a continuous boot-loop, then wait for the battery to dry out so that it powers off. Then plug in the charger and at the same time press and hold the Volume Up and Power button together. The timing is extremely important in this, if done at the right time, then you should have no issues in booting to Fastboot or Bootloader Mode.
- On the other hand, if your device is perfectly working then use the Advanced Reboot menu under Developer Options and access the Fastboot Mode option. Or you could also enable USB Debugging from Developer options and then use the adb reboot bootloader command. Anyways, once your device is booted to Fastboot Mode, head over to the next set of instructions. to restore your OnePlus 6/6T device to stock OxygenOS by flashing the Stock ROM via Fastboot Commands.
STEP 2: Download OnePlus 6/6T Stock OxygenOS ROM
Now head over to the OnePlus Support Forum and download the latest OxygenOS for your OnePlus 6. The firmware would be in ZIP format. If you see the firmware in JAR format, then simply use the 7 ZIP, WinZIP, WinRAR, etc extraction tool to extract its content.
- [GUIDE] Flash ROMs/Magisk/TWRP/Kernels on A/B Partition Devices
- Everything About Magisk- Manager, Modules and More
- Best Magisk Modules of 2020 [PART-1]
- Fix Magisk Module Bootloop without TWRP Recovery
STEP 3: Extract OnePlus 6 /6T Payload.Bin File
After extraction, you would notice that there aren’t any partition files. Rather you would see a payload.bin file. It is this file that is holding all the partition IMG files. So you will need to extract this patload.bin file to get hold of all the other files. In this regard, this guide should help you out: How to Extract Stock Boot. img from OnePlus OxygenOS Stock ROM.
Follow the steps given in this linked guide and you should all the files inside the Python output folder (again refer to the linked guide). For example, the above image shows all the files that I got after extracting the OnePlus 6 payload.bin file. Let’s now proceed to the next step to restore your OnePlus 6/6T device to stock OxygenOS by flashing the Stock ROM via Fastboot Commands.
STEP 4: Flash OnePlus 6/6T Stock ROM- The Initial Setup
Once you have got all the OxygenOS ROM extracted files, transfer them to the platform-tools folder. Inside the same folder, type in CMD in its address bar and hit Enter (see below image). This will launch the Command Prompt window. Now connect your device to the PC via USB cable. Make sure that is booted to Fastboot. Finally, you may now flash all the OnePlus Fastboot ROM files via Fastboot Commands.
Given below in STEP 5 we have listed all the commands for the same. Copy-paste the first command in the CMD window, hit Enter, then do so for the next one, and so on. Furthermore, some commands like when the system.img file is being flashed, will take up quite a lot of time. This is completely normal. Along the same lines, you might also get an “Invalid sparse file format at header magic” message. Well then it is not an error, just wait for a few seconds and it will automatically be gone.
- How to Fix TWRP Error 70 [With Screenshots]
- How to Fix TWRP Error 20 GApps after flashing LineageOS
- Fix TWRP Error 7 (While Flashing Custom ROM via TWRP)
- How to Boot into Recovery (TWRP/Stock) from Fastboot Mode
STEP 5: Restore OnePlus 6 Stock ROM via Fastboot Commands
Here are the required Fastboot commands to restore your OnePlus 6/6T device to stock OxygenOS by flashing the Stock ROM. The first command (fastboot -w) will completely wipe off all the data from your device, so make sure to have a backup beforehand. If you are doing just a normal upgrade, then you could skip this command. On the other hand, if you are fixing bootloop/softbrick or are coming from a custom ROM, then you will have to execute this command.
Then the command at the end (fastboot reboot bootloader) will reboot your device back to Fastboot Mode. After this, you may easily reboot to the OS from Fastboot either by bringing up the Reboot option via Volume Keys and then pressing the Power button to confirm the decision. Or you could also execute the fastboot reboot command to boot to the OS (only do so after all the files have been flashed and your device has been rebooted to Fastboot).
Android 10 Commands
fastboot flash aop_a aop.img
fastboot flash aop_b aop.img
fastboot flash bluetooth_a bluetooth.img
fastboot flash bluetooth_b bluetooth.img
fastboot flash boot_a boot.img
fastboot flash boot_b boot.img
fastboot flash dsp_a dsp.img
fastboot flash dsp_b dsp.img
fastboot flash dtbo_a dtbo.img
fastboot flash dtbo_b dtbo.img
fastboot flash modem_a modem.img
fastboot flash modem_b modem.img
fastboot flash oem_stanvbk oem_stanvbk.img
fastboot flash qupfw_a qupfw.img
fastboot flash qupfw_b qupfw.img
fastboot flash storsec_a storsec.img
fastboot flash storsec_b storsec.img
fastboot flash system_a system.img
fastboot flash system_b system.img
fastboot flash vbmeta_a vbmeta.img
fastboot flash vbmeta_b vbmeta.img
fastboot flash vendor_a vendor.img
fastboot flash vendor_b vendor.img
fastboot flash LOGO_a LOGO.img
fastboot flash LOGO_b LOGO.img
fastboot reboot bootloader
Android 11 Commands
Upon downloading and extracting the OnePlus 6 Android 11 (OxygenOS 11) firmware, here are the files that you will get, as shown in the below image. We will be flashing these files onto your device via Fastboot Commands to restore your OnePlus 6/6T device to stock OxygenOS. So without any further ado, let’s get started.
fastboot -w fastboot flash abl_a abl.img fastboot flash abl_b abl.img fastboot flash aop_a aop.img fastboot flash aop_b aop.img fastboot flash bluetooth_a bluetooth.img fastboot flash bluetooth_b bluetooth.img fastboot flash boot_a boot.img fastboot flash boot_b boot.img fastboot flash cmnlib_a cmnlib.img fastboot flash cmnlib_b cmnlib.img fastboot flash cmnlib64_a cmnlib64.img fastboot flash cmnlib64_b cmnlib64.img fastboot flash devcfg_a devcfg.img fastboot flash devcfg_b devcfg.img fastboot flash dsp_a dsp.img fastboot flash dsp_b dsp.img fastboot flash dtbo_a dtbo.img fastboot flash dtbo_b dtbo.img fastboot flash fw_4j1ed_a fw_4j1ed.img fastboot flash fw_4j1ed_b fw_4j1ed.img fastboot flash fw_4u1ea_a fw_4u1ea.img fastboot flash fw_4u1ea_b fw_4u1ea.img fastboot flash hyp_a hyp.img fastboot flash hyp_b hyp.img fastboot flash keymaster_a keymaster.img fastboot flash keymaster_b keymaster.img fastboot flash LOGO_a LOGO.img fastboot flash LOGO_b LOGO.img fastboot flash modem_a modem.img fastboot flash modem_b modem.img fastboot flash reserve_a reserve.img fastboot flash reserve_b reserve.img fastboot flash storsec_a storsec.img fastboot flash storsec_b storsec.img fastboot flash system_a system.img fastboot flash system_b system.img fastboot flash vbmeta_a vbmeta.img fastboot flash vbmeta_b vbmeta.img fastboot flash vendor_a vendor.img fastboot flash vendor_b vendor.img fastboot flash xbl_a xbl.img fastboot flash xbl_b xbl.img fastboot flash xbl_config_a xbl_config.img fastboot flash xbl_config_b xbl_config.img fastboot reboot bootloader
As mentioned before, your device will be booted to Fastboot mode due to the fastboot reboot bootloader command. You may now boot it to the OS right from the Fastboot Mode itself or use the fastboot reboot command. Do keep in mind that the first boot might take up some time. It is completely normal.
Furthermore, you might have to set up your device from scratch as a complete device wipe has taken place. On that note, let us know in the comments if you have any other queries related to the aforementioned steps. On that note, we conclude this guide to how to restore your OnePlus 6/6T device to stock OxygenOS by flashing the Stock ROM via Fastboot Commands.
- How to Update Magisk ZIP and Magisk Manager (without TWRP)
- Disable DM-Verity or Android Verified Boot without TWRP
- Fix Magisk Module Bootloop without TWRP Recovery
- How to Root Android Devices Without TWRP Recovery
40 thoughts on “Restore OnePlus 6/6T to Stock via Fastboot Commands”
The commands are only for flashing 13 .img files. I need to flash reserve.img which I accidentally deleted by advanced wiping from twrp.
Should I try “fastboot flash reserve reserve.img” or “fastboot flash reserve-a reserve.img fastboot flash reserve-b reserve.img”?
Apologies for the late reply. Well, true to my knowledge, fastboot flash reserve reserve.img should be the command. But I haven’t tested it myself. So if you are willing to try it on your own, then please share the result with us as well. Thanks in advance.
This method is lifesaver. But since some img files are skipped by flash scripts, the language packs, wallpapers, fonts default emojis and some other features do not display correctly (if someone has wiped the OS completely via custom recoveries). To get those skipped img files after flashing the phone by this method, I simply copied the entire zipped rom into the phone after booting and then from settings, did a local software upgrade. It automatically installed the remaining partitions instead of flashing the remaining img files through fastboot
Hi Anshul, thanks for bringing this to our notice. Many readers would benefit from it.
Sir Its saying
Erasing ‘userdata’ FAILED (remote: ‘Erase is not allowed in Lock State’)
Hi Pradhyumna, you will first have to unlock the bootloader [after booting to Fastboot Mode] via the fastboot oem unlock or fastboot flashing unlock command [it will wipe off all the data and could nullify the device’s warranty as well]
Where is the official list of these commands?
Hi Micheal, could you please be a little more specific regarding the “official” word here? These commands are indeed used to flash the official stock firmware released by OnePlus. if you have used the official keyword in some considerations, do let me know.
I was running LineageOS 17 and it was fun, but the rear camera is not working at all 🙁
So, I’m back to stock.
May I know if, after reinstalling stock rom, I can lock the boot loader ?
Hi JmKane, yes after you are back to stock, you could easily relock the bootloader. Just make sure that there are no custom binaries installed (such as modules, TWRP, etc). Then use the fastboot oem lock command to lock the bootloader.
Hi Sadique, thanks you very much for your in-depth explanation in this tutorial. Its awesome. It worked perfectly for me, i went from lineage os back to stock rom. I wish a happy new year and best luck for you!
Thank you so much Marvin for the encouraging words, glad that this article helped you.
I just wanted to say thanks for the great article!
I fucked up while installing lineageos and ended up in a soft boot, but your article helped me recover my phone back to a usable state!
Thanks so much!
Thank you so much for the encouraging words, glad that the guide proved to be useful
Hey I followed your guide and after command fastboot reboot I get booted right into fastboot. Basically everything is booting me into fastboot…
Hi Maciej, were all the other partition files flashed correctly. If yes, then could you try changing slots and see if it boots to the OS. You may refer to this guide: How to Check and Change Current Active Slot on Android
I am having the same issue MACIEJ had. Though trying the process again has now got me to the point where I am in a boot loop that only shows me the initial warning screen that the bootloader is unlocked and it keeps looping. If I hold vol down while in the loop it takes me to the OnePlus Recovery selection screen starting with language selection. I looked at the referenced guide for checking and changing active slots, but I’m new to this slot approach and don’t fully understand what I am trying to do. Should I be assigning a specific img file to a new slot if I get the ‘Invalid sparse file format at header magic’ message?
I am having some issues and what do you mean by changing slots? Please explain in detail as even in your given link I can’t understand what to do? Do I need to just change the slot instead of flashing all .img files into that inactive slot? No matter what I do it keep getting booted into the same screen of fast boot.
There are more .img files available in the output folder like india.img file since I am using the Indian variant so what about those files? we don’t need to flash them? like abl.img, india.img, keymaster.img, etc
Please reply as I was using cynogen mode and now my phone is dead going into just fastboot mode
You’re a hero, thank you so much!
Thank you so much Adam for the appreciation
I have the problem that the phone is locked in a reset loop and i cant access developer options to enable debugging mode in order to enable ADB or Fastboot commands. is there any way to achieving this any othe way? i can get the phone to be in fastboot mode.
Hi Lucas, USB Debugging is only needed to boot your device to Fastboot Mode. Since you are already in Fastboot, you could now directly use the Fastboot Commands to flash the firmware
Man, thank you man. You saved me from bricking a €500 device ^.^
Glad that it worked out for you 🙂
THANKYOU SOO MUCH SIR! AFTER TRYING ENDLESS PERMUTS AND COMBINATIONS AND HAVING SOMETHING OR THE ORTHER NOT WORKING (FLASHING STOCK FIRMWIRE WITH TWRP MADE INTERNAL STORAGE NOT ACCESSIBLE, SOME STOCK FIRMWIRE FLASHED WITH TWRP LEAD TO NOT BEING ABLE TO BYPASS GOOGLE ACCESS DEVICE AT STARTUP, SOO MANY ENDLESS FASTBOOT ERRROES, BOOT LOOPS I FACED IN THE PAST 36 HOURS) FINALLY THIS WORKED FOR ME. WAS SKEPTICAL INITALLY SEEING THE CUMBERSOME STEPS IT WOORRIED ME THAT EVEN ONE STEP WRONG OR THE PC NOT ACCEPETING SOME DRIVER ALL WOULD BE IN VEIN IT IT WENT SMOOTHLY AS DESCRIBED.
Well, it’s always great to receive such feedbacks. Thanks for these kinds words and I/’m glad that it worked out for you
lineageOS is nice all works BUT , i need all my google services working! so i decided to go back using this guide.
i was mining at the moment so my fastboot flash crashed in the middle… had a heart attack, then when got back to life, power off the device, fastboot again and started again.
it seems to work, rebooted, oem lock, rebooted and i’m typing this while my phone is booting again.
NEVER EVER AGAIN custom roms for working good mobiles, is just not worth it !!
love you all worked flawlessly,
Thanks a lot David for the appreciation, means a lot!
FAILED (remote: ‘Erase is not allowed in Lock State’)
How to solve this error? my device is bricked. So i cannot unloack bootloader
Bricked my phone thanks.
Hey, I tried doing this while going from lineage os 18.1 to oxygenOS a11 open beta 3. Once all the commands are executed, and I perform a reboot I get an error on my phone saying “Qualcom CrashDump Mode Attempted to kill init! exitcode=0x0000000b do_exit”
and it doesn’t proceed further. I can only go back to fastboot after this.
What do I do?
When I try to flash, it gives me error “Flashing is not allowed for Critical Partitions”. My bootloader was already unlocked. I did the “fastboot oem unlock” and “fastboot flashing unlock” and “fastboot flashing unlock_critical” commands and it tells me that the device is already unlocked. But still I can’t execute the actual flash images. The USB debugging is ON. Any idea what might have gone wrong?
Assalamualaikum Brother, I’m so worried about my phone. I recently purchased a used OnePlus 6 2 weeks ago. It had Android 9 installed at that time. I heard about Oxygen Updater app, updated it to Android 10, then Android 220.127.116.11. within same day from the app.
That’s when my frustration began, after the update 18.104.22.168.
My OnePlus 6 camera was working completely fine on Android 9/10 but 3-4 days after updating to Android 22.214.171.124., it started crashing. On 6-7th day it completely stopped working on stock Camera app.
It did not fall down at all or got pressed from anywhere anyhow. Be noted that I’m a very careful user.
Now when I click the Camera app, it opens the Camera with black screen and closes within two seconds. That’s it, no response at all. It does not switches to front camera at all. If I select any other Camera Mode (Video/Portrait) on back cam it closes without any response.
I then checked camera operation in some apps:
1- Instagram: By default Front cam opens. Front cam operates fine here and captures pictures.
2- Whatsapp: By default Back cam opens. Back cam is unresponsive, neither lets switching to Front cam.
Then I downloaded “HD Camera” app from Play store. Running this app, back camera is loaded by default so, at first it gives “Serious Camera Error” and switching to front camera is unresponsive. I open Gallery images from within the app and then back to camera, I click on Front camera and it switches to front camera. Then I can click images/videos with Front camera. I then again try to switch to back camera and “Failed to HD camera. Camera may be in use by another application?” message appears. Hence, back camera does not works.
I also noticed that in Face Unlock settings it lets Front Camera work. It recognized my face and lets it unlock the phone fine.
Then, I googled How to unlock Engineering Mode in OnePlus 6 and tested camera working in Engineering Mode:
1- Rear camera testing FAILED/unresponsive. (This is lower camera on the back)
2- Second Rear camera testing PASSED/camera image appears. (This is upper camera on the back)
3- Front camera testing PASSED/camera image appears.
Things that I have tried multiple times to cure the issue:
1- clearing Cache of Camera app
2- clearing Storage of Camera app
3- wiping Cache from Boot menu
4- doing Factory reset 5 times
5- rolling back to Android 10, then 9 but the problem still remains
6- tried Gcam, same behavior
As far as I know it may be a software issue since the issue happened right after updating to Android 11. Before that everything was working completely fine.
I followed some posts in OnePlus community, found multiple other users having the same issue after the update.
Could you please guide me on how can i get the Rear Camera to start working again?
i cannot execute the commands apart from fastboot -w, it shows an error of
flashing is not allowed for critical partitions
fastboot: error: command failed
I have followed all the steps
but getting this error for all the commands
FAILED (remote: Flashing is not allowed in Lock State)
This guide doesn’t work. I got to the “fastboot flash aop_a aop.img” command and got the error “Flashing is not allowed for Critical Partitions.” Tried to follow your other guide to solve that, but it didn’t work. Unfortunately now I’m sitting here with a softbricked phone because of this as well (boot loop).
I do not recommend this guide to anyone passing through.
Hi Sadique, this is really very helpful article.
My OnePlus 6 recently got into Qualcomm Crash dump mode and didn’t have data backup of my important documents & photos. After a lot of searching, found this & your related articles and read them.
Here the “fastboot -w” command indicates, it will wipe off whole data. What if I skip this command and follow all other steps, will my user data be saved and can I take backup once mobile is booted? Or please suggest me better way to have my data backup. Later I’m ready to do whatever to restore my mobile completely.
My device is in Locked bootloader state and getting an error while executing above said commands. But you didn’t mention anything related to that in this article, can you help here, how to do without unlocking? Because I need to take data backup.
Hello, thanks for the post I got something new today. But still have some questions.
1.) How this is different from MSM Tool Flashing. It is much easier and user-friendly as well.
2.) Is there any other method to install OTA updates. My one plus 6 was rooted. I rolled back it to Android 10 and it was working fine but after some days it suddenly stuck on Restart Loop. I tried to flash it with the same file again but the issue remains the same. I tried almost all Android 10 updates MSM flash I found on the internet it remains the same. Last hope is the later latest update for Android 10. But the issue is i am not able to find the MSM zip file. What i found is OTA update when i unzipped it PAYLOAD File in place of OPS file which is used by MSM tool. Can i flash OTA updates with this method. Can i directly download and flash the latest Android 11 update for OP6.
3.) As i said my device is stuck in Restart Loop. I am hopeless know even googling does not giving anything appropriate. Do you ever faced such problem and have the solution. thanks a lot. Please let me know. A quick reply will be appreciated.
while Flashing it shows “Flashing is not allowed for critical partitions” for several commands stating that they are failed.