Stage 1. Initial port Let's start with first step - bases choice. Under base I will mean rom which could be used to port miui and also miui release you choose. Let's assume - just "Base" will mean rom for your device with Jelybean 4.1.2/4.2.2, such as Cyanogen Mod, AOKP or AOSP and their variations (I don't know if it is possible to use stock rom for porting and wouldn't recommend it), "MIUI base" means any miui rom you prefer (my preference and advice - MiuiAndroid Mako [Nexus 4] or MiuiAndroid maguro (Galaxy Nexus) release). Or if on 4.1.2 use a device such as MiuiAndroid Crespo (Nexus S) In the guide I will describe steps right for you with mark "4.1.2 or with 4.2.2". If for you version number is crucial - stop reading this guide and just use PatchROM (though rom will be based on Stock rom). There is third variant, but it needs a device with nearly same specs: you might just replace some files in miui-supported device rom with files from your stock rom. When base choosen, start to port: Copy unpacked base rom (so set of folders) to any folder you prefer (let's name it "MIUI"), it usually contains: system - folder on which we will work more often data - may contain something necessary such as first boot scripts, config files etc. META-INF - contains certificates and signature for signcheck, updater-script(we also will work on it) update-binary (updater-script command processor) boot.img, kernel and ramdisk packed together. Starting with system: delete: app framework media fonts then open miui base and extract those folders to base. Don't close archive. Open lib folder in system to add the following files to base from miui base: content-types.properties libFreqFilter.so libaudiofp.so libffmpeg_xm.so libffplayer_jni.so libimageutilites_jni.so libjni_resource_drm.so liblbesec.so liblocSDK_2.5OEM.so liblocSDK_2_5OEM.so libmp3lame.so libpatcher_jni.so libphotocli.so libshell*.so Open etc folder in system to add to base: telocation.idf yellowpage.db secomxregistry pintinindex.idf unicode_py_index.td permission_config.json SPN-config go to permissions folder in etc to add: com.nxp.mifare.xml [NFC] com.google.android.media.effects.xml [gallery] com.google.widevine.software.drm.xml [something also related to google may affect play market] com.google.android.maps.xml [gmaps] Open xbin folder in system to add to base: su [replace, don't even use base one!] shelld [Important for shell services] Also Devices which don't have NFC(Near Field Communication chip) also shouldn't have Nfc.apk in app folder! Devices that do use your own! Let's modify build.prop of the base, add: ro.build.id=MIUIro.build.display.id=MIUIro.build.version.incremental=2.x.xro.config.ringtone=MI.oggro.config.notification_sound=FadeIn.oggro.config.alarm_alert=GoodMorning.oggro.config.sms_received_sound=FadeIn.oggro.config.sms_delivered_sound=MessageComplete.ogg ro.build.version.incremental points to MIUI you port, so specify it. At your base you will most likely see these lines ro.config.ringtone=ro.config.notification_sound=ro.config.alarm_alert=ro.config.sms_received_sound=ro.config.sms_delivered_sound= are filled with ringtones that only base have, soo just change them as MIUI do have different ringtone set. Initial port done, in system part, let's talk about Updater-script: any release of miui you port should have that line: set_perm(0, 0, 06755, "/system/xbin/shelld"); for example you have that bunch of code [which is mostly common for CM10/10.1 releases]: set_perm_recursive(0, 0, 0755, 0644, "/system");set_perm_recursive(0, 2000, 0755, 0755, "/system/bin");set_perm(0, 3003, 06755, "/system/bin/ip");set_perm(0, 3003, 02750, "/system/bin/netcfg");set_perm(0, 3004, 02755, "/system/bin/ping");set_perm(0, 2000, 06750, "/system/bin/run-as");set_perm_recursive(1002, 1002, 0755, 0440, "/system/etc/bluetooth");set_perm(0, 0, 0755, "/system/etc/bluetooth");set_perm(1000, 1000, 0640, "/system/etc/bluetooth/auto_pairing.conf");set_perm(3002, 3002, 0444, "/system/etc/bluetooth/blacklist.conf");set_perm(1002, 1002, 0440, "/system/etc/dbus.conf");set_perm(1014, 2000, 0550, "/system/etc/dhcpcd/dhcpcd-run-hooks");set_perm(0, 2000, 0550, "/system/etc/init.goldfish.sh");set_perm_recursive(0, 0, 0755, 0555, "/system/etc/ppp");set_perm_recursive(0, 2000, 0755, 0644, "/system/vendor");set_perm_recursive(0, 2000, 0755, 0755, "/system/xbin");set_perm(0, 0, 06755, "/system/xbin/librank");set_perm(0, 0, 06755, "/system/xbin/procmem");set_perm(0, 0, 06755, "/system/xbin/procrank");set_perm(0, 0, 06755, "/system/xbin/su");set_perm(0, 0, 06755, "/system/xbin/tcpdump");set_perm_recursive(0, 0, 0755, 0644, "/system/vendor/firmware");set_perm(0, 2000, 0755, "/system/vendor/firmware");set_perm_recursive(0, 0, 0755, 0555, "/system/etc/init.d"); So line I pointed should be somewhere there, for example: set_perm(0, 0, 06755, "/system/xbin/librank");set_perm(0, 0, 06755, "/system/xbin/procmem");set_perm(0, 0, 06755, "/system/xbin/procrank");set_perm(0, 0, 06755, "/system/xbin/shelld");set_perm(0, 0, 06755, "/system/xbin/su");set_perm(0, 0, 06755, "/system/xbin/tcpdump"); IF you have problems with SU, that line may help: symlink("/system/xbin/su", "/system/bin/su"); paste it somewhere after symlink("busybox"[later big code bunch like "/system/xbin/[" etc] but before unmount("/system"); Finally the Boot.img (Different for 4.1.2 and 4.2.2) For 4.1.2 and 4.2.2 you will have to know how to unpack and repack your boot.img so you can edit your ramdisk. Use dsixda's Android Kitchen located here: http://forum.xda-developers.com/showthread.php?t=633246. Once unpacked, you will have to make edits in your init.rc file and default.prop For 4.1.2 and 4.2.2 there are two common edits needed. One is adding shelld to your main class located at the end of the file. Another is editing your default.prop. You will see where it goes when you open the file. Add the following to your init.rc at the end with other main classes: service shelld /system/xbin/shelld class main For the second edit, you will need to modify your default.prop. Change your ro.secure line to: ro.secure=0 Then, you will need to delete the following line: ro.adb.secure=1 Thats all for 4.1.2!! Repack your boot.img and your good to go!! If you are 4.2.2 you will need one more edit in your init.rc bootclasspath. You will have to add the following in between two references: :/system/framework/framework_ext.jar ^^^^ Add that in between :/system/framework/android policy and :/system/framework/mms-common so it should look like this: :/system/framework/android policy:/system/framework/framework_ext.jar:/system/framework/mms-common And your 4.2.2 boot.img is done!!!! **Remember you need two edits in 4.1.2 and three edits in 4.2.2** Your own MIUI is now ready to be flashed, but only if your device is SOOO near on hardware part with MIUI base. For those who dont meet the rule I prepared the next part - framework mods and common debugging and troubleshooting. See next the two posts.