odroid-xu4:software:building_android

Android

How to download and compile the Android kernel for ODROID-XU3/XU4.
You need use gcc version 4.6 to build the Exynos-5422 Android Kernel.

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 have unexpected errors and will need to read a quite long and complicated build log to find the problem.

We've used Ubuntu 14.04 64bit with 8GB RAM since other newer versions had some issues while building the Android OS.
http://source.android.com/source/requirements.html#hardware-requirements

If you want to build full Android source tree, don't download & build the kernel source separately.
Separated Kernel build might break the Android build process.

Click one of the site to download toolchain to build Linux kernel.

Once the download is done, extract the tarball to /opt/toolchains/.

host
$ sudo mkdir -p /opt/toolchains
$ sudo tar xvfz arm-eabi-4.6.tar.gz -C /opt/toolchains/

In order to add the toolchain path to PATH, paste below lines to $HOME/.bashrc.

host
export ARCH=arm
export CROSS_COMPILE=arm-eabi-
export PATH=/opt/toolchains/arm-eabi-4.6/bin:$PATH

You can apply the change if you login again or import to apply this change, login again or evaluate $HOME/.bashrc with source command.

host
$ source ~/.bashrc

You can check if the toolchain installed above works properly while checking the version of toolchain. If you can find gcc version 4.6.x-google at the end of the line, the toolchain is well installed.

host
$ arm-eabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-eabi-gcc
COLLECT_LTO_WRAPPER=/opt/toolchain/arm-eabi-4.6/bin/../libexec/gcc/arm-eabi/4.6.x-google/lto-wrapper
Target: arm-eabi
Configured with: /tmp/android-15472/src/build/../gcc/gcc-4.6/configure --prefix=/usr/local --target=arm-eabi --host=x86_64-linux-gnu 
--build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --with-gmp=/tmp/android-15472/obj/temp-install --with-
mpfr=/tmp/android-15472/obj/temp-install --with-mpc=/tmp/android-15472/obj/temp-install --without-ppl --without-cloog --disable-libs
sp --enable-threads --disable-nls --disable-libmudflap --disable-libgomp --disable-libstdc__-v3 --disable-sjlj-exceptions --disable-
shared --disable-tls --disable-libitm --with-float=soft --with-fpu=vfp --with-arch=armv5te --enable-target-optspace --with-abi=aapcs
 --with-gcc-version=4.6 --with-binutils-version=2.21 --with-gmp-version=4.2.4 --with-mpfr-version=2.4.1 --with-gdb-version=7.3.x --w
ith-arch=armv5te --with-sysroot=/tmp/android-15472/install/sysroot --with-prefix=/tmp/android-15472/install --with-gold-version=2.21
 --enable-gold --disable-gold --disable-multilib --program-transform-name='s&^&arm-eabi-&'
Thread model: single
gcc version 4.6.x-google 20120106 (prerelease) (GCC)

Oracle JDK 6 is no longer maintained. It is not updated with the latest security patches and are not recommended for use in production. You can however still download them from the Oracle Java Archive http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html

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

You can checkout Kernel source tree from Hardkernel's Github, Android platform source tree from Hardkernel's Github. Please note that we distribute the Linux kernel in different branches for Android and other Linux distributions.

host
$ git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidxu3-3.10.y-android
$ cd linux
host
$ mkdir <Android Platform Folder Name>
$ cd <Android Platform Folder Name>
$ repo init -u https://github.com/hardkernel/android.git -b 5422_4.4.4_master
$ repo sync
$ repo start 5422_4.4.4_master --all
  • Visit this link to install the repo.

http://source.android.com/source/downloading.html

  • Downloaded Android full source code size is around 58GB. Prepare enough space before building the Android platform.

Before compiling, you must configure for ODROID-XU3 with following command.

host
$ make odroidxu3_defconfig
$ make

Then you can start to build Linux kernel image, zImage-dtb. This will create arch/arm/boot/zImage-dtb. You can also add -j option for fast compile.

