Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Note

Important - preliminary

The documented BSP is a preliminary version with restrictions and can change at any time.

The sole purpose of the BSP is to allow early adopters to start with their development.

Android 11.0.0_1.2.0 Build Guide

Rev: Preliminary

1. Setting up your computer

To build the Android source files, use a computer running the Linux OS. (The Ubuntu 16.04 64-bit version is the most tested environment for the Android 11.0 build.)
To synchronize the code and build images of this release, the computer should at least have:
• 450 GB free disk space
• 16 GB RAM
After installing the computer running Linux OS, check whether all the necessary packages are installed for an Android build. See
"Establishing a Build Environment" on the Android website.
In addition to the packages requested on the Android website, the following packages are also needed:

Code Block
languagebash
$ sudo apt-get install uuid uuid-dev \
zlib1g-dev liblz-dev \
liblzo2-2 liblzo2-dev \
lzop \
git-core curl \
u-boot-tools \
mtd-utils \
android-tools-fsutils \
device-tree-compiler \
gdisk \
m4 \
libz-dev \
bison \
flex \
libssl-dev \
gcc-multilib

Configure git before use. Set the name and email as follows:

Code Block
languagebash
$ git config --global user.name "First Last"
$ git config --global user.email "first.last@company.com"

2. Prepare the build environment for U-Boot.

This step is mandatory because there is no GCC cross-compile tool chain in the one in AOSP codebase.

Google started to put a limit on the host tools used when compiling Android code from Android 10.0 platform. Some host tools necessary for building U-Boot/kernel now cannot be used in the Android build system, which is under the control of soong_ui, so U-Boot/kernel cannot be built together with Android images. Google also recommends to use prebuilt binaries for U-Boot/kernel in Android build system. It takes some steps to build U-Boot/kernel to binaries and put these binaries in proper directories, so some specific Android images depending on these binaries can be built without error. imx-make.sh is then added to do these steps to simplify the build work. After U-Boot/kernel are compiled, any build commands in standard Android can be used.

An approach is provided to use the self-installed GCC cross-compile tool chain.

  • Download the tool chain for the A-profile architecture on arm Developer GNU-A Downloads page. It is recommended to use the 8.3 version for this release. You can download the gcc-arm-8.3-2019.03-x86_64-aarch64-elf.tar.xz or gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz from ARM developer GNU-A pages. The first one is dedicated for compiling bare-metal programs, and the second one can also be used to compile the application programs.

  • Decompress the file into a path on local disk, for example, to /opt/. Export a variable named AARCH64_GCC_CROSS_COMPILE to point to the tool as follows:

    • If gcc-arm-8.3-2019.03-x86_64-aarch64-elf.tar.xz is used

Code Block
languagebash
$ 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

Code Block
languagebash
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-

Note: The preceding command can be added to /etc/profile. When the host boots up, AARCH64_GCC_CROSS_COMPILE is set and can be directly used.

3. Building the Android platform for CGTSX8P

  • Install repo tool necessary to download all Android AOSP packages

Code Block
languagebash
$ mkdir ~/bin
$ curl <https://storage.googleapis.com/git-repo-downloads/repo> > ~/bin/repo
$ chmod a+x ~/bin/repo
$ export PATH=${PATH}:~/bin
  • Clone Android-11_AOSP package from congatec GIT repository and launch AOSP download script:

Code Block
languagebash
$ git clone ssh://git@git.congatec.com/arm-nxp/imx8-family-ea/imx8m/android-11_aosp
$ cd android-11_aosp/
$ git checkout --track remotes/origin/cgtimx8mp_imx_android_11.0.0_1.2.0
$ tar xzvf imx-android-11.0.0_1.2.0.tar.gz
$ cp cgt_android_setup.sh imx-android-11.0.0_1.2.0/
$ cp cgt_android_setup__qx8p.sh imx-android-11.0.0_1.2.0/
$ cd imx-android-11.0.0_1.2.0/
  • To generate the Congatec i.MX Android release source code build environment, execute the following commands for conga-SX8P:

Code Block
languagebash
$ source ./cgt_android_setup.sh
# By default, the cgt_android_setup.sh script downloads source code and changes current directory to source code root directory.
# ${MY_ANDROID} will be refered as the i.MX Android source code root directory in all i.MX Andorid release documentation.
$ export MY_ANDROID=`pwd`
  • To generate the Congatec i.MX Android release source code build environment, execute the following commands for conga-QX8P:

Code Block
languagebash
$ source ./cgt_android_setup__qx8p.sh
# By default, the cgt_android_setup.sh script downloads source code and changes current directory to source code root directory.
# ${MY_ANDROID} will be refered as the i.MX Android source code root directory in all i.MX Andorid release documentation.
$ export MY_ANDROID=`pwd`
  • After all packages are downloaded setup Android environment for conga-SX8P:

