[Tutorial] How to compile a kernel

Search This thread

djjonastybe

Senior Member
Sep 27, 2010
686
346
Tienen
If you see mistakes please contact me. If you think something can be shorter, easier, feel free to suggest.

I have spent a lot of time figuring this out. Not to mention making this guide.


If this guide helped you feel free to donate.

There is more to come, using different toolchains, important files, adding overclocking etc.

Coming soon
- Links to useful mods: deep idle, live oc, BLN, ...
- How to compile a custom kernel: eg air kernel
- A list of useful files and folders in the downloaded kernel source


Setting up the environment & building the kernel for the first time
  1. Ubuntu 10.04 64-Bit (recommended)
    Ubuntu 12.04 64-Bit

    Note that you cannot compile AOSP ROMs with Ubuntu 12.04. Ubuntu 12.04 is fine for kernels.

    If you want to use virtualization software, do not use Virtualbox. You can run into networking issues and so on. I suggest using VMWare Player instead, which is available for free on http://www.vmware.com
  2. Installing latest updates & reboot.
    $ sudo apt-get update
    $ sudo apt-get dist-upgrade
    $ sudo reboot

  3. Now we will download and install the latest Java 6 JDK from here. Look for Java 6 SE Update 33 or a later update version. Don't download Java 7 JDK. I am downloading the file below for this guide.
    Linux x64 68.69 MB jdk-6u33-linux-x64.bin
    This guide assumes you have downloaded the file in the folder
    $ cd ~/Downloads
    $ sudo chmod +x jdk-6u33-linux-x64.bin
    $ ./jdk-6u33-linux-x64.bin
    $ sudo mv jdk1.6.0_33 /usr/lib/jvm/jdk1.6.0_33
    $ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_33/bin/javac 1
    $ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_33/bin/java 1
    $ sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_33/bin/javaws 1
    $ sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.6.0_33/bin/jar 1
    $ sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/lib/jvm/jdk1.6.0_33/bin/javadoc 1
    $ sudo update-alternatives --config javac
    $ sudo update-alternatives --config java
    $ sudo update-alternatives --config javaws
    $ sudo update-alternatives --config jar
    $ sudo update-alternatives --config javadoc
    $ java --version
    $ ls -la /etc/alternatives/java*
    Now reboot is optional but welcome. Let's play safe.

  4. Install all required packages to play with Android.
    Ubuntu 10.04
    $ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc

    Ubuntu 12.04
    $ sudo apt-get update
    $ sudo apt-get install git-core 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 openjdk-6-jdk tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 git
    $ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
    $ sudo reboot

  5. Configure USB ports.
    $ sudo gedit /etc/udev/rules.d/51-android.rules
    This file should get the contents:
    # 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>"
    # 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>"
    Don't forget to replace the red marked text with your username from Ubuntu.

  6. When building a kernel, you only need to start from here. Pick the appropriate branch from the git manually. I used the one below as an example. What I did was visiting the git repository each time and picked the appropriate branch.
    https://android.googlesource.com/device/samsung/crespo
    $ mkdir ~/Documents/kernel
    $ cd ~/Documents/kernel
    $ git clone https://android.googlesource.com/device/samsung/crespo -b ics-plus-aosp
    Again pick the right branch from https://android.googlesource.com/kernel/samsung.git
    $ cd crespo
    $ git clone https://android.googlesource.com/kernel/samsung.git -b android-samsung-3.0-ics-mr1

  7. Ensure the toolchain is in your path.
    • Default, Easy solution
      $ git clone https://android.googlesource.com/platform/prebuilt -b ics-plus-aosp
      $ export PATH=$(pwd)/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:$PATH
      $(pwd) is a variable holding the current working directory.
    • Bandwidth-friendly solution
      You can also download the toolchain to another directory. Bit first write down the directory you are working at.
      mkdir ~/Documents/toolchain
      cd ~/Documents/toolchain
      $ git clone https://android.googlesource.com/platform/prebuilt -b ics-plus-aosp
      export PATH=~/Documents/toolchain/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:$PATH
      Instead of specifying the location of the toolchain with a relative path, we must specify the absolute path here.

      Now we go back to where we were working.
      cd ~/Documents/kernel/crespo
      I hope you understand why I mentioned the bandwidth-friendly solution. With little insight you could have come up with it yourself.
  8. Now let's build the kernel
    $ export ARCH=arm
    $ export SUBARCH=arm
    $ export CROSS_COMPILE=arm-eabi-
    $ cd samsung
    $ make ARCH=arm herring_defconfig (maybe ARCH=arm is unneeded here but added it to be sure)
    $ make


    [*]Now you need to put it in a flashable zip.


