Difference between revisions of "Xiaomi Mi 6 (xiaomi-sagit)"

From postmarketOS
Jump to: navigation, search
m (Building)
 
(12 intermediate revisions by 2 users not shown)
Line 17: Line 17:
 
| status_usbnet = Y
 
| status_usbnet = Y
 
| status_flashing = Y
 
| status_flashing = Y
| status_touch = P
+
| status_touch = Y
 
| status_screen = Y
 
| status_screen = Y
 
| status_wifi =
 
| status_wifi =
| status_xwayland =
+
| status_xwayland = Y
 
| status_fde =
 
| status_fde =
| status_mainline =
+
| status_mainline = P
 
| status_battery =
 
| status_battery =
 
| status_3d =
 
| status_3d =
Line 49: Line 49:
 
* MayeulC
 
* MayeulC
 
* Illen
 
* Illen
 +
* Degdag (mainlining)
  
 
== Maintainer(s) ==
 
== Maintainer(s) ==
Line 65: Line 66:
  
 
== Input ==
 
== Input ==
Touchscreen works sporadically, usually it starts working after the device is left unused for some time. All the buttons except for home button (which is is integrated with fingerprint scanner) are working.
+
Touchscreen works well on gnome. All the buttons except for home button (which is is integrated with fingerprint scanner) are working.
  
 
== Display ==
 
== Display ==
Seems to work well, except for the postmarketOS splash which is displayed incorrectly. Currently only xfce4 has been tested.
+
Seems to work well. Currently only xfce4 and mate and gnome have been tested.
  
 
== USB OTG ==
 
== USB OTG ==
 
Tested USB Hub with ethernet adapter, USB Audio device, and HID peripherals. Everything works well.
 
Tested USB Hub with ethernet adapter, USB Audio device, and HID peripherals. Everything works well.
 +
== Mainline kernel ==
 +
 +
Here's a list of stuff that is currently (Linux 5.6) known to be working (in at least some capacity):
 +
 +
* The kernel itself stays booted (i.e. no random panics) and is "stable"
 +
* UFS internal storage (<code>CONFIG_PHY_QCOM_UFS=y</code>)
 +
