Author: Sam Protsenko <semen.protsenko at linaro dot org>

Booting Android-N on AM57x EVM board

Board connections

Power supply: "Curtis Industries" DT060AF-5, 12V adapter, 5A (60W); positive inner, female barrel 5.5 mm x 2.5 mm

OTG cable: USB "A" to USB-Micro "B" (example).

OTG cable will be used for:

  • - flashing images to eMMC via fastboot tool

    - and for adb tool in Android.

Serial console cable:

There are 2 options verified:

1. PL2303 USB-to-TTL cable (example)

  • Connection scheme:

    align="middle"

2. TTL-232R-3V3 (datasheet)

  • Connection scheme:

    align="middle"

Downloading sources

U-Boot

Obtain U-Boot sources:

$ git clone git://git.ti.com/android-sdk/u-boot.git u-boot
$ cd u-boot
$ git checkout p-ti-u-boot-2016.05

Kernel

Obtain kernel sources:

$ git clone git://git.ti.com/android-sdk/kernel-omap.git linux
$ cd linux
$ git checkout p-ti-lsk-android-linux-4.4.y

Android

Obtain AFS sources:

$ repo init -u git://git.ti.com/android-sdk/platform-manifest.git -b d-nougat-mr1-release -m default.xml
$ repo sync -j20

Build instructions

Toolchain

We're gonna use Linaro toolchain for building U-Boot, kernel and SGX module.

Download toolchain from here.

Unpack it to /opt or any other convenient location.

NOTE: New Android pre-built toolchain doesn't work for kernel, so avoid using it.

Setting up build environment

Next environment should be used for build of U-Boot, Linux kernel and SGX module:

$ export PATH=/opt/gcc-linaro-arm-none-eabi-4.8-2014.04_linux/bin:$PATH
$ export CROSS_COMPILE="arm-none-eabi-"
$ export ARCH=arm

For Android build we're gonna use Android internal pre-built toolchain.

Building U-Boot

NOTE: For now we should use no-DT u-boot configuration, as DT configuration has issues with MMC (incorrect writing of system.img due to buggy ACMD12 implementation).

Build U-Boot using next commands:

$ make am57xx_evm_nodt_defconfig
$ make -j4

Output files:

  • 1st stage: MLO

  • 2nd stage: u-boot.img

Building the kernel

Build Linux kernel using next commands:

$ ti_config_fragments/defconfig_builder.sh -t ti_sdk_am57x_android_release
$ make ti_sdk_am57x_android_release_defconfig
$ make -j4 zImage
$ make am57xx-evm-reva3.dtb

Output files:

  • kernel image: arch/arm/boot/zImage

  • device tree blob: am57xx-evm-reva3.dtb

Building Android

Copy kernel image to AFS sources dir:

$ cp -fv $kernel_dir/arch/arm/boot/zImage device/ti/am57xevm/kernel

Build Android FS using next commands:

$ . build/envsetup.sh
$ lunch full_am57xevm-userdebug
$ make -j4

