Xiaomi Mi 9 (xiaomi-cepheus)

Category:Devices with known UART pinout
__TOC__
== Contributors ==
Alexey Min
== Maintainer(s) ==
Alexey Min
== Users owning this device ==
== How to enter flash mode ==
=== Bootloader Unlocking ===
Like other Xiaomi devices, the user will have to acquire the bootloader unlock key: https://en.miui.com/unlock
The device will not unlock if the device isn't 7 days old (from the time when your device connects to internet and powered on, and linked with Mi Account)
=== Recovery mode ===
* Turn the device off (or restart also works)
* Hold and button
* Once you feel vibration and phone turns on, release button
* Keep holding until you get to recovery.
=== Flashing (Download, Fastboot) mode ===
* Same as recovery, but this time hold the and keys.
The device supports booting images using fastboot boot / pmbootstrap flasher boot.
== Installation ==
To boot mainline kernel you need to erase dtbo partition and disable vbmeta.
 * pmbootstrap init # select xiaomi, cepheus, console ui (currently you probably don't need anything else)
 * pmbootstrap install --no-firewall
 * pmbootstrap initfs hook_add debug-shell / netboot # optional
 * fastboot erase dtbo
 * pmbootstrap flasher flash_vbmeta # this flashes vbmeta with verity disabled flag
 * pmbootstrap flasher flash boot && fastboot reboot / pmbootstrap flasher boot # ?
== Installation (downstream port) ==
Unlike with mainline kernel, here you don't need to erase dtbo partition.
 * pmbootstrap init # select xiaomi, cepheus-downstream, confirm Y, select console ui (currently you probably don't need anything else)
 * pmbootstrap install --no-firewall
 * pmbootstrap flasher flash_vbmeta # this flashes vbmeta with verity disabled flag
 * pmbootstrap flasher flash_rootfs
 * pmbootstrap flasher flash_kernel
 * fastboot reboot
== Extra information ==
=== Partition layout ===
Partition layout:
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 abl -> /dev/block/sde35
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 ablbak -> /dev/block/sde36
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 aop -> /dev/block/sde15
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 aopbak -> /dev/block/sde16
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 apdp -> /dev/block/sde8
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 bk01 -> /dev/block/sda4
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 bk02 -> /dev/block/sda5
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 bk03 -> /dev/block/sda6
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 bk04 -> /dev/block/sda7
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 bk05 -> /dev/block/sda10
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 bk06 -> /dev/block/sda13
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 bk07 -> /dev/block/sda15
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 bk08 -> /dev/block/sda20
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 bk09 -> /dev/block/sda22
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 bk31 -> /dev/block/sdd1
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 bk32 -> /dev/block/sdd3
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 bk33 -> /dev/block/sdd5
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 bk41 -> /dev/block/sde5
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 bk42 -> /dev/block/sde12
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 bk43 -> /dev/block/sde23
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 bk44 -> /dev/block/sde30
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 bk45 -> /dev/block/sde39
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 bk47 -> /dev/block/sde50
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 bk51 -> /dev/block/sdf2
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 bk52 -> /dev/block/sdf3
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 bluetooth -> /dev/block/sde26
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 boot -> /dev/block/sde49
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 cache -> /dev/block/sda29
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 catecontentfv -> /dev/block/sde28
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 catefv -> /dev/block/sde18
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 cateloader -> /dev/block/sde31
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 cdt -> /dev/block/sdd2
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 cmnlib -> /dev/block/sde19
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 cmnlib64 -> /dev/block/sde21
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 cmnlib64bak -> /dev/block/sde22
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 cmnlibbak -> /dev/block/sde20
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 core_nhlos -> /dev/block/sde51
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 cust -> /dev/block/sda30
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 dbg -> /dev/block/sda3
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 ddr -> /dev/block/sdd4
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 devcfg -> /dev/block/sde13
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 devcfgbak -> /dev/block/sde14
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 devinfo -> /dev/block/sda17
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 dip -> /dev/block/sde27
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 dsp -> /dev/block/sde48
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 dtbo -> /dev/block/sde45
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 frp -> /dev/block/sda9
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 fsc -> /dev/block/sdf1
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 fsg -> /dev/block/sde40
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 gsort -> /dev/block/sde44
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 hyp -> /dev/block/sde42
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 hypbak -> /dev/block/sde43
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 ifaa -> /dev/block/sde46
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 imagefv -> /dev/block/sdf4
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 keymaster -> /dev/block/sde24
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 keymasterbak -> /dev/block/sde25
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 keystore -> /dev/block/sda8
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 limits -> /dev/block/sde4
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 logdump -> /dev/block/sda25
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 logfs -> /dev/block/sda14
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 logo -> /dev/block/sde47
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 metadata -> /dev/block/sda19
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 minidump -> /dev/block/sda26
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 misc -> /dev/block/sda11
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 modem -> /dev/block/sde52
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 modemst1 -> /dev/block/sdf5
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 modemst2 -> /dev/block/sdf6
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 msadp -> /dev/block/sde9
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 multiimgoem -> /dev/block/sde1
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 multiimgqti -> /dev/block/sde2
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 oem_misc1 -> /dev/block/sda18
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 oops -> /dev/block/sda16
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 persist -> /dev/block/sda23
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 persistbak -> /dev/block/sda24
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 qupfw -> /dev/block/sde6
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 qupfwbak -> /dev/block/sde7
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 rawdump -> /dev/block/sda27
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 recovery -> /dev/block/sda28
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 secdata -> /dev/block/sde3
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 splash -> /dev/block/sda21
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 spunvm -> /dev/block/sde41
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 ssd -> /dev/block/sda2
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 storsec -> /dev/block/sde11
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 switch -> /dev/block/sda1
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 system -> /dev/block/sde54
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 toolsfv -> /dev/block/sde34
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 tz -> /dev/block/sde37
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 tzbak -> /dev/block/sde38
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 uefisecapp -> /dev/block/sde32
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 uefisecappbak -> /dev/block/sde33
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 uefivarstore -> /dev/block/sde17
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 userdata -> /dev/block/sda31
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 vbmeta -> /dev/block/sde10
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 vendor -> /dev/block/sde53
lrwxrwxrwx 1 root root 16 1971-12-18 13:45 vm-data -> /dev/block/sda12
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 xbl -> /dev/block/sdb2
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 xbl_config -> /dev/block/sdb1
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 xbl_configbak -> /dev/block/sdc1
lrwxrwxrwx 1 root root 15 1971-12-18 13:45 xblbak -> /dev/block/sdc2
$ sudo busybox fdisk -l
Note: sector size is 4096 (not 512)
Found valid GPT with protective MBR; using GPT
Disk /dev/sdf: 65536 sectors, 256M
Logical sector size: 4096
Disk identifier (GUID): fead433a-45f5-7b1c-4f17-9e5a276e3c76
Partition table holds up to 32 entries
First usable sector is 6, last usable sector is 8186
Number Start (sector) End (sector) Size Name
 1 6 69 256K fsc
 2 70 255 744K bk51
 3 256 511 1024K bk52
 4 512 1023 2048K imagefv
 5 1024 3071 8192K modemst1
 6 3072 5119 8192K modemst2
 7 5120 8186 11.9M last_parti
