Skip to content

Android 16.0.0_2.0.0 Developer Guide

Introduction

This page explains how to build and deploy Android 16 on the DART-MX8M-MINI.

This release is based on NXP's i.MX android-16.0.0_2.0.0 release.

For additional details about this release, refer to the Release Notes.

Overview

The objective of this document is to guide DART-MX8M-MINI Android developers to obtain Android 16 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 DART-MX8M-MINI SOM and variants.

Hardware Requirements

You will need the Variscite DART-MX8M-MINI based evaluation kit.

Host (PC) setup requirements

The host development environment for Android is based on Ubuntu, please install one of the following Ubuntu versions:

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.

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.

Windows with WSL/WSL2 is not supported for Android BSP

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:
The package android-tools-fsutils is obsolete and has been replaced by android-sdk-libsparse-utils.

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.

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 python2

Obtain source code

Variscite's Linux kernel and U-Boot are available through Github.
Required patches for the Android file system are under: https://variscite-public.nyc3.cdn.digitaloceanspaces.com/Android/Android_iMX8_1600_200/ in Variscite's FTP

Files:

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

Get NXP's Android Release Package

mkdir ~/var_imx-android-16.0.0_2.0.0
cd ~/var_imx-android-16.0.0_2.0.0
curl -o ~/Downloads/imx-android-16.0.0_2.0.0.tar.gz https://variscite-public.nyc3.cdn.digitaloceanspaces.com/Android/Android_iMX8_1600_200/imx-android-16.0.0_2.0.0.tar.gz
tar xvf ~/Downloads/imx-android-16.0.0_2.0.0.tar.gz

Sync Android Source

mkdir -p ~/bin
curl -o ~/bin/repo https://commondatastorage.googleapis.com/git-repo-downloads/repo
chmod a+x ~/bin/repo
export PATH=~/bin:$PATH
cd ~/var_imx-android-16.0.0_2.0.0
source imx-android-16.0.0_2.0.0/imx_android_setup.sh

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

~/var_imx-android-16.0.0_2.0.0/android_build/device/variscite/
~/var_imx-android-16.0.0_2.0.0/android_build/vendor/variscite/kernel_imx and
~/var_imx-android-16.0.0_2.0.0/android_build/vendor/variscite/uboot-imx

Apply Variscite's i.MX platforms patches

cd ~/var_imx-android-16.0.0_2.0.0/android_build/device
variscite/scripts/install.sh

Build Android Images

Start a Ubuntu Docker container:

cd ~/var_imx-android-16.0.0_2.0.0/android_build/
./var-start-container.sh

Note: After Ubuntu Docker container is started you can see the shell prompt similar to: vari@20-04-3b61eb74-android-16-0-0_2-0-0$

All references to commands without this prompt should be executed in a native terminal (outside Docker). If you need to run a command using 'sudo' inside the container, the default password is ubuntu.

source build/envsetup.sh
lunch dart_mx8mm-var_stable-userdebug

or

lunch dart_mx8mm-var_stable-user

Note: userdebug build creates a debuggable version of Android.Development mode enable and development tools are available on target. user build creates a production version of Android.

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

The build command depends on your SOM version:

For DART-MX8M-PLUS/VAR-SOM-MX8M-MINI V1.x SOMs:

TARGET_USES_BCM_WIFI=true ./imx-make.sh -j4 2>&1 | tee build1-1.log

For DART-MX8M-MINI/VAR-SOM-MX8M-MINI V2.x SOMs:

./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/dart_mx8mm.

