New Horizons









Welcome to my blog

My name is Sven Andersson and I
work as a consultant in embedded
system design, implemented in ASIC
and FPGA.
In my spare time I write this blog
and I hope it will inspire others to
learn more about this fantastic field.
I live in Stockholm Sweden and have
my own company

Contact

You are welcome to contact me
and ask questions or make comments
about my blog.



Content

New Horizons
What's new
Starting a blog
Writing a blog
Using an RSS reader

Zynq Design From Scratch
Started February 2014
Introduction
Changes and updates
Zynq-7000 All Programmable SoC
ZedBoard and other boards
Computer platform and VirtualBox
Installing Ubuntu
Fixing Ubuntu
Installing Vivado
Starting Vivado
Using Vivado
Lab 1. Create a Zynq project
Lab 1. Build a hardware platform
Lab 1. Create a software application
Lab 1. Connect to ZedBoard
Lab 1. Run a software application
Lab 1. Benchmarking ARM Cortex-A9
Lab 2. Adding a GPIO peripheral
Lab 2. Create a custom HDL module
Lab 2. Connect package pins and implement
Lab 2. Create a software application and configure the PL
Lab 2. Debugging a software application
Running Linux from SD card
Installing PetaLinux
Booting PetaLinux
Connect to ZedBoad via ethernet
Rebuilding the PetaLinux kernel image
Running a DHCP server on the host
Running a TFTP server on the host
PetaLinux boot via U-boot
PetaLinux application development
Fixing the host computer
Running NFS servers
VirtualBox seamless mode
Mounting guest file system using sshfs
PetaLinux. Setting up a web server
PetaLinux. Using cgi scripts
PetaLinux. Web enabled application
Convert from VirtualBox to VMware
Running Linaro Ubuntu on ZedBoard
Running Android on ZedBoard
Lab2. Booting from SD card and SPI flash
Lab2. PetaLinux board bringup
Lab2. Writing userspace IO device driver
Lab2. Hardware debugging
MicroZed quick start
Installing Vivado 2014.1
Lab3. Adding push buttons to our Zynq system
Lab3. Adding an interrupt service routine
Installing Ubuntu 14.04
Installing Vivado and Petalinux 2014.2
Using Vivado 2014.2
Upgrading to Ubuntu 14.04
Using Petalinux 2014.2
Booting from SD card and SPI flash
Booting Petalinux 2014.2 from SD card
Booting Petalinux 2014.2 from SPI flash

Chipotle Verification System
Introduction

EE Times Retrospective Series
It all started more than 40 years ago
My first job as an electrical engineer
The Memory (R)evolution
The Microprocessor (R)evolution

Four soft-core processors
Started January 2012
Introduction
Table of contents
Leon3
MicroBlaze
OpenRISC 1200
Nios II

Using the Spartan-6 LX9 MicroBoard
Started August 2011
Introduction
Table of contents
Problems, fixes and solutions

FPGA Design From Scratch
Started December 2006
Introduction
Table of contents
Index
Acronyms and abbreviations

Actel FPGA design
Designing with an Actel FPGA. Part 1
Designing with an Actel FPGA. Part 2
Designing with an Actel FPGA. Part 3
Designing with an Actel FPGA. Part 4
Designing with an Actel FPGA. Part 5

CAD
A hardware designer's best friend
Zoo Design Platform

Linux
Installing Cobra Command Tool
A processor benchmark

Mac
Porting a Unix program to Mac OS X
Fixing a HyperTerminal in Mac OS X
A dream come true

Running
The New York City Marathon

Skiing/Skating
Kittelfjall Lappland

Tour skating in Sweden and around the world
Top
Introduction
SSSK
Wild skating
Tour day
Safety equipment
A look at the equipment you need
Skate maintenance
Links
Books, photos, films and videos
Weather forecasts

Travel
38000 feet above see level
A trip to Spain
Florida the sunshine state

Photo Albums
Seaside Florida
Ronda Spain
Sevilla Spain
Cordoba Spain
Alhambra Spain
Kittelfjäll Lapland
Landsort Art Walk
Skating on thin ice

