Boot Xen on the Telechips Dolphin5 platform and spawn a DomU

Boot Xen on the Telechips Dolphin5 platform and spawn a DomU

Introduction

This document outlines the steps needed to boot Xen on the Telechips Dolphin 5 platform using Linaro’s Trusted Reference Stack (TRS) using prebuilt images. When completed, we will be able to boot Xen and run TRS in the Dom0. From there, we will be able to spawn a DomU (aka. VM) with Android Automotive OS as the guest OS. The VM will boot to command prompt where you can interact with it using console, virtio-input and virtio-gpu (unaccelerated).

Prerequisites

We will need the following to run this demo:

  • Telechips Dolphin 5 platform

  • Access to Telechips internal code repositories

  • USB stick (requires minimal 32GiB) for storing Android images

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

Prebuilt images

Prebuilt images can be downlaoded (please contact document author for access permisson):

Flash the images on Dolphin5

Step1: flash all-in-one image ‘SD_Data.fai’

The board supports multiple boot modes, e.g. boot from USB, SNOR, EMMC, etc. In here, we will flash Telechips' all-in-one image to the on-board EMMC. First, we need to switch to the USB 2.0 boot mode in order to download the firmware via a USB cable.

The script below will flash the all-in-one Telechip’s image. It relies on fwdn command line tool and some json configuration files in order to download prebuilt images, these files are provided by Telechips Linux SDK. Please refer to Telechip’s documentation TCC807x Linux SDK-Getting Started for IVI_K5.10 V0.20[A].pdf for how to download Telechips Linux SDK.

IMG_PATH=$PWD/build/tcc8070-main/tmp/deploy/fwdn/ sudo fwdn --fwdn $IMG_PATH/boot-firmware/fwdn.json sudo fwdn --storage emmc --low-format sudo fwdn -w $IMG_PATH/boot-firmware/boot.json sudo fwdn -w $IMG_PATH/boot-firmware/prebuilt/tcc807x_snor.rom --storage snor --area die1 --no-crc sudo fwdn -w SD_Data.fai --storage emmc --area user --no-crc

Step 2: flash boot image and TRS root file system image

After the image SD_Data.fai has been flashed on the board, we need to change to the SNOR and eMMC boot mode to boot up the U-boot.

Reboot the board, U-boot console will appear assuming we are connected to the USB-UART port:

U-Boot 2022.01-00001-g4e4a6d0856 (May 12 2023 - 06:56:16 +0000) CPU: ARM Cortex-A55 Processor, Rev: r2p0 Model: Telechips TCC8070 EVB SV0.1 DRAM: 7 GiB MMC: tcc_sc_mmc: 0 Loading Environment from nowhere... OK In: serial@16600000 Out: serial@16600000 Err: serial@16600000 blkread: mmc 0 is current device ANDROID: Booting slot: a Hit any key to stop autoboot: 0 =>

Execute the command fastboot 0 in the U-boot console so U-boot will run into the fastboot mode:

=> fastboot 0 Execute 'fastboot 0' command to use fastboot on USB 2.0 DRD port. Execute 'fastboot 1' command to use fastboot on USB 3.0 DRD port.

At the host, we can flash the boot.img and TRS file system image with the commands:

$ sudo fastboot flash boot_a boot.img $ sudo fastboot flash boot_b boot.img $ sudo fastboot flash system_a trs-image.ext4

Boot TRS file system

Once the images have been flashed, we can boot the board and wait for the U-boot prompt. we will need to setup the boot parameters then boot the system:

=> setenv bootcmd "blkread info ${rootpart} ${slot} root_devnum root_partnum; fatload mmc 0:3 0x20100000 xen-uImage; fatload mmc 0:3 ${kerneladdr} Image-initramfs-tcc8070-main.bin; run loadfdt; run setupfdt; bootm 0x20100000 - ${fdt_addr}" => boot

Once booted, we will see the TRS login prompt. We can log in as root user without password.

TRS (Trusted Reference Stack) v0.3-28-gd55bc84 (build_id 22c37ada78) trs-qemuarm64 hvc0 trs-qemuarm64 login: root root@trs-qemuarm64:~#

Using the command xl list we can confirm that Dom0 is up and running:

root@trs-qemuarm64:~# xl list Name ID Mem VCPUs State Time(s) Domain-0 0 2048 6 r----- 15.4

Spawn a Xen virtual machine (DomU)

Prepare USB stick with Android images

Since the Android images are large, we will use USB stick (min 32GB) to store the images and directly run Android Automotive OS from it.

Uncompress the Android image file into an USB stick. We need to replace the path /path/to/USB/partition/ with our own path after we inserted the USB stick on the host machine.

$ sudo tar zxvf cuttlefish.tgz -C /path/to/USB/partition/ $ sudo cp u-boot.bin /path/to/USB/partition/

We also need to copy the Xen virtual machine configuration file (named as aaos_vm.cfg in this case) into the USB stick. Below is an example for the aaos_vm.cfg:

# Copyright (c) 2023, Linaro Limited. # # SPDX-License-Identifier: MIT name = "aaos-vm" memory = 4096 vcpus = 2 extra = " earlyprintk=xenboot console=hvc0 rw androidboot.console=hvc0 androidboot.serialconsole=1" root = "/dev/xvda2" kernel = "/mnt/u-boot.bin" disk = ['format=qcow2, vdev=xvda, access=rw, target=/mnt/cuttlefish/instances/cvd-1/overlay.img', 'format=raw, vdev=xvdb, access=r w, target=/mnt/cuttlefish/instances/cvd-1/persistent_composite.img', 'format=raw, vdev=xvdc, access=rw, target=/mnt/cuttlefish/ins tances/cvd-1/sdcard.img'] virtio_qemu_domid = 0

