[Nubia Red Magic 9 Pro] cuynu:
Unlock Red Magic 9 Pro Bootloader under Linux environment
​

NOTICE : THIS IS THE INSTRUCTION FOR PC THAT RUNNING LINUX BASED DISTROS, IF YOU ARE USING WINDOWS, REFER THIS THREAD INSTEAD : Redmagic 9 Pro Bootloader Unlock (Windows).

Spoiler content hidden.

DISCLAIMER: I AM NOT RESPONSIBLE IF YOUR PHONE BRICKS! YOU ARE FOLLOWING THIS GUIDE AND ITS YOUR CHOICE TO DO IT OR NOT TO DO IT AND YOU'RE THE ONE DOING IT.

TIRED WITH DRIVER SIGNATURE, FAILED TO INSTALL DRIVER OR ANY ISSUE WHEN UNLOCK BOOTLOADER ON WINDOWS? TRY ON LINUX!

Prerequisites :

- PC running Linux distros (Ubuntu, Mint, Arch, Debian, Manjaro, EndeavourOS, etc)

- Red Magic 9 Pro phone

- Little knowledges about terminal commands

- Red Magic 9 Pro Firehose : DOWNLOAD

- Engineering ABL : DOWNLOAD (abl_a) | DOWNLOAD (abl_b)

STEPS :

- Download the firehose loader, engineering abl from above

- Install necessary dependency :

For Arch Linux/Manjaro/etc

Open Terminal, paste the command and press ENTER

sudo pacman -S android-tools python python-pip python-setuptools git xz
sudo pacman -R modemmanager

For Debian/Ubuntu/Mint/etc

Open Terminal, paste the command and press ENTER

sudo apt install adb fastboot python3-dev python3-pip liblzma-dev git
sudo systemctl stop ModemManager
sudo systemctl disable ModemManager
sudo apt purge ModemManager

For Fedora/CentOS/etc

Open Terminal, paste the command and press ENTER

sudo dnf install adb fastboot python3-devel python3-pip xz-devel git

- Clone the EDL repository source code and firehose loader binaries :

Open Terminal, paste the command and press ENTER

git clone https://github.com/ColdWindScholar/edl.git
cd edl
git submodule update --init --recursive
pip3 install -r requirements.txt

For Arch, you may need to remove the restriction of pip before do the above step :

sudo rm /usr/lib/python3.12/EXTERNALLY-MANAGED

- Install EDL Tool by bkerler :

Open Terminal at edl directory, paste the command and press ENTER

sudo cp Drivers/51-edl.rules /etc/udev/rules.d
sudo cp Drivers/50-android.rules /etc/udev/rules.d
python3 setup.py build
sudo python3 setup.py install

If you have SELinux enabled, you may need to set it to permissive mode temporarily to prevent permission issues. SELinux is commonly used by RedHat-like distros (for example, RHEL, Fedora, and CentOS). You can set it to permissive run-time until next boot with the command :

sudo setenforce 0

Enter EDL Mode :

- Turn off your Red Magic

- Hold both Volume buttons and connect USB together

- Device should be detected as : Qualcomm, Inc. Gobi Wireless Modem (QDL mode), to check it, open Terminal, press lsusb and enter.

Bus XXX Device XXX: ID 05c6:9008 Qualcomm, Inc. Gobi Wireless Modem (QDL mode)

Load firehose loader to device :

Open Terminal at directory that contain firehose, engineering abl, paste the command and press ENTER

edl --loader=firehose-redmagic9pro.elf

The EDL tool should detect your device, and load the firehose loader.

Read original abl partition

Open Terminal at directory that contain firehose, engineering abl, paste the command and press ENTER

edl r abl_a abl_a_backup.bin --memory=ufs && edl r abl_b abl_b_backup.bin --memory=ufs

The original abl will be saved on the PATH that the terminal currently on, if you don't know where, use pwd command.

Flash Engineering ABL to device

