[Guide] Unlock/Root/Update/Relock for BQ Aquaris X2 pro (zangyapro)

Search This thread

luk.giak

Member
Nov 2, 2017
17
27
Introduction
I'm writing this thread to summarize useful information about the BQ Aquaris X2 pro such as:

  1. preliminary actions (adb and fastboot configuration)
  2. unlocking the bootloader
  3. flash a factory image
  4. root the device (currently without TWRP)
  5. updating the device without losing root
  6. relocking the bootloader

I own this phone since July 2018. I started writing my notes in August 2018 in the form of a Google document (link here). I shared this document with some telegram groups and some people I know.
Now I that I think it can be more useful to summarize all my notes here on XDA so that all interested people can access it.

DISCLAIMER:
By attempting any of the processes listed in this thread you accept full responsibility for your actions. I have no responsibility about your actions.

1) Preliminary actions
1.1) Developer options, USB debugging and Unlock OEM
The first thing you need to do is to enable Developer options, USB debugging and Unlock OEM. Hence:
  • enable “Developer options” by hitting 7 times on the build number (Got to settings --> about phone)
  • enter the new menu “Developer options” and,
  • enable “USB debugging”
  • enable “Unlock OEM”

1.2) Download and configure abd and fastboot
All steps listed in this guide will require the use of Google Platform tools. I suggest the use of the one provided by Google here: https://developer.android.com/studio/releases/platform-tools.

Download the one for your operating system:
View attachment 4655394

Be sure that your terminal can access adb and fastboot from every position by configuring the PATH. I'm use to configure the PATH on the fly when I need it. As I said before, I work on Linux/macOS where you can set the PATH by:
  • opening a terminal and running:
Code:
export PATH=$PATH:path_to_platform_tools

2) Unlock the bootloader
Unlocking the booloader will wipe your phone. So backup your data first.
The good news here is that this phone can be handled like a Nexus/Pixel phone. Therefore, the procedure to unlock the bootloader is straightforward:

  1. do all stuff at point 1.1 and 1.2
  2. open a terminal
  3. plug your phone to the PC
  4. reboot into the bootloader

    Code:
    adb reboot bootloader
  5. run the code:
    Code:
    fastboot flashing unlock
  6. now you have to wait until your phone reboots. It takes a while, don't panic!!! When the phone is on the initial screen turn it off and reboot into the bottloader again by holing 'power + volume down'.
  7. run the code:
    Code:
    fastboot flashing unlock_critical
  8. it's done. Your bootloader is completely unlocked. Now, you only have to wait again for the reboot.

3) Flash a factory image
As you probably know, BQ releases a factory image at each update at this link factory images. Factory images are very useful to perform a very clean install. Are you experiencing some issues with your phone and none of the trick you tried solved it? If it is a software issue a clean flash with a factory image will likely remove the issue.
Keep in mind that by flashing a factory image you will wipe also the userdata partition. So backup your data first. Now let's see how to flash the factory image:

  1. you need an unlocked bootloader (see previous sections)
  2. download the factory image from this link
  3. unzip the archive
  4. open a terminal at this folder
  5. be sure to have abd and fastboot properly configured (see previous sections)
  6. run the script to flash all (*):
    Code:
    ./sdm660_fastboot_all_images.sh
  7. wait the end of the process. The phone will reboot.

(*) on Windows you have to deal with the file sdm660_fastboot_all_images.bat. I suppose it's similar but I've never done it on Windows.

4) Obtain ROOT privileges
Nowadays, the most common tool to obtain root privileges is Magisk. Many people here know very well what Magisk is and how to install it with TWRP. However, TWRP is not yet ready for BQ Aquaris X2 pro, hence, we must follow the procedure for installing it without the custom recovery.
When I wrote the document in August I find very informative this guide by @nathanchance. It's for the pixel 2XL but, as I told you before, it works perfectly also for the BQ Aquaris X2 pro (zangyapro). So here I summarize what @nathanchance already posted. All credits must go to him.

