[FAQ/HOWTO] An introduction to how-to-build a kernel for MT6589

Search This thread

Dr-Shadow

Inactive Recognized Developer
Sep 15, 2013
454
560
NANTES
Hi guys,

I was working on this since some time and here it is

Please read FAQ first

FAQ :
  1. Can I compile a MT6589 kernel for every phone ?
    As you know, a MT6589 kernel won't fit in every MT6589 smartphone because of specific configs/files in the kernel source tree.
    So, if you compile my kernel which is expected to work on a Faea F2S don't expect it to work on a Acer Liquid E3 for example.
    Conclusion : You have to get the kernel source for your phone​
  2. How can I check my kernel source ?
    Of course, this is not enough to see "source code for ZTE N986", you have to check if it's full or not and if it works.
    Most people don't know what is working kernel source. You just have to read the GPL guidelines that every manufacturer have to complain with :
    “ The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. ”
    The part which has not to be included is the toolchain but there should reference to it (which toolchain to use)
    For MT6589 kernel, the toolchains arm-eabi-4.6 and arm-linux-androideabi-4.6 should be used. (mtk used arm-linux-androideabi-4.6 for kernel but it should be arm-eabi-4.6)
    So now you know which toolchain to grab and then for kernel source you have to check this minimal structure :
    bionic
    kernel
    mediatek
    build
    config
    custom
    kernel
    platform​
    README​
  3. If I have kernel source, can I build it for my device ?
    Erm... Sometimes the structure is here but the kernel source is messy... Why ?
    Because you were not provided the matching source of the kernel used on your smartphone and the reasons are multiple (I won't give details).
    So, the idea is to run a first build. If you get errors, then check the step above about toolchain and structure.
    The next step for fixing errors is to play with source. Good luck for that.​
  4. What are the benefits of a custom kernel for MT6589 ?
    First big benefit is to introduce kitkat compatibility because there was an issue on android binder driver in mtk kernel source.
    Next benefit is to be able to remove some stuff from mtk which is useless on user side and waste ressources (a lot of debug for example).
    Others benefits will be in optimizations or new features (see frandom for example)​

HOWTO :
Build from my repo (specific devices supported) - It's not for compiling your kernel source but to understand how kernel build works​
I explain how to build from my repo first because it can help you to understand how you should build kernel source
Prerequisites : A build environment (actually Ubuntu Saucy x64 with build-essentials, ccache, repo, java, perl v5.14+ and openssl) and I won't explain how to get one as there is multiple howto on the net.
For repo, the idea is to create a bin directory in your $HOME (usually /home/accountname/), copy repo binary inside it and then add this bin to $PATH var.
BE CAREFULL TO WHAT YOU DO WITH $PATH VAR ! I always see people doing :
Code:
export PATH=/home/foo/bin
this is erasing $PATH var, just check before and after with echo $PATH
So the idea is to introduce your path AFTER the actual $PATH var
This is easy...
Code:
export PATH=[COLOR="red"]$PATH:[/COLOR]/home/foo/bin
And of course, $PATH is reset once you close terminal and I won't explain how to set $PATH automatically.
Once you got this, everything should be working and it will be easy
Code:
mkdir workdir
cd workdir
repo init -u https://github.com/Dr-Shadow/android_kernel_mt6589_manifest.git -b master
repo sync
Then you should get this in your workdir :
kernel
manifest
mtk-tools
out
ramdisk
scripts
toolchain​
Just do :
Code:
cd kernel
./certificates.sh
./build.sh
./certificates.sh is needed only once (it's for signing flashable zip and it will setup some keys for it, just reply to questions and don't add passphrase)
And of course, the build.sh contains most things you need to know on steps for building kernel (which commands to use) and you need to know how it works ;)
Build from your own kernel source​

I'm building the doc... I have to remind which vars need to be overriden
 
Last edited:

ransagy

Senior Member
Jun 29, 2010
300
41
Tel Aviv
I'll chip in and say thanks too. Finally getting around to trying to compile Alcatel's OneTouch Hero (aka TCL Y910) provided sources.
 

I.nfraR.ed

Senior Member
May 9, 2013
234
275
Sofia
I might be in as well with A820, but I'm relatively new to Android and have only done porting of 4.1 and 4.2 so far.
Haven't built anything although I have some knowledge about the source code and SDK, which I've only used for reference purposes and the tools from it.

Will try to compile the stock kernel this weekend, but I'm not quite sure if something else is needed, even if the kernel source seems complete to me.

