- Oct 11, 2009
- 5,577
- 2,816
- 113
Right up front – there are a lot of ways to do this, and this is not the most efficient or the best way to get it done. It is the easiest way for someone not familiar with the process though.
1. Get Ubuntu 9.04
The tools needed to build the Linux kernel as used for Android are pretty specific version. Thankfully, they also happen to be the current version available if you're using Ubuntu 9.04. To make things easy, we will have to install Ubuntu. When all said and done, we will end up with a windows/Ubuntu 9.04/Ubuntu 9.10 triple boot computer.
Like I said, not the best way but it works well and is easy to set up and use.
Get your existing Windows installation ready. Use the tools included with Windows to defragment your hard drive(s). Open your web browser and go to Ubuntu 9.04 (Jaunty Jackalope) to download the Ubuntu installation CD. Unless you're sure you need the 64 bit version, just download the 32 bit version. Burn it to a CD using whatever program you're comfortable using to burn .iso images.
Install Ubuntu 9.04 on your computer. There's a bajillion tutorials on the web to walk you through this, but honestly there is little need for one. Installing Ubuntu is easier than installing Windows. Just be sure when you reach the point to set up your hard disks, you give Ubuntu 9.04 about 12 gigs of space. It's a very easy to understand slider, adjust it so the Ubuntu 9.04 uses 12 gigs and the rest is allocated without any changes. When you have it installed, reboot into Ubuntu and wait about 5 minutes. You'll get a notification that there are updates available, follow the wizard and install the updates. Be sure to reboot when finished. In the future ignore these update notifications. When Android requires any packages to get updated, you can install those packages then. Remember, this install is only to build the kernel.
2. Installing the extra software needed to build your kernel.
Ubuntu uses a package manager to install and remove sofware. This makes it pretty easy to install everything needed. Follow along here and you'll have all the required libraries and tools required to build the kernel.
Open the terminal (Ubuntu Main Menu → Accessories → Terminal) and type or paste this into it:
When asked for a password, enter the password you used to set up your login for Ubuntu. Ubuntu automagically places new users into a group that has permission to run programs as root, and to do so requires you to enter YOUR password
A quick breakdown of the above command -
This will fetch the required packages and install the closed source Java Dev. Kit ver 5 from Sun Micro. At a certain point during the installation, you'll have to accept the license from Sun. Read through it if you like, but the important thing to remember is that what we are using it for is approved and encouraged by Sun so there is no issue. Once you have java installed and set up, continue by entering the following into the same terminal window
this fetches all the other tools needed to build the kernel. We installed java separately because it requires user action (accepting the license) to install. Notice it's just like the command used to install java in the above step “sudo apt-get install **package name(s)**” We can do many at once here because it needs no user interaction.
When that is all finished you have the tools needed to build a Linux kernel. You don't have the tools to build a Linux kernel for an ARM processor though. That's the next step.
3. Installing the arm specific toolchain and Android source
This will install tools and source from Google. A lot of tools and source. A whole lot. There are ways around this step, but this is the proper way, and gives you everything you need to build AOSP for your phone for future use. Yes, after we all get building kernels down to an artform, we'll work on building our own OS from the ground up.
In your terminal, type the following (READ THIS SECTION BEFORE ACTUALLY DOING THIS)
What these steps mean -
Now for the big step – downloading all the tools and source from Google.
What's going on here -
A couple things – you'll notice commands that start with the tilde “~”. In Linux, this ALWAYS means your home folder. Since we moved into the myandroid directory, we have to use the whole path to the command we are running. ~/bin/repo simply means “home/*your-user-name*/bin/repo”. You can use the tilde to start the path for any command from your home folder, and in Linux terminal work, you will be using it a lot.
This step takes about forever and a day. You're downloading about 1.7 gigabytes of data, and often times the android git repo is hammered for bandwidth. You're pretty lucky to get speeds over 900kb/s or so. You can safely start the download and walk away for a while. As long as nobody comes by and shuts down your terminal you can pick back up when it's finished. I usually run this command and give it at least an hour, sometimes overnight. Just be sure not to interfere with it.
1. Get Ubuntu 9.04
The tools needed to build the Linux kernel as used for Android are pretty specific version. Thankfully, they also happen to be the current version available if you're using Ubuntu 9.04. To make things easy, we will have to install Ubuntu. When all said and done, we will end up with a windows/Ubuntu 9.04/Ubuntu 9.10 triple boot computer.
Like I said, not the best way but it works well and is easy to set up and use.
Get your existing Windows installation ready. Use the tools included with Windows to defragment your hard drive(s). Open your web browser and go to Ubuntu 9.04 (Jaunty Jackalope) to download the Ubuntu installation CD. Unless you're sure you need the 64 bit version, just download the 32 bit version. Burn it to a CD using whatever program you're comfortable using to burn .iso images.
Install Ubuntu 9.04 on your computer. There's a bajillion tutorials on the web to walk you through this, but honestly there is little need for one. Installing Ubuntu is easier than installing Windows. Just be sure when you reach the point to set up your hard disks, you give Ubuntu 9.04 about 12 gigs of space. It's a very easy to understand slider, adjust it so the Ubuntu 9.04 uses 12 gigs and the rest is allocated without any changes. When you have it installed, reboot into Ubuntu and wait about 5 minutes. You'll get a notification that there are updates available, follow the wizard and install the updates. Be sure to reboot when finished. In the future ignore these update notifications. When Android requires any packages to get updated, you can install those packages then. Remember, this install is only to build the kernel.
Q. - Why use an old version of Ubuntu, and why not keep it up to date?
A. - As I said earlier, Android requires the kernel be built with a very specific version of the tools used. These aren't necessarily the latest or best version of those tools, but they are the right ones for Android's kernel. Hopefully later versions of the kernel source will be updated to work with a better toolchain, but for now – it is what it is. It's actually pretty common to have to use a specific version of software to build from source
2. Installing the extra software needed to build your kernel.
Ubuntu uses a package manager to install and remove sofware. This makes it pretty easy to install everything needed. Follow along here and you'll have all the required libraries and tools required to build the kernel.
Open the terminal (Ubuntu Main Menu → Accessories → Terminal) and type or paste this into it:
Code:
sudo apt-get install sun-java5-jdk
When asked for a password, enter the password you used to set up your login for Ubuntu. Ubuntu automagically places new users into a group that has permission to run programs as root, and to do so requires you to enter YOUR password
A quick breakdown of the above command -
sudo
The first portion of the command is short for “switch user do-it”. It's an old BSD command that allows an approved user (you are an approved user – see above) to run a command as root.
apt-get install
“apt-get” is the terminal command to start the package manager. It requires an option so it knows what to do when it starts. To see all these options, enter apt-get –help in your terminal. “install” is the option to tell apt-get to download and install the named package(s).
sun-java5-jdk
This is the name of the package you want to install through apt.
This will fetch the required packages and install the closed source Java Dev. Kit ver 5 from Sun Micro. At a certain point during the installation, you'll have to accept the license from Sun. Read through it if you like, but the important thing to remember is that what we are using it for is approved and encouraged by Sun so there is no issue. Once you have java installed and set up, continue by entering the following into the same terminal window
Code:
sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev valgrind
this fetches all the other tools needed to build the kernel. We installed java separately because it requires user action (accepting the license) to install. Notice it's just like the command used to install java in the above step “sudo apt-get install **package name(s)**” We can do many at once here because it needs no user interaction.
When that is all finished you have the tools needed to build a Linux kernel. You don't have the tools to build a Linux kernel for an ARM processor though. That's the next step.
3. Installing the arm specific toolchain and Android source
This will install tools and source from Google. A lot of tools and source. A whole lot. There are ways around this step, but this is the proper way, and gives you everything you need to build AOSP for your phone for future use. Yes, after we all get building kernels down to an artform, we'll work on building our own OS from the ground up.
In your terminal, type the following (READ THIS SECTION BEFORE ACTUALLY DOING THIS)
Code:
cd /home/*your-user-name
mkdir myandroid
mkdir bin
curl http://android.git.kernel.org/repo > ~/bin/repo
chmod a+x ~/bin/repo
What these steps mean -
- Change to your home directory. In Linux, your home directory is yours and yours alone. You have permission and control over everything in your directory.
- Create a new directory and name it myandroid. You could name it anything you want, but almost every tutorial and FAQ from Google uses the name “myandroid” so we're going to use it as well.
- Create another new directory named bin. Having a “bin” (short for binary) directory in your home folder is a common practice. This will hold programs that you use and install yourself, and not system programs.
- Use the program “curl” to get a copy of the Android repository script (the list of thing to download) direct from Android's GIT repository and place it in your “bin” directory we just made. Curl is a popular program to download text over the internet, and GIT is a standard code hosting program that Android uses to keep track of their versions.
- Use the Linux command “chmod” (short for change mode) to make the script we download readable by all (a) and executable (x)
Now for the big step – downloading all the tools and source from Google.
Code:
cd ~/myandroid
~/bin/repo init -u git://android.git.kernel.org/platform/manifest.git
~/bin/repo sync
What's going on here -
- Change to your myandroid directory FAILURE TO DO THIS STEP WILL TRASH YOUR WHOLE HOME FOLDER
- use the repo script we downloaded to find the source tree from Google, and create a list for downloading it all
- syncronize your local copy of the source code tree with Google's copy.
A couple things – you'll notice commands that start with the tilde “~”. In Linux, this ALWAYS means your home folder. Since we moved into the myandroid directory, we have to use the whole path to the command we are running. ~/bin/repo simply means “home/*your-user-name*/bin/repo”. You can use the tilde to start the path for any command from your home folder, and in Linux terminal work, you will be using it a lot.
This step takes about forever and a day. You're downloading about 1.7 gigabytes of data, and often times the android git repo is hammered for bandwidth. You're pretty lucky to get speeds over 900kb/s or so. You can safely start the download and walk away for a while. As long as nobody comes by and shuts down your terminal you can pick back up when it's finished. I usually run this command and give it at least an hour, sometimes overnight. Just be sure not to interfere with it.
Last edited: