Utilite: Android: Building from source code

From Utilite Wiki

Jump to: navigation, search

Contents

Prerequisites

The required steps, as outlined below, were tested on Ubuntu 12.04 (Precise).
Install required packages, as outlined on AOSP web-page.
Install additional packages (not listed on AOSP web-page):

$ sudo apt-get install u-boot-tools uuid-dev zlib1g-dev liblzo2-dev realpath bc

Getting Android Source Code

Overview

CompuLab Android package is obtained by applying CompuLab patches on top of Freescale Android package for Sabre-SD platform.

Download software packages

Freescale Android package for Sabre-SD platform

Run-time Software
Operating System Software-Board Support Packages
IMX6_JB43_110_ANDROID_SOURCE_BSP

Freescale AACP CODEC

Run-time Software
Middleware-Codecs and other Algorithms
IMX6_JB43_110_AACP_CODEC_CODA

Freescale documentation relevant for installing Android on Sabre-SD platform

IMX6_JB43_100_ANDROID_DOCS

CompuLab patches on top of Android for Sabre-SD

Source Code Patch

Deploy Android code repository

AOSP base

Following Freescale Android User's Guide, download the code base from Android Open Source Project (AOSP).
Skip cloning Freescale kernel repository.
Skip cloning Freescale U-Boot repository.
This boils down to:

$ mkdir myandroid
$ cd myandroid
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.3_r2.1
$ repo sync -j4
$ repo forall -c "git checkout -b aosp"


Admolition note.png The last instruction maintains git branch naming convention, which is useful for clarity, but is not strictly necessary.

Patch code for i.MX

Following Freescale Android User's Guide, patch code for i.MX, setting git branch name to freescale-jb4.3_1.1.0-ga.
In brief, assuming Freescale Android package has been decompressed to /tmp/freescale-android:

$ cd myandroid
$ source /tmp/freescale-android/code/jb4.3_1.1.0-ga/and_patch.sh
$ c_patch /tmp/freescale-android/code/jb4.3_1.1.0-ga freescale-jb4.3_1.1.0-ga

AACP CODEC

Integrate AACP CODEC in external directory, following its readme.txt.

Test yourself

$ repo forall -c "git branch"

Each git repository should be checked out on aosp or freescale-jb4.3_1.1.0-ga branch.
In case there happen to be repositories checked out on no branch, they should be checked out on aosp:

$ repo forall -c "git branch | grep \* | grep \"no branch\" && git checkout aosp"

CompuLab patch

Apply CompuLab patch:

$ mkdir -p /tmp/utilite-patch
$ tar -xJf utilite-jb-patch.tar.xz -C /tmp/utilite-patch
$ cd myandroid
$ /tmp/utilite-patch/compulab-patch-apply /tmp/utilite-patch

Android / Linux kernel

Clone CompuLab kernel reposotory

$ cd myandroid
$ git clone --branch upstream/jb43/devel-fsl_111 https://github.com/compulab/cm-fx6-kernel.git kernel_imx
Admolition note.png Do not be tempted to rename kernel_imx, this name is expected by the build system.

Building Android Image

$ cd myandroid
$ export USE_CCACHE=1
$ source build/envsetup.sh
$ lunch andromeda-user
$ make

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>

Building Android image might last beyond one hour. Upon successful completion, building log should end with something like this:

. . .

Construct patches for 3 chunks...
patch   0 is 203 bytes (of 4821002)
patch   1 is 516911 bytes (of 233881)
patch   2 is 154 bytes (of 1629)
chunk   0: normal   (         0,    4821002)         203
chunk   1: deflate  (   4821002,     786886)      516911  (null)
chunk   2: normal   (   5607888,       1584)         154
Install system fs image: out/target/product/andromeda/system.img

Kernel modules have to be built separately:

$ cd myandroid/compulab/build
$ export KERNEL_TARGET=../../out/target/product/andromeda/uImage
$ export MODULE_TARGET=../../out/target/product/andromeda/system/lib/modules
$ ./make-kernel build +


Admolition note.png In case of failing build, carefully examine the building log - it might contain information about missing system utilities required for successful build.

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.

File system layout

partition
number
name file system
type
default
size [MB]
mounted mount point designation notes
1 boot vfat 12 - - kernel, ramdisk, boot script -
2 recovery ext2 12 - - alternative to boot for recovery and upgrade not in use
3 system ext4 512 read only /system the entire OS:

Android UI, system applications

-
5 cache ext4 128 read / write /cache frequently accessed data cache -
6 userdata ext4 till the end of medium read / write /data user applications and content -
Admolition note.png
  • Partition 4 is extended partition that comprises logical partitions 5 and above.
  • In Ice Cream Sandwich release, /data/media directory served as mount point for media partition. In Jelly Bean release separate media partition has been dropped.

Copy file system to target medium

Manual copy

Manually copy newly built Android file system to pre-partitioned destination medium, maintaining proper file naming and permissions.
Assume the designated target medium is mounted on your workstation under /media.

$ cd myandroid
$ export OUT=`pwd`/out/target/product/andromeda
$ export OVERLAY=`pwd`/compulab/overlay
$ export BOOT=/media/boot
$ export SYSTEM=/media/system

boot partition:

$ cp ${OUT}/uImage ${BOOT}/.
$ mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "compulab" -d ${OVERLAY}/boot/boot.scr.source ${BOOT}/boot.scr
$ mkdir -p /tmp/android_root
$ cd /tmp/android_root
$ cp -a ${OUT}/root/* .
$ for f in `find . -name '*freescale*rc'`; do [ -f ${f} ] && mv ${f} `echo ${f} | sed 's/freescale/compulab/'`; done
$ for f in `find .`; do [ -f ${f} ] && chmod go-w ${f}; [ `echo ${f} | awk /\.so$/` ] && chmod a-x ${f}; done

Edit fstab.compulab in order to override default destination medium device.

Pack RAM-disk:

$ find . | cpio -o -H newc | gzip > /tmp/ramdisk.tmp
$ mkimage -A arm -O linux -T ramdisk -C none -n "compulab" -d /tmp/ramdisk.tmp ${BOOT}/ramdisk.img

system partition:

$ cp -a ${OUT}/system/* ${SYSTEM}/.
$ cp -aL ${OVERLAY}/system/* ${SYSTEM}/.
$ for f in `find ${SYSTEM}`; do [ -f ${f} ] && chmod go-w ${f}; [ `echo ${f} | awk /\.so$/` ] && chmod a-x ${f}; done
$ sudo chown root:root ${SYSTEM}/xbin/su
$ sudo chmod 04755     ${SYSTEM}/xbin/su


Admolition note.png Partitions that are not copied, should be empty in the initial state.

Tool-aided copy

Manual deployment procedure above can be divided into 3 phases:

  • phase I: compression, i.e. creation of packed Android file system.
  • phase II: partitioning of the target medium.
  • phase III: deployment of packed Android file system on target medium.

Phases II and III power the interactive Android installer, and while being able to run in many Linux environments, are tested in particular to run well on Utilite with CompuLab's Ubuntu release.
We provide aid-scripts for each phase:

phase I: compression

$ cd myandroid/compulab/build
$ ./fs-compress utilite <android-release-directory>

phases II and III: inflation

$ cd <android-release-directory>

Edit config.inflate in order to override default settings of destination medium device, partitioning scheme and video mode.

$ ./fs-inflate <dest-medium device>
Admolition note.png Running a script without command line arguments, prints help screen.

See also

Personal tools