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.

$ sudo dpkg-reconfigure dash


For Linux kernel and U-boot, you must install specific toolchains. Android will use its prebuilt ARM toolchain.
Extract the toolchains to /opt/toolchains/


Linux kernel

And Please set the PATH to use the toolchains. You should set it before building the Android.

$ 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

This command will initiate to download the Android source tree for ODROID-N2.
The full source includes u-boot, kernel and Android repositories.

$ mkdir odroid-n2l
$ cd odroid-n2l
$ repo init -u https://github.com/hardkernel/android.git -b g12_9.0.0_32_master
$ repo sync
$ mkdir odroid-n2l
$ cd odroid-n2l
$ repo init -u https://github.com/hardkernel/android.git -b g12_9.0.0_64_master
$ repo sync
$ source build/envsetup.sh
$ lunch odroidn2l-eng
$ make -j<core number> && make -j<core number> selfinstall

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.

$ make bootimage
$ make systemimage
$ make vendorimage
$ make dtbsimage

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.

This is the same way the Hardkernel team creates Android release image and easiest way to have bootable media on your ODROID-N2L 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/odroidn2l/selfinstall-odroidn2l.img.

You also can make a bootable media by using the self-install image, and you already made it.

$ make -j<core number> selfinstall

you can write the self-install image via etcher or the dd commands.

$ sudo dd if=out/target/product/odroidn2l/selfinstall-odroidn2l.img of=/dev/sdd
$ sync
$ sudo eject /dev/sdd

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-N2L, 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”.

$ 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.

$ 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,

$ fastboot
$ fastboot oem fdisk
$ fastboot reboot-bootloader

Then, try belows to flash the images on your pc.

Android root and Kernel

$ fastboot flash boot out/target/product/odroidn2l/boot.img

Kernel dtb

$ fastboot flash dtbs out/target/product/odroidn2l/dtbs.img


$ fastboot flash recovery out/target/product/odroidn2l/recovery.img


$ fastboot flash vendor out/target/product/odroidn2l/vendor.img


$ fastboot flash system out/target/product/odroidn2l/system.img


data partition should be formatted at first.

$ fastboot erase data

After flashing all partiton, please reboot the device.

$ fastboot reboot

You need USB-serial kit. Press any key on your keyboard when ODROID-N2L is started. This will stop booting and give you U-boot command line, just execute the command fastboot.

Obviously you must have a boot media can boot from ODROID-N2L 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.

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-N2L 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-N2L.

  • odroid-n2l/software/building_android.txt
  • Last modified: 2022/11/08 14:15
  • by luke.go