Note: sector size is 4096 (not 512)
Found valid GPT with protective MBR; using GPT
Disk /dev/sda: 112214016 sectors, 64.0M
Logical sector size: 4096
Disk identifier (GUID): 6bf2d432-e5e3-d03b-e45c-737163689e9a
Partition table holds up to 32 entries
First usable sector is 6, last usable sector is 14026746
Number Start (sector) End (sector) Size Name
 1 6 7 8192 switch
 2 8 15 32768 ssd
 3 16 23 32768 dbg
 4 24 31 32768 bk01
 5 32 63 128K bk02
 6 64 127 256K bk03
 7 128 255 512K bk04
 8 256 383 512K keystore
 9 384 511 512K frp
 10 512 1023 2048K bk05
 11 1024 2047 4096K misc
 12 2048 3071 4096K vm-data
 13 3072 4095 4096K bk06
 14 4096 6143 8192K logfs
 15 6144 8191 8192K bk07
 16 8192 12287 16.0M oops
 17 12288 16383 16.0M devinfo
 18 16384 20479 16.0M oem_misc1
 19 20480 24575 16.0M metadata
 20 24576 32603 31.3M bk08
 21 32604 40959 32.6M splash
 22 40960 49151 32.0M bk09
 23 49152 65535 64.0M persist
 24 65536 81919 64.0M persistbak
 25 81920 98303 64.0M logdump
 26 98304 131071 128M minidump
 27 131072 163839 128M rawdump
 28 163840 180223 64.0M recovery
 29 180224 245759 256M cache
 30 245760 507903 1024M cust
 31 507904 14026746 51.5G userdata
Note: sector size is 4096 (not 512)
Found valid GPT with protective MBR; using GPT
Disk /dev/sdb: 16384 sectors, 64.0M
Logical sector size: 4096
Disk identifier (GUID): 8492cc0f-bc06-ccf4-503c-12506a977b64
Partition table holds up to 32 entries
First usable sector is 6, last usable sector is 2042
Number Start (sector) End (sector) Size Name
 1 6 133 512K xbl_config
 2 134 1925 7168K xbl
 3 1926 2042 468K last_parti
