Skip to main content

IoTGateway/BSP/Android/User Guide 11.0.0 For i.MX8

Introduction

This user guide provides instructions for building and deploying Android 11.0.0 BSP for i.MX8 platforms, specifically for RSB-3720 and RSB-5722/ROM-5722 projects.

Android BSP Version

  • Android Version: 11.0.0
  • Kernel Version: 5.10.72

Build Environment on Host

Currently, we adopt Docker as build environment.

You can get the latest version of advrisc/u18.04-rk3399abv10 Docker image for developing Rockchip RK3399 and rk3568 projects.

Docker Command

docker pull advrisc/u18.04-rk3399abv10:latest

Run Docker Example

Step 1: Run Docker Container

docker run --privileged -it --name android_R11 -v /home/your-name/myandroid:/home/adv/BSP:rw advrisc/u18.04-rk3399abv10 /bin/bash

Step 2: Change User in Container

$ sudo chown adv:adv BSP

Getting Android Source Code

$ cd ~/BSP
$ mkdir bin
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ./bin/repo
$ mkdir imx8_android_R11
$ cd imx8_android_R11
$ git config --global user.name "Your Name"
$ git config --global user.email you@example.com
$ git config --global http.postBuffer 52428800000
$ git config --global http.maxRequestBuffer 100M
$ git config --global core.compression 0
$ ../bin/repo init -u https://dev.azure.com/AIM-Linux/RISC-IMX-Android11/_git/android-manifest -b android-11.0.0_2.6.0 -m default.xml
# If you want to get the latest code, please use default.xml
$ ~/bin/repo sync

Getting Prebuilts (Must Download)

Download Sources:

  • Baidu: prebuilts.tar.gz (Key: 1234)
  • DropBox: prebuilts.tar.gz

Installation Steps

  1. Exit docker and copy the file to your host directory:
$ cp prebuilts.tar.gz /home/your-name/myandroid/imx8_android_R11/android
  1. In container, attach and unzip the file:
$ docker attach android_R11
$ tar zxvf ~/BSP/imx8_android_R11/android/prebuilts.tar.gz

Compile All

i.MX Android platform needs some preparation for the first time when building the images. The image build steps are as follows:

Prepare Build Environment for U-Boot and Linux Kernel

This step is mandatory because there is no GCC cross-compile tool chain in the AOSP codebase. An approach is provided to use the self-installed GCC cross-compile tool chain.

Download ARM GCC Toolchain

  1. Download the tool chain for the A-profile architecture from ARM Developer GNU-A Downloads page
  2. It is recommended to use the 8.3 version for this release
  3. You can download:
    • gcc-arm-8.3-2019.03-x86_64-aarch64-elf.tar.xz (for bare-metal programs)
    • gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz (can also compile application programs)

Install GCC Toolchain

# If "gcc-arm-8.3-2019.03-x86_64-aarch64-elf.tar.xz" is used
$ sudo tar -xvJf gcc-arm-8.3-2019.03-x86_64-aarch64-elf.tar.xz -C /opt
$ export AARCH64_GCC_CROSS_COMPILE=/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-elf/bin/aarch64-elf-

# If "gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz" is used
$ sudo tar -xvJf gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz -C /opt
$ export AARCH64_GCC_CROSS_COMPILE=/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin/aarch64-linux-gnu-

Setup Clang for Kernel Compilation

The clang used to compile Linux kernel needs to be a newer version. Perform the following steps to set the clang to be used to compile Linux kernel:

$ sudo git clone https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86 /opt/prebuilt-android-clang -b master-kernel-build-2021
$ cd /opt/prebuilt-android-clang
$ sudo git checkout bceb7274dda5bb587a5473058bd9f52e678dde98
$ export CLANG_PATH=/opt/prebuilt-android-clang

Note: The preceding export commands can be added to /etc/profile. When the host boots up, AARCH64_GCC_CROSS_COMPILE and CLANG_PATH are set and can be directly used.

Build U-boot

$ ./imx-make.sh bootloader -j8

Build Kernel

$ ./imx-make.sh kernel -j8

Build Android Projects

Build RSB-3720 Android Project

$ source build/envsetup.sh
$ lunch rsb3720_a1-userdebug
$ ./imx-make.sh -j12

Build RSB-5722 Android Project

$ source build/envsetup.sh
$ lunch rom5722_a1-userdebug
$ ./imx-make.sh -j12

Output Images

All images are located in: out/target/product/${Project_Name}/

The common image files are listed below:

boot.img
dtbo-imx8mp.img
partition-table-28GB.img
partition-table.img
super.img
u-boot-imx8mp.imx
vbmeta.img
vbmeta-imx8mp.img
vendor_boot.img
vendor.img

How to Flash Images

Flash Images to SD Card

$ cd out/target/product/${Project_Name}/
$ sudo ./imx-sdcard-partition.sh -f imx8mp /dev/sdx

Note: Replace /dev/sdx with your actual SD card device path.

Flash Images to eMMC

# Note: put the image folder and script (imx-emmc-partition.sh) into /data folder (in the system)
$ sudo ./imx-emmc-partition.sh -f imx8mp /dev/block/mmcblk2

Supported Hardware Platforms

  • RSB-3720: Industrial SBC with i.MX8M Plus processor
  • RSB-5722/ROM-5722: Computer-on-Module with i.MX8M Plus processor

Requirements

  • Docker environment with advrisc/u18.04-rk3399abv10 image
  • ARM GCC 8.3 toolchain
  • Clang prebuilts for kernel compilation
  • Sufficient disk space for Android source code and build artifacts
  • Internet connection for downloading source code and dependencies

This document was last modified on 3 January 2024, at 03:54.