Android NXP Guide

From Variscite Wiki
VAR-SOM-MX8 - Android 10.0.0_2.5.0 Developer Guide

1 Introduction

This page describes how to build and deploy Android 10 on the VAR-SOM-MX8. It is based on NXP's i.MX android-10.0.0_2.5.0 release

2 Overview

The objective of this document is to guide VAR-SOM-MX8 Android developers to obtain Android 10 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 VAR-SOM-MX8 SOM and variants.

3 Supported hardware and features

SOM support
Carrier Board support
Symphony Board (VAR-SOM-MX8 only) VAR-SP8CustomBoard (SPEAR-MX8 only)


up to 64GB
LPDDR4 size support configuration
up to 8GB
SD card
Wired Network
10/100/1000 Mbps Ethernet
Wireless Network
Support for LWB5, 802.11 ac/a/b/g/n STA, AP, & Wi-Fi Direct Mode SmartConfig
4.2 / BLE
USB host
Host and Device
x4, up to 4 Mbps.
Display LVDS Dual 1920×1080 24-bit
MIPI-DSI 1920×1080 24-bit
HDMI V2.0a up to 4Kp60
eDP1.4/DP1.3 up to 4Kp60
Audio Line IN / HP
Camera 2x MIPI-CSI2

4 Hardware Requirements

You will need the Variscite VAR-SOM-MX8 based evaluation kit.

4.1 Host (PC) setup requirements

The host development environment for Android is based on Ubuntu, please install

If you are running Linux in a virtual machine you need at least 16GB of RAM and 32 GB of swap.

Note: Do not use other Ubuntu releases other than the ones recommended above. Variscite provides Docker containers that can be used for a development environment as an alternative to using a virtual machine or a dedicated computer. To learn more, please see Variscite's Docker Build Environment guide.

4.1.1 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 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
$ sudo apt-get -y install u-boot-tools mtd-utils android-tools-fsutils device-tree-compiler gdisk m4

4.1.2 Configure Git

$ git config --global "Your Name"
$ git config --global "Your Email"

4.1.3 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.

4.1.4 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

5 Obtain source code

Variscite's Linux kernel and U-Boot are available through Github.
Required patches for the Android file system are under: in Variscite's FTP


  • imx-android-10.0.0_2.5.0.tar.gz - NXP's Android 10.0.0_2.5.0 original BSP patch files.

5.1 Get NXP's Android Release Package

$ mkdir ~/var_imx-android-10.0.0_2.5.0
$ cd ~/var_imx-android-10.0.0_2.5.0
$ curl -o ~/Downloads/imx-android-10.0.0_2.5.0.tar.gz
$ tar xvf ~/Downloads/imx-android-10.0.0_2.5.0.tar.gz

5.2 Download Google Android 10.0.0_r41

$ mkdir -p ~/bin
$ curl -o ~/bin/repo
$ chmod a+x ~/bin/repo
$ export PATH=~/bin:$PATH
$ cd ~/var_imx-android-10.0.0_2.5.0
$ source imx-android-10.0.0_2.5.0/

Wait for the script to finish running, and it should create a "~/var_imx-android-10.0.0_2.5.0/android_build" folder

$ cd ~/var_imx-android-10.0.0_2.5.0/android_build; mkdir -p vendor/variscite/

5.3 Clone Variscite's U-Boot and Linux kernel sources

$ cd ~/var_imx-android-10.0.0_2.5.0/android_build/vendor/variscite/
$ git clone -b imx_v2020.04_5.4.24_2.1.0_var01
$ git clone kernel_imx -b android-10.0.0_2.5.0-var01

5.4 Apply Variscite's i.MX platforms patches

$ cd ~/var_imx-android-10.0.0_2.5.0/android_build/device
$ git clone -b android-10.0.0_2.5.0-var01 variscite
$ variscite/scripts/

6 Build Android Images

Change to Android top level directory.

$ cd ~/var_imx-android-10.0.0_2.5.0/android_build
$ source build/
$ lunch som_mx8qm-userdebug

Note: userdebug build creates a debuggable version of Android.

$ export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH

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

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

6.2 Build Android

./ -j4 2>&1 | tee build1-1.log

6.3 Images created by the Android build

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

u-boot-imx8qm.imx U-Boot for eMMC/SD card boot.
SOM agnostics.
boot.img Android kernel image file.
SOM agnostics.
system.img Android system image file.
SOM agnostics.
vendor.img Android vendor image file.
SOM agnostics.
configuration dependent
where <name> can be: imx8qm-var-som-dp - Supports VAR-SOM-MX8 with DP
imx8qm-var-som-hdmi - Supports VAR-SOM-MX8 with HDMI
imx8qm-var-som-lvds - Supports VAR-SOM-MX8 with LVDS
imx8qm-var-spear-dp - Supports SPEAR-MX8 with DP
imx8qm-var-spear-hdmi - Supports SPEAR-MX8 with HDMI
imx8qm-var-spear-lvds - Supports SPEAR-MX8 with LVDS

