Android TI Guide: Difference between revisions

From Variscite Wiki
(Created page with "<!-- Set release according to "release" parameter in URL and use RELEASE_O8.1.0_1.3.0_8M_DART-MX8M as default --> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!-- --> {{#lst:Android_Platform_Customization|{{#var:RELEASE_PARAM|RELEASE_O8.1.0_1.3.0_8M_DART-MX8M}}}} <!-- --> {{PageHeader|{{#var:HARDWARE_NAME}} - {{#var:ANDROID_NXP_VERSION}} Developer Guide}} {{DocImage|category1=Android|category2={{#var:HARDWARE_NAME}}}} __toc__ = Introduction<br/> = This page descri...")
 
 
(139 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<!-- Set release according to "release" parameter in URL and use RELEASE_O8.1.0_1.3.0_8M_DART-MX8M as default
<!-- Set release according to "release" parameter in URL and use am62-android-13_09.00.00-v1.0 as default
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!--
--> {{INIT_RELEASE_PARAM|am62-android-13_09.00.00-v1.0}}<!--
--> {{#lst:Android_Platform_Customization|{{#var:RELEASE_PARAM|RELEASE_O8.1.0_1.3.0_8M_DART-MX8M}}}} <!--
--> {{#lst:Android_Platform_Customization|{{#var:RELEASE_PARAM|am62-android-13_09.00.00-v1.0}}}} <!--
--> {{PageHeader|{{#var:HARDWARE_NAME}} - {{#var:ANDROID_NXP_VERSION}} Developer Guide}} {{DocImage|category1=Android|category2={{#var:HARDWARE_NAME}}}} __toc__
--> {{PageHeader|{{#var:HARDWARE_NAME}} - {{#var:ANDROID_TI_VERSION}} Developer Guide}} {{DocImage|category1=Android|category2={{#var:HARDWARE_NAME}}}} __toc__
= Introduction =


= Introduction<br/> =
This page describes how to build and deploy {{#var:ANDROID_NAME}} on the {{#var:HARDWARE_NAME}}. It is based on TI's {{#var:ANDROID_TI_VERSION}} release.
 
This page describes how to build and deploy {{#switch: Android 13 = {{#var:ANDROID_NAME}} | Android {{#var:ANDROID_NAME}} }} on the {{#var:HARDWARE_NAME}}.<br> It is based on TI's {{#var:ANDROID_TI_VERSION}} release


= Overview =
= Overview =
Line 19: Line 18:
*Download & build the sources.
*Download & build the sources.
*Install the binaries on the {{#var:HARDWARE_NAME}} SOM and variants.
*Install the binaries on the {{#var:HARDWARE_NAME}} SOM and variants.
*Making Changes to kernel/configuration and update {{#var:HARDWARE_NAME}} SOM and variants.


= Supported hardware and features =
= Supported Hardware and Features =
{{#lst:Android_Platform_Customization|{{#var:ANDROID_SUPPORTED_HARDWARE_SECTION}}}}


= Hardware Requirements =
= Hardware Requirements =
You will need the Variscite {{#var:HARDWARE_NAME}} based evaluation kit.
You will need the Variscite {{#var:HARDWARE_NAME}} based evaluation kit.


== Host (PC) setup requirements ==
== Host (PC) Setup Requirements ==


The host development environment for Android is based on Ubuntu, please install one of the following Ubuntu versions:
The host development environment for Android is based on Ubuntu, please install one of the following Ubuntu versions:
Line 32: Line 31:


If you are running Linux in a virtual machine you need at least 16GB of RAM and 32 GB of swap. <br>
If you are running Linux in a virtual machine you need at least 16GB of RAM and 32 GB of swap. <br>
The build process requires ~250GB of free storage space. Before starting a build, make sure you have adequate free space available.
The build process requires ~250GB of free storage space of SSD. <br>
 
Before starting a build, make sure you have adequate free space available.
{{Note|'''Note:''' Do not use other Ubuntu releases other than the ones recommended above. Variscite provides Docker containers that can be used for a development environment as an alternative to using a virtual machine or a dedicated computer.


To learn more, please see Variscite's [[Docker_Build_Environment | Docker Build Environment]] guide.
{{Note|'''NOTE:''' Avoid using Ubuntu releases other than those recommended above. </br></br>Variscite offers Docker containers as an alternative for a development environment, which can be used instead of a virtual machine or a dedicated computer. </br>To learn more, please see Variscite's [[Docker_Build_Environment | Docker Build Environment]] guide. </br>Windows with WSL/WSL2 is not supported for Android BSP.}}
Windows with WSL/WSL2 is not supported for Android BSP}}


=== Install required packages on host PC ===
=== Install required packages on host PC ===
<pre>
<pre>
$ sudo apt-get -y install gnupg flex bison gperf build-essential zip gcc-multilib g++-multilib  
$ sudo apt -y install gnupg flex bison gperf build-essential gcc-multilib g++-multilib
$ sudo apt-get -y install libc6-dev-i386 libncurses5 libncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libz-dev libssl-dev
$ sudo apt -y install python3-pyelftools python3-dev python3.6 python2 python-is-python3
$ sudo apt-get -y install ccache libgl1-mesa-dev libxml2-utils xsltproc unzip bc
$ sudo apt -y install libc6-dev-i386 libncurses5 libncurses5-dev lib32z-dev libz-dev liblz-dev liblzo2-2 liblzo2-dev lzop lz4 cpio
$ sudo apt-get -y install uuid uuid-dev zlib1g-dev liblz-dev liblzo2-2 liblzo2-dev lzop git curl 
$ sudo apt -y install libgl1-mesa-dev libxml2-utils xsltproc unzip bc libssl-dev ccache curl
$ sudo apt-get -y install u-boot-tools mtd-utils android-tools-fsutils device-tree-compiler gdisk m4 dwarves libgnutls28-dev
$ sudo apt -y install git zip swig mtools uuid uuid-dev zlib1g-dev u-boot-tools lib32z1-dev fontconfig
$ sudo apt-get -y install libelf-dev cpio lz4 python-is-python3
$ sudo apt -y install mtd-utils device-tree-compiler gdisk m4 dwarves libgnutls28-dev libelf-dev x11proto-core-dev libx11-dev
</pre>
</pre>


Line 52: Line 49:
The package '''android-tools-fsutils''' is obsolete and has been replaced by '''android-sdk-libsparse-utils'''.
The package '''android-tools-fsutils''' is obsolete and has been replaced by '''android-sdk-libsparse-utils'''.
<pre>
<pre>
$ sudo apt-get -y install android-sdk-libsparse-utils
$ sudo apt -y install android-sdk-libsparse-utils
</pre>
</pre>


Line 62: Line 59:
To install it:
To install it:


  $ sudo apt-get update
  $ sudo apt update
  $ sudo apt-get install openjdk-8-jdk
  $ sudo apt 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:
If your Ubuntu version is missing the package (which shouldn't happen), add the PPA repository and run the previous commands again:
Line 78: Line 75:
Android 13 = {{#vardefine:HOST_OS|UBUNTU_18_04_20_04_22_04}} | {{#vardefine:HOST_OS|UBUNTU_16_04_18_04}}}}
Android 13 = {{#vardefine:HOST_OS|UBUNTU_18_04_20_04_22_04}} | {{#vardefine:HOST_OS|UBUNTU_16_04_18_04}}}}


 
=== Check Python Version ===
=== Check python version ===
In the next steps, we will download (from Google repositories) the command repo, used to download all the Android source repositories.
In the next steps, we will download (from Google repositories) the command repo, used to download all the Android source repositories.
{{#switch: {{#var:ANDROID_NAME}} | Android 10 = {{#vardefine:HOST_OS|UBUNTU_16_04_18_04}} | Android 11 = {{#vardefine:HOST_OS|UBUNTU_18_04_20_04_22_04}} | Android 12 = {{#vardefine:HOST_OS|UBUNTU_18_04_20_04_22_04}} | Android 13 = {{#vardefine:HOST_OS|UBUNTU_18_04_20_04_22_04}} | {{#vardefine:HOST_OS|UBUNTU_16_04_18_04}}}}
{{#switch: {{#var:ANDROID_NAME}} | Android 10 = {{#vardefine:HOST_OS|UBUNTU_16_04_18_04}} | Android 11 = {{#vardefine:HOST_OS|UBUNTU_18_04_20_04_22_04}} | Android 12 = {{#vardefine:HOST_OS|UBUNTU_18_04_20_04_22_04}} | Android 13 = {{#vardefine:HOST_OS|UBUNTU_18_04_20_04_22_04}} | {{#vardefine:HOST_OS|UBUNTU_16_04_18_04}}}}
Line 89: Line 85:


  $ sudo add-apt-repository ppa:deadsnakes/ppa
  $ sudo add-apt-repository ppa:deadsnakes/ppa
  $ sudo apt-get update
  $ sudo apt update
  $ sudo apt-get install python3.6 python2
  $ sudo apt install python3.6 python2
|
|
Certain tools like bpttools requires python2 which is not available default on Ubuntu 20.04 or 22.04 LTS. <br>
Certain tools like bpttools requires python2 which is not available default on Ubuntu 20.04 or 22.04 LTS. <br>
Ubuntu 20.04/22.04 LTS users can install it running
Ubuntu 20.04/22.04 LTS users can install it running


$ sudo apt install software-properties-common
  $ sudo add-apt-repository ppa:deadsnakes/ppa
  $ sudo add-apt-repository ppa:deadsnakes/ppa
  $ sudo apt-get update
  $ sudo apt update
  $ sudo apt-get install python3.6 python2
  $ sudo apt install python3.6 python2


  {{#switch: {{#var:ANDROID_NAME}} | Android 10 =   
  {{#switch: {{#var:ANDROID_NAME}} | Android 10 =   
Line 109: Line 106:
}}
}}


= Obtain source code =
= Obtain Source Code =


Variscite's Linux kernel and U-Boot are available through Github.<br>
Variscite's Linux kernel and U-Boot are available through Github. Required patches for the Android file system are pre-installed<br>
Required patches for the Android file system are pre-installed<br>
<br>
<br>
Files:<br>
* {{#var:ANDROID_VARFTP_BASE_PATCH_FILE}} - NXP's {{#var:ANDROID_NXP_VERSION}} original BSP patch files.<br>
== Get NXP's Android Release Package ==
$ mkdir {{#var:BUILD_FOLDER}}
$ cd {{#var:BUILD_FOLDER}}
$ curl -o ~/Downloads/{{#var:ANDROID_VARFTP_BASE_PATCH_FILE}} {{#var:ANDROID_VARFTP_PATCH_DIR}}{{#var:ANDROID_VARFTP_BASE_PATCH_FILE}}
$ tar xvf ~/Downloads/{{#var:ANDROID_VARFTP_BASE_PATCH_FILE}}


== Download Google {{#var:ANDROID_VERSION}} ==
== Download Google Repo Tool ==
{{Note|Important update:
As of March 31, 2023, all codeaurora.org repositories have been migrated to other platforms and the project has been shut down.<br>
For more information, please visit: https://bye.codeaurora.org/<br>
<br>
In this context, errors may occur when downloading the source code running the script, such as:<br>
<code>fatal: unable to look up source.codeaurora.org (port 9418) (No address associated with hostname)</code><br>
<br>
Variscite has updated all relevant software repositories. Please re-download {{#var:ANDROID_VARFTP_PATCH_DIR}}{{#var:ANDROID_VARFTP_BASE_PATCH_FILE}} and the full Android source code from Variscite FTP <br>
|error}}
  $ mkdir -p ~/bin
  $ mkdir -p ~/bin
  $ curl -o ~/bin/repo https://commondatastorage.googleapis.com/git-repo-downloads/repo
  $ curl -o ~/bin/repo https://commondatastorage.googleapis.com/git-repo-downloads/repo
  $ chmod a+x ~/bin/repo
  $ chmod a+x ~/bin/repo
  $ export PATH=~/bin:$PATH
  $ export PATH=~/bin:$PATH
$ cd {{#var:BUILD_FOLDER}}
$ source {{#var:ANDROID_FOLDER_ID}}/imx_android_setup.sh
* Note : Since Oreo the distribution of Android NXP Source code is partially hosted on Linux Foundation https://source.codeaurora.org/*
* Since Android 12 onwards the Android NXP source code is hosted on GitHub https://github.com/nxp-imx-android
Note:
{{#switch: {{#var:ANDROID_NAME}}
  | Android 11
  | Android 12
  | Android 13 =
Wait for the script to finish running, and it should create following folders
$ {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/device/variscite/
$ {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/vendor/variscite/kernel_imx and
$ {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/vendor/variscite/uboot-imx


== Apply Variscite's i.MX platforms patches ==
== Clone Variscite's U-Boot and Linux kernel Sources ==
  $ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/device
$ mkdir {{#var:BUILD_FOLDER}} && cd $_
  $ variscite/scripts/install.sh {{#var:ANDROID_SCFW_INSTALL_ARGS}}
$ export YOUR_PATH=$PWD
|
 
Wait for the script to finish running, and it should create a "{{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}" folder
$ mkdir -p ${YOUR_PATH}/ti-bootloader-aosp/ && cd $_
  $ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}; mkdir -p vendor/variscite/
$ repo init -u https://github.com/varigit/variscite-bsp-platform.git -b {{#var:ANDROID_MANIFEST_BRANCH}} -m {{#var:AM62_BOOTLOADER_MANIFEST}}.xml
$ repo sync -j$(nproc)
 
$ mkdir -p ${YOUR_PATH}/ti-kernel-aosp/ && cd $_
$ repo init -u https://github.com/varigit/variscite-bsp-platform.git -b {{#var:ANDROID_MANIFEST_BRANCH}} -m {{#var:AM62_KERNEL_MANIFEST}}.xml
$ repo sync -j$(nproc)
 
== Clone Variscite's AOSP Sources ==
  $ mkdir -p ${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}} && cd $_
$ repo init -u https://github.com/varigit/variscite-bsp-platform.git -b {{#var:ANDROID_MANIFEST_BRANCH}} -m {{#var:AM62_AOSPFS_MANIFEST}}.xml
$ repo sync -j$(nproc)
 
== Apply Variscite's platforms patches and install toolchains ==
$ cd ${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}}/device
  $ variscite/scripts/install.sh
 
= Build Bootloader Components =
 
== Export Toolchains and setup paths ==
 
$ export PATH=$PATH:${YOUR_PATH}/ti-bootloader-aosp/toolchain/{{#var:ARMv8_TOOLCHAIN}}/bin:${YOUR_PATH}/ti-bootloader-aosp/toolchain/{{#var:ARMv7_TOOLCHAIN}}/bin
 
$ export G_ATF_SRC_DIR="${YOUR_PATH}/ti-bootloader-aosp/arm-trusted-firmware"
$ export G_OPTEE_SRC_DIR="${YOUR_PATH}/ti-bootloader-aosp/optee_os"
$ export G_CORE_LINUX_FIRMWARE_SRC_DIR="${YOUR_PATH}/ti-bootloader-aosp/ti-linux-firmware"
$ export G_UBOOT_SRC_DIR="${YOUR_PATH}/ti-bootloader-aosp/ti-u-boot"
 
$ export G_UBOOT_DEF_CONFIG_R="am62x_var_som_r5_defconfig"
$ export G_UBOOT_DEF_CONFIG_A="am62x_var_som_a53_defconfig"
 
== Building ARM Trusted Firmware (ATF) ==
$ cd ${G_ATF_SRC_DIR}
$ make distclean
$ make -j$(nproc) E=0 CROSS_COMPILE=aarch64-none-linux-gnu- ARCH=aarch64 PLAT=k3 TARGET_BOARD=lite SPD=opteed CFLAGS+="-DK3_PM_SYSTEM_SUSPEND=1"
 
== Building OP-TEE OS ==
$ cd ${G_OPTEE_SRC_DIR}
$ make clean && rm -rf out
$ make -j$(nproc) PLATFORM=k3 CFG_ARM64_core=y CROSS_COMPILE=arm-none-linux-gnueabihf- CROSS_COMPILE64=aarch64-none-linux-gnu-
 
== Building U-Boot for R5 Core ==
$ cd ${G_UBOOT_SRC_DIR}
$ make mrproper
$ make -C ${G_UBOOT_SRC_DIR} mrproper
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- ${G_UBOOT_DEF_CONFIG_R} O=${G_UBOOT_SRC_DIR}/out/r5
$ make -j$(nproc) ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- BINMAN_INDIRS=${G_CORE_LINUX_FIRMWARE_SRC_DIR} O=${G_UBOOT_SRC_DIR}/out/r5
 
== Building U-Boot for A53 Core with Android ==
$ cd ${G_UBOOT_SRC_DIR}
$ make mrproper
$ make ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- ${G_UBOOT_DEF_CONFIG_A} O=${G_UBOOT_SRC_DIR}/out/a53
$ make ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- am62x_android_a53.config O=${G_UBOOT_SRC_DIR}/out/a53
$ make -j$(nproc) ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- \
      BL31=${G_ATF_SRC_DIR}/build/k3/lite/release/bl31.bin \
      TEE=${G_OPTEE_SRC_DIR}/out/arm-plat-k3/core/tee-pager_v2.bin \
      BINMAN_INDIRS=${G_CORE_LINUX_FIRMWARE_SRC_DIR} O=${G_UBOOT_SRC_DIR}/out/a53
 
== Copying Bootloader Images to AOSP Build ==
$ cp ${G_UBOOT_SRC_DIR}/out/r5/tiboot3-am62x-hs-fs-am62x-var-som.bin ${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}}/vendor/ti/am62x/bootloader/am62x-sk/tiboot3-hsfs.bin
$ cp ${G_UBOOT_SRC_DIR}/out/r5/tiboot3-am62x-gp-am62x-var-som.bin ${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}}/vendor/ti/am62x/bootloader/am62x-sk/tiboot3.bin
  $ cp ${G_UBOOT_SRC_DIR}/out/a53/tispl.bin ${G_UBOOT_SRC_DIR}/out/a53/u-boot.img ${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}}/vendor/ti/am62x/bootloader/am62x-sk/


== Clone Variscite's U-Boot and Linux kernel sources ==
= Building the Kernel Image =
  $ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/vendor/variscite/
$ cd ${YOUR_PATH}/ti-kernel-aosp/
  $ git clone {{#var:U-BOOT_GIT}} -b {{#var:U-BOOT_BRANCH}}
  $ export DIST_DIR=${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}}/device/ti/am62x-kernel/kernel/6.1
$ git clone {{#var:KERNEL_GIT}} kernel_imx -b {{#var:KERNEL_BRANCH}}
  $ tools/bazel run //common:ti_dist -- --dist_dir=$DIST_DIR
<span style="color:red">Note:</span> The building process using the bazel tool is not a standard kernel build process, unlike make/soong. Google has published the guideline and package GKI bazel build, refer to https://source.android.com/docs/core/architecture/kernel/generic-kernel-image for more details.


== Apply Variscite's i.MX platforms patches ==
== To re-build Kernel fast for changes from the previous full build ==
  $ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/device
  $ tools/bazel run --config=fast //common:ti_dist -- --dist_dir=$DIST_DIR
$ git clone {{#var:ANDROID_VARISCITE_GIT}} -b {{#var:ANDROID_VARISCITE_BRANCH}} variscite
$ variscite/scripts/install.sh {{#var:ANDROID_SCFW_INSTALL_ARGS}}
}}


= Build Android Images =
= Build Android Images =
{{#ifeq:{{#var:ANDROID_BROKEN_FLEX}}|true |
For Ubuntu 22.04 LTS users the flex 2.5.39 needs to be re-compiled before you begin the build.
$ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}
$ cd prebuilts/misc/linux-x86/flex
$ rm flex-2.5.39
$ tar zxf flex-2.5.39.tar.gz
$ cd flex-2.5.39
$ ./configure
$ make
$ mv flex ../
$ cd ../
$ rm -rf flex-2.5.39
$ mv flex flex-2.5.39
}}


Change to Android top level directory.
Change to Android top level directory.
  $ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}
  $ cd ${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}}
  $ source build/envsetup.sh
  $ source build/envsetup.sh
{{#switch: {{#var:ANDROID_NAME}}
  | Android 10 = $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
  | Android 11 = $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
  | Android 12 = $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
  | Android 13 = $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
  | $ lunch {{#var:ANDROID_MACHINE_NAME}}-eng
  or
  $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
  $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
}}
{{#ifeq:{{#var:ANDROID_USERBUILD_SUPPORT}}|true |
{{#ifeq:{{#var:ANDROID_USERBUILD_SUPPORT}}|true |
  or
  or
Line 213: Line 215:
</span>  
</span>  
}}
}}
 
 
== Build Android File System ==
$ export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH
=== Switching from eMMC build to SD card build and vice versa ===
 
* For eMMC boot
== Switching from eMMC build to SD card build and vice versa ==
  $ m TARGET_AVB_ENABLE=true -j$(nproc) 2>&1 {{!}} tee build-emmc.log
Unlike previous Android BSPs, the boot media is autodetected at boot time.
* For SD boot
 
$ m TARGET_AVB_ENABLE=true TARGET_SDCARD_BOOT=true -j$(nproc) 2>&1 {{!}} tee build-sd.log
== Build Android ==
  {{#switch: {{#var:ANDROID_NAME}}
  | Android 10 = ./imx-make.sh -j4 2>&1 {{!}} tee build1-1.log  
  | Android 11 = ./imx-make.sh -j4 2>&1 {{!}} tee build1-1.log
  | Android 12 = ./imx-make.sh -j4 2>&1 {{!}} tee build1-1.log
  | Android 13 = ./imx-make.sh -j4 2>&1 {{!}} tee build1-1.log
  | make -j4 2>&1 {{!}} tee build1-1.log
}}


== Images created by the Android build ==
== Images created by the Android build ==
The resulted images are located in out/target/product/{{#if: {{#var:ANDROID_PRODUCT_NAME}} | {{#var:ANDROID_PRODUCT_NAME}} | {{#var:ANDROID_MACHINE_NAME}} }}.
The resulted images are located in out/target/product/{{#var:ANDROID_MACHINE_NAME}}.
 
{{#lst:Android_Platform_Customization|{{#var:ANDROID_IMAGES_SECTION}}}}
{{#lst:Android_Platform_Customization|{{#var:ANDROID_IMAGES_SECTION}}}}
{{#ifeq:{{#var:ANDROID_DYNAMIC_PARTITION}}|true |
{{#lst:APC_VAR-SOM-AM62|{{#var:ANDROID_IMAGES_SECTION}}}}
<span style="color:red">Note:</span> To create images with no dynamic support please follow [[Android_10_no_dynamic_partition]]
}}


= Boot options=
= Boot options=


Boot options of the Android:<br>
Boot options of the Android:<br>
1. Directly from SD card<br>
1. U-Boot boots from on-SOM eMMC<br>
2. U-Boot boots from on-SOM eMMC
2. Directly from SD card (Requires separate build for AOSP images.)<br>
 


== Flash and boot Android from SD card ==
== Flash and boot Android from SD card ==
=== Create a bootable SD card ===
=== Create a bootable SD card ===
Partition and format SD card, and copy all images
$ cd out/target/product/{{#var:ANDROID_MACHINE_NAME}}
<pre>
$ simg2img super.img super_raw.img
$ sudo ./var-mksdcard.sh -f <name> /dev/sdX;sync
$ gzip super_raw.img
</pre>
$ cd ${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}}
* Replace <name> with the actual desired setup name according to the second table in the [[#Images_created_by_the_Android_build|"Images created by the Android build" section]].
$ sudo ./device/variscite/scripts/sh/var-mksdcard.sh /dev/sdX; sync
* Replace /dev/sdX with your true device, You can identify it with dmesg.
* Replace /dev/sdX with your true device, You can identify it with dmesg.


=== Boot From SD card ===
=== Boot From SD card ===
{{#lst:Android_Recovery_SD_card|BOOT_FROM_SD_CARD}}
Make sure the BOOT SELECT DIP switch on the carrier board is set correctly before you power on the board.
<pre>
$ SW3
$ 0 : Boot from SD card
$ 1 : Boot from eMMC
</pre>


== Flash and boot Android from eMMC ==
== Flash and boot Android from eMMC ==
=== Preparing images ===
{{#ifeq:{{#var:ANDROID_NAME}}|Android 11 |
The default super.img, vendor_boot.img format is suitable for flashing using fastboot, and must be modified for flashing using 'dd'.
$ cd out/target/product/{{#if: {{#var:ANDROID_PRODUCT_NAME}} | {{#var:ANDROID_PRODUCT_NAME}} | {{#var:ANDROID_MACHINE_NAME}} }}
$ simg2img super.img super_raw.img
|
{{#ifeq:{{#var:ANDROID_DYNAMIC_PARTITION}}|true |
The default super.img, format is suitable for flashing using fastboot, and must be modified for flashing using 'dd'.
$ cd out/target/product/{{#if: {{#var:ANDROID_PRODUCT_NAME}} | {{#var:ANDROID_PRODUCT_NAME}} | {{#var:ANDROID_MACHINE_NAME}} }}
$ simg2img super.img super_raw.img
|
{{#ifeq:{{#var:ANDROID_NAME}}|Android 10 |
The default system.img, vendor.img and product.img format is suitable for flashing using fastboot, and must be modified for flashing using 'dd'.
|
The default system.img and vendor.img format is suitable for flashing using fastboot, and must be modified for flashing using 'dd'.
}}
$ cd out/target/product/{{#if: {{#var:ANDROID_PRODUCT_NAME}} | {{#var:ANDROID_PRODUCT_NAME}} | {{#var:ANDROID_MACHINE_NAME}} }}
$ simg2img system.img system_raw.img
$ simg2img vendor.img vendor_raw.img
{{#ifeq:{{#var:ANDROID_NAME}}|Android 10| $ simg2img product.img product_raw.img}}
}}}}


=== Flashing Android from Linux shell (when the primary installation android) ===
=== Flashing Android from Linux shell (when the primary installation android) ===
Line 291: Line 264:




Further, follow the steps described in paragraph "'''Flashing Android with USB Fastboot'''"
=== Flashing Android with USB Fastboot ===


=== Flashing Android with USB Fastboot ===
==== Install tools on host ====
==== Install tools on host ====
<pre>
<pre>
Line 309: Line 280:
'''On the Host PC:'''
'''On the Host PC:'''
{{#lst:Android_Platform_Customization|{{#var:ANDROID_FASTBOOT_SECTION}}}}
{{#lst:Android_Platform_Customization|{{#var:ANDROID_FASTBOOT_SECTION}}}}
Replace ''<name>'' with the actual desired setup name according to the table in the [[#Images_created_by_the_Android_build|"Images created by the Android build" section]].
{{#ifeq: {{#var:ANDROID_NAME}} | Pie |
=== Android recovery mode ===
==== Enter board in Android Recovery mode ====
If you are using DT8MCustomBoard or you implemented any recovery key detection in uboot, the device can powered on in recovery mode by holding down the "back" (or any other recovery key) button until the end of the boot, showing the "Android Recovery" menu.
Alternatively you can issue the command reboot recovery from the Android console (or using adb shell).
==== Control menu in Android Recovery Mode ====
If the board has UP, DOWN keys (like DT8MCustomBoard)
# To cycle between menu items, use a short press of UP or DOWN buttons
# To highlight an item, use a long press of BACK or HOME buttons or long touch the touchscreen
# To activate an item, use a short press of ON/OFF button


If the board has no UP and DOWN keys (like SymphonyBoard)
=== Update Android firmware ===


# To cycle between menu items, use a short press of any buttons or select the item with the touchscreen
==== Generate OTA packages ====
# To activate an item, use a long press of any buttons or of the touchscreen
}}


==== Update Android firmware ====
===== For generating "OTA" packages, use the following commands: =====
 
  $ cd ${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}}
===== Generate OTA packages =====
For generating "OTA" packages, use the following commands:
  $ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}
{{#switch: {{#var:ANDROID_NAME}}
| Android 10
| Android 11
| Android 12
| Android 13 =
  $ source build/envsetup.sh  
  $ source build/envsetup.sh  
  $ lunch PRODUCT={{#var:ANDROID_MACHINE_NAME}}-userdebug
  $ lunch PRODUCT={{#var:ANDROID_MACHINE_NAME}}-userdebug
  $ ./imx-make.sh bootloader kernel -j4
  $ m TARGET_AVB_ENABLE=true -j$(nproc) otapackage
$ make otapackage -j4 2>&1 || tee build1-1.log
|
$ make PRODUCT={{#var:ANDROID_MACHINE_NAME}}-eng otapackage -j4 2>&1 | tee build1-1.log
}}


===== Install OTA package to device =====
===== Install OTA package to device: =====
* Extract payload.bin and payload_properties.txt from OTA zip file
* Extract payload.bin and payload_properties.txt from OTA zip file
  {{#ifeq: {{#var:ANDROID_NAME}} | Android 11 |
* Push payload.bin to board's /data/ota_package dir: adb push payload.bin /data/ota_package/ .
* Push payload.bin to board's /data/ota_package dir: adb push payload.bin /data/ota_package/ .
  |
* Open payload_properties.txt on an editor to copy its content, lets suppose it's like in the TI manual:
  {{#ifeq: {{#var:ANDROID_NAME}} | Android 10 |
   FILE_HASH=wuBhu49k3pCmQmMl8S/n2NRm1he3A+IHshcQiOfCKc4=
* Push payload.bin to board's /sdcard dir: adb push payload.bin /sdcard/ .
   FILE_SIZE=501067958
  |
   METADATA_HASH=qPWe72T37KgJtyJhuKSlNkFm1NflKFnLy+An4GnoXyA=
* Push file payload.bin to somewhere on the device (typically /cache folder)
   METADATA_SIZE=31967
  }}}}
* Open payload_properties.txt on an editor to copy its content, lets suppose it's like in the NXP manual:
   FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
   FILE_SIZE=379074366
  {{#ifeq: {{#var:ANDROID_NAME}} | Android 10 |
  METADATA_HASH=Icrs3NqoglzyppyCZouWKbo5f08IPokhlUfHDmz77WQ=
  |
   METADATA_HASH=Icrs3NqoglzyppyCZouWKbo5f08IPokhlUfHDmz77WQ/de8Dgp9zFXt8Fo+Hxccp465uTOvKNsteWU=
  }}
   METADATA_SIZE=46866
  {{#ifeq: {{#var:ANDROID_NAME}} | Android 11 | Android 12 |
* Input the following command on the board's console to update:
* Input the following command on the board's console to update:
   su
   su
   update_engine_client --payload=file:///data/ota_package/payload.bin --update --headers="FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
  setenforce 0
  |
   update_engine_client --payload=file:///data/ota_package/payload.bin --update --headers="FILE_HASH=wuBhu49k3pCmQmMl8S/n2NRm1he3A+IHshcQiOfCKc4=
  {{#ifeq: {{#var:ANDROID_NAME}} | Android 10 |
   FILE_SIZE=501067958
* Input the following command on the board's console to update:
   METADATA_HASH=qPWe72T37KgJtyJhuKSlNkFm1NflKFnLy+An4GnoXyA=
  su
   METADATA_SIZE=31967"
  update_engine_client --payload=file:///sdcard/payload.bin --update --headers="FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
  |
* Issue the following command on adb shell:
  update_engine_client --payload=file:///cache/payload.bin --update --headers="FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
  }}}}
   FILE_SIZE=379074366
  {{#ifeq: {{#var:ANDROID_NAME}} | Android 10 |
   METADATA_HASH=Icrs3NqoglzyppyCZouWKbo5f08IPokhlUfHDmz77WQ=
  |
  METADATA_HASH=Icrs3NqoglzyppyCZouWKbo5f08IPokhlUfHDmz77WQ/de8Dgp9zFXt8Fo+Hxccp465uTOvKNsteWU=
  }}
   METADATA_SIZE=46866"


{{#ifeq: {{#var:ANDROID_NAME}} | Android 11 |Android 12 | Android 13
Make sure that the -- header equals to the exact content of payload_properties.txt without "space" or "return"
character.
|
{{#ifeq: {{#var:ANDROID_NAME}} | Android 10 |
Make sure that the -- header equals to the exact content of payload_properties.txt without "space" or "return"
Make sure that the -- header equals to the exact content of payload_properties.txt without "space" or "return"
character.
character.
|
Note that the command argument --headers="..." contains the exact (4-line) content of the payload_properties.txt file between quotes (you can copy and paste it), including 3 newline characters.
}}}}
   
   
After issuing the command, nothing seems to happen on the device, but you can monit logcat for operation progress. After a successful update you can reboot into the updated version.
After issuing the command, nothing seems to happen on the device, but you can monitor logcat for operation progress.  
 
  logcat | grep update_engine
You can check chapter 7 of official NXP "Android User Guide" for further "Over-The-Air (OTA) Update" examples.
After a successful update, you can reboot into the updated version (_b/_a) slot.


= Manual operations =
= Manual operations =
Line 409: Line 318:
== Build boot.img ==
== Build boot.img ==
When you perform changes to the kernel, you may build boot.img solely instead of building the whole Android.
When you perform changes to the kernel, you may build boot.img solely instead of building the whole Android.
  $ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}
  $ cd ${YOUR_PATH}/ti-kernel-aosp/
  $ source build/envsetup.sh
$ export DIST_DIR=${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}}/device/ti/am62x-kernel/kernel/6.1
  $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
  $ tools/bazel run --lto=full //common:ti_dist -- --dist_dir=$DIST_DIR
  $ cd ${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}}
$ lunch am62x_var_som-userdebug
$ m


{{#switch: {{#var:ANDROID_NAME}}
== Menu Config ==
| Android 11
  $ cd ${YOUR_PATH}/ti-kernel-aosp/
| Android 12
  $ tools/bazel run //common:ti_config -- menuconfig
| Android 13 =
  $ ./imx-make.sh kernel -j4
|
  $ make bootimage
}}


== Toolchain setup for manual build ==
== Porting Drivers Notes ==
Setup the toolchain path to point to arm-linux-androideabi- tools in prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin
* Actual Kernel source code is in ${YOUR_PATH}/ti-kernel-aosp/common
$ export ARCH=arm64
* Defconfig Used in the kernel is from Google: ${YOUR_PATH}/ti-kernel-aosp/common/arch/arm64/configs/gki_defconfig
$ export CROSS_COMPILE={{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-
* All drivers and SOC infrastructure is via modules and is setup by: ${YOUR_PATH}/ti-kernel-aosp/common/arch/arm64/configs/ti_gki.fragment
* Your driver/ kernel module .ko must be added to GKI module list
<pre>
    module_outs = COMMON_GKI_MODULES_LIST + [
    "net/wireless/your_module.ko",   
    "drivers/spi/your_driver.ko",
    ]
</pre>


{{#if: {{#var:ANDROID_FASTBOOT_NEED_UNLOCK}} |
* Your driver module dependencies must be resolved and must align cd ${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}}/device/variscite/am62x_var_som/BoardConfig.mk
== Unlock device for fastboot ==
with following  
 
<pre>
Our build behaves like any other standard Android device.
BOARD_VENDOR_RAMDISK_KERNEL_MODULES += \
 
        device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/zsmalloc.ko \
To use fastboot, you should go through the following steps
        device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/zram.ko \
 
        device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/ti-msgmgr.ko \
* Settings => System => About Tablet => Build number
        device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/ti_sci.ko \
* keep on tapping until you see a prompt that says "You are now a developer!"
        device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/ti_sci_pm_domains.ko \
* Settings => System => Advanced => Developer options => OEM unlocking
        device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/phy-omap-usb2.ko \
* reboot to bootloader
        device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/syscon-clk.ko \
* type "fastboot 0" in the U-Boot command line
                |                                   |
* run "sudo `which fastboot` oem unlock" from the Host PC
                |                                   |
* wait until the unlock process is complete
        device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/your_driver.ko
* proceed for flashing
</pre>
 
}}
{{#ifeq:{{#var:ANDROID_UUU_SUPPORT}}|true |
 
= Flashing Using NXP MFGTools - UUU (Universal Update Utility) =
To flash Android OS without using a recovery SD card, UUU (MFG Tools 3.0) can be used.<br>
Please refer to {{Varlink|Android_UUU_IMX8|{{#var:RELEASE_PARAM|RELEASE_O8.1.0_1.3.0_8M_DART-MX8M}}|Flashing Android OS using UUU - USB Boot}}.
}}
{{#ifeq:{{#var:ANDROID_UUU_LATEST}}|true |
{{Note|'''Note:'''The specific version of UUU is required to use this release, as VID/PIDs have been updated in the u-boot by NXP. <br>
Please download/build specific version of UUU on your host machine }}
}}
{{#ifeq:{{#var:ANDROID_M4_SUPPORTED}}|true |
 
= Running a M4 demo =
 
Please choose one of the below options while flashing Android from Linux shell
 
imx8mm-var-dart-dt8mcustomboard-legacy-m4 - Supports LVDS / SD / WiFi (DART-MX8M-MINI-M4 on DT8MCustomBoard 1.x)
imx8mm-var-dart-dt8mcustomboard-m4 - Supports LVDS / SD / WiFi (DART-MX8M-MINI-M4 on DT8MCustomBoard 2.x)
imx8mm-var-som-symphony-legacy-m4 - Supports LVDS / SD / WiFi (VAR-SOM-MX8M-MINI-M4 on a Symphony-Board V1.4 and below)
imx8mm-var-som-symphony-m4 - Supports LVDS / SD / WiFi (VAR-SOM-MX8M-MINI-M4 on a Symphony-Board V1.4A and above)
 
=== Running a demo from Linux ===
 
Boot Android to the shell
 
Increase kernel loglevel while debugging:
 
  sysctl kernel.printk=7;
 
Check the state of the m4, it should be running already by U-Boot
 
cat /sys/class/remoteproc/remoteproc0/state
 
If the state is 'running', stop the m4
 
echo stop > /sys/class/remoteproc/remoteproc0/state
 
Load new firmware (.elf file must already exist in /lib/firmware directory)
 
echo rpmsg_lite_pingpong_rtos_linux_remote.elf > /sys/class/remoteproc/remoteproc0/firmware
 
Change the state to running
 
echo start > /sys/class/remoteproc/remoteproc0/state
 
Copy and run demo module
 
From Host PC
$ adb root
$ adb push {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/out/target/product/dart_mx8mm/obj/KERNEL_OBJ/drivers/rpmsg/imx_rpmsg_pingpong.ko /data
From device shell
$ su
$ cd /data
$ insmod imx_rpmsg_pingpong.ko
 
=== Running a demo from U-Boot ===
{{#ifeq: {{#var:NXP_BSP_VERSION}} | i.MX android-11.0.0_2.4.0 |
Enable below node in -m4.dtsi and re-build images as per "Build Android Images" section and follow the steps described in paragraph "Flashing Android with USB Fastboot" to flash the images
 
  &rpmsg{
        status = "okay";
  };
}}
 
From U-Boot shell execute below commands
 
u-boot=> bootmcu
run command: 'bootaux 0x7e0000'
## Starting auxiliary core stack = 0x20020000, pc = 0x1FFE035D...
u-boot=> run bootcmd
 
Follow steps as described in "Copy and run demo module"
|
}}
{{#ifeq:{{#var:ANDROID_8MP_M7_SUPPORTED}}|true |
 
= Running a M7 demo =
 
Please choose one of the below options while flashing Android from Linux shell
 
imx8mp-var-dart-dt8mcustomboard-legacy-m7.img (Variscite DART-MX8M-PLUS M7 LVDS on DT8MCustomBoard 1.x)
imx8mp-var-dart-dt8mcustomboard-m7.img (Variscite DART-MX8M-PLUS M7 LVDS on DT8MCustomBoard 2.x)
imx8mp-var-som-symphony-2nd-ov5640-m7.img (Variscite VAR-SOM-MX8M-PLUS M7 with 2nd OV5640 on Symphony-Board)
imx8mp-var-som-symphony-m7.img (VAR-SOM-MX8M-PLUS M7 LVDS on Symphony-Board)
 
=== Running a demo from Linux ===
 
Boot Android to the shell
 
Increase kernel loglevel while debugging:
 
  sysctl kernel.printk=7;
 
Check the state of the m7, it should be running already by U-Boot
 
cat /sys/class/remoteproc/remoteproc0/state
 
If the state is 'running', stop the m7
 
echo stop > /sys/class/remoteproc/remoteproc0/state
 
Load new firmware (.elf file must already exist in /lib/firmware directory)
 
echo rpmsg_lite_pingpong_rtos_linux_remote.elf.dart > /sys/class/remoteproc/remoteproc0/firmware OR
echo rpmsg_lite_pingpong_rtos_linux_remote.elf.som > /sys/class/remoteproc/remoteproc0/firmware
 
Change the state to running
 
echo start > /sys/class/remoteproc/remoteproc0/state
 
Copy and run demo module
 
From Host PC
$ adb root
$ adb push {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/out/target/product/dart_mx8mp/obj/KERNEL_OBJ/drivers/rpmsg/imx_rpmsg_pingpong.ko /data
From device shell
$ su
$ cd /data
$ insmod imx_rpmsg_pingpong.ko
 
=== Running a demo from U-Boot ===
 
Enable below node in -m7.dtsi and re-build images as per "Build Android Images" section and follow the steps described in paragraph "Flashing Android with USB Fastboot" to flash the images
 
  &rpmsg{
        status = "okay";
  };
 
From U-Boot shell execute below commands
 
u-boot=> bootmcu
run command: 'bootaux 0x7e0000'
## Starting auxiliary core stack = 0x20020000, pc = 0x0000051D...
u-boot=> run bootcmd
 
Follow steps as described in "Copy and run demo module"
|
}}
{{#ifeq:{{#var:ANDROID_8M_M4_SUPPORTED}}|true |
 
= Running a M4 demo =
 
Please choose one of the below options while flashing Android from Linux shell
 
imx8mq-var-dart-dt8mcustomboard-legacy-m4-wifi-dp - Variscite DART-MX8M on DT8MCustomBoard 1.x M4+WIFI+DP
imx8mq-var-dart-dt8mcustomboard-legacy-m4-wifi-hdmi - Variscite DART-MX8M on DT8MCustomBoard 1.x M4+WIFI+HDMI
imx8mq-var-dart-dt8mcustomboard-legacy-m4-wifi-lvds-dp - Variscite DART-MX8M on DT8MCustomBoard 1.x M4+WIFI+LVDS
imx8mq-var-dart-dt8mcustomboard-legacy-m4-wifi-lvds-hdmi - Variscite DART-MX8M on DT8MCustomBoard 1.x M4+WIFI+LVDS+HDMI
imx8mq-var-dart-dt8mcustomboard-legacy-m4-wifi-lvds - Variscite DART-MX8M on DT8MCustomBoard 1.x M4+WIFI+LVDS
imx8mq-var-dart-dt8mcustomboard-m4-wifi-hdmi - Variscite DART-MX8M on DT8MCustomBoard 2.x M4+WIFI+HDMI
imx8mq-var-dart-dt8mcustomboard-m4-wifi-lvds-hdmi - Variscite DART-MX8M on DT8MCustomBoard 2.x M4+WIFI+LVDS+HDMI
imx8mq-var-dart-dt8mcustomboard-m4-wifi-lvds - Variscite DART-MX8M on DT8MCustomBoard 2.x M4+WIFI+LVDS
 
=== Running a demo from Linux ===
 
Boot Android to the shell
 
Increase kernel loglevel while debugging:
 
  sysctl kernel.printk=7;
 
Check the state of the m4, it should be running already by U-Boot
 
cat /sys/class/remoteproc/remoteproc0/state
 
If the state is 'running', stop the m4
 
echo stop > /sys/class/remoteproc/remoteproc0/state
 
Load new firmware (.elf file must already exist in /lib/firmware directory)
 
echo cm_rpmsg_lite_pingpong_rtos_linux_remote.elf > /sys/class/remoteproc/remoteproc0/firmware
 
Change the state to running
 
echo start > /sys/class/remoteproc/remoteproc0/state
 
Copy and run demo module
 
From Host PC
$ adb root
$ adb push {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/out/target/product/dart_mx8mq/obj/KERNEL_OBJ/drivers/rpmsg/imx_rpmsg_pingpong.ko /data
From device shell
$ su
$ cd /data
$ insmod imx_rpmsg_pingpong.ko
 
=== Running a demo from U-Boot ===
 
Enable below node in -m4.dtsi and re-build images as per "Build Android Images" section and follow the steps described in paragraph "Flashing Android with USB Fastboot" to flash the images
 
  &rpmsg{
        status = "okay";
  };
 
From U-Boot shell execute below commands
 
u-boot=> bootmcu
run command: 'bootaux 0x7e0000'
## Starting auxiliary core stack = 0x20020000, pc = 0x1FFE035D...
u-boot=> run bootcmd
 
Follow steps as described in "Copy and run demo module"
|
}}
{{#ifeq:{{#var:ANDROID_8X_M4_SUPPORTED}}|true |
 
= Running a M4 demo =
 
Please choose one of the below options while flashing Android from Linux shell
 
imx8qxp-var-som-symphony-wifi-m4 - Variscite M4 LVDS / WiFi
imx8qxp-var-som-symphony-sd-m4 - Variscite M4 LVDS / SD
 
=== Running a demo from Linux ===
 
Boot Android to the shell
 
Increase kernel loglevel while debugging:
 
  sysctl kernel.printk=7;
 
Check the state of the m4, it should be running already by U-Boot
 
cat /sys/class/remoteproc/remoteproc0/state
 
If the state is 'running', stop the m4
 
echo stop > /sys/class/remoteproc/remoteproc0/state
 
Load new firmware (.elf file must already exist in /lib/firmware directory)
 
echo cm_rpmsg_lite_pingpong_rtos_linux_remote.elf > /sys/class/remoteproc/remoteproc0/firmware
 
Change the state to running
 
echo start > /sys/class/remoteproc/remoteproc0/state
 
Copy and run demo module
 
From Host PC
$ adb root
$ adb push {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/out/target/product/som_mx8q/obj/KERNEL_OBJ/drivers/rpmsg/imx_rpmsg_pingpong.ko /data
From device shell
$ su
$ cd /data
$ insmod imx_rpmsg_pingpong.ko
|
}}
{{#ifeq:{{#var:ANDROID_8Q_M4_SUPPORTED}}|true |
 
= Running a M4 demo =
 
Please choose one of the below options while flashing Android from Linux shell
 
imx8qm-var-som-dp-m4 - Supports VAR-SOM-MX8QM M4 with DP
imx8qm-var-som-hdmi-m4 - Supports VAR-SOM-MX8QM M4 with HDMI
imx8qm-var-som-lvds-m4 - Supports VAR-SOM-MX8QM M4 with LVDS
imx8qm-var-spear-dp-m4 - Supports VAR-SOM-MX8QM M4 with DP
imx8qm-var-spear-hdmi-m4 - Supports SPEAR-MX8QM M4 with HDMI
imx8qm-var-spear-lvds-m4 - Supports SPEAR-MX8QM M4 with LVDS
imx8qp-var-som-dp-m4 - Supports VAR-SOM-MX8QP M4 with DP
imx8qp-var-som-hdmi-m4 - Supports VAR-SOM-MX8QP M4 with HDMI
imx8qp-var-som-lvds-m4 - Supports VAR-SOM-MX8QP M4 with LVDS
imx8qp-var-spear-dp-m4 - Supports VAR-SOM-MX8QP M4 with DP
imx8qp-var-spear-hdmi-m4 - Supports SPEAR-MX8QP M4 with HDMI
imx8qp-var-spear-lvds-m4 - Supports SPEAR-MX8QP M4 with LVDS
 
=== Running a demo from Linux ===
 
Boot Android to the shell
 
Increase kernel loglevel while debugging:
 
  sysctl kernel.printk=7;
 
Check the state of the m4, it should be running already by U-Boot
 
cat /sys/class/remoteproc/remoteprocX/state
 
If the state is 'running', stop the m4
 
echo stop > /sys/class/remoteproc/remoteprocX/state
 
<span style="color:red">Note:</span> Replace 'X' with 0 or 1.
 
Load new firmware (.elf file must already exist in /lib/firmware directory)
 
echo cm_rpmsg_lite_pingpong_rtos_linux_remote_m4X.elf > /sys/class/remoteproc/remoteproc0/firmware
 
Change the state to running
 
echo start > /sys/class/remoteproc/remoteprocX/state
 
Copy and run demo module
 
From Host PC
$ adb root
$ adb push {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/out/target/product/som_mx8q/obj/KERNEL_OBJ/drivers/rpmsg/imx_rpmsg_pingpong.ko /data
From device shell
$ su
$ cd /data
$ insmod imx_rpmsg_pingpong.ko
|
}}
{{#ifeq:{{#var:BASLER_ISP0}}|true |
 
= Running Camera app using Basler ISP camera =
Connect basler camera
{{#switch: {{#var:ANDROID_NAME}}
| Android 13 =
Flash any of the following dtbo and vbmeta images depending on your platform
* imx8mp-var-som-symphony-basler-isp0 - Supports Variscite VAR-SOM-MX8M-PLUS with Basler camera on Symphony-Board
* imx8mp-var-dart-dt8mcustomboard-basler-isp0 - Supports Variscite DART-MX8M-PLUS with Basler camera DT8MCustomBoard 2.x
* imx8mp-var-dart-dt8mcustomboard-legacy-basler-isp0 - Supports Variscite DART-MX8M-PLUS with Basler camera DT8MCustomBoard 1.x
<br>
* Note: This requires either device unlocked via fastboot or use UUU or recovery sdcard method to program proper images.
|
Please follow the steps to change the default camera configuration file to support Basler ISP Camera.
Unlock the device as per section 8.3
# boot up the system
adb root
# remount after reboot
adb remount
adb reboot
# boot up the system
adb root
# remount after reboot
adb remount
adb shell cp /vendor/etc/configs/camera_config_imx8mp-basler-isp0.json /vendor/etc/configs/camera_config_imx8mp.json
#reboot
}}
 
Launch Camera application using Basler ISP camera.
}}
{{#ifeq:{{#var:VAR_SOM_MX8MN_RPROC_DEMO}}|true |
 
= Running a M7 demo =
Please choose one of the below options while flashing Android from Linux shell
 
imx8mn-var-som-symphony-m7.img -  (VAR-SOM-MX8M-NANO M7 LVDS on Symphony-Board)
 
== Running a demo from Linux ==
 
Boot Android to the shell
 
Increase kernel loglevel while debugging:
 
$ sysctl kernel.printk=7;
 
Check the state of the m7, it should be running already by U-Boot
 
$ cat /sys/class/remoteproc/remoteproc0/state
 
If the state is 'running', stop the m7
 
$ echo stop > /sys/class/remoteproc/remoteproc0/state
 
Load new firmware (.elf file must already exist in /lib/firmware directory)
 
$ echo cm_rpmsg_lite_pingpong_rtos_linux_remote.elf.debug > /sys/class/remoteproc/remoteproc0/firmware OR
$ echo cm_rpmsg_lite_pingpong_rtos_linux_remote.elf.ddr_debug > /sys/class/remoteproc/remoteproc0/firmware
 
Note: elf.debug uses TCM and elf.ddr_debug uses DDR
 
Change the state to running
 
$ echo start > /sys/class/remoteproc/remoteproc0/state
 
Copy and run demo module
 
From Host PC
$ adb root
$ adb push {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/out/target/product/dart_mx8mn/obj/KERNEL_OBJ/drivers/rpmsg/imx_rpmsg_pingpong.ko /data
From device shell
$ su
$ cd /data
$ insmod imx_rpmsg_pingpong.ko
 
== Running a demo from U-Boot ==
 
You need to flash the firmware "Flashing Android with USB Fastboot" to flash the images
Android comes pre-compiled bin file for cortex-m7 for demo,
cm_rpmsg_lite_pingpong_rtos_linux_remote.bin.debug - TCM - Ping Pong Bin file
cm_rpmsg_lite_pingpong_rtos_linux_remote.bin.ddr_debug - DDR - Pingpong Demo bin file
$ fastboot flash mcu_os <bin file> from above
From U-Boot shell execute below commands after reset, hit enter at u-boot shell,
 
u-boot=> bootmcu
run command: 'bootaux 0x7e0000'
## Starting auxiliary core stack = 0x20020000, pc = 0x0000051D...
u-boot=> run bootcmd
 
Follow steps as described in "Copy and run demo module"
 
|
}}
{{#ifeq:{{#var:ANDROID_PCIE_MODEM_SUPPORTED}}|true |
= Setting up the PCI-E modem =
To add modem to your build follow {{Varlink|DART-MX8M_Android_Modem|{{#var:RELEASE_LINK}}|Modem Integration to Android build}}
}}

Latest revision as of 12:02, 27 May 2024

Warning: This page is designed to be used with a 'release' URL parameter.

This page is using the default release am62-android-13_09.00.00-v1.0.
To view this page for a specific Variscite SoM and software release, please follow these steps:

  1. Visit variwiki.com
  2. Select your SoM
  3. Select the software release
VAR-SOM-AM62 - Android 13-09.00.00 Developer Guide

Introduction

This page describes how to build and deploy Android 13 on the VAR-SOM-AM62. It is based on TI's Android 13-09.00.00 release.

Overview

The objective of this document is to guide VAR-SOM-AM62 Android developers to obtain Android 13 sources, setting up host environment, compilation, and deployment.

This document contains instructions for:

  • Hardware and software requirements.
  • Setup the hardware.
  • Setup the toolchain.
  • Download & build the sources.
  • Install the binaries on the VAR-SOM-AM62 SOM and variants.
  • Making Changes to kernel/configuration and update VAR-SOM-AM62 SOM and variants.

Supported Hardware and Features

Hardware Requirements

You will need the Variscite VAR-SOM-AM62 based evaluation kit.

Host (PC) Setup Requirements

The host development environment for Android is based on Ubuntu, please install one of the following Ubuntu versions:

If you are running Linux in a virtual machine you need at least 16GB of RAM and 32 GB of swap.
The build process requires ~250GB of free storage space of SSD.
Before starting a build, make sure you have adequate free space available.


NOTE: Avoid using Ubuntu releases other than those recommended above.

Variscite offers Docker containers as an alternative for a development environment, which can be used instead of a virtual machine or a dedicated computer.
To learn more, please see Variscite's Docker Build Environment guide.
Windows with WSL/WSL2 is not supported for Android BSP.

Install required packages on host PC

$ sudo apt -y install gnupg flex bison gperf build-essential gcc-multilib g++-multilib
$ sudo apt -y install python3-pyelftools python3-dev python3.6 python2 python-is-python3
$ sudo apt -y install libc6-dev-i386 libncurses5 libncurses5-dev lib32z-dev libz-dev liblz-dev liblzo2-2 liblzo2-dev lzop lz4 cpio
$ sudo apt -y install libgl1-mesa-dev libxml2-utils xsltproc unzip bc libssl-dev ccache curl
$ sudo apt -y install git zip swig mtools uuid uuid-dev zlib1g-dev u-boot-tools lib32z1-dev fontconfig
$ sudo apt -y install mtd-utils device-tree-compiler gdisk m4 dwarves libgnutls28-dev libelf-dev x11proto-core-dev libx11-dev

For Ubuntu 20.04 and above:
The package android-tools-fsutils is obsolete and has been replaced by android-sdk-libsparse-utils.

$ sudo apt -y install android-sdk-libsparse-utils

Configure Git

$ git config --global user.name "Your Name"
$ git config --global user.email "Your Email"

Install the OpenJDK

To install it:

$ sudo apt update
$ sudo apt 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

Note: The build process requires about 500GB of free space.


Check Python Version

In the next steps, we will download (from Google repositories) the command repo, used to download all the Android source repositories.


Certain tools like bpttools requires python2 which is not available default on Ubuntu 20.04 or 22.04 LTS.
Ubuntu 20.04/22.04 LTS users can install it running

$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt update
$ sudo apt install python3.6 python2
Make sure you use latest repo tool for all bug fixes

Obtain Source Code

Variscite's Linux kernel and U-Boot are available through Github. Required patches for the Android file system are pre-installed

Download Google Repo Tool

$ mkdir -p ~/bin
$ curl -o ~/bin/repo https://commondatastorage.googleapis.com/git-repo-downloads/repo
$ chmod a+x ~/bin/repo
$ export PATH=~/bin:$PATH

Clone Variscite's U-Boot and Linux kernel Sources

$ mkdir ~/var_aosp_ti-13_09_00_00 && cd $_
$ export YOUR_PATH=$PWD
$ mkdir -p ${YOUR_PATH}/ti-bootloader-aosp/ && cd $_
$ repo init -u https://github.com/varigit/variscite-bsp-platform.git -b ti-android-13.0.0_r62-var01 -m RLS_09_00_Bootloader.xml
$ repo sync -j$(nproc)
$ mkdir -p ${YOUR_PATH}/ti-kernel-aosp/ && cd $_
$ repo init -u https://github.com/varigit/variscite-bsp-platform.git -b ti-android-13.0.0_r62-var01 -m RLS_09_00_Kernel.xml
$ repo sync -j$(nproc)

Clone Variscite's AOSP Sources

$ mkdir -p ${YOUR_PATH}/ti-aosp-13 && cd $_
$ repo init -u https://github.com/varigit/variscite-bsp-platform.git -b ti-android-13.0.0_r62-var01 -m RLS_09_00.xml
$ repo sync -j$(nproc)

Apply Variscite's platforms patches and install toolchains

$ cd ${YOUR_PATH}/ti-aosp-13/device
$ variscite/scripts/install.sh

Build Bootloader Components

Export Toolchains and setup paths

$ export PATH=$PATH:${YOUR_PATH}/ti-bootloader-aosp/toolchain//bin:${YOUR_PATH}/ti-bootloader-aosp/toolchain//bin
$ export G_ATF_SRC_DIR="${YOUR_PATH}/ti-bootloader-aosp/arm-trusted-firmware"
$ export G_OPTEE_SRC_DIR="${YOUR_PATH}/ti-bootloader-aosp/optee_os"
$ export G_CORE_LINUX_FIRMWARE_SRC_DIR="${YOUR_PATH}/ti-bootloader-aosp/ti-linux-firmware"
$ export G_UBOOT_SRC_DIR="${YOUR_PATH}/ti-bootloader-aosp/ti-u-boot"
$ export G_UBOOT_DEF_CONFIG_R="am62x_var_som_r5_defconfig"
$ export G_UBOOT_DEF_CONFIG_A="am62x_var_som_a53_defconfig"

Building ARM Trusted Firmware (ATF)

$ cd ${G_ATF_SRC_DIR}
$ make distclean
$ make -j$(nproc) E=0 CROSS_COMPILE=aarch64-none-linux-gnu- ARCH=aarch64 PLAT=k3 TARGET_BOARD=lite SPD=opteed CFLAGS+="-DK3_PM_SYSTEM_SUSPEND=1"

Building OP-TEE OS

$ cd ${G_OPTEE_SRC_DIR}
$ make clean && rm -rf out
$ make -j$(nproc) PLATFORM=k3 CFG_ARM64_core=y CROSS_COMPILE=arm-none-linux-gnueabihf- CROSS_COMPILE64=aarch64-none-linux-gnu-

Building U-Boot for R5 Core

$ cd ${G_UBOOT_SRC_DIR}
$ make mrproper
$ make -C ${G_UBOOT_SRC_DIR} mrproper
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- ${G_UBOOT_DEF_CONFIG_R} O=${G_UBOOT_SRC_DIR}/out/r5
$ make -j$(nproc) ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- BINMAN_INDIRS=${G_CORE_LINUX_FIRMWARE_SRC_DIR} O=${G_UBOOT_SRC_DIR}/out/r5

Building U-Boot for A53 Core with Android

$ cd ${G_UBOOT_SRC_DIR}
$ make mrproper
$ make ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- ${G_UBOOT_DEF_CONFIG_A} O=${G_UBOOT_SRC_DIR}/out/a53
$ make ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- am62x_android_a53.config O=${G_UBOOT_SRC_DIR}/out/a53
$ make -j$(nproc) ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- \
      BL31=${G_ATF_SRC_DIR}/build/k3/lite/release/bl31.bin \
      TEE=${G_OPTEE_SRC_DIR}/out/arm-plat-k3/core/tee-pager_v2.bin \
      BINMAN_INDIRS=${G_CORE_LINUX_FIRMWARE_SRC_DIR} O=${G_UBOOT_SRC_DIR}/out/a53

Copying Bootloader Images to AOSP Build

$ cp ${G_UBOOT_SRC_DIR}/out/r5/tiboot3-am62x-hs-fs-am62x-var-som.bin ${YOUR_PATH}/ti-aosp-13/vendor/ti/am62x/bootloader/am62x-sk/tiboot3-hsfs.bin
$ cp ${G_UBOOT_SRC_DIR}/out/r5/tiboot3-am62x-gp-am62x-var-som.bin ${YOUR_PATH}/ti-aosp-13/vendor/ti/am62x/bootloader/am62x-sk/tiboot3.bin
$ cp ${G_UBOOT_SRC_DIR}/out/a53/tispl.bin ${G_UBOOT_SRC_DIR}/out/a53/u-boot.img ${YOUR_PATH}/ti-aosp-13/vendor/ti/am62x/bootloader/am62x-sk/

Building the Kernel Image

$ cd ${YOUR_PATH}/ti-kernel-aosp/
$ export DIST_DIR=${YOUR_PATH}/ti-aosp-13/device/ti/am62x-kernel/kernel/6.1
$ tools/bazel run //common:ti_dist -- --dist_dir=$DIST_DIR

Note: The building process using the bazel tool is not a standard kernel build process, unlike make/soong. Google has published the guideline and package GKI bazel build, refer to https://source.android.com/docs/core/architecture/kernel/generic-kernel-image for more details.

To re-build Kernel fast for changes from the previous full build

$ tools/bazel run --config=fast //common:ti_dist -- --dist_dir=$DIST_DIR

Build Android Images

Change to Android top level directory.

$ cd ${YOUR_PATH}/ti-aosp-13
$ source build/envsetup.sh
$ lunch am62x_var_som-userdebug

or

$ lunch am62x_var_som-user

Note: userdebug build creates a debuggable version of Android.
           user build creates a production version of Android.

Build Android File System

Switching from eMMC build to SD card build and vice versa

  • For eMMC boot
$ m TARGET_AVB_ENABLE=true -j$(nproc) 2>&1 | tee build-emmc.log
  • For SD boot
$ m TARGET_AVB_ENABLE=true TARGET_SDCARD_BOOT=true -j$(nproc) 2>&1 | tee build-sd.log

Images created by the Android build

The resulted images are located in out/target/product/am62x_var_som.


Boot options

Boot options of the Android:
1. U-Boot boots from on-SOM eMMC
2. Directly from SD card (Requires separate build for AOSP images.)


Flash and boot Android from SD card

Create a bootable SD card

$ cd out/target/product/am62x_var_som
$ simg2img super.img super_raw.img
$ gzip super_raw.img
$ cd ${YOUR_PATH}/ti-aosp-13
$ sudo ./device/variscite/scripts/sh/var-mksdcard.sh /dev/sdX; sync
  • Replace /dev/sdX with your true device, You can identify it with dmesg.

Boot From SD card

Make sure the BOOT SELECT DIP switch on the carrier board is set correctly before you power on the board.

 $ SW3
 $ 0 : Boot from SD card
 $ 1 : Boot from eMMC

Flash and boot Android from eMMC

Flashing Android from Linux shell (when the primary installation android)

An example of flashing eMMC, can be found here.

Follow the following steps instructions above:

1. Preparing a rescue SD card;

2. Flash from command line (use the install_android.sh script)


Flashing Android with USB Fastboot

Install tools on host

$ sudo apt-get install android-tools-adb android-tools-fastboot

Note: Make sure you built Android for eMMC
Connect the target with host PC at fastboot mode:

  1. Connect a USB OTG cable from the target board OTG port to a your host machine USB HOST port.
  2. Power up the board and hit return/space to stop the boot at U-Boot.
  3. type fastboot 0 in the U-Boot command line.

On the Host PC:


Update Android firmware

Generate OTA packages

For generating "OTA" packages, use the following commands:
$ cd ${YOUR_PATH}/ti-aosp-13
$ source build/envsetup.sh 
$ lunch PRODUCT=am62x_var_som-userdebug
$ m TARGET_AVB_ENABLE=true -j$(nproc) otapackage
Install OTA package to device:
  • Extract payload.bin and payload_properties.txt from OTA zip file
  • Push payload.bin to board's /data/ota_package dir: adb push payload.bin /data/ota_package/ .
  • Open payload_properties.txt on an editor to copy its content, lets suppose it's like in the TI manual:
 FILE_HASH=wuBhu49k3pCmQmMl8S/n2NRm1he3A+IHshcQiOfCKc4=
 FILE_SIZE=501067958
 METADATA_HASH=qPWe72T37KgJtyJhuKSlNkFm1NflKFnLy+An4GnoXyA=
 METADATA_SIZE=31967
  • Input the following command on the board's console to update:
 su
 setenforce 0
 update_engine_client --payload=file:///data/ota_package/payload.bin --update --headers="FILE_HASH=wuBhu49k3pCmQmMl8S/n2NRm1he3A+IHshcQiOfCKc4=
 FILE_SIZE=501067958
 METADATA_HASH=qPWe72T37KgJtyJhuKSlNkFm1NflKFnLy+An4GnoXyA=
 METADATA_SIZE=31967"

Make sure that the -- header equals to the exact content of payload_properties.txt without "space" or "return" character.

After issuing the command, nothing seems to happen on the device, but you can monitor logcat for operation progress.

 logcat | grep update_engine

After a successful update, you can reboot into the updated version (_b/_a) slot.

Manual operations

Build boot.img

When you perform changes to the kernel, you may build boot.img solely instead of building the whole Android.

$ cd ${YOUR_PATH}/ti-kernel-aosp/
$ export DIST_DIR=${YOUR_PATH}/ti-aosp-13/device/ti/am62x-kernel/kernel/6.1
$ tools/bazel run --lto=full //common:ti_dist -- --dist_dir=$DIST_DIR
$ cd ${YOUR_PATH}/ti-aosp-13
$ lunch am62x_var_som-userdebug
$ m

Menu Config

$ cd ${YOUR_PATH}/ti-kernel-aosp/
$ tools/bazel run //common:ti_config -- menuconfig

Porting Drivers Notes

  • Actual Kernel source code is in ${YOUR_PATH}/ti-kernel-aosp/common
  • Defconfig Used in the kernel is from Google: ${YOUR_PATH}/ti-kernel-aosp/common/arch/arm64/configs/gki_defconfig
  • All drivers and SOC infrastructure is via modules and is setup by: ${YOUR_PATH}/ti-kernel-aosp/common/arch/arm64/configs/ti_gki.fragment
  • Your driver/ kernel module .ko must be added to GKI module list
 
    module_outs = COMMON_GKI_MODULES_LIST + [
     "net/wireless/your_module.ko",    
     "drivers/spi/your_driver.ko",
    ]
  • Your driver module dependencies must be resolved and must align cd ${YOUR_PATH}/ti-aosp-13/device/variscite/am62x_var_som/BoardConfig.mk

with following

BOARD_VENDOR_RAMDISK_KERNEL_MODULES += \
        device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/zsmalloc.ko \
        device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/zram.ko \
        device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/ti-msgmgr.ko \
        device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/ti_sci.ko \
        device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/ti_sci_pm_domains.ko \
        device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/phy-omap-usb2.ko \
        device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/syscon-clk.ko \
                 |                                   |
                 |                                   |
        device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/your_driver.ko