Archive for June 2009

Contribute to Android – My repo/git adventure

Note (29 july 2009): found out that the merge action is generating a empty change commit (which depends on change 9828 and is needed by my change). I started a discussion at http://groups.google.com/group/repo-discuss/browse_thread/thread/c9c29d4eca6c7989 and got a response that I should use git reset. Updated this post to reflect the new procedure

While I am still working on some blogpost about flashing the Android Dev Phone and adding the Google Apps, I was wondering if I can easily contribute some changes to the Android source tree. In my blog about getting the Android Source, I applied a patch and edit the extract-files.sh and AndroidBoard.mk inside vendor/htc/dream by hand so that all proprietary used for the HTC Dream are extracted from an ADP and added to your own Android system image. But wouldn’t it be nice when you just apply one patch and do not have to edit the files by hand. This is where the journey begins.

In the beginning…

Before making the changes to both scripts I started with a clean local source tree. I got the source (android-1.5r2 as described here) together with the specific htc vendor parts (by using the local_manifest.xml). After repo sync is finished, it is time to perform the changes which will result in a new patch.

When repo was asking for my name and emailaddress, I used my gmail account. If you don’t use a gmail account you cannot post changes to the source tree.

Patch 9828

I knew that change 9828 already updates the two script files (but there are still parts missing). I decided to apply this patch to my local source tree with the idea that it will be an extension on this patch

repo download platform/vendor/htc/dream 9828

Because I want to make an extension on this patch I should make a local branch first containing this change which can be later merged to the developer branch which will contain the additions to both script. So you can skip this step if your change does not depend on another patch.

git checkout -b branch9828

This will make a local branch called branch9828

Contribute steps

Updating 2c2e915..b15e33c
Fast forward
AndroidBoard.mk  |   12 ++++++++++++
extract-files.sh |   14 ++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)
mode change 100755 => 100644 extract-files.sh

At http://source.android.com/submit-patches is described how to submit patches. I used these steps as my guide in the repo/git adventure. But like an outdated tourist guide book I found some rocks on my path.

Starting a topic branch

Before I can make my changes I should start a topic branch on my local work environment. This topic branch is used to keep changes together. You can have multiple topic branches in your local work environment. But keep changes seperate so that the use of a patch is clear.

Using repo start default (where default is the topic branch name, but you can name it whatever you want) does not work for me. You should also add the project which you are going to change (or supply the -all argument but I think that you should really limit it to a project to keep things seperately). The change I want to contribute is in the platform/vendor/htc/dream project

repo start default platform/vendor/htc/dream

This command will not give you back any feedback. On the other way, if you use it wrong it will give you feedback.

Merging the 9828 branch

The new change will be an addition on the 9828 step. I already created a local branch for those changes and I want to merge those to my default local development branch. This way I can use repo upload to send my change to the review server. So you can skip those steps if you don’t depend on unapproved changes

git reset--hard branch9828
HEAD is now at b15e33c... Added more proprietary libraries.

Because the local branch9828 is not needed anymore, I deleted it

git branch -d branch9828
Deleted branch branch 9828

Editing the files

With a texteditor I changed and saved both files. I will not place the changes I made to both files here in this blogpost because you can see them easily by going to https://review.source.android.com/Gerrit#change,10813 and look at the Side-By-Side diffs.

Staging changes

The steps at http://source.android.com/submit-patches describes that you should perform a git add to “stage” the changes for the next commit. This is optional when you don’t add files. So in my case I did not performed this step

Change status

After I changed both files I can see the status of the current branch by executing

repo status

You will get some kind of result (this is the repo status result after changing both script files)

# on branch default
project vendor/htc/dream/                       branch default
 -m     AndroidBoard.mk
 -m     extract-files.sh

This status reports makes clear that both files are changed (-m before each line). But what are the exact changes? You can use git diff to see detailed information.

git diff
diff --git a/AndroidBoard.mk b/AndroidBoard.mk
index 7f82037..58e2cd0 100644
--- a/AndroidBoard.mk
+++ b/AndroidBoard.mk
@@ -85,3 +85,8 @@ PRODUCT_COPY_FILES += \
 PRODUCT_COPY_FILES += \
        $(proprietary)/tiwlan.ini:system/etc/wifi/tiwlan.ini \
        $(proprietary)/Fw1251r1c.bin:system/etc/wifi/Fw1251r1c.bin
