[Xiaomi 12 Pro] NeoArian:
Introduction

This thread is supposed to be a place for development related discussion and help about LineageOS and OSS kernel development for all kind of Xiaomi devices with a 5.10 kernel.

We aim to support all of these devices in our common kernel and LineageOS devicetree,

Below, you can see the current state of each device. If you think we missed a device or you own one which is not supported yet and brought it up, feel free to mention it and we will add it here.

New devices (new as in a developer got them recently) are usually not supported in the lineage-* branches yet.

Usually we create a new branch for this device in the repositories where changes are necessary.

If you're building yourself or want to take a look at the source code for this device, look at the branches stated below instead of the default one.

Our github organisation can be found here.

Xiaomi 12 Pro (zeus)

Owners: @NeoArian

Supported in:

* lineage-20

* lineage-21

Support thread

Xiaomi 12 (cupid)

Owners: @NeoArian @Adrianyyy

Supported in:

* lineage-20

* lineage-21

Support thread

Xiaomi 12S Ultra (thor)

Owners: @Adrianyyy

Supported in:

* lineage-21

Support thread

Xiaomi 12S Pro (unicorn)

Owners: @NeoArian

Supported in:

* lineage-21

Support thead

Xiaomi 12S (mayfly)

Owners: @Flower Sea

Supported in:

* lineage-21

Support thread

Xiaomi 12T Pro (diting)

Owners: @Adrianyyy

Not supported yet

Xiaomi 13 Lite / Civi 2 (ziyi)

Owners: @Adrianyyy

Not supported yet

Xiaomi Mi Mix Fold 2 (zizhan)

Owners: @Adrianyyy

Not supported yet

POCO F4 GT (ingres)

Owners:

Not supported in the main branches yet

Support on https://github.com/xiaomi-sm8450-devs

POCOF5 / Redmi Note 12 Turbo (marble)

Owners: @Adrianyyy

Supported in:

* lineage-21

Support thread

POCO F5 Pro / Redmi K60 (mondrian)

Owners: @NeoArian

Supported in:

* lineage-21

Support thread

Building / Source Code

There are two relevant kernel build environments for our project, the first one is referred to as kernelplatform, which denotes the build environment used by Qualcomm and xiaomi.

The kernel is not compiled during the regular android compilation, but separately before and then included as a prebuilt into the ROM. All the kernel repositories for this can be found here: https://github.com/xiaomi-sm8450-kernel/

To build with the generated device/qcom/${codename}-kernel repository, the sm8450-common tree needs a patch, this commit must be reverted.

Additionally, this topic must be picked into LineageOS.

The benefits of this build environment is that it allows us to get very close to the stock kernel and we can load some stock kernel modules since the abi matches (by carefully finding the matching CLO tag).

However, for easier maintenance, we have moved on to building the kernel using the LineageOS kernel setup, which builds it during the android compilation. This is a necessary step to get our devices official in the future.

All the device repositories (and new-style kernel repositories used for lineage builds) can be found here: https://github.com/cupid-development/

If you are interested in building LineageOS for a supported device yourself, you can use the following two local_manifests, but note that you might need to adjust the branches or GitHub org if your device is not stated to be supported in the main branches above:

xiaomi_sm8450.xml

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<!-- Remotes -->
<remote fetch="https://git.mainlining.org" name="mainlining" revision="lineage-21" />

<!-- Device trees -->
<project name="cupid-development/android_device_xiaomi_cupid" path="device/xiaomi/cupid" remote="github" revision="lineage-21" />
<project name="cupid-development/android_device_xiaomi_marble" path="device/xiaomi/marble" remote="github" revision="lineage-21" />
<project name="cupid-development/android_device_xiaomi_mayfly" path="device/xiaomi/mayfly" remote="github" revision="lineage-21" />
<project name="cupid-development/android_device_xiaomi_mondrian" path="device/xiaomi/mondrian" remote="github" revision="lineage-21" />
<project name="cupid-development/android_device_xiaomi_thor" path="device/xiaomi/thor" remote="github" revision="lineage-21" />
<project name="cupid-development/android_device_xiaomi_unicorn" path="device/xiaomi/unicorn" remote="github" revision="lineage-21" />
<project name="cupid-development/android_device_xiaomi_zeus" path="device/xiaomi/zeus" remote="github" revision="lineage-21" />
<project name="cupid-development/android_device_xiaomi_sm8450-common" path="device/xiaomi/sm8450-common" remote="github" revision="lineage-21" />

