i.MX8 - iMX8MEVK - Android - Building Android
System Requirements
The minimum recommended system requirements are the following:
- 16 GB RAM
- 300 GB hard disk
Establishing a Build Environment (Host Machine)
The host development environment for Android is based on Ubuntu and Debian. Please install Ubuntu version 14.04/16.04 64bit LTS or Debian 8.4 64bit. Those are the recommended Operating Systems for Android.
Setting up a Linux Environment
- Select a Branch: You can choose to download and build the latest source code (called master), in which case you will simply omit the branch specification when you initialize the repository. Otherwise, you should specify the branch you plan to use. Find more information about platform codenames, versions, API Levels and NDK Releases in this page. You can access the whole Git repositories on Android in here.
Required Packages
In addition to the packages requested on the Android website, the following packages are also needed:
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib sudo apt-get install libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils sudo apt-get 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 install bc sudo apt-get install device-tree-compiler sudo apt-get install gdisk
Installing the Java Development Kit (JDK)
The master branch of Android comes with pre-built versions of OpenJDK below prebuilts/jdk/ so no additional installation is required.
- For Ubuntu >= 15.04 run the following:
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
Building the Android platform for i.MX
This section describes how to build the Android platform for the i.MX 8 series devices. The main information was taken from the Android User's Guide.
Getting i.MX Android release source code
The image can be downloaded from the following page: Android Release.
Unpack the Android Release Package
Let's consider the Oreo 8.1 as the required package, which name is imx-o8.1.0_1.3.0_8m.tar.gz. After you have set up a computer running Linux OS, unpack the Android release package as follows:
tar xzvf imx-o8.1.0_1.3.0_8m.tar.gz
The i.MX Android release source code consists of 3 parts:
- NXP i.MX public source code: maintained in the CodeAurora Forum repository.
- AOSP Android public source code: maintained in android.googlesource.com.
- NXP i.MX Android proprietary source code package: maintained in www.NXP.com. Get the code from the following link: i.MX Android Source Code Package
If you have i.MX Android proprietary source code package imx-o8.1.0_1.3.0_8m.tar.gz under ~/. directory. To generate the i.MX Android release source code build environment, execute the following commands:
mkdir ~/bin curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo chmod a+x ~/bin/repo export PATH=${PATH}:~/bin source ~/imx-o8.1.0_1.3.0_8m/imx_android_setup.sh # By default, the imx_android_setup.sh script will create the source code build environment in the folder ~/android_build # ${MY_ANDROID} will be referred as the i.MX Android source code root directory in all i.MX Android release documentation. export MY_ANDROID=~/android_build
Building Android images
Commands lunch <buildName-buildType> to set up the build configuration and make to start the build process are executed. The build configuration command lunch can be issued with an argument <Build name>-<Build type> string, such as lunch evk_8mq-userdebug, or can be issued without the argument, which will present a menu of options to select. The Build Name is the Android device name found in the directory ${MY_ANDROID}/device/fsl/. The following table lists the i.MX Build Names.
Build Name | Description |
---|---|
evk_8mq | i.MX 8MQuad EVK Board |
The build type is used to specify what debug options are provided in the final image. The following table lists the Build Types.
Build Type | Description |
---|---|
user | Production-ready image, no debug |
userdebug | Provides image with root access and debug, similar to "user" |
eng | Development image with debug tools |
Android build steps are as follows:
1. Change to the top level build directory.
cd ${MY_ANDROID}
2. Set up the environment for building. This only configures the current terminal.
source build/envsetup.sh
3. Execute the Android lunch command. In this example, the setup is for the production image of i.MX 8MQuad EVK Board/Platform device with userdebug type.
lunch evk_8mq-userdebug
4. Execute the make command to generate the image.
make 2>&1 | tee build-log.txt
When the make command is complete, the build-log.txt file contains the execution output. Check for any errors.
Running the Android Platform with a Prebuilt Image
To test the Android platform before building any code, you can use the pre-built images by following this guide or by using the following packages:
Image Package | Description |
---|---|
android_O8.1.0_1.3.0_8M_image_8mq.tar.gz | Prebuilt-image for i.MX 8MQuad EVK board, which includes NXP extended features. |
The tables below list the detailed contents of android_O8.1.0_1.3.0_8M_image_8mq.tar.gz image package. The table below shows the pre-built images to support the system boot from SD and eMMC on i.MX 8MQuad EVK boards.
i.MX 8MQuad EVK Image | Description |
---|---|
u-boot-imx8mq.imx | Bootloader (with padding) for i.MX 8MQuad EVK board. |
partition-table.img | GPT table image for 16 GB SD card and eMMC. |
partition-table-7GB.img | GPT table image for 8 GB SD card. |
partition-table-28GB.img | GPT table image for 32 GB SD card. |
boot-imx8mq.img | Boot image for i.MX 8MQuad EVK board to support HDMI output. |
/boot-imx8mq-mipi.img | Boot image for i.MX 8MQuad EVK board to support MIPI-toHDMI output. |
/boot-imx8mq-dual.img | Boot image for i.MX 8MQuad EVK board to support HDMI and MIPI-to-HDMI dual output. |
/boot-imx8mq-mipi-panel.img | Boot image for i.MX 8MQuad EVK board to support MIPI panel output. |
system.img | System Boot image. |
vbmeta-imx8mq.img | Android Verify Boot metadata Image for i.MX 8MQuad EVK board to support HDMI output. |
/vbmeta-imx8mq-mipi.img | Android Verify Boot metadata image for i.MX 8MQuad EVK board to support MIPI-to-HDMI output. |
/vbmeta-imx8mq-dual.img | Android Verify Boot metadata image for i.MX 8MQuad EVK board to support HDMI and MIPI-to-HDMI dual output. |
/vbmeta-imx8mq-mipi-panel.img | Android Verify Boot metadata image for i.MX 8MQuad EVK board to support MIPI panel output. |
vendor.img | Vendor image for i.MX 8MQuad EVK board. |
There are two methods for the build of the Android image.
Method 1: Set the environment first and then issue the make command:
cd ${MY_ANDROID} source build/envsetup.sh make PRODUCT-XXX #XXX depends on different board, see table below:
i.MX Development Tool | Description | Image Build Command |
---|---|---|
Evaluation Kit | i.MX 8MQuad EVK | make PRODUCT-evk_8mq-userdebug>&1 | tee buildlog.txt |
Method 2: Set the environment and then use lunch command to configure argument. See table below. An example for the i.MX 8MQuad EVK board is as follows:
cd ${MY_ANDROID} source build/envsetup.sh lunch evk_8mq-userdebug make
Note: evk_8mq-userdebug creates a debuggable version of Android and evk_8mq-eng creates an engineering version of Android. Development mode enable and development tools are available on target.