Date of last update: 14 Feb 2019

Android Oreo with 4.14

This page captures the latest Android baseline details for TI AM65XGPEVM.

Hardware and Supporting Documentation: http://www.ti.com/tool/TMDX654GPEVM

Baseline

* Android: 8.1/ Oreo MR1
* Kernel: 4.14.y
* Uboot: 2018.01
* ATF: 2.0
* OPTEE: 3.4.0
* SysFW: 2018.10

Preparing the Tools

1. Download and install required toolchains (ARM32 toolchain is needed for Cortex-R5F core, and ARM64 toolchain is needed for Cortex-A53):

$ cd ~/Downloads
$ wget https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
$ wget https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/arm-eabi/gcc-linaro-7.3.1-2018.05-x86_64_arm-eabi.tar.xz
$ sudo tar xJvf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz -C /opt/
$ sudo tar xJvf gcc-linaro-7.3.1-2018.05-x86_64_arm-eabi.tar.xz -C /opt

2. Make OTG USB work without root. Create file /etc/udev/rules.d/51-android.rules and add next line to it:

SUBSYSTEM=="usb", ATTR{idVendor}=="0451", MODE="0660", GROUP="plugdev"

and run next commands:

$ sudo udevadm control --reload
$ sudo udevadm trigger

3. Make the minicom work without root:

$ sudo usermod -a -G dialout $USER

then logout/login in your OS.

4. Install packages required for building:

$ sudo apt install git ccache minicom make libncurses5-dev libssl-dev bc bison flex mtools

5. Create directory for all repositories:

$ mkdir ~/repos

We will use this directory to keep the source code for all software. If you'd like to use another location, please replace ~/repos with desired directory further.

Hardware Connections

1. Connect LCD panel and touchscreen to the internal board:

lcd-internal-connections.jpg

2. Connect LCD board to main board:

lcd-connection.jpg

3. Remove shown jumper, so that OTG port can work in "device" mode:

jumper.jpg

4. Connect OTG USB and UART USB to your machine:

usb-connection.jpg

Obtaining and Building the Software

ATF

Obtain ATF:

$ cd ~/repos
$ git clone git://git.ti.com/atf/arm-trusted-firmware.git
$ cd arm-trusted-firmware
$ git checkout ti-atf

Configure shell environment for cross-compiling:

$ export PATH=/opt/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin:$PATH
$ export CROSS_COMPILE="ccache aarch64-linux-gnu-"
$ export ARCH=aarch64

Build ATF:

$ make PLAT=k3 TARGET_BOARD=generic SPD=opteed

OP-TEE

Obtain OP-TEE:

$ cd ~/repos
$ git clone git://git.ti.com/optee/ti-optee-os.git
$ cd ti-optee-os
$ git checkout ti_optee_os

Configure shell environment:

$ export PATH=/opt/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin:$PATH
$ export PATH=/opt/gcc-linaro-7.3.1-2018.05-x86_64_arm-eabi/bin:$PATH
$ export CROSS_COMPILE64="ccache aarch64-linux-gnu-"
$ export CROSS_COMPILE32="ccache arm-eabi-"
$ unset ARCH

Build OP-TEE:

$ make PLATFORM=k3-am65x CFG_ARM64_core=y

SYSFW

Obtain SysFW:

$ cd ~/repos
$ git clone git://git.ti.com/processor-firmware/system-firmware-image-gen.git
$ cd system-firmware-image-gen

Configure shell environment:

$ export CROSS_COMPILE="ccache arm-eabi-"
$ export PATH=/opt/gcc-linaro-7.3.1-2018.05-x86_64_arm-eabi/bin:$PATH
$ export ARCH=arm

Build SysFW:

$ make

U-Boot

Obtain U-Boot:

$ cd ~/repos
$ git clone git://git.ti.com/ti-u-boot/ti-u-boot.git
$ cd ti-u-boot
$ git checkout ti-u-boot-2018.01

Configure shell environment for Cortex-R5F build:

$ export PATH=/opt/gcc-linaro-7.3.1-2018.05-x86_64_arm-eabi/bin:$PATH
$ export CROSS_COMPILE="ccache arm-eabi-"
$ export ARCH=arm
$ unset ATF
$ unset TEE

Build U-Boot for Cortex-RF5 core:

$ make O=/tmp/r5 distclean
$ make O=/tmp/r5 am65x_evm_r5_defconfig
$ make O=/tmp/r5 -j4

Configure shell environment for Cortex-A53 build:

$ export PATH=/opt/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin:$PATH
$ export CROSS_COMPILE="ccache aarch64-linux-gnu-"
$ export ARCH=arm
$ export ATF=~/repos/ti-atf/build/k3/generic/release/bl31.bin
$ export TEE=~/repos/ti-optee-os/out/arm-plat-k3/core/tee-pager.bin

Build U-Boot for Cortex-A53 core:

$ make O=/tmp/a53 distclean
$ make O=/tmp/a53 am65x_evm_a53_defconfig
$ make O=/tmp/a53 -j4

Kernel

Obtain Android kernel:

$ cd ~/repos
$ git clone git://git.ti.com/ti-linux-kernel/ti-linux-kernel.git
$ cd ti-linux-kernel
$ git checkout ti-android-linux-4.14.y

Configure shell environment:

$ export PATH=/opt/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin:$PATH
$ export CROSS_COMPILE="ccache aarch64-linux-gnu-"
$ export ARCH=arm64

Configure and build the kernel:

$ ./ti_config_fragments/defconfig_builder.sh -t ti_sdk_arm64_android_release
$ make ti_sdk_arm64_android_release_defconfig
$ make -j4 Image dtbs modules

AFS

Obtain Android-O MR1 sources:

$ cd ~/repos
$ mkdir ti-android-o-mr1
$ cd ti-android-o-mr1
$ repo init -u git://git.ti.com/android/manifest.git -b oreo-mr1-core-dev
$ repo sync -j20

Configure and build Android:

$ export KERNELDIR=~/repos/ti-linux-kernel
$ . ./build/envsetup.sh
$ lunch am65xevm_full-userdebug
$ make –j4

Flashing and Booting

UART Boot: Recovery or First time Flash and Boot

Lets Assume /dev/ttyUSB1 is the first instance and /dev/ttyUSB2 is second instance.

Configure SYSBOOT DIP-switch for booting from UART:

SW2[0:3] = 0010
SW3[0:3] = 1010
SW4[0:1] = 00