Possible issues, things to avoid, FAQ
- Avoid downloading the kernel sources to directories which might require root/superuser access. This is one of the reasons I downloaded all sources to '~/Documents'. This will save a lot of time messing with chmod or chown commands.
- What is 'herring', shouldn't this be crespo? No, actually not. Herring is the board name, while crespo is the codename of the Nexus S. Something you might want to remember when building kernels.


Interesting files and locations
  • <kernel_directory>/samsung/arch/arm/mach-s5pv210/cpu-freq.c
    Overclocking
    Voltages


Links to mods, source code, ...
I am making the patch files currently
 
Last edited:

boog

Inactive Recognized Developer
May 15, 2008
1,154
583
Trenton, Ohio


$ export ARCH=arm
$ export SUBARCH=arm
$ export CROSS_COMPILE=arm-eabi-
$ cd omap
$ git checkout <commit_from_first_step> What to put here???
$ make panda_defconfig
$ make


You should have everything now ready to compile the aosp kernel

My method is:

$cd /path/to/kernel/source

$export ARCH=arm
$export CROSS_COMPILE=arm-eabi-
$export PATH=$PATH:~/path/to/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin
$make herring_defconfig
$make

Just change the '/path/to' to match yours :) You can also make it a script.

The checkout command I don't use (but I do have all of the aosp source and 'set the environment' first '. build/envsetup.sh && lunch full_crespo-userdebug'). You can clone from git and it will all be in the folder you cloned in. To pull the latest, just use 'git pull'.

Hope that helps.
 
Last edited:

boog

Inactive Recognized Developer
May 15, 2008
1,154
583
Trenton, Ohio
How do you use linaro toolchain?

I haven't used it, but theoretically you could export the path to the linaro tool chain instead of Google's gcc.

I have heard (have not confirmed) that there could be issues that may be introduced by using a different tool chain.

Sent from my Nexus S using xda app-developers app
 

djjonastybe

Senior Member
Sep 27, 2010
686
346
Tienen
Now I need this:

$ make ARCH=arm CROSS_COMPILE=arm-eabi- -j4
scripts/kconfig/conf --silentoldconfig Kconfig

*** Error during update of the configuration.

make[2]: *** [silentoldconfig] Error 1
make[1]: *** [silentoldconfig] Error 2
make: *** No rule to make target `include/config/auto.conf', needed by `include/config/kernel.release'. Stop.
 
Last edited:

snandlal

Senior Member
Apr 14, 2010
1,954
470
I haven't used it, but theoretically you could export the path to the linaro tool chain instead of Google's gcc.

I have heard (have not confirmed) that there could be issues that may be introduced by using a different tool chain.

Sent from my Nexus S using xda app-developers app


Cool, thanx
 

boog

Inactive Recognized Developer
May 15, 2008
1,154
583
Trenton, Ohio

Interesting....Sounds like it is maybe missing the files. I went back and reread your original instructions and instead of


try

Leave off the sudo, you don't need it for doing things in your own home directory, you'll end up with a bunch of files that belong to root.
 
  • Like
Reactions: Reptilez_DK

djjonastybe

Senior Member
Sep 27, 2010
686
346
Tienen
Interesting....Sounds like it is maybe missing the files. I went back and reread your original instructions and instead of



try


Leave off the sudo, you don't need it for doing things in your own home directory, you'll end up with a bunch of files that belong to root.

I think you are giving me wrong instructions? You mixed things up I think ;)

I also noticed that gcc was not found because it had the wrong permissions. 'chmod 755 *' fixed it.

I am now trying again. I made a mistake.
 
Last edited:

boog

Inactive Recognized Developer
May 15, 2008
1,154
583
Trenton, Ohio
I think you are giving me wrong instructions? You mixed things up I think ;)

I also noticed that gcc was not found because it had the wrong permissions. 'chmod 755 *' fixed it.

I am now trying again. I made a mistake.

Ahh, ok, then it was probably due to checking out as sudo. Not trying to give wrong instructions. Just trying to help.

If you had to chmod them, it was possibly because the files might have belonged to root instead of your user, I didn't think of that.

I think the guide should help people get started tinkering with kernels :)
 
  • Like
Reactions: Oodie

