[GUIDE]Building a Kernel from source{Mediatek}

Search This thread

pchatzop

Senior Member
Oct 16, 2015
272
338
Hello guys, thank you for your awesome work. I need a kernel to make a friend's phone work correctly with kitkat , the thl w200s. I found some kitkat kernel sources(all credits go to snowcatPDA from 4pda forums) here: https://yadi.sk/d/nQBTPzucjFkSm . Would someone be so kind to compile them, since i have no idea on android development and would probably mess it up? Thanks.
 

~cyandrew

Senior Member
Jan 24, 2016
55
18

Goayandi

Member
May 2, 2016
44
43
Essen
github.com
Thank you very much :) Your Guide helped me a lot. But i do not quite understand how to upstream the kernel-source to the latest linux-patch.
I tried to download all patches from 3.4.67 (my stock kernel-version) to latest 3.4.111 from kernel.org. As i learned from a guide on Xda, i have to move these patches to kernel-folder (does that mean, i have to use the "kernel"-folder in root-directory or the mediatek-folder?).
There i used this command:
Code:
$ patch -p1 < patch-3.4.68
Is that right? Or how to apply these patches?

SOLVED.
I found this guide http://www.pro-linux.de/artikel/2/1572/3,aktualisieren.html .
 
Last edited:

abiolakunle

New member
Jun 11, 2016
2
0
p
Code:
abiol@abiol-HP-ProBook-4320s:~/Kernel/kernel$ export TARGET_BUILD_VARIANT=user TARGET_PRODUCT=mt6592 MTK_ROOT_CUSTOM=/mediatek/custom/ TARGET_KERNEL_VERSION=mt6592 &&export PATH=/home/abiol/Kernel/kernel/toolchain/bin:$PATH&&export CROSS_COMPILE=arm-eabi-&&export ARCH=arm
abiol@abiol-HP-ProBook-4320s:~/Kernel/kernel$ cp mediatek/config/mt6592/autoconfig/kconfig/platform .config
abiol@abiol-HP-ProBook-4320s:~/Kernel/kernel$ export ARCH_MTK_PLATFORM=mt6592
abiol@abiol-HP-ProBook-4320s:~/Kernel/kernel$ make menuconfig
scripts/kconfig/mconf Kconfig
.config:2512:warning: override: reassigning to symbol MTK_SCHED_RQAVG_US
.config:2513:warning: override: reassigning to symbol MTK_SCHED_RQAVG_KS
#
# configuration written to .config
#


*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

abiol@abiol-HP-ProBook-4320s:~/Kernel/kernel$ make
scripts/kconfig/conf --silentoldconfig Kconfig
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
make[1]: 'include/generated/mach-types.h' is up to date.
  CC      kernel/bounds.s
  GEN     include/generated/bounds.h
  CC      arch/arm/kernel/asm-offsets.s
In file included from include/linux/sched.h:58:0,
                 from arch/arm/kernel/asm-offsets.c:13:
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:43:42: error: division by zero in #if
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:43:42: error: division by zero in #if
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:43:42: error: division by zero in #if
include/linux/jiffies.h:43:42: error: division by zero in #if
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:43:42: error: division by zero in #if
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:43:42: error: division by zero in #if
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:43:42: error: division by zero in #if
include/linux/jiffies.h:43:42: error: division by zero in #if
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:43:42: error: division by zero in #if
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:43:42: error: division by zero in #if
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:43:42: error: division by zero in #if
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:43:42: error: division by zero in #if
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:43:42: error: division by zero in #if
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:257:31: warning: "CLOCK_TICK_RATE" is not defined [-Wundef]
include/linux/jiffies.h:43:42: error: division by zero in #if
include/linux/jiffies.h:43:42: error: division by zero in #if
/home/abiol/Kernel/kernel/./Kbuild:81: recipe for target 'arch/arm/kernel/asm-offsets.s' failed
make[1]: *** [arch/arm/kernel/asm-offsets.s] Error 1
Makefile:1008: recipe for target 'prepare0' failed
make: *** [prepare0] Error 2
abiol@abiol-HP-ProBook-4320s:~/Kernel/kernel$

