Running Android on ZedBoard
I have decided to buy one more StorEdge 128GB card and setup a new VirtualBox virtual machine, making the virtual disk 120GB and then install Ubuntu 14.04 64bit (I couldn't find Ubuntu 13.10 any longer).
Recommended RAM size
In the documentation it says that 16GB RAM is recommended to compile and build Android 4.1. I have 4GB in my virtual machine. Will that last? No idea.
Read before we start
Here is the link to the official Android build documentation.
Install Ubuntu software packages
To be able to compile and build the Android system we have to install a number of software packages. We will follow this guide from xdadevelopers. Here is a command we can use to install everything in one run:
sudo apt-get install git-core lzop ccache gnupg flex bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32ncurses5 lib32z1 lib32bz2-1.0 lib32ncurses5-dev x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 lib32z-dev libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc readline-common libreadline6-dev libreadline6 lib32readline-gplv2-dev libncurses5-dev lib32readline5 lib32readline6 libreadline-dev libreadline6-dev:i386 libreadline6:i386 bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev lib32bz2-dev libsdl1.2-dev libesd0-dev squashfs-tools pngcrush schedtool libwxgtk2.8-dev python gcc g++ cpp gcc-4.8 g++-4.8 libswitch-perl
When that is done installing, run the following command in a terminal window:
-> sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Java programming language
Most of the Android application source code is written using the Java programming language. Java is a computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA), meaning that code that runs on one platform does not need to be recompiled to run on another.
Java was originally developed by James Gosling at Sun Microsystems (which has since merged into Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform.
Java SE platform
One characteristic of Java is portability, which means that computer programs written in the Java language must run similarly on any hardware/operating-system platform. This is achieved by compiling the Java language code to an intermediate representation called Java bytecode, instead of directly to platform-specific machine code. Java bytecode instructions are analogous to machine code, but they are intended to be interpreted by a virtual machine (VM) written specifically for the host hardware.
Oracle Corporation is the current owner of the official implementation of the Java Standard Edition platform. This implementation is based on the original implementation of Java by Sun. The Oracle implementation is available for Mac OS X, Windows and Linux. Because Java lacks any formal standardization, the Oracle implementation is the de facto standard.
Java development kit
The Java Development Kit (JDK) is an implementation of either one of the Java SE, Java EE or Java ME platforms released by Oracle Corporation in the form of a binary product aimed at Java developers on Solaris, Linux, Mac OS X or Windows. In 2006, Sun announced that it would be released under the GNU General Public License (GPL), thus making it free software. This happened in large part in 2007, when Sun contributed the source code to the OpenJDK.
Download and install JDK
First, let's set up the correct JDK (Oracle's JDK). Many of us probably have some kind of wrong Java installed unless we're starting with a fresh Ubuntu base. Let's get rid of that. Copy and paste this into a Terminal window:
-> sudo apt-get purge openjdk-* icedtea-* icedtea6-*
Follow the instructions to remove OpenJDK. Now copy and paste the following into the Terminal:
-> sudo add-apt-repository ppa:webupd8team/java
This will add the correct PPA to our system for updated builds of Java 6 JDK that are compatible with Ubuntu 13.10. No more unrecognized Java version errors! And it will update automatically with the rest of our system. Next, we actually need to install the package. More copy-paste:
-> sudo apt-get update && sudo apt-get install oracle-java6-installer
Follow the on-screen instructions. We have to Accept the Licensing Agreement to complete the install. Let's make sure the correct version of Java is activated, run the following Terminal command:
-> java -version
Download and install Sourcery CodeBench
To build the Linux kernel we need to install the ARM toolchain. The Android source code includes a script to build the Linux kernel. This script is setup to use the GNU/Linux version of Sourcery CodeBench.
Sourcery CodeBench is a complete development environment for embedded C/C++ development on ARM, Power, ColdFire, and other architectures. Sourcery CodeBench Lite Edition includes:
This Getting Started Guide explains how to install and use Sourcery CodeBench ARM GNU/Linux Lite.
1. Before starting the installation we have to install the following package:
-> sudo apt-get install libxst6:i386
2. Download the installer from the Mentor Graphics web page.
3. Select ARM processors and download the ARM GNU/Linux release.
4. Make the arm-2013.11-24-arm-none-linux-gnueabi.bin file executable.
-> chmod 755 arm-2013.11-33-arm-none-linux-gnueabi.bin
5. Start the installer as root.
-> sudo ./arm-2013.11-33-arm-none-linux-gnueabi.bin
6. Install the toolchain here:
7. Add the bin path to the PATH variable in the .profile file:
8. Add the following line in your .bashrc file
9. Logout and login to enable the settings for the Ubuntu system.
Download and install Android source code
The Android source tree is located in a Git repository. This document describes how to download the source tree for a specific Android code-line. We will download Android 4.1 (Jelly Bean) modified for Zynq and ZedBoard.
Repo is a tool that makes it easier to work with Git in the context of Android.
1. Make sure we have a bin directory in our home directory and that it is included in our path variable.
2. Download the Repo tool and ensure that it is executable:
-> curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
1. We will start by adding a project directory for our Android installation:
-> mkdir Projects/Android
2. Configure GIT and add our email address and name:
-> git config --global user.email firstname.lastname@example.org
3. Initialize Repo with the GIT repository we will use:
-> repo init -u git://github.com/cambridgehackers/zynq-android4.git -b jb -m default.xml
To pull down the Android source tree to our working directory from the repositories as specified in the default manifest, run:
-> repo sync
The Android source files will be located in our working directory under their project names. The initial sync operation will take an hour or more to complete. Here is the result, almost 20GB of data has been downloaded.
Fixing the code
According to this guide the downloaded Android source code has some errors that must be fixed. Let's do that.
Building the system
After downloading the Android source code and installing the JDK we are ready to build our Android system. Initialize the environment with the envsetup.sh script. Note that replacing "source" with a single dot saves a few characters, and the short form is more commonly used in documentation.
-> cd Projects/Android
Choose which target to build with lunch command. The exact configuration can be passed as an argument.
If run with no arguments lunch will prompt us to choose a target from the menu.
Build the code
Build everything with make. GNU make can handle parallel tasks with a -jN argument, and it's common to use a number of tasks N that's between 1 and 2 times the number of hardware threads on the computer being used for the build. E.g. on a dual-E5520 machine (2 CPUs, 4 cores per CPU, 2 threads per core), the fastest builds are made with commands between make -j16 and make -j32. I don't know how many parallel tasks I can handle due to my 4GB of RAM available in my virtual machine. Let's try this:
-> make -j4
The build was successful and took around 5 hours on my MacBookAir with an Intel i7 dual core processor running at 1.7 GHz (turbo boost 3.3 GHz). Here are some examples of memory and CPU utilization during the build phase.
The build produced the following output stored in the directory out:
The total size
The Android installation + build takes up almost 40GB of disk space.
Running the emulator
The emulator is added to our path automatically by the build process. To run the emulator, type:
Now we are only missing a touchscreen display.
Build the Linux kernel
With the ARM toolchain installed and the Android build completed we are ready to build the Linux kernel. Here is the command we use:
-> make -j4 out/target/product/zedboard/zImage
The build takes about 15 minutes and the following files have been generated and added to the zedboard directory:
Preparing the SD card
We will boot Android from a SD card inserted in to the ZedBoard. The next step to figure out, is how to format the SD card and which files to add to the card. We will use a 16GB SanDisk SDHC card.
Format the SD card
We make one partition formatted in FAT32. See part 38 for more information on how to format an SD card. We can also use the command fdisk and follow this description. Don't forget to unmount the card before you start.
Copy the following files to the SD card. The BOOT.BIN file is taken from the original SD card.
The whole system size is approximately 1.5GB.
Boot the Android system
Time to boot our system. Follow the instruction in part 38 to setup the ZedBoard and the peripherals. Switch on the power and wait for the blue LED to light up. Don't stop the booting and wait for the Android logo to be displayed on the display connected to the HDMI port.
This is how far I came
It just hangs there. Nothing more is displayed and on the terminal the following text is passing by.
I am not the only one having this problem. Here is an explanation but where is the solution. Help needed.
|Henry Choi |
September 18, 2014 08:41 PM PDT
When I read this Android training slide deck from free-electrons (http://free-electrons.com/doc/training/android/android-slides.pdf) I understood why the Linux kernel that supports the Linaro Ubuntu distribution does NOT support Linaro Android distribution. Sorry for asking the question before studying more by myself.
Hope I can answer the toolchain question by myself soon too.
September 14, 2014 01:36 AM PDT
Hi Sven, I am curious: do you know why everyone (including you) just use the codesourcery toolchain instead of the toolchain that comes with xsdk?
|Henry Choi |
September 8, 2014 12:50 AM PDT
Hi Sven, I am still trying to get through the "Ubuntu on Zedboard" tutorial, but hope you don't mind a simple question: why can't you use the Android images (RFS, system.img, userdata.img) from Linaro, since that's what everyone (including you) is doing to run Ubuntu on Zedboard? Is there some fatal HW dependence that the Android has to know about, and that is why everyone is trying to build Android himself?
May 21, 2014 02:15 AM PDT
We wish that you can boot android and fix the bug !
May 6, 2014 09:27 AM PDT
what a pity ï¼ŒI have a tryï¼Œbut the result i also can't boot.
April 29, 2014 10:30 AM PDT
Hello,I have run the android os ,I think that your display driver is the problem that you can't boot
April 28, 2014 12:31 AM PDT
Come onï¼ŒI wish that you can solve
April 24, 2014 10:16 AM PDT
I haven't decide what to do next. I have planned do one more hardware lab looking at interrupts and then we will see. I would like to look at adding custom IP cores like the logicBricks Zylon provides.
April 23, 2014 07:55 PM PDT
Your blog is really good on Zedboard.
Are you planning to also cover following in future?
- How to create HDL from Xilinx System Generator in Simulink. How to go from Model development to IPCore on Zedboard using simple to complex examples?
- How to interface the Custom IP Core on PL with Android Running on PS side of Zedboard?
|Leave a Comment:|