I'm a quick learner and have a lot of programming experience in other technologies, even thought I'm more of a front-end developer these days.
 
  • Like
Reactions: hajiborojobo

Top Liked Posts

  • There are no posts matching your filters.
  • 17
    Hi guys,

    I was working on this since some time and here it is

    Please read FAQ first

    FAQ :
    1. Can I compile a MT6589 kernel for every phone ?
      As you know, a MT6589 kernel won't fit in every MT6589 smartphone because of specific configs/files in the kernel source tree.
      So, if you compile my kernel which is expected to work on a Faea F2S don't expect it to work on a Acer Liquid E3 for example.
      Conclusion : You have to get the kernel source for your phone​
    2. How can I check my kernel source ?
      Of course, this is not enough to see "source code for ZTE N986", you have to check if it's full or not and if it works.
      Most people don't know what is working kernel source. You just have to read the GPL guidelines that every manufacturer have to complain with :
      “ The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. ”
      The part which has not to be included is the toolchain but there should reference to it (which toolchain to use)
      For MT6589 kernel, the toolchains arm-eabi-4.6 and arm-linux-androideabi-4.6 should be used. (mtk used arm-linux-androideabi-4.6 for kernel but it should be arm-eabi-4.6)
      So now you know which toolchain to grab and then for kernel source you have to check this minimal structure :
      bionic
      kernel
      mediatek
      build
      config
      custom
      kernel
      platform​
      README​
    3. If I have kernel source, can I build it for my device ?
      Erm... Sometimes the structure is here but the kernel source is messy... Why ?
      Because you were not provided the matching source of the kernel used on your smartphone and the reasons are multiple (I won't give details).
      So, the idea is to run a first build. If you get errors, then check the step above about toolchain and structure.
      The next step for fixing errors is to play with source. Good luck for that.​
    4. What are the benefits of a custom kernel for MT6589 ?
      First big benefit is to introduce kitkat compatibility because there was an issue on android binder driver in mtk kernel source.
      Next benefit is to be able to remove some stuff from mtk which is useless on user side and waste ressources (a lot of debug for example).
      Others benefits will be in optimizations or new features (see frandom for example)​

    HOWTO :
    Build from my repo (specific devices supported) - It's not for compiling your kernel source but to understand how kernel build works​
    I explain how to build from my repo first because it can help you to understand how you should build kernel source
    Prerequisites : A build environment (actually Ubuntu Saucy x64 with build-essentials, ccache, repo, java, perl v5.14+ and openssl) and I won't explain how to get one as there is multiple howto on the net.
    For repo, the idea is to create a bin directory in your $HOME (usually /home/accountname/), copy repo binary inside it and then add this bin to $PATH var.
    BE CAREFULL TO WHAT YOU DO WITH $PATH VAR ! I always see people doing :
    Code:
    export PATH=/home/foo/bin
    this is erasing $PATH var, just check before and after with echo $PATH
    So the idea is to introduce your path AFTER the actual $PATH var
    This is easy...
    Code:
    export PATH=[COLOR="red"]$PATH:[/COLOR]/home/foo/bin
    And of course, $PATH is reset once you close terminal and I won't explain how to set $PATH automatically.
    Once you got this, everything should be working and it will be easy
    Code:
    mkdir workdir
    cd workdir
    repo init -u https://github.com/Dr-Shadow/android_kernel_mt6589_manifest.git -b master
    repo sync
    Then you should get this in your workdir :
    kernel
    manifest
    mtk-tools
    out
    ramdisk
    scripts
    toolchain​
    Just do :
    Code:
    cd kernel
    ./certificates.sh
    ./build.sh
    ./certificates.sh is needed only once (it's for signing flashable zip and it will setup some keys for it, just reply to questions and don't add passphrase)
    And of course, the build.sh contains most things you need to know on steps for building kernel (which commands to use) and you need to know how it works ;)
    Build from your own kernel source​

    I'm building the doc... I have to remind which vars need to be overriden
    1
    Looking forward to the how-to to build with your own kernel source.
    1
    I might be in as well with A820, but I'm relatively new to Android and have only done porting of 4.1 and 4.2 so far.
    Haven't built anything although I have some knowledge about the source code and SDK, which I've only used for reference purposes and the tools from it.

    Will try to compile the stock kernel this weekend, but I'm not quite sure if something else is needed, even if the kernel source seems complete to me.

    I'm a quick learner and have a lot of programming experience in other technologies, even thought I'm more of a front-end developer these days.