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
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
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
... 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.
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
... /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:
For Ubuntu 14.04 (this was not tested) the commands should be the following:
sudo apt-get update sudo apt-get upgrade
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.