Personal tools

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

From ICOP tech wiki

Jump to: navigation, search
  Android Platform Customization  

- Android Developer Guide


Introduction

This Wiki describes how to build and deploy Android on the . It is based on NXP's release

Overview

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

Supported hardware and features

Android Platform Customization

Hardware Requirements

You will need the Variscite based evaluation kit.

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.

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

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
$ 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 libz-dev

Configure GIT account

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

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

Files:

  • - NXP's i.MX8M original BSP patch files.


Get NXP's Android Release Package

$ mkdir 
$ cd 
$ curl -o ~/Downloads/ 
$ tar xvf ~/Downloads/

Download Google Android

$ 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 
$ source /imx_android_setup.sh

Wait for the script to finish running, and it should create a "/" folder

$ cd /; mkdir -p vendor/variscite/

Clone Variscite's U-Boot and Linux kernel sources

$ cd //vendor/variscite/
$ git clone  -b 
$ git clone  kernel_imx -b 

Apply Variscite's i.MX platforms' patches

$ cd //device
$ git clone  -b  variscite
$ variscite/scripts/install.sh

Build Android Images

Change to Android top level directory.

$ cd /
$ source build/envsetup.sh
$ lunch -eng
or
$ lunch -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

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


Images created by the Android build

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

Android Platform Customization

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 ./var-mksdcard.sh -f <name> /dev/sdX;sync

Boot From SD card

Android Recovery SD card

Flash and boot Android from eMMC

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/
$ 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 q in the U-Boot command line.

On the Host PC: Android Platform Customization Replace <name> with the actual desired setup name according to the table in the "Images created by the Android build" section.

Android recovery mode

Enter board in Android Recovery mode

Turn on the device by holding down the "back" button must be held until the end of the boot and logged in "Android Recovery" mode.

Control menu in Android Recovery Mode

  1. To switch between menu items, use a short press of UP or DOWN buttons
  2. To highlight an item, use a long press of BACK or HOME buttons or long touch the touchscreen
  3. To activate an item, use a short press of ON/OFF button

Update Android firmware

Generate OTA packages

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

$ cd /
$ make PRODUCT=-userdebug otapackage -j4 2>&1 | tee build1-1.log
Install OTA package to device
  • extract payload.bin and payload_properties.txt from OTA zip file
  • 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
  • Issue the following command on adb shell:
 update_engine_client --payload=file:///cache/payload.bin --update --headers="FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
 FILE_SIZE=379074366
 METADATA_HASH=Icrs3NqoglzyppyCZouWKbo5f08IPokhlUfHDmz77WQ/de8Dgp9zFXt8Fo+Hxccp465uTOvKNsteWU=
 METADATA_SIZE=46866"

Note that the command argument --headers="..." contains the exact (4-line) content of the payload_properties.txt file between quotes (you can copy and paste it), including 3 newline characters.

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 /
$ source build/envsetup.sh
$ lunch -userdebug
$ make bootimage

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=//prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-