
Code:
#include <std_disclaimer.h>
/*
* Your warranty is now void.
*
* I am not responsible for bricked devices, dead SD cards,
* thermonuclear war, or you getting fired because the alarm app failed. Please
* do some research if you have any concerns about features included in this ROM
* before flashing it! YOU are choosing to make these modifications, and if
* you point the finger at me for messing up your device, I will laugh at you.
*/
Introduction
To find out more about LineageOS visit the official Website.LineageOS, an open-source Android distribution, is available for several devices,
with more being continuously added thanks to the biggest, yet ever growing, Android open-source community.
Join us and breathe new life in your device, be it old or new.
All the source code for LineageOS is available in the LineageOS Github organization. And if you would like to contribute to LineageOS, please visit out Gerrit Code Review.
Installation
Warning: These instructions only work if you follow every section and step precisely.
Do not continue after something fails!
Basic requirements
- Read through the instructions at least once before actually following them, so as to avoid any problems due to any missed steps!
- Make sure your computer has adb and fastboot. Setup instructions can be found here.
- Enable USB debugging on your device.
- LineageOS is provided as-is with no warranty. While we attempt to verify everything works you are installing this at your own risk!
If the vendor provided multiple updates for that version, e.g. security updates, make sure you are on the latest!
If your current installation is newer or older than Android 13, please upgrade or downgrade to the required version before proceeding (guides can be found on the internet!).
Unlocking the bootloader
Note: The steps below only need to be run once per device. They require a machine running Windows 7 or newer.Warning: Unlocking the bootloader will erase all data on your device! Before proceeding, ensure the data you would like to retain is backed up to your PC and/or your Google account, or equivalent. Please note that OEM backup solutions like Samsung and Motorola backup may not be accessible from LineageOS once installed.
Tip: It is highly recommended to have the latest official MIUI stable package installed on the device, before proceeding with unlock.
- Create a Mi account on Xiaomi’s website. Beware that one account is only allowed to unlock one unique device every 30 days.
- Add a phone number to your Mi account.
- Insert a SIM into your phone.
- Enable developer options in Settings > About Phone by repeatedly tapping MIUI Version.
- Link the device to your Mi account in Settings > Additional settings > Developer options > Mi Unlock status.
- Download the Mi Unlock app (Windows is required to run the app).
- Run the Mi Unlock app and follow the instructions provided by the app. It may tell you that you have to wait up to 30 days. If it does so, please wait the quoted amount of time before continuing to the next step!
- After device and Mi account are successfully verified, the bootloader should be unlocked.
- Since the device resets completely, you will need to re-enable USB debugging to continue.
Flashing additional partitions
Warning: This platform requires additional partitions to be flashed for recovery to work properly, the process to do so is described below.- Download the following files from here.
- boot.img
- dtbo.img
- vendor_boot.img
- Power off the device, and boot it into bootloader mode:
- With the device powered off, hold Volume Down + Power. Keep holding both buttons until the word “FASTBOOT” appears on the screen, then release.
- Flash the downloaded image files to your device by typing (replace
<...>
with the actual filenames!):
fastboot flash boot <boot>.img fastboot flash dtbo <dtbo>.img fastboot flash vendor_boot <vendor_boot>.img
Booting a custom recovery using fastboot
- Download Lineage Recovery. Simply download the latest recovery file, named recovery.img.
Important: Other recoveries may not work for installation or updates. We strongly recommend to use the one linked above! - Connect your device to your PC via USB if it isn’t already.
- If your device isn’t already in fastboot mode, on the computer, open a command prompt (on Windows) or terminal (on Linux or macOS) window, and type:
adb reboot bootloader
You can also boot into fastboot mode via a key combination:- With the device powered off, hold Volume Down + Power. Keep holding both buttons until the word “FASTBOOT” appears on the screen, then release.
- Once the device is in fastboot mode, verify your PC finds it by typing:
fastboot devices
If you don’t get any output or an error:- on Windows: make sure the device appears in the device manager without a triangle. Try other drivers until the command above works!
- on Linux or macOS: If you see no permissions fastboot try running fastboot as root. When the output is empty, check your USB cable (preferably use a USB Type-A 2.0 one or a USB hub) and port!
- Tip: Some devices have buggy USB support while in bootloader mode, if you see fastboot hanging with no output when using commands such as fastboot getvar ..., fastboot boot ..., fastboot flash ... you may want to try a different USB port (preferably a USB Type-A 2.0 one) or a USB hub.
- Flash a recovery on your device by typing (replace
<recovery_filename>
with the actual filename!):
fastboot flash recovery <recovery_filename>.img
Note: Outdated fastboot releases dropped legacy A/B support, so it might attempt to flash to recovery__a /recovery__b rather than recovery_a / recovery_b if you try to flash recovery. In this case, you must update fastboot to a release newer than or equal to 31.0.2. Alternatively, you can manually specify which slot to flash to based on what slot fastboot failed to flash to. For example, if fastboot fails to flash to recovery__a, you must flash to recovery_a. - Now reboot into recovery to verify the installation.
- With the device powered off, hold Volume Up + Power. Keep holding both buttons until the “MI” logo appears on the screen, then release.
- Note: If your recovery does not show the LineageOS logo, you accidentally booted into the wrong recovery. Please start at the top of this section!
Installing LineageOS from recovery
- Download the LineageOS installation package that you would like to install or build the package yourself.
- (Optionally): If you want to install an application package add-on such as Google Apps (use the arm64 architecture), please read and follow the instructions on Google Apps page
- If you are not in recovery, reboot into recovery:
- With the device powered off, hold Volume Up + Power. Keep holding both buttons until the “MI” logo appears on the screen, then release.
- Now tap Factory Reset, then Format data / factory reset and continue with the formatting process. This will remove encryption and delete all files stored in the internal storage.
- Return to the main menu.
- Sideload the LineageOS .zip package but do not reboot before you read/followed the rest of the instructions!
- On the device, select “Apply Update”, then “Apply from ADB” to begin sideload.
- On the host machine, sideload the package using: adb sideload filename.zip.
Tip: Normally, adb will report Total xfer: 1.00x, but in some cases, even if the process succeeds the output will stop at 47% and report adb: failed to read command: Success. In some cases it will report adb: failed to read command: No error or adb: failed to read command: Undefined error: 0 which is also fine.
All set!
Once you have installed everything successfully, you can now reboot your device into the OS for the first time!- Click the back arrow in the top left of the screen, then “Reboot system now”.
Download link:
Builds are released here: Releases on GitHub
Warning: These releases include builds for other devices i own, make sure to download files from a release for Xiaomi 12, for example: "LineageOS 20.0 for Xiaomi 2201123G (cupid)"
Note: There are two variants which are not necessarily released at the same time. Vanilla builds are pure LineageOS without additional apps and GMS builds include Google services. The GMS builds are too big for github releases, so they will be uploaded to this shared folder on Google Drive instead
Source Code
Please read this thread about the OSS kernel on Xiaomi 12.
All kernel related source code can be found here.
Device trees for LineageOS can be found here.
Donate to support development:
Donate via PayPal to ArianK16a
Donate via PayPal to LineageOS
Last edited: