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.

Difference between revisions of "Getting started XDAndroid development"

From The XDAndroid Project
Jump to navigation Jump to search
[unchecked revision][pending revision]
 
(15 intermediate revisions by 5 users not shown)
Line 5: Line 5:
 
XDAndroid supports a series of HTC phones based on [http://www.qualcomm.com/products_services/chipsets/mobile_processors.html 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 :
 
XDAndroid supports a series of HTC phones based on [http://www.qualcomm.com/products_services/chipsets/mobile_processors.html 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
+
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.
 
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.
  
Line 18: Line 18:
 
* The [[HaRET]] boot loader
 
* The [[HaRET]] boot loader
 
* Initrd
 
* Initrd
* rootfs
+
* [[rootfs.img|rootfs]]
* Modified Linux Kernel for the MSM Chipset
+
* Modified Linux kernel for the MSM Chipset
** A set of add-on Kernel Modules, that can be called by applications
+
** A set of add-on kernel modules, that can be called by applications
 
* A modified Android build
 
* A modified Android build
 
** A set of proprietary Google/HTC software taken from other sources.
 
** A set of proprietary Google/HTC software taken from other sources.
Line 26: Line 26:
  
 
==[[HaRET]] boot loader==
 
==[[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.
+
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 :
 
Here is the boot sequence for Android :
Line 33: Line 33:
 
# HaRET loads the kernel and the initrd to the memory
 
# HaRET loads the kernel and the initrd to the memory
 
# HaRET boots the kernel passing along the parameters
 
# HaRET boots the kernel passing along the parameters
# The Kernel mounts the initrd disk on a memory filesystem
+
# The kernel mounts the initrd disk on a memory filesystem
 
# Initrd does ???
 
# Initrd does ???
 
# ???
 
# ???
# Initrd loads the rootfs from the sdcard, mounts it, ans sets it as the new root filesystem
+
# Initrd loads the rootfs from the SD card, mounts it, and sets it as the new root filesystem
 
# ???
 
# ???
# sistem.ext2
+
# [[system.ext2]] is mounted at <code>/system</code>
 
# ????
 
# ????
 
# Android Starts
 
# Android Starts
  
 
==Initrd==
 
==Initrd==
If you don't know what is a initrd and its relation the the kernel, you should read [http://www.mjmwired.net/kernel/Documentation/initrd.txt the official Kernel.org initrd documentation]. On XDAndroid, the initrd :  
+
If you don't know what a initrd is, and its relation the the kernel, you should read [http://www.mjmwired.net/kernel/Documentation/initrd.txt 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")
+
*Prepares the system for the rootfs to be mounted (TODO: Explain what "prepare the system" is)
 
*Mounts the a new root file system using the rootfs image.
 
*Mounts the a new root file system using the rootfs image.
 
*TODO: List any other initrd functions
 
*TODO: List any other initrd functions
Line 55: Line 55:
  
 
==Qualcomm-S-MSM Linux Kernel==
 
==Qualcomm-S-MSM Linux Kernel==
The kernel used by Xdandroid is located at [http://gitorious.org/linux-on-qualcomm-s-msm/linux-msm 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.
+
The kernel used by XDAndroid is located at [http://gitorious.org/linux-on-qualcomm-s-msm/linux-msm gitorious linux-on-qualcomm-s-msm repo]. This kernel is branched from Google's Android kernel, modified to support Qualcomm-specific hardware. The kernel is responsible for (almost) all the hardware support, including display, camera, Wi-Fi, 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===
 
===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.
+
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, hard to integrate, or 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 directory.
  
  
 
==Modified Android Build==
 
==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.
+
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 its 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
 
TODO: Understand how .repo/manifest.xml file really works
Line 69: Line 69:
  
 
==The Android build system==
 
==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.
+
Android has a very complex build system. For compiling a port to a specific device, you have to :
 +
 
 +
# Create a Company Directory (ours is xdandroid)
 +
# Create a products and a boards dir (ours it msm)
 +
# Define a product in a .mk file(s) inside the products folder
 +
# Define a board in a .mk file(s) inside the boards folder
 +
# Create mandatory configuration files (such as BoardConfig.mk, AndroidProducts.mk)
 +
# Create a buildspec.mk on the root folder
 +
# call make
 +
 
 +
The Android build system will automagically create a build for your product on the //out directory. It's important to note that everything that gets on the build will be somehow linked or referenced via the definition files, so it's important to understand it, and figure out what it links to. So next we learn more about the XDAndroid company folder.
  
 
===The XDAndroid Product Tree===
 
===The XDAndroid Product Tree===
  
Is located at //device/xandroid/msm. It serves both as an android board folder (has definition for boards) and as an android products folder ( has definition for products). This is what we find in our company folder :  
+
It is located at //device/xandroid/msm. It serves both as an android board folder (has definition for boards) and as an android products folder (has definition for products). This is what we find in our company folder :  
  
 
*'''''Board Config Files :'''''  
 
*'''''Board Config Files :'''''  
**AndroidBoard.mk ( board makefile, defines settings for all products using this board)
+
**AndroidBoard.mk (board makefile, defines settings for all products using this board)
**BoardConfig.mk ( compile-time definitions. TODO : Find out the difference between this file and AndroidBoard.mk)
+
**BoardConfig.mk (compile-time definitions. TODO : Find out the difference between this file and AndroidBoard.mk)
 
*'''''Product Definition Files : '''''
 
*'''''Product Definition Files : '''''
**AndroidProducts.mk ( list of all products makefiles in this product folder)
+
**AndroidProducts.mk (list of all products makefiles in this product folder)
**generic_msm.mk ( another root product define - could be used to make a clean default build)
+
**generic_msm.mk (another root product define - could be used to make a clean default build)
**full_msm.mk ( the main root product define file)
+
**full_msm.mk (the main root product define file)
***device_msm.mk ( gets inherited by full_msm.mk )
+
***device_msm.mk (gets inherited by full_msm.mk )
***device_msm_us/as/eu.mk ( gets inherited by full_msm.mk )
+
***device_msm_us/as/eu.mk (gets inherited by full_msm.mk )
 
*'''''Files that will just get copied to the final build'''''
 
*'''''Files that will just get copied to the final build'''''
 
**Overlay - Directory (resources that replace Android original resource files - copied with overlay definition)
 
**Overlay - Directory (resources that replace Android original resource files - copied with overlay definition)
 
**bootanimation.zip (nice XDA boot animation - to /system/media)
 
**bootanimation.zip (nice XDA boot animation - to /system/media)
 
**apns-conf.xml (complete list of worldwide data connection info. to /system/etc)
 
**apns-conf.xml (complete list of worldwide data connection info. to /system/etc)
**media_profiles.xml ( configuration for media/video/music features. to /system/etc)
+
**media_profiles.xml (configuration for media/video/music features. to /system/etc)
**egl.cfg ( open gl configuration. This should probably go to /system/lib/egl TODO: FIND WHO COPIES IT)
+
**egl.cfg (open gl configuration. Passed to build system by Board Config Files via parameter)
**h2w_headset.kl ( key maps for the USB headset. TODO: find out who copies this)
+
**h2w_headset.kl (key maps for the USB headset. TODO: find out who copies this)
 
**vold.fstab (android fstab, defines that our sdcard should be mounted at /sdcard)
 
**vold.fstab (android fstab, defines that our sdcard should be mounted at /sdcard)
**wlan.ko ( binary, will probably get copied to somewhere TODO : FIND OUT WHO COPIES IT)
+
**wlan.ko (binary, will probably get copied to somewhere TODO : FIND OUT WHO COPIES IT)
**init.xdandroid.rc ( android-init-language init file. TODO: find who copies this)
+
**init.xdandroid.rc (android-init-language init file. TODO: find who copies this)
 
* ''''' Helper Scripts '''''
 
* ''''' Helper Scripts '''''
**Tools - Directory ( Set of helper scripts)
+
**Tools - Directory (Set of helper scripts)
 
***generate_release_image.sh --- ???
 
***generate_release_image.sh --- ???
 
***release_manifest.sh --- ???
 
***release_manifest.sh --- ???
**unzip-files.sh ( extracts all proprietary software (gapps, hw3d, etc) into a //vendor directory)
+
**unzip-files.sh (extracts all proprietary software (gapps, hw3d, etc) into a //vendor directory)
 
**setup-makefiles.sh (seens to be related to including proprietary code in TODO : FIND OUT THAT THIS IS )
 
**setup-makefiles.sh (seens to be related to including proprietary code in TODO : FIND OUT THAT THIS IS )
 
* '''''Other files evaluated by Android Build System'''''
 
* '''''Other files evaluated by Android Build System'''''
**vendorsetup.sh ( called by build/envsetup.sh - adds a lunch option TODO: FIND OUT WHY WE NEED THIS)
+
**vendorsetup.sh (called by build/envsetup.sh - adds a lunch option TODO: FIND OUT WHY WE NEED THIS)
 
**system.prop (modify system properties -  pixel density, etc)
 
**system.prop (modify system properties -  pixel density, etc)
 
* ''''' Empty or all-commented files '''''
 
* ''''' Empty or all-commented files '''''
 
**CleanSpec.mk (comented-out file, in future could be used to define clean-steps for the build system)
 
**CleanSpec.mk (comented-out file, in future could be used to define clean-steps for the build system)
**froyo.build ( Empty file ??? TODO: find out why it exists)
+
**froyo.build (Empty file ??? TODO: find out why it exists)
**kernel ( Empty file ??? TODO: find out why it exists)
+
**kernel (Empty file, if we want to use it, we should set TARGET_PREBUILT_KERNEL to true and copy kernel to this file)
  
  
Line 114: Line 124:
 
====Board Config Files====
 
====Board Config Files====
  
=====BoardConfig.mk=====
+
*They define
Defines TARGET_BOARD_PLATFORM, TARGET_CPU_ABI, TARGET_ARCH_VARIANT according to our hardware.
+
** TARGET_BOARD_PLATFORM, TARGET_CPU_ABI, TARGET_ARCH_VARIANT, TARGET_BOOTLOADER_BOARD_NAME with our string variables
Since we are using Haret, it sets TARGET_NO_BOOTLOADER.
+
** TARGET_NO_BOOTLOADER to True, since we are using HaRET
Also sets WITH_JIT and ENABLE_JSC_JIT to use a faster JIT compiler.
+
** WITH_JIT, ENABLE_JSC_JIT, to use JIT to speedup
Sets Wifi, Bluetooth, the size for the generated image files, disables OpenGLES-2 ( our hardware doesn't support it)
+
** BOARD_WPA_SUPPLICANT_DRIVER, BOARD_WPA_SUPPLICANT_PRIVATE_LIB, BOARD_WLAN_TI_STA_DK_ROOT, WIFI_DRIVER_MODULE_PATH, WIFI_DRIVER_MODULE_ARG, WIFI_DRIVER_MODULE_NAME, WIFI_DRIVER_FW_AP_PATH, WIFI_FIRMWARE_LOADER to correctly set Wifi
 
+
** BOARD_KERNEL_CMDLINE := no_console_suspend=1
Also
+
** BOARD_HAVE_BLUETOOTH := true, BOARD_HAVE_BLUETOOTH_BCM := true # Rhodium has Broadcom bluetooth
* TARGET_BOOTLOADER_BOARD_NAME := msm ???
+
** BOARD_VENDOR_USE_AKMD := true ????
* BOARD_KERNEL_CMDLINE := no_console_suspend=1 ???
+
** USE_PV_WINDOWS_MEDIA := false
* USE_PV_WINDOWS_MEDIA := false ???
+
** BUILD_WITH_FULL_STAGEFRIGHT := true ???
* BUILD_WITH_FULL_STAGEFRIGHT := true ???
+
** BOARD_NO_GL2, BOARD_GL_TEX_POW2_DIMENSION_REQUIRED := true # Our hardware is not OpenGLES-2 capable
 
+
** BOARD_EGL_CFG := device/xdandroid/msm/egl.cfg
 
+
** BOARD_BOOTIMAGE_MAX_SIZE, BOARD_RECOVERYIMAGE_MAX_SIZE, BOARD_SYSTEMIMAGE_MAX_SIZE, BOARD_USERDATAIMAGE_MAX_SIZE, BOARD_FLASH_BLOCK_SIZE
=====AndroidBoard.mk=====
+
** USE_CAMERA_STUB := false
Probably the equivalent to Android.mk
+
** PRODUCT_PROPERTY_OVERRIDES = ro.com.android.dataroaming=false (don't allow data when roaming, a wise setting)
 
+
*They include
Sets the path for our pre-built kernel,  
+
**vendor/xdandroid/msm/BoardConfigVendor.mk
 
+
**vendor/xdandroid/msm/AndroidBoardVendor.mk
--- ?????? -----
+
*They copy
 
+
**h2w_headset.kl to TARGET_OUT_KEYLAYOUT
file := $(TARGET_OUT_KEYLAYOUT)/h2w_headset.kl
+
**init.xdandroid.rc to TARGET_ROOT_OUT
ALL_PREBUILT += $(file)
+
**vold.fstab to /system/etc
$(file) : $(LOCAL_PATH)/h2w_headset.kl | $(ACP)
+
** froyo.build file gets passed on LOCAL_SRC_FILES variable
$(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
 
 
 
 
 
  
 
====Product Definition Files====
 
====Product Definition Files====
 
These are the full_msm.mk, device_msm.mk, device_msm_us/as/eu.mk.
 
These are the full_msm.mk, device_msm.mk, device_msm_us/as/eu.mk.
  
*They inherit from languages_full.mk, making the final build have a full list of languages
+
*They inherit from
*They inherit from full.mk, making our build a "complete" one.
+
**languages_full.mk, making the final build have a full list of languages
*They inherit from device/common/gps/gps_us_supl.mk
+
**full.mk, making our build a "complete" one.
*They inherit from vendor/xdandroid/msm/device_msm_us-vendor.mk
+
**device/common/gps/gps_us_supl.mk (sets us ntp server and google supl server for a-gps lock)
*They inherit from vendor/xdandroid/msm/device_msm-vendor.mk
+
**vendor/xdandroid/msm/device_msm_us-vendor.mk
 +
**vendor/xdandroid/msm/device_msm-vendor.mk
 +
*They define
 +
** PRODUCT_NAME, PRODUCT_DEVICE, PRODUCT_MODEL, PRODUCT_MANUFACTURER with our string settings
 +
**DEVICE_PACKAGE_OVERLAYS with our overlay folder
 +
**PRODUCT_LOCALES to support hdpi screen density
 +
**PRODUCT_PACKAGES  [Gallery,PinyinIME, OpenWnn, libWnnEngDic, libWnnJpnDic, libwnndict]
 +
**PRODUCT_PROPERTY_OVERRIDES, to set the supported opengles version (ro.opengles.version=65536)
 +
*They copy
 +
**frameworks/base/data/etc/ [core_hardware, camera.autofocus, telephony.gsm, location.gps, wifi] to system/etc/permissions/
 +
**media_profiles.xml and apns-conf.xml to /system/etc
 +
**bootanimation.zip to and apns-conf.xml to /system/media
  
*They define PRODUCT_NAME, PRODUCT_DEVICE, PRODUCT_MODEL, PRODUCT_MANUFACTURER with our string settings
+
====Helper Scripts====
*They define DEVICE_PACKAGE_OVERLAYS with our overlay folder
 
*They define PRODUCT_LOCALES to support hdpi screen density
 
*They define PRODUCT_PACKAGES  [Gallery,PinyinIME, OpenWnn, libWnnEngDic, libWnnJpnDic, libwnndict]
 
*They define PRODUCT_PROPERTY_OVERRIDES, to set the supported opengles version (ro.opengles.version=65536)
 
  
*They copy frameworks/base/data/etc/ [core_hardware, camera.autofocus, telephony.gsm, location.gps, wifi] to system/etc/permissions/
+
*generate_release_image.sh --- ???
*They copy media_profiles.xml and apns-conf.xml to /system/etc
+
*release_manifest.sh --- ???
*They copy bootanimation.zip to and apns-conf.xml to /system/media
+
*unzip-files.sh (extracts all proprietary software (gapps, hw3d, etc) into a //vendor directory)
 +
*setup-makefiles.sh (seens to be related to including proprietary code in TODO: FIND OUT THAT THIS IS)
  
====Files that will just get copied to the final build====
 
  
====Helper Scripts====
+
====Other files evaluated by Android Build System====
  
====Other files evaluated by Android Build System====
+
*system.prop
====system.prop====
+
**Sets the LCD pixel density, the default network type (WCDMA ???)  and  
Sets the LCD pixel density, the default network type (WCDMA ???)  and  
+
**rild.libpath=/lib/froyo/libhtcgeneric-ril.so
rild.libpath=/lib/froyo/libhtcgeneric-ril.so ???
+
*build/envsetup.sh -- ???
  
  
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 -- ???
+
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 .
====Empty or all-commented file
 
  
 
==References==
 
==References==
[http://pdk.android.com/online-pdk/guide/index.html Android.com Plataform developer guide]
+
*[http://pdk.android.com/online-pdk/guide/index.html Android.com Plataform developer guide]
[http://www.johandekoning.nl/index.php/2009/06/23/contribute-to-android-my-repogit-adventure/ Guide showing how to make a path to the official android repo]
+
*[http://www.johandekoning.nl/index.php/2009/06/23/contribute-to-android-my-repogit-adventure/ Guide showing how to make a path to the official android repo]
 +
* [http://www.gadgetsdotcom.com Gadgets]

Latest revision as of 14:32, 28 August 2011

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 SD card, mounts it, and sets it as the new root filesystem
  8.  ???
  9. system.ext2 is mounted at /system
  10.  ????
  11. Android Starts

Initrd

If you don't know what a initrd is, 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 "prepare the system" is)
  • 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 Google's Android kernel, modified to support Qualcomm-specific hardware. The kernel is responsible for (almost) all the hardware support, including display, camera, Wi-Fi, 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, hard to integrate, or 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 directory.


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 its 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

Android has a very complex build system. For compiling a port to a specific device, you have to :

  1. Create a Company Directory (ours is xdandroid)
  2. Create a products and a boards dir (ours it msm)
  3. Define a product in a .mk file(s) inside the products folder
  4. Define a board in a .mk file(s) inside the boards folder
  5. Create mandatory configuration files (such as BoardConfig.mk, AndroidProducts.mk)
  6. Create a buildspec.mk on the root folder
  7. call make

The Android build system will automagically create a build for your product on the //out directory. It's important to note that everything that gets on the build will be somehow linked or referenced via the definition files, so it's important to understand it, and figure out what it links to. So next we learn more about the XDAndroid company folder.

The XDAndroid Product Tree

It is located at //device/xandroid/msm. It serves both as an android board folder (has definition for boards) and as an android products folder (has definition for products). This is what we find in our company folder :

  • Board Config Files :
    • AndroidBoard.mk (board makefile, defines settings for all products using this board)
    • BoardConfig.mk (compile-time definitions. TODO : Find out the difference between this file and AndroidBoard.mk)
  • Product Definition Files :
    • AndroidProducts.mk (list of all products makefiles in this product folder)
    • generic_msm.mk (another root product define - could be used to make a clean default build)
    • full_msm.mk (the main root product define file)
      • device_msm.mk (gets inherited by full_msm.mk )
      • device_msm_us/as/eu.mk (gets inherited by full_msm.mk )
  • Files that will just get copied to the final build
    • Overlay - Directory (resources that replace Android original resource files - copied with overlay definition)
    • bootanimation.zip (nice XDA boot animation - to /system/media)
    • apns-conf.xml (complete list of worldwide data connection info. to /system/etc)
    • media_profiles.xml (configuration for media/video/music features. to /system/etc)
    • egl.cfg (open gl configuration. Passed to build system by Board Config Files via parameter)
    • h2w_headset.kl (key maps for the USB headset. TODO: find out who copies this)
    • vold.fstab (android fstab, defines that our sdcard should be mounted at /sdcard)
    • wlan.ko (binary, will probably get copied to somewhere TODO : FIND OUT WHO COPIES IT)
    • init.xdandroid.rc (android-init-language init file. TODO: find who copies this)
  • Helper Scripts
    • Tools - Directory (Set of helper scripts)
      • generate_release_image.sh --- ???
      • release_manifest.sh --- ???
    • unzip-files.sh (extracts all proprietary software (gapps, hw3d, etc) into a //vendor directory)
    • setup-makefiles.sh (seens to be related to including proprietary code in TODO : FIND OUT THAT THIS IS )
  • Other files evaluated by Android Build System
    • vendorsetup.sh (called by build/envsetup.sh - adds a lunch option TODO: FIND OUT WHY WE NEED THIS)
    • system.prop (modify system properties - pixel density, etc)
  • Empty or all-commented files
    • CleanSpec.mk (comented-out file, in future could be used to define clean-steps for the build system)
    • froyo.build (Empty file ??? TODO: find out why it exists)
    • kernel (Empty file, if we want to use it, we should set TARGET_PREBUILT_KERNEL to true and copy kernel to this file)



Board Config Files

  • They define
    • TARGET_BOARD_PLATFORM, TARGET_CPU_ABI, TARGET_ARCH_VARIANT, TARGET_BOOTLOADER_BOARD_NAME with our string variables
    • TARGET_NO_BOOTLOADER to True, since we are using HaRET
    • WITH_JIT, ENABLE_JSC_JIT, to use JIT to speedup
    • BOARD_WPA_SUPPLICANT_DRIVER, BOARD_WPA_SUPPLICANT_PRIVATE_LIB, BOARD_WLAN_TI_STA_DK_ROOT, WIFI_DRIVER_MODULE_PATH, WIFI_DRIVER_MODULE_ARG, WIFI_DRIVER_MODULE_NAME, WIFI_DRIVER_FW_AP_PATH, WIFI_FIRMWARE_LOADER to correctly set Wifi
    • BOARD_KERNEL_CMDLINE := no_console_suspend=1
    • BOARD_HAVE_BLUETOOTH := true, BOARD_HAVE_BLUETOOTH_BCM := true # Rhodium has Broadcom bluetooth
    • BOARD_VENDOR_USE_AKMD := true ????
    • USE_PV_WINDOWS_MEDIA := false
    • BUILD_WITH_FULL_STAGEFRIGHT := true ???
    • BOARD_NO_GL2, BOARD_GL_TEX_POW2_DIMENSION_REQUIRED := true # Our hardware is not OpenGLES-2 capable
    • BOARD_EGL_CFG := device/xdandroid/msm/egl.cfg
    • BOARD_BOOTIMAGE_MAX_SIZE, BOARD_RECOVERYIMAGE_MAX_SIZE, BOARD_SYSTEMIMAGE_MAX_SIZE, BOARD_USERDATAIMAGE_MAX_SIZE, BOARD_FLASH_BLOCK_SIZE
    • USE_CAMERA_STUB := false
    • PRODUCT_PROPERTY_OVERRIDES = ro.com.android.dataroaming=false (don't allow data when roaming, a wise setting)
  • They include
    • vendor/xdandroid/msm/BoardConfigVendor.mk
    • vendor/xdandroid/msm/AndroidBoardVendor.mk
  • They copy
    • h2w_headset.kl to TARGET_OUT_KEYLAYOUT
    • init.xdandroid.rc to TARGET_ROOT_OUT
    • vold.fstab to /system/etc
    • froyo.build file gets passed on LOCAL_SRC_FILES variable

Product Definition Files

These are the full_msm.mk, device_msm.mk, device_msm_us/as/eu.mk.

  • They inherit from
    • languages_full.mk, making the final build have a full list of languages
    • full.mk, making our build a "complete" one.
    • device/common/gps/gps_us_supl.mk (sets us ntp server and google supl server for a-gps lock)
    • vendor/xdandroid/msm/device_msm_us-vendor.mk
    • vendor/xdandroid/msm/device_msm-vendor.mk
  • They define
    • PRODUCT_NAME, PRODUCT_DEVICE, PRODUCT_MODEL, PRODUCT_MANUFACTURER with our string settings
    • DEVICE_PACKAGE_OVERLAYS with our overlay folder
    • PRODUCT_LOCALES to support hdpi screen density
    • PRODUCT_PACKAGES [Gallery,PinyinIME, OpenWnn, libWnnEngDic, libWnnJpnDic, libwnndict]
    • PRODUCT_PROPERTY_OVERRIDES, to set the supported opengles version (ro.opengles.version=65536)
  • They copy
    • frameworks/base/data/etc/ [core_hardware, camera.autofocus, telephony.gsm, location.gps, wifi] to system/etc/permissions/
    • media_profiles.xml and apns-conf.xml to /system/etc
    • bootanimation.zip to and apns-conf.xml to /system/media

Helper Scripts

  • generate_release_image.sh --- ???
  • release_manifest.sh --- ???
  • unzip-files.sh (extracts all proprietary software (gapps, hw3d, etc) into a //vendor directory)
  • setup-makefiles.sh (seens to be related to including proprietary code in TODO: FIND OUT THAT THIS IS)


Other files evaluated by Android Build System

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



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 .

References