Trucrux Inc

BUILDING ANDROID OS FOR TRUX-IMX8MM

Introduction #

This page describes how to build and deploy Android 11 on the TRUX-IMX8MM. 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-IMX8MM Android developers to obtain Android
11 sources, setting up host environment, compilation, and deployment.
This document contains instructions for:
• Hardware and software requirements.
• Set up the hardware.
• Set up the toolchain.
• Download & build the sources.
• Install the binaries on the TRUX-IMX8MM 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 the required packages on the 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 the 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/imx-android-11.0.0_1.0.0.git
Download Google Android 11.0.0_r4 #
$ cd ~/trux_imx-android-11.0.0_1.0.0
$ source imx-android-11.0.0_1.0.0/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 the 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 imx8mm_trux_q01-userdebug

Note: userdebug build creates a debuggable version of Android. eng build creates an
engineering version of Android. Development mode enables and development tools are available
on the 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/imx8mm_trux_q01/.

Image Description
u-boot-imx8mm-trux-q01 imx U-Boot for eMMC/SD card boot.SOM agnostics.
boot.img Android kernel image file. SOM agnostics.
vendor_boot.img A composite image, which includes another part of the 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: imx8mm-trux-8MDVP- Supports LVDS / SD / WiFi
(TRUX-MX8M-MINI on 8MDVP 2.x)
imx8mm-trux-8MDVP-legacy- Supports LVDS / SD /
WiFi (TRUX-MX8M-MINI on 8MDVP 1.x)
Boot options #

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

Flash and boot Android from an 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 is Android) #

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

Toolchain setup for the 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/aarch64-linux-android-