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:

Recommended cable for serial console is TTL-232R-3V3 (datasheet).

  • Connection scheme:


Downloading sources


Obtain U-Boot sources:

$ git clone git:// u-boot
$ cd u-boot
$ git checkout p-ti-u-boot-2016.05


Obtain kernel sources:

$ git clone git:// linux
$ cd linux
$ git checkout p-ti-android-linux-4.4.y


Make sure you have a bin/ directory in your home directory and that it is included in your path:

$ mkdir ~/bin
$ export PATH=~/bin:$PATH

Download the Repo tool and ensure that it is executable:

$ curl > ~/bin/repo
$ chmod a+x ~/bin/repo

Obtain AFS sources:

$ mkdir android
$ cd android
$ repo init -u git:// -b oreo-dev
$ repo sync -j20

Build instructions

Setting up build environment

We're going to use prebuilt GCC toolchain from Android for building U-Boot and kernel.

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

$ export PATH=$ANDROID_PATH/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin:$PATH
$ export CROSS_COMPILE=arm-linux-androidkernel-
$ export ARCH=arm

where $ANDROID_PATH is a path to directory to which you downloaded Android sources.

Building U-Boot

Build U-Boot using next commands:

$ make am57xx_evm_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/ -t ti_sdk_am57x_android_release
$ make ti_sdk_am57x_android_release_defconfig
$ make -j4 zImage dtbs modules

Output files:

  • kernel image: arch/arm/boot/zImage

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

Building Android

Follow instructions from official Android page for setting up the packages required for building Android.

Build Android FS using next commands:

$ export KERNELDIR=<path to your kernel directory>
$ . build/
$ lunch full_am57xevm-userdebug
$ make -j4

Output files:

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

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

Boot from SD card

SD card boot can be helpful in next cases:

  • Brand-new board doesn't have any software flashed into its eMMC. So SD card should be used to bring it up
  • SD card boot also can be helpful when the board is "bricked" (eMMC boot doesn't work)

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
   3 disk=""
   4 boot_part=""
   5 rootfs_part=""
   7 print_usage() {
   8         echo "Usage: $0 sd_card_device"
   9         echo
  10         echo "Example:"
  11         echo "    $0 /dev/mmcblk0"
  12 }
  14 parse_arguments() {
  15         if [ $# -ne 1 ]; then
  16                 echo "Error: Wrong arguments count ($#)" >&2
  17                 print_usage
  18                 exit 1
  19         fi
  21         disk=$1
  22         boot_part=${disk}p1
  23         rootfs_part=${disk}p2
  25         if [ $disk != "/dev/mmcblk0" ]; then
  26                 echo "PROTECTION!!! Use only /dev/mmcblk0 or modify script!" >&2
  27                 exit 1
  28         fi
  30         if [ ! -e $disk ]; then
  31                 echo "Error: $disk file not found" >&2
  32                 exit 1
  33         fi
  34 }
  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
  40         echo
  41         echo "---> Create partition layout..."
  42         sudo sfdisk ${disk} << EOF
  43                 2048,100M,0x0c,*
  44                 ,,L,-
  45 EOF
  47         if [ ! -e $boot_part ]; then
  48                 echo "Error: $boot_part file not found" >&2
  49                 exit 1
  50         fi
  52         if [ ! -e $rootfs_part ]; then
  53                 echo "Error: $rootfs_part file not found" >&2
  54                 exit 1
  55         fi
  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 }
  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:

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

  • vendor.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 boot boot.img
$ fastboot flash cache cache.img
$ fastboot flash recovery recovery.img
$ fastboot flash system system.img
$ fastboot flash userdata userdata.img
$ fastboot flash vendor vendor.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-N images for AM57x EVM

[3] Jacinto 6 (DRA7 EVM) instructions

Boards/BeagleBoard-X15 (last modified 2018-01-26 17:33:24)