• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

How To Guide Restore OnePlus 9 to Stock via Fastboot Commands

Search This thread

Slikkster2k

Senior Member
Mar 24, 2021
59
15
OnePlus 9
This guide assumes you have the SDK Platform Tools installed and working, along with USB drivers for your device (if needed), and have your full update zip which you've already extracted the payload.bin from, and then dumped the images using payload dumper. If you haven't done any of these things yet, there are plenty of other guides out there on how to do them.

Steps:

1. Reboot your device to the bootloader (power off, then hold volume up + power) and connect it to USB.
2. The following command will wipe your device. I found this to be necessary to recover my OnePlus 9:
Code:
fastboot -w
3. Now flash the following files:
Code:
fastboot flash boot boot.img
fastboot flash cpucp cpucp.img
fastboot flash dtbo dtbo.img
fastboot flash modem modem.img
fastboot flash oplusstanvbk oplusstanvbk.img
fastboot flash oplus_sec oplus_sec.img
fastboot flash qweslicstore qweslicstore.img
fastboot flash shrm shrm.img
fastboot flash splash splash.img
fastboot flash vbmeta vbmeta.img
fastboot flash vbmeta_vendor vbmeta_vendor.img
fastboot flash vbmeta_system vbmeta_system.img
fastboot flash vendor_boot vendor_boot.img
fastboot flash vm-bootsys vm-bootsys.img
4. Now reboot into userspace fastboot, aka fastbootd. If you don't do this, the remaining files cannot be flashed:
Code:
fastboot reboot fastboot
5. Flash the remaining files:
Code:
fastboot flash abl abl.img
fastboot flash aop aop.img
fastboot flash bluetooth bluetooth.img
fastboot flash devcfg devcfg.img
fastboot flash dsp dsp.img
fastboot flash featenabler featenabler.img
fastboot flash hyp hyp.img
fastboot flash imagefv imagefv.img
fastboot flash keymaster keymaster.img
fastboot flash multiimgoem multiimgoem.img
fastboot flash qupfw qupfw.img
fastboot flash tz tz.img
fastboot flash uefisecapp uefisecapp.img
fastboot flash xbl xbl.img
fastboot flash xbl_config xbl_config.img
fastboot flash product product.img
fastboot flash system system.img
fastboot flash system_ext system_ext.img
fastboot flash vendor vendor.img
fastboot flash odm odm.img
6. Final reboot:
Code:
fastboot reboot
7. If everything worked your phone should now boot into OxygenOS.

Note:
The files will be flashed to your currently active boot slot. If any of them fail to flash, switch to the other slot and start over from the beginning. I wasn't able to flash odm, product, system, system_ext and vendor to slot a, and had to use slot b instead. To check current slot:
Code:
fastboot getvar current-slot
To switch slots:
Code:
fastboot --set-active=a
or
Code:
fastboot --set-active=b

Use this guide at your own risk. I take no responsibility if you brick your device, set it on fire, or otherwise mess it up as a result of any of the above steps. That being said, it worked for me using 11.2.2.2.LE25AA available from the official OnePlus support website.
 
Last edited:

Slikkster2k

Senior Member
Mar 24, 2021
59
15
OnePlus 9
If you want, you can do the flashing easily with powershell, rather than running each command one after the other. Here is what I did:

1. Have fastboot.exe in your path, or in the same folder as all your extracted images. Open powershell and navigate to the folder with your boot images. Connect your phone to USB.
2. This will wipe your device! Reboot to the bootloader and run:
Code:
fastboot -w
3. Run:
Code:
gci -filter *.img | where {$_.Name.split('.')[0] -match 'boot|cpucp|dtbo|modem|oplusstanvbk|oplus_sec|qweslicstore|shrm|splash|vbmeta|vbmeta_vendor|vbmeta_system|vendor_boot|vm-bootsys'} | foreach-object { fastboot.exe flash $($_.Name.split('.')[0]) $_.Name }
4. Run:
Code:
fastboot reboot fastboot
5. Run:
Code:
gci -filter *.img | where {$_.Name.split('.')[0] -match 'abl|aop|bluetooth|devcfg|dsp|featenabler|hyp|imagefv|keymaster|multiimgoem|qupfw|tz|uefisecapp|xbl|xbl_config|product|system|system_ext|vendor|odm'} | foreach-object { fastboot.exe flash $($_.Name.split('.')[0]) $_.Name }
6. Run:
Code:
fastboot reboot
7. Proceed to boot normally.

