Versions Compared

Key

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

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 13.0.0_1.2.0 Early Access Build Guide

1. Setting up your computer

To build the Android source files, use a computer running the Linux OS. (The Ubuntu 18.04 64-bit version is the most tested environment for the Android 13.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 curl \
	 u-boot-tools \
	 mtd-utils \
	 android-sdk-libsparse-utils \
	 android-sdk-ext4-utils \
	 device-tree-compiler \
	 gdisk \
	 m4 \
	 zlib1g-dev \
	 bison \
	 flex make \
	 libssl-dev \
	 gcc-multilib \
	 libghc-gnutls-dev \
	 swig \
	 liblz4-tool \
	 liblz4-tool \
	 libdw-dev \
	 dwarves \
	 bc cpio tar lz4 rsync \
	 ninja-build clang

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 and Kernel

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 9.2 version for this release. You can download the gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf.tar.xz or gcc-arm-9.2-2019.12-x86_64-aarch64-none-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-9.2-2019.12-x86_64-aarch64-none-elf.tar.xz is used

Code Block
languagebash
sudo tar -xvJf gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf.tar.xz -C /opt
export AARCH64_GCC_CROSS_COMPILE=/opt/gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf/bin/aarch64-none-elf-
Code Block
- If ```gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz``` is used
Code Block
languagebash
sudo tar -xvJf gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz -C /opt 
export AARCH64_GCC_CROSS_COMPILE=/opt/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-

Follow below steps to set external clang tools for kernel building:

Code Block
sudo git clone <https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86> /opt/prebuilt-android-clang
cd /opt/prebuilt-android-clang
sudo git checkout 0fc0715d9392ca616605c07750211d7ca71f4e36
export CLANG_PATH=/opt/prebuilt-android-clang

Note: The preceding command 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.

3. Building the Android platform

  • 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

The software provided by congatec can be found on the congatec Git server (https://git.congatec.com). The server can be accessed either via the web interface or via SSH. For the SSH access, required for an Early Access release, a SSH key pair must be generated and the public key registered at the https://git.congatec.com/-/profile/keys page (note that an account on the congatec Git server is required here).

  • Afterwards get congatec patch

Code Block
languagebash
$ git clone ssh://git@git.congatec.com/arm-nxp/imx8-family-ea/imx8m/android android-13
$ cp imx-android-13.0.0_1.2.0.tar.gz android-13
$ cd android-13
$ tar xzvf imx-android-13.0.0_1.2.0.tar.gz
$ cp cgt_android_setup.sh imx-android-13.0.0_1.2.0/
$ cd imx-android-13.0.0_1.2.0/
  • To generate the Congatec i.MX Android release source code build environment, execute the following commands:

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`

3.1 Setup environment for conga-SMX8-Plus

  • After all packages are downloaded setup Android environment for conga-SMX8-Plus:

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

3.2 Setup environment for conga-QMX8-Plus

  • After all packages are downloaded setup Android environment for conga-QMX8-Plus:

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_qx8p or ${MY_ANDROID}/out/target/product/cgt_sx8p

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

4.1 conga-SMX8-Plus

To program the image to SD card use these commands:

Code Block
languagebash
$ cd ${MY_ANDROID}/out/target/product/cgt_sx8p
$ sudo imx-sdcard-partition.sh -f imx8mp -d cgtsx8p -c 28 /dev/sd<X>

4.1 conga-QMX8-Plus

To program the image to SD card use these commands:

Code Block
languagebash
$ cd ${MY_ANDROID}/out/target/product/cgt_qx8p
$ sudo imx-sdcard-partition.sh -f imx8mp -d cgtqx8p -c 28 /dev/sd<X>

5. Program bootconatiner into SPI flash

Connect the host system with an USB OTG cable to module
Get uuu tool version 1.4.243

5.1 conga-QMX8-Plus

Use the USB-OTG port of conga-QMX8-Plus to update the bootcontainer. Dip 1 of Switch M13 must be set to ON when updating the conga-QMX8-Plus bootloader.

Code Block
$ sudo ./uuu.exe -b qspi bootcontainer__imx8mp-cgtqx8p-yocto.bin bootcontainer__imx8mp-cgtqx8p-android.bin

5.2 conga-SMX8-Plus

Use the USB-OTG port of conga-SMX8-Plus to update the bootcontainer. Dip M17(1,2) and M18(1) must be set to OFF when updating the conga-SMX8-Plus bootloader.

Code Block
$ sudo ./uuu.exe -b qspi bootcontainer__imx8mp-cgtsx8p-yocto.bin bootcontainer__imx8mp-cgtsx8p-android.bin

or use the ECC version

Code Block
$ sudo ./uuu.exe -b qspi bootcontainer__imx8mp-cgtsx8p-yocto.bin bootcontainer__imx8mp-cgtsx8p-android_ecc.bin

Power up module and wait until flash has finished
Power off module
Set boot mode switches to standard boot
Power up and check uboot version