Angepinnt [ANLEITUNG] MIUI selbst erstellen (via Patch ROM)

  • [MIUI ROM]

  • dRaCID01
  • 21581 Aufrufe 29 Antworten
  • [ANLEITUNG] MIUI selbst erstellen (via Patch ROM)

    Dies ist eine Anleitung wenn man sich sein eigenes MIUI ROM für sein Gerät erstellen möchte. Sei es aus dem Grund weil man für sein Gerät keine offizielle Version von MIUI findet oder weil die bisherige Version nicht ganz so gut funktioniert und man sich selbst an eine Umsetzung für sein Gerät setzen möchte.

    Beim lesen und anwenden dieser Anleitung zum eigenständigen erstellen einer MIUI ROM für Android, wird Vorausgesetzt dass man der englischen Sprache mächtig ist. Dies ist aus dem Grund schon wichtig, da die hier angebotene Anleitung komplett in Englisch verfasst ist und man auch für das allg. Verständnis der englischen Sprache mächtig sein muss. Bei Fragen zu dieser Anleitung verweisen Wir direkt auf das Hersteller Forum von Xiaomi .

    Man kann sich hier aber über dieses Thema austauschen und bei einigen Problemen findet sich auch sicherlich jemand, der einem behilflich sein kann.

    Chapter one: Setting up a build environment

    Before you get your hands dirty with MIUI, you need to set up a build environment. Everything we cover here does not require you to have the source code (if you are interested in the source code please see We recommend that you download Android's source code if you're interested in development: it isn't necessary, but it's helpful.

    1. Operating system: Ubuntu 10 or higher

    You can use Windows, Linux or OSX to build MIUI ROM (or any other ROM for that matter). However, we developed the patchrom project using Linux (Ubuntu), we recommend that you use Ubuntu 10 or above. At the moment, we have no plans to develop a patchrom for Windows or OSX.

    2. Install the Android SDK

    This section will walk you through how to install the Android SDK in Ubuntu.

    2.1 Install the Java Development Kit (JDK)

    Download the Java Development Kit (JDK) at ... ownloads/index.html

    We recommend using version Java SE 6 Update 38.

    Ok, now install what you've downloaded:


    1. sudo chmod 755 jdk-6u38-linux-x64.bin
    2. sudo -s ./jdk-6u38-linux-x64.bin /opt

    Next, edit the bash file (.bashrc) under your root directory (home), to port all environment PATH variables


    1. vim ~/.bashrc

    at the end of the file add:


    1. # set java environment
    2. JAVA_HOME=/opt/jdk1.6.0_38
    3. export JRE_HOME=${JAVA_HOME}/jre
    4. export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
    5. export PATH=${JAVA_HOME}/bin:$PATH

    Next, apply the changes you just made:


    1. .~/.bashrc

    Finally, make sure that you've succesfully installed the JDK:


    1. java -version

    If everything has worked, you should see:

    2.2 Download the Android SDK
    Get the Android SDK at
    Unzip the contents to your root directory (home). Contents should be located @ /home/patcher/android-sdk-linux

    Ok, now edit the .bashrc file in your root directory (home), change the PATH environment variable to: export PATH=~/android-sdk-linux/platform-tools:~/android-sdk-linux/tools:$PATH

    Now apply the changes you've made to the PATH environment variable:


    1. .~/.bashrc

    2.3 Install the Android SDK

    Launch the Android SDK Manager:


    1. android

    After the installation is finished you'll see following window:

    Select Android SDK Tools and the Android SDK Platform-tool and click "Install packages", then follow the installer's instructions to complete the installation.

    NB: At, you may see that they tell you that you need to install Eclipse, however building the MIUI ROM doesn't require Eclipse, this is only required for Android development.

    2.4 Android Debug Bridge (adb)

    The most important tool in the Android SDK is adb and aapt. In the process of debugging, the command "adb logcat" comes in handy, as it prints a log for your connected device.

    To check and see if everything is working correctly, grab your device and go to Settings > Developer options, and make sure that USB debugging is enabled.
    Next, connect your device to the computer via USB and (in the Ubuntu Shell):


    1. adb devices

    If you see something like:

    Bus 002 Device 001:ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 001 Device 098:ID 04e8:685e Samsung Electronics Co.,Ltd

    Then congratulations! adb has recognized your device.

    NB: If you run into the message "No such permissions", you can run adb with ROOT permission (i.e. root your device). Or you can:

    1. (In terminal) Run:


    1. lsusb

    For the device I'm using, the output display is:

    Bus 002 Device 001:ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 001 Device 098:ID 04e8:685e Samsung Electronics Co.,Ltd

    Now copy the corresponding "04e8:685e" number (this contains the vendor id and product id). If you're not sure which line is your phone, then run the $ lsusb before connecting your device

    2. Under the directory "/etc/udev/rules.d"


    1. mkdir 99-android.rules

    then make the following edits: SUBSYSTEMS=”usb”, ATTRS{idVendor}=”04e8”,ATTRS{idProduct}=”685e”,
    MODE=”0666” , OWNER=”current_user”

    3. In terminal run:


    1. sudo restart udev

    Then reconnect your device.

    3. Sync MIUI code

    Under your root directory (home) make a new file:


    1. mkdir patchrom

    Install repo


    1. mkdir ~/bin
    2. vim ~/.bashrc
    3. set PATH=~/bin:$PATH

    Ok, switch to your patchrom directory (cd patchrom):


    1. cd patchrom

    4. The patchrom project

    Introduction to files and functions in the patchfrom
    • android: this directory has five sub-directories. The sub-directory src has a one-to-one correspondence with the miui/src (see below). android/src is the Android source code released by Google. miui/src is all the changes that have been on top of Google's source code. framework.jar.out, android.policy.jar.out, services.jar.out, have all been changed by MIUI, and have a one-to-one correspondence with the files in google-framework.
    • build: this directory has to do with the compiler and includes all the structures for the makefiles.
    • miui: this directory has two sub-directories: system and src. The system directory contains files that have been compiled with MIUI's source code, and these files are you will build MIUI ROM.
    • tools: this directory contains all the code for the tools included in the project. You need these tools in the process of compiling.

    Next, we'll do a build of MIUI that has been ported to i9300.

    Ok under the directory /home/patcher/patchrom:


    1. . build/

    After the command you've run has finished, the directory will create an install out (as a sub-directory). In the sub-directory you'll find the file (and that's the file we publish, which you can use to flash MIUI onto you're device). You can flash it out to your i9300 by booting into recovery mode.

    MIUI releases new builds every Friday (Orange Friday), below we can try the OTA update process.

    Ok let's say you're working with the for the build 3.1.18, ok, under the "out" directory you'll find We'll rename it "". Then, on 3.1.25, we issue a new fullota. When we issue a new OTA, in the "out" directory we now have "" and "", we rely on these two files to carry out an OTA. Just remember that you need to rename the target_files from the last OTA, otherwise the new fullota will replace them, and then you can't carry out an OTA.

    Under the directory /home/patcher/patchrom


    1. ./tools/releasetools/ota_from_target_files -k ../build/security/testkey -i</p><p>out/

    -k stands for key

    -i designates the previous target_files

    out/ are the new target_files this is the name of the newly created OTA file

    Miui Community
  • Chapter Two: Getting to know your Android phone

    When you get a new phone, you put in the battery, connect it to a charger, and turn it on. What happens from the moment when you turn on your phone to when you reach the Home screen of your OS? We'll answer that question by starting with a diagram of your phone's partitions:

    NB: This image does not reflect actual the order or location of partitions in your phone. It's just food for thought...

    A ROM is kind of like your computer's hard drive, it's partitioned into a couple parts: bootloader, boot, system, etc. In a second, we'll explain what some of these partitions actually do. Flashing a ROM is basically just installing some software on to a couple partitions on your phone, like installing a new OS on your computer's hard drive.

    After you've started your phone, commands are loaded from the bootloader partition. The bootloader consists of two parts: the primary bootloader and the secondary stage bootloader. The primary bootloader handles tests for hardware and makes sure it's all functioning properly. Then it copies the secondary stage bootloader to you phone's RAM and starts running it. The secondary stage bootloader runs some more preparatory processes for hardware. It gets the size of the device's RAM and launches into boot mode. Everyone is familiar with pressing & holding the Power button and some other button to boot into recovery mode, fastboot mode, or a menu of boot modes. When we talk about the bootloader on the forum, we are often referring to the secondary stage bootloader. But we don't need to get into too many details here, we can just say that the bootloader handles code, and depending on which buttons the user uses to start the device, bootloader boots into the corresponding mode.

    recovery mode: when you enter recovery mode, the secondary stage bootloader starts from the recovery partition of your device. The recovery partition is a separate Linux system. When the Linux kernel has started, it starts a program called "init" ("init is a collection of all the programs that Linux runs on). init then starts a program called "recovery". In recovery mode, the user can delete all the data stored on the device, install a new OTA package, etc. Generally speaking, manufacturers provide a simple recovery program. The famous CWM Recovery is just a basic recovery program with a bunch features added on. If you want to use CWM Recovery you'll need to make sure that your phone's recovery partition is rewritable. The unlocked bootloader that you see on the forum, refers to unlocked recovery or fastboot, and allows for the recovery partition to be rewritten. MIUI also has a recovery mode, which shares the same design principles as the ROM and can been operated using your phone's touch screen. Recovery's source code can be found and downloaded on github. We're working on a tutorial of recovery as fast as we can.

    In addition to common CPU, your phone also has a MODEM processor. This processor handles all the more traditional communication functions of your phone (for example the Radio app is written in the modem partition).

    2. Regular boot

    Most often, we power on our phones by touching the Power button (and enter a normal boot mode). The secondary stage bootloader will start from your phone's boot partition. The format of the boot partition is fixed: first there's the head, then there's the Linux kernel, and finally there's the ramdisk used with root systemfiles.

    After the Linux kernel has started, the init program in the system files begins and starts reading the script files (init.rc and There is a lot of material online regarding the format of the script files. When migrating to MIUI, we don't make any changes to the boot partition, because on some devices the boot partition is read-only.

    In the root systemfiles, there is a very important file called "default.prop", the contents of this file are usually as follows:


    Every line in this file corresponds to properties of different attributes, in the following chapter we will discuss some of these properties. For now, you need to take note of two properties: and ro.debuggable. If, then you can execute the $ adb root command (this is the core ROOT). When most people talk about ROOT permission, they are referring to permissions manager program on a device (Superuser.apk) which allows them to gain ROOT permissions.

    init reads and runs the scripts, a part of the script files run files that are stored on the system partition. Next, we'll take a look at the structure of the system partition.

    3. The system partition

    Before we get started on the system partition, let's take a look at this diagram of the Android system.

    • Core-app level: This level includes all the "built-in" apps in MIUI, like Contacts, Phone, Music, etc. App developers generally deal with this level and everything above.

    • System framework: This is the core of Android, it provides the entire mechanism for the operation of Android (e.g. managing windows, apks and install files) and other things that developers deal with activity, service, broadcast, etc.

    • JNI level: Java programs and the underlying OS both depend on this mechanism, it allows Java byte-code to be transferred using C/C++ to access the underlying OS's APIs.

    • Davlik virtual machine: Android is based on Java, Android's Java code is compiled in a virtual Davlik machine, and then the virtual machine analyzes and runs the code.

    • Local libraries: Local libraries are usually developed using C/C++, and are directly compiled into the corresponding CPU, this includes the standard C library, and the skia library which is used for rendering graphics, the Browser's core webkit and engine.

    HAL: HAL stands for Hardware Abstraction Layer. In order to get all the hardware from different manufacturers to work together, Android defines a hardware interface. For example, in order to use the camera, camera manufacturers must provide a hardware interface for the device, this allows code upstream to work with different kinds of hardware.

    Manufacturers' adaptation layer: Originally Android defined HAL as a layer which would deal directly with the drivers for hardware from various manufacturers, however manufacturers were not keen on making all of HAL open source, so many manufactures provide their own "adaptation layer". The hardware interface in the HAL layer uses simple functions from the Manufacturers' adaptation layer.

    Kernel: This layer is the Linux kernel, which includes a variety of hardware drivers, contents vary between manufacturer. The Linux kernel supports all the drivers. It allows users to dynamically install and uninstall drivers. But at the moment, besides providing the drivers for Wi-Fi, manufacturers keep all of the other drivers for hardware bundled together with the kernel (out of users' reach).

    Besides the kernel (which is stored in the boot partition), all other code is stored in the system partition. Below we discuss the directories located in the system partition.

    • system/app: Core apps are stored in this directory (also referred to as "Built-in apps"). These apps cannot be deleted as easily like downloaded apps, many people ROOT their devices and the use RE file manager to get rid of bloatware masquerading as build-in apps.

    • system/lib: This directory is home to the JNI level, the virtual Dalvik machine, Local libraries, HAL, the manufacturers' adaptation layer, and the dynamic links libraries (files ending in .so).

    • system/framework: The frame's JAR package is located here. For the purposes of porting MIUI, there are three important JAR packages (framework.jar, android.policy.jar, services.jar). We'll get into each of these packages in a bit.

    • system/fonts: The directory houses the system's default font files

    • system/media: This directory holds all sorts of media files that are used by the system (e.g. boot animation, wallpapers, etc.). The grouping of these files may vary between devices.

    • system/bin: This directory holds some extensions' executable files. Generally they are written using C/C++.

    • system/xbin: Many extensions' executable files are stored here, so this directory can be empty. The popular app Busybox is stored in this directory. All the symbolic link commands established by Busybox are stored in this directory.

    • system/build.prop: This directory has the same format as the default.prop file in system files, they are both referred to as attribute configuration files. The have some defined property values, codes can read or change these property values. The property value naming convention is as follows:

    If the property value begins with "ro" it means that it's read-only, and can't be edited with code.

    If it begins with "persist", it means that the values of these properties will be saved in a file, so they will be preserved even after a reboot.

    Properties with other beginnings can be edited with code, but will not be saved upon reboot.

    Most romers will edit the build.prop file, inside there are a few properties which have to do with your phone's settings. By changing the build.prop file you can make your own imprint.

    • system/etc: This directory has some config files (not the same as the property config files). The config files in this directory don't follow any conventions. Generally speaking, script files, like the config files for GPS (gps.conf) and APN (apns-conf.xml) are located in this directory. For example, the files for special filters and effects used by HTC's camera are stored here.

    4. Data and cache partitions

    After you power on your phone and get to the Home screen, you'll probably go download some apps. All of these apps are stored in data/app. All of the data generated by Android's apps is saved in the directory "data/data". When you're "wiping data", you're really just formatting the data partition of this drive. When you do this, all the data for your downloaded apps is deleted.

    As its name implies, the cache partition houses files: for example temporary files downloaded by the Music app or the Download app.

    5. Summary

    In this chapter we covered the basic structure of Android's software and the content in important partitions, and we also briefly covered your smartphone's boot process. This knowledge will help you gain a more comprehensive understanding of the porting process.

    Miui Community
  • Übersetzen alleine bringt Dir nichts.. da du später ja selbstständig bestimmte Sachen ausarbeiten musst. Daher würde eine Übersetzung nicht viel bringen. Dies steht übrigens auch oben im ersten Beitrag drin.. Wenn kein englisch vorhanden ist, brauch man sich auch weiter keine Mühe machen. Da alle weiteren Hilfsmittel in englisch dokumentiert sind.

    Miui Community
  • Wie sieht es aus, besteht Interesse dass dieses Tutorial vervollständigt und auf Deutsch übersetzt wird? Sollte Interesse daran bestehen, werde ich mich an die Arbeit machen und es übersetzen :)

  • Aber natürlich gerade jetzt!!! :)) schonmal jetzt danke für deine Mühe
    Samsung M8800 < iPhone 3G < HTC Desire < HTC Desire HD < Galaxy S1 < Galaxy S2 < Xperia Play < Galaxy S3 < Xiaomi Mi3 < LG G2 < HTC One M7 < galaxy S4 < iPhone 5 < Xiaomi MI4 < Oneplus One < LG G3 < Galaxy S5 < iPhone 6+ < Xiaomi Mi Note
  • ja dann.. Anleitung annehmen, versuchen sich damit auseinander zusetzen und mal sein Glück versuchen. Learning by doing, sagt man doch so schön. Bei Problemen gibt es hier sicherlich unterschiedliche Benutzer im Forum die da einem weiterhelfen können, wenn man die Probleme die da aufkommen könnten auch richtig schildert.

    Miui Community
  • Hells, gerne kann ich auch Teile oder gar die ganze Anleitung auch übersetzen wenn du keine Zeit/Lust o.ä. hast, würde das Montag in Angriff nehmen :)
    Samsung M8800 < iPhone 3G < HTC Desire < HTC Desire HD < Galaxy S1 < Galaxy S2 < Xperia Play < Galaxy S3 < Xiaomi Mi3 < LG G2 < HTC One M7 < galaxy S4 < iPhone 5 < Xiaomi MI4 < Oneplus One < LG G3 < Galaxy S5 < iPhone 6+ < Xiaomi Mi Note