The commands in steps 3 and 5 get a list of all files in the current directory with the .img extension, filter them to the correct ones to flash, and then flash them one after another.

If someone wants, I can probably throw together a script to run the whole process start to finish.

Edit: script attached. I've (unfortunately) had the opportunity to test it and fix all the bugs. So it works. You will need to have fastboot.exe accessible in your system PATH to run it.
 

Attachments

  • Fastboot-Flash.zip
    1.2 KB · Views: 87
Last edited:

toyanucci

Senior Member
May 28, 2010
849
346
OnePlus 9
If you want, you can do the flashing easily with powershell, rather than running each command one after the other. Here is what I did:

1. Have fastboot.exe in your path, or in the same folder as all your extracted images. Open powershell and navigate to the folder with your boot images. Connect your phone to USB.
2. Reboot to the bootloader and run:
Code:
fastboot -w
This will wipe your device!
3. Run:
Code:
gci -filter *.img | where {$_.Name.split('.')[0] -match 'boot|cpucp|dtbo|modem|oplusstanvbk|oplus_sec|qweslicstore|shrm|splash|vbmeta|vbmeta_vendor|vbmeta_system|vendor_boot|vm-bootsys'} | foreach-object { fastboot.exe flash $($_.Name.split('.')[0]) $_.Name }
4. Run:
Code:
fastboot reboot fastboot
5. Run:
Code:
gci -filter *.img | where {$_.Name.split('.')[0] -match 'abl|aop|bluetooth|devcfg|dsp|featenabler|hyp|imagefv|keymaster|multiimgoem|qupfw|tz|uefisecapp|xbl|xbl_config|product|system|system_ext|vendor|odm'} | foreach-object { fastboot.exe flash $($_.Name.split('.')[0]) $_.Name }
6. Run:
Code:
fastboot reboot bootloader
7. Proceed to boot normally.

The commands in steps 3 and 5 get a list of all files in the current directory with the .img extension, filter them to the correct ones to flash, and then flash them one after another.

If someone wants, I can probably throw together a script to run the whole process start to finish.
That would be helpful indeed. Would this script run on mac as well?
 
  • Like
Reactions: [email protected]

AxelM

Senior Member
Jul 10, 2007
87
8
OnePlus 9
@Slikkster2k: I tried your tutorial. At first it did not work...serveral errors occure during copying one file. On the second run I had to change the slot, than it runs through.

But now I am in a boot loop, during starting the oxygen.

While wiping I got this message:
Code:
fastboot: error: Cannot generate image for userdata

Which version of the OS did you use?

I tried to install the actual european rom (11.2.3.3) on my indian device from china ;) but this obviously did not work. Do you have any suggestions for me?
 

Slikkster2k

Senior Member
Mar 24, 2021
59
15
OnePlus 9
@Slikkster2k: I tried your tutorial. At first it did not work...serveral errors occure during copying one file. On the second run I had to change the slot, than it runs through.

But now I am in a boot loop, during starting the oxygen.

While wiping I got this message:
Code:
fastboot: error: Cannot generate image for userdata

Which version of the OS did you use?

I tried to install the actual european rom (11.2.3.3) on my indian device from china ;) but this obviously did not work. Do you have any suggestions for me?
I used 11.2.2.2.LE25AA as I said in the original post (this is the global variant, which matches my device). I am not sure if this works for cross-flashing, or if it's possible to cross-flash an Indian phone to EU. Have you tried restoring the Indian ROM? Does that work?

