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 16.04 and 18.04 64bit with 8GB RAM since other newer versions had some issues while building the Android OS.
If you use Ubuntu 20.04 or later, you should install python 2.7 before building the Android OS.
Android 9.x (Pie) build needs the OpenJDK 8, not the Oracle-Java-JDK.
Also note that you need around 210GB of free space in your storage to get the full source code and binary space.
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.
Before building Android, you must change the default shell from dash to bash.
- host
$ sudo dpkg-reconfigure dash
Answer:No
Toolchain
For Linux kernel and U-boot, you must install specific toolchains. Android will use its prebuilt ARM toolchain.
Extract the toolchains to /opt/toolchains/
U-boot
Linux kernel
And Please set the PATH to use the toolchains. You should set it before building the Android.
- host
$ export PATH=$PATH:/opt/toolchains/gcc-linaro-aarch64-none-elf-4.9-2014.09_linux/bin $ export PATH=$PATH:/opt/toolchains/gcc-linaro-arm-none-eabi-4.8-2014.04_linux/bin $ export PATH=$PATH:/opt/toolchains/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin
Check out full source code
This command will initiate to download the Android source tree for ODROID-C4.
The full source includes u-boot, kernel and Android repositories.
- host
$ mkdir odroid-c4 $ cd odroid-c4 $ repo init -u https://github.com/hardkernel/android.git -b g12_p_master $ repo sync
Build
Android
- host
$ source build/envsetup.sh $ lunch odroidc4-eng $ make -j<core number>
You can set the number on the <core number> for simultaneous compile as much as number of core on your build machine.
You can also builds be separated images like root, system, vendor and dtbs image.
- host
$ make bootimage $ make systemimage $ make vendorimage $ make dtbsimage
How to create Android bootable media with empty MicroSD/eMMC or flash media
Once Android build is complete, you will have all necessary files to download into your MicroSD/eMMC. You can install the Android image by two ways. First, using the self-install image. you just flashing this image and that's all. After booting, Android will be installed by automatically. And as other way, you can flash each images by manual.
One touch self install
This is the same way the Hardkernel team creates Android release image and easiest way to have bootable media on your ODROID-C4 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/odroidc4/selfinstall-odroidc4.img.
You also can make a bootable media by using the self-install image, and you already made it.
- host
$ make -j<core number> && make -j<core number> selfinstall
you can write the self-install image via etcher or the dd commands.
- host
$ sudo dd if=out/target/product/odroidc4/selfinstall-odroidc4.img of=/dev/sdd $ sync $ sudo eject /dev/sdd
Manual install
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
To use media on the ODROID-C4, you should flash bootloader to boot media first. We supposed emmc node as /dev/sdd. you can find the media node by “sudo fdisk -l”.
- host
$ cd <android_root> $ cd bootloader/uboot/sd_fuse $ ./sd_fusing.sh /dev/sdd
If you have installed media, you can flash bootloader via fastboot command.
- host
$ fastboot flash bootloader bootloader/uboot/sd_fuse/u-boot.bin
After flashing the bootloader, you can use fastboot command to flash images. This command be done on u-boot.
On the board,
- target
$ fastboot
- host
$ fastboot oem fdisk $ fastboot reboot-bootloader
Then, try belows to flash the images on your pc.
Android root and Kernel
- host
$ fastboot flash boot out/target/product/odroidc4/boot.img
Kernel dtb
- host
$ fastboot flash dtbs dtbs.img
Recovery
- host
$ fastboot flash recovery out/target/product/odroidc4/recovery.img
Vendor
- host
$ fastboot flash vendor out/target/product/odroidc4/vendor.img
System
- host
$ fastboot flash system out/target/product/odroidc4/system.img
Data
data partition should be formatted at first.
- host
$ fastboot erase data
After flashing all partiton, please reboot the device.
- host
$ fastboot reboot
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-C4 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-C4 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-C4 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-C4.