Output files:

  • host files: out/host/linux-x86/bin/*

  • target files: out/target/product/am57xevm/*

Rebuild PowerVR SGX544-MP2 kernel module

Run next script to rebuild SGX kernel module against your kernel:

   1 #!/bin/bash
   2 
   3 eurasiacon_dir=device/ti/proprietary-open/jacinto6/sgx_src/eurasia_km/eurasiacon
   4 src_dir=$eurasiacon_dir/build/linux2/omap_android
   5 out_dir=$eurasiacon_dir/binary2_omap_android_release/target
   6 
   7 export KERNELDIR=path/to/your/kernel/dir
   8 export KERNEL_CROSS_COMPILE="$CROSS_COMPILE"
   9 export ANDROID_ROOT=$(pwd)
  10 export TARGET_DEVICE=am57xevm
  11 
  12 cd $src_dir
  13 make TARGET_PRODUCT="am57xevm" BUILD=release
  14 cd -

Be sure to put correct kernel dir path in $KERNELDIR variable.

Output file:

  • $out_dir/pvrsrvkm.ko

Push SGX module to the system partition and reboot the board:

   1 #!/bin/bash
   2 
   3 sgx_module=device/ti/proprietary-open/jacinto6/sgx_src/eurasia_km/eurasiacon/binary2_omap_android_release/target/pvrsrvkm.ko
   4 
   5 adb root
   6 sleep 3
   7 adb remount
   8 sleep 3
   9 adb push $sgx_module /system/lib/modules
  10 sleep 3
  11 adb reboot

Boot from SD card

Brand-new board doesn't have any software flashed into its eMMC. So SD card should be used to bring it up.

If your board already has U-Boot in eMMC -- skip this step.

AM57xx EVM board supports only micro-SD cards.

Format SD card

SD card needs to have 2 partitions on it: "boot" (FAT32) and "rootfs" (ext4).

Script below will partition and format SD card for you (making 100MB for "boot" partition and the rest of SD card for "rootfs").

NOTE: Be sure to use sfdisk 2.27.* or above. It was noticed that my script doesn't work with sfdisk 2.25.2.

   1 #!/bin/bash
   2 
   3 disk=""
   4 boot_part=""
   5 rootfs_part=""
   6 
   7 print_usage() {
   8         echo "Usage: $0 sd_card_device"
   9         echo
  10         echo "Example:"
  11         echo "    $0 /dev/mmcblk0"
  12 }
  13 
  14 parse_arguments() {
  15         if [ $# -ne 1 ]; then
  16                 echo "Error: Wrong arguments count ($#)" >&2
  17                 print_usage
  18                 exit 1
  19         fi
  20 
  21         disk=$1
  22         boot_part=${disk}p1
  23         rootfs_part=${disk}p2
  24 
  25         if [ $disk != "/dev/mmcblk0" ]; then
  26                 echo "PROTECTION!!! Use only /dev/mmcblk0 or modify script!" >&2
  27                 exit 1
  28         fi
  29 
  30         if [ ! -e $disk ]; then
  31                 echo "Error: $disk file not found" >&2
  32                 exit 1
  33         fi
  34 }
  35 
  36 create_partitions() {
  37         echo "---> Erase partition table/labels on micro-SD card..."
  38         sudo dd if=/dev/zero of=${disk} bs=1M count=1
  39 
  40         echo
  41         echo "---> Create partition layout..."
  42         sudo sfdisk ${disk} << EOF
  43                 2048,100M,0x0c,*
  44                 ,,L,-
  45 EOF
  46 
  47         if [ ! -e $boot_part ]; then
  48                 echo "Error: $boot_part file not found" >&2
  49                 exit 1
  50         fi
  51 
  52         if [ ! -e $rootfs_part ]; then
  53                 echo "Error: $rootfs_part file not found" >&2
  54                 exit 1
  55         fi
  56 
  57         echo
  58         echo "---> Format partitions..."
  59         echo "  --> Format partition 1 (boot)..."
  60         sudo mkfs.vfat -F 32 -n "boot" $boot_part
  61         echo "  --> Format partition 2 (rootfs)..."
  62         sudo mkfs.ext4 -F -L "rootfs" $rootfs_part
  63 }
  64 
  65 parse_arguments $*
  66 create_partitions

Copying files

Copy next files to "boot" partition of your SD card:

 - MLO
 - u-boot.img

Flashing U-Boot to eMMC

1. Insert your SD card into board's slot and press power or reset button to start.

2. Once you can see U-Boot output in "minicom" -- press any key to get into U-Boot shell.

3. Run next commands in U-Boot shell:

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

4. On your host:

$ fastboot oem format
$ fastboot flash xloader MLO
$ fastboot flash bootloader u-boot.img

(you can find fastboot tool in your AFS host output directory).

5. Press "Ctrl+C" in U-Boot shell to get out from fastboot mode (or just reboot your board).

6. Check that eMMC has correct partition table (optional):

=> part list mmc 1

7. Remove SD card from your board. Now you can run U-Boot from eMMC (just reset the board).

Booting Android from SD

See this link to figure out how to boot Android from SD card:

http://www.omappedia.org/wiki/6AM_SD_card_boot

Preparing images

Preparing eMMC binaries/images

Copy next files to the directory that will contain binaries for flashing:

From U-Boot:

  • MLO

  • u-boot.img

From kernel:

  • arch/arm/boot/zImage

  • arch/arm/boot/dts/am57xx-evm-reva3.dtb

From Android (from out/target/product/am57xevm/):

  • boot.img

  • cache.img

  • recovery.img

  • system.img

  • userdata.img

Flashing eMMC images

Get to U-Boot shell on device and run next command:

=> fastboot 1

Run next commands on host, from directory with eMMC images:

$ fastboot flash xloader MLO
$ fastboot flash bootloader u-boot.img
$ fastboot flash environment am57xx-evm-reva3.dtb
$ fastboot flash recovery recovery.img
$ fastboot flash boot boot.img
$ fastboot flash system system.img
$ fastboot flash cache cache.img
$ fastboot flash userdata userdata.img

Now you can reboot your board and Android will be booted from eMMC.

[1] TI Release Notes for Android-M on AM57x EVM

[2] Pre-built Android-M images for AM57x EVM

[3] Pre-built Android-N images for AM57x EVM

Boards/BeagleBoard-X15 (last modified 2017-08-31 12:04:41)