Here you have the steps:
  1. Download the Magisk zip from the official thread and install the manager from the zip.
  2. Grab a boot image to patch (either the one from the latest factory image or a custom kernel one) and push it to your device:
    Code:
    adb push <path_to_file> /sdcard/Download
  3. Open Magisk Manager and click the Install button.
  4. Click "Install" at the first prompt then choose "Patch Boot Image File". A file manager will pop up.
  5. Select the boot image you want to patch and let Magisk Manager patch it.
  6. Pull it off your device:
    Code:
    adb pull /sdcard/MagiskManager/patched_boot.img
  7. Reboot into the bootloader:
    Code:
    adb reboot bootloader
  8. Flash the boot image and reboot.
    Code:
    fastboot flash boot patched_boot.img
    fastboot reboot
  9. Open Magisk Manager and you should be rooted!

Please note that it exists also a specific thread where the author also provides the patched boot.img files for download. Hence, you can start from point 6 without patching the boot.img by yourself. Take care of selecting the right one. Here you have the thread link.

5) Update the ROM without loosing root
To the best of my knowledge, the only way to update keeping root is by using the factory images provided by BQ.

  1. Download the factory image of the latest firmware (link)
  2. Extract the file zip and upload the file boot.img on your phone
    Code:
    adb push <path_to_file> /sdcard/Download
  3. Open Magisk Manager and click the Install button.
  4. Click "Install" at the first prompt and then choose "Patch Boot Image File". A file manager will pop up.
  5. Select the boot image you want to patch and let Magisk Manager patch it.
  6. Pull it off your device:
    Code:
    adb pull /sdcard/MagiskManager/patched_boot.img
  7. Place the file patched_boot.img in the folder of the BQ firmware unzipped at point 2
  8. Make a copy of the file sdm660_fastboot_all_images (.sh in Mac/Liux and .bat on Windows).
  9. Rename the file, I called it sdm660_fastboot_upgrade.sh
  10. Change the following lines (this will preserve root privileges on your phone):
    Code:
    fastboot flash boot_a boot.img # <-- delete this line
    fastboot flash boot_a patched_boot.img # <-- add this line
  11. Delete the following line (this will prevent your data to be wiped):
    Code:
    fastboot flash userdata userdata.img # <-- delete this line
  12. Run from your terminal
    Code:
    ./sdm660_fastboot_upgrade.sh (or bat)

I think that one can also update using the OTA. This will make you lose the root privileges and therefore, you will have to repeat the procedure at section 4. I've never tested this so, if you decide to do it, you are on your own.

6) Relock the Bootloader
By relocking the bootloader you will lose all your data, hence, backup them first.

To relock the bootloader you only need the following commands:
Code:
fastboot flashing lock_critical
fastboot flashing lock

Each command will wipe your data and will reboot the phone. Be patient waiting for the reboot and do not panic.
 
Last edited:

raudidroid

Member
Apr 29, 2009
38
4
First: Thanks for this really nice and comprehensive thread!

I have an important addition to point:
3. Open Magisk Manager and click the Install button.
Install Button will only appear if the phone has internet connection (Wifi or Mobile Data)
with this I can patch the boot image successfully
But unfortunately I can not run the "sdm660_fastboot_upgrade.sh.bat" it does not recognize my device.
When checking the commands in the batch I found that my device is acting really strange, sometimes giving different errors for the same command like:
Code:
C:\Android\X2proRoot\1.7.1_WithRoot>fastboot set_active _a
error: Device does not support slots.

C:\Android\X2proRoot\1.7.1_WithRoot>fastboot set_active _a
Setting current slot to 'a'...
FAILED (remote: Invalid Slot)
finished. total time: 0.004s

C:\Android\X2proRoot\1.7.1_WithRoot>fastboot set_active _a
error: Device does not support slots.
also strange:
Code:
C:\Android\X2proRoot\1.7.1_WithRoot>fastboot flash boot patched_boot.img
target didn't report max-download-size
sending 'boot' (50749 KB)...
FAILED (remote: Requested download size is more than max allowed
)
finished. total time: 0.004s

Probably some windows crap not working or an incompatibility of the installed platform tools / drivers and the ones from BQ...
 
Last edited:
  • Like
Reactions: luk.giak

luk.giak

Member
Nov 2, 2017
17
27
First: Thanks for this really nice and comprehensive thread!

I have an important addition to point:

Install Button will only appear if the phone has internet connection (Wifi or Mobile Data)

Thanks. I was not aware of this. And now I can't check this on my device because I started using GPay and I prefer to stay with no root and locked bootloader.

Maybe I will play again with the bootloader when TWRP for this device will be released. If it will ;)
 

raudidroid

Member
Apr 29, 2009
38
4
got it running!

