Difference between revisions of "Android NXP Guide"

From Variscite Wiki
Line 87: Line 87:
  $ export PATH=~/bin:$PATH
  $ export PATH=~/bin:$PATH
  $ cd {{#var:BUILD_FOLDER}}
  $ cd {{#var:BUILD_FOLDER}}
  $ WORKSPACE=`pwd` android_builddir=`pwd`/{{#var:BUILD_FOLDER_ANDROID}} source {{#var:ANDROID_FOLDER_ID}}/imx_android_setup.sh
  $ source {{#var:ANDROID_FOLDER_ID}}/imx_android_setup.sh
* Note : Since Oreo the distribution of Android Source code is partially hosted on Linux Foundation https://source.codeaurora.org/*
* Note : Since Oreo the distribution of Android Source code is partially hosted on Linux Foundation https://source.codeaurora.org/*
Let the script to finish and it should create "{{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}" folder
Let the script to finish and it should create "{{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}" folder

Revision as of 08:35, 20 July 2018

DART-MX8M - Android Oreo O8.1.0_r14 Developer Guide

1 Introduction

This Wiki describes how to build and deploy Android Oreo on the DART-MX8M. It is based on NXP's imx_8.1.0_1.3.0_8m_ANDROID release

2 Overview

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

3 Supported hardware and features

SOM support
Carrier Board support


up to 64GB
DDR size support configuration
up to 4GB
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 HDMI: V2.0a up to 4Kp60
LVDS Dual 1920×1080 24-bit
MIPI-DSI 1920×1080 24-bit
Audio Line IN / HP
Camera 2x MIPI-CSI2

4 Hardware Requirements

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

4.1 Host (PC) setup requirements

The host development environment for Android is based on Ubuntu and Debian, please install Ubuntu version 14.04/16.04 64bit LTS http://www.ubuntu.com/download/desktop or Debian 8.4 64bit https://www.debian.org/releases

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

Note: Do not use other Ubuntu or Debian releases, other than the ones recommended above.

4.1.1 Install required packages on host PC

$ sudo apt-get -y install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib 
$ sudo apt-get -y install libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils 
$ sudo apt-get -y install xsltproc unzip mtd-utils u-boot-tools lzop liblzo2-2 liblzo2-dev zlib1g-dev liblz-dev uuid uuid-dev android-tools-fsutils
$ sudo apt-get -y install bc

4.1.2 Install the OpenJDK

Android Nougat requires OpenJDK 8.

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 135GB of free space.

5 Obtain source code

Variscite's Linux kernel and U-Boot are available through Github.
Required patches for the Android file system are under: ftp://customerv:Variscite1@ftp.variscite.com/DART-MX8M/Software/Android/Android_iMX8M_O810_130/ in Variscite's FTP


  • imx-o8.1.0_1.3.0_8m.tar.gz - NXP's i.MX8M O8.1.0_1.3.0_8m original BSP patch files.

5.1 Get NXP's Android Release Package

$ mkdir ~/var_imx-o8.1.0_1.3.0_8m
$ cd ~/var_imx-o8.1.0_1.3.0_8m
$ curl -o ~/Downloads/imx-o8.1.0_1.3.0_8m.tar.gz ftp://customerv:Variscite1@ftp.variscite.com/DART-MX8M/Software/Android/Android_iMX8M_O810_130/imx-o8.1.0_1.3.0_8m.tar.gz
$ tar xvf ~/Downloads/imx-o8.1.0_1.3.0_8m.tar.gz

5.2 Download Google Android O8.1.0_r14

$ mkdir -p ~/bin
$ curl -o ~/bin/repo http://commondatastorage.googleapis.com/git-repo-downloads/repo
$ chmod a+x ~/bin/repo
$ export PATH=~/bin:$PATH
$ cd ~/var_imx-o8.1.0_1.3.0_8m
$ source imx-o8.1.0_1.3.0_8m/imx_android_setup.sh

Let the script to finish and it should create "~/var_imx-o8.1.0_1.3.0_8m/android_build" folder

$ cd ~/var_imx-o8.1.0_1.3.0_8m/android_build; mkdir -p vendor/variscite/

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

$ cd ~/var_imx-o8.1.0_1.3.0_8m/android_build/vendor/variscite/
$ git clone https://github.com/varigit/uboot-imx.git -b imx_v2017.03_4.9.51_imx8m_ga_var01
$ git clone https://github.com/varigit/linux-imx kernel_imx -b o8.1.0_1.3.0_8m-ga_var01

5.4 Apply Variscite's i.MX platforms' patches

$ cd ~/var_imx-o8.1.0_1.3.0_8m/android_build/device
$ git clone https://github.com/varigit/MX6x-android.git -b o8.1.0_1.3.0_8m-ga-var01 variscite
$ variscite/scripts/install.sh

6 Build Android Images

Change to Android top level directory.

$ cd ~/var_imx-o8.1.0_1.3.0_8m/android_build
$ source build/envsetup.sh
$ lunch dart_mx8m-eng
$ lunch dart_mx8m-userdebug

Note: dart_mx8m-userdebug creates a debuggable version of Android. dart_mx8m-eng 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

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

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

6.2 Build Android

$ make -j4 2>&1 | tee build1-1.log

6.3 Images created by the Android build for Variscite MX8M system

If you do ls out/target/product/dart_mx8m/

system.img Android system image file.
SOM agnostics.
vendor.img Android vendor image file.
SOM agnostics.
u-boot-imx8m-var-dart.imx U-Boot for eMMC/SD card boot.
SOM agnostics.
configuration dependent
<name> is one of: imx8m-var-dart-emmc-wifi-dcss-lvds - Supports LVDS (via DCSS) / WiFi
imx8m-var-dart-emmc-wifi-lcdif-lvds - Supports LVDS (via LCDIF) / WiFi
imx8m-var-dart-emmc-wifi-hdmi - Supports HDMI / WiFi
imx8m-var-dart-sd-emmc-dcss-lvds - Supports LVDS (via DCSS) / SD
imx8m-var-dart-sd-emmc-lcdif-lvds - Supports LVDS (via LCDIF) / SD
imx8m-var-dart-sd-emmc-hdmi - Supports HDMI/SD

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 ./var-mksdcard.sh -f SETUP_NAME /dev/sdX;sync
  • Replace SETUP_NAME with the actual desired setup name accrding to the second table in the "images created" section.
  • Replace /dev/sdX with your true device, You can identify it with dmesg.

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

eMMC based system consist of:

  1. SPL and U-Boot on NAND flash
  2. Rest of Android images in eMMC

7.2.1 Preparing images

All Android built images but system.img are ready for flashing out of the default build.

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_mx8m
$ simg2img system.img system_raw.img
$ simg2img vendor.img vendor_raw.img

Make sure you built Android for eMMC

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

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

7.2.3 Flashing Android with USB Fastboot

Coming soon

7.2.4 Android recovery mode

Coming soon Update Android firmware

Generate OTA packages
Coming soon

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-o8.1.0_1.3.0_8m/android_build
$ source build/envsetup.sh
$ lunch dart_mx8m-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=arm
$ export CROSS_COMPILE=~/var_imx-o8.1.0_1.3.0_8m/android_build/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-