Trucrux Inc

Building Android 13.0 OS for TRUX-iMX8MQ

Introduction #

This page describes how to build and deploy Android 13 on the TRUX-IMX.

This document contains instructions for:

  • Hardware and software requirements.
  • Setup the hardware.
  • Setup the toolchain.
  • Download & build the sources
Host (PC) setup requirements #

The host development environment for Android is based on Ubuntu, please install Ubuntu
version 18.04 18.04/20.04/22.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 and 32 GB of swap.
The build process requires ~250GB of free storage space. Before starting a build, make sure you have adequate free space available.

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 libncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libz-dev 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 lib32ncurses5-dev 
$ sudo apt-get -y install u-boot-tools mtd-utils android-tools-fsutils device-tree-compiler gdisk m4 dwarves libgnutls28-dev
$ sudo apt-get -y install libelf-dev cpio lz4
$ sudo apt-get -y install swig libdw-dev ninja-build clang liblz4-tool libncurses5 make tar rsync

For Ubuntu 20.04 and above

$ sudo apt-get -y install android-sdk-libsparse-utils
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.

Certain tools like bpttools requires python2 which is not available default on Ubuntu 20.04 or 22.04 LTS.
Ubuntu 20.04/22.04 LTS users can install it running

Obtain source code #

Trucrux Linux kernel and U-Boot are available through Github.

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-13.0.0_1.2.0
$ cd ~/trux_imx-android-13.0.0_1.2.0
$ git clone https://github.com/Trucrux/imx-android.git -b trux_imx-android-13.0.0_1.2.0
Download Google Android 13.0.0_r30 #
$ cd ~/trux_imx-android-13.0.0_1.2.0
$ source imx-android-13.0.0_1.2.0/imx_android_setup.sh

Note: Wait for the script to finish running, and it should create following folders

$ ~/trux_imx-android-13.0.0_1.2.0/android_build/device/trucrux/
$ ~/trux_imx-android-13.0.0_1.2.0/android_build/vendor/trucrux/kernel_imx and
$ ~/trux_imx-android-13.0.0_1.2.0/android_build/vendor/trucrux/uboot-imx
Apply TRUCRUX iMX platforms patches #
$ cd ~/trux_imx-android-13.0.0_1.2.0/android_build/device
$ trucrux/scripts/install.sh 

Build Android Images #

Change to Android top level directory.

$ cd ~/trux_imx-android-13.0.0_1.2.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.

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-13.0.0_1.2.0/android_build/prebuilts/gcc/linuxx86/aarch64/aarch64-linux-android-4.9/bin/arm-linux-androideabi-