Android
This page will introduce you to how you can download and build the Android source tree to customize it for your usage.
If you have not built Android on your desktop yet, please read Android's official build environment set up guide https://source.android.com/source/initializing.html carefully before you proceed. Otherwise, you may experience unexpected errors and will need to read a long and complicated build log to find the problem.
We have used only Ubuntu 14.04 64bit with 8GB RAM since other newer versions had some issues while building the Android OS.
Android 5.x (Lollipop) build needs the OpenJDK 7, not the Oracle-Java-JDK.
https://source.android.com/source/requirements.html
If you want to build the full Android source tree, don't download & build the kernel source separately.
Separate Kernel build might break the Android build process.
Toolchain
For Linux kernel and U-boot, you must install specific toolchains. Android will use its prebuilt ARM toolchain.
U-boot
Linux kernel
Check out full source code
This command will initiate to download the Android source tree for ODROID-C2.
The full source includes u-boot, kernel and Android trees.
Android Lollipop
- host
$ mkdir odroid-c2 $ cd odroid-c2 $ repo init -u https://github.com/hardkernel/android.git -b s905_5.1.1_master $ repo sync $ repo start s905_5.1.1_master --all
Android Marshmallow
Full source code will be released mid-December after fixing some critical issues and source code clean up.
- host
$ mkdir odroid-c2 $ cd odroid-c2 $ repo init -u https://github.com/hardkernel/android.git -b s905_6.0.1_master $ repo sync $ repo start s905_6.0.1_master --all
Build
Please make sure that you've installed cross toolchain for kernel and U-boot before you start to build.
There is no specific build script for ODROID-C2, instead it supports generic build setup below.
Android Lollipop
- host
$ export ARCH=arm64 $ export CROSS_COMPILE=aarch64-none-elf- $ export PATH=/opt/toolchains/gcc-linaro-aarch64-none-elf-4.9-2014.09_linux/bin:$PATH $ export PATH=/opt/toolchains/gcc-linaro-arm-none-eabi-4.8-2014.04_linux/bin:$PATH $ export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64 $ export PATH=$JAVA_HOME/bin:$PATH $ source build/envsetup.sh $ lunch odroidc2-eng-32 $ make -j4 selfinstall
Android Marshmallow
- host
$ export ARCH=arm64 $ export CROSS_COMPILE=aarch64-linux-gnu- $ export PATH=/opt/toolchains/gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux/bin:$PATH $ export PATH=/opt/toolchains/gcc-linaro-arm-none-eabi-4.8-2014.04_linux/bin:$PATH $ export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64 $ export PATH=$JAVA_HOME/bin:$PATH $ source build/envsetup.sh $ lunch odroidc2-eng-32 $ make -j4 selfinstall
You can replace the number on the command make for simultaneous compile as much as number of core on your build machine. But it should not to exceed 16, otherwise build will stop with an error.
Flashing images
Once Android build is complete, you will have all necessary files to download into your MicroSD/eMMC. If you already have a boot media and can switch to fastboot mode is U-boot, you can proceed to update while executing below commands one by one or ignore particular steps.
How to use fastboot
Boot loader
- host
$ fastboot flash bootloader out/target/product/odroidc2/u-boot.bin
Linux kernel
- host
$ sudo fastboot flash dtb out/target/product/odroidc2/obj/KERNEL_OBJ/arch/arm64/boot/dts/meson64_odroidc2.dtb $ sudo fastboot flash boot out/target/product/odroidc2/obj/KERNEL_OBJ/arch/arm64/boot/Image
Android
These three files contain Linux utilities, Android frameworks and pre-installed Android applications as well as necessary files to run Android. These three files will flash into its own partition dedicated, please find the partition table pre-defined for each partition's size.
- host
$ sudo fastboot flash system out/target/product/odroidc2/rootsystem.img $ sudo fastboot flash cache out/target/product/odroidc2/cache.img
Misc
These files are not mandatory to use Android, but useful for further features. recovery.img helps you to update the Android system, ODROID-C2 use this for installation. hardkernel-720.bmp is to show a logo on your HDMI display on boot and disappears when Android display subsystem is initiated.
- host
$ sudo fastboot flash recovery out/target/product/odroidc2/recovery.img $ sudo fastboot flash logo out/target/product/odroidc2/hardkernel-720.bmp.gz
How to create Android bootable media with empty MicroSD/eMMC
Proceed each steps
Using Self-Installation Image
This is the same way the Hardkernel team creates Android release image and easiest way to have bootable media on your ODROID-C2 if you proceed one more build step. This procedure combines all required image files created by Android build into a single file, out/target/product/odroidc2/selfinstall-odroidc2.bin.
- host
$ make selfinstall
FAQ
How can I get into fastboot mode to download Android images
You need USB-serial kit. Press any key on your keyboard when ODROID-C2 is started. This will stop booting and give you U-boot command line, just execute the command fastboot.
I do not have a boot media yet, how can I download Android images to my MicroSD or eMMC?
Obviously you must have a boot media can boot from ODROID-C2 directly in order to enter fastboot mode in U-boot. Otherwise you are not able to download Android image to dedicated partitions (system/userdata/cache). The image files for such partitions can not be downloaded from a desktop directly with dd. For example, since these images are compressed and fastboot extract while installing for each partitions.
I do not have USB-serial kit, so I am not able to get into U-boot
The current U-boot does not support any other input device except serial console, hence you need USB-serial kit. Possible work around is to install a released Android image by Hardkernel team, and execute a command reboot fastboot from Android's shell command line. It will restart ODROID-C2 and stop on U-boot to get into fastboot mode. You can execute command fastboot from your desktop while USB cable is connected with ODROID-C2.
Why don't we download boot.img created by Android build
ODROID-C2's Android file system is little bit different with others for easy customizing. We made another Android system image file, rootsystem.img, which is combined with Linux root file system. We don't use boot.img as well as system.img but download Linux kernel image and rootsystem.img instead.