djjonastybe

Senior Member
Sep 27, 2010
686
346
Tienen
Ahh, ok, then it was probably due to checking out as sudo. Not trying to give wrong instructions. Just trying to help.

If you had to chmod them, it was possibly because the files might have belonged to root instead of your user, I didn't think of that.

I think the guide should help people get started tinkering with kernels :)

I really hope this too. I have been willing to do this since October 2011, but never got to it because I always thought it would be too difficult. Now I spent 3-4 days figuring everything out, with your help.

I still have few things on my list like adding a tutorial here on how to rename the kernel, and links to specific mods like Ezekeel's mods.
 

Oodie

Inactive Recognized Developer
May 6, 2011
1,680
1,940
Kuliyapitiya
I'm gonna try this . will trouble you a lot i guess . lol . this would be hard with my ****ty internet connection . ( i won't ever be able to compile AOSP , becuase of the large file size to be downloaded )
Now i'm @ the start of the guide .

apt-get update - done

apt-get dist-upgrade - returned some errors so ,
apt-get -f dist-upgrade - running ...


many thanks for the OP , to this tutorial . It's a must needed . & I think other experienced devs should also help out this thread .
 

boog

Inactive Recognized Developer
May 15, 2008
1,154
583
Trenton, Ohio
I'm gonna try this . will trouble you a lot i guess . lol . this would be hard with my ****ty internet connection . ( i won't ever be able to compile AOSP , becuase of the large file size to be downloaded )
Now i'm @ the start of the guide .



apt-get dist-upgrade - returned some errors so ,



many thanks for the OP , to this tutorial . It's a must needed . & I think other experienced devs should also help out this thread .

Being updated isn't a bad thing, but if your already on 12.04, it could be possible to just:
sudo apt-get update

sudo apt-get upgrade
That should have you updated to the latest updates for 12.04.

Doing a dist-upgrade can upgrade you to the next version of ubuntu (not released yet). But could on the next release.
 

Oodie

Inactive Recognized Developer
May 6, 2011
1,680
1,940
Kuliyapitiya
Being updated isn't a bad thing, but if your already on 12.04, it could be possible to just:

That should have you updated to the latest updates for 12.04.

Doing a dist-upgrade can upgrade you to the next version of ubuntu (not released yet). But could on the next release.

oops . will it do any harm if i dist-upgrade ? :eek:
 

djjonastybe

Senior Member
Sep 27, 2010
686
346
Tienen
oops . will it do any harm if i dist-upgrade ? :eek:

http://techhamlet.com/2012/02/ubuntu-whats-the-difference-between-upgrade-and-dist-upgrade/

Google it: upgrade vs dist-upgrade

upgrade only updates the packages already installed.
I believe apt-get upgrade is equal to the update manager of ubuntu. If you use the GUI to update. Correct me if I am wrong

I believe dist-upgrade also handles the dependencies.
http://en.wikipedia.org/wiki/Advanced_Packaging_Tool

I have always preferred dist-upgrade.

Oodie if you get errors during dist-upgrade try reinstalling your ubuntu. Maybe you want to start fresh. I started a clean Virtual Box virtual machine.
dist-upgrade has never given me errors. :D

How old is your installation ?
 
  • Like
Reactions: Oodie

boog

Inactive Recognized Developer
May 15, 2008
1,154
583
Trenton, Ohio
http://techhamlet.com/2012/02/ubuntu-whats-the-difference-between-upgrade-and-dist-upgrade/

Google it: upgrade vs dist-upgrade

upgrade only updates the packages already installed.
I believe apt-get upgrade is equal to the update manager of ubuntu. If you use the GUI to update. Correct me if I am wrong

I believe dist-upgrade also handles the dependencies.
http://en.wikipedia.org/wiki/Advanced_Packaging_Tool

I have always preferred dist-upgrade.

Oodie if you get errors during dist-upgrade try reinstalling your ubuntu. Maybe you want to start fresh. I started a clean Virtual Box virtual machine.
dist-upgrade has never given me errors. :D

How old is your installation ?

You are correct. For some reason I had it in my head as an update to the next release.

Sent from my Nexus S using xda app-developers app
 

Oodie