You're getting an actual boot loop? The error I was getting (and the reason I had to restore) was the phone booting to the bootloader or fastbootd (depending on the slot I tried) instead of Oxygen, because it couldn't mount the user partition due to encryption. In fastbootd an error was reported (I forget the exact one) which made me suspect it was a partition mounting issue. At no point was my phone actually boot looping, even during partial/failed flashes.

I've never encountered the error with fastboot -w, but I only did that on my phone once. From some searching online, it can be caused by an old version of the platform tools, so did you download the latest version?
 
  • Like
Reactions: AxelM

AxelM

Senior Member
Jul 10, 2007
87
8
OnePlus 9
@Slikkster2k: First of all, thank you for providing help :)

In deed, what worked was the indian first version. This i could flash and from there on everything works. Up to OS and than installing the latest european os. Now everything ist fine...

The error while whiping did not occure while using the indian version...so no clue why...

But now it works for me, thank you!
 
  • Like
Reactions: Slikkster2k

Slikkster2k

Senior Member
Mar 24, 2021
59
15
OnePlus 9
@Slikkster2k: First of all, thank you for providing help :)

In deed, what worked was the indian first version. This i could flash and from there on everything works. Up to OS and than installing the latest european os. Now everything ist fine...

The error while whiping did not occure while using the indian version...so no clue why...

But now it works for me, thank you!
Glad to hear you got it working!
 

toyanucci

Senior Member
May 28, 2010
849
346
OnePlus 9
This guide assumes you have the SDK Platform Tools installed and working, along with USB drivers for your device (if needed), and have your full update zip which you've already extracted the payload.bin from, and then dumped the images using payload dumper. If you haven't done any of these things yet, there are plenty of other guides out there on how to do them.

Steps:

1. Reboot your device to the bootloader (power off, hold volume up + power) and connect it to USB.
2. The following command will wipe your device. I found this to be necessary to recover my OnePlus 9:
Code:
fastboot -w
3. Now flash the following files:
Code:
fastboot flash boot boot.img
fastboot flash cpucp cpucp.img
fastboot flash dtbo dtbo.img
fastboot flash modem modem.img
fastboot flash oplusstanvbk oplusstanvbk.img
fastboot flash oplus_sec oplus_sec.img
fastboot flash qweslicstore qweslicstore.img
fastboot flash shrm shrm.img
fastboot flash splash splash.img
fastboot flash vbmeta vbmeta.img
fastboot flash vbmeta_vendor vbmeta_vendor.img
fastboot flash vbmeta_system vbmeta_system.img
fastboot flash vendor_boot vendor_boot.img
fastboot flash vm-bootsys vm-bootsys.img
4. Now reboot into userspace fastboot, aka fastbootd. If you don't do this, the remaining files cannot be flashed:
Code:
fastboot reboot fastboot
5. Flash the remaining files:
Code:
fastboot flash abl abl.img
fastboot flash aop aop.img
fastboot flash bluetooth bluetooth.img
fastboot flash devcfg devcfg.img
fastboot flash dsp dsp.img
fastboot flash featenabler featenabler.img
fastboot flash hyp hyp.img
fastboot flash imagefv imagefv.img
fastboot flash keymaster keymaster.img
fastboot flash multiimgoem multiimgoem.img
fastboot flash qupfw qupfw.img
fastboot flash tz tz.img
fastboot flash uefisecapp uefisecapp.img
fastboot flash xbl xbl.img
fastboot flash xbl_config xbl_config.img
fastboot flash product product.img
fastboot flash system system.img
fastboot flash system_ext system_ext.img
fastboot flash vendor vendor.img
fastboot flash odm odm.img
6. Reboot back into the bootloader:
Code:
fastboot reboot bootloader
7. You should now be able to continue booting normally by pressing the power button.

Note:
The files will be flashed to your currently active boot slot. If any of them fail to flash, switch to the other slot and start over from the beginning. I wasn't able to flash odm, product, system, system_ext and vendor to slot a, and had to use slot b instead. To switch slots:
Code:
fastboot --set-active=a
or
Code:
fastboot --set-active=b