Probably some windows crap not working or an incompatibility of the installed platform tools / drivers and the ones from BQ...

Probably it was just that. I Installed Ubuntu 16.04 LTS in a Vmware machine and followed the tutorial (important note here: do everything in a Terminal running under root).

Short moments of panic due to boot-loop included (I flashed a defective boot image [vmware drag and drop files obviously did not copy the whole file] )

for everybody who ends in a bootloop: just keep calm, switch off phone (>10s press power button) an very quickly when it is of press power and volume down to get into flashmode again (I had to try several times)
 
  • Like
Reactions: luk.giak

luk.giak

Member
Nov 2, 2017
17
27
Hey @raudidroid, when I answered to you the first time I did not read all the message or you edited it later. Only now I'm reading the issues you faced.

On Windows, what shell did you use? PowerShell?
I'm not sure about this because I banned Windows from my personal and working life several years ago, however, recently I read some posts of people having issues with PowerShell. If this is also your case next time try to use classic cmd.

Probably it was just that. I Installed Ubuntu 16.04 LTS in a Vmware machine and followed the tutorial (important note here: do everything in a Terminal running under root).
Regarding this the above quote, I'm quite sure that you do not need to be super user to apply any of the procedure listed in the guide.

for everybody who ends in a bootloop: just keep calm, switch off phone (>10s press power button) an very quickly when it is of press power and volume down to get into flashmode again (I had to try several times)
Since your are suggesting "... very quickly when it is of press power and volume down ... " I can imagine that you did this procedure while your phone was connected to the laptop/PC with the USB cable. In this condition, when you force the shutdown by pressing power for 10s, the phone reboots automatically. So my suggestion is to unplug it first, in this way the phone turn off without rebooting and you can comfortably enter in the bootloader with no hurry.
 

raudidroid

Member
Apr 29, 2009
38
4
On Windows, what shell did you use? PowerShell?
I'm not sure about this because I banned Windows from my personal and working life several years ago, however, recently I read some posts of people having issues with PowerShell. If this is also your case next time try to use classic cmd.
I was using CMD / Command Prompt on win10, but maybe I have to many ADBs/Drivers/... installed. got a really weird behavior...
Regarding this the above quote, I'm quite sure that you do not need to be super user to apply any of the procedure listed in the guide.
without root it wouldn't work, i got "no permissions (user in plugdev group; are your udev rules wrong?)"
with root everything ran smoothly
Since your are suggesting "... very quickly when it is of press power and volume down ... " I can imagine that you did this procedure while your phone was connected to the laptop/PC with the USB cable. In this condition, when you force the shutdown by pressing power for 10s, the phone reboots automatically. So my suggestion is to unplug it first, in this way the phone turn off without rebooting and you can comfortably enter in the bootloader with no hurry.

Oh! Yep, that sounds like it would have been the better way to do it ;)

Thanks for your post and your answers.

BTW: half-OT do you know any way to get netflix running after the rooting?
 

krillin666

Member
Feb 21, 2016
12
0
Hello, maybe someone can be of help to my situation.

I had my phone rooted in the last firmware version (1.7.3), and I was getting notifications to update to Android 9 pie for some time, however I was waiting to have some time to spare and first backup my files and do a factory update to pie and then root.

However, last nigh without warning my phone just rebooted and updated to pie, (firmware ver 2.0.2) and I lost root obviously. However, all my files, apps, etc were intact.

So today I decided to root my phone again. I download the firmware zip from BQ's site and then used Magisk (ver. 19.2) to patch the boot.img.

I rebooted to fastboot and did "sudo fastboot flash magisk_patched.img", and rebooted but the phone got stuck in the logo screen.

Then I used method 5 of this tutorial and ran ./sdm660_fastboot_upgrade.sh (with the mentioned modifications), however it bootlooped again. Then I flashed the original boot img and my phone booted just fine again, I tried to patch the img again, did again step 4 and it bootlooped again.

Any clues on how to successfully root ? Never had any problems updating and rooting from firmware 1.4.0 to 1.7.3.

Thank you for your time
 

