How To Guide [GUIDE][WINDOWS] Bootloader Unlock/Re-Lock, Rooting with Magisk and flashing Firmwares

Search This thread

emgao

Member
Sep 15, 2023
12
0
Are you sure? Magisk usually renames the file, unless you've renamed it back? Can I see a screenshot of the Magisk patching process as it'll confirm the name of the image it writes?
You are right, my bad, here it is...
 

Attachments

  • Capture4.PNG
    Capture4.PNG
    33.5 KB · Views: 8

emgao

Member
Sep 15, 2023
12
0
I struggled quite a lot to install the proper drivers, in fact I managed only with the "install last adb and fastboot" script. Despite that I had problems as well to get thenfastboot recognized, in fact I have ee-launched the process with the phone in fastboot (something foreseen for the script btw). So except for the adb I for everything from the aforemenruoned file list...I am on w10 and I tried the process on there different PC by the way, succeeded only on one.

About the process? You mean opening the file, selecting it and processing it with Magisk? Or maybe I have lost something?!?
 

emgao

Member
Sep 15, 2023
12
0
The USB drivers can be fiddly.

The bit I need to see is the bit where you flash the patched boot image to your phone. That's what these commands are doing:

Code:
fastboot flash boot_a magisk_patched.img
fastboot flash boot_b magisk_patched.img

This is from step 15 - 19 in section 4 of the instructions from the first post.
I will send later today. Just a question, which driver have you used and did you download them and on which system you did the procedure? Could you please share them with me so I can download them?
 

emgao

Member
Sep 15, 2023
12
0
The USB drivers can be fiddly.

The bit I need to see is the bit where you flash the patched boot image to your phone. That's what these commands are doing:

Code:
fastboot flash boot_a magisk_patched.img
fastboot flash boot_b magisk_patched.img

This is from step 15 - 19 in section 4 of the instructions from the first post.
Here you are
 

Attachments

  • Capture6.PNG
    Capture6.PNG
    31.1 KB · Views: 7

emgao

Member
Sep 15, 2023
12
0
I have installed an app to verify it and I don-t have admin rights. Also, maybe I am wrong with it, if I am admin, Should I be able to remove google apps and not just disable them? Can you please confirm this?

Also, which OS have you installed?
 

Attachments

  • capture 7.PNG
    capture 7.PNG
    83.6 KB · Views: 5

emgao

Member
Sep 15, 2023
12
0
Thanks, that's a very helpful guide! I'm now running the latest available Android 13 image for my phone, happily rooted :cool:

As it's in the Sony Xperia 5 IV section of the forum it's important to note that you must use fastbootd or you won't be able to wipe the phone. As such, to summarise, the rooting steps are:

- Unlock bootloader
- Download and extract boot.img (on PC)
- Download Magisk and patch boot.img (on phone)
- Reboot to bootloader (adb reboot fastboot) then to fastboot (fastboot reboot fastboot)
- Flash patched boot.img, wipe phone, and reboot

Once rooted you probably want to:
- Install Displax's safetynet-fix to get Google Wallet, Netflix etc working
- Remove unwated bloatware using something like De-Bloater
that detail you mention about fastbootD... I think I have never implemented it. I mean, following the procedure the phone never goes into fastbootD, just the balck screnn of fastboot or the custom recovery...So if this is crucial please, help me to understand how I can it...I am getting heavily frustrated now with this process, I need help. Thank you!
 

Aakash12

Member
Apr 21, 2015
30
4
Thanks for the root guide, but I'm getting a bootloop.
My phone Model is XQ-CQ72, bought from singapore, running the latest firmware (android 13).
Magisk:v26.3, also tried with v26.1
There are 3 carriers available for my device on xperiafirm, and I have tried the boot img of all 3 of them and it always gets into a bootloop. I also wipe the data after every flash.

For safety, I always flash the patched boot.img file into slot a only, so that the other slot stays safe.
I have tried flashing from fastboot and fastbootd and it always get into bootloop.

