Android TI Guide: Difference between revisions

From Variscite Wiki
Line 417: Line 417:
  $ export DIST_DIR=${YOUR_PATH}/ti-aosp-13/device/variscite/am62x-kernel/kernel/6.1
  $ export DIST_DIR=${YOUR_PATH}/ti-aosp-13/device/variscite/am62x-kernel/kernel/6.1
  $ tools/bazel run --lto=full //common:ti_dist -- --dist_dir=$DIST_DIR
  $ tools/bazel run --lto=full //common:ti_dist -- --dist_dir=$DIST_DIR
$ cd ${YOUR_PATH}/ti-aosp-13
$ lunch am62x_var_som-userdebug
$ m TARGET_AVB_ENABLE=true


== Toolchain setup for manual build ==
== Menu Config ==
Setup the toolchain path to point to arm-linux-androideabi- tools in prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin
  $ cd ${YOUR_PATH}/ti-kernel-aosp/
  $ export ARCH=arm64
$ tools/bazel run //common:ti_config -- menuconfig
$ export CROSS_COMPILE={{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-


{{#if: {{#var:ANDROID_FASTBOOT_NEED_UNLOCK}} |
{{#if: {{#var:ANDROID_FASTBOOT_NEED_UNLOCK}} |
Line 439: Line 441:
* proceed for flashing
* proceed for flashing


}}
{{#ifeq:{{#var:ANDROID_UUU_SUPPORT}}|true |
= Flashing Using TI 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 TI. <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:TI_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}}
}}
}}

Revision as of 03:28, 21 December 2023

VAR-SOM-AM62 - Android 13-09.00.00 Developer Guide

Introduction

This page describes how to build and deploy Android 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.

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: 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 guide.

Windows with WSL/WSL2 is not supported for Android BSP

Install required packages on host PC

$ sudo apt-get -y install gnupg flex bison gperf build-essential zip 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-get -y install ccache libgl1-mesa-dev libxml2-utils xsltproc unzip bc
$ sudo apt-get -y install uuid uuid-dev zlib1g-dev liblz-dev liblzo2-2 liblzo2-dev lzop git curl  
$ sudo apt-get -y install u-boot-tools mtd-utils android-tools-fsutils device-tree-compiler gdisk m4 dwarves libgnutls28-dev
$ sudo apt-get -y install libelf-dev cpio lz4 python-is-python3 

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

$ sudo apt-get -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-get update
$ sudo apt-get 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 add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get 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/
$ repo init -u git@github.com:varigit-dev/variscite-bsp-platform.git -b develop_ti_android13_RND-1731_android -m RLS_09_00_Bootloader.xml
$ repo sync -j4
$ mkdir -p ${YOUR_PATH}/ti-kernel-aosp/ && cd $_
$ repo init -u git@github.com:varigit-dev/variscite-bsp-platform.git -b develop_ti_android13_RND-1731_android -m RLS_09_00_Kernel.xml
$ repo sync -j4

Clone Variscite's AOSP sources

$ mkdir -p ${YOUR_PATH}/ti-aosp-13 && cd $_
$ repo init -u git@github.com:varigit-dev/variscite-bsp-platform.git -b develop_ti_android13_RND-1731_android -m RLS_09_00.xml

Setup toolchain for Bootloader Components

$ cd ${YOUR_PATH}/ti-bootloader-aosp/

Download Toolchain and setup PATH

$ mkdir -p toolchain
$ wget https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xz && \
  tar -Jxvf gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xz -C toolchain && \
  wget https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz && \
  tar -Jxvf gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz -C toolchain
$ export PATH=$PATH:${YOUR_PATH}/ti-bootloader-aosp/toolchain/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin:${YOUR_PATH}/ti-bootloader-aosp/toolchain/toolchain/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin
$ export G_CORE_SECDEV_K3_SRC_DIR="${DEF_SRC_DIR}/core-secdev-k3"
$ export G_CORE_K3_IMAGE_GEN_SRC_DIR="${YOUR_PATH}/ti-bootloader-aosp/k3-image-gen"
$ export G_CORE_LINUX_FIRMWARE_SRC_DIR="${YOUR_PATH}/ti-bootloader-aosp/ti-linux-firmware"
$ 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_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_android_defconfig"
$ export G_CROSS_COMPILER_JOPTION="-j $(nproc)"

Build ATF

$ cd ${YOUR_PATH}/ti-bootloader-aosp/
$ make -C ${G_OPTEE_SRC_DIR} clean
$ make -C ${G_ATF_SRC_DIR} E=0 CROSS_COMPILE=aarch64-none-linux-gnu- ARCH=aarch64 PLAT=k3 TARGET_BOARD=lite SPD=opteed CFLAGS+="-DK3_PM_SYSTEM_SUSPEND=1"

