Posts Tagged ‘Cupcake’

Building Android 1.5 – Google Apps and audio files

Note 30 july 2009: updated the post. It now reflects the changes made to the repository (dream is now called dream-open)

Note 13 july 2009: Vladimir Stepanov post a reply today, telling me that the media files are already part of the source tree and can be found at ~/mydroid/fameworks/base/data/sounds. Adding the media files is a lot easier this way. I changed this blogpost about how to include those media files inside the system image.

This will be (for now) the last post of the building Android 1.5 for the Android Dev Phone. In the previous posts I explained how to prepare your building environment (Ubuntu 8.04), get the source and make it ready for building, building the source and finaly flash it to your device. Your own build should be working fine, but comparing to the official builds you are missing the Google applications like GMail, Google Maps, Android Market and YouTube. Besides the applications missing there are also no ringtones available on your device.

In this blogpost you will extract the Google Applications and media files from the official HTC Android 1.5 image (this can be done by extracting them from your device or with the use of unyaffs). The extracted files will be added to your own Android image. This results in an Android build which is almost the same as the HTC version.

Note: it is also possible to install the applications and add the media files while your device is running. But the purpose of this blog post is to create your own image which can be flashed over and over again (or even exchanged between other Android Dev Phone users)

Audio Files

In the official HTC image (http://www.htc.com/www/support/android/adp.html) a system/media directory exists which contains audio files for the alarms, notifications, ringtones and ui. These audio files are also part of the source tree but are not included by default.

Inside the ~/mydroid/frameworks/base/data/sounds folder you will find the different audio files. Together with those audio files there are two build scripts: OriginalAudio.mk and AudioPackage2.mk (containing a larger audio pack). Just rename one of those two script to Android.mk.

mv ~/mydroid/frameworks/base/data/sounds/OriginalAudio.mk ~/mydroid/frameworks/base/data/sounds/Android.mk

You can create a new image by running the make command from ~\mydroid location. The make command will not compile everything again. Only the changed files. In our case nothing will be recompiled, only the media files will be added to the system.img.

After the make command is finished you can flash the new image to your phone. If you are already running your own build, you only need to flash the system.img. You can found more details about the flash process at the Flashing The Phone blogpost.

Google Applications

Besides the missing audio files, are also the closed source Google Applications not installed. The following list of applications are not installed

checkin.apk (needed for login with Google Account)
Gmail.apk
GmailProvider.apk (the synchronization module for GMail)
GoogleApps.apk
GoogleContactsProvider.apk (replacement for the ContactsProvider. This version will synchronize with your Google Contacts)
GooglePartnerSetup.apk
GoogleSettingsProvider.apk
GoogleSubscribedFeedsProvider.apk (replacement for the  SubscribedFeedsProvider.apk)
gtalkservice.apk (for Google Talk)
Maps.apk (Google Maps)
MediaUploader.apk
NetworkLocation.apk (for determining your location based on network cells)
SetupWizard.apk (for setting up your Google Account connected with your device)
Street.apk (Google Maps StreetView)
Talk.apk (Google Talk application)
Vending.apk (Android Market applicatioN)
VoiceSearch.apk (Voice Search)
YouTube.apk (YouTube application)

Note: the HTC image does have more  application installed by default. But I think those are not relevant for your own build but HTC related: BugReport.apk, DebugTool.apk, FieldTest.apk, HtcLog.apk and QxdmLog.apk. Let me know if you think (with some information) that these packages should be part of your own build. Also the use/need of the Ftp.apk package is not clear. And I did not add the SystemUpdater.apk because this is your own build so you should provide updates for it (and not HTC/Google).

The Google applications make use of extra libraries and permission files. So also these files should be part of our build:

com.google.android.gtalkservice.jar (is placed inside the framework directory of the system image and will be used with GoogleTalk)
com.google.android.maps.jar (also part of the framework and is use by Google Maps)
com.google.android.gtalkservice.xml  (permission file for gtalkservice library, placed inside the etc\permissions directory)
com.google.android. maps.xml (permission file for maps library, placed inside the etc\permissions directory)

Just like with the media files, the extracting of these files can be done with adb or unyaffs. The keep thing seperated, I decided to put the extracted files inside the ~/mydroid/vendor/google directory. Because the google directory does not exist, go to the ~/mydroid/vendor location and create the google folder.

cd ~/mydroid/vendor
mkdir google
cd google

Extracting with adb

The procedure for extracting the files with the adb tool is the same as with the media files. Just create a new script called extract-google-files.sh inside the ~/mydroid/vendor/google folder. Place the following commands inside the file

#!/bin/sh

mkdir -p app
adb pull /system/app/checkin.apk app/checkin.apk
adb pull /system/app/Gmail.apk app/Gmail.apk
adb pull /system/app/GmailProvider.apk app/GmailProvider.apk
adb pull /system/app/GoogleApps.apk app/GoogleApps.apk
adb pull /system/app/GoogleContactsProvider.apk app/GoogleContactsProvider.apk
adb pull /system/app/GooglePartnerSetup.apk app/GooglePartnerSetup.apk
adb pull /system/app/GoogleSettingsProvider.apk app/GoogleSettingsProvider.apk
adb pull /system/app/GoogleSubscribedFeedsProvider.apk app/GoogleSubscribedFeedsProvider.apk
adb pull /system/app/gtalkservice.apk app/gtalkservice.apk
adb pull /system/app/Maps.apk app/Maps.apk
adb pull /system/app/MediaUploader.apk app/MediaUploader.apk
adb pull /system/app/NetworkLocation.apk app/NetworkLocation.apk
adb pull /system/app/SetupWizard.apk app/SetupWizard.apk
adb pull /system/app/Street.apk app/Street.apk
adb pull /system/app/Talk.apk app/Talk.apk
adb pull /system/app/Vending.apk app/Vending.apk
adb pull /system/app/VoiceSearch.apk app/VoiceSearch.apk
adb pull /system/app/YouTube.apk app/YouTube.apk

mkdir -p etc/permissions
adb pull /system/etc/permissions/com.google.android.gtalkservice.xml etc/permissions/com.google.android.gtalkservice.xml
adb pull /system/etc/permissions/com.google.android.maps.xml etc/permissions/com.google.android.maps.xml

mkdir -p framework
adb pull /system/framework/com.google.android.gtalkservice.jar framework/com.google.android.gtalkservice.jar
adb pull /system/framework/com.google.android.maps.jar framework/com.google.android.maps.jar

Save and exit the editor. Make sure that your device is connected to Ubuntu. Execute the script by executing the command (from the location ~/mydroid/vendor/google)

./extract-google-files.sh

The different files, needed for the Google applications, will be extracted from your device and placed inside app, etc or framework directory. The build script should be updated so that those files are included inside your own build. This will be explained further in this blog post. First I will explain how to get the files with the use of unyaffs.

Extracting with unyaffs

For the media files I already explained how to use the unyaffs tool. So I presume that the system image is extracted inside the ~/htc directory. You only need to copy the files to the ~/vendor/google location. This will need some more commands than with the media files.

mkdir -p ~/mydroid/vendor/google/app
cp ~/htc/app/checkin.apk ~/mydroid/vendor/google/app/checkin.apk
cp ~/htc/app/Gmail.apk ~/mydroid/vendor/google/app/Gmail.apk
cp ~/htc/app/GmailProvider.apk ~/mydroid/vendor/google/app/GmailProvider.apk
cp ~/htc/app/GoogleApps.apk ~/mydroid/vendor/google/app/GoogleApps.apk
cp ~/htc/app/GoogleContactsProvider.apk ~/mydroid/vendor/google/app/GoogleContactsProvider.apk
cp ~/htc/app/GooglePartnerSetup.apk ~/mydroid/vendor/google/app/GooglePartnerSetup.apk
cp ~/htc/app/GoogleSettingsProvider.apk ~/mydroid/vendor/google/app/GoogleSettingsProvider.apk
cp ~/htc/app/GoogleSubscribedFeedsProvider.apk ~/mydroid/vendor/google/app/GoogleSubscribedFeedsProvider.apk
cp ~/htc/app/gtalkservice.apk ~/mydroid/vendor/google/app/gtalkservice.apk
cp ~/htc/app/Maps.apk ~/mydroid/vendor/google/app/Maps.apk
cp ~/htc/app/MediaUploader.apk ~/mydroid/vendor/google/app/MediaUploader.apk
cp ~/htc/app/NetworkLocation.apk ~/mydroid/vendor/google/app/NetworkLocation.apk
cp ~/htc/app/SetupWizard.apk ~/mydroid/vendor/google/app/SetupWizard.apk
cp ~/htc/app/Street.apk ~/mydroid/vendor/google/app/Street.apk
cp ~/htc/app/Talk.apk ~/mydroid/vendor/google/app/Talk.apk
cp ~/htc/app/Vending.apk ~/mydroid/vendor/google/app/Vending.apk
cp ~/htc/app/VoiceSearch.apk ~/mydroid/vendor/google/app/VoiceSearch.apk
cp ~/htc/app/YouTube.apk ~/mydroid/vendor/google/app/YouTube.apk

mkdir -p ~/mydroid/vendor/google/etc/permissions
cp ~/htc/etc/permissions/com.google.android.gtalkservice.xml ~/mydroid/vendor/google/etc/permissions/com.google.android.gtalkservice.xml
cp ~/htc/etc/permissions/com.google.android.maps.xml ~/mydroid/vendor/google/etc/permissions/com.google.android.maps.xml

mkdir -p ~/mydroid/vendor/google/framework
cp ~/htc/framework/com.google.android.gtalkservice.jar ~/mydroid/vendor/google/framework/com.google.android.gtalkservice.jar
cp ~/htc/framework/com.google.android.maps.jar ~/mydroid/vendor/google/framework/com.google.android.maps.jar

The different files needed for the application are now placed inside the app, etc and framework directory (at ~/mydroid/vendor/google). Next step is to edit the buildscripts

Changing the build script for the Google applications

The htc_dream.mk build script should be edited. I decided to change the htc_dream.mk build script so that it does not depend on the build/target/product/generic.mk script (which depends on the build/target/product.core.mk file). The reason I do this, is that I don’t want to have the generic providers be part of my own build. Those providers will be replaced with the Google specific version (so the ContactsProvider is not needed anymore because the GoogleContactsProvider will be used instead). I could off course remove them from the generic.mk and core.mk files, but I don’t want to edit those files to keep things seperated. Because the core.mk also contains packages which I don’t want to be part of the build, I cannot change the dependency of the htc_dream.mk from generic.mk to core.mk. So the dependencies will be completly removed.

At the point also the SdkSetup package is not needed anymore, because we are using the SetupWizard package. (The SdkSetup package does some small things like making it possible to make phone calls. This functionality is also part of the SetupWizard package).

To add the Google applications a PRODUCT_COPY_FILES section should be added to the htc_dream.mk file. We use PRODUCT_COPY_FILES because the packages are already in a binary format and only need to be copied to the system image.

One of the packages is the NetworkLocation package. This package contains functionality to determine your position based on network GSM cells. To get this package working an extra build property should be set. This can be done by adding the PRODUCT_PROPERTY_OVERRIDES variable to the htc_dream.mk file which contains the property ro.com.google.locationfeatures=1

The complete htc_dream.mk script (which can be find inside the ~/mydroid/vendor/htc/dream-open location) is placed below.

PRODUCT_PROPERTY_OVERRIDES := \
    ro.config.notification_sound=F1_New_SMS.ogg \
    ro.com.google.locationfeatures=1

PRODUCT_PACKAGES := \
    framework-res \
    Browser \
    Contacts \
    Launcher \
    HTMLViewer \
    Phone \
    DownloadProvider \
    GoogleSearch \
    MediaProvider \
    SettingsProvider \
    TelephonyProvider \
    UserDictionaryProvider \
    PackageInstaller \
    Bugreport \
    AlarmClock \
    AlarmProvider \
    Calendar \
    Camera \
    DrmProvider \
    LatinIME \
    Mms \
    Music \
    Settings \
    Sync \
    Updater \
    CalendarProvider \
    SyncProvider \
    Calculator \
    Email \
    ImProvider \
    VoiceDialer

PRODUCT_COPY_FILES := \
	vendor/google/app/checkin.apk:system/app/checkin.apk \
	vendor/google/app/Gmail.apk:system/app/Gmail.apk \
	vendor/google/app/GmailProvider.apk:system/app/GmailProvider.apk \
	vendor/google/app/GoogleApps.apk:system/app/GoogleApps.apk \
	vendor/google/app/GoogleContactsProvider.apk:system/app/GoogleContactsProvider.apk \
	vendor/google/app/GooglePartnerSetup.apk:system/app/GooglePartnerSetup.apk \
	vendor/google/app/GoogleSettingsProvider.apk:system/app/GoogleSettingsProvider.apk \
	vendor/google/app/GoogleSubscribedFeedsProvider.apk:system/app/GoogleSubscribedFeedsProvider.apk \
	vendor/google/app/gtalkservice.apk:system/app/gtalkservice.apk \
	vendor/google/app/Maps.apk:system/app/Maps.apk \
	vendor/google/app/MediaUploader.apk:system/app/MediaUploader.apk \
	vendor/google/app/NetworkLocation.apk:system/app/NetworkLocation.apk \
	vendor/google/app/SetupWizard.apk:system/app/SetupWizard.apk \
	vendor/google/app/Street.apk:system/app/Street.apk \
	vendor/google/app/Talk.apk:system/app/Talk.apk \
	vendor/google/app/Vending.apk:system/app/Vending.apk \
	vendor/google/app/VoiceSearch.apk:system/app/VoiceSearch.apk \
	vendor/google/app/YouTube.apk:system/app/YouTube.apk \
	vendor/google/etc/permissions/com.google.android.gtalkservice.xml:system/etc/permissions/com.google.android.gtalkservice.xml \
	vendor/google/etc/permissions/com.google.android.maps.xml:system/etc/permissions/com.google.android.maps.xml \
	vendor/google/framework/com.google.android.gtalkservice.jar:system/framework/com.google.android.gtalkservice.jar \
	vendor/google/framework/com.google.android.maps.jar:system/framework/com.google.android.maps.jar

# Overrides
PRODUCT_NAME := htc_dream
PRODUCT_DEVICE := dream-open
PRODUCT_MANUFACTURER := htc
PRODUCT_BRAND := generic
PRODUCT_POLICY := android.policy_phone

Save the file and exit the editor. The build script for the google applications is now ready. Before running the make command again remove the ~/mydroid/out/target/product/dream-open/system directory first. If you don’t remove this directory when you remove packages (like the SdkSetup) from your build, those packages will still be copied to your final build. The system directory contains the binary version of your system image but when you remove this directory the binary files will not be recompiled again (there are intermediates version inside the ~/mydroid/out/target/product/dream/obj directory

rm -rf ~/mydroid/out/target/product/dream-open/system

Now you can run the make command again (from the ~\mydroid locatin).  Like I already said, the make command will not compile everything again. Only the changed files. In our case nothing will be recompiled, only the google files will be added to the system.img.

After the make command is finished you can flash the new image to your phone. If you are already running your own build, you only need to flash the system.img. You can found more details about the flash process at the Flashing The Phone blogpost.

What’s next?

If you start your device with the image containing the Google applications files, the Setup Wizard will be shown. Complete the steps of this wizard to connect your Google Account to your device. You will now have an image running that contains the different Google applications which should run correctly (also the Calendar application should work now).

So that brings us to the end of the Building Android 1.5 series. I hoped you liked it and got enough information for making your own build. If not, just post a reply on one of the blog posts so that I can give you more details.  Although this is the final post of this blogpost serie, I will continue writing about Android (and other technologies). So look at my website often or follow me on Twitter to get updates.

Blogpost in the Building Android 1.5 serie

Building Android 1.5 – Flashing the phone

Note 30 july 2009: updated the post. It now reflects the changes made to the repository (dream is now called dream-open)

In the previous blog posts I described how to setup your build environment, get the Android source and how to build it for the Android Dev Phone. When you followed these steps you should now have an own version of the Android OS image available which can be flashed on your Android Dev Phone. But first, as usual, some preperations to make the flashing succesful.

Note: flashing your Android phone will remove your data from the phone (not the SD card). For example the SMS messages will be destroyed. It is possible to keep this “userdata” by NOT flashing the userdata partition. I found out that this can sometimes result in strange behaviors of the OS. Another option is to backup the data first (with applications from the Android Market)

Note: in my opinion flashing your Android will not brick your phone easily (brick means that you can only use your phone as a building block). You should be able to access the bootloader of the device even when your build does not work. But there is a possibility that things can go wrong. So I am not responsable for any damage to your phone. Know what you are doing. Besides the step by step walkthrough, I try to give you as much information so that you know why you are doing those steps. If you are not sure that what you are doing is right, just post a question to this blog or ask it on the Android Platform Forum  (http://groups.google.com/group/android-platform)

Radio image

The radio part of the Android OS for the Android Dev Phone is, just like the proprietary files, closed source. The radio part makes communication with the GSM network possible. This part is not build with the Android source code but can be downloaded at the HTC support site as separate download (http://www.htc.com/www/support/android/adp.html).

Because your build can be seen as an Android 1.5 version, it is important that you use the 1.5 version of the Radio image. Previous versions are not compatible.

The steps which I took to make sure that I have the right radio version on my phone and that it is working properly, is to flash the phone first to the official HTC 1.5 version of Android. If you already did that you can skip those steps. If you are not sure which radio version is running on your phone, follow these steps on your dev phone

Press menu (from the home screen)
Choose settings
Scroll down to the last option About Phone
At the bottom you will find information about which version is installed

The baseband version shows the radio image version which is in use. It should end with 2.22.19.16I (just like the download name ota-radio-2_22_19_26I). If this is not the case, you should first flash the phone with the HTC image for Android 1.5

The steps for flashing the phone with the HTC image are clearly described at http://www.htc.com/www/support/android/adp.html If you follow these steps (and use the Android 1.5 version) you should end with your dev phone running the HTC Android 1.5 version. I will give you some extra information which can be usefull during the flashing procedure.

About phone screen

About phone screen

Fastboot

For the update process described by HTC you will need the tool fastboot. You can download this tool from the same website as where you find the HTC images. Another option is to use your own version of fastboot which is created during the build process. You will find this application (which is in our case the Linux version) in ~/mydroid/out/host/linux-x86/bin. If you are a Windows user, you should use the fastboot executable provided by HTC. I don’t know if building the source on Mac OS X is as clear as on Ubuntu (it should be possible to compile the source) and that the fastboot version can be used.

Make sure that the fastboot utility location is inside the PATH variable. So that it can be found on the whole system independent on the location of which the terminal is currently active.

Connect ADP with Ubuntu

In a previous blog post I explained how to connect your device with Ubuntu which runs within VMWare as Virtual Machine. Those steps (http://www.johandekoning.nl/index.php/2009/02/07/android-dev-phone-ubuntu-and-vmware-server/) are also relevant when running Ubuntu natively (except for the VMWare steps).  Or follow the steps (when for example you want to use fastboot with Windows) which are written for the Android SDK http://developer.android.com/guide/developing/device.html

Flashing the device

So the HTC Android 1.5 version is running well? You made sure that the right radio version is installed? Fastboot is working properly? And made (optionally) a backup of your important data?

If that’s the case it is time for flashing the phone. The flashing part is quit easy and will take only a couple of minutes. First the device should be started in fastboot mode. The Android Dev Phone contains a bootloader which makes it possible to flash the phone. I think, but I am not sure, that this bootloader is always accessible (or you should execute some kind of operation which will destroy the bootloader part but I don’t know how to do that) making it possible to flash your Android over and over again with for example your own build (if your build is not working or you make changes) or the official HTC one.

To use fastboot execute the following steps on your device

If your device is running, shut is down
Power up the device while holding the BACK key
Hold the BACK key until you see a screen with the message Fastboot

The device is now in fastboot mode. The bootloader exists in different version. You can have a version with a rainbow background or one with skating Androids. It doesn’t matter, the flashing will work for both. Of course only when using a Dev Phone, the G1 does not support the flashing part.

The images which will be flashed to your device are inside the ~/mydroid/out/target/product/dream-open directory. So move to that directory and check if the following four images exists

  • boot.img (for booting the device, contains the kernel)
  • system.img (contains the Android framework, drivers, default applications and utilities)
  • userdata.img (used for the userdata storage. You don’t have to flash the userdata partition, so that your data will not be removed. But I got sometimes strange effects when there is still userdata available from a different Android image. )
  • recovery.img (used to restore and update the Android device. Don’t know when this will be used).

You don’t have to flash all partitions on your Android device every time. If you don’t change the kernel than you can skip the boot image. But off course you should flash the boot partition for the first time because it is different than the HTC one.

From the ~/mydroid/out/target/product/dream-open directory, use the following commands to flash the phone

fastboot flash boot boot.img
fastboot flash system system.img
fastboot flash recovery recovery.img
fastboot flash userdata userdata.img

Every fastboot command will send the image first to the device and (after succesfully received) will be written to the specific device partition. After all partitions are flashed succesfully you can reboot the device. This can be done by executing

fastboot reboot

It is also possible to exit fastboot by pressing Menu+CALL+END CALL button on your device.

It’s alive!

The first boot can take some time. You will get an Android splash screen, followed by another (grey logo) Android splash screen. Finally the home screen will be available. The Android system will be different comparing to the HTC version. A summary of what you can do and can’t with your own build.

Can

  • Wifi and bluetooth should work properly (because we added the right driver versions)
  • The Home button will work and you will have the Silent and Airplane option when holding the END CALL button (this is done by the SdkSetup package)
  • The led light should work when you get an SMS or connect the device
  • You should be able to make and receive calls
  • Camera, GPS and all the other sensors should be working fine
  • Start applications like Browser, Calculator, etc
  • Make use of 3G connection
  • Use android in a different language. The HTC version of Android has only the English language pack. Your own version has multiple language support.

Can’t

  • Use the Calendar application. Because this application depends on some Google libraries which are not on the system. I was looking how to seperate the Calendar application so that it is not Google dependent (and submit the source back to the source tree)
  • No Market application.
  • No Google applications (like GMail, GTalk, Maps).
  • No nice ringtones. The media directory which contains all the ringtones which are normally there is not part of the built.
  • No synchronization with Google (like contacts and calendar)

What’s next?

I will write another post about how to add the Google Apps, Market and ringtones to your own build. For now the flashing part is completed (so turn on the lights again :D ). Questions and other feedback can be given to this post.

Blogpost in the Building Android 1.5 serie

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