Open Terminal at directory that contain firehose, engineering abl, paste the command and press ENTER

edl w abl_a abl_a_eng-redmagic9p.elf --memory=ufs && edl w abl_b abl_b_eng-redmagic9p.elf --memory=ufs

Engineering ABL should be flashed to device.

Reboot the device from the EDL mode

edl reset

Device will boot normally, but the bootloader isn't unlocked yet, you need enter Fastboot in order to unlock it

Enter Bootloader Mode :

- Enable USB Debugging mode from Developer Options, and reboot to bootloader (Fastboot) with this command in Terminal :

adb reboot bootloader

- Device should reboot to Bootloader (Fastboot) Mode

Unlock Bootloader :

- Open Terminal and paste this command to the Terminal, then press ENTER

fastboot flashing unlock

- Wait until it return with success message, then reboot the device with

fastboot reboot

- Bootloader should be unlocked!

Restore the backed up ABL :

- This only needed if you having any issues when using Engineering ABL !

- Enter EDL again, load the firehose as above steps

- Open Terminal at the directory that have saved original ABL file, paste this command, then press ENTER

edl w abl_a abl_a_backup.bin --memory=ufs && edl w abl_b abl_b_backup.bin --memory=ufs

- Reboot the device with command :

edl reset

ADDITIONAL (for rooting)

If you want to read the init_boot_a and init_boot_b partition for rooting with Magisk/Apatch, do this :

Enter EDL Mode :

- Turn off your Red Magic

- Hold both Volume buttons and connect USB together

- Device should be detected as : Qualcomm, Inc. Gobi Wireless Modem (QDL mode), to check it, open Terminal, press lsusb and enter.

Bus XXX Device XXX: ID 05c6:9008 Qualcomm, Inc. Gobi Wireless Modem (QDL mode)

Load firehose loader to device :

Open Terminal at directory that contain firehose, engineering abl, paste the command and press ENTER

edl --loader=firehose-redmagic9pro.elf

The EDL tool should detect your device, and load the firehose loader.

Read init_boot_a & init_boot_b partition

Open Terminal, paste the command and press ENTER

edl r init_boot_a init_boot_a_backup.img --memory=ufs && edl r init_boot_b init_boot_b_backup.img --memory=ufs

The original init_boot partition will be saved on the PATH that the terminal currently on, if you don't know where, use pwd command.

Patch both init_boot_a & init_boot_b with Magisk/APatch app and copy it back to your PC

Flash patched init_boot_a & init_boot_b partition to device

Copy the patched files to PC, and rename it to : "init_boot_a.img" and "init_boot_b.img"

Enter EDL Mode, and do the Enter EDL Mode & Load firehose loader to device step (otherwise skip if you already do that)

Open Terminal at the directory that have patched init_boot_a & init_boot_b partition, paste the command and press ENTER

edl w init_boot_a init_boot_a.img --memory=ufs && edl w init_boot_b init_boot_b.img

In some cases, you need disable vbmeta avb verification to be able to boot after flashed patched init_boot, do this by download the disabled vbmeta AVB flag here, and flash with edl tool on terminal :

edl w vbmeta_a vbmeta.img --memory=ufs && edl w vbmeta_b vbmeta.img

Reboot the device with command :

edl reset

Troubleshoots :

EDL tool throw error : AttributeError: 'req' object has no attribute 'version' :

- Reinstall EDL tool with latest fork : https://github.com/ColdWindScholar/edl.git

EDL tool does not recognize device :

Make sure device : Qualcomm, Inc. Gobi Wireless Modem (QDL mode) appears on hardinfo or lsusb

Pylzma dependencies failling to install (usually happens on Arch based distros) :

- Clone this fork

git clone https://github.com/electimon/pylzma.git

- Install manually

python setup.py build
sudo python setup.py install

Credits :

mvikrant97 for Firehose, Engineering ABL file and pictures for reference purpose

bkerler for EDL Tool implementation