[Moto G Stylus 5G] Tokth:
***This is meant to be a guide only. I am not responsible for any adverse effects rooting or attempting to root your device. It is possible to brick your phone doing this so use at your own risk! ***

That being said, the following are the steps I took in order to root my own Motorola G Stylus 5G 2022 (XT2215-4) running android 12. NOTE: This tutorial assumes that your phone's bootloader has already been unlocked

**Please be aware if you have taken an OTA update firmware build will not match those shown in this guide.**

Confirm your model and Android version:

​

On your phone go to Settings -> About Phone and tap "Model" to bring up more information about your phone's model.

View attachment 5635225 View attachment 5635215​

Confirm your phone is running android 12 and see the firmware build number curently on the phone

Again go to Settings -> About Phone. Scroll down to and tap "Android version" to bring up additional details

View attachment 5635231 View attachment 5636049​

​

NOTE: If your phone or android version do not match those shown in the images above these steps may still work, however I have not tested them, have no way of testing them, and take no responsibility for any adverse effects from performing these steps on your device.

​

Confirm your bootloader has been unlocked:

​

In Developer Options confirm that "OEM Unlocking" says "Bootloader is already unlocked" and that USB Debugging has been enabled.

On your phone go to Settings -> System -> Developer Options

View attachment 5635205 View attachment 5635207​

If you do not see "Developer Options" in the list it does not necessarily mean that your boot loader has been unlocked (as you may not have re-enabled developer options after unlocking) but it is a red flag!

To enable developer options go to Settings -> About Phone and click "Build Number" 6 or 7 times until it says "you are now a developer".

Getting the stock firmware:

​

At the time of writing this guide there were no legitimate and or trustable sources to download the stock firmware for the XT2215-4 other than Motorola. If you google something such as "XT2215-4 stock firmware" you will get several different results however they are almost all clones of the same (presumably) scam website. Do yourself a favor and just.. dont! Get it directly from Motorola by doing the following steps.

Download and install the Motorola Rescue and Smart Assistant Tool https://www.motorola.com/us/rescue-and-smart-assistant/p

When you connect your phone to your computer it should detect your phone model and prompt you about downloading the correct firmware your phone. If not you may have to select the "Backup & restore" option in the right hand menu.

I had some trouble with getting my phone to connect to be recognized by the Rescue and Smart Assistant Tool and was forced to use the "Connect via WiFi" option. This option requires that both your computer and the phone be on the same network. It will prompt you to download and install the app's apk on your phone and then use the QR code on your computer to start the sync process.​

Once the rescue tool recognizes your phones model it should prompt you with the firmware for your phone, and begin downloading it to your computer.​

The default path it will download the firmware to is C:\ProgramData\RSA\Download\RomFiles​

Once downloaded you should see a directory here called "MILANF_G_S1SD32.56_22_subsidy_DEFAULT_regulatory_DEFAULT_cid50_R3_CFC.xml"​

If you do not have a directory but a *.zip instead, simply extract the zip to the current director and you will then see it as mentioned above.​

**IMPORTANT** Make sure that the build number of the firmware you downloaded matches that on your phone. ​

The initial build for this phone is S1SD32.56-22 and we can see that the (colored portion of filename) firmware we downloaded is the same as the build currently on our phone (from "Confirming your android version" step 2 from earlier).

NOTE: If you have an taken OTA update or flashed a newer firmware version than you the must make sure that the firmware you are patching is the same as one currently on your phone.

Open the directory and you will see the stock firmware and all of its content for the Motorola G Stylus 5G 2022 (XT2215-4) as shown below:​

View attachment 5635743
​

Patching the stock firmware with Magisk (Obtaining root)

​

So here is were things might not be so obvious. The XT2215-4 model is an A/B device along with utilizing ramdisk. What this really means for us is that our firmware does not have separate boot.img and recovery.img files. Instead the boot.img in our firmware is actually a combination boot and recovery rolled into one.

Additionally many, if not most, guides on rooting will have you using TWRP or some other recovery tool. Unfortunately at this time (to my knowledge) TWRP does not support android 12, and since the stock firmware runs android 12 that isnt really an option. One other issue is that the XT2215-4 is currently not supported by TWRP and thus has no TWRP recovery images available. I am currently working on this but as of right now have not complete them.

Instead we will be using ADB and Fastboot utilities from the android SDK to flash the patched boot image to our phone. If you do not have the android SDK installed along with adb/fastboot, you should go do so now.

*** IMPORTANT *** If the build of the firmware you downloaded and patched does not match that of that of your phone, STOP! Do not proceed. Instead you must use the rescue option to install the new firmware to your phone as mentioned by sd_shadow. I do not include directions on how to do this in this guide, but you should be able to easily use Motorola's "Rescue and Smart Assistant Tool" to accomplish this.

Copy the boot.img from the firmware you downloaded to your phone.

This can be done easily by simply connecting your phone to your PC and then browsing the Downloads directory and copy pasting the file over.

Install Magisk on your phone

You need to either download the apk directly to your phone, or side load it from the PC and then install it

You can find the latest version (v25.0) here https://github.com/topjohnwu/Magisk/releases/tag/v25.0

With Magisk installed and the boot.img file on copied to your phone we can now use Magisk to path the stock firmware and acquire root on our device. Press the Install button in the Magisk card (Not the "App" section)

Magisk will auto detect that the XT2215-4 is a ramdisk device and therefore selects the appropriate installation type.

NOTE: Once patched and flashed, if you open Magisk again you will have more installation options because you will have root access

Choose “Select and Patch a File” in method, and select the stock boot.img that you uploaded to your phone

Start the installation by clicking "Let's Go".

View attachment 5635759​

As you can see, Magisk will patch both the boot.img and the ramdisk on your device and then save the patched image to your phone.​

Copy the patched image to your PC using ADB

adb pull /sdcard/Download/magisk_patched_[random_strings].img

I didnt use ADB for this. I did it the lazy way and just browsed copied it manually by browsing to it on my PC and not using ADB to do it. But either should work.

NOTE: you may have to move the patched boot.img to another location on your phone so that it is accessible via ADB or regular File Explorer browsing.

Put your device into flashboot mode

Flash the patched boot/recovery image to your device.

For most devices, reboot into fastboot mode and flash with command:

fastboot flash boot C:/path/to/magisk_patched.img

Our device has a separate vbmeta partition, so we need to patch the vbmeta partition with command:

fastboot flash vbmeta --disable-verity --disable-verification vbmeta.img

Reboot and voila!

View attachment 5635765 View attachment 5635769

​

Now you should have root access on your Motorola G Stylus 5G 2022 (XT2215-4) phone! Remember that this will be overwritten by any OTA or firmware flashes that do not have not been patched with Magisk.

Again I am not responsible if you brick your phone using this guide. I created once I was able to get my device successfully rooted without and issues along the way, but that does not mean it is with out risks.

I will be working on TWRP recovery images for this model and eventually a Lineage 19 (hopefully) port.

Take Care!

Tokth