Xiaomi POCO X3 NFC (xiaomi-surya)

From postmarketOS Wiki
Xiaomi POCO X3 NFC
Xiaomi POCO X3 NFC
Xiaomi POCO X3 NFC
Manufacturer Xiaomi
Name POCO X3 NFC
Codename xiaomi-surya
Model
  • POCO X3 NFC: M2007J20CG
  • POCO X3 (India): M2007J20CI
Released 2020
Type handset
Hardware
Chipset Qualcomm Snapdragon 732G (SM7150-AC)
CPU Octa-core (2x 2.3 GHz Kryo 470 Gold & 6x 1.8 GHz Kryo 470 Silver)
GPU Adreno 618
Display 1080 x 2400 (120Hz 6.67" IPS LCD)
Storage 64/128 GB
Memory 6 GB
Architecture aarch64
Software
Original software Android (MIUI)
Original version 10 (MIUI 12)
Extended version 12 (MIUI 14)
FOSS bootloader partial
postmarketOS
Category testing
Pre-built images no
Mainline yes
postmarketOS kernel Mainline 6.7.4
Features
Flashing
Works
USB Networking
Works
Internal storage
Works
SD card
Works
Battery
Partial
Screen
Works
Touchscreen
Works
Multimedia
3D Acceleration
Works
Audio
Partial
Camera
Broken
Camera Flash
Works
IR TX
Broken
Connectivity
WiFi
Works
Bluetooth
Works
GPS
Broken
NFC
Works
Modem
Calls
Works
SMS
Works
Mobile data
Works
Miscellaneous
FDE
Works
USB OTG
Works
Sensors
Accelerometer
Works
Magnetometer
Works
Ambient Light
Works
Proximity
Works
Haptics
Works
U-Boot
Secondary Bootloader
Works
Mainline
Broken
Internal Storage
Partial
SD card
Broken
USB Host
Broken
USB Peripheral
Partial
Display
Works
Buttons
Works
This device is based on the Snapdragon 732G.
See the SoC page for common tips, guides and troubleshooting steps

Maintainer(s)

Users owning this device

  • Cxt (Notes: Main phone)
  • JIaxyga (Notes: x2 Mainline maintainer)
  • MuseCat (Notes: Main)
  • Rainbyte (Notes: Daily driver ; OS: Android 12 (ArrowOS))
  • Soupborsh (Notes: Lindroid with LineageOS)
  • Ungeskriptet (Notes: Main device for pmOS)
  • Wizzdom (Notes: Daily driver, running LineageOS 18.1)
  • Zerkalo (Notes: not tested yet)


How to enter flash mode

  • Bootloader: Power on the device with both Power and Volume Down buttons.
  • Recovery: Power on the device with both Power and Volume Up buttons.
  • Fastbootd: Reboot into bootloader mode first and then run fastboot reboot fastboot from a computer.

Installation

  1. Make sure pmbootstrap is installed and your bootloader is unlocked
  2. Run through pmbootstrap init and select xiaomi as the vendor and surya as the device.
  3. 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
  4. 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
    1. 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.
    2. Boot into bootloader mode
    3. Erase the dtbo partition with fastboot erase dtbo
    To restore the partition flash it with fastboot flash dtbo dtbo.img
  5. 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
  6. 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

Note Note: The latest kernel is under active development and things might not work as expected.
  1. 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.
  2. Go through $ pmbootstrap init and select xiaomi-surya as the device. The UI can be choosen as desired.
  3. Clone the sm7150-mainline kernel fork: $ cd ~/Downloads && git clone https://github.com/sm7150-mainline/linux.git && cd linux.
  4. Prepare envkernel: $ source ~/.local/share/pmbootstrap/helpers/envkernel.sh
  5. Generate the kernel config: $ make defconfig sm7150.config
  6. Build the kernel: $ make -j$(nproc)
  7. 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
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
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
Magnetometer AKM ak09918c Y
Haptics/Vibrator Awinic aw8624 Y
Speakers Texas Instruments tas2562 (SPK) Y Works from here
Texas Instruments tas2564 (EAR) N
Camera regualtor OmniVision wl2866d N Called longcheer,wl2866d downstream
Camera Sony IMX682 N Main camera
Samsung S5K3T2 N Front camera
Hynix Hi-1337 N Ultrawide camera
Hynix Hi-259 N Macro camers
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).

See also: Serial debugging

Gallery

See also