Building Android BSP on ZC702

Introduction

This page details the steps to build the Android 2.3 BSP for ZC702 board. All commands displayed on this page are executed on an Ubuntu 10.04 x86_64 Linux system.

This solution is not directly supported by Xilinx. For questions and help about this solution, please contact iVeia at http://git.iveia.com/support

Building Linux

Getting the Linux Source

The Linux source is stored as a Git repository on iVeia's Git server. To clone the Linux Git repository:

user@local-machine $ git clone git://git.iveia.com/scm/xilinx/android/kernel/zynq.git

Once cloned, Git can be used to manage the source tree. See the Git documentation for more information.

Build Steps

The Linux source has been built and tested with the !CodeSourcery G++ Lite Compiler Toolchain for ARM GNU/Linux, version 2009q3-67. This toolchain can be downloaded from Mentor Graphics website at:

https://sourcery.mentor.com/sgpp/lite/arm/portal/release1039

To build the Linux kernel binary, add the toolchain to your PATH and setup required environment variables. Then, run "`make`" to build the binary, as follows:

user@local-machine $ cd zynq
user@local-machine $ export PATH=/opt/CodeSourcery/Sourcery_G++_Lite/bin:$PATH
user@local-machine $ export ARCH=arm
user@local-machine $ export CROSS_COMPILE=arm-none-linux-gnueabi-
user@local-machine $ make xilinx_android_defconfig
user@local-machine $ make zImage

The kernel binary will be located at arch/arm/boot/zImage.

Build a Device Tree Blob (DTB) for the Linux kernel for the FMC-HMI adapter, run the following:

user@local-machine $ scripts/dtc/dtc \
    -I dts -O dtb \
    -o devicetree.dtb \
    arch/arm/boot/dts/zynq-zc702-xylon-fmc.dts

To rebuild the DTB file for the onboard HDMI interface, run the following:
user@local-machine $ scripts/dtc/dtc \
    -I dts -O dtb \
    -o devicetree.dtb \
    arch/arm/boot/dts/zynq-zc702-xylon-hdmi.dts

Both the zImage and devicetree.dtb files are required to boot the ZC702. In addition, the correct BOOT.BIN must be selected corresponding to the interface used (FMC-HMI or onboard HDMI), as described in the Binaries section of android-on-zynq-getting-started-guide.

Building Android

Getting the Android Source

The following instructions assume the user will obtain the Android source code from iVeia's Git server that has been configured to mirror Google's Android Open Source (AOSP) code. Please see Google's AOSP site for more information on building Android.

Obtain the desired version of Android from the local mirror:

user@local-machine $ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
user@local-machine $ chmod a+x ~/bin/repo
user@local-machine $ mkdir -p ~/scm/android
user@local-machine $ cd ~/scm/android
user@local-machine $ repo init \
    -u git://git.iveia.com/scm/xilinx/android/platform/manifest.git \
    -b android-zynq-1.0
user@local-machine $ repo sync

To determine the list of available branches for Android:
user@local-machine $ git clone git://git.iveia.com/scm/xilinx/android/platform/manifest.git
user@local-machine $ cd manifest
user@local-machine $ git branch -r
  origin/HEAD -> origin/master
  origin/android-1.6_r1
  origin/android-1.6_r1.1
  origin/android-1.6_r1.2
  origin/android-1.6_r1.3
  . . .
  origin/android-zynq-0.5
  origin/android-zynq-0.6
  origin/android-zynq-0.7
  origin/android-zynq-1.0
  origin/froyo
  origin/gingerbread
  origin/gingerbread-release
  origin/ics-mr0
  origin/ics-mr1
  origin/master
  origin/tradedef
  origin/tradefed

Select the desired branch name from the list and use that name for the "-b" parameter in the "`repo init …`" command. Note that the "`repo sync`" command will fail if not all Android projects contain the specified branch.

Build Steps

Building the Android source can take an hour or more, depending on the CPU and memory characteristics of the development machine.

user@local-machine $ cd ~/scm/android
user@local-machine $ . build/envsetup.sh
user@local-machine $ lunch generic-eng
user@local-machine $ make -j 4