this is the log for error i get when i try to compile
i.e
Code:
make zImage

pls i need help.
 

~cyandrew

Senior Member
Jan 24, 2016
55
18
#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.35.7
# Tue Dec 16 15:53:27 2014

Well, I had to download the entire ALPS build environment.
Then download your devices kernel and build it using build.sh , after configuring the environment in the kernel dir.
Afterwards copy the generated kernel...bin file into the baoxue_mytqe-master/kernel/ dir and rename it to kernel_baoxue.bin
then run
./target_build bootimage
you will get your boot.img in /baoxue_mytqe-master/out/target/product/baoxue/boot.image
that's all, I did , but i'll have to look into it deeply to understand what is going on.
Any am a little dissappointed that nobody showed how to do this, or even offered to help.
But I guess the best way is the hardway , compiling it a hundred times, only to figure out that arm-android-eabi doesn't work I found this after trying the original arm-eabi-
If you get s bootloop, try building with the stock .confi from the downloaded source then proceed.


Sent from my ALCATEL ONE TOUCH 918D using xda app-developers app
Bro, my source is also ALPS (Lenovo A536). Can you teach me how'd you set up the build enviroment?

Sent from my A536 using XDA-Developers mobile app
 

Qernel

New member
Jul 2, 2016
4
1
zImage compile error

