Android has made great contributions to the popularity of smart phones, but the "fragmentation" problem caused by open source has always been a pain in Google's heart that cannot be concealed. In order to change this situation, Google has made many attempts. For example, the "A/B (seamless) system update" introduced in Android 7.0 and the "Project Treble" launched in Android 8.0 are all designed to pave the way for barrier free system update and reduce the risk of device failure caused by update failure, so that manufacturers can more easily push system updates.

And in Android 11 In version 5, Google used a new partition called "virtual A/B", and took the lead in using it on Google Pixel 5. Virtual A/B updates the system in a similar way to A/B, and its core functions are the same. When the system performs OTA update, if the update fails, it will automatically roll back to the previous system. The new data will not be written to the system until it is successfully powered on. And the system update can be completed in standby mode without restarting to wait for new data to be written, which can be said to greatly improve the user experience when updating the system. However, "A/B" needs to prepare two identical partitions, which will occupy more storage space. "Virtual A/B" deletes the "cache" and "recovery" partitions, and "system" partitions only reserve one to solve the above space occupation problem. one

Xiaomi 11 It also uses "virtual A/B", but this is not good news for me. Because the "recovery" partition is deleted by "virtual A/B", the third-party "recovery" cannot be flushed in without the "recovery" partition. Therefore, before TWRP officially solves the problem of flushing this new partition mode into third-party recovery, I can only use other methods to flush Xiaomi 11.

However, this is not a brush machine for me. I just install a Magisk. This article will also be updated when TWRP is available.

There is a risk of machine brushing, so you need to be careful when operating the machine. Please prepare the spare machine and be prepared for brick changing. After confirming that Xiaomi Home is available for after-sales maintenance, brush the machine.

The following is a complete brush record.

Unlock

The mobile phone in hand is still the factory system. Update the system to the latest version first. I use the stable version of MIUI 12.0.22.0, and the experience is not bad. Of course, it's OK not to update.

1. Enable developer mode

For the newly acquired mobile phone, first log in to your Xiaomi account, and then open the " Developer Mode 」。

MIUI 12 System Enable 「 Developer Mode The steps are: Set → My Device → All Parameters, click MIUI Version "Seven times, a prompt pops up" Developer mode is enabled 」。

Set " Developer Mode The entry of "" is at Settings>More Settings>Developer Options. Check " OEM unlock 」、「 USB debugging 」。 On the " Device unlocking status ", bind the account and the device.

2. Download the unlocking tool

Go to " Unlock Xiaomi mobile phone "Page to download the unlocking tool.

3. Update drive

In order to avoid various unpredictable dangers when unlocking or brushing the machine, first update the drive. Unzip the downloaded compressed package and click miflash_unlock.exe Open the unlocking tool.

Click Settings in the upper right corner.

Before connecting the phone to the computer, be sure to select the " Developer Mode ", open the" USB debugging ", similar to" Allow this PC to debug using USB ", and then click" Drive detection Update the driver.

4. Unlock

Then you can unlock it. Note that unlocking will erase all phone data, so don't rush to transfer data to a new phone. The unlocking tool will be prompted during the unlocking process, so it will be skipped.

However, it has been said that if a new phone is unlocked, it needs to be bound to a Xiaomi account for a period of time (about seven days), but my phone was unlocked as soon as I got it

After unlocking, it will automatically restart and the data will be cleared.

extract boot.img

At present, the purpose of machine brushing is only to Brush in Magisk , Magisk can repair the system boot.img It does not need to use TWRP or other third-party REC tools.

So you need to extract the original of the current system boot.img File.

Extract with wire brush package

stay Xiaomi Community See if there is a wire brush package of the current system version of the mobile phone. Download it and unzip it boot.img , can be used directly. Only the MIUI 12 stable version of the wire brush package is available at present.

Extract with card swiping package (mobile system update package)

If Xiaomi Community has not provided the current version of the card swiping package, you can also download the complete card swiping package in the mobile system update. First, enter the system update and click to download the complete update package. After the download starts, close the background completely. Enter the download management and continue to download manually. Otherwise, the update package will be automatically unpacked and updated to the system.

However, this kind of update package is encrypted and needs to be decrypted with tools.

Mobile terminal