Code Block
languagebash
$ source build/envsetup.sh
$ lunch cgt_sx8p-<build_mode>
  • For conga-QX8P:

Code Block
languagebash
$ source build/envsetup.sh
$ lunch cgt_qx8p-<build_mode>

Where <build-mode> can be:

Build mode

Description

user

Production ready image, no debug available

userdebug

Provides image with root access and debug feature

After the two commands above are executed, the build process is not started yet. It is at a stage that the next command is necessary to be used to start the build process. There are some differences from pure Android AOSP. A shell script named cgt-make.sh is provided and its symlink file can be found under ${MY_ANDROID} directory, and ./cgt-make.sh should be executed first to start the build process.

The original purpose of this cgt-make.sh is to build U-Boot / kernel before building Android images.

  • Execute the imx-make.sh script to generate the image.

Code Block
languagebash
$ ./cgt-make.sh -j4 2>&1 | tee build-log.txt

It is possible to compile uboot, kernel and AOSP with separate steps

Code Block
languagebash
# uboot
$ ./cgt-make.sh -j4 bootloader 2>&1 | tee uboot-build-log.txt
# kernel
$ ./cgt-make.sh -j4 kernel 2>&1 | tee kernel-build-log.txt
# AOSP
$ ./make -j4  2>&1 | tee build-log.txt

The build process takes several hours. The following outputs are generated by default in ${MY_ANDROID}/out/target/product/cgt_sx8p or ${MY_ANDROID}/out/target/product/cgt_qx8p:

root/: Root file system, it is used to generate system.img together with files in system/.
system/: Android system binary/libraries. It is used to generate system.img together with files in root/.
recovery/: Root file system, intergrated into boot.img as a part of the ramdisk and used by the Linux kernel when the system boots up.
vendor-ramdisk: Integrated into vendor_boot.img as another part of the ramdisk and used by the Linux kernel when the system boots up.
dtbo-imx8mp.img: Board's device tree binary. It is used to support the sx8p with SEVAL base board.
dtbo-imx8mp-basler-CSI0.img Board's device tree binary. It is used to support sx8p with SMC base board and with the MIPI-CSI Basler VVCAM camera plugged in CSI0 slot
dtbo-imx8mp-basler-CSI1.img Board's device tree binary. It is used to support sx8p with SMC base board and with the MIPI-CSI Basler VVCAM camera plugged in CSI1 slot
vbmeta-imx8mp.img: Android Verify boot metadata image for dtbo-imx8mp.img.
vbmeta-imx8mp-basler-CSI0.img: Android Verify boot metadata image for dtbo-imx8mp-basler-CSI0.img.
vbmeta-imx8mp-basler-CSI1.img: Android Verify boot metadata image for dtbo-imx8mp-basler-CSI1.img.
ramdisk.img: Ramdisk image generated from root/. Not directly used.
system.img: EXT4 image generated from system/ and root/.
system_ext.img: EXT4 image generated from system_ext/.
product.img: EXT4 image generated from product/.
partition-table.img: GPT partition table image for single bootloader condition. Used for 16 GB sdcard and eMMC.
partition-table-dual.img: GPT partition table image for dual bootloader condition. Used for 16 GB sdcard and eMMC. Not supported for congatec sx8p.
partition-table-28GB.img: GPT partition table image for single bootloader condition. Used for 32 GB sdcard.
partition-table-28GB-dual.img: GPT partition table image for dual bootloader condition. Used for 32 GB sdcard. Not supported for congatec sx8p.
u-boot-imx8mp.imx: U-Boot image without Trusty OS integrated for congatec sx8p board.
vendor.img: Vendor image, which holds platform binaries. Mounted at /vendor.
super.img: Super image, which is generated with system.img, system_ext.img, vendor.img, and product.img.
boot.img: A composite image, which includes the kernel Image, a part of ramdisk, and boot parameters.
vendor_boot.img: A composite image, which includes another part of ramdisk and boot parameters.
rpmb_key_test.bin: Prebuilt test RPMB key. Can be used to set the RPMB key as fixed 32 bytes 0x00.
testkey_public_rsa4096.bin: Prebuilt AVB public key. It is extracted from the default AVB private key.

4. Programming Images

Current congatec AOSP supports only SD card deployment. To download all images to SD card there is a script:
imx-sdcard-partition.sh

To program the image to SD card use these commands:

Code Block
languagebash
$ cd ${MY_ANDROID}/out/target/product/cgt_sx8p
# SEVAL version
$ sudo imx-sdcard-partition.sh -f imx8mp /dev/sd<X>
# or for basler camera on CSI<X> where X = {0,1}
$ sudo imx-sdcard-partition.sh -f imx8mp -d basler-CSI<X> /dev/sd<X>

5. Current limitations

Preliminary congatec Android AOSP does't support all features provided by NXP. There is the list of limitations:

Missing features:

  • disabled buggy watchdog driver

  • trusty OS support

  • dual boot support