Contents

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.

Note

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.

Risks - Read Before Proceeding!
  1. 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.
  2. 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!
  3. 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.
  4. Some apps (like banking apps) refuse to work on rooted phones, so if you need to use them, do not root your phone.
  5. You may not get official updates to your phone anymore, so keep that in mind before rooting your phone.
  6. Your phone warranty gets voided if you unlock the bootloader.

Requires

  1. 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)
  2. A PC or Laptop with Windows, MacOS, or GNU + Linux OS
  3. USB-A to USB-C Cable with data transmission and charging capability (OnePlus Red Cable can be used).
Note
Though I have tried to make this article easily understandable for everyone, it is still preferred to have some experience with the CLI (Command Line Interface), on your PC or Laptops. And please note, I am asking to use the Powershell on Windows as, it has aliases for most of the bash commands, which helps me here. So some of the commands below may not work at all if done on Command Prompt.

General Outline

  1. Unlocking the boot-loader.
  2. Getting the boot.img file.
  3. Use Magisk to root your phone.
  4. Test if your phone got successfully rooted.
Note
This article doesn’t use TWRP for rooting (and also at the time of writing, there was no TWRP image available for Nord CE).

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.

Warning
I am providing information on the Rooting process of an Android phone while giving the steps I followed with my phone as an example, but I take no liability if you lose data or brick your phone while following the instructions. These instructions are meant to showcase how exactly I rooted my phone, and are valid for OnePlus Nord CE 5G at the time of writing, but due to future updates they may no longer work, so check in XDA Rooting guides for the latest instructions.

Step 1 - Unlocking the bootloader

Enable the Developer Mode

  1. Open Settings
  2. Go to About Device > Version
  3. Here you will find Build Number, click on it until there is a prompt with the message - “You are now a developer!”.
More Info
Developer mode provides access to additional options which allows you to make changes to your phones

Enable Required Developer Options

  1. In Settings go to System Settings > Developer Options
  2. Enable OEM unlocking and USB debugging (enable the Stay Awake option as it is convenient, as the setting lacks the never sleep option)
More Info

The above 2 options enable the following:

  1. OEM unlocking allows you to unlock the bootloader using the steps below
  2. While USB debugging allows the PC to interact with the phone via USB and run commands on the phone.

Download adb and fastboot

  1. Download the Android SDK Platform Tools
  2. You will get a .zip folder, unzip it and delete the .zip folder.
  3. Then make sure you can access these tools from the Command Line.
    1. 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%.
    2. 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).
    3. 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.
More Info
  1. 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
  2. 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
  3. 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.
  4. fastboot is mainly used to flash stuff onto android devices via USB.
  5. Flashing is the process of updating the firmware, with a new one

Connect the phone to your PC

  1. 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.
  2. 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

  1. Open your Terminal/Powershell
  2. Run adb devices
    1. 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
      1. USB debugging has not been enabled
      2. You have not allowed your PC/Laptop permission to the phone.
      3. If your cable is faulty and can’t transmit data.
  3. Run adb reboot bootloader
    1. This option will restart your phone, so after running this your phone should go blank for a moment.
  4. Run fastboot oem unlock
    1. It will not work if you have not enabled the OEM Unlocking setting in Developer Options
  5. 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.
More Info
  1. adb devices - List all the devices connected to the PC with USB Debugging
  2. adb reboot bootloader - Makes your phone boot into the bootloader
  3. fastboot 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

  1. 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.
  2. Download the app from Play Store - Play Store Link
  3. Now start up the app and follow the prompts while keeping in mind that we will need - “Stable(full)” files, for our purpose.
  4. Go to the settings of the app and enable the advanced setting, to get access to the latest version.
  5. 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
    1. If the file is not in GBs then check if you have selected Full or not
More Info
  1. Oxygen Updater allows you to install official update files that OnePlus rolls out, called OTA (Over The Air) files
  2. Types of OTA files available
    1. “Stable”: Stuff that has been released onto your phone officially and is known to work
    2. “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”)
    3. “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)
  3. Enabling advanced allows you to download the latest stable and also later versions.

OTA (Over the air) Payload Dump

  1. Run adb pull /storage/self/primary/<filename>.zip ./ - Replace <filename> with the name of the .zip file that gets downloaded from Oxygen Updater
  2. Unzip the above file
    1. In MacOS download the app - “Unarchiver” from Mac Store to unzip, as the normal uncompressing software can have issues in unzipping the .zip file
  3. Download the Payload Dumper and Dependencies
    1. Download python if you don’t have it already
      1. If on Windows and you don’t have Python, then download it from python.org
      2. While MacOS and major Linux distros usually include Python3 inside them
    2. Get the required scripts
      1. Go to the Payload Dumper - GitHub
      2. 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
    3. 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
    4. Download the required dependencies
      1. In the command line go to the folder just downloaded using the cd command
      2. Download the dependencies with - pip3 install -r requirements.txt
  4. Use Payload Dumper
    1. 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)
    2. python3 payload_dumper.py payload.bin - To make the boot.img in the directory “output”
More Info
  1. 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)
  2. /storage/self/primary/ - The directory (aka folder) which holds all the data you can access on your phone’s file app
  3. ./ - 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)
  4. payload.bin - Contains individual partition images
  5. Payloader Dumper - It extracts from payload.bin and generates the boot.img
  6. 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

  1. Go to Magisk’s GitHub Page, on your phone
  2. Click on “Releases” and on the latest release, download the .apk file
  3. 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.
  4. adb push boot.img /storage/self/primary/ - To copy the boot.img file
  5. Open the Magisk app and click “Install Magisk” > select patch file > select the boot.img and proceed
  6. Once everything is done Magisk will return complete and in the download folder the patched file will be stored
  7. adb pull /storage/emulated/0/Download/magisk_patched-<number>.img . - To copy the patched file to your PC/Laptop
More Info
  1. adb push <path1> <path2> - It copies data on path 1 of the PC to your phone’s path2
  2. Magisk - Software used to root Android Devices

Root Phone

  1. adb reboot bootloader - To reboot into bootloader
  2. fastboot getvar current-slot - To get the current slot. Either a/b
  3. fastboot flash boot_<prep_step_result> magisk_patched-<number>.img - Flash .img
  4. fastboot reboot - To reboot the phone
More Info
This is the final step where the flashing takes place.

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

  1. 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).
  2. 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).