Build OPTEE

$ cd ${YOUR_PATH}/ti-bootloader-aosp/
$ make clean
$ make -C ${G_OPTEE_SRC_DIR} CROSS_COMPILE32=arm-none-linux-gnueabihf- CROSS_COMPILE64=aarch64-none-linux-gnu- PLATFORM=k3-am62x CFG_ARM64_core=y

Build ti-boot3 R5

$ cd ${YOUR_PATH}/ti-u-boot/
$ rm -rf out
$ make -C ${G_UBOOT_SRC_DIR} mrproper
$ make -j4 ARCH=arm O=out/r5
$ make -C ${G_UBOOT_SRC_DIR} ${G_CROSS_COMPILER_JOPTION} ARCH=arm O=${G_UBOOT_SRC_DIR}/out/r5 \
               CROSS_COMPILE=arm-none-linux-gnueabihf- \
               ${G_UBOOT_DEF_CONFIG_R}
$ make -C ${G_UBOOT_SRC_DIR} ${G_CROSS_COMPILER_JOPTION} ARCH=arm O=${G_UBOOT_SRC_DIR}/out/r5 \
               CROSS_COMPILE=arm-none-linux-gnueabihf-

Build tiboot3-am62x-gp-evm.bin

$ make -C ${G_CORE_K3_IMAGE_GEN_SRC_DIR} mrproper
$ make -C ${G_CORE_K3_IMAGE_GEN_SRC_DIR} ${G_CROSS_COMPILER_JOPTION} ARCH=arm \
               CROSS_COMPILE=arm-none-linux-gnueabihf- \
               SOC=am62x SOC_TYPE=gp SBL=$G_UBOOT_SRC_DIR/out/r5/spl/u-boot-spl.bin \
               SYSFW_DIR=${G_CORE_LINUX_FIRMWARE_SRC_DIR}/ti-sysfw

Build tiboot3-am62x-hs-evm.bin

$ make -C ${G_CORE_K3_IMAGE_GEN_SRC_DIR} mrproper
$ make -C ${G_CORE_K3_IMAGE_GEN_SRC_DIR} ${G_CROSS_COMPILER_JOPTION} ARCH=arm \
               CROSS_COMPILE=arm-none-linux-gnueabihf- \
               SOC=am62x SOC_TYPE=hs SBL=$G_UBOOT_SRC_DIR/out/r5/spl/u-boot-spl.bin \
               SYSFW_DIR=${G_CORE_LINUX_FIRMWARE_SRC_DIR}/ti-sysfw \
               TI_SECURE_DEV_PKG=${G_CORE_SECDEV_K3_SRC_DIR}

Build tiboot3-am62x-hs-fs-evm.bin

$ make -C ${G_CORE_K3_IMAGE_GEN_SRC_DIR} mrproper
$ make -C ${G_CORE_K3_IMAGE_GEN_SRC_DIR} ${G_CROSS_COMPILER_JOPTION} ARCH=arm \
               CROSS_COMPILE=arm-none-linux-gnueabihf- \
               SOC=am62x SOC_TYPE=hs-fs SBL=$G_UBOOT_SRC_DIR/out/r5/spl/u-boot-spl.bin \
               SYSFW_DIR=${G_CORE_LINUX_FIRMWARE_SRC_DIR}/ti-sysfw \
               TI_SECURE_DEV_PKG=${G_CORE_SECDEV_K3_SRC_DIR}

Build u-boot A53 Android

$ cd ${YOUR_PATH}/ti-bootloader-aosp
$ make -C ${G_UBOOT_SRC_DIR} mrproper
$ make -j4 ARCH=arm O=out/r5
$ make -C ${G_UBOOT_SRC_DIR} ${G_CROSS_COMPILER_JOPTION} ARCH=arm O=${G_UBOOT_SRC_DIR}/out/a53 \
               CROSS_COMPILE=aarch64-none-linux-gnu- \
               ${G_UBOOT_DEF_CONFIG_A}
$ make -C ${G_UBOOT_SRC_DIR} ${G_CROSS_COMPILER_JOPTION} ARCH=arm O=${G_UBOOT_SRC_DIR}/out/a53 \
               CROSS_COMPILE=aarch64-none-linux-gnu-

Build tispl.bin and u-boot.img

$ make -C ${G_UBOOT_SRC_DIR} ${G_CROSS_COMPILER_JOPTION} ARCH=arm O=${G_UBOOT_SRC_DIR}/out/a53 \
               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}

Copy bootloader images to AOSP build

