Skip to content

Latest commit

 

History

History
479 lines (344 loc) · 16.4 KB

getting-started.md

File metadata and controls

479 lines (344 loc) · 16.4 KB

Getting Started

This guide will show how to set up the host machine for Yocto build and then how to build and boot ACRN Hypervisor, Service VM and User VMs on Intel platforms.

Table of Contents

=================

I. Overview

II. Set Up Build Host

III. Building ACRN Bootable Image

IV. Booting ACRN Image

V. Configurations

VI. Build WIC Installer Image

VII. Tested Hardware

VIII.Contributing

Overview

This layer provides ACRN Hypvervisor integration with Yocto Project.

Supported Hardware

ACRN is supported on the following Intel platforms:

  • Kaby Lake
  • Whiskey Lake
  • Tiger Lake
  • Elkhart Lake

About minimum system requirements and limitations, please find more information at Supported Hardware

Set Up Build Host

Compatible Linux Distribution

Make sure your build host meets the following requirements:

  • 50 Gbytes of free disk space
  • Runs a supported Linux distribution

Currently, the Yocto Project is supported on a number of Linux Distributions. This guide covers only for Ubuntu 18.04 (LTS). To know more about the complete list of supported Linux distributions, please visit Supported Linux Distributions

  • Git 1.8.3.1 or greater
  • tar 1.28 or greater
  • Python 3.5.0 or greater
  • gcc 5.0 or greater

Required Packages for Build Host

Install essential host packages on your build host (Ubuntu):

$ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm

Building ACRN Bootable Image

Dependencies

meta-acrn layer depends on:

  • poky, branch master [or hardknott/gatesgarth/dunfell]
  • meta-oe, branch master [or hardknott/gatesgarth/dunfell]
  • meta-python, branch master [or hardknott/gatesgarth/dunfell]
  • meta-filesystems, branch master [or hardknott/gatesgarth/dunfell]
  • meta-networking, branch master [or hardknott/gatesgarth/dunfell]
  • meta-virtualization, branch master [or hardknott/gatesgarth/dunfell]
  • meta-intel, branch master [or hardknott/gatesgarth/dunfell]

Build Image

Download Layers and Initialize Build Environment

  • Create build workspace
$ mkdir workspace
  • Clone poky
$ cd workspace
$ git clone https://git.yoctoproject.org/git/poky
  • Clone all dependent layers
$ cd poky
$ git clone https://github.com/openembedded/meta-openembedded.git
$ git clone https://git.yoctoproject.org/git/meta-virtualization
$ git clone https://git.yoctoproject.org/git/meta-intel
$ git clone https://github.com/intel/meta-acrn.git
  • Initialize build environment
$ source oe-init-build-env
  • Add layers to build environment conf/bblayers.conf
$ bitbake-layers add-layer ../meta-openembedded/meta-oe
$ bitbake-layers add-layer ../meta-openembedded/meta-python
$ bitbake-layers add-layer ../meta-openembedded/meta-filesystems
$ bitbake-layers add-layer ../meta-openembedded/meta-networking
$ bitbake-layers add-layer ../meta-virtualization
$ bitbake-layers add-layer ../meta-intel
$ bitbake-layers add-layer ../meta-acrn

Configure Service VM (SOS)

meta-acrn maintains prototype DISTRO configurations for both Servcie VM OS (SOS) and User VM OS (UOS). acrn-demo-sos for Service VM OS and acrn-demo-uos for User VM OS. local.conf carries the common configuration, which can be overwritten by individual multiconfigs conf/multiconfig/xxx.conf For the Service VM OS, we carry configuration in conf/local.conf and for User VM OS we carry in conf/multiconfig/uos.conf

Append the following configuration in conf/local.conf:

MACHINE = "intel-corei7-64"
TMPDIR = "${TOPDIR}/master-acrn-sos"
DISTRO = "acrn-demo-sos"

# Also use the 'uos' configuration
BBMULTICONFIG = "uos"

# The packages-from-images class (container-package.bbclass) needs to know where images are
CONTAINER_PACKAGE_DEPLOY_DIR = "${TOPDIR}/master-acrn-uos/deploy/images/${MACHINE}"
CONTAINER_PACKAGE_MC = "uos"

# Add core-image-base-package to acrn-image-base
IMAGE_INSTALL:append:pn-acrn-image-base = " core-image-base-package"
# Add core-image-weston-package to acrn-image-sato
IMAGE_INSTALL:append:pn-acrn-image-sato = " core-image-weston-package"

# set preferred kernel for sos
PREFERRED_PROVIDER_virtual/kernel = "linux-intel-acrn-sos"

Configure Post-launched User VM (UOS)

Add the following in conf/multiconfig/uos.conf:

DISTRO = "acrn-demo-uos"
TMPDIR = "${TOPDIR}/master-acrn-uos"
PREFERRED_PROVIDER_virtual/kernel = "linux-intel-acrn-uos"

Note how the parent local.conf refers to what DEPLOY_DIR_IMAGE will be in uos.conf. Remember to keep these in sync.

Build UOS image via multiconfig

Based on your target image. It can be:

  • core-image-base
  • core-image-sato
  • core-image-weston
$ bitbake mc:uos:core-image-base

This should build you a core-image-base-intel-corei7-64.wic can be located at build/master-acrn-uos/deploy/images/intel-corei7-64/.

Build ACRN image

Based on your target image, It can be:

  • acrn-image-base
  • acrn-image-sato
  • acrn-image-weston
  • acrn-image-minimal
$ bitbake acrn-image-base

Note that thanks to a bug in bitbake if you go straight to acrn-image-base from an empty sstate then it will build a lot of recipes twice. For speed, build the UOS image first and then the SOS, as the SOS image can re-use 99% of the sstate.

By default, building acrn-image-base will build a .wic image and can be located at build/master-acrn-sos/deploy/images/intel-corei7-64/.

Booting ACRN Image

Boot ACRN and SOS

On successful build, you will find the ACRN bootable image acrn-image-base-intel-corei7-64.wic in the build/master-acrn-sos/deploy/images/intel-corei7-64/ directory.

Under Linux, insert a USB flash drive. Assuming the USB flash drive takes device /dev/sdf, use dd to copy the image to it. Before the image can be burned onto a USB drive, it should be un-mounted. Some Linux distros may automatically mount a USB drive when it is plugged in. Using USB device /dev/sdf as an example, find all mounted partitions:

    $ mount | grep sdf

and un-mount those that are mounted, for example:

    $ umount /dev/sdf1
    $ umount /dev/sdf2

Now burn the image onto the USB drive:

    $ sudo dd if=acrn-image-base-intel-corei7-64.wic of=/dev/sdf status=progress
    $ sync
    $ eject /dev/sdf

This should give you a bootable USB flash device. Insert the device into a bootable USB socket on the target, and power on. It should give two boot options, 'boot' and 'ACRN (Yocto)'. Select 'ACRN (Yocto)' to spawn hypervisor, while 'boot' to boot as normal Linux.

Launching UOS

$ /var/lib/machines/launch-base.sh

USB Passthrough

Once a graphical UOS has been started you'll want to interact with it. One simple solution is to set the relevant variables so that logging into the console can access the display.

For X:

$ export DISPLAY=:1

And for Weston:

$ export XDG_RUNTIME_DIR=/run/user/$(id -u)

That will let you start applications but you still can't interact with them: good enough for running glmark2 but not for anything interactive. For this, USB host virtualisation lets you pass specific USB ports through to the guest. Start by using lsusb to identify the bus and port you want to forward, and then edit launch-weston.sh or similar to pass another option to acrn-dm:

-s 7,xhci,1-1,1-2

This forwards ports 1-1 and 1-2 into the UOS, which on Skull Canyon is the two front ports (1-1 on the left, 1-2 on the right). You'll need two input devices for this to work, obviously.

Configurations

MACHINE Configuration

meta-intel provides the following machine configurations:

  • intel-corei7-64

  • intel-skylake-64

intel-skylake-64 is 64-bit machine with -march=skylake and avx2 instruction-set set up. For more information, please check intel-skylake-64.conf

intel-skylake-64 machine must be used for Skylake and successor platforms

To configure MACHINE, set the following in your conf/local.conf

MACHINE = "intel-corei7-64"

Adding Guests

The multiconfig/package magic works with a <image>-package.bb recipe that inherits container-package. This puts the wic image and launcher script into a package which can be added as usual.

To add core-image-base.wic image into Service OS (Add core-image-base-package to your target ACRN image)

IMAGE_INSTALL:append:pn-acrn-image-base = " core-image-base-package"

To add core-image-weston-package to acrn-image-weston

IMAGE_INSTALL:append:pn-acrn-image-weston = " core-image-weston-package"

To add core-image-weston-package to acrn-image-base

IMAGE_INSTALL:append:pn-acrn-image-base = " core-image-weston-package"

ACRN Configuration

ACRN BOARD Configuration

To build for your target board, set ACRN_BOARD in your conf/local.conf. By default it is set to nuc7i7dnb

ACRN_BOARD = "whl-ipc-i5"

Supported Boards:

  • apl-mrb
  • apl-up2-n3350
  • apl-up2
  • nuc6cayh
  • nuc7i7dnb
  • whl-ipc-i5
  • whl-ipc-i7

For More information, Please check Supported Hardware

ACRN SCENARIO Configuration

To build for your acrn scenario, set ACRN_SCENARIO in your conf/local.conf. By default it is set to industry scenario.

ACRN_SCENARIO  = "hybrid"

Supported scenarios:

  • sdc
  • logical_partition
  • industry
  • hybrid
  • hybrid_rt

For more information, please check Build With the ACRN Scenario

To customize ACRN Configruation, please check Introduction to ACRN Configuration

ACRN BUILD MODE Configuration

To build ACRN in RELEASE mode, set 1 to ACRN_RELEASE in your conf/local.conf. By default it is set to 0

ACRN_RELEASE = "1"

