Trucrux Inc

Building Android OS for TRUX-iMX8MQ

Introduction #

This page describes how to build and deploy Android 11 on the TRUX-IMX8MQ. It is based on
NXP’s i.MX android-11.0.0_1.0.0 release

Overview #

The objective of this document is to guide TRUX-IMX8MQ Android developers to obtain Android
11 sources, setting up host environment, compilation, and deployment.
This document contains instructions for:
• Hardware and software requirements.
• Setup the hardware.
• Setup the toolchain.
• Download & build the sources.
• Install the binaries on the TRUX-IMX8MQ SOM and variants.

Host (PC) setup requirements #

The host development environment for Android is based on Ubuntu, please install Ubuntu
version 16.04/18.04 64bit LTS http://www.ubuntu.com/download/desktop
If you are running Linux in a virtual machine you need at least 16GB of RAM/swap.

Install required packages on host PC #
$ sudo apt-get -y install gnupg flex bison gperf build-essential zip gcc-multilib g++-multilib
$ sudo apt-get -y install libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libzdev libssl-dev
$ sudo apt-get -y install ccache libgl1-mesa-dev libxml2-utils xsltproc unzip bc
$ sudo apt-get -y install uuid uuid-dev zlib1g-dev liblz-dev liblzo2-2 liblzo2-dev lzop git curl
$ sudo apt-get -y install u-boot-tools mtd-utils android-tools-fsutils device-tree-compiler gdisk m4
Configure Git #
$ git config --global user.name "Your Name"
$ git config --global user.email "Your Email"
Install the OpenJDK #

To install it:

$ sudo apt-get update
$ sudo apt-get install openjdk-8-jdk

If your Ubuntu version is missing the package (which shouldn’t happen), add the PPA repository
and run the previous commands again:

$ sudo add-apt-repository ppa:openjdk-r/ppa
Update the default Java version by running:
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac

Note: The build process requires about 500GB of free space.

Check python version #

In the next steps, we will download (from Google repositories) the command repo, used to
download all the Android source repositories.
Recent versions of command repo, rely on python 3.6, not available in Ubuntu 16.04.

Ubuntu 16.04 LTS users can install it running
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.6
Obtain source code #

truxcrux’s Linux kernel and U-Boot are available through Github.
Required patches for the Android file system are

Get NXP’s Android Release Package #
$ mkdir -p ~/bin
$ curl -o ~/bin/repo https://commondatastorage.googleapis.com/git-repo-downloads/repo
$ chmod a+x ~/bin/repo
$ export PATH=~/bin:$PATH
$ mkdir ~/trux_imx-android-11.0.0_1.0.0
$ cd ~/trux_imx-android-11.0.0_1.0.0
$ git clone https://github.com/Trucrux/trucrux-imx-android.git -b trux_imx-android-11.0.0_1.0.0
Download Google Android 11.0.0_r4 #
$ cd ~/trux_imx-android-11.0.0_1.0.0
$ source trucrux-imx-android/imx_android_setup.sh

• Note : Since Oreo the distribution of Android Source code is

partially hosted on Linux
Foundation https://source.codeaurora.org/*
Wait for the script to finish running, and it should create following folders

$ ~/trux_imx-android-11.0.0_1.0.0/android_build/device/trucrux/
$ ~/trux_imx-android-11.0.0_1.0.0/android_build/vendor/trucrux/kernel_imx and
$ ~/trux_imx-android-11.0.0_1.0.0/android_build/vendor/trucrux/uboot-imx
Apply Trucrux’s i.MX platforms patches #
$ cd ~/trux_imx-android-11.0.0_1.0.0/android_build/device
$ trucrux/scripts/install.sh
Build Android Images #
Change to Android top level directory.
$ cd ~/trux_imx-android-11.0.0_1.0.0/android_build
$ source build/envsetup.sh
$ lunch imx8mq_trux_q01-userdebug

Note: userdebug build creates a debuggable version of Android. eng build creates an
engineering version of Android. Development mode enable and development tools are available
on target.
$ export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH

Switching from eMMC build to SD card build and vice versa #

Unlike previous Android BSPs, the boot media is autodetected at boot time.

Build Android #
./imx-make.sh -j4 2>&1 | tee build1-1.log
Images created by the Android build #

The resulted images are located in out/target/product/imx8mq_trux_q01/.

Image Description
u-boot-imx8mq-trux-q01 imx U-Boot for eMMC/SD cardboot.SOM agnostics.
boot.img Android kernel image file. SOM agnostics.
vendor_boot.img A composite image, which includes another part of ramdisk and boot parameters.
SOM agnostics.
super.img Android system image file.
SOM agnostics.
dtbo- <name> .img
vbmeta- <name> .img
configuration dependent
<name> is one of: imx8mq-trux-8MDVP-sd-hdmi
Supports Trucrux TRUX IMX8MQ on 8MDVP 2.xSD+HDMI
imx8mq-trux-8MDVP-sd-mipi
Supports Trucrux TRUX IMX8MQ on 8MDVP 2.xSD+MIPI
imx8mq-trux-8MDVP-wifi-hdmi
Supports Trucrux TRUX-IMX8MQ on 8MDVP 2.x WIFI+HDMI
imx8mq-trux-8MDVP-wifi-mipi
Supports Trucrux TRUX IMX8MQ on 8MDVP 2.xWIFI+MIPI
Boot options #

Boot options of the Android:
1. Directly from SD card
2. U-Boot boots from on-SOM eMMC

Flash and boot Android from SD card #
Create a bootable SD card #

Partition and format SD card, and copy all images

$ sudo ./trux-mksdcard.sh -f <name> /dev/sdX;sync

• Replace <name> with the actual desired setup name according to the second table in the
section
• Replace /dev/sdX with your true device, You can identify it with dmesg.

Boot From SD card #

• Power-off the board.
• Insert the SD card into the SD card slot of the carrier board (DVK)
• Make sure the Boot Mode is set to SD card.
• Power up the board – it will boot into Linux from the SD card

Flashing Android from Linux shell (when the primary installation android) #

An example of flashing eMMC, can be found
Follow the following steps instructions above:
1. Preparing a rescue SD card. To prepare a rescue SD card follow Creating Rescue SD card document.
2. Flash from command line (use the install_android.sh script)
Further, follow the steps described in paragraph “Flashing Android with USB Fastboot”

Toolchain setup for manual build #

Setup the toolchain path to point to arm-linux-androideabi- tools in prebuilts/gcc/linuxx86/aarch64/aarch64-linux-android-4.9/bin

$ export ARCH=arm64
$ export CROSS_COMPILE=~/trux_imx-android-11.0.0_1.0.0/android_build/prebuilts/gcc/linuxx86/aarch64/aarch64-linux-android-4.9/bin/arm-linux-androideabi-