Xiaomi Mi A1 (xiaomi-tissot)

Xiaomi Mi A1 (xiaomi-tissot) is Xiaomi Mi 5X (xiaomi-tiffany), but with Android One on board and A/B structure. On the Mi A1, unlike the Mi 5X, you do not need to link your Mi Account and wait 15 days (360 hours) to unlock the bootloader.
== Maintainer(s) ==
* JIaxyga
* Bczeman
== Users owning this device ==
== Installation ==
* Follow the Installation guide
$ pmbootstrap init # choose Vendor: qcom Device codename: msm8953
$ pmbootstrap install
$ pmbootstrap flasher flash_lk2nd
$ pmbootstrap flasher flash_rootfs
=== Pre-built images ===
$ fastboot flash boot qcom-msm8953-lk2nd.img
$ fastboot flash userdata qcom-msm8953.img # You can use system also but userdata is recomended 
Or
$ fastboot flash boot_a qcom-msm8953-lk2nd.img # You can use boot_b if you want
$ fastboot flash system_a qcom-msm8953.img # system_b
$ fastboot set_active a # b
=== How to enter flash mode ===
* Stock Fastboot: Power on the device with both and buttons
* lk2nd Fastboot: Power on the device. After it vibrates, hold 
* Recovery: Power on the device with both and buttons
=== OEM unlock ===
First make sure to enable USB debugging and OEM unlock in Android.
Then with device powered off, hold down and buttons simultaneously for a few seconds, until Fastboot Mode screen appears. Plug in USB cable and do:
$ fastboot oem unlock
=== Wipes ===
Wipes work very strangely. Fastboot says that the wipes were successfully completed, but the partitions are not cleared. Therefore, the only way out is to make wipes from twrp or use formatting.
$ fastboot format:ext4 boot_a
$ fastboot format:ext4 boot_b
$ fastboot format:ext4 system_a
$ fastboot format:ext4 system_b
$ fastboot format:ext4 userdata
=== Dual booting ===
We can use the a/b markup feature for dual booting. In this case, we will have the kernel in the boot_a (or boot_b) section and the rootfs will be located in the same system_a (or system_b) slot. The opposite slot will use Android.
To find out the active slot, run in fastboot:
$ fastboot getvar current-slot
To switch a slot, run:
$ fastboot set_active a / b
E.g., if your Android ROM uses slot a, flash lk2nd to slot b:
$ pmbootstrap flasher flash_lk2nd --partition boot_b
The system partition severely limits the available space. So, you can install the rootfs to an SD card.
== What works ==
Main:
* USB Networking
* Flashing
* Touchscreen - focaltech,ft5435 (edt-ft5x06)
* Display - EBBG ili7807(ilitek) / tianma otm1911(focal) / EBBG ft8716(focal)
* WiFi - WCN3680B (WCN36XX)
* Xwayland
* FDE
* Bluetooth - WCN3680B (WCN36XX)
* Hall Effect Sensor - BU52061NVX (gpio-keys)
* Accelerometer - bosch,bmi120 (bosch,bmi160) 
* Magnetometer - AKM, AK09918 (asahi-kasei,ak8975)
* Battery
* Charger
* Audio - 
* SMS
* Calls
* Mobile Data (there are some variants where it is not working)
* USB OTG
* GPS
Other:
* Notification LED - awinic,aw2013
== What does not work ==
Main:
* Proximity Sensor - LiteOn, LTR579 (liteon,ltr501?)
* Ambient Light Sensor - LiteOn, LTR579 (liteon,ltr501?)
* Camera - Front Cam: samsung_s5k5e8 Back Cam: ov_12a10 Back Sub Cam: ov_13880
* Ir TX
Other:
* Flashlight - qcom,spmi-flash Works from here
* Keypad backlights
* Haptics
* Fingerprint - fpc,fpc1020 / goodix,gf3208
== Downstream ==
There is an alternative device port using the downstream kernel, xiaomi-tissot-downstream. It can be selected by entering the name in pmbootstrap init.
== Serial debugging (UART) ==
File:Xiaomi-tissot-uart.png
See also: Serial debugging
== See also ==
* Kernel source
* 
* 
* 
* lk2nd (build script)
* lk2nd (source code)
* twrp-3.3.0-1-tissot.img
* Schematic Mi A1
* MSM8953 mainlining status
Category:Devices with known UART pinout
__forcetoc__