OnePlus provides the factory firmware for all its phones on a first-party download page. It's a great tool to have if you ever brick your phone, but it's not exactly easy to use. Instead of providing the factory firmware as a set of image files in an archive like Google does for Pixels, OnePlus tucks them away in a "payload.bin" file that you can't flash in fastboot.
So in this guide, you'll be learning how to take the payload.bin file you extracted from your OnePlus firmware ZIP and turn it into a set of IMG files you can actually use. For instance, you could take the boot.img file out and run it through Magisk to get a fastboot-flashable root method. Or you could re-flash the system.img and vendor.img files if you've applied a root mod and soft-bricked your phone, then you'd be back up and running.
Python is the programming language that is used to run the required commands for the Payload Dumper Tool. So before you can get started extracting your payload.bin file, you'll need to install Python on your computer. Hit up the one of the links below to download Python for your operating system.
- Python for Windows: 32-bit | 64-bit
- Python for macOS: 32-bit | 64-bit
- Python for Linux: Gzipped Tarball | XZ Compressed Tarball
Both the 32-bit and 64-bit versions for Windows are using the new web installer, which means it will download and install the latest files automatically. If you're using a Mac, you should be aware that Python only supports 64-bit versions going forward. 32-bit support for macOS has been officially dropped with version 3.8.1, but still exists with version 3.7.6 and below.
Once downloaded, open the installer and click the "Install Now" option to continue.
Follow the quick on-screen instructions, and it will install in a minute or so. Once the process finishes up, click the "Close" button to continue. From here, you can move onto the next step.
Now that Python has been installed on your computer, the next thing you'll need to do is grab the Payload Dumper Tool by geminids14. This is what will be used to actually take the "payload.bin" file and crack it wide open, so you can view the core system image files. You can download the tool using the link below.
Once the Payload Dumper Tool has been downloaded, you need to extract and move its contents over to your newly installed Python folder from the previous step.
You also need to take your "payload.bin" file and put it in the same Python folder as well so that everything is in the same location.
Now that you have all the necessary files in the Python folder, you need to open a command window before you can begin extracting the payload.bin file.
If you're using Windows, you can click the address bar in the Python folder, then type "cmd" and hit enter to open a command window right there. You can also hold the Shift key and right-click a blank spot in the Python folder, then select "Open PowerShell window here." Now the command window is ready to go! You can move onto the next step.
If you're using Mac or Linux, you can open the Terminal app, type "cd" and a space, then drag and drop the Python folder onto the command window itself. Hit enter and it will automatically link the Python folder to your Terminal app. Now the command window is ready to go! You can move onto the next step.
You're almost there now — the final step is to actually execute the proper commands and extract the payload.bin file. From the command window opened in the previous step, you'll want to copy and paste (or type) the following command, then hit enter to continue.
python -m pip install -r requirements.txt
Note: Mac, Linux, and Windows PowerShell users might have to add a period and a slash before entering certain commands (e.g., ./python -m pip install -r requirements.txt).
The above command will download the required dependencies for the process of extracting the payload.bin file. It won't take long for that to finish up.
After that, you'll want to copy and paste (or type) the next command, then hit enter to continue.
python payload_dumper.py payload.bin
The above command is where the magic happens — it will now begin breaking down your payload.bin file into individual system image files. Since this can take some time to complete, you'll need to have a bit of patience here.
Once the entire process has successfully finished, all of the system image files extracted from the payload.bin file will be placed in the "Output" folder of your Python directory.
The initial process can be kind of a pain to set up, but you're past the hard part now. From this point on, all you have to do is take a payload.bin file, drop it into the Python folder, then run the Payload Dumper Tool via the proper command. You can now use whatever system image files you want for your device and flash them in Fastboot Mode with ease. Enjoy!
Oh... and if you're working from home these days, be sure to check out Gadget Hacks' Working-From-Home Essentials.