Top Liked Posts

  • There are no posts matching your filters.
  • 5
    Introduction
    I'm writing this thread to summarize useful information about the BQ Aquaris X2 pro such as:

    1. preliminary actions (adb and fastboot configuration)
    2. unlocking the bootloader
    3. flash a factory image
    4. root the device (currently without TWRP)
    5. updating the device without losing root
    6. relocking the bootloader

    I own this phone since July 2018. I started writing my notes in August 2018 in the form of a Google document (link here). I shared this document with some telegram groups and some people I know.
    Now I that I think it can be more useful to summarize all my notes here on XDA so that all interested people can access it.

    DISCLAIMER:
    By attempting any of the processes listed in this thread you accept full responsibility for your actions. I have no responsibility about your actions.

    1) Preliminary actions
    1.1) Developer options, USB debugging and Unlock OEM
    The first thing you need to do is to enable Developer options, USB debugging and Unlock OEM. Hence:
    • enable “Developer options” by hitting 7 times on the build number (Got to settings --> about phone)
    • enter the new menu “Developer options” and,
    • enable “USB debugging”
    • enable “Unlock OEM”

    1.2) Download and configure abd and fastboot
    All steps listed in this guide will require the use of Google Platform tools. I suggest the use of the one provided by Google here: https://developer.android.com/studio/releases/platform-tools.

    Download the one for your operating system:
    View attachment 4655394

    Be sure that your terminal can access adb and fastboot from every position by configuring the PATH. I'm use to configure the PATH on the fly when I need it. As I said before, I work on Linux/macOS where you can set the PATH by:
    • opening a terminal and running:
    Code:
    export PATH=$PATH:path_to_platform_tools

    2) Unlock the bootloader
    Unlocking the booloader will wipe your phone. So backup your data first.
    The good news here is that this phone can be handled like a Nexus/Pixel phone. Therefore, the procedure to unlock the bootloader is straightforward:

    1. do all stuff at point 1.1 and 1.2
    2. open a terminal
    3. plug your phone to the PC
    4. reboot into the bootloader

      Code:
      adb reboot bootloader
    5. run the code:
      Code:
      fastboot flashing unlock
    6. now you have to wait until your phone reboots. It takes a while, don't panic!!! When the phone is on the initial screen turn it off and reboot into the bottloader again by holing 'power + volume down'.
    7. run the code:
      Code:
      fastboot flashing unlock_critical
    8. it's done. Your bootloader is completely unlocked. Now, you only have to wait again for the reboot.

    3) Flash a factory image
    As you probably know, BQ releases a factory image at each update at this link factory images. Factory images are very useful to perform a very clean install. Are you experiencing some issues with your phone and none of the trick you tried solved it? If it is a software issue a clean flash with a factory image will likely remove the issue.
    Keep in mind that by flashing a factory image you will wipe also the userdata partition. So backup your data first. Now let's see how to flash the factory image:

    1. you need an unlocked bootloader (see previous sections)
    2. download the factory image from this link
    3. unzip the archive
    4. open a terminal at this folder
    5. be sure to have abd and fastboot properly configured (see previous sections)
    6. run the script to flash all (*):
      Code:
      ./sdm660_fastboot_all_images.sh
    7. wait the end of the process. The phone will reboot.

    (*) on Windows you have to deal with the file sdm660_fastboot_all_images.bat. I suppose it's similar but I've never done it on Windows.

    4) Obtain ROOT privileges
    Nowadays, the most common tool to obtain root privileges is Magisk. Many people here know very well what Magisk is and how to install it with TWRP. However, TWRP is not yet ready for BQ Aquaris X2 pro, hence, we must follow the procedure for installing it without the custom recovery.
    When I wrote the document in August I find very informative this guide by @nathanchance. It's for the pixel 2XL but, as I told you before, it works perfectly also for the BQ Aquaris X2 pro (zangyapro). So here I summarize what @nathanchance already posted. All credits must go to him.

    Here you have the steps:
    1. Download the Magisk zip from the official thread and install the manager from the zip.
    2. Grab a boot image to patch (either the one from the latest factory image or a custom kernel one) and push it to your device:
      Code:
      adb push <path_to_file> /sdcard/Download
    3. Open Magisk Manager and click the Install button.
    4. Click "Install" at the first prompt then choose "Patch Boot Image File". A file manager will pop up.
    5. Select the boot image you want to patch and let Magisk Manager patch it.
    6. Pull it off your device:
      Code:
      adb pull /sdcard/MagiskManager/patched_boot.img
    7. Reboot into the bootloader:
      Code:
      adb reboot bootloader
    8. Flash the boot image and reboot.
      Code:
      fastboot flash boot patched_boot.img
      fastboot reboot
    9. Open Magisk Manager and you should be rooted!

    Please note that it exists also a specific thread where the author also provides the patched boot.img files for download. Hence, you can start from point 6 without patching the boot.img by yourself. Take care of selecting the right one. Here you have the thread link.

    5) Update the ROM without loosing root
    To the best of my knowledge, the only way to update keeping root is by using the factory images provided by BQ.

    1. Download the factory image of the latest firmware (link)
    2. Extract the file zip and upload the file boot.img on your phone
      Code:
      adb push <path_to_file> /sdcard/Download
    3. Open Magisk Manager and click the Install button.
    4. Click "Install" at the first prompt and then choose "Patch Boot Image File". A file manager will pop up.
    5. Select the boot image you want to patch and let Magisk Manager patch it.
    6. Pull it off your device:
      Code:
      adb pull /sdcard/MagiskManager/patched_boot.img
    7. Place the file patched_boot.img in the folder of the BQ firmware unzipped at point 2
    8. Make a copy of the file sdm660_fastboot_all_images (.sh in Mac/Liux and .bat on Windows).
    9. Rename the file, I called it sdm660_fastboot_upgrade.sh
    10. Change the following lines (this will preserve root privileges on your phone):
      Code:
      fastboot flash boot_a boot.img # <-- delete this line
      fastboot flash boot_a patched_boot.img # <-- add this line
    11. Delete the following line (this will prevent your data to be wiped):
      Code:
      fastboot flash userdata userdata.img # <-- delete this line
    12. Run from your terminal
      Code:
      ./sdm660_fastboot_upgrade.sh (or bat)

    I think that one can also update using the OTA. This will make you lose the root privileges and therefore, you will have to repeat the procedure at section 4. I've never tested this so, if you decide to do it, you are on your own.

    6) Relock the Bootloader
    By relocking the bootloader you will lose all your data, hence, backup them first.

    To relock the bootloader you only need the following commands:
    Code:
    fastboot flashing lock_critical
    fastboot flashing lock

    Each command will wipe your data and will reboot the phone. Be patient waiting for the reboot and do not panic.
    1
    First: Thanks for this really nice and comprehensive thread!

    I have an important addition to point:
    3. Open Magisk Manager and click the Install button.
    Install Button will only appear if the phone has internet connection (Wifi or Mobile Data)
    with this I can patch the boot image successfully
    But unfortunately I can not run the "sdm660_fastboot_upgrade.sh.bat" it does not recognize my device.
    When checking the commands in the batch I found that my device is acting really strange, sometimes giving different errors for the same command like:
    Code:
    C:\Android\X2proRoot\1.7.1_WithRoot>fastboot set_active _a
    error: Device does not support slots.
    
    C:\Android\X2proRoot\1.7.1_WithRoot>fastboot set_active _a
    Setting current slot to 'a'...
    FAILED (remote: Invalid Slot)
    finished. total time: 0.004s
    
    C:\Android\X2proRoot\1.7.1_WithRoot>fastboot set_active _a
    error: Device does not support slots.
    also strange:
    Code:
    C:\Android\X2proRoot\1.7.1_WithRoot>fastboot flash boot patched_boot.img
    target didn't report max-download-size
    sending 'boot' (50749 KB)...
    FAILED (remote: Requested download size is more than max allowed
    )
    finished. total time: 0.004s

    Probably some windows crap not working or an incompatibility of the installed platform tools / drivers and the ones from BQ...
    1
    got it running!

    Probably some windows crap not working or an incompatibility of the installed platform tools / drivers and the ones from BQ...

    Probably it was just that. I Installed Ubuntu 16.04 LTS in a Vmware machine and followed the tutorial (important note here: do everything in a Terminal running under root).

    Short moments of panic due to boot-loop included (I flashed a defective boot image [vmware drag and drop files obviously did not copy the whole file] )

    for everybody who ends in a bootloop: just keep calm, switch off phone (>10s press power button) an very quickly when it is of press power and volume down to get into flashmode again (I had to try several times)
    1
    For your information.

    I follow part 5 and updated my firmware to version 1.7.3 successfully. Thanks for this guide.
    1
    For your information.

    I follow part 5 and updated my firmware to version 2.0.0 (Android Pie 9) successfully.