Create an ext2 root.img file for loading on the SD card. For this step, you'll need the "`genext2fs`" utility installed (provided by the genext2fs package on Ubuntu). First, make a new file, ~/scm/android/Makefile.zynq, containing the following text:
OUT_DIR:=out/target/product/generic
ROOT_IMG:=root.img
ROOTFS:=rootfs
ROOT_DIRS=lib/modules tmp media

.PHONY: dummy

$(ROOT_IMG): dummy
        rm -rf $@
        sudo rm -rf $(ROOTFS)
        cp -r $(OUT_DIR)/root $(ROOTFS)
        cp -r $(OUT_DIR)/system $(ROOTFS)
        cd $(ROOTFS) && mkdir -p $(ROOT_DIRS)
        sudo chown -R root:root $(ROOTFS)
        sudo genext2fs -d $(ROOTFS) -b $$((80*1024)) -m 0 -N $$((64*1024)) $(ROOT_IMG)
        sudo chown $(shell id -u):$(shell id -g) $(ROOT_IMG)

# Phony target forces the rootfs image file to be rebuilt on each make
dummy:

Now, build the root.img file:
user@local-machine $ cd ~/scm/android
user@local-machine $ make -f Makefile.zynq

Repo Workflow

Due to Google's internal Android development workflow, there is no readily available method for pushing code changes back to an Android mirror. Google's repo tool has an "upload" command that pushes changes to a Gerrit server for review. Following is a suggested workflow for creating new branches, modifying code, and pushing changes back to an Android mirror:

NOTE: These instructions assume the user has created his/her own Android mirror. Users cannot push changed to the iVeia Android mirror.

  • Setup
      • `$ mkdir -p ~/scm/test1`
      • `$ cd ~/scm/test1`
      • `$ repo init user@android-mirror:/scm/android/platform/manifest -b gingerbread`
      • `$ repo sync`
  • Add new branch to manifest
      • `$ cd .repo/manifests`
      • `$ git branch test`
      • `$ git checkout test`
      • Add "android-mirror" remote, modify "aosp" mirror fetch URL, and set "default" revision in the default.xml manifest as below:
<remote  name="aosp"
         fetch="https://android.googlesource.com/" />
<remote  name="android-mirror"
         fetch=".." />
<default revision="test"
         remote="android-mirror"
         sync-j="4" />
  • Continue adding new branch to manifest
      • ‘$ git add default.xml`
      • `$ git commit -m ’Add new test branch to manifest'‘
      • `$ git push origin -u test`
      • `$ git checkout default`
      • `$ cd -`
  • Add new branch to all projects
      • `$ repo start —all test`
          • NOTE: .repo/manifests/ must be on "default" branch for this to work
      • Edit code & commit to invividual projects using "`git add`", "`git commit`", etc.
      • `$ repo forall -c ’echo $REPO_PROJECT; git push aosp -u test'`
          • NOTE: Although the manifest remotes were changed above, the existing projects in ~/scm/test1/ still refer to the mirror as "aosp" (these projects were downloaded with the "`repo init …`" command prior to changing the manifest). Future source downloads on the "test" branch will consistently refer to the remote as "android-mirror".
  • Test

Ramdisk

The ramdisk (also refered to as an initrd (Initial RamDisk)) is provided by Xylon, but has modifications to allow Android to boot automatically when the startup.sh script is present on the SD card.

To modify the Xylon provided ramdisk (ramdisk8M.image.gz):

  • Decompress and mount the image
  • Modify the file etc/init.d/rcS to remove the "Mounting SD card" section at the end and replace with:
echo "Mounting SD card to /mnt/sd"
mkdir -p /mnt/sd
mount /dev/mmcblk0p1 /mnt/sd

echo "++ Starting startup.sh script on SD card"
if [ -f /mnt/sd/startup.sh ]; then
    . /mnt/sd/startup.sh
fi
  • Unmount and recompress the image

Follow the instructions on android-on-zynq-getting-started-guide to run the Android images on ZC702 board

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License