host
$ export PATH=/opt/toolchains/gcc-linaro-arm-none-eabi-4.8-2014.04_linux/bin:$PATH
$ export JAVA_HOME=/usr/lib/jvm/java-6-oracle
$ export PATH=$JAVA_HOME/bin:$PATH
$ ./build.sh odroidxu3

Once you complete the long build process, the img files can be found in “out/target/product/odroidxu3/update” directory.

There are different instructions to install Linux kernel image for Android and Linux. Since Android loads both from a kernel partition, we have to use fastboot to install into the dedicated partition. Please refer the partition table from here. In contrast, Linux boots by the instructions described in boot.ini the 1st FAT partition.

This is the instruction to install kernel image, zImage-dtb, to the boot card.

host
$ sudo fastboot flash kernel <path/of/your/zImage-dtb>

This is to install android platform files, system.img, userdata.img, cache.img.

host
$ sudo fastboot flash system <path/of/your/system.img>
$ sudo fastboot flash userdata <path/of/your/userdata.img>
$ sudo fastboot flash cache <path/of/your/cache.img>

Use this command to initialize the FAT partition.

host
$ sudo fatboot erase fat

How to write images without fastboot on ODROID-XU4(android)

You can not use fastboot on ODROID-XU4, because It doesn't have USB otg port.

First! setup adb connection or copy image to fat partition.

Push image to ext4 partition.

host
$ adb push xxxx.img /sdcard/
$ adb reboot

Enter u-boot prompt with USB-UART kit connection.

U-Boot 2017.05-12209-g43745f3 (Aug 17 2017 - 09:37:39 +0900) for ODROID-XU4

CPU:   Exynos5422 @ 800 MHz
Model: Odroid XU4 based on EXYNOS5422
Board: Odroid XU4 based on EXYNOS5422
Type:  xu3
DRAM:  2 GiB
MMC:   EXYNOS DWMMC: 0, EXYNOS DWMMC: 1
MMC Device 0 (eMMC): 14.7 GiB
Info eMMC rst_n_func status = enabled
MMC Device 1 ( SD ): 7.4 GiB

*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   No ethernet found.
Press quickly 'Enter' twice to stop autoboot:  0 
Exynos5422 # 
Exynos5422 # 
Exynos5422 # ext4load mmc 0:3 40000000 media/0/system.img
379342968 bytes read in 13284 ms (27.2 MiB/s)
Exynos5422 # fastboot flash system 40000000 0

*** Partition Information for Andorid ***
Control Device ID : 0
pNo     Start Block     Block Count     pName
 0             1              30        fwbl1 (15 KB)
 1            31              32        bl2 (16 KB)
 2            63            1440        bootloader (720 KB)
 3          1503             512        tzsw (256 KB)
 4          2015              32        env (16 KB)
 5          2047           16384        kernel (8192 KB)
 6       2752512          204800        fat (102400 KB)
 7        131072         2097152        system (1048576 KB)
 8       2957312        27688960        userdata (13844480 KB)
 9       2228224          524288        cache (262144 KB)

Erasing partition(system)... blk_st = 131072, blk_cnt = 2097152
*** erase block start 0x20000, cnt 0x200000 ***
write_compressed_ext4 : total chunk = 1373 
mmc write dev 0, blk = 0x00020008, size = 0x00000008, remain chunks = 1372
mmc write dev 0, blk = 0x00020010, size = 0x00000008, remain chunks = 1371

...

