A x86 based Linux system with installed cross-compile toolchain / SDK Android development is required for i.MX 8-based congatec designs. It is possible to use a virtual machine but a dedicated system is preferrable. Furthermore, the host should have a serial port to access the serial console and an SD card reader.
The i.MX 8-based congatec designs require a 64-bit Ubuntu 16.04 system as the host for Android development.
Setting up and building Android
1. Installation in Ubuntu 18.04 64 bit [Clean install]
2. Some packages are needed:
Code Block |
---|
$ sudo apt-get update
$ 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 make libssl-dev gcc-multilib |
3. Config the local git:
Code Block |
---|
$ git config --global user.email "youremail"
$ git config --global user.name "Your name" |
4. A SSH key must be generated
In order to fetch te software from the congatec git server, after login into git.congatec.com go to the link https://git.congatec.com/-/profile/keys and follow the instructions there to generate and link a key with the computer will fetch and build the Yocto BSP.
5. Download and unpack the Android NXP
Download the release package https://www.nxp.com/webapp/sps/download/license.jsp?colCode=11.0.0_1.2.0_ANDROID_SOURCE&appType=file2&DOWNLOAD_ID=null
Code Block |
---|
$ cd ~ (or any other directory you like)
$ tar xzvf imx-android-11.0.0_1.2.0.tar.gz |
In the imx_android_setup.sh script, a .xml file that contains the code repository information is specified. To make the code synchronized by this script the same as the release state, code repository revision is specified with the release tag in this file. The release tag is static and is not moved after the code is published, so no matter when imx_android_setup.sh is executed, the working area of the code repositories synchronized by this script are the same as release state and images being built are the same as prebuilt images.
Code Block |
---|
|
diff --git a/imx_android_setup.sh b/imx_android_setup.sh
index 324ec67..4618679 100644
--- a/imx_android_setup.sh
+++ b/imx_android_setup.sh
@@ -26,7 +26,7 @@ if [ ! -d "$android_builddir" ]; then
# Create android build dir if it does not exist.
mkdir "$android_builddir"
cd "$android_builddir"
- repo init -u <https://github.com/nxp-imx/imx-manifest> -b imx-android-11 -m imx-android-11.0.0_1.2.0_github.xml --repo-branch=v2.4.1
+ repo init -u <https://github.com/nxp-imx/imx-manifest> -b imx-android-11 -m imx-android-11.0.0_1.2.0_github.xml
rc=$?
if [ "$rc" != 0 ]; then
echo "---------------------------------------------------" |
6. Getting i.MX Android NXP
Code Block |
---|
$ mkdir ~/bin
$ curl <https://storage.googleapis.com/git-repo-downloads/repo> > ~/bin/repo
$ chmod a+x ~/bin/repo
$ export PATH=${PATH}:~/bin
$ source imx-android-11.0.0_1.2.0/imx_android_setup.sh
# By default, the imx_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` |
7. Fetch congatec source code
7.1. Android kernel
Code Block |
---|
$ cd $MY_ANDROID
$ cd vendor/nxp-opensource/kernel_imx/
$ git remote add cgtimx8__imx_11.0.0_5.4.70 git@git.congatec.com:arm-nxp/imx8-family/kernel-imx8-family.git
$ git fetch cgtimx8__imx_11.0.0_5.4.70
$ git checkout --track cgtimx8__imx_11.0.0_5.4.70/cgtimx8__imx_11.0.0_5.4.70 |
7.2. Device configuration files
Code Block |
---|
$ cd $MY_ANDROID
$ cd device/nxp
$ git remote add cgtimx8__imx_11.0.0_1.2.0 git@git.congatec.com:arm-nxp/imx8-family/android/device-imx8-family.git
$ git fetch cgtimx8__imx_11.0.0_1.2.0
$ git checkout --track cgtimx8__imx_11.0.0_1.2.0/cgtimx8__imx_11.0.0_1.2.0 |
7.3. Hardware Bluetooth files
Code Block |
---|
$ cd $MY_ANDROID
$ cd hardware/nxp/libbt
$ git remote add cgtimx8__imx_11.0.0_1.2.0 git@git.congatec.com:arm-nxp/imx8-family/android/hardware-nxp-libbt.git
$ git fetch cgtimx8__imx_11.0.0_1.2.0
$ git checkout --track cgtimx8__imx_11.0.0_1.2.0/cgtimx8__imx_11.0.0_1.2.0 |
7.4. Hardware Wlan files
Code Block |
---|
$ cd $MY_ANDROID
$ cd hardware/nxp/wlan
$ git remote add cgtimx8__imx_p11.0.0_1.2.0 git@git.congatec.com:arm-nxp/imx8-family/android/hardware-nxp-wlan.git
$ git fetch cgtimx8__imx_11.0.0_1.2.0
$ git checkout --track cgtimx8__imx_11.0.0_1.2.0/cgtimx8__imx_11.0.0_1.2.0 |
7.5. NXP imx-firmware files
Code Block |
---|
$ cd $MY_ANDROID
$ cd vendor/nxp/imx-firmware
$ git remote add cgtimx8__imx_p11.0.0_1.2.0 git@git.congatec.com:arm-nxp/imx8-family/android/vendor-nxp-imx-firmware.git
$ git fetch cgtimx8__imx_11.0.0_1.2.0
$ git checkout --track cgtimx8__imx_11.0.0_1.2.0/cgtimx8__imx_11.0.0_1.2.0 |
8. Prepare build environment for U-boot
This step is mandatory because there is no GCC cross-compile tool chain in the one in AOSP codebase.
An approach is provided to use the self-installed GCC cross-compile tool chain.
a. Download the tool chain for the A-profile architecture on arm Developer GNU-A Downloads page https://developer.arm.com/downloads/-/gnu-a It is recommended to use the 8.3 version for this release. There are two options, either 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. The first one is dedicated for compiling bare-metal programs, and the second one can also be used to compile the application programs. We recomend to select the second one.
b. 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:
Code Block |
---|
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- |
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.
9. Build the images
One way to make up for the limited RAM is using a bigger swap. Google recommends at least 16GB of RAM/swap so it’s not uncommon to create a 16GB swap when working in VM, to do this please use the following commands.
Code Block |
---|
$ sudo fallocate -l 16g /mnt/16GB.swap
$ sudo chmod 600 /mnt/16GB.swap
$ sudo mkswap /mnt/16GB.swap
$ sudo swapon /mnt/16GB.swap |
Set the environment and build the images
Code Block |
---|
$ cd $MY_ANDROID
$ source build/envsetup.sh
$ lunch cgt_8q-userdebug
$ ./imx-make.sh -j4 2>&1 | tee build-log.txt |
10. Transfer the images to the SD card (/dev/sdX check your device)
After building is complete, you can access the target files with the following command:
Code Block |
---|
$ cd out/target/product/cgt_8q/ |
10.1. conga-SMX8
Code Block |
---|
$ sudo ./imx-sdcard-partition.sh-f imx8qm /dev/sdX
# Beside the default device tree other options are built as well
# To use the PCIeB:
$ sudo ./imx-sdcard-partition.sh-f imx8qm -d pcieb /dev/sdX
# To enable HDMI:
$ sudo ./imx-sdcard-partition.sh-f imx8qm -d hdmi /dev/sdX
# To enable HDMI, PCIeB and LVDS:
$ sudo ./imx-sdcard-partition.sh-f imx8qm -d hdmi-lvds-pcieb /dev/sdX |
10.2. conga-SMX8-X
Code Block |
---|
$ sudo ./imx-sdcard-partition.sh -f imx8qxp /dev/sdX |
11. Bootcontainer
11.1 SMX8
In order to use the bootloader according the target variant follow the next steps to build boot containers
Code Block |
---|
$ cd $MY_ANDROID
$ cd vendor/nxp-opensource/uboot-imx/
$ git remote add cgtimx8__imx_v2020.04_5.4.70_2.3.0 git@git.congatec.com:arm-nxp/imx8-family/uboot-imx8-family.git
$ git fetch cgtimx8__imx_v2020.04_5.4.70_2.3.0
$ git checkout --track cgtimx8__imx_v2020.04_5.4.70_2.3.0/cgtimx8__imx_v2020.04_5.4.70_2.3.0
$ export AARCH64_GCC_CROSS_COMPILE=/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin/aarch64-linux-gnu-
$ make cgtsmx8_android_usd_defconfig
#For 2GB variant
$ echo "CONFIG_CGT_SMX8_MEM_VAR_2GB=y" >> .config
#For 4GB variant
$ echo "CONFIG_CGT_SMX8_MEM_VAR_4GB=y" >> .config
$ make |
In order to build the bootcontainer the cgtbcbe tool is required, to fetch it and set the correct configuration for you variant follow the next steps.
Code Block |
---|
[!!] Open a new terminal
$ cd vendor/nxp-opensource/
$ git clone <https://git.congatec.com/arm-nxp/imx8-family/misc/cgtbcbe.git>
$ cd cgtbcbe
$ git checkout imx8
#For 2GB variant (rev A.2)
$ ./mkbcbe.sh -b BUILD_SMX8 -c mx8/config/cgtsmx8-A2-2GB_BSP-5.4.70_2.3.1_SCFW-1.7.1__rel_cgtsmx8_21-07-14-0.inc.sh
#For 4GB variant (rev A.2)
$ ./mkbcbe.sh -b BUILD_SMX8 -c mx8/config/cgtsmx8-A2-4GB_BSP-5.4.70_2.3.1_SCFW-1.7.1__rel_cgtsmx8_21-07-14-0.inc.sh
# In case the hardware revision is different check the mx8x/config directory and select the configuration script accordingly
$ source ./mkbcbe.sh BUILD_SMX8
$ cp ../../uboot-imx/u-boot.bin .
$ cp ../../imx-mkimage/iMX8QM/hdmi* .
#SD
$ rm -f u-boot-hash.bin; make flash
$ sudo dd if=flash.bin of=/dev/sdX bs=1k seek=32 |
11.2 SMX8-X
In order to use the bootloader according the target variant follow the next steps to build boot containers
Code Block |
---|
$ cd $MY_ANDROID
$ cd vendor/nxp-opensource/uboot-imx/
$ git remote add cgtimx8x__imx_v2020.04_5.4.70_2.3.0 git@git.congatec.com:arm-nxp/imx8-family/uboot-imx8-family.git
$ git fetch cgtimx8x__imx_v2020.04_5.4.70_2.3.0
$ git checkout --track cgtimx8x__imx_v2020.04_5.4.70_2.3.0/cgtimx8x__imx_v2020.04_5.4.70_2.3.0
$ export AARCH64_GCC_CROSS_COMPILE=/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin/aarch64-linux-gnu-
$ make cgtsx8x_android_sd_defconfig
#For 1GB variant
$ echo "CONFIG_CGT_SX8X_MEM_VAR_1GB=y" >> .config
#For 2GB variant
$ echo "CONFIG_CGT_SX8X_MEM_VAR_2GB=y" >> .config
#For 4GB variant
$ echo "CONFIG_CGT_SX8X_MEM_VAR_4GB=y" >> .config
$ make |
In order to build the bootcontainer the cgtbcbe tool is required, to fetch it and set the correct configuration for you variant follow the next steps.
Code Block |
---|
[!!] Open a new terminal
$ cd vendor/nxp-opensource/
$ git clone <https://git.congatec.com/arm-nxp/imx8-family/misc/cgtbcbe.git>
$ cd cgtbcbe
$ git checkout imx8x
#For 1GB variant (rev B.3)
$ ./mkbcbe.sh -b BUILD_SX8X -c mx8x/config/cgtsx8x-B3-1GB_BSP-5.4.70_2.3.3_SCFW-1.7.3__rel_cgtsx8x_21-10-13-0.inc.sh
#For 2GB variant (rev B.3)
$ ./mkbcbe.sh -b BUILD_SX8X -c mx8x/config/cgtsx8x-B3-2GB_BSP-5.4.70_2.3.3_SCFW-1.7.3__rel_cgtsx8x_21-10-13-0.inc.sh
#For 4GB variant (rev B.3)
$ ./mkbcbe.sh -b BUILD_SX8X -c mx8x/config/cgtsx8x-B3-4GB_BSP-5.4.70_2.3.3_SCFW-1.7.3__rel_cgtsx8x_21-10-13-0.inc.sh
# In case the hardware revision is different check the mx8x/config directory and select the configuration script accordingly
$ source ./mkbcbe.sh BUILD_SX8X
$ cp ../../uboot-imx/u-boot.bin .
#SD
$ rm -f u-boot-hash.bin; make REV=C0 flash
$ sudo dd if=flash.bin of=/dev/sdX bs=1k seek=32 |
12. Hardware configuration
Bootcontainer is programmed into the SDcard, therefore the module needs be configured as follows:
conga-SMX8-X
Select on conga-SEVA
M17 ON-ON
M18 OFF-OFF