+
+PRODUCT_COPY_FILES += \
+        $(proprietary)/lights.msm7k.so:system/lib/hw/lights.msm7k.so \
+        $(proprietary)/AudioPreProcess.csv:system/etc/AudioPreProcess.csv
+
diff --git a/extract-files.sh b/extract-files.sh
index ccd78a3..7318500 100644
--- a/extract-files.sh
+++ b/extract-files.sh
@@ -31,4 +31,7 @@ adb pull /system/lib/hw/sensors.trout.so proprietary/sensors.t
 adb pull /system/etc/wifi/Fw1251r1c.bin proprietary/Fw1251r1c.bin
 adb pull /system/etc/wifi/tiwlan.ini proprietary/tiwlan.ini

+adb pull /system/lib/hw/lights.msm7k.so proprietary/lights.msm7k.so
+adb pull /system/etc/AudioPreProcess.csv proprietary/AudioPreProcess.csv
The diff  will only give you the changes. The lines starting with @@ are used as location markers pointing to where inside a file the change is made. Lines with a + are new added lines.

Committing changes

Next step is to commit the changes. Because I did not add new files I run the command

git commit -a

Commit will find the changes and the default texteditor will be opened for providing a comment (in my case it is gedit). There is a comment template which I changed to


Added more proprietary libraries.

The Led light of the HTC Dream should work when
extra libraries are extracted from the HTC Dream and
added to the system image.

The wlan.ko is not extracted (comparing to change 10501).
This is already part of the project or can be build from
source.

Saved and close the file and the commit command will result with a message like

Created commit 6aab35e: Added more proprietary libraries.
 2 files changed, 8 insertions(+), 0 deletions(-)

Note: If you provide an empty comment then the commit will be aborted

Contributor Agreement and public SSH key (only for the first time)

