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



The HTCCamera.apk package needs a different shared library
07-20 20:18:46.153: ERROR/PackageManager(78): Package com.android.camera requires unavailable shared library com.htc.framework; ignoring!
jekyll says:
July 19, 2009 at 6:01 pm
i have this error when building wifi module:
jekyll@jekyll-desktop:~/mydroid/system/wlan/ti/sta_dk_4_0_4_32$ make
rm -f ./libestadrv.a
make -C /home/jekyll/mydroid/kernel/ M=`pwd` ARCH=arm CROSS_COMPILE=arm-eabi- modules
make[1]: ingresso nella directory «/home/jekyll/mydroid/kernel»
CC [M] /home/jekyll/mydroid/system/wlan/ti/sta_dk_4_0_4_32/./pform/linux/src/esta_drv.o
/home/jekyll/mydroid/system/wlan/ti/sta_dk_4_0_4_32/./pform/linux/src/esta_drv.c: In function ‘tiwlan_drv_net_open’:
/home/jekyll/mydroid/system/wlan/ti/sta_dk_4_0_4_32/./pform/linux/src/esta_drv.c:497: error: ’struct net_device’ has no member named ‘priv’
--------------------------
It looks like some codes workround in donut branch, but not in 1.5r2.
I added some new lines in .repo/local_manifest.xml,like these:
It's compiled successful.
Sorry,the code have been blocked.
Here they are:
<remove-project name="platform/system/wlan/ti"/>
<project path="system/wlan/ti" name="platform/system/wlan/ti" revision="refs/heads/donut"/>
<remove-project name="platform/external/wpa_supplicant"/>
<project path="external/wpa_supplicant" name="platform/external/wpa_supplicant" revision="refs/heads/donut"/>
<remove-project name="platform/external/dhcpcd"/>
<project path="external/dhcpcd" name="platform/external/dhcpcd" revision="refs/heads/donut"/>
Which kernel are you using? Because I did a new build yesterday with the cupcake-release and kernel 2.6.27 and did not have this problem.
Issues with the 2.6.29 kernel on the HTC Dream is that the camera is not working
I believe its a kernel thing, because I also can't get the HTC Camera to work. Always force close. PDFReader is working and Superuser app is working.
Kernel building does not work for me:
scripts/kconfig/conf -s arch/arm/Kconfig
CHK include/linux/version.h
make[1]: `include/asm-arm/mach-types.h' is up to date.
CHK include/linux/utsrelease.h
SYMLINK include/asm -> include/asm-arm
CALL scripts/checksyscalls.sh
:1097:2: warning: #warning syscall fadvise64 not implemented
:1265:2: warning: #warning syscall migrate_pages not implemented
:1321:2: warning: #warning syscall pselect6 not implemented
:1325:2: warning: #warning syscall ppoll not implemented
:1365:2: warning: #warning syscall epoll_pwait not implemented
HOSTCC scripts/mod/mk_elfconfig
scripts/mod/mk_elfconfig.c:4:17: error: elf.h: No such file or directory
scripts/mod/mk_elfconfig.c: In function 'main':
scripts/mod/mk_elfconfig.c:9: error: 'EI_NIDENT' undeclared (first use in this function)
scripts/mod/mk_elfconfig.c:9: error: (Each undeclared identifier is reported only once
scripts/mod/mk_elfconfig.c:9: error: for each function it appears in.)
scripts/mod/mk_elfconfig.c:19: error: 'ELFMAG' undeclared (first use in this function)
scripts/mod/mk_elfconfig.c:19: error: 'SELFMAG' undeclared (first use in this function)
scripts/mod/mk_elfconfig.c:23: error: 'EI_CLASS' undeclared (first use in this function)
scripts/mod/mk_elfconfig.c:24: error: 'ELFCLASS32' undeclared (first use in this function)
scripts/mod/mk_elfconfig.c:27: error: 'ELFCLASS64' undeclared (first use in this function)
scripts/mod/mk_elfconfig.c:33: error: 'EI_DATA' undeclared (first use in this function)
scripts/mod/mk_elfconfig.c:34: error: 'ELFDATA2LSB' undeclared (first use in this function)
scripts/mod/mk_elfconfig.c:37: error: 'ELFDATA2MSB' undeclared (first use in this function)
scripts/mod/mk_elfconfig.c:9: warning: unused variable 'ei'
make[2]: *** [scripts/mod/mk_elfconfig] Error 1
make[1]: *** [scripts/mod] Error 2
make: *** [scripts] Error 2
It also asks a loooot of config questions and I'm never quite sure how I should answer...
Hi,
Are we heading to Donut build soon? I've some stuff from here.
http://forum.xda-developers.com/showthread.php?t=540740
Regards,
Anousak
Hi,
Are we heading to Donut build soon? I've read some stuff from here:
http://forum.xda-developers.com/showthread.php?t=540740
Cheers,
Anousak
I seem to have a similar issue as Christian T:
scripts/kconfig/conf -o arch/arm/Kconfig
#
# configuration written to .config
#
scripts/kconfig/conf -s arch/arm/Kconfig
CHK include/linux/version.h
make[1]: `include/asm-arm/mach-types.h' is up to date.
CHK include/linux/utsrelease.h
CALL scripts/checksyscalls.sh
sed: 4: "/^\#define/ { s/[^_]*__ ...": bad flag in substitute command: '}'
HOSTCC scripts/mod/mk_elfconfig
scripts/mod/mk_elfconfig.c:4:17: error: elf.h: No such file or directory
scripts/mod/mk_elfconfig.c: In function ‘main’:
scripts/mod/mk_elfconfig.c:9: error: ‘EI_NIDENT’ undeclared (first use in this function)
scripts/mod/mk_elfconfig.c:9: error: (Each undeclared identifier is reported only once
scripts/mod/mk_elfconfig.c:9: error: for each function it appears in.)
scripts/mod/mk_elfconfig.c:19: error: ‘ELFMAG’ undeclared (first use in this function)
scripts/mod/mk_elfconfig.c:19: error: ‘SELFMAG’ undeclared (first use in this function)
scripts/mod/mk_elfconfig.c:23: error: ‘EI_CLASS’ undeclared (first use in this function)
scripts/mod/mk_elfconfig.c:24: error: ‘ELFCLASS32’ undeclared (first use in this function)
scripts/mod/mk_elfconfig.c:27: error: ‘ELFCLASS64’ undeclared (first use in this function)
scripts/mod/mk_elfconfig.c:33: error: ‘EI_DATA’ undeclared (first use in this function)
scripts/mod/mk_elfconfig.c:34: error: ‘ELFDATA2LSB’ undeclared (first use in this function)
scripts/mod/mk_elfconfig.c:37: error: ‘ELFDATA2MSB’ undeclared (first use in this function)
scripts/mod/mk_elfconfig.c:9: warning: unused variable ‘ei’
make[2]: *** [scripts/mod/mk_elfconfig] Error 1
make[1]: *** [scripts/mod] Error 2
make: *** [scripts] Error 2
Which OS are you using?
Seems I can build the kernel just fine, but when I do a make, I get a stop error that seems to be related to the emulator:
make: *** [out/host/linux-x86/obj/executables/emulator_intermediates/android/skin/window.o] Error 1
...any ideas?
You did not forget the buildspec.mk file inside ~/mydroid?
emulator_intermediates/android/skin/window.o] Error 1
and i checked the buildspec.mk file... it is as it should be...
Hello Johan,
While performing the 'make" for the initial build, it looks like the make stops/hangs - see text output below. Any ideas? My setup is almost identical to yours. Ubuntu 8.04 running on VMWARE.
------
build/core/product_config.mk:261: WARNING: adding test OTA key
============================================
TARGET_PRODUCT=htc_dream
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=
============================================
build/core/Makefile:17: warning: overriding commands for target `out/target/product/dream-open/system/etc/apns-conf.xml'
build/core/Makefile:17: warning: ignoring old commands for target `out/target/product/dream-open/system/etc/apns-conf.xml'
build/core/Makefile:17: warning: overriding commands for target `out/target/product/dream-open/system/lib/libjni_pinyinime.so'
build/core/base_rules.mk:384: warning: ignoring old commands for target `out/target/product/dream-open/system/lib/libjni_pinyinime.so'
build/core/Makefile:17: warning: overriding commands for target `out/target/product/dream-open/system/etc/wifi/tiwlan.ini'
build/core/base_rules.mk:384: warning: ignoring old commands for target `out/target/product/dream-open/system/etc/wifi/tiwlan.ini'
build/core/Makefile:17: warning: overriding commands for target `out/target/product/dream-open/system/lib/hw/lights.msm7k.so'
build/core/base_rules.mk:384: warning: ignoring old commands for target `out/target/product/dream-open/system/lib/hw/lights.msm7k.so'
No private recovery resources for TARGET_DEVICE dream-open
make: execvp: /bin/bash: Argument list too long
target Dex: core-tests
------
I have stopped and restarted the make with the same results.
Thanks,
Jeff
How long did you wait before you stopped the build process? Some parts of compiling can take some time.
Hi
Even after following the steps as it is, the crash at boot time is happening.
I am following the 'yaffs' method to get the Proprietary binaries as mentioned on http://www.johandekoning.nl/index.php/2009/06/07/building-android-15-getting-the-source/.I could not get signed-dream_devphone_userdebug-img-148830.zip on http://www.htc.com/www/support/android/adp.html, I have used signed-dream_devphone_userdebug-img-150275.zip instead of that.
The complete build is successful, however at boot time the below message gets printed; and phone boots in a repetitive manner.
I/ActivityThread( 102): Publishing provider sync: android.content.SyncProvider
I/SystemServer( 102): Starting Battery Service.
I/SystemServer( 102): Starting Hardware Service.
W/HAL ( 102): load: module=/system/lib/hw/lights.trout.so error=Cannot find library
W/HAL ( 102): load: module=/system/lib/hw/lights.trout.so error=Cannot find library
E/ActivityThread( 102): Failed to find provider info for settings
W/dalvikvm( 102): threadid=31: thread exiting with uncaught exception (group=0x4000fe70)
E/AndroidRuntime( 102): Uncaught handler: thread PowerManagerService exiting due to uncaught exception
E/AndroidRuntime( 102): *** EXCEPTION IN SYSTEM PROCESS. System will crash.
E/AndroidRuntime( 102): java.lang.NullPointerException
E/AndroidRuntime( 102): at android.content.ContentQueryMap.(ContentQueryMap.java:65)
E/AndroidRuntime( 102): at com.android.server.PowerManagerService.initInThread(PowerManagerService.java:414)
E/AndroidRuntime( 102): at com.android.server.PowerManagerService$1.onLooperPrepared(PowerManagerService.java:374)
E/AndroidRuntime( 102): at android.os.HandlerThread.run(HandlerThread.java:59)
E/AndroidRuntime( 102): Crash logging skipped, no checkin service
Any Guess...
I made a build yesterday (which went succesfully) but did not yet flashed it to my phone. Will try that tonight/tomorrow.
I'm on Mac OSX 10.5.7
Checked out kernel 2.6.29 (But error does not seem to be realated to kernel version)
Also, it would be great to get some more info about the .config file. As I said, I get a lot of config questions and I want to get the kernel as lean and clean as possible so is there a possibility to optimize the kernel at build time? (I read something about a -O2 argument) Are there some .config settings to optimize the kernel further for the G1?
I made a post here: http://forum.xda-developers.com/showthread.php?p=4220511#post4220511 but sadly no one answered yet
Your guide is really awesome and I hope you'll adjust it to donut (especially all the Google Apps including build script) after it's release. Maybe a whole post about optimizing the android and kernel build would be something to add to these posts.
I could not get a build working with the 2.6.29 kernel. I still use 2.6.27 when building Cupcake
Thanks for your good tutorials!
Some one asked for localization. Just add to #Overrides in vendor/htc/dream-open/htc_dream.mk a PRODUCT_LOCALES
For example for us, de, zh and ru locale you have to add:
PRODUCT_LOCALES := \
en_US \
de_DE \
zh_CN \
ru_RU \
Thank you for your post.
I made a build with cupcake-release and kernel 2.6.27 for my ADP1(dream) yesterday, but the Camcorder App is not working, always asked me to force cloase, the error msg is "Activity Camcorder (in application Camera) is not responding.".
I also flashed the offical HTC Dream ROM in my ADP1, the Camcorder App is OK.
Can you give me any ideas?
Thanks,
Your instructions are not correct. I just got the code from the repository and there is no such directory ~/mydroid/kernel
@Tomas
You need to include the kernel directory in .repo
Create local_manifest.xml and follow the instructions under Johan's Getting the Source: Repo configuration changes for Android Dev Phone article.
That includes the kernel directory in the repo sync.
Alternatively, you can download it yourself by creating the directory and getting it via git.