• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[GUIDE]Making a ROM from source{Mediatek}

Top Liked Posts

  • There are no posts matching your filters.
  • 32
    Guide to Mediatek Building(Guide 3:=/system)

    Requisites
    A Linux machine
    The required packages(Look to the 2nd post)
    A source code(CyanogenMod,AOKP..)[Look at post 3 for more details]
    The Mediatek modified packaged, attached to post
    ]


    Lets get started!

    I'll reinstate the fact that mediatek is Anti GPL so doesnt release the source codes but some companies recently have started releasing the source and many of you guys asked me how to build a rom for a mediatek device. Here it goes



    There are three requirments for building a rom for a phone from source
    a)device tree
    b)kernel source
    c)vendor tree(usually made by the device/setup-makefiles.sh

    Step 1(Merging Mediatek files):First. you'd have to merge the package i gave in the post to your source tree.


    Step 2(Setting up the environment):(Assuming you have a kernel tree) Try to find a device tree for your phone this device tree can either be built from start or can be "forked" of a similar device. What i mean is, suppose you have a mt6589 chipset you can take the device tree from another mt6589 chipset. Here is a link to my device tree for Canvas 4 kitkat mt6589 device tree..kernel source for mt6589. If you are building for very similar devices of canvas 4 you could use my prebuilt kernel too.

    Step 3(Obtaining proprietory files):: For wifi,gps and radio to work we have to obtain some files which are "device-specific". We do this by executing the file in the device tree called the "extract-files.sh" or the "proprietory-files.sh". what these files do is they grep the contents from the proprietory-files.txt and pull it from your phone using adb.

    Step 4(Building):What we want to do first is setup the build environment. The script is located inside the build folder.This script describes how to set up your local work environment to build the Android source files. You will need to use Linux or Mac OS. Building under Windows is not currently supported.. to execute this script,
    Code:
    source build/envetup.sh
    . We have to now "lunch" the device. What this does is that it initializes the build environment for that particular device.
    we use this to tell linux to build it for your device this is done by
    Code:
    lunch cm_devicename-userdebug or lunch cm_devicename-eng
    A very good artical i came across for explaining the build-variants is here. Now is the easy part(Compiling). We now type
    Code:
    make -j# bacon
    what bacon does is create a .zip file which is flashable on your phone. #=no of processors+2. But if your processor is hyperthreaded, add 4 to the no of physical cores.

    Step 5(Errors):There is no one solution for all errors but general errors like "Term.apk not found" can be fixed by going to the vendor/cm(aokp..)/get-prebuilts. Other errors are welcome in the thread and I'll try my best to solve them :cool:

    Hope it helped you!, any feedback on the tutorial is welcome.
    Hit that thanks button if you think its worth it

    Regards and Good Luck
    My first tutorial:building a boot.img for mediatek


    Links to my next Guides
    Building the boot.img{MediaTek}
    Building the Kernel{MediaTek}

    Toolchain links are coming up.
    8
    Source code links

    you can get repo script by typing
    Code:
    curl $ http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    chmod a+x ~/bin/repo
    Code:
    repo init -u <URL to android manifest> -b <branch name>
    this is the generalized way to do this.

    For cyanogenmod:
    Code:
    repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0
    For aokp
    Code:
    repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat

    This is about 14GB and will take time to download. once its downloaded make sure you have the required packages from the second post. To start building follow the first post
    6
    Required packages before building



    Python 2.6 -- 2.7, which you can download from python.org.

    GNU Make 3.81 -- 3.82, which you can download from gnu.org,

    JDK 6 if you wish to build Gingerbread or newer; JDK 5 for Froyo or older. You can download both from java.sun.com.

    Git 1.7 or newer. You can find it at git-scm.com.



    #Required packages

    Code:
    sudo apt-get install git gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 git-core lzop ccache gnupg flex bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32ncurses5 lib32z1 lib32bz2-1.0 lib32ncurses5-dev x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 lib32z-dev libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc readline-common libreadline6-dev libreadline6 lib32readline-gplv2-dev libncurses5-dev lib32readline5 lib32readline6 libreadline-dev libreadline6-dev:i386 libreadline6:i386 bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev lib32bz2-dev libsdl1.2-dev libesd0-dev squashfs-tools pngcrush schedtool libwxgtk2.8-dev python gcc g++ cpp gcc-4.8 g++-4.8 && sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

    Go to etc/udev/rules.d/51-android.rules

    Code:
    # adb protocol on passion (Nexus One)
    SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="<username>"
    # fastboot protocol on passion (Nexus One)
    SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="<username>"
    # adb protocol on crespo/crespo4g (Nexus S)
    SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="<username>"
    # fastboot protocol on crespo/crespo4g (Nexus S)
    SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="<username>"
    # adb protocol on stingray/wingray (Xoom)
    SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="70a9", MODE="0600", OWNER="<username>"
    # fastboot protocol on stingray/wingray (Xoom)
    SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="708c", MODE="0600", OWNER="<username>"
    # adb protocol on maguro/toro (Galaxy Nexus)
    SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="<username>"
    # fastboot protocol on maguro/toro (Galaxy Nexus)
    SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER="<username>"
    # adb protocol on panda (PandaBoard)
    SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d101", MODE="0600", OWNER="<username>"
    # adb protocol on panda (PandaBoard ES)
    SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="d002", MODE="0600", OWNER="<username>"
    # fastboot protocol on panda (PandaBoard)
    SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d022", MODE="0600", OWNER="<username>"
    # usbboot protocol on panda (PandaBoard)
    SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d00f", MODE="0600", OWNER="<username>"
    # usbboot protocol on panda (PandaBoard ES)
    SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d010", MODE="0600", OWNER="<username>"
    # adb protocol on grouper/tilapia (Nexus 7)
    SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e42", MODE="0600", OWNER="<username>"
    # fastboot protocol on grouper/tilapia (Nexus 7)
    SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e40", MODE="0600", OWNER="<username>"
    # adb protocol on manta (Nexus 10)
    SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee2", MODE="0600", OWNER="<username>"
    # fastboot protocol on manta (Nexus 10)
    SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee0", MODE="0600", OWNER="<username>"




    In bash.rc
    Code:
    export USE_CCACHE=1

    Beter way installing java
    Code:
    sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update && sudo apt-get install oracle-java6-installer

    Reuqired package check
    Code:
    sudo apt-get install git-core lzop ccache gnupg flex bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32ncurses5 lib32z1 lib32bz2-1.0 lib32ncurses5-dev x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 lib32z-dev libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc readline-common libreadline6-dev libreadline6 lib32readline-gplv2-dev libncurses5-dev lib32readline5 lib32readline6 libreadline-dev libreadline6-dev:i386 libreadline6:i386 bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev lib32bz2-dev libsdl1.2-dev libesd0-dev squashfs-tools pngcrush schedtool libwxgtk2.8-dev python gcc g++ cpp gcc-4.8 g++-4.8

    THIS
    Code:
    sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so




    You're done
    3
    Kernel Development guide coming today :)
    2
    Nice guide, will surely try it when i get some time... Subscribed (y)

    Have fun!

    Regards