* Display (via [https://github.com/JamiKettunen/linux-mainline-oneplus5/commit/704fce760059660aac6f1b236238d461806da34f <code>simplefb</code>] & <code>CONFIG_FB_SIMPLE=y</code>)
 +
* Xorg & Wayland (tested with [https://i.imgur.com/VgsaOtY.jpg MATE] & [https://i.imgur.com/dLItMIm.jpg Weston] respectively)
 +
* Bluetooth (requires <code>crbtfw21.tlv</code> and <code>crnv21.bin</code> blobs from [https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/qca linux-firmware] + a <code>hciconfig hci0 up</code> in userspace)
 +
* Power button ([https://github.com/JamiKettunen/linux-mainline-oneplus5/blob/device-oneplus-cheeseburger/arch/arm64/boot/dts/qcom/pm8998.dtsi#L41 in DTS])
 +
* USB working ([https://github.com/degdag/mi6-mainline/commit/a11665d313213ad5ab464e74f488465ee053fe38]) (not ; USB_OTG not working yet)
 +
 +
 +
Check the links below for source code.
 +
 +
=== Building ===
 +
It's easiest to build mainline (for pmOS anyway) with [https://wiki.postmarketos.org/wiki/Mainlining_Guide#pmbootstrap_setup pmbootstrap], so get that setup and remember the install location (in this guide <code>~/pmOS/pmbootstrap</code> is an example).
 +
 +
After you've run through the [https://wiki.postmarketos.org/wiki/OnePlus_5_(oneplus-cheeseburger)#Installation installation steps found on this site at least once] please <code>pmbootstrap extract</code> & save the produced downstream <code>boot.img</code> to a known location as we'll reuse the initramfs found inside later.
 +
 +
Next start following the instructions below:
 +
 +
  git clone https://github.com/degdag/Xiaomi-Mi6-Mainline-Linux.git
 +
  cd Xiaomi-Mi6-Mainline-Linux/
 +
  source ~/pmOS/pmbootstrap/helpers/envkernel.sh    # adjust to match where you've cloned PMB yourself
 +
  make defconfig
 +
  make -j`nproc`
 +
 +
=== Boot image generation ===
 +
Now that the kernel image and DTBs have been built we can assemble a bootable Android-friendly boot.img (assuming you're still in the root of the cloned kernel dir):
 +
 +
  pmbootstrap chroot -- apk add abootimg android-tools mkbootimg dtbtool
 +
  export DEVICE=`pmbootstrap config device | cut -d'-' -f2` WORK=`pmbootstrap config work` PMOS_BOOT_IMG_PATH="~/pmOS/downstream-boot.img"
 +
  export TEMP="$WORK/chroot_native/tmp/mainline/" DTB="$PWD/.output/arch/arm64/boot/dts/qcom/msm8998-$DEVICE.dtb"
 +
  rm -r "$TEMP"; mkdir -p "$TEMP"
 +
  cat .output/arch/arm64/boot/Image.gz "$DTB" > "$TEMP/Image.gz-dtb"
 +
  cp "$PMOS_BOOT_IMG_PATH" "$TEMP/boot.img"          # replace "$PMOS_BOOT_IMG_PATH" with the known location of a pmOS downstream boot.img
 +
  pmbootstrap chroot -- abootimg -u /tmp/mainline/boot.img -k /tmp/mainline/Image.gz-dtb -c "bootsize=67108864"
 +
 +
At this point you get to choose whether to <code>boot</code> the new kernel image or more "permanently" <code>flash</code> it on the device's boot partition instead ^^
 +
 +
Boot: <code>pmbootstrap chroot -- fastboot boot /tmp/mainline/boot.img</code>
 +
 +
Flash: <code>pmbootstrap chroot -- fastboot flash boot /tmp/mainline/boot.img</code>
 +
 
== See also ==
 
== See also ==
 
<!--
 
<!--
Line 81: Line 127:
 
* [https://gitlab.com/Hacker1245/pmaports/tree/device/xiaomi-sagit Old Mi 6 port]
 
* [https://gitlab.com/Hacker1245/pmaports/tree/device/xiaomi-sagit Old Mi 6 port]
 
* [https://github.com/LineageOS/android_kernel_xiaomi_msm8998 Kernel sources]
 
* [https://github.com/LineageOS/android_kernel_xiaomi_msm8998 Kernel sources]
 +
* [https://github.com/degdag/mi6-mainline mainline sagit sources]
  
 
<!--
 
<!--

Latest revision as of 16:40, 13 May 2020

Xiaomi Mi 6
Xiaomi Mi 6
Xiaomi Mi 6
Manufacturer Xiaomi
Name Mi 6
Codename xiaomi-sagit
Released 2017
Category testing
Original software Android 7.1.1
Hardware
Chipset Qualcomm MSM8998 Snapdragon 835
CPU Octa-core (4x 2.45GHz Kryo 280 + 4x 1.9GHz Kryo 280)
GPU Adreno 540
Display 1920x1080 IPS LCD
Storage 64/128 GB
Memory 6 GB
Architecture aarch64
Features
USB Networking
Works
Flashing
Works
Touchscreen
Works
Display
Works
WiFi
Xwayland
Works
FDE
Mainline
Partial
Battery
3D Acceleration
Accelerometer
Audio
Bluetooth
Camera
GPS
Mobile data
SMS
Calls
USB OTG
Works



Contributors

  • Hacker420
  • MayeulC
  • Illen
  • Degdag (mainlining)

Maintainer(s)

How to enter flash mode

  • Power + Volume Down buttons or use TWRP reboot bootloader, or adb reboot bootloader

Installation

Use pmbootstrap flasher.

Virtual terminal

Virtual terminal is broken in downstream, causing early reboot without logs in pstore. This patch is needed to make virtual terminal working properly.

Input

Touchscreen works well on gnome. All the buttons except for home button (which is is integrated with fingerprint scanner) are working.

Display

Seems to work well. Currently only xfce4 and mate and gnome have been tested.

USB OTG

Tested USB Hub with ethernet adapter, USB Audio device, and HID peripherals. Everything works well.

Mainline kernel

Here's a list of stuff that is currently (Linux 5.6) known to be working (in at least some capacity):

  • The kernel itself stays booted (i.e. no random panics) and is "stable"
  • UFS internal storage (CONFIG_PHY_QCOM_UFS=y)
  • Display (via simplefb & CONFIG_FB_SIMPLE=y)
  • Xorg & Wayland (tested with MATE & Weston respectively)
  • Bluetooth (requires crbtfw21.tlv and crnv21.bin blobs from linux-firmware + a hciconfig hci0 up in userspace)
  • Power button (in DTS)
  • USB working ([1]) (not ; USB_OTG not working yet)


Check the links below for source code.

Building

It's easiest to build mainline (for pmOS anyway) with pmbootstrap, so get that setup and remember the install location (in this guide ~/pmOS/pmbootstrap is an example).

After you've run through the installation steps found on this site at least once please pmbootstrap extract & save the produced downstream boot.img to a known location as we'll reuse the initramfs found inside later.

Next start following the instructions below:

 git clone https://github.com/degdag/Xiaomi-Mi6-Mainline-Linux.git
 cd Xiaomi-Mi6-Mainline-Linux/
 source ~/pmOS/pmbootstrap/helpers/envkernel.sh     # adjust to match where you've cloned PMB yourself
 make defconfig
 make -j`nproc`

Boot image generation

Now that the kernel image and DTBs have been built we can assemble a bootable Android-friendly boot.img (assuming you're still in the root of the cloned kernel dir):

 pmbootstrap chroot -- apk add abootimg android-tools mkbootimg dtbtool
 export DEVICE=`pmbootstrap config device | cut -d'-' -f2` WORK=`pmbootstrap config work` PMOS_BOOT_IMG_PATH="~/pmOS/downstream-boot.img"
 export TEMP="$WORK/chroot_native/tmp/mainline/" DTB="$PWD/.output/arch/arm64/boot/dts/qcom/msm8998-$DEVICE.dtb"
 rm -r "$TEMP"; mkdir -p "$TEMP"
 cat .output/arch/arm64/boot/Image.gz "$DTB" > "$TEMP/Image.gz-dtb"
 cp "$PMOS_BOOT_IMG_PATH" "$TEMP/boot.img"          # replace "$PMOS_BOOT_IMG_PATH" with the known location of a pmOS downstream boot.img
 pmbootstrap chroot -- abootimg -u /tmp/mainline/boot.img -k /tmp/mainline/Image.gz-dtb -c "bootsize=67108864"

At this point you get to choose whether to boot the new kernel image or more "permanently" flash it on the device's boot partition instead ^^

Boot: pmbootstrap chroot -- fastboot boot /tmp/mainline/boot.img

Flash: pmbootstrap chroot -- fastboot flash boot /tmp/mainline/boot.img

See also