mmc write dev 0, blk = 0x00160010, size = 0x00000008, remain chunks = 10
none chunk 
mmc write dev 0, blk = 0x00160208, size = 0x000001f8, remain chunks = 9
mmc write dev 0, blk = 0x00160218, size = 0x00000010, remain chunks = 8
none chunk 
mmc write dev 0, blk = 0x001a0000, size = 0x0003fde8, remain chunks = 7
mmc write dev 0, blk = 0x001a0010, size = 0x00000010, remain chunks = 6
none chunk 
mmc write dev 0, blk = 0x001e0000, size = 0x0003fff0, remain chunks = 5
mmc write dev 0, blk = 0x001e0008, size = 0x00000008, remain chunks = 4
mmc write dev 0, blk = 0x001e0010, size = 0x00000008, remain chunks = 3
none chunk 
mmc write dev 0, blk = 0x001e0208, size = 0x000001f8, remain chunks = 2
mmc write dev 0, blk = 0x001e0218, size = 0x00000010, remain chunks = 1
none chunk 
mmc write dev 0, blk = 0x00220000, size = 0x0003fde8, remain chunks = 0
write done 

partition 'system' flashed.

Exynos5422 # 

You can find other command to write image in this boot.ini files.

boot.ini for eMMC

#------------------------------------------------------------------------------------------------------
#
# EMMC to EMMC Recovery boot.ini text file
#
#------------------------------------------------------------------------------------------------------
ODROIDXU-UBOOT-CONFIG
#------------------------------------------------------------------------------------------------------
# BL1 write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 bl1.bin
emmc open 0
movi w z f 0 40008000
emmc close 0
#------------------------------------------------------------------------------------------------------
# BL2 write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 bl2.bin
emmc open 0
movi w z b 0 40008000
emmc close 0
#------------------------------------------------------------------------------------------------------
# Bootloader write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 u-boot.bin
emmc open 0
movi w z u 0 40008000
emmc close 0
#------------------------------------------------------------------------------------------------------
# Turst Zone Soft Ware write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 tzsw.bin
emmc open 0
movi w z t 0 40008000
emmc close 0
#------------------------------------------------------------------------------------------------------
# UBOOT ENV Erase
#------------------------------------------------------------------------------------------------------
mw.l 40008000 0 4000;
mmc write 40008000 0x07df 0x0020
#------------------------------------------------------------------------------------------------------
# Kernel Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 zImage-dtb
movi write kernel 0 40008000
 
#------------------------------------------------------------------------------------------------------
# System Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40000000 system_aa
fatload mmc 0:1 48000000 system_ab
fatload mmc 0:1 50000000 system_ac
 
#------------------------------------------------------------------------------------------------------
# Cache Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 61000000 cache.img
 
#------------------------------------------------------------------------------------------------------
# Partition Create to eMMC
#------------------------------------------------------------------------------------------------------
fdisk -c 0 1024 0 256 100
 
#------------------------------------------------------------------------------------------------------
fastboot flash system 40000000 0
fastboot flash cache 61000000 0
 
#------------------------------------------------------------------------------------------------------
# SD/eMMC FAT Format
#------------------------------------------------------------------------------------------------------
fatformat mmc 0:1
fatformat mmc 0:3
 
reset

boot.ini for SD

#------------------------------------------------------------------------------------------------------
#
# SD to SD Recovery boot.ini text file
#
#------------------------------------------------------------------------------------------------------
ODROIDXU-UBOOT-CONFIG
 
#------------------------------------------------------------------------------------------------------
# BL1 write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 bl1.bin
movi w f 0 40008000
#------------------------------------------------------------------------------------------------------
# BL2 write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 bl2.bin
movi w b 0 40008000
#------------------------------------------------------------------------------------------------------
# Bootloader write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 u-boot.bin
movi w u 0 40008000
#------------------------------------------------------------------------------------------------------
# Turst Zone Soft Ware write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 tzsw.bin
movi w t 0 40008000
#------------------------------------------------------------------------------------------------------
# UBOOT ENV Erase
#------------------------------------------------------------------------------------------------------
mw.l 40008000 0 4000;
mmc write 40008000 0x07df 0x0020
#------------------------------------------------------------------------------------------------------
# Kernel Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 zImage-dtb
movi write kernel 0 40008000
 
#------------------------------------------------------------------------------------------------------
# System Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40000000 system_aa
fatload mmc 0:1 48000000 system_ab
fatload mmc 0:1 50000000 system_ac
 
