Xiaomi Mi 9T / Redmi K20 (xiaomi-davinci)

== Maintainer(s) ==
* Adrian
* ArianK16a
== Users owning this device ==
== How to enter flash mode ==
* Bootloader: Power on the device with both and buttons.
* Recovery: Power on the device with both and buttons.
* Fastbootd: Reboot into bootloader mode first and then run fastboot reboot fastboot from a computer.
== Installation ==
# Make sure pmbootstrap is installed and your bootloader is unlocked
# Run through pmbootstrap init and select xiaomi as the vendor and davinci as the device.
# Generate the rootfs
#* For netbooting pmOS without flashing the phone, run pmbootstrap --extra-space 1000 install --no-sparse and pmbootstrap initfs hook_add netboot
#* If you want to flash pmOS to the phone, run pmbootstrap install
# Backup and erase the dtbo partition
#: To boot Linux, you'll have to erase the dtbo partition. It is recommended to back it up first if you want to boot Android again
## Run dd if=/dev/block/by-name/dtbo of=/sdcard/dtbo.img from a rooted shell on your phone and pull it with adb pull /sdcard/dtbo.img to your computer.
## Boot into bootloader mode
## Erase the dtbo partition with fastboot erase dtbo
#: To restore the partition flash it with fastboot flash dtbo dtbo.img
# Flash the rootfs
#* If you decided to go with netbooting, start the server with pmbootstrap netboot serve
#* If you want to install pmOS to the phones internal storage, run pmbootstrap flasher flash_rootfs --partition userdata (you can use --partition system if you want to keep the Android userdata and are fine with ~6GB of storage)
# Boot the kernel
#* To boot temporarily, without flashing run pmbootstrap flasher boot
#* To flash the kernel to the boot partition, run pmbootstrap flasher flash_kernel and reboot with fastboot reboot
After successfully following this guide, your phone should boot postmarketOS! If you have problems installing, feel free to ask in #sm7150-mainline:matrix.org
== Quirks ==
This should provide a rough overview explaining some unexpected things in the feature support table in the infobox.
=== NFC ===
This device shares the reset GPIO between NFC and the amplifier (for speaker audio). There is no such mechanism in the mainline kernel yet, so only one of them can work at a time. Due to that, NFC is currently disabled, but works fine and can be enabled in the kernel if preferred over speaker audio.
=== Battery ===
It charges, but very slowly since the hardware charger is not supported yet and especially the fuel gauge implementation is very basic and inaccurate.
=== Audio ===
Speaker audio works, microphone and earpiece are not working due to missing WCD implementation in the kernel.
=== Camera ===
The tele and ultrawide sensors are supported by our kernel fork and probing fine, but the camss is not implemented yet, making it impossible to take pictures.
=== GPS ===
Not tested yet, should work with the Qualcomm PDS patch for GPSD.
=== FOSS Bootloader ===
Unless the signing keys leak or we crack them, ABL will always remain the first stage bootloader. I wrote a basic EDK2-MSM port a while ago, but the "reboot to Android" flag never persisted in memory, making it rather unusable. We are working on U-Boot for SM7150 instead.
== Mainline ==
The SM7150 mainline kernel used by this device is being developed here. Please note that this wiki page is being updated to reflect progress and document feature support as we work on it, which means that sometimes, features marked as supported here will only work on the latest kernel fork, which might not be packaged in upstream pmaports quite yet.
== Nightlies ==
The sm7150-mainline team provides weekly prebuilt nightly postmarketOS builds with bleeding edge kernel versions which can be found here. We hope to encourage testing and trying out postmarketOS by providing a beginner-friendly way to install while the devices reside in the testing category.