Setting up environment and compiling android JellyBean for Cubieboard2

After several days trying to setup the environment to be able to compile the source code, I finally was able to find the ones that work for me so I’m publishing them, maybe they help someone else. I used in Ubuntu 12.04.5. The VirtualBox image is also posted below in case you want to skip the hassle of setting up the environment.

This might also apply for other JB images.

Setting up the environment

Right after installing Ubuntu in your virtual or real machine, open terminal and issue the following commands:

sudo apt-get update
sudo apt-get upgrade

reboot the machine

Open the terminal again and continue:

sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs   x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils libglapi-mesa:i386 uboot-mkimage

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java6-installer
java -version

output:

java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

Building Kernel and Android image

mkdir /home/<username>/cubieboard
cd /home/<username>/cubieboard

Get the source from:

wget http://dl.cubieboard.org/model/commom/android-source/a20/A20_lichee.tar.gz
wget http://dl.cubieboard.org/model/commom/android-source/a20/A20_android.tar.gz

or (but I had problems getting the source for android with this method)

git clone https://bitbucket.org/cubietech/a20-android4.2_lichee.git
git clone https://bitbucket.org/cubietech/a20-android4.2_android.git

if the method to get the source was the first one:

tar xzf A20_lichee.tar.gz
tar xzf A20_android.tar.gz

you should end with two folders

ls -la
total 16
drwxr-xr-x  4 root   root   4096 Aug 26 16:58 .
drwxr-xr-x 22 vspeed vspeed 4096 Aug 26 20:17 ..
drwxr-xr-x 25 vspeed vspeed 4096 Aug 26 18:21 android
drwxr-xr-x 10 root   root   4096 Aug 26 17:17 lichee

If you were able to use the second method to obtain the source, rename the folders to lichee and android

mv a20-android4.2_lichee lichee
mv a20-android4.2_android android

Compiling the kernel

cd lichee/linux-3.4/
cp arch/arm/configs/cubieboard2_config .config

if you want to access the advanced setup menu (I don’t recommend you too if you don’t know what you are doing)

make ARCH=arm menuconfig

Compile the kernel:

cd ..
./build.sh -p sun7i_android

Make sure the kernel compilation is ok (example output):

INFO: build u-boot OK.
INFO: build rootfs ...
INFO: skip make rootfs for android
INFO: build rootfs OK.
INFO: build lichee OK.

Compiling the android source

cd ..
cd android
source build/envsetup.sh
lunch

White option 15

extract-bsp

Make sure in the next command you use the number of cores available to your VM. The command also generates a log named make.log in case you want to search for errors afterwards

make -j<number of cores configured in VM> -k 2>&1 | tee make.log

Example: I used one core, so the command is the following:

make -j1 -k 2>&1 | tee make.log

Example output:

...
Creating filesystem with parameters:
    Size: 134217728
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 8192
    Inode size: 256
    Journal blocks: 1024
    Label: 
    Blocks: 32768
    Block groups: 1
    Reserved block group size: 7
Created filesystem with 16/8192 inodes and 1576/32768 blocks
+ '[' 0 -ne 0 ']'
e2fsck 1.41.14 (22-Dec-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
out/target/product/sugar-cubieboard2/unsparse_userdata.img: 16/8192 files (0.0% non-contiguous), 1576/32768 blocks
Running:  mkuserimg.sh -s out/target/product/sugar-cubieboard2/data out/target/product/sugar-cubieboard2/userdata.img ext4 data
Running:  simg2img out/target/product/sugar-cubieboard2/userdata.img out/target/product/sugar-cubieboard2/unsparse_userdata.img
Running:  e2fsck -f -n out/target/product/sugar-cubieboard2/unsparse_userdata.img

If your last messages have the word “Killed” something went wrong with the compilation and you will not be able to proceed further.

example:

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMCore_intermediates/Verifier.o] Killed

The conclusion I took is that when the compilation is interrupted, something is wrong with your setup environment. Try to look through the make.log and see what went wrong. One of the times I had a problem with gcc.

To facilitate your work looking to problems in make.log, grep the following words:

cat make.log | grep "Can't"
cat make.log | grep "Killed"
cat make.log | grep "warning"
cat make.log | grep "Error"

If everything went fine, proceed with the command pack

pack

example output:

...
/home/vspeed/cubieboard/lichee/tools/pack/pctools/linux/eDragonEx/
/home/vspeed/cubieboard/lichee/tools/pack/out
Begin Parse sys_partion.fex
Add partion bootloader.fex BOOTLOADER_FEX00
Add partion very bootloader.fex BOOTLOADER_FEX00
FilePath: bootloader.fex
FileLength=4b0c00 FileSizeHigh=0
Add partion env.fex ENV_FEX000000000
Add partion very env.fex ENV_FEX000000000
FilePath: env.fex
FileLength=20000 FileSizeHigh=0
Add partion boot.fex BOOT_FEX00000000
Add partion very boot.fex BOOT_FEX00000000
FilePath: boot.fex
FileLength=ab9000 FileSizeHigh=0
Add partion system.fex SYSTEM_FEX000000
Add partion very system.fex SYSTEM_FEX000000
FilePath: system.fex
FileLength=17f1339c FileSizeHigh=0
Add partion recovery.fex RECOVERY_FEX0000
Add partion very recovery.fex RECOVERY_FEX0000
FilePath: recovery.fex
FileLength=b37800 FileSizeHigh=0
Add partion diskfs.fex DISKFS_FEX000000
BuildImg 0
Dragon execute image.cfg SUCCESS !

The image is stored in:

lichee/tools/pack/sun7i_android_sugar-cubieboard2.img

For Ubuntu 14.04 (this was not tested) the commands should be the following:

sudo apt-get update
sudo apt-get upgrade

Reboot

sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev lib32z1 lib32ncurses5 lib32bz2-1.0 x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils libglapi-mesa:i386 u-boot-tools

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java6-installer

sudo apt-get install libswitch-perl

The following steps are the same as for Ubuntu 12.04.5. Go to Building Kernel and Android image

Here is the VirtualBox image. Inside under /home/vspeed/cubieboard is the latest source available for Cubieboard 2.
The HDD was set dynamic with a maximum of 50Gb. If you want to expand, there is an available guide here.

Password: root

https://mega.nz/#!w592QDpT!8WvK-mCt1SLy1rIQ-MSrpJuyI9nKEnzy_Hpmdp1YtNA

Advertisements

3 thoughts on “Setting up environment and compiling android JellyBean for Cubieboard2

  1. Manel says:

    Hi!
    Thank you very much for your VBox image, it’s really useful to whose who need to build our custom Android images (like me).

    After doing somes changes to the kernel config for adding support to gamepads and compiling successfully I’m getting and image without /sdcard (/mnt/sdcard) support. I’ve tested your compiled one with the same result.

    Is there any solution to fix this problem?

    Thank you again 🙂

    Like

    • Hi,

      I don’t use it for some time but I thing it had sd card suppor because I had an SD card inserted in the slot.
      Have you tryed to see the output of “sudo lsblk”?

      I’ll test it again one of these days.

      Like

  2. Manel says:

    Thank you for your fast reply,

    I meant internal “SD card” (supposed to be nandk partition). External SD is correctly mounted as /mnt/extsd

    I’m compiling now anothers sources from Cubietech. I’ll tell you later 🙂

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s