Any help would be appreciated.
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 6

    [GUIDE][WINDOWS] Bootloader Unlock/Re-Lock, Rooting with Magisk and flashing Firmwares​

    Introducing this Guide​

    Hello there and welcome to My Guide for Your Xperia Smartphone. This Guide will walk with You thru the whole Process of installing Drivers, getting an unlock Key for Your Bootloader, rooting with Magisk and even flashing GSI Custom ROMs up to re-locking Your Bootloader and re-flashing Stock for the total Factory Reset. This Thread/Guide is not meant as Wiki n'or will it teach You about Android at all. Inform Yourself using Google to enjoy the total Freedom and Customization of Android... If You can't solve Problems Yourself, by communicating and research, don't touch Your Bootloader!

    IMPORTANT:
    2020+ Xperias are using fastbootd, and equivalent to fastboot which runs in Userspace (Same as Recoveries).
    You can access Your Recovery on Your Xperia by holding VolumeDown (-) & the Powerbutton (Your Device needs to be turned off before ofc). Release the Powerbutton after the Display turned on and hold VolumeDown (-) until You see the Recovery Screen. From there, You can enter fastbootd and fastboot. Labled as "Fastboot" for fastbootd and "Bootloader" which is the old fastboot. You can flash Kernels, Recoveries and other stuff from fastboot. Everything else like System Images (GSIs for example), Product Images, System_ext Images and any Userspace stuff has to be flashed from fastbootd. 2019 Xperias are still using fastboot only...
    Fastboot and Fastbootd has nothing to do with SONYs Flashmode on Xperias!


    INDEX:
    1. Requirements
    2. Installing Drivers
    3. Firmware Flashing
    4. Bootloader Unlocking & Magisk Root
    5. GSI ROM flashing with Fastboot (Optional)
    6. Bootloader Re-Locking (TheWayBack)
    7. Firmware Restoring after Re-Locking

    1. Requirements:
    • Read! Inform Yourself about the Tools You use...
    • Xperia Basics:
      Your Device is turned Off...
      Blue LED=Fastboot (Hold VolumeUp (+) & Connect to USB)
      Green LED=Flashmode (Hold VoumeDown (-) & Connect to USB)
    • Windows 10/11 for Firmware flashing & downloading
    • Xperia Bootloader Unlock Key (From HERE)
    • Platform Tools alias ADB and Fastboot (From HERE)
    • Fastboot and Flashmode Drivers (From HERE and HERE)
    • EMMA for Firmware Updates (From HERE)
    • XperiFirm for Firmware Downloads (From XDA)
    • Unsin to extract the Kernel .sin from XperiFirm (From XDA)
    • Magisk Manager to patch the extracted Kernel .sin (From GitHub)
    • A working Android System for the Magisk Kernel patching
    • GSI & vbmeta Image (From Google) (Optional)
    • A Backup of Your Internal Devices Storage (Optional)


    2. Installing Drivers:
    1. Download the Drivers from the Links above and extract them
    2. Install the downloaded and extracted Drivers by right clicking on the ***.inf Files "Install"


    3. Flashing Firmwares with EMMA:
    1. Download EMMA and install it
    2. Start EMMA and connect Your Device to USB (Flashmode)

    3.1. Downloading Firmwares with XperiFirm:
    1. Download and extract XperiFirm from the link above
    2. Run XperiFirm and Download the right Firmware for Your Device


    4. Bootloader Unlocking and Magisk Root:

    Note: Since You are going to unlock Your Bootloader, You may surely want to get Root. So let's start with Magisk or it will take more Time afterwards...

    1. Download UnSin from the link above and extract it somewhere
    2. Download the "Platform Tools" from Google and extract it to the root of Your main Windows Drive
    3. Download and install the Magisk Manager on Your Android Device
    4. Extract the File boot_********.sin (60MB+ File) with the Unsin Exe (Drag and drop the Image on the Exe)
    5. You will get a .img File which You can patch now with the Magisk Manager on Your Android Device
    6. Open the Magisk Manager and Install Magisk by selecting the Image File You just got from UnSin
    7. Copy the magisk_patched.img in /download from Your Device to the Platform Tools Folder
    8. Grab Your Device again, go to "About Phone" in the Settings and tap several Times on the build Version
    9. Go now to the Developer Settings under "System" and enable "OEM-Unlock" and "USB-Debugging"
    10. Use now the Platform Tools with this Commands (In Powershell):
    11. Type now (Step by Step):
      Code:
      cd\
      cd platform-tools
      Note: To use the Platform Tools Folder as environment for Fastboot and ADB. Or hold Shift and Make a right Click in the Platform Tools Folder to open the Command prompt there...

    12. Type now:
      Code:
      adb reboot bootloader
      You will get a prompt on Your Xperia Device. Your Device will Reboot afterwards...

    13. Now Your Bootloader Unlock Code:
      Code:
      fastboot oem unlock 0xYOURKEY

    14. Wait for it... And type now:
      Code:
      fastboot reboot

    15. Wait for Your Device to Wipe and Start. Once in the Android System, turn Your Device off without USB Connected

    16. Press and hold now the VolumeUp (+) Button while connecting to USB to enable the fastboot Mode

    17. Continue with flashing the Images for Root (Step by Step):
      Code:
      fastboot flash boot_a magisk_patched.img
      fastboot flash boot_b magisk_patched.img

    18. Wipe and Reboot:
    19. Code:
      fastboot -w
      fastboot reboot
      Note: Your are unlocked and rooted now! Enjoy Your Unleashed Device
      :)



    5. GSI flashing with Fastboot:

    Note: GSI ROMs can be found around the Web. Like here...
    Not all GSIs require the vbmeta change. You can use all GSIs that are made for ARM64 + A/B Devices. Play around. Systems can't damage Your Device since You keep the Stock Vendor & Kernel! You can use any Android Version! Don't forget to make backups if needed. You are going to Format Your Device!
    • Download a GSI Zip from Google
    • Extract the system.img and the vbmeta.img to Your Platform-Tools
    • Connect Your Device in Fastboot Mode and use Fastboot with:
      (On 2020+ Xperias run: "fastboot reboot fastboot" first after You booted into fastboot)
      Code:
      fastboot flash system_a system.img
      fastboot flash system_b system.img
      [Optional] fastboot --disable-verity --disable-verification flash vbmeta_a vbmeta.img
      [Optional] fastboot --disable-verity --disable-verification flash vbmeta_b vbmeta.img
      fastboot -w (This does Format Your Device and is needed everytime You change the GSI!)
      fastboot reboot


    6. Bootloader Re-Lock:
    • Flash the latest Firmware for Your Device with EMMA
    • Erase all Userdata before You continue (like with fastboot -w or via Recovery)
    • Just go into Fastboot mode and type in the command prompt (like before in this Guide):
    Code:
    fastboot oem lock
    • Wait for Your Device and disconnect it from USB
    • Done... Continue with Step 7.
    7. Firmware Restoring after Re-Locking:
    • Download and Install the "Xperia Companion" from SONY
    • Open the Xperia Companion and select Software Repair
    • Select that Your Device can't get recognized (or is a Smartwatch 3 lol)
    • Go to the next Page and select the Xperia Smartphone Option
    • Continue and wait for the Initialization
    • Press and hold Volume DOWN while connecting to USB (You will see the Green Flashmode LED again)
    Continue once Your Device gets recognized and let the Xperia Companion do his work...
    Done. Your Bootloader is locked again and almost all of Your DRMs are restored.
    1
    Thanks, that's a very helpful guide! I'm now running the latest available Android 13 image for my phone, happily rooted :cool:

    As it's in the Sony Xperia 5 IV section of the forum it's important to note that you must use fastbootd or you won't be able to wipe the phone. As such, to summarise, the rooting steps are:

    - Unlock bootloader
    - Download and extract boot.img (on PC)
    - Download Magisk and patch boot.img (on phone)
    - Reboot to bootloader (adb reboot fastboot) then to fastboot (fastboot reboot fastboot)
    - Flash patched boot.img, wipe phone, and reboot

    Once rooted you probably want to:
    - Install Displax's safetynet-fix to get Google Wallet, Netflix etc working
    - Remove unwated bloatware using something like De-Bloater
    1
    Edit: couple reboots later and magisk did something (some kind of update) and it says rooted.
    This is one of the devices that Magsik has to install some early hooks for, so indeed to finish root you'll need to open Magisk and it'll tell you that 'additional setup required' and to reboot your device. Then it'll be rooted.
    1
    Make sure the device is up-to-date before rooting.
    1
    Hiding root from Google Pay is still working as long as you use the modded USNF Magisk Module: https://forum.xda-developers.com/t/module-mod-universal-safetynet-fix.4553699/

    The problem arises if you have any apps that are able to detect Zygisk or an unlock bootloader, which the above relies on.