Rooting OnePlus Nord CE 5G
Rooting - Concept
Rooting is the process of unlocking superuser permissions in an Android device, which is usually locked due to privacy and security reasons. It is done by various people with various objectives in mind; and in my case, it was to use the phone as a local server, where I can run different self-hosting programs (topic for another post) and get access to the full file system of Android to explore and learn more about it.
This article is meant to inform what exactly rooting is, while using an example of my experience of rooting my OnePlus Nord CE 5G. Its primary aim is to inform you about rooting Android devices, while also giving the steps I followed to root my phone, with explanations for each step.
If your phone is not Nord CE 5G then I highly suggest that after reading this article, to check out the page for specific instructions for your phone model - XDA Rooting Tutorials. It offers ways to root various models of phones from various brands, but they could be difficult for a beginner with limited experience to follow along, as they are usually more directly written, with minimal explanations given for each step.
- Rooting involves enabling the boot loader on your phone, which factory resets your phone, i.e, all the data on your phone will get wiped out, so proceed after backing up all the important data on your phone.
- My guide is intended and tested with OnePlus Node CE 5G but should work on most of OnePlus devices, but I can’t guarantee it, so if you have a different model, try at your own risk!
- Even if I have succeeded in rooting my phone using the following steps, there is a chance that the procedure may fail and may end up bricking your phone. So be aware of the risks, before proceeding.
- Some apps (like banking apps) refuse to work on rooted phones, so if you need to use them, do not root your phone.
- You may not get official updates to your phone anymore, so keep that in mind before rooting your phone.
- Your phone warranty gets voided if you unlock the bootloader.
Requires
- A OnePlus Nord CE 5G (As mentioned above, it should work in other OnePlus Devices, but I suggest you follow the set of instructions meant for your phone specifically)
- A PC or Laptop with Windows, MacOS, or GNU + Linux OS
- USB-A to USB-C Cable with data transmission and charging capability (OnePlus Red Cable can be used).
General Outline
- Unlocking the boot-loader.
- Getting the
boot.img
file. - Use Magisk to root your phone.
- Test if your phone got successfully rooted.
The Procedure
Before I start, I have tried to explain every command I have shown to help you understand what exactly you are doing, and not just copy down commands without any understanding. This should help understand the procedure in general, and also help build confidence in what you are doing.
Step 1 - Unlocking the bootloader
Enable the Developer Mode
- Open Settings
- Go to About Device > Version
- Here you will find Build Number, click on it until there is a prompt with the message - “You are now a developer!”.
Enable Required Developer Options
- In Settings go to System Settings > Developer Options
- Enable OEM unlocking and USB debugging (enable the Stay Awake option as it is convenient, as the setting lacks the never sleep option)
The above 2 options enable the following:
- OEM unlocking allows you to unlock the bootloader using the steps below
- While USB debugging allows the PC to interact with the phone via USB and run commands on the phone.
Download adb
and fastboot
- Download the Android SDK Platform Tools
- You will get a .zip folder, unzip it and delete the .zip folder.
- Then make sure you can access these tools from the Command Line.
- For Windows: Copy the files (not the folder) to any of the folders which are returned from Powershell when you enter the command -
echo %PATH%
. - For MacOS and Linux: Copy the files (not the folder) to any of the folders which are returned from the Terminal when you enter the command -
echo $PATH
(on bash/zsh, no idea about other shells). - You could add the folder you downloaded to the path, yourself if you know how to, or else you could
cd
into the rectory with the binaries.
- For Windows: Copy the files (not the folder) to any of the folders which are returned from Powershell when you enter the command -
- Bootloader - It is a piece of code responsible for the booting process, which includes loading the operating system’s kernel into the memory of the computer
- Android SDK Platform Tools - These are tools that are part of the Android SDK (Software Development Kit), which are made to be used to interface with the android devices
adb
stands for Android Debug Bridge and is a utility that enables connection between a PC and a phone, and accomplishes a variety of operations.fastboot
is mainly used to flash stuff onto android devices via USB.- Flashing is the process of updating the firmware, with a new one
Connect the phone to your PC
- Use a cable with both data transmission (for USB debugging) and charging (so that the phone doesn’t die in between due to the battery) capacity.
- And make sure you allow your PC to use USB Debugging by accepting the prompt that appears when you plug in your phone.
CLI Commands to unlock the bootloader
- Open your Terminal/Powershell
- Run
adb devices
- If you get a device in the list, then everything is ok, else you need to make check the following and re-run the above command
- USB debugging has not been enabled
- You have not allowed your PC/Laptop permission to the phone.
- If your cable is faulty and can’t transmit data.
- If you get a device in the list, then everything is ok, else you need to make check the following and re-run the above command
- Run
adb reboot bootloader
- This option will restart your phone, so after running this your phone should go blank for a moment.
- Run
fastboot oem unlock
- It will not work if you have not enabled the OEM Unlocking setting in Developer Options
- Then use the volume buttons to choose the option - “Unlock the Bootloader” and press the power button to select it and start the process. It will take some time so wait for a bit.
adb devices
- List all the devices connected to the PC with USB Debuggingadb reboot bootloader
- Makes your phone boot into the bootloaderfastboot oem unlock
- Unlock the OEM safeguard placed on the bootloader
Re-setup your phone
After the above is done, you will need to set up your phone to the point we can proceed.
Step 2 - Get boot.img
Use Oxygen Updater
- Check if your phone is supported by the app by visiting its site at - Oxygen Updater Website, and at the time of writing, Nord CE is supported.
- Download the app from Play Store - Play Store Link
- Now start up the app and follow the prompts while keeping in mind that we will need - “Stable(full)” files, for our purpose.
- Go to the settings of the app and enable the advanced setting, to get access to the latest version.
- Now go back to the home page, here you will see the latest update note, with a download button below with should be a few Gigabytes. Download it
- If the file is not in GBs then check if you have selected Full or not
- Oxygen Updater allows you to install official update files that OnePlus rolls out, called OTA (Over The Air) files
- Types of OTA files available
- “Stable”: Stuff that has been released onto your phone officially and is known to work
- “Full”: The full package that you can flash to get your current device OS (“This is needed for rooting, as when we flash we want all the required files of the current version”)
- “Partial”: Stuff which is used if you are at an older version and want to upgrade to a newer version (this is useful if you want to update your phone yourself to a newer supported version)
- Enabling advanced allows you to download the latest stable and also later versions.
OTA (Over the air) Payload Dump
- Run
adb pull /storage/self/primary/<filename>.zip ./
- Replace <filename> with the name of the .zip file that gets downloaded from Oxygen Updater - Unzip the above file
- In MacOS download the app - “Unarchiver” from Mac Store to unzip, as the normal uncompressing software can have issues in unzipping the .zip file
- Download the Payload Dumper and Dependencies
- Download python if you don’t have it already
- If on Windows and you don’t have Python, then download it from python.org
- While MacOS and major Linux distros usually include Python3 inside them
- Get the required scripts
- Go to the Payload Dumper - GitHub
- Click on the green button with the name “Code”, and download the zip and unzip it. If you have git installed then -
git clone https://github.com/vm03/payload_dumper.git
- If you don’t have pip/pip3 in your system (to test type pip -V or pip3 -V). To install run
python3 -m ensurepip --upgrade
- Download the required dependencies
- In the command line go to the folder just downloaded using the
cd
command - Download the dependencies with -
pip3 install -r requirements.txt
- In the command line go to the folder just downloaded using the
- Download python if you don’t have it already
- Use Payload Dumper
- Copy the “payload.bin” you got from the un-zipped folder (from step 2-2) to the current directory (i.e, the file which you downloaded from GitHub)
python3 payload_dumper.py payload.bin
- To make the boot.img in the directory “output”
adb pull <path1> <path2>
- It copies data on the phone that is on path 1 to your PC’s path2 (path is called file address in Windows, it is something you write on the Address Bar in the File Explorer)/storage/self/primary/
- The directory (aka folder) which holds all the data you can access on your phone’s file app./
- The file your PC has its terminal on when you run a command (If you want to know what the directory path is, type -pwd
on Terminal/Powershell)payload.bin
- Contains individual partition images- Payloader Dumper - It extracts from payload.bin and generates the boot.img
boot.img
- It is the boot image file, and in this case, it holds all the data required to boot into Android
Step 3 - Using Magisk and Rooting
Install Magisk and path boot.img
- Go to Magisk’s GitHub Page, on your phone
- Click on “Releases” and on the latest release, download the .apk file
- On your phone, using the file app try to open the .apk file and then give the required permission, to get an install prompt where you install the application.
adb push boot.img /storage/self/primary/
- To copy theboot.img
file- Open the Magisk app and click “Install Magisk” > select patch file > select the
boot.img
and proceed - Once everything is done Magisk will return complete and in the download folder the patched file will be stored
adb pull /storage/emulated/0/Download/magisk_patched-<number>.img .
- To copy the patched file to your PC/Laptop
adb push <path1> <path2>
- It copies data on path 1 of the PC to your phone’s path2- Magisk - Software used to root Android Devices
Root Phone
adb reboot bootloader
- To reboot into bootloaderfastboot getvar current-slot
- To get the current slot. Either a/bfastboot flash boot_<prep_step_result> magisk_patched-<number>.img
- Flash .imgfastboot reboot
- To reboot the phone
Step 4 - Check if Rooting was Successful
Finally, check if everything went properly
Download Root Checker Basic (or any other root checkers available) from Play Store and use it to check if you have a successfully rooted phone.
Resources used
- magnusPI (2021) Short and sketchy guide to rooting, XDA Forums. XDA Forums. Available at: https://forum.xda-developers.com/t/short-and-sketchy-guide-to-rooting.4318605/ (Accessed: February 17, 2023).
- Razzaq, ABD (2022) How to Root OnePlus Nord CE 5G using magisk without TWRP, Get Droid Tips. Available at: https://www.getdroidtips.com/root-oneplus-nord-ce-5g/ (Accessed: February 17, 2023).