I have ported miui 9. The system boots up but the main problem is that cannot pass initial configuration because mi servers cannot verify/activated device. Right now I have tried to change devicename on build.prop and default.prop, changing bool flags on device features to non xiaomi device and so on. Nothing seems to work. As an important data,Provision.apk is is responsible for connecting and verifying the device during the initial configuration.
Ok, so, I have made 2 ports, one from Mi5x and other from Redmi 5 plus. I use tissot stock 7.8.24 as base.
MI 5x port:
Port rom is miui china official dev 8.4.12
Download rom: https://www.androidfilehost.com/?fid=818222786056029774
As a workaround to pass initial configuration, my friend @AnkyWalker send me a twrp data backup file after install same rom and pass initial config on his Mi5x device. Put the file on TWRP/snxxx/ and restore and you will be on launcher. Now you can install an app to take logs.
TWRP data backup: https://www.androidfilehost.com/?fid=962339331458991576
You will see system ui is crashing time to time. according anr traces log, find device and mi cloud is the responsible.
Redmi 5 plus port:
Port rom is miui global stable 188.8.131.52
Download rom: https://www.androidfilehost.com/?fid=818222786056029785
How to install:
Reboot to recovery
Install magisk zip
Reboot to bootloader
fastboot flash userdata userdata.img from Mi5x nougat i.e https://www.androidfilehost.com/?fid=746163614322263787
Tips to port:
-I use superr kitchen in linux to build the system. You must use raw images since sparse new.dat and meta-data/perm will not boot.
-Mount point for system is / as you can see on fstab ,so ramdisk is on / and system files are on /system/, thats the main difference.
-You can extract and compare wich files has been changed but basically, using fstab from stock and lib/modules will succesfully boot miui.