$ cp ${G_CORE_K3_IMAGE_GEN_SRC_DIR}/tiboot3.bin \
               ${G_CORE_K3_IMAGE_GEN_SRC_DIR}/tiboot3-am62x-gp-evm.bin \
               ${G_CORE_K3_IMAGE_GEN_SRC_DIR}/tiboot3-am62x-hs-evm.bin \
               ${G_CORE_K3_IMAGE_GEN_SRC_DIR}/tiboot3-am62x-hs-fs-evm.bin \
               ${G_UBOOT_SRC_DIR}/out/a53/tispl.bin \
               ${G_UBOOT_SRC_DIR}/out/a53/u-boot.img \
               ${YOUR_PATH}/ti-aosp-13/vendor/variscite/bootloader/am62x-sk

Build Kernel Image

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

PS: This is a GKI bazel build, refer to https://source.android.com/docs/core/architecture/kernel/generic-kernel-image

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 ~/var_aosp_ti-13_09_00_00/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.

$ export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH

Build Android

Switching from eMMC build to SD card build and vice versa

  • For eMMC boot
$ m TARGET_AVB_ENABLE=true -j4  2>&1 | tee build1-1.log 
  • For SD boot (Booting the entire Android from SDCard only)

Patch U-boot to be able to flash Android on sdcard via fastboot

Apply this patch in the U-boot source code:

diff --git a/configs/am62x_var_som_a53_android_defconfig b/configs/am62x_var_som_a53_android_defconfig
index 43ebd4e2f2..91e7ee0b47 100644
--- a/configs/am62x_var_som_a53_android_defconfig
+++ b/configs/am62x_var_som_a53_android_defconfig
@@ -125,7 +125,7 @@ CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
 CONFIG_FASTBOOT_BUF_SIZE=0x2F000000
 CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
 CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_TI_SCI_PROTOCOL=y
 CONFIG_SPL_DM_GPIO_LOOKUP_LABEL=y
$ m TARGET_SDCARD_BOOT=true TARGET_AVB_ENABLE=true -j4 2>&1 | tee build1-1.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 bootloader and AOSP images see above)


Flash and boot Android from SD card

Create a bootable SD card

$ cd ${YOUR_PATH}/ti-aosp-13/out/target/product/am62x_var_som
$ sudo ./flashall.sh --board am62x-sk --hsfs /dev/sdX;sync

OR If you want to boot entire Android from SD Card

$ cd ${YOUR_PATH}/ti-aosp-13/out/target/product/am62x_var_som
$ sudo ./flashall.sh --board am62x-sk --sdcard --hsfs /dev/sdX;sync
  • Replace /dev/sdX with your true device, You can identify it with dmesg.

Boot From SD card

  • Power-off the board.
  • Insert the SD card into the SD card slot of the carrier board (DVK)
  • Make sure the Boot Mode is set to SD card: see Setting the Boot Mode section
  • Power up the board - it will boot into Linux from the SD card


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)


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


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 ~/var_aosp_ti-13_09_00_00/ti-aosp-13
$ source build/envsetup.sh 
$ lunch PRODUCT=am62x_var_som-userdebug
$ m otapackage TARGET_AVB_ENABLE=true
Install OTA package to device:
  • Extract payload.bin and payload_properties.txt from OTA zip file
  • Push file payload.bin to somewhere on the device (typically /data/ota_package folder)
 adb push payload.bin /data/ota_package/payload.bin
  • Open payload_properties.txt on an editor to copy its content, lets suppose it's like in the TI manual:
 FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
 FILE_SIZE=379074366
 METADATA_HASH=Icrs3NqoglzyppyCZouWKbo5f08IPokhlUfHDmz77WQ/de8Dgp9zFXt8Fo+Hxccp465uTOvKNsteWU=
 METADATA_SIZE=46866
 
  • 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=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
 FILE_SIZE=379074366
 METADATA_HASH=Icrs3NqoglzyppyCZouWKbo5f08IPokhlUfHDmz77WQ/de8Dgp9zFXt8Fo+Hxccp465uTOvKNsteWU=
 METADATA_SIZE=46866"

Android 13 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 monit logcat for operation progress. After a successful update you can reboot into the updated version.

You can check chapter 7 of official TI "Android User Guide" for further "Over-The-Air (OTA) Update" examples.

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/variscite/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 TARGET_AVB_ENABLE=true

Menu Config

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

Unlock device for fastboot

Our build behaves like any other standard Android device.

To use fastboot, you should go through the following steps

  • Settings => System => About Tablet => Build number
  • keep on tapping until you see a prompt that says "You are now a developer!"
  • Settings => System => Advanced => Developer options => OEM unlocking
  • reboot to bootloader
  • 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
  • proceed for flashing