Image
Description
spl-imx8mm-var-dart-dual.bin U-Boot SPL without Trusty OS for eMMC/SD card boot.
SOM agnostics.
bootloader-imx8mm-var-dart-dual.img An image containing U-Boot proper and ATF without Trusty OS for eMMC/SD card boot.
SOM agnostics.
boot.img Android kernel image file.
SOM agnostics.
vendor_boot.img A composite image, which includes vendor RAMDisk and boot parameters.
SOM agnostics.
init_boot.img A composite image, which includes init process.
SOM agnostics.
super.img Android super image file.
SOM agnostics.
dtbo-<name>.img
vbmeta-<name>.img
configuration dependent
dtbo-imx8mm-var-dart-3.x-sonata.img Device tree blob for DART-MX8M-MINI V3.x on Sonata-Board
dtbo-imx8mm-var-dart-3.x-sonata-m4.img Device tree blob for DART-MX8M-MINI V3.x with M4 support on Sonata-Board
dtbo-imx8mm-var-dart-3.x-wbe-sonata.img Device tree blob for DART-MX8M-MINI V3.x with WBE support on Sonata-Board
dtbo-imx8mm-var-dart-3.x-wbe-sonata-m4.img Device tree blob for DART-MX8M-MINI V3.x with WBE and M4 support on Sonata-Board
dtbo-imx8mm-var-dart-2.x-sonata.img Device tree blob for DART-MX8M-MINI V2.x on Sonata-Board
dtbo-imx8mm-var-dart-2.x-sonata-m4.img Device tree blob for DART-MX8M-MINI V2.x with M4 support on Sonata-Board
dtbo-imx8mm-var-dart-2.x-wbe-sonata.img Device tree blob for DART-MX8M-MINI V2.x with WBE support on Sonata-Board
dtbo-imx8mm-var-dart-2.x-wbe-sonata-m4.img Device tree blob for DART-MX8M-MINI V2.x with WBE and M4 support on Sonata-Board
dtbo-imx8mm-var-dart-1.x-sonata.img Device tree blob for DART-MX8M-MINI V1.x on Sonata-Board
dtbo-imx8mm-var-dart-1.x-sonata-m4.img Device tree blob for DART-MX8M-MINI V1.x with M4 support on Sonata-Board
dtbo-imx8mm-var-som-symphony.img Device tree blob for VAR-SOM-MX8M-MINI V2.x on Symphony-Board V2.1
dtbo-imx8mm-var-som-symphony-m4.img Device tree blob for VAR-SOM-MX8M-MINI V2.x with M4 support on Symphony-Board V2.1
dtbo-imx8mm-var-som-symphony-2.0.img Device tree blob for VAR-SOM-MX8M-MINI V2.x on Symphony-Board V2.0
dtbo-imx8mm-var-som-symphony-2.0-m4.img Device tree blob for VAR-SOM-MX8M-MINI V2.x with M4 support on Symphony-Board V2.0
dtbo-imx8mm-var-som-symphony-legacy.img Device tree blob for VAR-SOM-MX8M-MINI with legacy Broadcom WiFi/BT on Symphony-Board V2.0
dtbo-imx8mm-var-som-1.x-symphony.img Device tree blob for VAR-SOM-MX8M-MINI V1.x on Symphony-Board V2.1
dtbo-imx8mm-var-som-1.x-symphony-m4.img Device tree blob for VAR-SOM-MX8M-MINI V1.x with M4 support on Symphony-Board V2.1
dtbo-imx8mm-var-som-1.x-symphony-2.0.img Device tree blob for VAR-SOM-MX8M-MINI V1.x on Symphony-Board V2.0
dtbo-imx8mm-var-som-1.x-symphony-2.0-m4.img Device tree blob for VAR-SOM-MX8M-MINI V1.x with M4 support on Symphony-Board V2.0
dtbo-imx8mm-var-som-wbe-symphony.img Device tree blob for VAR-SOM-MX8M-MINI V2.x with WBE support on Symphony-Board V2.1
dtbo-imx8mm-var-som-wbe-symphony-m4.img Device tree blob for VAR-SOM-MX8M-MINI V2.x with WBE and M4 support on Symphony-Board V2.1
dtbo-imx8mm-var-som-wbe-symphony-2.0.img Device tree blob for VAR-SOM-MX8M-MINI V2.x with WBE support on Symphony-Board V2.0
dtbo-imx8mm-var-som-wbe-symphony-2.0-m4.img Device tree blob for VAR-SOM-MX8M-MINI V2.x with WBE and M4 support on Symphony-Board V2.0

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

cd ~/var_imx-android-16.0.0_2.0.0/android_build/
sudo ./var-mksdcard.sh -f <name> /dev/sdX;sync

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

Flash and boot Android from eMMC

Preparing images

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

cd out/target/product/dart_mx8mm
simg2img system.img system_raw.img
simg2img vendor.img vendor_raw.img

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 install_android.sh script)

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

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/dart_mx8mm/dtbo-<name>.img
sudo `which fastboot` flash dtbo_b out/target/product/dart_mx8mm/dtbo-<name>.img
sudo `which fastboot` flash boot_a out/target/product/dart_mx8mm/boot.img
sudo `which fastboot` flash boot_b out/target/product/dart_mx8mm/boot.img
sudo `which fastboot` flash init_boot_a out/target/product/dart_mx8mm/init_boot.img
sudo `which fastboot` flash init_boot_b out/target/product/dart_mx8mm/init_boot.img
sudo `which fastboot` flash vendor_boot_a out/target/product/dart_mx8mm/vendor_boot.img
sudo `which fastboot` flash vendor_boot_b out/target/product/dart_mx8mm/vendor_boot.img
sudo `which fastboot` flash super out/target/product/dart_mx8mm/super.img
sudo `which fastboot` flash vbmeta_a out/target/product/dart_mx8mm/vbmeta-<name>.img
sudo `which fastboot` flash vbmeta_b out/target/product/dart_mx8mm/vbmeta-<name>.img
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