Inactive Recognized Developer
May 6, 2011
1,680
1,940
Kuliyapitiya
I'm stuck on kernel source downloading ( user / kernel folder ) .
Download interrupted 3 times now :(
Can't we share a completed kernel folder or something?

I hate my internet connection.

°°° This comment is Sent from my Nexus S °°°
 

djjonastybe

Senior Member
Sep 27, 2010
686
346
Tienen
I'm stuck on kernel source downloading ( user / kernel folder ) .
Download interrupted 3 times now :(
Can't we share a completed kernel folder or something?

I hate my internet connection.

°°° This comment is Sent from my Nexus S °°°
Have you tried connecting it with a ethernet cable to the modem? I have a good connection but cable seems to be always 100% safe.

sudo sysctl -w net.ipv4.tcp_window_scaling=0

Maybe this tweak helps you. But I suggest shutting down as much programs as you can. And other computers. And if you can connect it directly to the modem/router with a ethernet cable.

Or keep trying. In the end it should be complete.

Also try a retail installation of Ubuntu instead of using a virtual machine this has helped me here.

EDIT: Updated first post with more kernel fun.
 
Last edited:
  • Like
Reactions: Oodie

djjonastybe

Senior Member
Sep 27, 2010
686
346
Tienen
ok . the first branch finished successfully :angel: ( finally )
( Now there is files in the kernel / crespo folder )

Now running the second branch .
Told you :D

Oodie I changed something in my guide.

$ sudo update-alternatives --config javac
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javaws
Make sure you run these to see if you are using the right JDK. By default the OpenJDK is still used. Just discovered it.
 
  • Like
Reactions: Oodie

Top Liked Posts

  • There are no posts matching your filters.
  • 20
    If you see mistakes please contact me. If you think something can be shorter, easier, feel free to suggest.

    I have spent a lot of time figuring this out. Not to mention making this guide.


    If this guide helped you feel free to donate.

    There is more to come, using different toolchains, important files, adding overclocking etc.

    Coming soon
    - Links to useful mods: deep idle, live oc, BLN, ...
    - How to compile a custom kernel: eg air kernel
    - A list of useful files and folders in the downloaded kernel source


    Setting up the environment & building the kernel for the first time
    1. Ubuntu 10.04 64-Bit (recommended)
      Ubuntu 12.04 64-Bit

      Note that you cannot compile AOSP ROMs with Ubuntu 12.04. Ubuntu 12.04 is fine for kernels.

      If you want to use virtualization software, do not use Virtualbox. You can run into networking issues and so on. I suggest using VMWare Player instead, which is available for free on http://www.vmware.com
    2. Installing latest updates & reboot.
      $ sudo apt-get update
      $ sudo apt-get dist-upgrade
      $ sudo reboot

    3. Now we will download and install the latest Java 6 JDK from here. Look for Java 6 SE Update 33 or a later update version. Don't download Java 7 JDK. I am downloading the file below for this guide.
      Linux x64 68.69 MB jdk-6u33-linux-x64.bin
      This guide assumes you have downloaded the file in the folder
      $ cd ~/Downloads
      $ sudo chmod +x jdk-6u33-linux-x64.bin
      $ ./jdk-6u33-linux-x64.bin
      $ sudo mv jdk1.6.0_33 /usr/lib/jvm/jdk1.6.0_33
      $ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_33/bin/javac 1
      $ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_33/bin/java 1
      $ sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_33/bin/javaws 1
      $ sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.6.0_33/bin/jar 1
      $ sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/lib/jvm/jdk1.6.0_33/bin/javadoc 1
      $ sudo update-alternatives --config javac
      $ sudo update-alternatives --config java
      $ sudo update-alternatives --config javaws
      $ sudo update-alternatives --config jar
      $ sudo update-alternatives --config javadoc
      $ java --version
      $ ls -la /etc/alternatives/java*
      Now reboot is optional but welcome. Let's play safe.

    4. Install all required packages to play with Android.
      Ubuntu 10.04
      $ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc

      Ubuntu 12.04
      $ sudo apt-get update
      $ sudo apt-get install git-core 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 openjdk-6-jdk tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 git
      $ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
      $ sudo reboot

    5. Configure USB ports.
      $ sudo gedit /etc/udev/rules.d/51-android.rules
      This file should get the contents:
      # 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>"
      # 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>"
      Don't forget to replace the red marked text with your username from Ubuntu.

    6. When building a kernel, you only need to start from here. Pick the appropriate branch from the git manually. I used the one below as an example. What I did was visiting the git repository each time and picked the appropriate branch.
      https://android.googlesource.com/device/samsung/crespo
      $ mkdir ~/Documents/kernel
      $ cd ~/Documents/kernel
      $ git clone https://android.googlesource.com/device/samsung/crespo -b ics-plus-aosp
      Again pick the right branch from https://android.googlesource.com/kernel/samsung.git
      $ cd crespo
      $ git clone https://android.googlesource.com/kernel/samsung.git -b android-samsung-3.0-ics-mr1

    7. Ensure the toolchain is in your path.
      • Default, Easy solution
        $ git clone https://android.googlesource.com/platform/prebuilt -b ics-plus-aosp
        $ export PATH=$(pwd)/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:$PATH
        $(pwd) is a variable holding the current working directory.
      • Bandwidth-friendly solution
        You can also download the toolchain to another directory. Bit first write down the directory you are working at.
        mkdir ~/Documents/toolchain
        cd ~/Documents/toolchain
        $ git clone https://android.googlesource.com/platform/prebuilt -b ics-plus-aosp
        export PATH=~/Documents/toolchain/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:$PATH
        Instead of specifying the location of the toolchain with a relative path, we must specify the absolute path here.

        Now we go back to where we were working.
        cd ~/Documents/kernel/crespo
        I hope you understand why I mentioned the bandwidth-friendly solution. With little insight you could have come up with it yourself.
    8. Now let's build the kernel
      $ export ARCH=arm
      $ export SUBARCH=arm
      $ export CROSS_COMPILE=arm-eabi-
      $ cd samsung
      $ make ARCH=arm herring_defconfig (maybe ARCH=arm is unneeded here but added it to be sure)
      $ make


      [*]Now you need to put it in a flashable zip.


    Possible issues, things to avoid, FAQ
    - Avoid downloading the kernel sources to directories which might require root/superuser access. This is one of the reasons I downloaded all sources to '~/Documents'. This will save a lot of time messing with chmod or chown commands.
    - What is 'herring', shouldn't this be crespo? No, actually not. Herring is the board name, while crespo is the codename of the Nexus S. Something you might want to remember when building kernels.


    Interesting files and locations
    • <kernel_directory>/samsung/arch/arm/mach-s5pv210/cpu-freq.c
      Overclocking
      Voltages


    Links to mods, source code, ...
    I am making the patch files currently
    1

    Interesting....Sounds like it is maybe missing the files. I went back and reread your original instructions and instead of


    try

    Leave off the sudo, you don't need it for doing things in your own home directory, you'll end up with a bunch of files that belong to root.
    1
    I think you are giving me wrong instructions? You mixed things up I think ;)

    I also noticed that gcc was not found because it had the wrong permissions. 'chmod 755 *' fixed it.

    I am now trying again. I made a mistake.

    Ahh, ok, then it was probably due to checking out as sudo. Not trying to give wrong instructions. Just trying to help.

    If you had to chmod them, it was possibly because the files might have belonged to root instead of your user, I didn't think of that.

    I think the guide should help people get started tinkering with kernels :)
    1
    oops . will it do any harm if i dist-upgrade ? :eek:

    http://techhamlet.com/2012/02/ubuntu-whats-the-difference-between-upgrade-and-dist-upgrade/

    Google it: upgrade vs dist-upgrade

    upgrade only updates the packages already installed.
    I believe apt-get upgrade is equal to the update manager of ubuntu. If you use the GUI to update. Correct me if I am wrong

    I believe dist-upgrade also handles the dependencies.
    http://en.wikipedia.org/wiki/Advanced_Packaging_Tool

    I have always preferred dist-upgrade.

    Oodie if you get errors during dist-upgrade try reinstalling your ubuntu. Maybe you want to start fresh. I started a clean Virtual Box virtual machine.
    dist-upgrade has never given me errors. :D

    How old is your installation ?
    1
    I'm stuck on kernel source downloading ( user / kernel folder ) .
    Download interrupted 3 times now :(
    Can't we share a completed kernel folder or something?

    I hate my internet connection.

    °°° This comment is Sent from my Nexus S °°°
    Have you tried connecting it with a ethernet cable to the modem? I have a good connection but cable seems to be always 100% safe.

    sudo sysctl -w net.ipv4.tcp_window_scaling=0

    Maybe this tweak helps you. But I suggest shutting down as much programs as you can. And other computers. And if you can connect it directly to the modem/router with a ethernet cable.

    Or keep trying. In the end it should be complete.

    Also try a retail installation of Ubuntu instead of using a virtual machine this has helped me here.

    EDIT: Updated first post with more kernel fun.