Last step is to upload the changes to the review server. Because it is the first time I want to post some changes to the Android Source tree I have to complete a Contributor Agreement (https://review.source.android.com/Gerrit#settings,new-agreement) to give permission that your changes can be distributed to others. I logged in with my Google Account (the one I also used when getting the source from repo) and because I am an individual I selected the Individual Ageement Type, filled in the form and submitted it.

Because you signed this agreement it is important that repo knows who you are by providing a public SSH key. The steps for creating this key should only be executed once and are stored (as default) inside the ~/.ssh directory. I am not going to describe the steps of creating this SSH keys because those are clearly written down in a step by step manual at http://github.com/guides/providing-your-ssh-key

Note: xclip (a tool for sending the content to the clipboard) can be installed on ubuntu with: sudo apt-get install xclip

The contents of the public key (which is on you clipboard) should be added to your personal page on the review server (https://review.source.android.com/Gerrit#settings,ssh-keys, maybe you should login with you Google Account). Paste the content of the clipboard inside the Add SSH Public Key box and press Add.

Note: don’t mind the / characters inside the clipboard content. Adding the messy content of the clipboard will work.

After the key is added it will be shown in the list (https://review.source.android.com/Gerrit#settings,ssh-keys).These steps should only repeated again I you want to use a different key when for example you are using a different environment.

Uploading changes

Even we had to take a sidepath (for creating the SSH key), the last step is to upload the changes. It is possible that in the meantime someone is working at the same files. So before uploading, synchonize the source

repo sync

Upload the changes by executing

repo upload

If you are working on multiple changes and have multiple topic branches, some editor window will be shown. In my case I only have one topic branch so I get a prompt if I want to upload the sources

Upload project vendor/htc/dream-open/:
  branch default ( 4 commits, Tue Jul 28 07:05:46 2009 +0200):
         0c35fa84 Add /system/lib/libhtc_acoustic.so to the list of needed proprietary files. Without it, audio does not play in Android 1.5.
         c93fac29 Whoops, fix file permission touched by editor.
         b15e33c5 Added more proprietary libraries.
         f2a9ebde Added more proprietary libraries.
to review.source.android.com (y/n)? y
Counting objects: 7, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 653 bytes, done.
Total 4 (delta 3), reused 0 (delta 0)
To ssh://johan.c.de.koning@review.source.android.com:29418/platform/vendor/htc/dream-open
 * [new branch]      default -> refs/for/cupcake

New Changes:

https://review.source.android.com/10813

--------------------------------------------
[OK    ] vendor/htc/dream-open/ default

Changes are submitted and a url is given back. On this url you can find details about the change made (like the Side-by-side diffs). The result given back also makes clear that this change depends on other changes.

And they lived happily ever after….

So what’s next? I uploaded the change to the review server. This does not mean that when you do a repo sync you will automatically get this change. No, like the server name said, it should be reviewed first. But by who and when? I don’t know. In the meantime you can use these changes by applying them on your local source

repo download platform/vendor/htc/dream 10813

Looks like there will be a sequel of this journey: Contribute to Android – Judgement of the reviewer

Building Android 1.5 – Building the source

Note (30 july 2009): made some changes because of the repository changes (dream is now called dream-open)

Note (16 july 2009): based on the comments of Foogod a section is added to this blogpost about how to create an updated wifi module. The wlan.ko module which is downloaded by default is not compatible (by version) with the compiled kernel. The new wlan.ko module will resolve the Wifi issue

Note (2 july 2009): I updated the htc_dream.mk script. The updated version will also add the Calculator, Email, ImProvider (which is not GTalk Client) and the VoiceDialer packages to your build. These application are open source and are also part of the Android source tree. Don’t know why these are not by default in the product configuration file.

Note (23 june 2009): the SdkSetup package is not by default added to the system image.  By editing the htc_dream.mk build script the SdkSetup package will be added. Previously I added the package by adding a LOCAL_MODULE_TAGS line to the build script of the SdkSetup package. But by changing the htc_dream.mk buildscript the process is more easier, clearer and the build script will also be used later for adding other packages.

My previous two blogitems about Android described the steps for setting up the build environment and getting the Android source. The next step is to build the source code. Let’s build our own kernel first.

Building the kernel

The kernel can be seen as the core of the OS. Execute the following steps to configure and perform a kernel build which is compatible for the dream hardware (ARM)

cd ~/mydroid/kernel
export ARCH=arm
export CROSS_COMPILE=arm-eabi-
export PATH=$PATH:~/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin
cp arch/arm/configs/msm_defconfig .config
make oldconfig && make

Result of this build will be an image of the kernel  found at ~/mydroid/arch/arm/boot/zImage. This kernel will be used for building the other parts of the operating system.

Building the Wifi Module

The ~/mydroid/vendor/htc/dream-open contains a wlan.ko module by default when downloading the source from the Android repository. The problem is that this version is not compatible with the compiled kernel (different version number). Because the wlan.ko is not a proprietary file, you can compile your own version of this module which is compatible with the kernel.

The sourcecode of the wlan.ko module can be found at ~/mydroid/system/wlan/ti/sta_dk_4_0_4_32. Execute the following commands to create a version compatible wifi module

cd ~/mydroid/system/wlan/ti/sta_dk_4_0_4_32
export KERNEL_DIR=~/mydroid/kernel/
make

After make is complete there will be a binary version of the wlan.ko module inside the ~/mydroid/system/wlan/ti/sta_dk_4_0_4_32. This module should be copied to the ~/mydroid/vendor/htc/dream-open location

cp wlan.ko ~/mydroid/vendor/htc/dream-open

Note: make sure, when building the wifi module, that the same terminal is used (the terminal which was also used for building the kernel). This will keep the PATH location to the arm-eabi-gcc compiler available. If you closed the terminal/used another one execute the export PATH command first (before executing make)

export PATH=$PATH:~/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin

Changing the HTC build script

The SdkSetup application (.apk) is needed to make incoming call possible (it sets the phone to the “provisioned” state) and makes the home button work. Because the package is not deployed by default, the htc_dream.mk build script should be changed. Edit the file htc_dream.mk inside the ~/mydroid/vendor/htc/dream-open directory by adding the following lines at top of the document

PRODUCT_PACKAGES := \
 Calculator \
 Email \
 ImProvider \
 SdkSetup \
 VoiceDialer

Save the file and exit the editor. The SdkSetup package will now be part of the build.

Building the system image

It is time to start a long task which will compile and create the system image of the Android OS. Two lines added to a configuration file are needed and than the compiler can do it job (and you can watch television or walk with the dog because this takes some time).  Go to the top level of the Android source

cd ~/mydroid

Use a texteditor to create a file called buildspec.mk. Add the following two lines to this file, save the file and exit the editor

TARGET_PRODUCT:=htc_dream
TARGET_PREBUILT_KERNEL:=kernel/arch/arm/boot/zImage

The TARGET_PREBUILT_KERNEL point to the location of the kernel we build earlier.

Let’s start the build by running the command

make

What’s next?

Because I don’t want to wait until your build is over, I am now going to play on my Nintendo Wii. In the next post I will give details about the flash process of your Android Device. While you are waiting you can take some time to give some feedback on these blogposts (even if you want to talk about the Nintendo Wii).

Blogpost in the Building Android 1.5 serie

Building Android 1.5 – Getting the source

Note (7 augusts 2009): patch 10889 is now part of the source tree and cupcake branch is used instead of cupcake-release

Note (30 july 2009): because of the changes made inside the Android repository, I decided to change the 10501 patch so that the wlan.ko module is not extracted from the device. The wlan.ko module is part of the dream-open project or you can build the latest version of the wlan.ko from source (as described in the blog posts). Instead of patch 10501, patch 10889 is used.

Note (27 july 2009): based on this forum post from JBQ (Software Engineer at Google), I decided to take the cupcake-release branch for the Building 1.5 series. I will write a different blogpost later about the other branches

Note (15 july 2009): the platform/vendor/htc/dream project inside the Android source tree is renamed to platform/vendor/htc/dream-open. Only the local_manifest.xml and the command for applying the patch should be changed (changes are made in this blogpost). The project is renamed because of some cleanup actions by Google. Problem is now with the latest Android1.5r2 source code, that Wifi is not working. Try to found a solution for that.

Note (24 june 2009): contributed a patch to the Android Source (change 10501) for updating the extact-files.sh and AndroidBoard.mk scripts which where outdated for the proprietary files. This simplifies the process of getting the source a little bit.

Note (9 june 2009): I updated this blogpost to make wifi and the led light of your Android Dev Phone working inside your own build.

In the previous blogpost I described how to set up the build environment. The next step will be downloading the source and apply some changes so that it will succesfully build. Getting the source is described at http://source.android.com/download but I will give a more detailed overview (and the details for making the build ready for the Android Dev Phone)

Installing repo

The repo tool will be used to get the Android source from Git. Before you can use Repo it should be installed, initialized and configured. I did not described the installation of repo in setting up the build environment because the repo script is Android specific.

Open a terminal inside Ubuntu and make sure that you are inside your home directory

cd ~

Inside the home directory, create a new directory called bin

mkdir bin

The bin directory should be part of your path ($PATH).  Edit the .bashrc file inside your user home directory (which is the current directoy you are working) and add the following line to the end of the file

export PATH=$PATH:~/bin

Save .bashrc and open a new terminal (this will execute .bashrc). Check if the bin directory is inside your path

echo $PATH

The results will be different for each installation because a different username will be used (or you would like my username jcdekoning) and maybe even more locations are inside your path. The result within my installation gives back

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/jcdekoning/bin

The last part (home/jcdekoning/bin) is pointing to the bin directory inside the users home directory (in my case /home/jcdekoning).

The next step is to download the repo script (with curl) and make it executable (chmod). Use to following two commands

curl http://android.git.kernel.org/repo > ~/bin/repo
chmod a+x ~/bin/repo

Initializing the Repo client

You need to make a location where you want to store the files (source, configuration, etc) from Git. I create a directoy inside the users home which is called mydroid

cd ~
mkdir mydroid
cd mydroid

Inside the mydroid directory you need to execute repo init to specify where the android files are remotely located. By running repo init -u git://android.git.kernel.org/platform/manifest.git you will get the master version of the Android source. The problem with this version is that it is mostly not stable and can have expiremental code. Therefore I use a specific branch of the Android source which hold a stable build for Android 1.5

repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake

Repo will ask for your name and email address. When you are planning to  submit code back to the Android source, use a email address which is assciated with a Google account.

If repo init is succesfully finished you will receive a message with at the

repo initialized in /home/jcdekoning/mydroid

You did not download the source yet, you only configured the repo tool so that it knowns where the source can be found. Inside the mydroid directoy you will find a .repo directory

Repo configuration changes for Android Dev Phone

Note: the download of the kernel source files is only needed if you want to compile the kernel by your own. You can also skip this configuration change and use the prebuilt kernel which is part of the dream-open project. It is possible that this prebuilt kernel is not the latest version

It is possible to download the source at this point, but we need to make some changes to retrieve specific source for the Android Dev Phone (internally called Dream).

Inside the .repo directory (within mydroid) you need to create a local_manifest.xml. This file containsa description of the three extra project needed for the Dev Phone. The contents of the local_manifest.xml

<?xml version="1.0" encoding="UTF-8"?>
 <manifest>
  <project path="kernel" name="kernel/msm" revision="refs/heads/android-msm-2.6.27"/>
 </manifest>

With the local_manifest.xml in place it is time to get the source code. Inside the mydroid directory (and not the .repo directory) execute the command

repo sync

No sit back, relax, drink some coffee or read some of my other blog posts because downloading the code will take some time.

Proprietary binaries

Note: the patch changes are now part of the source tree.

Some closed source files which are specific for the Dream need to be extracted from a Android device running 1.5. These files are not part of the source tree but are needed for running Android on the Android Dev Phone. Within you mydroid directory you find /vendor/htc/dream-open. There is a script called extract-files.sh. This script will use the adb tool to retrieve the files from an android device. But the content of this script is outdated for version 1.5.

To update the content of the extract-files.sh script (and the AndroidBoard.mk file) get a patch (10889):

repo download platform/vendor/htc/dream-open 10889/4

You can now get the proprietary files from you Android device by connecting it to Ubuntu and execute the extract.files.sh script

./extract-files.sh

Sometimes the Android connection between my Ubuntu in VMWare is not working properly. Therefore I use a different method for extracting the files from the official Android 1.5 image. By extracting the image provided by HTC

Using unyaffs

This part is only relevant when you don’t want or not able to extract the proprietary files from an Android device. So skip this part if you already have the files extracted. These files should be downloaded to /vendor/htc/dream-open/proprietary

The Android OS makes use of a yaffs file system. You can download the unyaffs tool at http://code.google.com/p/unyaffs/ to extract the content of an Android image. There is a prebuildversion available at the Downloads section. Place the unyaffs tool inside the ~/bin directory so that the tool can be found because it is inside the PATH definition

When the unyaffs is downloaded, make sure it can be executed

cd ~/bin
chmod a+x unyaffs

Official Android images provided by HTC for the Android Dev Phone can be found at http://www.htc.com/www/support/android/adp.html You will extract the system image to get the proprietary files. At the HTC download page, make sure you download the Android 1.5 system image (signed-dream_devphone_userdebug-img-148830.zip). Inside my home directory I create a new directory where the content of the zip file will be stored (~/htc). It is important to use the same directory name otherwise the script for copying the proprietary files will not work.

The downloaded system image archive contains four different .img files

  • boot.img
  • recovery.img
  • system.img
  • userdata.img

When our own build is compiled we will end up with our build Android OS which also consists of these four different image files. The system.img will be extracted using the unyaffs tool

cd ~/htc
sudo ~/bin/unyaffs system.img

If the unyaffs is executed succesfully it will give a message like end of image. When looking at the content of the htc directory you will find new created files and folders (like app, bin, etc, lib, usr). The proprietary files are stored inside the etc and lib directory. Create with your favorite text editor a new file called htc-copy.sh (the location where you save this file doesn’t matter. I saved it inside ~/htc) and give it the following content.

#!/bin/sh

mkdir -p ~/mydroid/vendor/htc/dream-open/proprietary

cp ~/htc/bin/akmd ~/mydroid/vendor/htc/dream-open/proprietary/akmd

cp ~/htc/etc/AudioFilter.csv ~/mydroid/vendor/htc/dream-open/proprietary/AudioFilter.csv
cp ~/htc/etc/AudioPara4.csv ~/mydroid/vendor/htc/dream-open/proprietary/AudioPara4.csv
cp ~/htc/etc/AudioPreProcess.csv ~/mydroid/vendor/htc/dream-open/proprietary/AudioPreProcess.csv
cp ~/htc/etc/firmware/brf6300.bin ~/mydroid/vendor/htc/dream-open/proprietary/brf6300.bin
cp ~/htc/etc/gps.conf ~/mydroid/vendor/htc/dream-open/proprietary/gps.conf
cp ~/htc/etc/wifi/Fw1251r1c.bin ~/mydroid/vendor/htc/dream-open/proprietary/Fw1251r1c.bin
cp ~/htc/etc/wifi/tiwlan.ini ~/mydroid/vendor/htc/dream-open/proprietary/tiwlan.ini

cp ~/htc/lib/libaudioeq.so ~/mydroid/vendor/htc/dream-open/proprietary/libaudioeq.so
cp ~/htc/lib/libgps.so ~/mydroid/vendor/htc/dream-open/proprietary/libgps.so
cp ~/htc/lib/libhgl.so ~/mydroid/vendor/htc/dream-open/proprietary/libhgl.so
cp ~/htc/lib/libhtc_acoustic.so ~/mydroid/vendor/htc/dream-open/proprietary/libhtc_acoustic.so
cp ~/htc/lib/libhtc_ril.so ~/mydroid/vendor/htc/dream-open/proprietary/libhtc_ril.so
cp ~/htc/lib/libjni_pinyinime.so ~/mydroid/vendor/htc/dream-open/proprietary/libjni_pinyinime.so
cp ~/htc/lib/libmm-adspsvc.so ~/mydroid/vendor/htc/dream-open/proprietary/libmm-adspsvc.so
cp ~/htc/lib/libOmxCore.so ~/mydroid/vendor/htc/dream-open/proprietary/libOmxCore.so
cp ~/htc/lib/libOmxH264Dec.so ~/mydroid/vendor/htc/dream-open/proprietary/libOmxH264Dec.so
cp ~/htc/lib/libOmxMpeg4Dec.so ~/mydroid/vendor/htc/dream-open/proprietary/libOmxMpeg4Dec.so
cp ~/htc/lib/libOmxVidEnc.so ~/mydroid/vendor/htc/dream-open/proprietary/libOmxVidEnc.so
cp ~/htc/lib/libopencorehw.so ~/mydroid/vendor/htc/dream-open/proprietary/libopencorehw.so
cp ~/htc/lib/libpvasf.so ~/mydroid/vendor/htc/dream-open/proprietary/libpvasf.so
cp ~/htc/lib/libpvasfreg.so ~/mydroid/vendor/htc/dream-open/proprietary/libpvasfreg.so
cp ~/htc/lib/libqcamera.so ~/mydroid/vendor/htc/dream-open/proprietary/libqcamera.so
cp ~/htc/lib/libspeech.so ~/mydroid/vendor/htc/dream-open/proprietary/libspeech.so

cp ~/htc/lib/hw/lights.goldfish.so ~/mydroid/vendor/htc/dream-open/proprietary/lights.goldfish.so
cp ~/htc/lib/hw/lights.msm7k.so ~/mydroid/vendor/htc/dream-open/proprietary/lights.msm7k.so
cp ~/htc/lib/hw/sensors.trout.so ~/mydroid/vendor/htc/dream-open/proprietary/sensors.trout.so

chmod 755 ~/mydroid/vendor/htc/dream-open/proprietary/akmd

Execute the htc-copy.sh script so that the files will be copied to the ~/mydroid/vendor/htc/dream-open location.

chmod a+x htc-copy.sh
./htc-copy.sh

You can check if the script is succesful by going to ~/mydroid/vendor/htc/dream-open/proprietary and take a look at the contents of this directory.

What’s next?

So the source is downloaded, patched for the dream device and also the proprietary binary files are in place. The next step will be configuring the build and finally, the real work, compiling the source. I will write down more information about these steps in a next blog. Feel free to give comments on this post even if those are possitive.

Blogpost in the Building Android 1.5 serie

Building Android 1.5 – Build environment

Last year I bought an Android Dev Phone. I wanted to be one of the first to use this great device and operating system. The Android Dev Phone makes it possible to flash it with your own build version of Android. So why not building the Android OS from source?

This first part of Building Android 1.5 is about setting up the build environment. There is a description available at http://source.android.com/download. I will write down the steps I have taken to give you a step by step manual

Installation of Ubuntu

I installed Ubuntu as a Virtual Machine (because I am running Windows Vista). I used Ubuntu 8.04 because this is also the environment which Google is using (as I should believe). There are some issues with Ubuntu 8.10 for example when building the source.

I will not explain the installation of Ubuntu. This is really straight forward (perhaps even easier than installing Windows) when putting in the Ubuntu CD and boot from it.

When Ubuntu is installed I did sudo apt-get update and sudo apt-get upgrade to have the latest versions of all the packages which are installed by default

Required packaged

In order to retrieve the source code from git and to build the Android OS, the installation of some packages is required. Install the following packages by executing sudo apt-get install <pakagename>

  • git-core
  • gnupg (this package was already installed)
  • sun-java5-sdk (don’t use java 6 because this will result in errors during build)
  • flex
  • bison
  • gperf
  • libsdl-dev
  • libesd0-dev (the last 0 is a zero)
  • libwxgtk2.6-dev
  • build-essential
  • zip (already installed)
  • curl
  • libncurses5-dev
  • zlib1g-dev
  • valgrind (this packge is optional)

Instead of installing the packages seperately, you can also comine the apt-get install command

sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev valgrind

At http://source.android.com/download is written that Ubuntu 8.10 users should install a newer version of libreadline. I found out that I also needed this package because otherwise repo gives errors.

sudo apt-get install libreadline5-dev

Note: the Get source page on the android website uses a different package name (lib32readline5-dev) but that one does not exists

Java Environment

It could be possible that java 6 is installed on your own Ubuntu installation. To check which Java version is used, run the command

update-java-alternatives -l

In my Ubuntu enviroment only one java version is given back in the result

java-1.5.0-sun 53 /usr/lib/jvm/java-1.5.0-sun

If multiple versions are installed, use update-java-alternatives -s to change the default Java Environment. For example

update-java-alternatives -s java-1.5.0-sun

The location of the Java installation should also be set exported as $JAVA_HOME. Edit the .bashrc file inside your users home directory. Add the following line to the end of the file

export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun-1.5.0.16

The location of the Java installation can be different (depending on the version number which is in my case 1.5.0.16). Check the location first to see if it contains the Java installation.

Start a new terminal and check if $JAVA_HOME is working and pointing to the right location

echo $JAVA_HOME

When the result given back is correct (for example /usr/lib/jvm/java-1.5.0-sun.1.5.0.16) the $JAVA_HOME is correctly set.

You can also check if the correct Java version is used by running the command java -version

java -version

Result

java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b02)
Java HotSpot(TM) Client VM (build 1.5.0_16-b02, mixed mode, sharing)

What’s next?

By installing Ubuntu, de required packages and setting up Java everyting is ready for downloading the source from Git and building your own version of the Android source. I will explain the steps of retrieving the source code from Git in a next blog item.  Feel free to give feedback on this post.

Blogpost in the Building Android 1.5 serie

Rood potlood

Er zijn momenten in het leven die toch vastgelegd moeten worden. Vandaag was zo’n moment… voor het eerst stemmen met een rood potlood voor de Europese Verkiezingen. Ik ben al een aantal keren naar de stembus gegaan maar het stemmen ging altijd met een stemcomputer.

Overigens vond ik het stemmen met rood potlood tegenvallen: de kleur rood was meer roze