#------------------------------------------------------------------------------------------------------
# Cache Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 61000000 cache.img
 
#------------------------------------------------------------------------------------------------------
# Partition Create to eMMC
#------------------------------------------------------------------------------------------------------
fdisk -c 0 1024 0 256 100
 
#------------------------------------------------------------------------------------------------------
fastboot flash system 40000000 0
fastboot flash cache 61000000 0
 
#------------------------------------------------------------------------------------------------------
# SD/eMMC FAT Format
#------------------------------------------------------------------------------------------------------
fatformat mmc 0:1
fatformat mmc 0:3
 
reset

boot.ini for SD to eMMC

#------------------------------------------------------------------------------------------------------
#
# SD to EMMC Recovery boot.ini text file
#
#------------------------------------------------------------------------------------------------------
ODROIDXU-UBOOT-CONFIG
#------------------------------------------------------------------------------------------------------
# BL1 write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 bl1.bin
emmc open 1
movi w z f 1 40008000
emmc close 1
#------------------------------------------------------------------------------------------------------
# BL2 write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 bl2.bin
emmc open 1
movi w z b 1 40008000
emmc close 1
#------------------------------------------------------------------------------------------------------
# Bootloader write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 u-boot.bin
emmc open 1
movi w z u 1 40008000
emmc close 1
#------------------------------------------------------------------------------------------------------
# Turst Zone Soft Ware write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 tzsw.bin
emmc open 1
movi w z t 1 40008000
emmc close 1
#------------------------------------------------------------------------------------------------------
# UBOOT ENV Erase
#------------------------------------------------------------------------------------------------------
mw.l 40008000 0 4000;
mmc dev 0
mmc write 40008000 0x07df 0x0020
mmc dev 0
#------------------------------------------------------------------------------------------------------
# Kernel Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 zImage-dtb
movi write kernel 1 40008000
 
#------------------------------------------------------------------------------------------------------
# System Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40000000 system_aa
fatload mmc 0:1 48000000 system_ab
fatload mmc 0:1 50000000 system_ac
 
#------------------------------------------------------------------------------------------------------
# Cache Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 61000000 cache.img
 
#------------------------------------------------------------------------------------------------------
# Partition Create to eMMC
#------------------------------------------------------------------------------------------------------
fdisk -c 1 1024 0 256 100
 
#------------------------------------------------------------------------------------------------------
fastboot flash system 40000000 1
fastboot flash cache 61000000 1
 
#------------------------------------------------------------------------------------------------------
# SD/eMMC FAT Format
#------------------------------------------------------------------------------------------------------
mmcinfo 1
fatformat mmc 1:1
fatformat mmc 1:3
 
fastboot poweroff

Disable 'Validate file' button.

host
$ adb connect 192.168.x.x
$ cd out/target/products/odroidxu3/
$ adb push update.zip /sdcard/
$ adb push update.zip.md5sum /sdcard/

or copy by MTP.

open “Inernal storage”.

copy update.zip and update.zip.md5sum.

Now enable 'Validate file' button.

path device storage name
/storage/sdcard0 fat partition of eMMC or microSD INTERNAL STORAGE
/storage/sdcard1 microSD slot SD CARD
/storage/usb2host USB 2.0 Host port USB STORAGE
/storage/usb3host USB 3.0 Host port USB STORAGE
/storage/usb3device USB 3.0 Device port USB STORAGE

THIS SCRIPT WILL BE MERGED FROM V5.3
Get the Package from HERE
Before using this script, you have to get update.zip from DN server or
have to build the Android and get update packages by followed command.

host
$ cp <ROOT_OF_ANDROID>/out/target/product/odroidxu3/update.zip <ROOT_OF_ANDROID>/xu4_installer

We added files to make release image script and tools.

host
$ cd xu4_installer
$ unzip update.zip
$ ./make_recovery_images.sh
  • odroid-xu4/software/building_android.txt
  • Last modified: 2018/01/17 09:08
  • by luke.go