What's new

[FAQ & Guides][Merlin] Bootloader, Magisk, EdXposed, SafetyNet, GSI/Treble ROMs

ramleozingabo

Honorary Poster
Joined
Nov 20, 2016
Posts
468
Solutions
1
Reaction
572
Points
250
Age
29
DISCLAIMERS (please read !)
The content seen in this thread is targeted at this specific forum's device, the Redmi Note 9, codenamed Merlin.
Follow the instructions shown in this thread at your own risks, I will not be held responsible for bricking your device, you did this yourself.
That said, the information will be kept up to date relatively frequently, and should you follow the steps and ask questions below when unsure, everything will be fine!
No files will be directly provided. Do not use pre-created/re-uploaded content. Instead I'll teach you to gather the required files from official websites, and create the other ones yourself.

Prerequisites for most manipulations:
  • Your phone, well charged if possible
  • The USB cable used to link your phone to your computer (the one on your charger works just fine)
  • A computer, with recent You do not have permission to view the full content of this post. Log in or register now.
  • Some time, patience, and the ability to read and follow instructions!
Unlock your bootloader (otherwise this thread is useless to you as it's required for rooting as well as installing custom ROMs)
Tutorial:

Step 1- Make sure you have a Mi Account ready. Technically you should've created one when first setting up your phone, with your phone number and a password.
If you have it: Double-check you have access to it by attempting to connect on You do not have permission to view the full content of this post. Log in or register now..
If you don't: Create one with the Create an account button below the password form (same link as above), then connect to it.
Step 2 - On your PC, head to You do not have permission to view the full content of this post. Log in or register now. and click the colored Download Mi Unlock button:
https%3A%2F%2Fi.imgur.com%2Fj8fgLYw.jpg
Step 3 - A download should've started. Patiently wait for it to finish, move the archive to your desktop and extract its content.
Step 4 - Inside the extracted folder, double click the file called miflash_unlock.exe to start Xiaomi's Unlocking program.
Step 5 - Read Xiaomi's Disclaimer then click agree to their terms, or stop here and leave this thread if you don't.
Step 6 - Sign in to your Mi Account we talked about in Step 1.
Step 7 - Let's get your phone ready for unlocking.
  • Go to your phone's Settings > Mi Account > Make sure you're logged in
  • Now Settings > About Phone > Tap the "MIUI Version" box multiple times until it says You are now a developer!
  • And finally Settings > Additional Settings > Developer Options
- Enable the following settings inside Developer Options, and click Acceptwhen warnings pop-up:
  • OEM Unlocking
  • USB Debugging
- Then, still in Developer Options, check your Mi Unlock status and click the Add account and device button at the bottom if present.
Great! You're ready to go. Make sure to backup your phone's data before continuing on with this tutorial, as unlocking will make it factory reset (wipe)!

Step 8
- Alright, all backed up? Confident? Let's get going with the final steps.
  • Turn off your phone.
  • Turn it back on into fastboot mode by holding down the Power button AND Volume Down together until it vibrates, you may then let go of the Power Button, but keep Volume Down helduntil you see the fastboot image on your phone.
  • Connect your phone to your computer with the USB Cable.
  • Xiaomi's Software should detect it. If not, click on the cog-wheel in the top right, click the Check button to install the driver and follow instructions, then keep going.
  • Click Unlock, and follow the instructions!
Now there are two possible scenarios:
  • Either you've done all this before and can have your phone unlocked right away.
  • Or this is the first time and at the end of the progress it'll ask you to wait ~7days, and, well, there's no way around that, so come back in 7 days and start from Step 8 again.
And there you go! Your phone will reboot and you can set it all up again, with the ability to follow the rooting tutorial below, and you can also install custom ROMs/recovery!


Rooting with Magisk (Not recommended for custom ROMs)

Tutorial:

The procedure is the same whether you're on the stock MIUI Rom or on a custom GSI (treble) one.
Step 1 - Download the latest You do not have permission to view the full content of this post. Log in or register now.on your phone.
Go to the link above, click the latest MagiskManager-vX.X.X.apk you see in the list to start the download, open the file and install.
Step 2 - Download the latest You do not have permission to view the full content of this post. Log in or register now. depending on your region, make sure to get the fastboot version.

Step 3 - Get your ROM you downloaded above, it should be a .tgz archive. Extract it, you'll get a .tar achive, extract that one again.

Step 4- You should now get a folder like shown below, and..
https%3A%2F%2Fi.imgur.com%2Fd1H2K4g.jpg

Go inside images,
https%3A%2F%2Fi.imgur.com%2FKQ7GB7S.jpg

Copy the boot.img to your phone's /sdcard/ folder (where the Android, DCIM, Download, and more are present, just drop it in there).
And here's how it shoud look inside your phone's storage in the end.
https%3A%2F%2Fi.imgur.com%2FuiusbXG.jpg
Step 5- On your phone, open up Magisk Manager.
  • Click the Magisk Install button as shown below.
  • Then Select and ρá†ch a File.
  • Go look for your boot.img you previously copied to your phone and pick it.
  • Click Let's go! and wait for Magisk to complete the process!
https%3A%2F%2Fi.imgur.com%2FZ8o3ai9.jpg
Step 6 - Link your phone to your PC, and grab the file the Magisk Manager created. It's located in your downloads folder, called magisk_patched.img.

Step 7 - Paste it where your ADB & Fastboot (Platform Tools) are located, along with the vbmeta.img file located in Stock ROM's images folder from earlier, where you grabbed the original boot.img.
You should now have a folder like this with:
  • adb.exe
  • fastboot.exe
  • magisk_patched.img
  • vbmeta.img
  • Extra files from the platform tools
https%3A%2F%2Fi.imgur.com%2FepfTRVa.jpg
Step 8 - Alright, we're ready to root! Turn off your phone, and get in fastboot mode like we did during the bootloader unlocking (Power + Volume Down).
Step 9 - Link your phone to your PC with the USB cable if not done already.
Step 10 - Shift + Right click in an empty space inside the folder we prepared in Step 7, and click Open PowerShell window here.
Inside the PowerShell window, input the following commands line by line, in order.
Code:
.\fastboot.exe devices
And make sure your device shows up, should be a bunch of numbers and letters, a couple spaces, and fastboot.
If nothing does, go back to Step 8 and try again.
Code:
.\fastboot.exe --disable-verity --disable-verification flash vbmeta vbmeta.img
.\fastboot.exe flash boot .\magisk_patched.img
.\fastboot.exe reboot
https%3A%2F%2Fi.imgur.com%2FZ5zUaGR.jpg

Your PowerShell window will look a little different, I'm using a different program, don't worry[/INDENT]
You're done! Your phone will reboot, hopefully, without a hitch! Open up Magisk Manager, and check that it's installed.


Passing SafetyNet (Only possible with Magisk. Not with SuperSU on GSI's)
Tutorial:

For Magisk Rooted Phones
Enable Magisk Hide inside Magisk Manager's settings.
For EdXposed Phones
Again, I highly recommend not EdXposing your phone and sticking to just Magisk if you can help it.
You should also know that this method will show you're passing SafetyNet inside Magisk but it's a pain to do and isn't as well hidden as Magisk alone.
Step 1
- Do the step for Rooted phones listed above if not done already.
Step 2 - In EdXposed Manager, get the HiddenCore Module and activate it.
Step 3 - Now, in the side-menu: Compat List > tick HiddenCore Module.
Step 4 - Then, go to Settings > Framework > Enable "App List mode".
Step 5 - Finally, Applications(Black List) and tick: Android Services Library, Chrome, Google Play services, Google Play Store, Google Services Framework
Reboot and enjoy! You're all set and SafetyNet should pass just fine.

Installing GSI's (Custom ROMs)

Tutorial:

Step 1 - Pick your poison in the You do not have permission to view the full content of this post. Log in or register now.!
Check my forum signature if you want to see my recommendations with links to them.
Step 2 - Download the chosen ROM, A/B Arm64version (usually nicknamed b), with (g) or without GApps (v), rooted (S) or not (N), that's entirely up to you.
It should be an .img.xz file, extract it and you'll get an .img file.
You're ready to flash. Make sure to backup your phone's data before continuing on with this tutorial, as wiping it is required for installation!

Step 3
- Put your phone into fastboot mode (Power + Volume Down) and link it to your PC.
Step 4 - Move the .img file you downloaded to your ADB & Fastboot (Platform Tools) folder, and rename it to system.img.
Step 5 - Shift + Right click in an empty space inside the folder, and click Open PowerShell window here.
Inside the PowerShell window, input the following commands line by line, in order.
Code:
.\fastboot.exe reboot fastboot
.\fastboot.exe --disable-verification flash vbmeta .\vbmeta.img
.\fastboot.exe flash system .\system.img
.\fastboot.exe -w
.\fastboot.exe reboot
Your phone will now reboot on its own, using the new ROM you picked earlier, set it all up and enjoy!
That said, you will have issues leaving it at that. Treble (GSI) Roms have two issues with Merlin at the moment. But it's fixable!
Therefore, I highly recommend checking out the next Tutorial section, Fixing GSI Issues.


Fixing GSI Issues

I have worked with developer to bring fixes for our device to every custom GSI rom out there.
They'll take some time to get through, so in the meantime you may have to do the following depending on your chosen ROM.
GSI (treble) roms have two known bugs that we can fix:
  • The brightness slider being misscalibrated, and therefore auto-brightness broken too.
  • The headphone jack not working.

You need to be rooted to do so.

Tutorial
:

Step 1 - Get yourself a Terminal Emulator, I recommend You do not have permission to view the full content of this post. Log in or register now.
Step 2 - Type the following commands inside of it, line by line, in order:
Code:
su
setprop persist.sys.qcom-brightness $(cat /sys/class/leds/lcd-backlight/max_brightness)
setprop persist.sys.overlay.devinputjack true
And ehm, yeah, you're done! Brightness should be fine, headphones get detected, enjoy!

CREDITS TO THIS LINKYou do not have permission to view the full content of this post. Log in or register now.
 
Back
Top