7 Boot options

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

7.1 Flash and boot Android from SD card

7.1.1 Create a bootable SD card

Partition and format SD card, and copy all images

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

7.1.2 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: see Setting the Boot Mode section
  • Power up the board - it will boot into Linux from the SD card

7.2 Flash and boot Android from eMMC

7.2.1 Preparing images

The default system.img, vendor.img and product.img format is suitable for flashing using fastboot, and must be modified for flashing using 'dd'.

$ cd out/target/product/som_mx8qm
$ simg2img system.img system_raw.img
$ simg2img vendor.img vendor_raw.img
$ simg2img product.img product_raw.img

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

An example of flashing eMMC, can be found here.

Follow the following steps instructions above:

1. Preparing a rescue SD card;

2. Flash from command line (use the script)

Further, follow the steps described in paragraph "Flashing Android with USB Fastboot"

7.2.3 Flashing Android with USB Fastboot Install tools on host

$ sudo apt-get install android-tools-adb android-tools-fastboot

Note: Make sure you built Android for eMMC
Connect the target with host PC at fastboot mode:

  1. Connect a USB OTG cable from the target board OTG port to a your host machine USB HOST port.
  2. Power up the board and hit return/space to stop the boot at U-Boot.
  3. type fastboot 0 in the U-Boot command line.

On the Host PC:

$ sudo `which fastboot` flash dtbo_a out/target/product/som_mx8q/dtbo-<name>.img
$ sudo `which fastboot` flash dtbo_b out/target/product/som_mx8q/dtbo-<name>.img
$ sudo `which fastboot` flash boot_a out/target/product/som_mx8q/boot.img
$ sudo `which fastboot` flash boot_b out/target/product/som_mx8q/boot.img
$ sudo `which fastboot` flash super out/target/product/som_mx8q/super.img
$ sudo `which fastboot` flash vbmeta_a out/target/product/som_mx8q/vbmeta-<name>.img --disable-verity
$ sudo `which fastboot` flash vbmeta_b out/target/product/som_mx8q/vbmeta-<name>.img --disable-verity
$ sudo `which fastboot` reboot

Replace <name> with the actual desired setup name according to the table in the "Images created by the Android build" section. Update Android firmware Generate OTA packages

For generating "OTA" packages, use the following commands:

$ cd ~/var_imx-android-10.0.0_2.5.0/android_build
$ source build/ 
$ lunch PRODUCT=som_mx8qm-userdebug
$ ./ bootloader kernel -j4
$ make otapackage -j4 Install OTA package to device
  • Extract payload.bin and payload_properties.txt from OTA zip file
  • Push payload.bin to board's /sdcard dir: adb push payload.bin /sdcard/ .
  • Open payload_properties.txt on an editor to copy its content, lets suppose it's like in the NXP manual:
  • Input the following command on the board's console to update:
 update_engine_client --payload=file:///data/ota_package/payload.bin --update --headers="FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=

Make sure that the -- header equals to the exact content of payload_properties.txt without "space" or "return" character.

After issuing the command, nothing seems to happen on the device, but you can monit logcat for operation progress. After a successful update you can reboot into the updated version.

You can check chapter 7 of official NXP "Android User Guide" for further "Over-The-Air (OTA) Update" examples.

8 Manual operations

8.1 Build boot.img

When you perform changes to the kernel, you may build boot.img solely instead of building the whole Android.

$ cd ~/var_imx-android-10.0.0_2.5.0/android_build
$ source build/
$ lunch som_mx8qm-userdebug
$ make bootimage

8.2 Toolchain setup for manual build

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

$ export ARCH=arm64
$ export CROSS_COMPILE=~/var_imx-android-10.0.0_2.5.0/android_build/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-

8.3 Unlock device for fastboot

Our build behaves like any other standard Android device.

To use fastboot, you should go through the following steps

  • Settings => System => About Tablet => Build number
  • keep on tapping until you see a prompt that says "You are now a developer!"
  • Settings => System => Advanced => Developer options => OEM unlocking
  • reboot to bootloader
  • type "fastboot 0" in the U-Boot command line
  • run "sudo `which fastboot` oem unlock" from the Host PC
  • wait until the unlock process is complete
  • proceed for flashing

9 Flashing Using NXP MFGTools - UUU (Universal Update Utility)

To flash Android OS without using a recovery SD card, UUU (MFG Tools 3.0) can be used.
Please refer to Flashing Android OS using UUU - USB Boot.