Note: sector size is 4096 (not 512)
Found valid GPT with protective MBR; using GPT
Disk /dev/sdc: 16384 sectors, 64.0M
Logical sector size: 4096
Disk identifier (GUID): 20d6b4ac-e894-aa85-f848-30ef7a612310
Partition table holds up to 32 entries
First usable sector is 6, last usable sector is 2042
Number Start (sector) End (sector) Size Name
 1 6 133 512K xbl_configbak
 2 134 1925 7168K xblbak
 3 1926 2042 468K last_parti
Note: sector size is 4096 (not 512)
Found valid GPT with protective MBR; using GPT
Disk /dev/sdd: 65536 sectors, 256M
Logical sector size: 4096
Disk identifier (GUID): c56e2ee2-0467-b3c1-b445-8ccafb33c002
Partition table holds up to 32 entries
First usable sector is 6, last usable sector is 8186
Number Start (sector) End (sector) Size Name
 1 6 13 32768 bk31
 2 14 45 128K cdt
 3 46 261 864K bk32
 4 262 517 1024K ddr
 5 518 773 1024K bk33
 6 774 8186 28.9M last_parti
Note: sector size is 4096 (not 512)
Found valid GPT with protective MBR; using GPT
Disk /dev/sde: 12582912 sectors, 0
Logical sector size: 4096
Disk identifier (GUID): bf0ad734-2424-987e-e115-25eb5eb0690b
Partition table holds up to 64 entries
First usable sector is 6, last usable sector is 1572858
Number Start (sector) End (sector) Size Name
 1 6 13 32768 multiimgoem
 2 14 21 32768 multiimgqti
 3 22 29 32768 secdata
 4 30 37 32768 limits
 5 38 63 104K bk41
 6 64 95 128K qupfw
 7 96 127 128K qupfwbak
 8 128 191 256K apdp
 9 192 255 256K msadp
 10 256 287 128K vbmeta
 11 288 319 128K storsec
 12 320 383 256K bk42
 13 384 447 256K devcfg
 14 448 511 256K devcfgbak
 15 512 639 512K aop
 16 640 767 512K aopbak
 17 768 895 512K uefivarstore
 18 896 1023 512K catefv
 19 1024 1279 1024K cmnlib
 20 1280 1535 1024K cmnlibbak
 21 1536 1791 1024K cmnlib64
 22 1792 2047 1024K cmnlib64bak
 23 2048 2303 1024K bk43
 24 2304 2559 1024K keymaster
 25 2560 2815 1024K keymasterbak
 26 2816 3071 1024K bluetooth
 27 3072 3327 1024K dip
 28 3328 3583 1024K catecontentfv
 29 3584 5631 8192K bk44
 30 5632 6143 2048K bk44
 31 6144 6655 2048K cateloader
 32 6656 7167 2048K uefisecapp
 33 7168 7679 2048K uefisecappbak
 34 7680 8191 2048K toolsfv
 35 8192 8703 2048K abl
 36 8704 9215 2048K ablbak
 37 9216 10239 4096K tz
 38 10240 11263 4096K tzbak
 39 11264 12287 4096K bk45
 40 12288 14335 8192K fsg
 41 14336 16383 8192K spunvm
 42 16384 18431 8192K hyp
 43 18432 20479 8192K hypbak
 44 20480 24575 16.0M gsort
 45 24576 32767 32.0M dtbo
 46 32768 49151 64.0M ifaa
 47 49152 65535 64.0M logo
 48 65536 81919 64.0M dsp
 49 81920 114687 128M boot
 50 114688 120319 22.0M bk47
 51 120320 163839 170M core_nhlos
 52 163840 245759 320M modem
 53 245760 638975 1536M vendor
 54 638976 1556479 3584M system
 55 1556480 1572858 63.9M last_parti
=== Getting logs through debug UART ===
Tested! It works extremely well and the TX pin is easily accessible even without soldering.
For the ground you can force a breadboard pin into some metal shield. Be careful not to break the back being of a glassy material, so use a piece of plastic such as a credit card (not to scratch the metal edges) to unstick the glue in the edges. To get the credit card into the edges you must first heat them with a phono or with a gas stove and then with a suction cup lift the back (opposing the strength of the glue). Never bend the back too much to avoid the risk of breaking it, but it is relatively flexible and always keeping in mind that it is a glassy material you will not have to leave defects, let alone cracks. If you care about aesthetics and plan to combine a mess, I recommend you put a spare back on the cart, they have a paltry price. The image below indicates which are the serial pins, this is the upper board.
=== Other xiaomi phones on sm8150 ===
* xiaomi-raphael (Mi 9T Pro / Redmi K20 Pro)
* xiaomi-andromeda (Mi Mix 3 5G)
* xiaomi-vayu (POCO X3 Pro) (sm8150-ac aka Snapdragon 860)
== Links ==
* pmaports WIP branch
* GSMARENA
* Deviceinfo HW pages: for cepheus: 1 2 (for raphael)