Script for flashing images via UART:

   1 #!/bin/bash
   2 
   3 # Run stty to set the baud rate
   4 stty -F /dev/ttyUSB1 115200
   5 stty -F /dev/ttyUSB2 115200
   6 
   7 # Send tiboot3.bin  as xmodem, 2 minute timeout
   8 /usr/bin/timeout 120 /usr/bin/sx -k --xmodem tiboot3.bin < /dev/ttyUSB2 > /dev/ttyUSB2
   9 
  10 # If we timeout or don't return cleanly (transfer failed), return 1
  11 if [ $? -ne 0 ]; then
  12     exit 1
  13 fi
  14 
  15 # Send sysfw as ymodem, 4 minute timeout.
  16 /usr/bin/timeout 240 /usr/bin/sb -kb --ymodem sysfw.itb < /dev/ttyUSB2 > /dev/ttyUSB2
  17 
  18 # If we timeout or don't return cleanly (transfer failed), return 1
  19 if [ $? -ne 0 ]; then
  20     exit 1
  21 fi
  22 
  23 # Send tispl as ymodem, 4 minute timeout
  24 /usr/bin/timeout 240 /usr/bin/sb -kb --ymodem tispl.bin < /dev/ttyUSB1 > /dev/ttyUSB1
  25 
  26 # If we timeout or don't return cleanly (transfer failed), return 1
  27 if [ $? -ne 0 ]; then
  28     exit 1
  29 fi
  30 
  31 # Send U-Boot as ymodem, 4 minute timeout
  32 /usr/bin/timeout 240 /usr/bin/sb -kb --ymodem u-boot.img < /dev/ttyUSB1 > /dev/ttyUSB1
  33 
  34 # If we timeout or don't return cleanly (transfer failed), return 1
  35 if [ $? -ne 0 ]; then
  36     exit 1
  37 fi
  38 
  39 sleep 1
  40 # Send an echo to be sure that we will break into autoboot
  41 echo > /dev/ttyUSB1
  42 
  43 mkdir /tmp/images
  44 cd /tmp/images
  45 cp /tmp/a53/tispl.bin .
  46 cp /tmp/a53/u-boot.img .
  47 cp ~/repos/system-firmware-image-gen/sysfw.itb .
  48 dd if=/dev/zero of=bootloader.img bs=1M count=8
  49 /sbin/mkfs.vfat bootloader.img
  50 mcopy -i bootloader.img tispl.bin ::tispl.bin
  51 mcopy -i bootloader.img u-boot.img ::u-boot.img
  52 mcopy -i bootloader.img sysfw.itb ::sysfw.itb
  53 
  54 cp /tmp/r5/tiboot3.bin .
  55 cp ~/repos/ti-android-o-mr1/out/target/product/am65xevm/*.img .
  56 
  57 # Flash bootloader in eMMC
  58 
  59 echo 'env default -f -a' > /dev/ttyUSB1
  60 echo 'setenv partitions $partitions_android' > /dev/ttyUSB1
  61 echo 'env save' > /dev/ttyUSB1
  62 
  63 echo 'fas 0' > /dev/ttyUSB1
  64 fastboot oem format
  65 fastboot flash tiboot3 tiboot3.bin
  66 fastboot flash bootloader bootloader.img

SD Boot: Recovery or First time Flash and Boot

Let's assume your SD card dev file is /dev/mmcblk0.

Format SD card:

$ sudo dd if=/dev/zero of=/dev/mmcblk0 bs=1M count=1
$ sudo sfdisk /dev/mmcblk0 << EOF
2048,1G,0x0c,*
,,L,-
EOF

$ sudo mkfs.vfat -F 32 -n "boot" /dev/mmcblk0p1
$ sudo mkfs.ext4 -F -L "rootfs" /dev/mmcblk0p2

Copy files to SD card:

sudo mkdir /mnt/boot
sudo mount /dev/mmcblk0p1 /mnt/boot
sudo cp ~/repos/system-firmware-image-gen/sysfw.itb /mnt/boot
sudo cp /tmp/r5/tiboot3.bin /mnt/boot
sudo cp /tmp/a53/tispl.bin /mnt/boot
sudo cp /tmp/a53/u-boot.img /mnt/boot
sudo sync
sudo umount /mnt/boot

Configure SYSBOOT DIP-switch for booting from SD card:

SW2[0:3] = 0010
SW3[0:3] = 0110
SW4[0:1] = 11

Insert prepared SD card into the slot. Power on the board. Press SPACE to get into U-Boot shell.

eMMC Boot: Production Flash and Boot

You can use either SD or UART Boot to Recover the device or Boot for the first time.

Configure SYSBOOT DIP-switch for booting from eMMC (user area mode):

SW2[0:3] = 0000
SW3[0:3] = 0110
SW4[0:1] = 00

Prepare the U-Boot environment:

=> env default -f -a
=> setenv partitions $partitions_android
=> env save
=> fastboot 0

Flash images to eMMC:

$ fastboot oem format
$ fastboot flash tiboot3 tiboot3.bin
$ fastboot flash bootloader bootloader.img
$ fastboot flash vendor vendor.img
$ fastboot flash userdata userdata.img
$ fastboot flash boot boot_fit.img
$ fastboot flash system system.img

Reboot the board:

$ fastboot reboot

You should see kernel boot log in minicom and Android boot animation/lock screen on LCD panel.

If you have Automation Board (optional), you can use it for switching between UART and eMMC boot mode. More at https://wiki.linaro.org/Boards/TI_Automation .

References

[1] http://git.ti.com/cgit/cgit.cgi/ti-u-boot/ti-u-boot.git/tree/board/ti/am65x/README?h=ti-u-boot-2018.01

Boards/AM65xEVM (last modified 2019-02-14 11:24:50)