Results 1 to 2 of 2

Thread: [HowTo] Cross-Compiling the Android-kernel

777
  1. [translate]    #1
    Senior Member
    Join Date
    May 2010
    Location
    /dev/null
    Posts
    1,704

    Default [HowTo] Cross-Compiling the Android-kernel

    I created this topic in order to improve our spica ...

    ... I know that we haven't much real kernel-developer here but we have motivated people with some basic linux / C / C++ know-how and to make the first steps simpler I post this tutorial to explain the compilation of the kernel.

    First step: install linux + cross compiler
    you have to install Linux first (e.g. Ubuntu, Debian ...) but you can also install this as a virtual PC e.g. with VirtualBox. Now open a Terminal and install this software ->
    Code:
    sudo apt-get install build-essential git gcc-4.5-arm-linux-gnueabi wget libncurses5-dev
    PS: you can also try gcc-4.6 (info) if you add this to your repository (/etc/apt/sources.list) -> *only tested with debian sid*
    Code:
    deb http://www.emdebian.org/debian/ unstable main
    or you can build your own cross-compiler -> HowTo

    2nd step: download the source
    in this example I show you how to get my sources for Kernel 2.6.29.6. Open a Terminal again and type this ->
    Code:
    mkdir -p ~/spica/voku-kernel/
    cd ~/spica/voku-kernel/
    git clone https://github.com/voku/i5700-sm-kernel.git
    mv i5700-sm-kernel/ kernel/
    git clone https://github.com/voku/i5700-sm-froyo-initramfs.git
    mv i5700-sm-froyo-initramfs/ initramfs/
    git clone https://github.com/voku/i5700-sm-kmodules2.git
    mv i5700-sm-kmodules2/ modules/
    PS: "~" (tilde) the home directory (normally the directory /home/my_login_name). (info)

    Step 4: change the config / your path to the files

    Step 4.1: the "config"-file: .config
    Every kernel version comes with a "default" kernel configuration. This configuration is loosely based on the defaults that the kernel maintainer of that architecture feels are the best options to be used. and you will find different config-files here (~/spica/voku-kernel/kernel/arch/arm/configs/...) for the first time you maybe can try my config file
    Code:
    cd ~/spica/voku-kernel/kernel/
    wget http://www.suckup.de/spica_config.txt
    mv spica_config.txt .config
    if you try different directory-names for the initramfs you have to change ths path e.g.:
    Code:
    CONFIG_INITRAMFS_SOURCE="~/spica/i5700-initramfs-froyo-2.6.29.6/"
    if you will change 16bpp to 24bpp change this
    e.g.:
    Code:
    CONFIG_FB_S3C_BPP_16=y
    to
    Code:
    CONFIG_FB_S3C_BPP_24=y
    Step 4.2: the "Makefile":
    A makefile specifies a set of compilation rules in terms of targets (such as executables) and their dependencies (such as object files and source files) e.g. if you try gcc 4.5 you have to change -Ofast to -O2 or -O3 in this file. Maybe you have also change the "CROSS_COMPILE"-variable with the path to your installed cross-compiler. (info & info)
    e.g.:
    Code:
    CROSS_COMPILE := /usr/bin/arm-linux-gnueabi-
    Step 4.3: initrd.arm.initramfs_list
    You have also to change the path in this file e.g.:
    Code:
    sed -i '/\/home\/lars\/spica\/new_kernel\/initramfs/\/home\/USER-NAME\/spica\/voku-kernel\/initramfs/g' ~/spica/voku-kernel/initramfs/initrd.arm.initramfs_list
    Step 4.4: the "init.rc"-file
    Here you can add e.g. the version-number etc. ->
    Code:
    cat ~/spica/voku-kernel/initramfs/init.rc | grep build.display.id
    setprop ro.build.display.id "VOKU-kernel v1.5"
    Step 5: start compiling
    Now we can finally start compilation. try "make -j2" or "make -j4" ... if you only want to compile the kernel with the files from initramfs! If you also will compile the modules try the "./build_kernel.sh"-script in the kernel-directory.

    Step 6: make a zip-file for recovery
    Once finished compiling your kernel you will find in:
    Code:
    ~/spica/voku-kernel/kernel/arch/arm/boot/zImage
    the easiest way is to download e.g. my last kernel-version 1.5B and replace the file in the "/xbin"-directory with you own kernel

    ... this is only a example you can choose different sources on github.

    Step 6: use github!
    I also have a very low upload BUT you only upload modified sources the other files will be used from a fork so you don't upload all files only the files you touched...

    Step 6.1: fork sources
    e.g.: gotenks I5700-kernel -> simply press the fork button on github Help.GitHub - Fork A Repo

    Step 6.2: get your new fork sources
    e.g.:
    Code:
    git clone https://github.com/voku1987/I5700-kernel-2.6.32.9.git
    (replace voku1987 with our username)

    Step 6.3: committing your changes
    Now edit the sources and committing this -> Help.GitHub - Git cheat sheets
    Code:
    git commit -a
    and upload only your modified files (also with low upload)

    Code:
    git push
    PS: to update the sources try this ->
    Code:
    git pull
    to add new files try this ->
    Code:
    git add new_file.c
    or
    Code:
    git add --all
    ---------------------

    I hope this tutorial can help someone and please, if you find any mistakes report it ...
    Last edited by voku1987; 05-24-2011 at 02:36 AM.

  2. [translate]    #2
    Senior Member
    Join Date
    Jun 2010
    Location
    Portugal
    Posts
    789

    Default

    Thank you very much for sharing! Just a suggestion: maybe you could place it at Samdroid wiki

    We now just need a tutorial for compiling ROMs :P
    Creator of apKitchen -> apkitchen.pt.vu

    Android App here

    CM+X 14.2

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •