Posts Tagged ‘Android’

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

Enable Latitude on Android

With the Android 1.1 and Android 1.5 images for the Android Dev Phone 1 (ADP1), Google Latitude is not available by default. It is possible to enable Latitude inside the Google Maps application by adding one record to a settings database.

At http://forum.xda-developers.com/showthread.php?p=3438480#post3438480 there are several steps described to enable Latitude. Adding a record to a settings database and updating a XML file (MapsActivity.xml) are needed to make Latitude available as menu item inside the Google Maps application.

Updating the MapsActivity.xml file is not that easy. The adb shell does not support a copy command and there is also no editor available inside the shell. With the use of cat it is possible to make a copy of the MapsActivity.xml to the sdcard of your Android device:

cat /data/data/com.google.android.apps.maps/shared_prefs/com.google.android.maps.MapsActivity.xml > /sdcard/MapsActivity.xml

Next you should mount the sdcard, edit the file on your desktop pc, unmount the sdcard and replace the MapsActivity.xml with the one which you changed on your sdcard:

cat /sdcard/MapsActivity.xml > /data/data/com.google.android.apps.maps/shared_prefs/com.google.android.maps.MapsActivity.xml

Because editing needs a lot of actions, I found a different way of enabling Latitude by only adding the record to the database. I performed the following steps on a device running Android 1.5, but I think it will also work on the Android 1.1 version.

  1. On your ADP1, choose Menu -> Settings -> Applications -> Manage applications -> Maps
  2. Push the Clear data button.This will remove the /data/data/com.google.android.apps.maps/shared_prefs/ folder which contains the MapsActivity.xml file.
    Don’t worry, the different xml files in this folder will be auto generated again with Latitude (Friend Finder) enabled.
  3. Clear Data of Maps Application

  4. Connect your ADP1 to your PC (with the use of the USB cable) and execute adb shell inside a Windows shell or Linux terminal
  5. Execute su inside the adb shell to give you more rights
  6. Change the current directory: cd /data/data/com.android.providers.settings/databases
  7. Run the sqlite3 application on the settings database: sqlite3 settings.db
  8. To see if the setting maps_enable_friend_finder is not already inside the settings database, make a dump of all the records inside the gservices table on the screen and look if the record already exists: .dump gservices
  9. Insert a new record: INSERT INTO “gservices” (name,value) VALUES(‘maps_enable_friend_finder’,’1′);. This record will hold the flag to enable Latitude
  10. Exit the sqlite3 application: .quit
  11. Exit the su mode: exit
  12. Exit the adb shell: exit
  13. On your Android device, run the Maps application. A popup will be shown that Latitude is available. Pressing Menu will show you the Join Latitude option.
  14. Latitude PopupJoin Latitude

By clearing the data of the Maps application (with the Clear data option) the /data/data/com.google.android.apps.maps/shared_prefs/ is removed containing settings for the map application. By adding the record to the database and starting the Maps application again, the /data/data/com.google.android.apps.maps/shared_prefs/ is generated again. Because of the maps_enable_friend_finder flag set to true (1) the MapsActivity.xml is also generated which enables Latitude.

Android Dev Phone, Ubuntu and VMWare Server

Compiling the source code for creating your own Android build is not supported within a Windows operating system (I don’t know if it is possible by the use of Cygwin). Because my notebook is running Windows XP, I use VMWare Server 2.0 which runs a Ubuntu 8.10 (Desktop) as virtual machine.

VMWare makes it possible to connect USB devices inside your virtual machine. Because I want to connect my Android Dev Phone to Ubuntu, I performed the following steps to make that possible.

VMWare hardware configuration

When creating a virtual machine (or before starting the virtual machine) make sure that the USB controller is added to the hardware list.

If this is not the fact. Add the USB Controller by choosing Add hardware and select the USB Controller from the Hardware type list.

Sharing the USB device

Connect your Android Dev Phone to your computer and start the Ubuntu Virtual Machine by pressing the Play button inside the VMWare Server web interface. When booting the Virtual Machine you will notice that a new icon (with an USB sign) is placed on the toolbar inside the VMWare Web Interface next to the Restart button. When you click on this icon a context menu will be shown with a list of devices that are plugged inside the host OS (in my case connected to Windows XP).

Mark the checkbox in front of the High Android Phone to make it available inside Ubuntu.

Udev configuration

You can perform a check, to see that the Android Dev Phone is shared with Ubuntu, by opening a Terminal (inside Ubuntu. Open a VMWare Remote Console to make use of the Ubuntu) and type the following command

lsusb

A list of USB devices will be shown. For example:

Bus 002 Device 001: ID ld6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 004: ID 0bb4:0c02 High Tech Computer Corp.
Bus 001 Device 001: ID ld6b:0002 Linux Foundation 2.0 root hub

The Android Dev Phone is the device with the name High Tech Computer Corp (HTC). Make a note of the first part of the device ID (in this case 0bb4) because this is needed for the udev rule.

Create a new file (as root)

sudo gedit /etc/udev/rules.d/50-android.rules

with the following content

SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"

Make sure that the text after {idVendor} is the same as the device id found when using the lsusb command. Save and exit the editor

To make execution of the rule possible, perform a chmod

sudo chmod a+rx /etc/udev/rules.d/50-android.rules

To make the rule active, restart udev

sudo /etc/init.d/udev restart

Final check

To check if the device is available use the adb tool (which is part of the Android SDK. Download and installation instructions at http://code.google.com/android)

adb devices

This will return a list of attached devices.

List of devices attached
HT845GZ51782 device

You should now be able to use the different tools of the Android SDK (and application deployment with the use of Eclipse) within Ubuntu running inside VMWare Server.