Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Introduction

This article is to record document outlines the steps for of setting up and running Android Automotive images on Linaro’s Trusted Reference Stack (TRS. In this article, we will share the prebuilt images for easier reproducing this experiment. But in case if you are interested in how to build Android automotive images and build TRS images, you can refer to the documentations ) using prebuilt images. When completed, you will be able to boot the Android Automotive OS (AAOS) image in a DomU (aka VM) running on top of the Xen Hypervisor using TRS in the Dom0. The AAOS image will utilize the AVA platform's frame buffer (unaccelerated) and use VirtIO serial device to enable keyboard and mouse in order to interact with OS.

If interested in building from source please refer to the following documents [1][2] for details.

Prerequisites

You will need the following to run this demo

  • ADLink AVA Platform

  • Display connected to the VGA interface

  • Enough disk space

  • x86 Linux desktop (Tested on Ubuntu 22.04.3 LTS and Debian GNU/Linux 12 (bookworm))

Prebuilt images

The TRS prebuilt image is:
https://people.linaro.org/~leo.yan/arm_blueprint/aaos_on_xen/trs-image-trs-qemuarm64.wic.

The prebuilt Android automotive image is: https://people.linaro.org/~leo.yan/arm_blueprint/aaos_on_xen/cuttlefish.tgz.

Flash TRS image

We need to flash TRS image on NVME or USB stick. It’s recommended to use below shell script to flash TRS image, you can use below commands:

Code Block
$ wget https://people.linaro.org/~leo.yan/arm_blueprint/aaos_on_xen/trs-image-trs-qemuarm64.wic
$ sh flash_trs.sh /dev/nvmeXn1  # for flashing TRS on NVME block device
$ sh flash_trs.sh /dev/sdX      # for flashing TRS on USB stick

This script helps us to extend Prebuilt images can be downlaoded:

Flash the TRS image

TRS image can be flashed on either an NVME or a USB stick. The below script flash_trs.sh is for flashing TRS wic image onto a block device, the block device can be either an NVMe or USB stick, it also extends the root file system partition to the end of the disk device, thus we can get device to provide sufficient disk space for storing the Android imagesAutomotive OS image.

Code Block
languagebash
#!/bin/bash

DEV=$1

sudo parted ${DEV} print

echo "Please confirm if the partitiondevice is right?"
while : ; do
	read -n 1 k <&1
	if [[ $k = y ]] ; then
		printf "\n"
		break
	else
		printf "\nExit\n"
		exit 0
	fi
done

echo "Copy TRS image to the device ${DEV}"
sudo dd bs=4M if=./trs-image-trs-qemuarm64.wic of=$DEV status=progress && sync

sudo growpart $DEV 2
sudo /home/leoy/Downloads/e2fsprogs-1.47.0/e2fsck/e2fsckif [[ $DEV == *"nvme"* ]]; then
    ## Flash NVMe block device
    sudo e2fsck -f "${DEV}p2"
    sudo /home/leoy/Downloads/e2fsprogs-1.47.0/resize/resize2fs "${DEV}p2"
#sudo /home/leoy/Downloads/e2fsprogs-1.47.0/e2fsck/e2fsckelse
    ## Flash USB block device
    sudo e2fsck -f "${DEV}2"
#sudo /home/leoy/Downloads/e2fsprogs-1.47.0/resize/    sudo resize2fs "${DEV}2"
fi

sudo parted ${DEV} print

By following below steps, you can download the prebuilt TRS wic image then flash it to NVMe or USB stick.

Code Block
$ wget https://people.linaro.org/~leo.yan/arm_blueprint/aaos_on_xen/trs-image-trs-qemuarm64.wic
$ sh flash_trs.sh /dev/nvmeXn1  # for flashing TRS on NVMe block device
$ sh flash_trs.sh /dev/sdX      # for flashing TRS on USB stick

Note 1: It uses the commands e2fsck and resize2fs for resizing the second partition, if your working distro cannot provide e2fsck and resize2fs for the related new version (as tested they should The shell script requires the e2fsck and resize2fs utilities to be at least version 1.47.0 or newer versions), you need to download e2fsprogs and build by yourself.

Note 2: Because USB stick and NVME device have different block naming, you need to comment out lines 23 and 24, and enable lines 25 and 26.

...

. if not available, please download the e2fsprogs source and build it from source.

Run Android Automotive in a Xen virtual machine

After Once TRS system booted up, you need to download Android Cuttlefish automotive image (cuttlefish.tgz) image and uncompress it into a specific the folder (/home/leoy/android-cf-mainline/cf due to ), this is because the overlay images contains the absolute path so we must uncompress the Cuttlefish image into an absolute path. The commands are:

Code Block
languagebashnone
# wget https://people.linaro.org/~leo.yan/arm_blueprint/aaos_on_xen/cuttlefish.tgz
# wget https://people.linaro.org/~leo.yan/arm_blueprint/aaos_on_xen/aaos_vm.cfg
# wget https://people.linaro.org/~leo.yan/arm_blueprint/aaos_on_xen/u-boot.bin
# mkdir -p /home/leoy/android-cf-mainline/cf/
# tar zxvf cuttlefish.tgz -C /home/leoy/android-cf-mainline/cf/

In the console, we need to firstly launch Launch Xfce4 windows manager:

Code Block
languagebashnone
# startxfcestartxfce4 &

Everything is ready, we can run Android automotive on Run AAOS in a Xen virtual machine:

Code Block
# export DISPLAY=:0
# xl -vvv create aaos_vm.cfg -c

Note, the xen configuration file aaos_vm.cfg is updated to refelect the latest Android images:

Code Block
# Copyright (c) 2022, Arm Limited.
#
# SPDX-License-Identifier: MIT

name = "aaos-vm"
memory = 6144
vcpus = 4
extra = " earlyprintk=xenboot console=hvc0 rw androidboot.console=hvc0 androidboot.serialconsole=1"
root = "/dev/xvda2"
kernel = "/home/root/u-boot.bin"
disk = ['format=qcow2, vdev=xvda, access=rw, target=/home/leoy/android-cf-mainline/cf/cuttlefish/instances/cvd-1/overlay.img', 'format=qcow2, vdev=xvdb, access=rw, target=/home/leoy/android-cf-mainline/cf/cuttlefish/instances/cvd-1/persistent_composite_overlay.img', 'format=qcow2, vdev=xvdc, access=rw, target=/home/leoy/android-cf-mainline/cf/cuttlefish/instances/cvd-1/sdcard_overlay.img']
vif = ['mac=00:16:3E:74:34:32', 'mac=00:16:3e:5f:48:e4', 'mac=00:16:3E:74:34:32,script=vif-bridge,bridge=xenbr0']
virtio_qemu_domid = 0

Note, the prebuilt TRS image provided uses an outdated Xen repository, resulting in the lack of support for the option virtio = ['transport=pci, backend_type=qemu, bdf=02:00.0']. If you are building a TRS image using the Xen and AOSP maintenance repositories located in the directory xen-aosp, it is necessary to include the virtio configuration to enable the virtio-pci bus.

We have a recorded video which has been uploaded to the server [3]. You can refer to it for how to lanch AAOS on Xen virtual machine.

[1] Xen: maintenance Xen and QEMU repos for TRS
[2] Xen: porting Android Cuttlefish on Xen Virtual Machine
[3] https://people.linaro.org/~leo.yan/arm_blueprint/aaos_on_xen/AAOS_On_Xen_Demo.MOV