Mount USB stick on Dolphin 5 board

Insert the prepared USB stick into the USB 3.0 A-type connector (JC3 as shown in below picture).

Unfortunately, the system cannot detect the USB stick by default so you need to enable the USB port by running the following shell script ./enable-removable-disk.sh start for configuring the USB vbus appropriately.

#!/bin/sh ### BEGIN INIT INFO # Provides: Telechips Enable Removable Disk # Required-Start: # Required-Stop: # Default-Start: 5 # Default-Stop: 0 # Short-Description: Script to enable removable disk # Description: Script to enable removable disk after application ready. ### END INIT INFO # # -*- coding: utf-8 -*- # Debian init.d script for Telechips Launcher # Copyright © 2014 Wily Taekhyun Shin <thshin@telechips.com> case "$1" in start) . /etc/profile if [ -f /sys/devices/platform/11a00000.usb_ehci/ehci_vbus ]; then echo 1 > /sys/module/ehci_tcc/parameters/ehci_vbus_control_enable echo on > /sys/devices/platform/11a00000.usb_ehci/ehci_vbus fi if [ -f /sys/devices/platform/11980000.usb_dwc2/dwc2_vbus ]; then echo 1 > /sys/module/dwc2/parameters/dwc2_vbus_control_enable echo on > /sys/devices/platform/11980000.usb_dwc2/dwc2_vbus fi if [ -f /sys/devices/platform/11b00000.usb_dwc3/dwc3_vbus ]; then echo 1 > /sys/module/dwc3_tcc/parameters/dwc3_vbus_control_enable echo on > /sys/devices/platform/11b00000.usb_dwc3/dwc3_vbus fi udevadm trigger --action=add --subsystem-match=block --sysname-match=mmcblk[1-9]* ;; stop) . /etc/profile if [ -f /sys/devices/platform/11a00000.usb_ehci/ehci_vbus ]; then echo off > /sys/devices/platform/11a00000.usb_ehci/ehci_vbus echo 0 > /sys/module/ehci_tcc/parameters/ehci_vbus_control_enable fi if [ -f /sys/devices/platform/11980000.usb_dwc2/dwc2_vbus ]; then echo off > /sys/devices/platform/11980000.usb_dwc2/dwc2_vbus echo 0 > /sys/module/dwc2/parameters/dwc2_vbus_control_enable fi if [ -f /sys/devices/platform/11b00000.usb_dwc3/dwc3_vbus ]; then echo off > /sys/devices/platform/11b00000.usb_dwc3/dwc3_vbus echo 0 > /sys/module/dwc3_tcc/parameters/dwc3_vbus_control_enable fi udevadm trigger --action=remove --subsystem-match=block --sysname-match=mmcblk[1-9]* ;; *) echo "Usage: /usr/bin/enable-removable-disk.sh {start/stop}" exit 1 esac exit 0

We can confirm the USB stick is being detected by checking hte system log output (example below):

[ 534.903764] usb 4-1: new SuperSpeed Gen 1 USB device number 2 using xhci-hcd [ 534.930430] usb 4-1: New USB device found, idVendor=11b0, idProduct=3307, bcdDevice= 0.14 [ 534.938577] usb 4-1: New USB device strings: Mfr=3, Product=4, SerialNumber=2 [ 534.945822] usb 4-1: Product: UHSII uSD Reader [ 534.950353] usb 4-1: Manufacturer: Kingston [ 534.954629] usb 4-1: SerialNumber: 20210500002377 [ 534.960406] usb-storage 4-1:1.0: USB Mass Storage device detected [ 534.966764] scsi host0: usb-storage 4-1:1.0 [ 536.000954] scsi 0:0:0:0: Direct-Access Kingston UHSII uSD Reader 0014 PQ: 0 ANSI: 6 [ 536.009324] sd 0:0:0:0: Attached scsi generic sg0 type 0 [ 536.469999] sd 0:0:0:0: [sda] 125173760 512-byte logical blocks: (64.1 GB/59.7 GiB) [ 536.478273] sd 0:0:0:0: [sda] Write Protect is off [ 536.482998] sd 0:0:0:0: [sda] Mode Sense: 21 00 00 00 [ 536.488826] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA [ 536.525427] sda: sda1 sda2 [ 536.530560] sd 0:0:0:0: [sda] Attached SCSI removable disk

At this point, we can mount the USB stick to /mnt folder:

root@trs-qemuarm64:~# mount /dev/sda2 /mnt/ [ 903.254941] EXT4-fs (sda2): recovery complete [ 903.261185] EXT4-fs (sda2): mounted filesystem with ordered data mode. Opts: (null) root@trs-qemuarm64:~# ls /mnt/ aaos_vm.cfg u-boot.bin cuttlefish

Launch graphics system

Android running on a virtual machine will use TRS in the Dom0 graphcis system, which is baed on xfce4 . You can start xfce as follows:

root@trs-qemuarm64:~# startxfce4 Ctrl-c root@trs-qemuarm64:~# startxfce4 &

Known issue: when execute startxfce4, it fails to initialize the framebuffer in the first time. We need to kill it with ctrl-c command for doing a power cycle for display device. Then, the xfce4 window manager can boot up successfully in the second time after reanbled the display.

Run Android automotive OS on Xen virtual machine

Once xfce4 is up and running, we can launch Android automotive OS on a Xen virtual machine using the following commands

# export DISPLAY=:0 # cd /mnt # xl -vvv create aaos_vm.cfg -c

If successful, we can see the Android system booting up and Android homescreen: