The XDAndroid Project is no longer active.
This site provides archived information from while the project was under development. Some links may no longer function.

Getting started XDAndroid development

From The XDAndroid Project
Jump to navigation Jump to search

This is a page written for programmers who are interested on developing for XDAndroid, but have no embedded Linux or Android knowledge. It should help you getting started on producing code and fixing bugs in no time.


Supported devices

XDAndroid supports a series of HTC phones based on Qualcomm MSM chipset. Those are the HTC Raphael/Diamond, Topaz, Rhodium, and Blackstone. To find exactly what is your device, open it, remove the battery and look for a model line. For example, the HTC Touch Pro 2 will have this line :

    HTC Touch Pro2 T7373 RHOD100 5VDC = 1A Made in Taiwan
    

It means the device should be identified as RHOD100. Codes vary, such as RHOD400, RHOD500. You have to know your device code in order to properly identify your device for other people and also to find the right configuration/documentation regarding your device's specific hardware.

Check the Supported Devices for more info.


Exploring XDAndroid

These are the parts that make XDAndroid. We will explore each of these topics.

  • The HaRET boot loader
  • Initrd
  • rootfs
  • Modified Linux Kernel for the MSM Chipset
    • A set of add-on Kernel Modules, that can be called by applications
  • A modified Android build
    • A set of proprietary Google/HTC software taken from other sources.


HaRET boot loader

Currently XDAndroid boots from Windows CE. Haret is used as a boot loader. On Windows CE, you should place the Kernel (zImage file), the initrd (initrd.gz file), the special boot parameters (startup.txt file) and HaRET (haret.exe) on the sd card filesystem, in the same directory (usually /andboot), and then run HaRET.exe. The startup.txt file must be changed to pass kernel specific information that will enable/configure your device correctly. The XDAndroidStartup program for Windows Mobile can correctly set the startup.txt file, given your device id code.

Here is the boot sequence for Android :

  1. HaRET starts, and reads the startup.txt file - startup.txt informs the location of kernel, initrd and boot parameters
  2. HaRET loads the kernel and the initrd to the memory
  3. HaRET boots the kernel passing along the parameters
  4. The Kernel mounts the initrd disk on a memory filesystem
  5. Initrd does ???
  6.  ???
  7. Initrd loads the rootfs from the sdcard, mounts it, ans sets it as the new root filesystem
  8.  ???
  9. sistem.ext2
  10.  ????
  11. Android Starts

Initrd

If you don't know what is a initrd and its relation the the kernel, you should read the official Kernel.org initrd documentation. On XDAndroid, the initrd :

  • Prepares the system for the rootfs to be mounted (TODO: Explain what is "prepare the system")
  • Mounts the a new root file system using the rootfs image.
  • TODO: List any other initrd functions

rootfs

  • responsible for the key maps
  • TODO: list other features for rootfs

Qualcomm-S-MSM Linux Kernel

The kernel used by Xdandroid is located at gitorious linux-on-qualcomm-s-msm repo. This Kernel is branched from the google's android kernel, modified to support Qualcom specific hardware. The kernel is responsible for (almost) all the hardware support, including display, camera, wifi, audio, power management, etc. With a proper kernel, even a generic build of Android using the vanilla source code from google should bring up the phone.

Add-on Kernel Modules

A modules-2.6.xxxxxxxx.tar.gz file will most times be packed with the kernel. Those represent some kernel modules that weren't integraded on the kernel either because they are closed source, either because they are hard to integrate, either because they are not used. The wifi kernel module resides on this package, and it is later on loaded and used via the libhardware_legacy on userland. The Netfilter module, with is also not used, will also go into this diretory.


Modified Android Build

