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
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
). Questions and other feedback can be given to this post.
Blogpost in the Building Android 1.5 serie



WiFi not working, why?
I exact htc closesourced file from adp system.img, but the build image still cannot enable wifi, logcat say "Failed to load Wi-Fi Driver"
I/ActivityManager( 59): Displayed activity com.android.settings/.WirelessSettings: 552 ms
D/SettingsWifiEnabler( 190): Received wifi state changed from Disabled to Enabling
E/WifiService( 59): Failed to load Wi-Fi driver.
D/SettingsWifiEnabler( 190): Received wifi state changed from Enabling to Unknown
flash image from htc cupcake page is fine
should be version problems:
dmesg say:
[ 175.928619] wlan: version magic '2.6.27-00393-g6607056 preempt mod_unload ARMv6 ' should be '2.6.27-00394-gc6c6056 preempt mod_unload ARMv6 '
how to fix?
You are sure that the correct version of wlan.ko is also extracted from the HTC Android 1.5 image? There is already a wlan.ko file inside the vendor/htc/dream directory but this one is not working.
Another question? Did you also build the kernel like I described with using 2.6.27 (and not 2.6.29). There is a difference between those kernels and how they work with the drivers.
I do all steps as your described, kernel is 2.6.27, not 29, the kernel dmesg say:
wlan: version magic ‘2.6.27-00393-g6607056 preempt mod_unload ARMv6 ‘ should be ‘2.6.27-00394-gc6c6056 preempt mod_unload ARMv6 ‘
kernel 2.6.27-00394-gc6c6056
wlan.ko 2.6.27-00393-g6607056
not exact equal
Strange, maybe they changed something in the source tree. When I look at Settings -> About Phone, the Kernel version is 2.6.27.00393-g6607056 just like the wlan.ko module.
I will try to download the source code again (from scratch) to see if there are changes.
Is it possible to change kernel version number and cheat, how?
seems platform/vendor/htc/dream is not possible
Found out that the project is renamed to dream-open. So the line inside the local_manifest.xml should be
<project path="vendor/htc/dream" name="platform/vendor/htc/dream-open" revision="cupcake"/>and to apply the patch you should call
repo download platform/vendor/htc/dream-open 10501Did not performed a build yet with this renamed project. Try to do that tonight. Will also update the blogpost about getting the source if everything is working fine.
Thanks for your quick response, and maybe you should update your blog
Maybe someone can post a Kernel of version 2.6.27.00393-g6607056 to make it works
If everything work fine, I want to make a CHINESE translation of your blog, planning to post on Chinese android forum.
Fine?
A chinese translation would be nice
. If the translation is ready, give me the links so I can make a reference to it.
Chinese Link
http://www.hiapk.com/bbs/thread-7714-1-1.html
but we are still waiting for solving of wlan.ko version incompatible problems
They are changing this in the repository. Like the htc dream project which is now called dream-open. Maybe this has also something to do with your issue.
Did a build today and I got the same wlan.ko errror. I didn't got the issue before. Try to found out how to solve this. The only thing is that i am doing this is my sparetime so it can take some time
Hi, after a long download and finally built...Thanks, Johan.
For the localization, here is what I fond out. Under /mydroid/packages/apps/ directory there are various:
AlarmClock Contacts Launcher Settings VoiceDialer
Browser Email Mms SoundRecorder
Calculator GoogleSearch Music Stk
Calendar HTMLViewer PackageInstaller Sync
Camera IM Phone Updater
When you dig into each app and under /res, you'll be able to see at least 13 languages, starting with English:
values-de values-it values-nb values-ru
values values-es values-ja values-nl values-zh-rCN
values-cs values-fr values-ko values-pl values-zh-rTW
For example, under /mydroid/packages/apps/Email/res/values there is a file called strings.xml
read Email attachments
Allows this application to read your Ema
il attachments.
So to add your language all you have to to is make a copy of English template (values) to your language, for example, for Lao, 'values-lo', where 'lo' is language code for lao. Others will have to check your language code. Then we can translate it accordingly.
Which we can translate each after "> your language goes here........
So the questions are:
1) Where do we add additional locale should one to add a new language? I think that we have to tell the Android load a new locale otherwise it will not shows up under 'Setting/Locale and Text/Select Locale'.
3) Can someone please also check beside these files, what are other files that we need to translate?
I guess this is for now...and hope that we can shed some light on this soon.Let's work on this together.
Cheers,
Anousak
Hi,
I have successful and flashed images onto my G1. However I would like to confirm that WLAN doesn't work.
Question: I just added new fonts and would like to rebuild the image so that it includes new font pack, what is the proper way? I tried to remake it but it doesn't seem to work.
Thanks,
Anousak
Did you try to remove the ~/mydroid/out/target/product/system directory.
rm -rf ~/mydroid/out/target/product/dream/system
And are the new fonts referenced inside a buildscript so that those are copied to the system image?
For those with wlan driver issues:
I have just discovered that the wlan.ko driver is not, in fact, proprietary, and does not need to be copied from the ADP image at all. We can (and should) rebuild it from source when building our own kernel images.
To do this (after building the kernel, before building the rest of the Android system):
cd ~/mydroid/system/wlan/ti/sta_dk_4_0_4_32
export KERNEL_DIR=$HOME/mydroid/kernel
make
cp wlan.ko ~/mydroid/vendor/htc/dream
I've done this myself and now have Wifi working in my custom build with no complaints!
Thanks for sharing how to resolve this wifi issue
Will update the post tonight or tomorrow
how can sign *.img file for flash my Vodafone Htc Magic with fastboot? I must use signapk o similar apps?
Thank you
I build android.
i Sign APK in system/apps and JAR in system/framework
I create update.zip and sign it.
I Send update.zip in sdcard.
I make Wipe and flash update.zip.
When Reboot the phone show Vodafone splash screen but when normaly i see Android logo, the phone reboot and entry automaticaly in recovery.
I Use Htc Magic kernel 2.6.29 recompiled all from me followinf this guide.
How can see the error that reboot my phone?
I must do something different for HTC magic?
Thank you
i try no sign apk and jar (i think no correct), but result not changed.
someone can help me?
I think the hardware of the HTC Magic is different than the HTC Dream. This means that also other drivers are needed. But I don't have a HTC Magic to check out if you can create your own build for it.
Can I follow this to build custom kernel for my T-mobile G1?
i built my own variant of android
using the recovery image method rather than fastboot.
in the sdcard there is update.zip which is the central point for android to recognize the recovery image.
i made changes to my system folder using eclipse residing in mydroid/out/target/product/generic/system (im assuming when u compile in eclipse it updates the changes to your system folder automatically), zipped the folder using the command sudo zip -r update.zip system META-INF radio.img boot.img,
and then signed it sudo java -jar /home/foo/Work/mydroid/out/host/linux-x86/framework/signapk.jar /home/foo/Work/mydroid/build/target/product/security/testkey.x509.pem /home/foo/Work/mydroid/build/target/product/security/testkey.pk8 /home/foo/Work/Bahar/update.zip /home/foo/Work/Bahar/signed-update.zip
when i right it to device in recovery mode i get verification error
am feeling tht problem lies with the update-script please help me
I have a china android tablet, I haven't notice that the device is low battery, I format the device and during the format the device shut down (bec. it is low battery). Now the phone hangs, only ANDROID logo appears on the phone. Is there any way to update the device?
specs:
CPU: MARVELL PXA303 / XSCALE 624MHZ / DDR-RAM 128MB / NAND FLASH 256MB / 800X480 SCREEN RESOLUTION / GOOGLE ANDROID 1.5
The model is M5000 but I haven't seen any thread regarding the said model, can anyone help me please?