Use this guide at your own risk. I take no responsibility if you brick your device, set it on fire, or otherwise mess it up as a result of any of the above steps. That being said, it worked for me using 11.2.2.2.LE25AA available from the official OnePlus support website.
My phone has been weird for a week or so occasionally freezing up and saying system ui has crashed or something so I followed these instructions last night to completely wipe and reset everything (after backing up). It worked perfectly!

My only suggestion would be for step 7 to be:

fastboot reboot

Since we're already using fastboot it's just quicker and less fiddly than using the power button 😊
 
  • Like
Reactions: Slikkster2k

Slikkster2k

Senior Member
Mar 24, 2021
59
15
OnePlus 9
My phone has been weird for a week or so occasionally freezing up and saying system ui has crashed or something so I followed these instructions last night to completely wipe and reset everything (after backing up). It worked perfectly!

My only suggestion would be for step 7 to be:

fastboot reboot

Since we're already using fastboot it's just quicker and less fiddly than using the power button 😊
Thanks, updated OP.
 
ok i kind of bricked my phone using this and i need a little help PLEASE?

Ok i tried the fist 2 steps 1. fastboot -w than the first list of commands using cmd with admin rights it worked...i think but it did load everything without issues...now i go to do the "fastboot reboot fastboot"

and now my phone is stuck on a black screen with nothing and i just hear the chime windows makes when you disconnect and reconnect a device..... and in the Device manager this comes up for 10 seconds than goes away for 5 than comes back NON STOP

i cant adb i cant do anything please help !
 

Attachments

  • Untitled.png
    Untitled.png
    32.1 KB · Views: 48

m0d hipp¥

Senior Member
Sep 27, 2006
174
96
I'm not sure if this will help you, but I had a lot of issues initially running this. First off you need to use the Oneplus drivers, I don't think the qualcom driver will work the same way. I could be wrong, but that's what I did. Secondly, you need to force install the driver because Windows doesn't like it.

Here are the steps I took.
1. Uninstall any old drivers.
2. Install the newest Oneplus Drivers from here https://oneplususbdrivers.com/
3. Extract the zip file and run the installer like normal
4. Once the installer finishes, you'll need to reboot your machine and bring up the Startup settings (hold down shift and reboot (keep holding down shift until you get a screen with options)) Then click advanced and startup settings and hit restart after that. Once the machines starts up, on the first boot you will have a bunch of options. Choose option 7 "disabling driver signature enforcement" mode.
5. Once Windows launches and you login, go back into the device manager and follow these steps:

right click the device --> update driver
Browse my computer for drivers
Let me pick from a list of available drivers on my computer
Show all Devices --> Next
Have Disk (Button)
Navigate to where you installed Oneplus drivers (Default: C:\Program Files (x86)\OnePlus USB Drivers)
Select "OnePlus_android_winusb.inf"
Select "Oneplus Android Bootloader Interface" and then just hit next/OK until it installs.

You might need to reboot after doing the above, but this worked for me.

----------------------------------------
The above should get your drivers working properly in all modes (adb, fastbootd, bootloader, normal)
One other issue that I ran into when I was using the powershell script was that I was seeing intermittent errors. After trial and error I realized that Windows was picking up a different version of fastboot. I was initially using the minimal adb/fastboot files, but if you compare those to the ones listed in the first post in the "SDK Platform Tools", they are very different from each other, so you need to make sure you use the SDK Platform Tools version. The minimal ADB/Fastboot version will NOT work.

After I got those 2 things ironed out, the powershell script ran without a hiccup and my phone is stock and booting without an issue.

I know I'm late to respond to this thread, but I hope someone finds this information helpful!
 

ilikepie___

Member
Apr 25, 2021
19
0
OnePlus 9 Pro
Mine keeps trying this and it isn't running and or rebooting into Fastbootd when the script is ran. Should I just try and invoke this manually? I've tried that as well an I'm seeming to get errors left and right with no resolve.
 

toyanucci

Senior Member
May 28, 2010
849
346
OnePlus 9
Actually, I ended up making my phone hard bricked to the point where it doesn’t even turn on at this point. I’m just going to send it in for repair, which is nothing short of being due to my stupidity.
It's probably stuck in edl mode. Nothing on the screen, no vibration or anything but it shows up in device manager when connected to a computer?

