1.2. Building the SDK

1.2.1. Build PC Setup

Please refer to the following pages from Android documentation to setup your environment for Android build:

Getting the Repo tool

You will need the Repo tool to retrieve repositories. To install it, please refer to this webpage : https://source.android.com/setup/develop#installing-repo

Getting toolchain for u-boot builds

Links to download toolchains for building u-boot are mentioned in the SDK download page.

Install Optee-OS build dependencies

Check OPTEE OS docs to know list of dependencies needed to be installed : https://optee.readthedocs.io/en/latest/building/prerequisites.html

1.2.2. Downloading Sources

Create a folder for downloading all sources

mkdir ~/09_00_00 && cd $_
export YOUR_PATH=$PWD

1.2.2.1. Bootloader components

mkdir ${YOUR_PATH}/ti-bootloader-aosp/ && cd $_
git clone -b 08.06.00.007 git://git.ti.com/atf/arm-trusted-firmware.git
git clone -b 3.22.0-rc1 https://github.com/OP-TEE/optee_os.git
git clone -b 09.00.00.007-android git://git.ti.com/ti-u-boot/ti-u-boot.git
git clone -b 09.00.00.007 git://git.ti.com/processor-firmware/ti-linux-firmware.git

1.2.2.2. Kernel

Fetch the code using repo:

mkdir ${YOUR_PATH}/ti-kernel-aosp/ && cd $_
repo init -u git://git.ti.com/android/manifest.git -b android13-release -m releases/RLS_09_00_Kernel.xml
repo sync

Note

To save same disk space, pass the --depth=1 option to repo init:

repo init -u git://git.ti.com/android/manifest.git -b android13-release -m releases/RLS_09_00_Kernel.xml --depth=1

1.2.2.3. Android File System

Fetch the code using repo:

mkdir ${YOUR_PATH}/ti-aosp-13 && cd $_
repo init -u git://git.ti.com/android/manifest.git -b android13-release -m releases/RLS_09_00.xml
repo sync

1.2.3. Build Instructions

Note

The Bootloader and Kernel builds below are optional if they are used as is from TI release. Prebuilt copies of these binaries are already part of Android file system sources in device/ti/am62x-kernel and vendor/ti/am62x/bootloader folder.

1.2.3.1. Bootloader components

  1. Build ATF
cd ${YOUR_PATH}/ti-bootloader-aosp/arm-trusted-firmware
make E=0 CROSS_COMPILE=aarch64-none-linux-gnu- ARCH=aarch64 PLAT=k3 TARGET_BOARD=lite SPD=opteed CFLAGS+="-DK3_PM_SYSTEM_SUSPEND=1"
  1. Build OPTEE-OS
cd ${YOUR_PATH}/ti-bootloader-aosp/ti-optee-os
make PLATFORM=k3 CFG_ARM64_core=y CROSS_COMPILE=arm-none-linux-gnueabihf- CROSS_COMPILE64=aarch64-none-linux-gnu-
  1. Build tiboot3.bin
cd ${YOUR_PATH}/ti-bootloader-aosp/ti-u-boot/
make ARCH=arm am62x_evm_r5_defconfig
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- \
     BINMAN_INDIRS=${YOUR_PATH}/ti-bootloader-aosp/ti-linux-firmware
  1. Build tispl.bin and u-boot.img
cd ${YOUR_PATH}/ti-bootloader-aosp/ti-u-boot/
make ARCH=arm am62x_evm_a53_defconfig
make ARCH=arm am62x_android_a53.config
make ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- \
    BL31=${YOUR_PATH}/ti-bootloader-aosp/arm-trusted-firmware/build/k3/lite/release/bl31.bin \
    TEE=${YOUR_PATH}/ti-bootloader-aosp/optee_os/out/arm-plat-k3/core/tee-pager_v2.bin \
    BINMAN_INDIRS=${YOUR_PATH}/ti-bootloader-aosp/ti-linux-firmware
  1. Copy the tiboot3.bin, tispl.bin and u-boot.img generated in steps 3 and 4 to ${YOUR_PATH}/ti-aosp-13/vendor/ti/am62x/bootloader. If not copied, the prebuilt bootloader binaries already present in vendor/ti/am62x/bootloader will get use by flashall.sh flashing script.

Note

To Build bootloaders for AM62X LP Board please do same step with this defconfig:

  • For step 3 use am62x_lpsk_r5_defconfig
  • For step 4 use am62x_lpsk_a53_defconfig with same fragment

1.2.3.2. Kernel

1.2.3.2.1. Building everything from scratch

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

Note

Android move on Kleaf bazel build system, AOSP documentation can be read here and Kleaf documentatation here

1.2.3.2.2. Rebuilding faster

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

1.2.3.2.3. Defconfig/menuconfig changes

The usual (make menuconfig ) is done via bazel` command :

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

Note

Users must have built the android kernel image prior to building the Android file system. Otherwise pre-built Kernel images present in device/ti/am62x-kernel will be used to create boot.img

1.2.3.3. Android File System

cd ${YOUR_PATH}/ti-aosp-13
lunch <BUILD_TARGET>
m

Where BUILD_TARGET is listed in the table below :

Android Build type Build target
AM62X-SK Tablet userdebug am62x-userdebug
AM62X-SK Tablet user am62x-user
AM62X-SK Car userdebug am62x_car-userdebug
AM62X-SK Car user am62x_car-user

Note

Default BUILD_TARGET to use is am62x-userdebug

Note

By default with User images AVB feature was enabled. For userdebug images if you want to enable AVB feature you need to build with TARGET_AVB_ENABLE=true build args

cd ${YOUR_PATH}/ti-aosp-13
lunch <BUILD_TARGET>
m TARGET_AVB_ENABLE=true

After building all components, refer to instruction in next section for flashing the images to EVM