Sunday, December 11, 2011

OhHeyItsLou Custom Android Kernel Guide



  • Packages to install in Fedora

sudo yum -y install gcc ncurses-devel

  • Packages to install in Ubuntu or Debian

sudo apt-get install -y build-essential kernel-package libncurses5-dev bzip2

  • Prepare your kernel source for compilation:

make clean && make mrproper
*You must be within your kernel source directory when executing this command.

  • Pull config from device as a starting point:

*Your default doncifg is located in your kernel source directory in /arch/arm/configs/yourdevice_defconfig

  • Execute the command:

make yourdevice_defconfig

  • Or if you have the Android SDK installed you can get your config by executing the following:

adb pull /proc/config.gz
gunzip config.gz

*This requires that the Android SDK be installed.  Please see my Android SDK installation and set up videos for more information.

  • Point the "Makefile" to the compilation tools:

export CROSS_COMPILE=/home/rizzo/ndk/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/arm-eabi-

*This is the path for the location where you have the Android NDK stored.  All you have to do is replace the beginning of the above path "/home/rizzo/ndk/" to your location, the rest of the path stays the same.

*Or you can edit the cross_compile flag in the "Makefile"

  • Edit "Makefile" to add a name to your custom kernel:

*Search for "Extraversion" at the top of the "Makefile" now add your own custom name with no spaces or capital letters name cannot exceed 64 characters use “-” to separate your words there cannot be empty spaces separating characters.

  • Move the config you pulled from your device into your kernel source directory and rename it to ".config":

  • Apply any kernel patches ie. BFS, BFQ etc:

patch -p1 < yourpatch.patch

  • Further configure your kernel if so desired:

make menuconfig

*Load the config you pulled from you device in the above step by using the “Load an Alternate Configuration File” option.

  • Execute compile command:

make -j5 ARCH=arm

*Using the "-J" flag optimizes the compilation process for the number of cores your host system has. The general rule of thumb is to add "1" to the number of cores on your host system in my case I have a quad core system so I would use -J5.

  • Kernel & Wifi module locations after compilation:

/arch/arm/boot/zImage
/drivers/net/wireless/bcm4329_204/bcm4329.ko

  • Installation:

With an archive manager open "AnyKernel.zip" and place "zImage" in the "kernel" directory then place your wifi module "bcm4329.ko" in the "/system/lib/modules" directory.

Take special precautions not to unzip the AnyKernel tool in doing so you will break the signing of the package and your recovery will not allow you to flash your new kernel!

Place your custom kernel .zip on the root of your SD card and flash in recovery just as you would a Rom. Wiping your dalvik cache is recommended before installing your kernel.  This kernel can also be shared and installed with other individuals with the SAME device.


Please note this guide is meant to accompany the corresponding YouTube video which goes into much greater detail of the Android kernel compilation process.

*Android NDK,r5c used for demonstration*

31 comments:

  1. i followed ur tutorial and everything went fine thanx for ur wonderful tutorial but i have a doubt please clear it i added extra i/o and cpu schedulers to the source and did make menuconfig but couldn't c them in the window wat should i do??? i created the object in d make file too of the respective folder

    ReplyDelete
  2. to download Android r5c NDK
    http://dl.google.com/android/ndk/android-ndk-r5c-linux-x86.tar.bz2

    ReplyDelete
  3. Your links are broken... Is the AnyKernel tool the same thing as getting the file from Koush's GitHub?

    ReplyDelete
  4. Replies
    1. plase post link for any kernel..!!!
      i used any kernel master from github but it did not work for me.

      Delete
  5. I'm having trouble I installed the package then tried 'make claen && mrproper' but get 'make: *** No rule to make target 'clean'. Stop.' i've tried ./configure and installing make??

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. HELLO SIR after linking my kernel source to linux ...i wrote a command "cd linux" but i am getting error like "cd :linux :not a directory" plz help me
    iam using ubuntu

    ReplyDelete
    Replies
    1. Start over and ignore that part when he adds a symbolic link.

      Delete
  8. hello world...
    i got a problem here. where can i find anykernel zip file that used by 'heyitslou' in his vid? the anykernel that i've found didn't work. i'm using koushanykernel here https://github.com/koush/AnyKernel

    ReplyDelete
  9. Touchscreen module.

    Hello.
    I have a problem. I found this "source code" :
    https://github.com/vurrut/android_ke...ockchip_rk2918
    or here
    https://github.com/yatto/Smartpad-810c-Kernel-3.0.8

    But does not contain the "source code" of the module touch my tablet .

    How do I add it to the compilation?

    I have compiled the module apart and also I have the "source code".

    Thank

    ReplyDelete
  10. can you post anykernel.zip used in this tutorial download link. tks

    ReplyDelete
  11. export CROSS_COMPILE .... command gives me the following error... please help..

    /home/mamatha/androidkernelsources/linux/drivers/gud/mobicore_driver/platforms: No such file or directory

    under my drivers/gud folder I only have Kconfig and Makefile files...

    Thanks in advance

    ReplyDelete
  12. Thanks LUO!!! Totally made my day!!!!

    ReplyDelete
    Replies
    1. I ended up using the config in configs, some_defconfig, and edited it to how I saw fit, then I built it with the rest of my rom, I hope the changes get included the way I think they would.

      Delete
  13. need any kernel ..!! i am trying for samsung 5830i..!!!

    ReplyDelete
  14. hi...i have download ndk package, when i type the command (make clean && make mrpropper) and (make -j5 ARCH=arm) ,then the output was (arm-eabi-gcc: not found) .... then i see in the ndk --->toolchains is found the (arm-linux-androideabi-gcc) and not the (arm-eabi-gcc).... please help?

    ReplyDelete
  15. How can i modify the kernel of android in the source code , and what are the possible modification ??
    please help me as soon as possible

    ReplyDelete
    Replies
    1. You can modify for exemple the tcp protocol ,to MPTCP multiplpath tcp the code is free on internet.

      Delete
  16. can you make a kernel 3.4 for my lenovo s560 smartphone?

    ReplyDelete
  17. Can't create a Symlink... When I try I get this information...

    In: Command not found

    How to fix it?

    ReplyDelete
  18. how to build custom kernel with swap support for mtk 6577 karbonn a30 with windows 7

    ReplyDelete
  19. drivers/misc/mediatek/video/mt6592/mtkfb.c:54:24: fatal error: mach/fbcon.h: No such file or directory

    this error is always coming when i am trying to compile the kernel. my phone model is lgh540d. plz help me.

    ReplyDelete
  20. Hi all!, Would you mind giving me some pointers about Lineage OS porting to a new device? My mate 8 is not supported in guthub (cant get device tree and stuff) BUT huawei released the open source for my device. I downloaded to my computer, its .tar file, when I extract it I end up with 3 folders, 1 External, 2 Kernel & 3Vendor, where do I go from there, what can I do with those? please shine a light on me, I m determined on getting AOSP based ROM on my device, thanks a lot!

    ReplyDelete
  21. hi sir i need your help plesse help me
    sir how to port kernel source /example-mt6580 3.18.35 kernel source in availabe github/my device is mt6580 3.18.19
    how to update mt6580 3.18.19 to mt6580 3.18.35
    i can port mt6580 3.18.35 kernel source for my device is mt6580 3.18.19

    ReplyDelete
  22. Is it possible to change display drivers in android devices?

    ReplyDelete