Android is composed of multiple software sources that together make up the whole system. Xdandroid uses the official google android repository (git://android.git.kernel.org/) and it's own gittorious repository. To manage the commits/syncs at the same base on different repositories, Android and XDAndroid use a google tool to work with multiple git repositories called Repo.

TODO: Understand how .repo/manifest.xml file really works


The Android build system

On Android, in order to make a port for a specific device, you have to build a Product tree directory and define a product type. Then you have to make a buildspec.mk, containing the new product you have defined on the PRODUCT_TYPE parameter. Then you call the Android build system, and it will automagically create a build for your product on the //out directory. So next we learn more about the Product tree.

The XDAndroid Product Tree

  • xdandroid (company name)
    • msm (board and products folder)
      • Overlay (resources that replace Android original resource files)
      • Tools' ( Set of helper scripts)
        • generate_release_image.sh --- ???
        • release_manifest.sh --- ???
      • AndroidBoard.mk ( board makefile, defines settings for all products using this board)
      • AndroidProducts.mk ( list of all products makefiles in this product folder)
      • apns-conf.xml --- ??? Apparently doesn't get called, TODO: RESEARCH ABOUT THIS FILE
      • BoardConfig.mk
      • bootanimation.zip (nice XDA boot animation)
      • Android.mk
      • CleanSpec.mk --- ???
      • device_msm.mk
      • device_msm_us.mk
      • device_msm_as.mk
      • device_msm_eu.mk
      • egl.cfg
      • froyo.build
      • full_msm.mk
      • generic_msm.mk
      • h2w_headset.kl
      • init.xdandroid.rc
      • kernel
      • media_profiles.xml
      • setup-makefiles.sh
      • system.prop
      • unzip-files.sh
      • vendorsetup.sh
      • product_config.mk
      • system.prop
      • vold.fstab
      • wlan.ko


(ps.: the xandroid folder is located under //device folder)

Product Specific Makefiles

full_msm.mk

Provides definitions for our product. It inherits from a full_product type of android, from device_msm_us.mk ( product definition for a US-based device, AS and EU are also available), and from languages_full.mk (defines support for a wide range of languages. It also sets the PRODUCT_NAME, PRODUCT_DEVICE and PRODUCT_MODEL variables. A valid project file must define those variables.

device_msm_us/as/eu.mk

Inherits from device/common/gps/gps_us/as/eu_supl.mk, device/xdandroid/msm/device_msm.mk.

device_msm.mk

Defines the boot animation, and PRODUCT_MANUFACTURER. Sets our overlay, that is responsible for device settings, auto-backligh adjustment, thether, config_networkLocationProvider, config_geocodeProvider, def_backup_transport, some bluetooth settings, launcher2 settings, and incall touch ui settings.

Also

  • PRODUCT_LOCALES := hdpi ???
  • PRODUCT_PACKAGES += Gallery PinyinIME OpenWnn libWnnEngDic libWnnJpnDic libwnndict ???
  • PRODUCT_COPY_FILES -> frameworks/base/data/etc/* to system/etc/permissions/* ???
  • PRODUCT_PROPERTY_OVERRIDES += ro.opengles.version=65536 ???
  • PRODUCT_COPY_FILES += device/xdandroid/msm/media_profiles.xml:/system/etc/media_profiles.xml

Board Specific Makefiles

BoardConfig.mk

Defines TARGET_BOARD_PLATFORM, TARGET_CPU_ABI, TARGET_ARCH_VARIANT according to our hardware. Since we are using Haret, it sets TARGET_NO_BOOTLOADER. Also sets WITH_JIT and ENABLE_JSC_JIT to use a faster JIT compiler. Sets Wifi, Bluetooth, the size for the generated image files, disables OpenGLES-2 ( our hardware doesn't support it)

Also

  • TARGET_BOOTLOADER_BOARD_NAME := msm ???
  • BOARD_KERNEL_CMDLINE := no_console_suspend=1 ???
  • USE_PV_WINDOWS_MEDIA := false ???
  • BUILD_WITH_FULL_STAGEFRIGHT := true ???


AndroidBoard.mk

Probably the equivalent to Android.mk

Sets the path for our pre-built kernel,

--- ?????? -----

file := $(TARGET_OUT_KEYLAYOUT)/h2w_headset.kl ALL_PREBUILT += $(file) $(file) : $(LOCAL_PATH)/h2w_headset.kl | $(ACP) $(transform-prebuilt-to-target)

file := $(TARGET_ROOT_OUT)/init.xdandroid.rc ALL_PREBUILT += $(file) $(file) : $(LOCAL_PATH)/init.xdandroid.rc | $(ACP) $(transform-prebuilt-to-target)

--- ?????? ----- Includes AndroidBoardVendor.mk - that does a BOARD_GPS_LIBRARIES := librpc and disables CAMERA



system.prop

Sets the LCD pixel density, the default network type (WCDMA ???) and rild.libpath=/lib/froyo/libhtcgeneric-ril.so ???


For convinience, on XDAndroid, the root makefile ( originally at //core/root.mk) was copied to //Makefile. So, to call Android's build system, you call make on the root folder. The build system will load the buildspec.mk file, and create a build based on the parameters on that file, specially the TARGET_PRODUCT parameter. The build system creates the buid on out/product/msm .


 . build/envsetup.sh -- ???

References

Android.com Plataform developer guide Guide showing how to make a path to the official android repo