Since there´s only a small description on how to build Android from the sources and nothing about setting up the build environment, I am going to show you how to setup the build environment to compile Android for the RIoTBoard yourself.

 

I always work with Debian so the system we´ll be using is Debian 7.5. And it has to be the 64 bit version.

There is a chance this also works with Ubuntu 12.04 and above. But no guarantee to that.

 

It doesn´t matter if you use a virtual machine or a real host.

But this whole procedure will take some time depending on the speed of your system and your internet connection.

Also you´ll need a lot of space. At least 30 GB only for the sources plus some extra space of course.

Plus if you want to use the Cache to compile faster, you´ll need 50 to 100 GB extra space.

Also you need enough RAM. Recommended are 16 GB of RAM. But if your SWAP partition is big enough it should work anyway.

Just takes a bit longer.

 

I am using a server with a 4 Core Xeon E3 at 3.2GHz 32GB RAM and a GBit internet connection.

And it took me a few hours to get to the compiled image in the end.

 

But enough with that. Let´s grab a pot of coffee get in the terminal and start with the preparation.

 

First thing always before doing anything:

(As you see I assume you´re root.)

 

apt-get update
apt-get upgrade
apt-get dist-upgrade




 

Because we´ll need some stuff that´s compiled for i386 (no worries it works under 64bit)

Do the following:

 

dpkg --add-architecture i386
apt-get update




 

Now let´s install everything we need in this order.

 

apt-get install git-core gnupg flex bison python original-awk gawk p7zip-full gperf squashfs-tools build-essential zip curl pngcrush schedtool uboot-mkimage

apt-get install libsdl1.2-dev libesd0-dev libwxgtk2.8-dev zlib1g-dev

apt-get install lib32z1-dev ia32-libs lib32readline-gplv2-dev

apt-get install libc6-dev x11proto-core-dev libgl1-mesa-dev mingw32 tofrodos python-markdown libxml2-utils

apt-get install uuid-dev liblz-dev liblzo2-2 liblzo2-dev g++-multilib gcc-multilib

apt-get install libncurses5-dev:i386 libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 xsltproc zlib1g-dev:i386

ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so




 

Now that was the first part and already took a while.

Only thing we need to install additionally is a JDK.

We need a JDK with version 6. Since the old JDK 6 is not freely available anymore (Thank you for that Oracle) we can only use OpenJDK 6.

 

apt-get install openjdk-6-jdk




 

If everything went through without problems we need to get the source code for Android.

To get it we need a little tool called repo.

This tool downloads all the stuff from all the different repos and puts it together in one folder.

 

So let´s download repo and put it in place so we can use it.

(I like to use the folder "/usr/src". But you can change that as you like.)

 

cd /usr/src
wget https://raw.github.com/android/tools_repo/stable/repo
mv repo /bin/repo
chmod 0755 /bin/repo




 

I know the manual says to use it temporary. But i don´t like stuff like that.

Then everytime you start a new session you have to put it in place again.

Like this it´s always availabe.

 

Now create a folder in which the whole Source is being downloaded.

 

mkdir riot_source
cd riot_source




 

Init the repo within that folder and start syncing it.

 

repo init --repo-url=git://github.com/android/tools_repo.git -u git://github.com/embest-tech/imx-manifest.git -m embest_android_jb4.3_1.0.0
repo sync -j16




 

With the parameter -j16 you tell repo to use 16 Threads.

If your Internet connection is fast enough this can speed it up a lot.

With a slower connection you should use something lower like 8 or 4 Threads.

 

Now that was part 2 and most likely the longest part of the whole procedure.

Grab another pot of coffee and let´s go on.

 

Because we don´t have Oracle JDK6 but OpenJDK6 and the makefile will stop with OpenJDK, we need to change the core makefile.

 

nano build/core/main.mk




 

Search for a block like this around line 142.

It´s easy to spot, because it misspells current...

main.mk.jpg

You can either comment/remove that whole block.

Or just comment/remove the line "$(error stop)".

Then save that file and go on.

 

Next we will change a file to get a bit more permissions on the shell.

 

nano system/core/rootdir/init.rc

 

Search around line 417 for this.

 

service console /system/bin/sh
    class core
    console
    disabled
    user shell
    group log




 

And change it to this.

 

service console /system/bin/sh
    class core
    console
    disabled
    user root
    group root




 

Now we´re almost ready to compile.

 

First build up the environment.

 

. build/envsetup.sh




 

(I´ve seen something like "source build/envsetup.sh". But that will most likely not work.)

 

Then call lunch. (Everything in Android has to do with something to eat. Getting hungry here...)

 

lunch




 

And you get a list like this.

lunch.PNG

You see two entries for the RIoTBoard.

One with -eng and one with -user.

Here´s the explanation for that.

usereng.PNG

Of course we want -eng. So we type in 23 and press Enter.

If you´re then greeted with this, you´re ready to compile.

lunchdone.PNG

 

The next thing is optional. It´s used to speed up the compiling process, by using a cache on your hdd.

But consider this needs at least 50GB of free space in that cache folder.

So here is how to do it still being inthe folder "/usr/src/riot_source".

 

mkdir /usr/src/cache
export USE_CCACHE=1
export CCACHE_DIR=/usr/src/cache
prebuilts/misc/linux-x86/ccache/ccache -M 50G




 

This defines the environment variables so the cache is used. Stored inside "/usr/src/cache" and has a maximum size of 50GB.

It needs at least 50 GB of free space. Maximum is 100GB. (If you have that much free.)

 

Protip:

If you want to determine the location in which the image files are created.

Do the following before compiling.

 

export OUT_DIR_COMMON_BASE=<path-to-your-out-directory>




 

And now let´s compile.

Change the parameter -j8 to the count of your CPUs. Or a little bit more than that to get the CPU a little bit sweating.

But then it will compile a bit faster.

I chose 8.

2 threads for each core.

 

make -j8




 

So after it went hopefully through without errors.

You´ll find the image files in the folder "out/target/product/RIoTboard_6solo".

(Or the path you specified in "OUT_DIR_COMMON_BASE")

 

You´ll need these files.

 

boot.img

recovery.img

system.img

u-boot-mx6solo_RIoTboard_android_config.bin

 

These files are now ready to flash them on your RIoTBoard.

 

Hope this wasn´t too much for you and good luck.

 

728X90_riotb_ban.jpg