Difference between revisions of "CM-QS600: Android: Building from source code"
(New page: === This section is under construction. === Category:Android Category:CM-QS600) |
|||
Line 1: | Line 1: | ||
− | == | + | = Prerequisites = |
+ | The required steps, as outlined below, were tested on Ubuntu 14.04 (Trusty).<br/> | ||
+ | Install required packages, as outlined on [http://source.android.com/source/initializing.html#installing-required-packages-ubuntu-1404 AOSP web-page].<br/> | ||
+ | Install additional packages (not listed on AOSP web-page): | ||
+ | $ sudo apt-get install xz-utils make flex lib32z1 zip | ||
+ | = Getting Android Source Code = | ||
+ | == Overview == | ||
+ | CompuLab Android package is obtained by applying CompuLab patches on top of Code Aurora Forum's Android package for MSM APQ8064 CDP platform. | ||
+ | |||
+ | == Download software packages == | ||
+ | Proceed to CM-QS600 [http://compulab.co.il/products/computer-on-modules/cm-qs600/#devres Downloads] page in order to acquire the following software packages: | ||
+ | * '''Qualcomm proprietary libraries''' | ||
+ | : Prebuilt Qualcomm proprietary libraries. | ||
+ | * '''CompuLab patches on top of Android for MSM APQ8064''' | ||
+ | : CompuLab patches on top of Android source code tree include, among other, Linux kernel patches, Android device configuration files and firmware binary blobs. | ||
+ | |||
+ | == Deploy Android source code repository == | ||
+ | === Code Aurora Forum base === | ||
+ | Download the code base from Code Aurora Forum (CAF): | ||
+ | $ mkdir myandroid | ||
+ | $ cd myandroid | ||
+ | $ repo init -u git://codeaurora.org/platform/manifest.git -b release -m '''LNX.LA.2.7-06310-8064.0.xml''' --repo-url=git://codeaurora.org/tools/repo.git --repo-branch=caf-stable | ||
+ | $ repo sync -j4 | ||
+ | $ repo forall -c "git checkout -b codeaurora" | ||
+ | |||
+ | {{Note | The last instruction maintains git branch naming convention, which is useful for clarity, but is not strictly necessary.}} | ||
+ | |||
+ | === Qualcomm proprietary prebuilt libraries === | ||
+ | Extract prebuilt Qualcomm proprietary libraries: | ||
+ | $ mkdir -p myandroid/vendor/qcom/proprietary | ||
+ | $ tar -xJf cm-qs600-qcom-proprietary.tar.xz -C myandroid/vendor/qcom/proprietary | ||
+ | |||
+ | === CompuLab patch === | ||
+ | Apply CompuLab patch: | ||
+ | $ mkdir -p /tmp/sandbox | ||
+ | $ tar -xJf cm-qs600-compulab-patch.tar.xz -C /tmp/sandbox | ||
+ | $ cd myandroid | ||
+ | $ /tmp/sandbox/compulab-patch-apply /tmp/sandbox | ||
+ | |||
+ | === Wireless kernel driver === | ||
+ | Clone out of tree wireless kernel driver: | ||
+ | $ cd myandroid/external | ||
+ | $ git clone --branch upstream https://github.com/compulab/cm-qs600-compat-wireless.git compat-wireless | ||
+ | |||
+ | == Building Android image == | ||
+ | $ cd myandroid | ||
+ | $ export USE_CCACHE=1 | ||
+ | $ source build/envsetup.sh | ||
+ | $ choosecombo 1 bellatrix 3 | ||
+ | $ make -j4 BUILD_ID=CM-QS600 BUILD_NUMBER=20140901 | ||
+ | |||
+ | In case Java version different from the system default, is required by the build system, download the required JDK version, and export path to its root directory: | ||
+ | $ export JAVA_HOME=<full path to JDK> | ||
+ | |||
+ | While the '''make''' instruction above builds the whole Android image, including all its partitions, it is possible to build '''boot''' partition only, which is useful for most Android hacking as the '''boot''' partition contains the '''kernel''' and the '''ramfs''' with most configuration files: | ||
+ | ==== Bring up kernel configuration menu ==== | ||
+ | $ make kernelconfig | ||
+ | |||
+ | ==== Build boot image (kernel + initramfs) ==== | ||
+ | $ make bootimage -j4 | ||
+ | |||
+ | == Summary == | ||
+ | Upon successful build, the output directory (<code> myandroid/out/target/product/bellatrix </code>) contains ready to deploy OS partitions represented both as directories with appropriate files and compressed image files ready to deploy on eMMC: | ||
+ | {| class="wikitable" border="1" cellspacing="0" | ||
+ | ! partition<br/>name | ||
+ | ! directory | ||
+ | ! image file | ||
+ | ! file system<br/>type | ||
+ | ! access | ||
+ | ! mount point | ||
+ | ! default<br/>partition<br/>size [MB] | ||
+ | ! designation | ||
+ | ! notes | ||
+ | |- | ||
+ | | boot | ||
+ | | root | ||
+ | | boot.img | ||
+ | | style="text-align:center;" | - | ||
+ | | read only | ||
+ | | style="text-align:center;" | - | ||
+ | | 20 | ||
+ | | kernel, ramdisk | ||
+ | | style="text-align:center;" | - | ||
+ | |- | ||
+ | | recovery | ||
+ | | recovery | ||
+ | | recovery.img | ||
+ | | style="text-align:center;" | - | ||
+ | | read only | ||
+ | | style="text-align:center;" | - | ||
+ | | 20 | ||
+ | | alternative to ''boot'' for recovery and upgrade | ||
+ | | currently not in use | ||
+ | |- | ||
+ | | system | ||
+ | | system | ||
+ | | system.img | ||
+ | | style="text-align:center;" | ext4 | ||
+ | | read only | ||
+ | | /system | ||
+ | | 512 | ||
+ | | the entire OS:<br/> | ||
+ | Android UI, system applications | ||
+ | | style="text-align:center;" | - | ||
+ | |- | ||
+ | | cache | ||
+ | | cache | ||
+ | | cache.img | ||
+ | | style="text-align:center;" | ext4 | ||
+ | | read / write | ||
+ | | /cache | ||
+ | | 64 | ||
+ | | frequently accessed data cache | ||
+ | | style="text-align:center;" | - | ||
+ | |- | ||
+ | | userdata | ||
+ | | data | ||
+ | | userdata.img | ||
+ | | style="text-align:center;" | ext4 | ||
+ | | read / write | ||
+ | | /data | ||
+ | | 2048 | ||
+ | | user applications and content | ||
+ | | style="text-align:center;" | - | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | = Deploying Android Image on Target Medium = | ||
+ | == Overview == | ||
+ | In normal boot mode, the root of the file system is mounted from RAM-disk, whereas storage device partitions containing system utilities, applications and data are mounted under it.<br/> | ||
+ | Root on a physical device, or file system mounted via NFS are also viable options, but are used mainly throughout development stage.<br/> | ||
+ | LK bootloader expects a valid boot partition ('''boot.img''') on the eMMC. ''System'', ''userdata'' and ''cache'' partitions mounting is ruled by ''fstab'' file - they can reside on any available storage device.<br/> | ||
+ | In case LK does not identify a valid boot partition on the eMMC, it falls back to [[Android: Fastboot setup | ''fastboot mode'']], where it is possible, along with other options, to load ''boot.img'' dynamically from PC workstation. | ||
+ | |||
+ | === [[CM-QS600: Android: Getting started#Installation onto eMMC | Deploy file system on eMMC]] === | ||
+ | * Enter ''fastboot mode''. | ||
+ | * Flash each partition image file to the eMMC with the aid of ''fastboot'' utility: | ||
+ | <pre> | ||
+ | $ fastboot flash boot boot.img | ||
+ | $ fastboot flash system system.img | ||
+ | $ fastboot flash cache cache.img | ||
+ | $ fastboot flash userdata userdata.img | ||
+ | </pre> | ||
+ | |||
+ | === Deploy file system on SD-card === | ||
+ | ==== Prepare SD-card ==== | ||
+ | * [http://linux.die.net/man/8/gdisk GPT-partition] SD-card, creating ''system'', ''cache'', ''userdata'' partitions. | ||
+ | * Format each partition with ''ext4'' file system. | ||
+ | * Copy ''system'' partition contents, maintaining proper file permissions: | ||
+ | $ cp -a ${OUT}/system/* ${SYSTEM}/. | ||
+ | $ for f in `find ${SYSTEM}`; do [ -f ${f} ] && chmod go-w ${f}; [ `echo ${f} | awk /\.so$/` ] && chmod a-x ${f}; done | ||
+ | |||
+ | ==== Re-build ''boot.img'' with patched ''fstab'' ==== | ||
+ | * Edit ''device/qcom/bellatrix/fstab.qcom'' file, in order to override default destination medium device: | ||
+ | <pre> | ||
+ | #boot time mount | ||
+ | - /dev/block/platform/msm_sdcc.1/by-name/system /system ext4 ro,barrier=1 wait | ||
+ | + /dev/block/platform/msm_sdcc.3/by-name/system /system ext4 ro,barrier=1 wait | ||
+ | - /dev/block/platform/msm_sdcc.1/by-name/cache /cache ext4 nosuid,nodev,noatime,barrier=1 wait,check | ||
+ | + /dev/block/platform/msm_sdcc.3/by-name/cache /cache ext4 nosuid,nodev,noatime,barrier=1 wait,check | ||
+ | - /dev/block/platform/msm_sdcc.1/by-name/userdata /data ext4 nosuid,nodev,noatime,barrier=1,noauto_da_alloc wait,check,length=1073741824,encryptable=footer | ||
+ | + /dev/block/platform/msm_sdcc.3/by-name/userdata /data ext4 nosuid,nodev,noatime,barrier=1,noauto_da_alloc wait,check,length=1073741824,encryptable=footer | ||
+ | </pre> | ||
+ | |||
+ | * Rebuild ''boot.img'': | ||
+ | $ make bootimage -j4 | ||
+ | |||
+ | ==== Flash ''boot.img'' onto eMMC ==== | ||
+ | As pointed out above, ''boot.img'' has to reside on the eMMC, flash it via ''fastboot'' utility: | ||
+ | $ fastboot flash boot boot.img | ||
+ | |||
+ | = See Also = | ||
+ | * [https://www.codeaurora.org CodeAurora Forum website] | ||
+ | * [http://source.android.com/source/building.html Android|Downloading and Building] | ||
+ | * [http://source.android.com/source/developing.html Android|Developing with Repo and Git] | ||
+ | * [http://source.android.com/devices/index.html Android|Subsystems explained] | ||
+ | * [http://www.kandroid.org/online-pdk/guide/build_system.html AOSP|Android Build System] | ||
[[Category:Android]] | [[Category:Android]] | ||
[[Category:CM-QS600]] | [[Category:CM-QS600]] |
Revision as of 12:56, 19 March 2015
Contents
Prerequisites
The required steps, as outlined below, were tested on Ubuntu 14.04 (Trusty).
Install required packages, as outlined on AOSP web-page.
Install additional packages (not listed on AOSP web-page):
$ sudo apt-get install xz-utils make flex lib32z1 zip
Getting Android Source Code
Overview
CompuLab Android package is obtained by applying CompuLab patches on top of Code Aurora Forum's Android package for MSM APQ8064 CDP platform.
Download software packages
Proceed to CM-QS600 Downloads page in order to acquire the following software packages:
- Qualcomm proprietary libraries
- Prebuilt Qualcomm proprietary libraries.
- CompuLab patches on top of Android for MSM APQ8064
- CompuLab patches on top of Android source code tree include, among other, Linux kernel patches, Android device configuration files and firmware binary blobs.
Deploy Android source code repository
Code Aurora Forum base
Download the code base from Code Aurora Forum (CAF):
$ mkdir myandroid $ cd myandroid $ repo init -u git://codeaurora.org/platform/manifest.git -b release -m LNX.LA.2.7-06310-8064.0.xml --repo-url=git://codeaurora.org/tools/repo.git --repo-branch=caf-stable $ repo sync -j4 $ repo forall -c "git checkout -b codeaurora"
The last instruction maintains git branch naming convention, which is useful for clarity, but is not strictly necessary. |
Qualcomm proprietary prebuilt libraries
Extract prebuilt Qualcomm proprietary libraries:
$ mkdir -p myandroid/vendor/qcom/proprietary $ tar -xJf cm-qs600-qcom-proprietary.tar.xz -C myandroid/vendor/qcom/proprietary
CompuLab patch
Apply CompuLab patch:
$ mkdir -p /tmp/sandbox $ tar -xJf cm-qs600-compulab-patch.tar.xz -C /tmp/sandbox $ cd myandroid $ /tmp/sandbox/compulab-patch-apply /tmp/sandbox
Wireless kernel driver
Clone out of tree wireless kernel driver:
$ cd myandroid/external $ git clone --branch upstream https://github.com/compulab/cm-qs600-compat-wireless.git compat-wireless
Building Android image
$ cd myandroid $ export USE_CCACHE=1 $ source build/envsetup.sh $ choosecombo 1 bellatrix 3 $ make -j4 BUILD_ID=CM-QS600 BUILD_NUMBER=20140901
In case Java version different from the system default, is required by the build system, download the required JDK version, and export path to its root directory:
$ export JAVA_HOME=<full path to JDK>
While the make instruction above builds the whole Android image, including all its partitions, it is possible to build boot partition only, which is useful for most Android hacking as the boot partition contains the kernel and the ramfs with most configuration files:
$ make kernelconfig
Build boot image (kernel + initramfs)
$ make bootimage -j4
Summary
Upon successful build, the output directory ( myandroid/out/target/product/bellatrix
) contains ready to deploy OS partitions represented both as directories with appropriate files and compressed image files ready to deploy on eMMC:
partition name |
directory | image file | file system type |
access | mount point | default partition size [MB] |
designation | notes |
---|---|---|---|---|---|---|---|---|
boot | root | boot.img | - | read only | - | 20 | kernel, ramdisk | - |
recovery | recovery | recovery.img | - | read only | - | 20 | alternative to boot for recovery and upgrade | currently not in use |
system | system | system.img | ext4 | read only | /system | 512 | the entire OS: Android UI, system applications |
- |
cache | cache | cache.img | ext4 | read / write | /cache | 64 | frequently accessed data cache | - |
userdata | data | userdata.img | ext4 | read / write | /data | 2048 | user applications and content | - |
Deploying Android Image on Target Medium
Overview
In normal boot mode, the root of the file system is mounted from RAM-disk, whereas storage device partitions containing system utilities, applications and data are mounted under it.
Root on a physical device, or file system mounted via NFS are also viable options, but are used mainly throughout development stage.
LK bootloader expects a valid boot partition (boot.img) on the eMMC. System, userdata and cache partitions mounting is ruled by fstab file - they can reside on any available storage device.
In case LK does not identify a valid boot partition on the eMMC, it falls back to fastboot mode, where it is possible, along with other options, to load boot.img dynamically from PC workstation.
Deploy file system on eMMC
- Enter fastboot mode.
- Flash each partition image file to the eMMC with the aid of fastboot utility:
$ fastboot flash boot boot.img $ fastboot flash system system.img $ fastboot flash cache cache.img $ fastboot flash userdata userdata.img
Deploy file system on SD-card
Prepare SD-card
- GPT-partition SD-card, creating system, cache, userdata partitions.
- Format each partition with ext4 file system.
- Copy system partition contents, maintaining proper file permissions:
$ cp -a ${OUT}/system/* ${SYSTEM}/. $ for f in `find ${SYSTEM}`; do [ -f ${f} ] && chmod go-w ${f}; [ `echo ${f} | awk /\.so$/` ] && chmod a-x ${f}; done
Re-build boot.img with patched fstab
- Edit device/qcom/bellatrix/fstab.qcom file, in order to override default destination medium device:
#boot time mount - /dev/block/platform/msm_sdcc.1/by-name/system /system ext4 ro,barrier=1 wait + /dev/block/platform/msm_sdcc.3/by-name/system /system ext4 ro,barrier=1 wait - /dev/block/platform/msm_sdcc.1/by-name/cache /cache ext4 nosuid,nodev,noatime,barrier=1 wait,check + /dev/block/platform/msm_sdcc.3/by-name/cache /cache ext4 nosuid,nodev,noatime,barrier=1 wait,check - /dev/block/platform/msm_sdcc.1/by-name/userdata /data ext4 nosuid,nodev,noatime,barrier=1,noauto_da_alloc wait,check,length=1073741824,encryptable=footer + /dev/block/platform/msm_sdcc.3/by-name/userdata /data ext4 nosuid,nodev,noatime,barrier=1,noauto_da_alloc wait,check,length=1073741824,encryptable=footer
- Rebuild boot.img:
$ make bootimage -j4
Flash boot.img onto eMMC
As pointed out above, boot.img has to reside on the eMMC, flash it via fastboot utility:
$ fastboot flash boot boot.img