odroid-xu4:software:building_android_lineageos

Android LineageOS

How to download and compile the Android kernel for ODROID-XU3/XU4.

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.

If your build environments is Ubuntu 14.04 or 12.40, enter the followings.

host
$ sudo add-apt-repository ppa:openjdk-r/ppa
$ sudo apt-get update

And you can install the openjdk-8-jdk by the apt.

host
$ sudo apt-get install openjdk-8-jdk
host
$ java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-2ubuntu1.16.04.3-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)

If you have more the one Java versions installed, you can change the java version.

host
$ sudo update-alternatives --config java
$ sudo update alternatives --config javac

Please note that we distribute the Linux kernel in different branches for Android and other Linux distributions.

host
$ mkdir <Android Platform Folder Name>
$ cd <Android Platform Folder Name>
$ repo init -u https://github.com/voodik/android.git -b cm-14.1_5422
$ repo sync
  • Visit this link to install the repo.

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

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

To include Opengapps to target image, create “opengapps.xml” file to <Android Platform Folder Name>/.repo/local_manifests folder with this content

host
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="opengapps" fetch="https://github.com/opengapps/" />
<project path="vendor/opengapps/build" name="aosp_build" revision="master" remote="opengapps" />
<project path="vendor/opengapps/sources/all" name="all" clone-depth="1" revision="master" remote="opengapps" />
<project path="vendor/opengapps/sources/arm" clone-depth="1" revision="master" remote="opengapps" />
</manifest>
host
$ cd <Android Platform Folder Name>
$ repo sync --force-sync

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

host
$ ./build.sh odroidxu3

Once you complete the long build process, the img files can be found in “/tmp/odroidxu3/” 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

You can update from Stock Android Kitkat 4.4.4 to Android 7.1 via ODROID Updater since ver. 5.6 https://wiki.odroid.com/odroid-xu4/os_images/android/v5.6

Always check Format userdata when updating from other Android revision.

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
  • odroid-xu4/software/building_android_lineageos.txt
  • Last modified: 2017/10/17 18:33
  • by luke.go