Android TI Guide: Difference between revisions

From Variscite Wiki
 
(68 intermediate revisions by 2 users not shown)
Line 3: Line 3:
--> {{#lst:Android_Platform_Customization|{{#var:RELEASE_PARAM|am62-android-13_09.00.00-v1.0}}}} <!--
--> {{#lst:Android_Platform_Customization|{{#var:RELEASE_PARAM|am62-android-13_09.00.00-v1.0}}}} <!--
--> {{PageHeader|{{#var:HARDWARE_NAME}} - {{#var:ANDROID_TI_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<br/> =
= Introduction =


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


= Overview =
= Overview =
Line 20: Line 20:
*Making Changes to kernel/configuration and update {{#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 =
 
= 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 33: Line 34:
Before starting a build, make sure you have adequate free space available.
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.
{{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.}}
 
To learn more, please see Variscite's [[Docker_Build_Environment | Docker Build Environment]] guide.
Windows with WSL/WSL2 is not supported for Android BSP}}


=== Install required packages on host PC ===
=== Install required packages on host PC ===
Line 44: Line 42:
$ 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 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 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
$ 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
$ sudo apt -y install mtd-utils device-tree-compiler gdisk m4 dwarves libgnutls28-dev libelf-dev x11proto-core-dev libx11-dev
</pre>
</pre>
Line 77: 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 108: 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>


Line 120: Line 117:
  $ export PATH=~/bin:$PATH
  $ export PATH=~/bin:$PATH


== Clone Variscite's U-Boot and Linux kernel sources ==
== Clone Variscite's U-Boot and Linux kernel Sources ==
  $ mkdir {{#var:BUILD_FOLDER}} && cd $_
  $ mkdir {{#var:BUILD_FOLDER}} && cd $_
  $ export YOUR_PATH=$PWD
  $ export YOUR_PATH=$PWD
Line 132: Line 129:
  $ repo sync -j$(nproc)
  $ repo sync -j$(nproc)


== Clone Variscite's AOSP sources ==
== Clone Variscite's AOSP Sources ==
  $ mkdir -p ${YOUR_PATH}/ti-aosp-13 && cd $_
  $ 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 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)
  $ repo sync -j$(nproc)


$ sed -i '/DTB_FILES :=/d' device/ti/am62x/build/tasks/dtimages.mk
== Apply Variscite's platforms patches and install toolchains ==
  $ sed -i '/$(LOCAL_DTB)\/k3-am625-sk.dtb/d' device/ti/am62x/build/tasks/dtimages.mk
  $ cd ${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}}/device
$ sed -i '/$(LOCAL_DTB)\/k3-am62-lp-sk.dtb/d' device/ti/am62x/build/tasks/dtimages.mk
  $ variscite/scripts/install.sh
  $ sed -i 's/# Please keep this list fixed: add new files in the end of the list/include device\/variscite\/am62x_var_som\/build\/tasks\/dtimages.mk/g' \
        device/ti/am62x/build/tasks/dtimages.mk


= Build Bootloader Components =
= Build Bootloader Components =


== Download Toolchain and setup PATH ==
== Export Toolchains and setup paths ==
$ cd ${YOUR_PATH}/ti-bootloader-aosp/
 
$ mkdir -p toolchain
  $ export PATH=$PATH:${YOUR_PATH}/ti-bootloader-aosp/toolchain/{{#var:ARMv8_TOOLCHAIN}}/bin:${YOUR_PATH}/ti-bootloader-aosp/toolchain/{{#var:ARMv7_TOOLCHAIN}}/bin
$ 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/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_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_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_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_R="am62x_var_som_r5_defconfig"
  $ export G_UBOOT_DEF_CONFIG_A="am62x_var_som_a53_android_defconfig"
  $ export G_UBOOT_DEF_CONFIG_A="am62x_var_som_a53_defconfig"
$ export G_CROSS_COMPILER_JOPTION="-j $(nproc)"


== Build ATF ==
== Building ARM Trusted Firmware (ATF) ==
  $ cd ${YOUR_PATH}/ti-bootloader-aosp/
  $ cd ${G_ATF_SRC_DIR}
  $ make -C ${G_ATF_SRC_DIR} clean
  $ make distclean
  $ 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"
  $ 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"


== Build OPTEE ==
== Building OP-TEE OS ==
  $ cd ${YOUR_PATH}/ti-bootloader-aosp/
  $ cd ${G_OPTEE_SRC_DIR}
  $ make -C ${G_OPTEE_SRC_DIR} clean
  $ make clean && rm -rf out
  $ 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
  $ make -j$(nproc) PLATFORM=k3 CFG_ARM64_core=y CROSS_COMPILE=arm-none-linux-gnueabihf- CROSS_COMPILE64=aarch64-none-linux-gnu-


== Build ti-boot3 R5 ==
== Building U-Boot for R5 Core ==
  $ cd ${YOUR_PATH}/ti-bootloader-aosp/ti-u-boot
  $ cd ${G_UBOOT_SRC_DIR}
$ rm -rf out
  $ make mrproper
  $ cd ${YOUR_PATH}/ti-bootloader-aosp
  $ make -C ${G_UBOOT_SRC_DIR} mrproper
  $ make -C ${G_UBOOT_SRC_DIR} mrproper
  $ make -C ${G_UBOOT_SRC_DIR} ${G_CROSS_COMPILER_JOPTION} ARCH=arm O=${G_UBOOT_SRC_DIR}/out/r5 \
  $ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- ${G_UBOOT_DEF_CONFIG_R} O=${G_UBOOT_SRC_DIR}/out/r5
                CROSS_COMPILE=arm-none-linux-gnueabihf- \
  $ 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
                ${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 (GP) ==
  $ 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 (HS-SE) ==
$ 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 (HS-FS) ==
$ 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 with Android ==
== Building U-Boot for A53 Core with Android ==
  $ cd ${YOUR_PATH}/ti-bootloader-aosp
  $ cd ${G_UBOOT_SRC_DIR}
  $ make -C ${G_UBOOT_SRC_DIR} mrproper
  $ make mrproper
  $ make -C ${G_UBOOT_SRC_DIR} ${G_CROSS_COMPILER_JOPTION} ARCH=arm O=${G_UBOOT_SRC_DIR}/out/a53 \
  $ make ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- ${G_UBOOT_DEF_CONFIG_A} O=${G_UBOOT_SRC_DIR}/out/a53
                CROSS_COMPILE=aarch64-none-linux-gnu- \
$ make ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- am62x_android_a53.config O=${G_UBOOT_SRC_DIR}/out/a53
                ${G_UBOOT_DEF_CONFIG_A}
$ 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


== Build tispl.bin and u-boot.img ==
== Copying Bootloader Images to AOSP Build ==
  $ make -C ${G_UBOOT_SRC_DIR} ${G_CROSS_COMPILER_JOPTION} ARCH=arm O=${G_UBOOT_SRC_DIR}/out/a53 \
  $ 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
                CROSS_COMPILE=aarch64-none-linux-gnu- \
$ 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
                BL31=${G_ATF_SRC_DIR}/build/k3/lite/release/bl31.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/
                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 ==
= Building the Kernel Image =
$ 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/am62x_var_som/bootloader/am62x-sk/
 
= Build Kernel Image =
  $ cd ${YOUR_PATH}/ti-kernel-aosp/
  $ cd ${YOUR_PATH}/ti-kernel-aosp/
  $ export DIST_DIR=${YOUR_PATH}/ti-aosp-13/device/variscite/am62x-kernel/kernel/6.1
  $ export DIST_DIR=${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}}/device/ti/am62x-kernel/kernel/6.1
$ mkdir -p $DIST_DIR
  $ tools/bazel run //common:ti_dist -- --dist_dir=$DIST_DIR
  $ tools/bazel run --lto=full //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.
<span style="color:red">Note:</span> The build process uses bazel tool. <br> This 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 ==
== To re-build Kernel fast for changes from the previous full build ==
Line 241: Line 196:


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
  $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
  $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
Line 260: Line 215:
</span>  
</span>  
}}
}}
$ export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH
   
   
== Build Android ==
== Build Android File System ==
=== Switching from eMMC build to SD card build and vice versa ===
=== Switching from eMMC build to SD card build and vice versa ===
* For eMMC boot
* For eMMC boot
  $ m TARGET_AVB_ENABLE=true -j4  2>&1 {{!}} tee build1-1.log  
  $ m TARGET_AVB_ENABLE=true -j$(nproc) 2>&1 {{!}} tee build-emmc.log
* For SD boot (Booting the entire Android from SDCard only)
* For SD boot
=== Patch U-boot to be able to flash Android on sdcard via fastboot ===
  $ m TARGET_AVB_ENABLE=true TARGET_SDCARD_BOOT=true -j$(nproc) 2>&1 {{!}} tee build-sd.log
Apply this patch in the U-boot source code and re-build, copy bootloader components as per above steps:
<syntaxhighlight lang="diff">
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
</syntaxhighlight>
  $ m TARGET_SDCARD_BOOT=true TARGET_AVB_ENABLE=true -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}}}}
{{#lst:APC_VAR-SOM-AM62|{{#var:ANDROID_IMAGES_SECTION}}}}
{{#lst:APC_VAR-SOM-AM62|{{#var:ANDROID_IMAGES_SECTION}}}}
Line 295: Line 232:
Boot options of the Android:<br>
Boot options of the Android:<br>
1. U-Boot boots from on-SOM eMMC<br>
1. U-Boot boots from on-SOM eMMC<br>
2. Directly from SD card (Requires separate build for bootloader and AOSP images. See "Patch U-boot to be able to flash Android on sdcard via fastboot" above.)<br>
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 ===
<pre>
$ cd out/target/product/{{#var:ANDROID_MACHINE_NAME}}
$ cd ${YOUR_PATH}/ti-aosp-13/out/target/product/am62x_var_som
$ simg2img super.img super_raw.img
$ sudo ./flashall.sh --board am62x-sk --hsfs /dev/sdX;sync
$ gzip super_raw.img
</pre>
$ cd ${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}}
OR
$ sudo ./device/variscite/scripts/sh/var-mksdcard.sh /dev/sdX; sync
If you want to boot entire Android from SD Card
<pre>
$ cd ${YOUR_PATH}/ti-aosp-13/out/target/product/am62x_var_som
$ sudo ./flashall.sh --board am62x-sk --sdcard --hsfs /dev/sdX;sync
</pre>
* 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 ==
Line 325: Line 262:


2. Flash from command line (use the install_android.sh script)
2. Flash from command line (use the install_android.sh script)
Further, follow the steps described in paragraph "'''Flashing Android with USB Fastboot'''"




Line 352: Line 286:


===== For generating "OTA" packages, use the following commands: =====
===== For generating "OTA" packages, use the following commands: =====
  $ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}
  $ cd ${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}}
  $ source build/envsetup.sh  
  $ source build/envsetup.sh  
  $ lunch PRODUCT={{#var:ANDROID_MACHINE_NAME}}-userdebug
  $ lunch PRODUCT={{#var:ANDROID_MACHINE_NAME}}-userdebug
  $ m otapackage TARGET_AVB_ENABLE=true
  $ m TARGET_AVB_ENABLE=true -j$(nproc) otapackage


===== 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/ .
  |
  {{#ifeq: {{#var:ANDROID_NAME}} | Android 10 |
* Push payload.bin to board's /sdcard dir: adb push payload.bin /sdcard/ .
  |
* 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:
* Open payload_properties.txt on an editor to copy its content, lets suppose it's like in the TI manual:
   FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
   FILE_HASH=wuBhu49k3pCmQmMl8S/n2NRm1he3A+IHshcQiOfCKc4=
   FILE_SIZE=379074366
   FILE_SIZE=501067958
   {{#ifeq: {{#var:ANDROID_NAME}} | Android 10 |
   METADATA_HASH=qPWe72T37KgJtyJhuKSlNkFm1NflKFnLy+An4GnoXyA=
    METADATA_HASH=Icrs3NqoglzyppyCZouWKbo5f08IPokhlUfHDmz77WQ=
   METADATA_SIZE=31967
    |
    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:
  su
  setenforce 0
  update_engine_client --payload=file:///data/ota_package/payload.bin --update --headers="FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
  |
  {{#ifeq: {{#var:ANDROID_NAME}} | Android 10 |
* Input the following command on the board's console to update:
* Input the following command on the board's console to update:
   su
   su
   setenforce 0
   setenforce 0
   update_engine_client --payload=file:///sdcard/payload.bin --update --headers="FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
   update_engine_client --payload=file:///data/ota_package/payload.bin --update --headers="FILE_HASH=wuBhu49k3pCmQmMl8S/n2NRm1he3A+IHshcQiOfCKc4=
  |
   FILE_SIZE=501067958
* Issue the following command on adb shell:
   METADATA_HASH=qPWe72T37KgJtyJhuKSlNkFm1NflKFnLy+An4GnoXyA=
  update_engine_client --payload=file:///cache/payload.bin --update --headers="FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
   METADATA_SIZE=31967"
  }}}}
   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"
Make sure that the -- header equals to the exact content of payload_properties.txt without "space" or "return"
character.
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"
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 monitor logcat for operation progress. After a successful update, you can reboot into the updated version (_b/_a) slot.
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 =
= Manual operations =
Line 418: Line 319:
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 ${YOUR_PATH}/ti-kernel-aosp/
  $ cd ${YOUR_PATH}/ti-kernel-aosp/
  $ export DIST_DIR=${YOUR_PATH}/ti-aosp-13/device/variscite/am62x-kernel/kernel/6.1
  $ export DIST_DIR=${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}}/device/ti/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
  $ cd ${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}}
  $ lunch am62x_var_som-userdebug
  $ lunch am62x_var_som-userdebug
  $ m TARGET_AVB_ENABLE=true
  $ m


== Menu Config ==
== Menu Config ==
Line 440: Line 341:
</pre>
</pre>


* Your driver module dependencies must be resolved and must align ${YOUR_PATH}/ti-aosp-13/device/variscite/am62x_var_som/BoardConfig.mk
* Your driver module dependencies must be resolved and must align cd ${YOUR_PATH}/{{#var:BUILD_FOLDER_ANDROID}}/device/variscite/am62x_var_som/BoardConfig.mk
with following  
with following  
<pre>
<pre>
BOARD_VENDOR_RAMDISK_KERNEL_MODULES += \
BOARD_VENDOR_RAMDISK_KERNEL_MODULES += \
         device/variscite/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/zsmalloc.ko \
         device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/zsmalloc.ko \
         device/variscite/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/zram.ko \
         device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/zram.ko \
         device/variscite/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/ti-msgmgr.ko \
         device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/ti-msgmgr.ko \
         device/variscite/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/ti_sci.ko \
         device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/ti_sci.ko \
         device/variscite/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/ti_sci_pm_domains.ko \
         device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/ti_sci_pm_domains.ko \
         device/variscite/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/phy-omap-usb2.ko \
         device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/phy-omap-usb2.ko \
         device/variscite/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/syscon-clk.ko \
         device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/syscon-clk.ko \
                 |                                  |
                 |                                  |
                 |                                  |
                 |                                  |
         device/variscite/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/your_driver.ko
         device/ti/am62x-kernel/kernel/$(TARGET_KERNEL_USE)/your_driver.ko
</pre>
</pre>

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