The decryption method on the mobile phone side refers to the course Brush in the Magisk patch boot.img Still need a computer ), the steps are as follows:

  1. Download Termux( Play Store / Ku'an
  2. Download payload_dumper( GitHub )And decompress
  3. Decompress and download the system update package payload.bin Put payload_dumper Folder
  4. Open Termux and execute the command
 pkg install python -y pip install --upgrade pip apt update && apt upgrade -y termux-setup-storage

After this step, a prompt will pop up and you can agree.


Find the unzipped payload_dumper folder, long press the folder, click More → Details, and copy the folder position

For example, my payload_dumper folder is located in /storage/emulated/0/payload_dumper , then the next operation instruction in Termux should be

 cd /storage/emulated/0/payload_dumper pip install -r requirements.txt python payload_dumper.py payload.bin

Wait for the end of unpacking, then you can payload_dumper/output Found in folder boot.img

PC side

Refer to Ku'an Tutorial

  1. hold payload.bin Unzip it
  2. Download decryption tool: Portal , and unzip
  3. take payload.bin put to payload_input Folder
  4. function payload_dumper.exe
  5. Because only boot.img , so there is no need to wait for the whole journey boot.img Decompress it to close the program

Brush in Magisk

1. Install Magisk

Download Magisk Manager( GitHub / backups )Install and open. The relevant information may not be loaded normally due to network reasons.


You can open the settings in the upper right corner, click "Update Channel" to modify it to custom, and then search for "Magisk Custom Channel" on the Internet to find one that can be used and fill it in the custom channel. You can use my, which is currently a stable version twenty-three , but continuous updates are not guaranteed. (Don't bother to maintain the ready-made online search.)

After setting, it should be able to load normally.

2. Repair boot.img

Then click Install next to Magisk.


Select Select and patch a file.

Find what was just decrypted boot.img Select it and click Start.

Magisk patched boot.img Put on /Download Folder.

3. Brush in boot.img

To be repaired magisk_patched_xxxxx.img Copy to PC , ready to start painting Magisk, refer to Ku'an Tutorial You need to use adb tools to brush the machine( Portal ), pay attention to decompression.

Connect the phone to the computer when the phone is switched on. Double click the Open CMD command line.bat

The following commands need to be enabled on the phone USB debugging ", the meaning of the command is explained in the figure above, and will not be explained any more.

 adb devices

You need to list the adb devices successfully. If you fail, check the drivers, data cables, and computer interfaces one by one.

 adb reboot bootloader

After restarting to the fastboot mode, the phone displays a rice rabbit of the maintenance robot. Then you can apply the patched boot.img Has. Due to the repaired magisk_patched_xxxxx.img The name is different every time. It is recommended to drag it directly. You can refer to the moving picture I made earlier. Note the spaces in the command.

 fastboot flash boot_ab magisk_patched_xxxxx.img

After successful flushing, enter fastboot reboot Restart the device. If there is no accident, you can see the Magisk that has been successfully activated.

4. Subsequent system updates

The later update system does not need to be extracted as cumbersome as the first time boot.img The patch was applied and then applied to the system. You just need to select "Download the full update package" when updating the new version.

Then wait for the update package to be written to the system, and when prompted "Restart to complete the update", do not rush to update. At this time, open Magisk, select "Install to an unused slot (after OTA)", and click OK.


Wait for the completion of brushing.

Restart the system, and the update is complete.

Or, You don't need to download the full package Before downloading the incremental package, click "Uninstall Magisk" in the magisk and select "Restore the original factory image".

Then update incrementally. After the update is completed, do not restart. As above, install Magisk, select "Install to an unused slot (after OTA)", and then restart the system.

Brush in TWRP

The official TWRP has been officially launched, and the brushing method is almost the same as that of Magisk. However, since there is no usable package for Xiaomi 11, TWRP is not recommended here.

You can go by yourself if necessary TWRP official website Download.

The brushing method is to brush in the command line in adb.

 adb reboot bootloader fastboot boot twrp.img

It's really good to patch the magisk.

Some questions

1. SafetyNet cannot pass

After using Magisk, SafetyNet cannot pass the detection. If it fails, the Google Play guarantee mechanism will fail, and some games will fail to download.

The solution is to use the following two modules

  1. safetynet-fix
  2. XiaomiCTSPass

Brush in the magisk and restart it. You can cheat the system to pass this detection and make the proof pass. (The test system version is the development version MIUI 12.5 21.3.25)

In the Play store, clear the data.

Be careful to turn on the magic hide.

2. The mobile phone is stuck due to problems with the Magisk module

Deactivate all modules.

Connect the mobile phone to the computer, open the adb tool, enter adb shell , the prompt will appear after successful connection venus:/ ", and then enter" magisk --remove-modules The phone will automatically restart. If the card cannot restart, long press the power button to force the restart.

Then check one by one to see which module has the problem.

Be sure to turn on USB debugging, otherwise it can only be solved by brushing back the original image. For details, please refer to: Magisk Frequently Asked Questions

MIUI13(Android12)

The MIUI13 based on Android 12 can also directly use Magisk to patch the boot, but Magisk needs to use the Canary edition.

You can click here Download the GitHub real-time build version, or visit here Download my archived backup.

If it is still used v23 Version, installation completed Canary After version of the app, the app will prompt for updates Magisk , select "direct installation (recommended)" during installation, restart, and then update to MIUI13.


  1. The above concept of "virtual A/B" partition is based on the idea of "autumn leaves with the wind" Ku'an Dynamic In a simple summary, there may be some omissions or errors. Please forgive me.