To build ACRN in DEBUG mode, set 0 to ACRN_RELEASE in your conf/local.conf.

ACRN_RELEASE = "0"

Kernel Configuration

There are multiple kernel variant available for both SOS and UOS.

SOS

To switch to linux-intel-acrn-sos LTS 5.4 kernel (default), in 'local.conf' replace with the following lines:

PREFERRED_PROVIDER_virtual/kernel = "linux-intel-acrn-sos"
PREFERRED_VERSION_linux-intel-acrn-sos = "5.4%"

UOS

To switch to linux-intel-acrn-uos LTS 5.4 kernel (default), in 'conf/multiconfig/uos.conf' replace with following lines:

PREFERRED_PROVIDER_virtual/kernel = "linux-intel-acrn-uos"
PREFERRED_VERSION_linux-intel-acrn-uos = "5.4%"

To switch to linux-intel-rt-acrn-uos Preempt-RT 5.4 kernel, in 'conf/multiconfig/uos.conf' replace with following line:

PREFERRED_PROVIDER_virtual/kernel = "linux-intel-rt-acrn-uos"
PREFERRED_VERSION_linux-intel-rt-acrn-uos = "5.4%"

GRUB Configuration

Following variables are used to prepare kernel command lines for Pre-launched User VMs and Service VM. Based on these variables an ACRN specific grub.cfg gets generated. These variables can be overwritten in your local config.

  • VMFLAGS - list of pre-launched VMs including Service VM For example: VMFLAGS = "vm0 vm1 ... vmx"

  • VM_APPEND - VM kernel commandline

  • KERNEL_IMAGE - kernel image like bzImage for each vm

  • KERNEL_MOD - kern_mod tag in acrn scenario xml for each

  • ACPI_TAG - ACPI tag for specific VM

  • ACPI_BIN - binary of ACPI tables for a specific vm

For example, using hybrid scenario for nuc7i7dnb:

 VMFLAGS = "vm0 vm1"
 # vm0 (prelaunch vm zephyr)
 VM_APPEND_vm0 = "xxx"
 KERNEL_IMAGE_vm0 = "zephyr.bin"
 KERNEL_MOD_vm0 = "Zephyr_RawImage"
 ACPI_TAG_vm0 = "ACPI_VM0"
 ACPI_BIN_vm0 = "ACPI_VM0.bin"

 # vm1 (sos)
 VM_APPEND_vm1 = "xxx"
 KERNEL_IMAGE_vm1 = "bzImage"
 KERNEL_MOD_vm1 = "Linux_bzImage"
  • ACRN_EFI_GRUB2_MOD_CFG wic variable (semicolon (;) separated list) to make additional entries in grub.cfg i.e insmod ext3

For more information, please check Update Ubuntu GRUB and acrn-bootconf.bbclass

Override distro configuration

Due to parsing sequence conflict with meta-intel, weak assignments are not used in acrn-demo-sos and acrn-demo-uos distros. So to override distro configuration in conf/local.conf, override syntax can be used i.e

WKS_FILE_acrn-demo-sos = "your-custom.wks.in"

Build WIC Installer Image

To install the image on to NUC, you could burn the .wic image to the target hardware's internal storage.

Alternatively, you could build a wic based installer image where you can burn the .wic image onto USB flash drive and use USB flash drive as installer. To build the installer image for ACRN, add the following lines to conf/local.conf:

BBMULTICONFIG:append  = " installer "

Add followings in conf/multiconfig/installer.conf:

# use the installer wks file
WKS_FILE:pn-acrn-image-base = "image-installer.wks.in"

# build initramsfs to start the installation
INITRD_IMAGE_LIVE="core-image-minimal-initramfs"

# make sure initramfs and ext4 image are ready before building wic image
do_image_wic[depends] += "${INITRD_IMAGE_LIVE}:do_image_complete"
IMAGE_TYPEDEP_wic = "ext4"

# content to be installed
IMAGE_BOOT_FILES:append = "\
    ${KERNEL_IMAGETYPE} \
    acrn.bin;esp/acrn.bin \
    microcode.cpio;esp/microcode.cpio \
    grub-efi-bootx64.efi;EFI/BOOT/bootx64.efi \
    ${IMAGE_ROOTFS}/boot/EFI/BOOT/grub.cfg;esp/EFI/BOOT/grub.cfg \
    ${IMGDEPLOYDIR}/${IMAGE_BASENAME}-${MACHINE}.ext4;rootfs.img \
"

Now build the installer image:

$ bitbake mc:installer:acrn-image-base

Currently ACRN WIC Installer is supported only OE-Core(poky) master, hardknott and gatesgarth. Support for dunfell is still in progress.

Tested Hardware

The following undergo regular basic testing with their respective MACHINE types.

intel-corei7-64: NUC7i7DNH

intel-skylake-64: NUC7i7DNH

Contributing

You are encouraged to follow Github Pull request workflow to share changes and following commit message guidelines are recommended OE patch guidelines

Layer Maintainer: Naveen Saini <naveen.kumar.saini@intel.com>