Android 14-09.02.00 Developer Guide¶
Introduction¶
This page describes how to build and deploy Android 14 on the VAR-SOM-AM62. It is based on TI's Android 14-09.02.00 release.
For additional details about this release, refer to the Release Notes.
Overview¶
The objective of this document is to guide VAR-SOM-AM62 Android developers to obtain Android Android 14 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:
- Ubuntu 16.04/18.04 64bit LTS http://www.ubuntu.com/download/desktop
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.
Configure Git¶
Install the OpenJDK¶
To install it:
If your Ubuntu version is missing the package (which shouldn't happen), add the PPA repository and run the previous commands again:
Update the default Java version by running:
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.
Recent versions of command repo, rely on python 3.6, not available in Ubuntu 16.04.
Ubuntu 16.04 LTS users can install it running
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 -p ${YOUR_PATH}/ti-bootloader-aosp/ && cd $_
repo init -u https://github.com/varigit/variscite-bsp-platform.git -b ti-android-14.0.0_r19-var01 -m RLS_09_02_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-14.0.0_r19-var01 -m RLS_09_02_Kernel.xml
repo sync -j$(nproc)
Clone Variscite's AOSP Sources¶
mkdir -p ${YOUR_PATH}/ti-aosp-14 && cd $_
repo init -u https://github.com/varigit/variscite-bsp-platform.git -b ti-android-14.0.0_r19-var01 -m RLS_09_02.xml
repo sync -j$(nproc)
Apply Variscite's platforms patches and install toolchains¶
Build Bootloader Components¶
Export Toolchains and setup paths¶
export PATH=$PATH:${YOUR_PATH}/ti-bootloader-aosp/toolchain/arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu/bin:${YOUR_PATH}/ti-bootloader-aosp/toolchain/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf/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-14/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-14/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-14/vendor/ti/am62x/bootloader/am62x-sk/
Building the Kernel Image¶
cd ${YOUR_PATH}/ti-kernel-aosp/
export DIST_DIR=${YOUR_PATH}/ti-aosp-14/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¶
Build Android Images¶
Change to Android top level directory.
or
Note: userdebug build creates a debuggable version of Android. eng build creates an engineering version of Android. Development mode enable and development tools are available on target.
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
- For SD boot
Images created by the Android build¶
The resulted images are located in out/target/product/am62x_var_som.
|
Image
|
Description
|
|---|---|
|
tiboot3-am62x-sk-hsfs.bin
tiboot3-am62x-sk.bin tispl-am62x-sk.bin u-boot-am62x-sk.img |
Bootloader images for eMMC/SD card boot.
bootloader.img = (tispl.bin + u-boot.img). |
| boot.img | Kernel Image + dtbs. |
| vendor_boot.img | Vendor modules, vendor ramdisk. |
| init_boot.img | Generic init ramdisk. |
| dtbo.img | dtbo.img or dtbo-unsigned.img (list of overlays). |
| vbmeta.img | With AVB feature or user images. |
| vbmeta_vendor_dlkm | AVB info for vendor_dlkm. |
| persist.img | Used for OP-TEE secure storage. |
| super.img | Android super image file.(Contains system, vendor). |
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-14
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.
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:
-
Preparing a rescue SD card;
-
Flash from command line (use the install_android.sh script)
Flashing Android with USB Fastboot¶
Install tools on host¶
Note: Make sure you built Android for eMMC
Connect the target with host PC at fastboot mode:
- Connect a USB OTG cable from the target board OTG port to a your host machine USB HOST port.
- Power up the board and hit return/space to stop the boot at U-Boot.
- type fastboot 0 in the U-Boot command line.
On the Host PC:
sudo fastboot flash dtbo_a out/target/product/am62x_var_som/dtbo.img
sudo fastboot flash dtbo_b out/target/product/am62x_var_som/dtbo.img
sudo fastboot flash boot_a out/target/product/am62x_var_som/boot.img
sudo fastboot flash boot_b out/target/product/am62x_var_som/boot.img
sudo fastboot flash init_boot_a out/target/product/am62x_var_som/init_boot.img
sudo fastboot flash init_boot_b out/target/product/am62x_var_som/init_boot.img
sudo fastboot flash vendor_boot_a out/target/product/am62x_var_som/vendor_boot.img
sudo fastboot flash vendor_boot_b out/target/product/am62x_var_som/vendor_boot.img
sudo fastboot flash vbmeta_a out/target/product/am62x_var_som/vbmeta.img
sudo fastboot flash vbmeta_b out/target/product/am62x_var_som/vbmeta.img
sudo fastboot flash vbmeta_vendor_dlkm_a out/target/product/am62x_var_som/vbmeta_vendor_dlkm.img
sudo fastboot flash vbmeta_vendor_dlkm_b out/target/product/am62x_var_som/vbmeta_vendor_dlkm.img
sudo fastboot flash super out/target/product/am62x_var_som/super.img
sudo `which fastboot` reboot
Update Android firmware¶
Generate OTA packages¶
For generating "OTA" packages, use the following commands:¶
cd ${YOUR_PATH}/ti-aosp-14
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.
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-14/device/ti/am62x-kernel/kernel/6.1
tools/bazel run --lto=full //common:ti_dist -- --dist_dir=$DIST_DIR
cd ${YOUR_PATH}/ti-aosp-14
lunch am62x_var_som-userdebug
m
Menu Config¶
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-14/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