I am getting an error cannot find Makefile when i try to make zImage. :confused:
Code:
scripts/Makefile.build:44: /home/steave/alps/kernel/mediatek/platform//kernel/core/Makefile: No such file or directory
make[1]: *** No rule to make target `/home/steave/alps/kernel/mediatek/platform//kernel/core/Makefile'.  Stop.
make: *** [mediatek/platform//kernel/core] Error 2

Here is the whole output
Code:
steave@steave-X-C660:~/alps/kernel$ cp mt6592cfg .config
steave@steave-X-C660:~/alps/kernel$ make zImage
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig Kconfig
#
# configuration written to .config
#
  WRAP    arch/arm/include/generated/asm/auxvec.h
  WRAP    arch/arm/include/generated/asm/bitsperlong.h
  WRAP    arch/arm/include/generated/asm/cputime.h
  WRAP    arch/arm/include/generated/asm/emergency-restart.h
  WRAP    arch/arm/include/generated/asm/errno.h
  WRAP    arch/arm/include/generated/asm/ioctl.h
  WRAP    arch/arm/include/generated/asm/irq_regs.h
  WRAP    arch/arm/include/generated/asm/kdebug.h
  WRAP    arch/arm/include/generated/asm/local.h
  WRAP    arch/arm/include/generated/asm/local64.h
  WRAP    arch/arm/include/generated/asm/percpu.h
  WRAP    arch/arm/include/generated/asm/poll.h
  WRAP    arch/arm/include/generated/asm/resource.h
  WRAP    arch/arm/include/generated/asm/sections.h
  WRAP    arch/arm/include/generated/asm/siginfo.h
  WRAP    arch/arm/include/generated/asm/sizes.h
  CHK     include/linux/version.h
  UPD     include/linux/version.h
  CHK     include/generated/utsrelease.h
  UPD     include/generated/utsrelease.h
  Generating include/generated/mach-types.h
  CC      kernel/bounds.s
  GEN     include/generated/bounds.h
  CC      arch/arm/kernel/asm-offsets.s
  GEN     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CC      scripts/mod/empty.o
  HOSTCC  scripts/mod/mk_elfconfig
  MKELF   scripts/mod/elfconfig.h
  HOSTCC  scripts/mod/file2alias.o
  HOSTCC  scripts/mod/modpost.o
  HOSTCC  scripts/mod/sumversion.o
  HOSTLD  scripts/mod/modpost
  HOSTCC  scripts/selinux/genheaders/genheaders
  HOSTCC  scripts/selinux/mdp/mdp
  HOSTCC  scripts/kallsyms
  CC      init/main.o
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  CC      init/do_mounts.o
  CC      init/do_mounts_initrd.o
  LD      init/mounts.o
  CC      init/initramfs.o
  CC      init/calibrate.o
  LD      init/built-in.o
  HOSTCC  usr/gen_init_cpio
  GEN     usr/initramfs_data.cpio
  AS      usr/initramfs_data.o
  LD      usr/built-in.o
  CC      arch/arm/vfp/vfpmodule.o
/tmp/ccHUzd26.s: Assembler messages:
/tmp/ccHUzd26.s:184: Warning: register range not in ascending order
/tmp/ccHUzd26.s:184: Warning: register range not in ascending order
  AS      arch/arm/vfp/entry.o
  AS      arch/arm/vfp/vfphw.o
  CC      arch/arm/vfp/vfpsingle.o
  CC      arch/arm/vfp/vfpdouble.o
  LD      arch/arm/vfp/vfp.o
  LD      arch/arm/vfp/built-in.o
  CC      arch/arm/kernel/elf.o
  AS      arch/arm/kernel/entry-armv.o
  AS      arch/arm/kernel/entry-common.o
  CC      arch/arm/kernel/irq.o
  CC      arch/arm/kernel/opcodes.o
  CC      arch/arm/kernel/process.o
  CC      arch/arm/kernel/ptrace.o
  CC      arch/arm/kernel/return_address.o
  CC      arch/arm/kernel/sched_clock.o
  CC      arch/arm/kernel/setup.o
  CC      arch/arm/kernel/signal.o
  CC      arch/arm/kernel/stacktrace.o
  CC      arch/arm/kernel/sys_arm.o
  CC      arch/arm/kernel/time.o
  CC      arch/arm/kernel/traps.o
  CC      arch/arm/kernel/fiq.o
  AS      arch/arm/kernel/fiqasm.o
  CC      arch/arm/kernel/armksyms.o
  CC      arch/arm/kernel/module.o
  AS      arch/arm/kernel/sleep.o
  CC      arch/arm/kernel/suspend.o
  CC      arch/arm/kernel/smp.o
  CC      arch/arm/kernel/smp_tlb.o
  CC      arch/arm/kernel/smp_scu.o
  CC      arch/arm/kernel/jump_label.o
  CC      arch/arm/kernel/insn.o
  CC      arch/arm/kernel/patch.o
  CC      arch/arm/kernel/thumbee.o
  CC      arch/arm/kernel/swp_emulate.o
  CC      arch/arm/kernel/pmu.o
  CC      arch/arm/kernel/topology.o
  CC      arch/arm/kernel/io.o
  LD      arch/arm/kernel/built-in.o
  AS      arch/arm/kernel/head.o
  CC      arch/arm/kernel/init_task.o
  LDS     arch/arm/kernel/vmlinux.lds
  CC      arch/arm/mm/dma-mapping.o
  CC      arch/arm/mm/extable.o
  CC      arch/arm/mm/fault.o
  CC      arch/arm/mm/init.o
  CC      arch/arm/mm/iomap.o
  CC      arch/arm/mm/fault-armv.o
  CC      arch/arm/mm/flush.o
  CC      arch/arm/mm/idmap.o
  CC      arch/arm/mm/ioremap.o
  CC      arch/arm/mm/mmap.o
  CC      arch/arm/mm/pgd.o
  CC      arch/arm/mm/mmu.o
  CC      arch/arm/mm/vmregion.o
  CC      arch/arm/mm/proc-syms.o
  CC      arch/arm/mm/alignment.o
arch/arm/mm/alignment.c: In function 'do_alignment':
arch/arm/mm/alignment.c:327:15: warning: 'offset.un' may be used uninitialized in this function [-Wmaybe-uninitialized]
   offset.un = -offset.un;
               ^
arch/arm/mm/alignment.c:749:21: note: 'offset.un' was declared here
  union offset_union offset;
                     ^
  CC      arch/arm/mm/highmem.o
  AS      arch/arm/mm/abort-ev7.o
  AS      arch/arm/mm/pabort-v7.o
  AS      arch/arm/mm/cache-v7.o
  CC      arch/arm/mm/copypage-v6.o
  CC      arch/arm/mm/context.o
  AS      arch/arm/mm/tlb-v7.o
  AS      arch/arm/mm/proc-v7.o
  LD      arch/arm/mm/built-in.o
  CC      arch/arm/common/gic.o
  AS      arch/arm/common/fiq_glue.o
  CC      arch/arm/common/fiq_glue_setup.o
  LD      arch/arm/common/built-in.o
  LD      arch/arm/net/built-in.o
scripts/Makefile.build:44: /home/steave/alps/kernel/mediatek/platform//kernel/core/Makefile: No such file or directory
make[1]: *** No rule to make target `/home/steave/alps/kernel/mediatek/platform//kernel/core/Makefile'.  Stop.
make: *** [mediatek/platform//kernel/core] Error 2

Any help will be greatly appreciated
 

hacknmtk

Senior Member
Jul 19, 2016
141
71
github.com
Check line 44 in your Makefile.build file. It looks like you may have added an extra "/" between "platform" and "kernel". That may be why it can't find the directory with your makefile in it.

Sent from my PIXI3_45_4G using XDA Labs
 

prateetsingh

Member
Feb 9, 2016
13
1
That is because the Environment variable "ARCH_MTK_PLATFORM" is not set. export it via the terminal. something like

Code:
export ARCH_MTK_PLATFORM=MT****

since the KConfig will specify the directory and drivers it will build using this variable

Code:
config ARCH_MTK_PLATFORM
  string
  option env="ARCH_MTK_PLATFORM"
[B][I][I]source "../mediatek/platform/$ARCH_MTK_PLATFORM/kernel/Kconfig/Platform"
source "../mediatek/platform/$ARCH_MTK_PLATFORM/kernel/Kconfig/Kernel"
source "../mediatek/platform/$ARCH_MTK_PLATFORM/kernel/Kconfig/Board"
source "../mediatek/platform/$ARCH_MTK_PLATFORM/kernel/Kconfig/Drivers"[/I][/I][/B]

endif

Me too facing the same and tried this too but no luck.. please help
 

kirito9

Inactive Recognized Contributor
Oct 30, 2013
3,127
1,367

ranchu-panchu

Senior Member
Nov 16, 2016
144
4
Hi,

I see that NO.1 D6 is using android 5.1 with mtk6577,
so isn't it just a matter of building mediatek kernel source for mtk6580 ?
I found mtk git for 5,1 here:
https://android.googlesource.com/kernel/mediatek/+/refs/tags/android-5.1.0_r0.2
So isn't it just a matter of building these source for mtk6580 , or do I miss something in my understand ?

NO.1 comany are not giving their kernel sources, although I've tried.

Thank you for the assistance,
Ranchu
 

kirito9

Inactive Recognized Contributor
Oct 30, 2013
3,127
1,367
Hi,

I see that NO.1 D6 is using android 5.1 with mtk6577,
so isn't it just a matter of building mediatek kernel source for mtk6580 ?
I found mtk git for 5,1 here:
https://android.googlesource.com/kernel/mediatek/+/refs/tags/android-5.1.0_r0.2
So isn't it just a matter of building these source for mtk6580 , or do I miss something in my understand ?

NO.1 comany are not giving their kernel sources, although I've tried.

Thank you for the assistance,
Ranchu

It is using android 5.1? I thought it was 6.0 and I thought the chipset was mt6580.

If no kernel sources, then you would have to use prebuilt kernel.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 40
    Guide to Mediatek Building(Guide 1:=Kernel)

    Here, we'll be talking about how to build kernels and how they are different than the ones we've built for Qualcomm.

    Requisites
    A linux machine
    Required Packages(Attached in 2nd post)
    C programming and a knowledge about Makefiles
    NDK


    Lets begin,

    Step 1(Setting up the build environment):=As always we have to set up the build environment so that the linux knows we are building something.
    This is how we do it
    Code:
    export TARGET_BUILD_VARIANT=user TARGET_PRODUCT=devicename MTK_ROOT_CUSTOM=../mediatek/custom/ TARGET_KERNEL_VERSION=devicename &&export PATH=pathToDir/arm-eabi-4.6/bin:$PATH&&export CROSS_COMPILE=arm-eabi-&&export ARCH=arm

    Let me explain what this does
    The BUILD_VARIANT specifies what the kernel is going to be built for. A very good article i came across for explaining the build-variants is here.
    The TARGET_PRODUCT/TARGET_KERNEL_PRODUCT tells the linux machine what "device specific" files to use
    The MTK_ROOT_CUSTOM specifies the directory of the mediatek/custom folder. remember this mide be in the same directory as the kernel source as well.
    The PATHThis sets your toolchain executables to your path. Download toolchain(preferably arm-eabi-4.6) Or, if you want to, you could build your own toolchain from source code
    The CROSS_COMPILE, A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running. The toolchain facilitates this function
    ARCH=arm, ARM is a family of instruction set architectures for computer processors based on a reduced instruction set computing (RISC) architecture developed by British company ARM Holdings. ARM is also used in Android. Here by typing
    Code:
    export ARCH=arm
    we are telling linux that we are going to be building for the CPU architecture "ARM".

    Thats enough theory, lets get our hands dirty :cool:

    Step 2(Configuring your kernel):=This is the heart to what your phone does so be careful when you do this if you're doubtful about something dont hesitate to ask me in the thread.. the base config is usually present in the kernel_source/mediatek/config/devicename/autoconfig/kconfig/platform. this is your base config which you will use and build with different requirments(Example:SELinux). You can always build a config from the start, I advice you dont do that until you have compiled a few kernels before. for using existing config as a base
    Code:
    cd kernel_source
    cp mediatek/config/devicename/autoconfig/kconfig/platform .config
    Now,
    Code:
    make menuconfig
    This will give a graphical interface for you to choose what features you want to add to your phone(Example:I/O Schedule,CPU Governors..) More about this here. You're now ready for compiling

    Step 3(Compiling):=This is the moment of truth; This is what youve been waiting for! Now, type
    Code:
    make zImage

    You will get something which says
    Code:
    arch/arm/boot/zImage Ready

    Step 4(Adding MediaTek headers):=[GUIDE]Building Mediatek boot.img{Appending headers}. This is my next guide, follow this to your way to compile a whole ROM for your phone.

    Now, use your source code to build a ramdisk for you by typing make bootimage. in the out folder you'll get a folder called root. This folder is the initramfs or the ramdisk. to this follow my next guide to understand how to append mediatek headers


    Code:
    make modules

    This is almost the most important step or your ROMS wont boot. after this is complete go to your sourcedir then in search type ".ko" you'll get a bunch of .ko files copy these to your device tree/ROM to make the rom to work.

    If you're moving to a device tree make sure to add this to your device_makefile
    Code:
    PRODUCT_COPY_FILES += \
    $(MOD_SRC)/ccci.ko:$(MOD_TGT)/ccci.ko \
    $(MOD_SRC)/ccci_plat.ko:$(MOD_TGT)/ccci_plat.ko \
    $(MOD_SRC)/devapc.ko:$(MOD_TGT)/devapc.ko \
    $(MOD_SRC)/devinfo.ko:$(MOD_TGT)/devinfo.ko \
    $(MOD_SRC)/mtk_fm_drv.ko:$(MOD_TGT)/mtk_fm_drv.ko \
    $(MOD_SRC)/mtk_hif_sdio.ko:$(MOD_TGT)/mtk_hif_sdio.ko \
    $(MOD_SRC)/mtk_stp_bt.ko:$(MOD_TGT)/mtk_stp_bt.ko \
    $(MOD_SRC)/mtk_stp_gps.ko:$(MOD_TGT)/mtk_stp_gps.ko \
    $(MOD_SRC)/mtk_stp_uart.ko:$(MOD_TGT)/mtk_stp_uart.ko \
    $(MOD_SRC)/mtk_stp_wmt.ko:$(MOD_TGT)/mtk_stp_wmt.ko \
    $(MOD_SRC)/mtk_wmt_wifi.ko:$(MOD_TGT)/mtk_wmt_wifi.ko \
    $(MOD_SRC)/mtklfb.ko:$(MOD_TGT)/mtklfb.ko \
    $(MOD_SRC)/pvrsrvkm.ko:$(MOD_TGT)/pvrsrvkm.ko \
    $(MOD_SRC)/scsi_tgt.ko:$(MOD_TGT)/scsi_tgt.ko \
    $(MOD_SRC)/scsi_wait_scan.ko:$(MOD_TGT)/scsi_wait_scan.ko \
    $(MOD_SRC)/sec.ko:$(MOD_TGT)/sec.ko \
    $(MOD_SRC)/vcodec_kernel_driver.ko:$(MOD_TGT)/vcodec_kernel_driver.ko \
    $(MOD_SRC)/wlan_mt6628.ko:$(MOD_TGT)/wlan_mt6628.ko

    This copies your custom built modules to the Module out folder. In BoardConfig.mk add
    Code:
    TARGET_PREBUILT_KERNEL := $(DEVICE_FOLDER)/prebuilt/kernel
    ..

    Remember :If you're building kernel for already existing 4.2 roms disable SELINUX support by going into security options inside menuconfig

    You're done!!

    All Questions and feedbacks are welcome in the thread
    Be sure to drop a thanks if you thought this was usefull

    Happy Building.

    --------------------------------------------------
    Links to my next Guides
    Building the boot.img{MediaTek}
    Building the ROM{MediaTek}
    9
    Build Packages

    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
    4
    I think I`m getting error because the toolchain.
    As Grand Prime Duos has a x64 cpu arquitecture, I used this toolschains to compile: aarch64-linux-android-4.9.
    I tried with arm-linux-androideabi-4.9 (x64) too...


    Which toolchain should I have to use to compile the kernel?

    Thanks!

    Arm-eabi 4.4 / 4.6 to until JB 4.2
    Arm-eabi 4.6 for mtk KK 4.4.2
    arm-eabi 4.7 for mtk KK 4.4.4
    arm-eabi 4.8 for mtk LL 5.0/ 5.1

    You can use whatever toolchain, but depending on your source / platform core OS, you may need to fix the source to work with higher toolchains.

    The ones i mention are the recommended for The OS versions

    Linaro toolchains, will also need some work, depending on your OS version / source

    cheers
    4
    @abiolakunle
    You're getting error because
    You're dividing somthing by zero
    3
    @MasterAwesome this went a little bit over my head....:confused:

    i understood till making zimage,,,,,after that how to make it a boot img...:confused:

    After compiling the zImage, move it to your device tree in your source code. under a folder called prebuilts. Look at my git repo for more reference a210_device_tree. As i said add a flag in the BoardConfig.mk
    Code:
    TARGET_PREBUILT_KERNEL:=sourcetokernel
    . then, we use the the PRODUCT_COPY_FILES to copy the kernel specific files. since modules are kernel specific you'd have to use the modules you built or you'll get a boot loop.