<!-- Xiaomi common hardware -->
<project path="hardware/xiaomi" remote="github" name="LineageOS/android_hardware_xiaomi" revision="lineage-21" />

<!-- Kernel -->
<project name="cupid-development/android_kernel_xiaomi_sm8450" path="kernel/xiaomi/sm8450" remote="github" revision="lineage-21" />
<project name="cupid-development/android_kernel_xiaomi_sm8450-devicetrees" path="kernel/xiaomi/sm8450-devicetrees" remote="github" revision="lineage-21" />
<project name="cupid-development/android_kernel_xiaomi_sm8450-modules" path="kernel/xiaomi/sm8450-modules" remote="github" revision="lineage-21" />

<!-- Vendor -->
<project name="cupid-development/proprietary_vendor_xiaomi_cupid" path="vendor/xiaomi/cupid" remote="mainlining" revision="lineage-21" />
<project name="cupid-development/proprietary_vendor_xiaomi_marble" path="vendor/xiaomi/marble" remote="mainlining" revision="lineage-21" />
<project name="cupid-development/proprietary_vendor_xiaomi_mayfly" path="vendor/xiaomi/mayfly" remote="mainlining" revision="lineage-21" />
<project name="cupid-development/proprietary_vendor_xiaomi_mondrian" path="vendor/xiaomi/mondrian" remote="mainlining" revision="lineage-21" />
<project name="cupid-development/proprietary_vendor_xiaomi_thor" path="vendor/xiaomi/thor" remote="mainlining" revision="lineage-21" />
<project name="cupid-development/proprietary_vendor_xiaomi_unicorn" path="vendor/xiaomi/unicorn" remote="mainlining" revision="lineage-21" />
<project name="cupid-development/proprietary_vendor_xiaomi_zeus" path="vendor/xiaomi/zeus" remote="mainlining" revision="lineage-21" />
<project name="cupid-development/proprietary_vendor_xiaomi_sm8450-common" path="vendor/xiaomi/sm8450-common" remote="mainlining" revision="lineage-21" />
</manifest>

Additionally to these repositories there are a few patches from gerrit needed, you can run this bash scrip to apply them locally

repopicks.sh

#!/bin/bash
set -e

source "build/envsetup.sh";
source "vendor/lineage/build/envsetup.sh";

# hardware/xiaomi
changes=(
352657 # Add dummy sensors sub HAL
352658 # sensors: Make sensor batch function virtual
352659 # sensors: Make sensor run function virtual
352660 # sensors: Make sensor flush function virtual
352661 # sensors: Make sensor set mode operation function virtual
352662 # sensors: Move one shot sensor out of main class
352663 # sensors: Fix locking around setOperationMode and activate
352664 # sensors: Create sysfs polling one shot sensor
392967 # sensors: Let the reading of poll fd be configurable
392968 # sensors: Add SysfsPollingOneShotSensor constructor without enable path
392969 # sensors: Add udfps long press sensor using SysfsPollingOneShotSensor
352665 # sensors: Handle fod_pressed_state without coordinates
363160 # hidl: biometrics: fingerprint: Add enroll methods to udfps handler
392965 # vibrator: effect: Create double click effect from click if necessary
392966 # vibrator: effect: Fallback to click if an effect is missing
)
repopick -P hardware/xiaomi ${changes[@]}&

# frameworks/base
changes=(
386158 # Add 5G Ultra Wideband icon carrier config keys
386159 # Fix default values for 5G Ultra Wideband icon carrier config keys
)
repopick -P frameworks/base ${changes[@]}&

# vendor/lineage
changes=(
367044 # android: merge_dtbs: Respect miboard-id while merging
)
repopick -P vendor/lineage ${changes[@]}&

# vendor/qcom/opensource/vibrator
changes=(
392952 # vibrator: Use a better check for primitive effects
)
repopick -P vendor/qcom/opensource/vibrator ${changes[@]}&

wait

Now you're ready to start the build of LineageOS, for example for zeus:

brunch zeus

Installation

In order to flash the compiled build you can follow the instructions from my thread for the shared builds,

Make sure you are using firmware from MIUI 14 based on Android 13 before flashing LineageOS!

We hope this can help other interested developers to get AOSP for Xiaomi 12 series in a better shape!

Donate to support development:

Donate via PayPal to ArianK16a

Donate via PayPal to LineageOS