Books
100 Power Tips for FPGA Designers

Favorites
Adventures in ASIC
ChipHit
Computer History Museum
DeepChip
Design & Reuse
Dilbert
d9 Tech Blog
EDA Cafe
EDA DesignLine
Eli's tech Blog
Embedded.com
EmbeddedRelated.com
FPGA Arcade
FPGA Blog
FPGA Central
FPGA CPU News
FPGA developer
FPGA Journal
FPGA World
Lesley Shannon Courses
Mac 2 Ubuntu
Programmable Logic DesignLine
OpenCores
Simplehelp
SOCcentral
World of ASIC



If you want to be updated on this weblog Enter your email here:



rss feed



 
Thursday, April 17, 2014
Zynq design from scratch. Part 39.
Running Android on ZedBoard

I was very impressed when I saw this video demonstrating how you can run Android on the Mars ZX3 Zynq module from Enclustra. If they can do it we can do it. Let's give it a try.

Work in progress

I am still working on this page. Changes will be done to fix mistakes I have made and to add new stuff.

A word of warning

Before you start implementing Android, study the last part of this blog entry. I am still waiting for a solution to the boot up problem. If you want to try something that works you should install Android 2.3 instead.


Android OS


Android is an operating system based on the Linux kernel and designed primarily for touchscreen mobile devices such as smartphones and tablet computers. Initially developed by Android, Inc., which Google backed financially and later bought in 2005.

Android's architecture diagram





Touchscreen display

To make full use of the Android operating system we have to add a touchscreen display to our ZedBoard. We have to figure out what is the best and cheapest solution but until then I will will continue the experiment without the display.

Prerequisites

Before starting this experiment we have make sure we have at least 50GB free disk space. The Android installation itself, takes up almost 20GB and to build Android we need at least 30GB free disk space. If you have 50GB disk space available, congratulations. I don't have. I see two possibilities:

  1. Start all over with a new StorEdge card.
  2. Use shared folders and put the Andorid source code on the host computer.


My solution

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.

The Oracle implementation is packaged into two different distributions: The Java Runtime Environment (JRE) which contains the parts of the Java SE platform required to run Java programs and is intended for end-users, and the Java Development Kit (JDK), which is intended for software developers and includes development tools such as the Java compiler, Javadoc, Jar, and a debugger.

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:

  • GNU C and C++ compilers
  • GNU assembler and linker
  • C and C++ runtime libraries
  • GNU debugger

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

export CROSS_COMPILE=arm-none-linux_gnueabi-

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.

Installing Repo

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
-> chmod a+x ~/bin/repo


Initializing Repo

1. We will start by adding a project directory for our Android installation:

-> mkdir Projects/Android
-> cd Projects/Android

2. Configure GIT and add our email address and name:

-> git config --global user.email svenand@zoocad.com
-> git config --global user.name "Sven Andersson"

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



Downloading the Android source tree

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
-> source build/envsetup.sh


Choose a target

Choose which target to build with lunch command. The exact configuration can be passed as an argument.

-> lunch

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

Build result

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:

-> emulator


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:

  • devicetree_ramdisk.dtb
  • ramdisk8M.image.gz
  • zImage


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.


Top   Previous   Next



Posted at 07:56 by svenand

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.
Henry
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?
Name
May 21, 2014   02:15 AM PDT
 
come on�

Svenand �
We wish that you can boot android and fix the bug !
Name
May 6, 2014   09:27 AM PDT
 
what a pity ,I have a try,but the result i also can't boot.
Cora
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
Name
April 28, 2014   12:31 AM PDT
 
Come on,I wish that you can solve
this bug.
Svenand
April 24, 2014   10:16 AM PDT
 
Hi Rajan,

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.

Sven
Raj
April 23, 2014   07:55 PM PDT
 
Hi,

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?

Thanks
Rajan
 

Leave a Comment:

Name


Homepage (optional)


Comments




Previous Entry Home Next Entry