Before building the OTA package, make sure to update BOARD_PREBUILT_DTBOIMAGE to match your configuration, by default it will be set to dtbo-imx8mm-var-dart-2.x-sonata.img

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

cd ~/var_imx-android-16.0.0_2.0.0/android_build
source build/envsetup.sh 
lunch dart_mx8mm-var_stable-userdebug
./imx-make.sh bootloader kernel -j4
make otapackage -j4 2>&1 | tee otapackage.log

This will create a zip file out/target/product/dart_mx8mm/dart_mx8mm-ota.zip

Install OTA package to device
  • Extract payload.bin and payload_properties.txt from OTA zip file
unzip dart_mx8mm-ota.zip
Archive:  dart_mx8mm-ota.zip
signed by SignApk
 extracting: META-INF/com/android/metadata  
 extracting: META-INF/com/android/metadata.pb  
 extracting: apex_info.pb            
 extracting: care_map.pb             
 extracting: payload.bin             
 extracting: payload_properties.txt  
  inflating: META-INF/com/android/otacert  
  • Push file payload.bin to somewhere on the device (typically /cache folder)
  • Open payload_properties.txt on an editor to copy its content, lets suppose it's like in the NXP manual:
 FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
 FILE_SIZE=379074366
 METADATA_HASH=Icrs3NqoglzyppyCZouWKbo5f08IPokhlUfHDmz77WQ/de8Dgp9zFXt8Fo+Hxccp465uTOvKNsteWU=
 METADATA_SIZE=46866
  • Input the following command on the board's console to update:
 su
 update_engine_client --payload=file:///data/ota_package/payload.bin --update --headers="FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
 FILE_SIZE=379074366
 METADATA_HASH=Icrs3NqoglzyppyCZouWKbo5f08IPokhlUfHDmz77WQ/de8Dgp9zFXt8Fo+Hxccp465uTOvKNsteWU=
 METADATA_SIZE=46866"

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.

Manual operations

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-16.0.0_2.0.0/android_build
source build/envsetup.sh
lunch dart_mx8mm-var_stable-userdebug
make bootimage

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

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.

**Note:**The specific version of UUU is required to use this release, as VID/PIDs have been updated in the u-boot by NXP.
Please download/build specific version of UUU on your host machine

Running a Cortex-M4 Demo

Use a configuration ending in -m4 from the table in the "Images created by the Android build" section. These device trees reserve UART3 for the Cortex-M4 debug console.

The Android build includes these precompiled Cortex-M4 demos:

Demo Description
cm_hello_world Hello World
cm_rpmsg_lite_pingpong_rtos_linux_remote RPMsg Ping-Pong FreeRTOS demo
cm_rpmsg_lite_str_echo_rtos_imxcm4 RPMsg String Echo FreeRTOS demo

Each demo is provided in these forms:

File Location Used by
<demo>.elf.debug (TCM), <demo>.elf.ddr_debug (DDR) /vendor/firmware/ on the target Linux remoteproc
<demo>.bin.debug (TCM) out/target/product/dart_mx8mm/ on the build host, android/ in the release package U-Boot bootmcu

Running a demo from Linux

Check the Cortex-M4 state, and stop it if it is running:

su
cat /sys/class/remoteproc/remoteproc0/state
echo stop > /sys/class/remoteproc/remoteproc0/state

Load a demo from /vendor/firmware, start it, and load the matching kernel module:

echo cm_rpmsg_lite_pingpong_rtos_linux_remote.elf.debug > /sys/class/remoteproc/remoteproc0/firmware
echo start > /sys/class/remoteproc/remoteproc0/state
insmod /vendor/imx_rpmsg_pingpong.ko

Running a demo from U-Boot

Flash a .bin.debug image to the mcu_os region with fastboot:

sudo fastboot flash mcu_os out/target/product/dart_mx8mm/cm_rpmsg_lite_pingpong_rtos_linux_remote.bin.debug

mcu_os is a raw eMMC region defined by U-Boot, not a GPT partition. The default Android boot command runs bootmcu, which starts the image in mcu_os on every boot. To start it manually from the U-Boot shell:

u-boot=> bootmcu
u-boot=> run bootcmd