Xiaomi POCO X3 NFC (xiaomi-surya)

== Maintainer(s) ==
* JIaxyga
* Ungeskriptet
== 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 surya 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
#* To install pmOS to an SD card, run pmbootstrap install --sdcard /dev/sdX
#* 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 (Skip this step if you installed to an SD card)
#* 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
# 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
=== Building the latest kernel yourself ===
# Make sure you installed pmbootstrap from git, as the packaged versions do not include envkernel.sh, which needed for compiling the kernel. Follow this guide to install pmbootstrap from git.
# Go through $ pmbootstrap init and select xiaomi-surya as the device. The UI can be choosen as desired.
# Clone the sm7150-mainline kernel fork: $ cd ~/Downloads && git clone https://github.com/sm7150-mainline/linux.git && cd linux.
# Prepare envkernel: $ source ~/.local/share/pmbootstrap/helpers/envkernel.sh
# Generate the kernel config: $ make defconfig sm7150.config
# Build the kernel: $ make -j$(nproc)
# After the build has finished, package the built kernel for postmarketOS: $ pmbootstrap build linux-postmarketos-qcom-sm7150 --force --envkernel
Now you can follow the installation guide above.
== Mainline ==
A work in progress mainline kernel is being developed here.
=== Mainline status ===
Feature table for SM7150 </br>
Device feature table:
Component 	Model 	Status	Notes
Display 	Huaxing FHD DSC panel with NT36672C controller	Y 	Works from here
Touchscreen 	NovaTek NT36672C 	Y 	Connected via SPI, needs firmware
Charging 	qcom,qpnp-smb5 (downstream) 	N 	
Charging 	Texas Instruments BQ25968 	N 	
Fuel gauge 	qcom,pm6150-qg 	P 	
Accelerometer and gyroscope 	Bosh bmi220 	Y 	Managed by SSC
Ambient light and proximity sensor	Sensortek stk3a5x 	Y 	Managed by SSC
Magnetometer 	AKM ak09918c 	Y 	Managed by SSC
Haptics/Vibrator 	Awinic aw8624 	Y 	
Speakers 	Texas Instruments tas2562 (SPK) 	Y 	Works from here
Speakers 	Texas Instruments tas2564 (EAR) 	N 	
Camera regualtor 	OmniVision wl2866d 	N 	Called longcheer,wl2866d downstream
Camera 	Sony IMX682 	N 	Main camera
Camera 	Samsung S5K3T2 	N 	Front camera
Camera 	Hynix Hi-1337 	N 	Ultrawide camera
Camera 	Hynix Hi-259 	N 	Macro camers
Camera 	OmniVision ov02b1b 	N 	Depth camera
NFC 	NQX NCI NXP55303 (PN553 type) 	Y 	
== U-Boot ==
U-Boot has been successfully ported to SM7150 in this branch. This already includes dts for Xiaomi POCO X3 NFC.
The display and buttons work great. UFS and USB (in peripheral mode) also work, but we rely on the first stage bootloader setting the regulators. Therefore it is marked as Partial.
Caleb is doing an excellent job developing U-Boot for QCOM SoCs. This means that soon the features table will be completely “green” for us too.
Unless the signing keys leak or we crack them, ABL will always remain the first stage bootloader. Therefore we can only use U-Boot only as a second stage bootloader. However, we will do everything possible so that U-Boot relies as little as possible on the first stage bootloader and is ready to configure everything necessary on its own.
== Serial debugging (UART) ==
Xiaomi POCO X3 NFC uses 1.8 voltage for UART. So make sure that the logic one of your TTL adapter starts at a voltage below 1.8v.
The RX pin should be pulled-up to 1.8v to obtain the log. In Linux and U-Boot we pulled-up this pin software, but if you want to receive the log the rest of the time too, then you need to pull-up this pin hardware. It is enough to solder the TX pin of the adapter to the RX pin on the device, but make sure that your TTL adapter has a voltage of 1.8v (If this is not the case, then use a voltage divider schematic or buy an adapter with a voltage of 1.8v).
File:Xiaomi-surya-uart.png
See also: Serial debugging
== Gallery ==
File:Xiaomi-surya_plasma.jpg|Xiaomi POCO X3 NFC with Plasma Mobile
File:Xiaomi-surya-uboot.jpg|U-Boot on Xiaomi POCO X3 NFC
== See also ==
* Device Info HW database entry
* GSMArena page