Try the man tool mentioned Here that worked for me.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 3
    This guide assumes you have the SDK Platform Tools installed and working, along with USB drivers for your device (if needed), and have your full update zip which you've already extracted the payload.bin from, and then dumped the images using payload dumper. If you haven't done any of these things yet, there are plenty of other guides out there on how to do them.

    Steps:

    1. Reboot your device to the bootloader (power off, then hold volume up + power) and connect it to USB.
    2. The following command will wipe your device. I found this to be necessary to recover my OnePlus 9:
    Code:
    fastboot -w
    3. Now flash the following files:
    Code:
    fastboot flash boot boot.img
    fastboot flash cpucp cpucp.img
    fastboot flash dtbo dtbo.img
    fastboot flash modem modem.img
    fastboot flash oplusstanvbk oplusstanvbk.img
    fastboot flash oplus_sec oplus_sec.img
    fastboot flash qweslicstore qweslicstore.img
    fastboot flash shrm shrm.img
    fastboot flash splash splash.img
    fastboot flash vbmeta vbmeta.img
    fastboot flash vbmeta_vendor vbmeta_vendor.img
    fastboot flash vbmeta_system vbmeta_system.img
    fastboot flash vendor_boot vendor_boot.img
    fastboot flash vm-bootsys vm-bootsys.img
    4. Now reboot into userspace fastboot, aka fastbootd. If you don't do this, the remaining files cannot be flashed:
    Code:
    fastboot reboot fastboot
    5. Flash the remaining files:
    Code:
    fastboot flash abl abl.img
    fastboot flash aop aop.img
    fastboot flash bluetooth bluetooth.img
    fastboot flash devcfg devcfg.img
    fastboot flash dsp dsp.img
    fastboot flash featenabler featenabler.img
    fastboot flash hyp hyp.img
    fastboot flash imagefv imagefv.img
    fastboot flash keymaster keymaster.img
    fastboot flash multiimgoem multiimgoem.img
    fastboot flash qupfw qupfw.img
    fastboot flash tz tz.img
    fastboot flash uefisecapp uefisecapp.img
    fastboot flash xbl xbl.img
    fastboot flash xbl_config xbl_config.img
    fastboot flash product product.img
    fastboot flash system system.img
    fastboot flash system_ext system_ext.img
    fastboot flash vendor vendor.img
    fastboot flash odm odm.img
    6. Final reboot:
    Code:
    fastboot reboot
    7. If everything worked your phone should now boot into OxygenOS.

    Note:
    The files will be flashed to your currently active boot slot. If any of them fail to flash, switch to the other slot and start over from the beginning. I wasn't able to flash odm, product, system, system_ext and vendor to slot a, and had to use slot b instead. To check current slot:
    Code:
    fastboot getvar current-slot
    To switch slots:
    Code:
    fastboot --set-active=a
    or
    Code:
    fastboot --set-active=b

    Use this guide at your own risk. I take no responsibility if you brick your device, set it on fire, or otherwise mess it up as a result of any of the above steps. That being said, it worked for me using 11.2.2.2.LE25AA available from the official OnePlus support website.
    2
    If you want, you can do the flashing easily with powershell, rather than running each command one after the other. Here is what I did:

    1. Have fastboot.exe in your path, or in the same folder as all your extracted images. Open powershell and navigate to the folder with your boot images. Connect your phone to USB.
    2. This will wipe your device! Reboot to the bootloader and run:
    Code:
    fastboot -w
    3. Run:
    Code:
    gci -filter *.img | where {$_.Name.split('.')[0] -match 'boot|cpucp|dtbo|modem|oplusstanvbk|oplus_sec|qweslicstore|shrm|splash|vbmeta|vbmeta_vendor|vbmeta_system|vendor_boot|vm-bootsys'} | foreach-object { fastboot.exe flash $($_.Name.split('.')[0]) $_.Name }
    4. Run:
    Code:
    fastboot reboot fastboot
    5. Run:
    Code:
    gci -filter *.img | where {$_.Name.split('.')[0] -match 'abl|aop|bluetooth|devcfg|dsp|featenabler|hyp|imagefv|keymaster|multiimgoem|qupfw|tz|uefisecapp|xbl|xbl_config|product|system|system_ext|vendor|odm'} | foreach-object { fastboot.exe flash $($_.Name.split('.')[0]) $_.Name }
    6. Run:
    Code:
    fastboot reboot
    7. Proceed to boot normally.

    The commands in steps 3 and 5 get a list of all files in the current directory with the .img extension, filter them to the correct ones to flash, and then flash them one after another.

    If someone wants, I can probably throw together a script to run the whole process start to finish.

    Edit: script attached. I've (unfortunately) had the opportunity to test it and fix all the bugs. So it works. You will need to have fastboot.exe accessible in your system PATH to run it.
    1
    If you want, you can do the flashing easily with powershell, rather than running each command one after the other. Here is what I did:

    1. Have fastboot.exe in your path, or in the same folder as all your extracted images. Open powershell and navigate to the folder with your boot images. Connect your phone to USB.
    2. Reboot to the bootloader and run:
    Code:
    fastboot -w
    This will wipe your device!
    3. Run:
    Code:
    gci -filter *.img | where {$_.Name.split('.')[0] -match 'boot|cpucp|dtbo|modem|oplusstanvbk|oplus_sec|qweslicstore|shrm|splash|vbmeta|vbmeta_vendor|vbmeta_system|vendor_boot|vm-bootsys'} | foreach-object { fastboot.exe flash $($_.Name.split('.')[0]) $_.Name }
    4. Run:
    Code:
    fastboot reboot fastboot
    5. Run:
    Code:
    gci -filter *.img | where {$_.Name.split('.')[0] -match 'abl|aop|bluetooth|devcfg|dsp|featenabler|hyp|imagefv|keymaster|multiimgoem|qupfw|tz|uefisecapp|xbl|xbl_config|product|system|system_ext|vendor|odm'} | foreach-object { fastboot.exe flash $($_.Name.split('.')[0]) $_.Name }
    6. Run:
    Code:
    fastboot reboot bootloader
    7. Proceed to boot normally.

    The commands in steps 3 and 5 get a list of all files in the current directory with the .img extension, filter them to the correct ones to flash, and then flash them one after another.

    If someone wants, I can probably throw together a script to run the whole process start to finish.
    That would be helpful indeed. Would this script run on mac as well?
    1
    @Slikkster2k: I tried your tutorial. At first it did not work...serveral errors occure during copying one file. On the second run I had to change the slot, than it runs through.

    But now I am in a boot loop, during starting the oxygen.

    While wiping I got this message:
    Code:
    fastboot: error: Cannot generate image for userdata

    Which version of the OS did you use?

    I tried to install the actual european rom (11.2.3.3) on my indian device from china ;) but this obviously did not work. Do you have any suggestions for me?
    I used 11.2.2.2.LE25AA as I said in the original post (this is the global variant, which matches my device). I am not sure if this works for cross-flashing, or if it's possible to cross-flash an Indian phone to EU. Have you tried restoring the Indian ROM? Does that work?

    You're getting an actual boot loop? The error I was getting (and the reason I had to restore) was the phone booting to the bootloader or fastbootd (depending on the slot I tried) instead of Oxygen, because it couldn't mount the user partition due to encryption. In fastbootd an error was reported (I forget the exact one) which made me suspect it was a partition mounting issue. At no point was my phone actually boot looping, even during partial/failed flashes.

    I've never encountered the error with fastboot -w, but I only did that on my phone once. From some searching online, it can be caused by an old version of the platform tools, so did you download the latest version?
    1
    @Slikkster2k: First of all, thank you for providing help :)

    In deed, what worked was the indian first version. This i could flash and from there on everything works. Up to OS and than installing the latest european os. Now everything ist fine...

    The error while whiping did not occure while using the indian version...so no clue why...

    But now it works for me, thank you!