acrn-hypervisor/doc/tutorials/using_zephyr_as_uos.rst
David B. Kinder 54975e4629 doc: remove docs referencing Clear Linux
ACRN 2.1 supports two virtual boot modes, deprivilege boot mode and
direct boot mode. The deprivilege boot mode’s main purpose is to support
booting Clear Linux Service VM with UEFI service support, but this
brings scalability problems when porting ACRN to new Intel platforms.
For the 2.2 release, deprivilege mode is removed, and only direct boot
is supported, and with this we've removed support for Clear Linux as the
service VM, which impacts over 50 ACRN documents.  This PR removes
documents we don't intend to update, and fixes broken links that would
occur from references to these deleted docs.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2020-09-01 11:46:41 -07:00

122 lines
3.7 KiB
ReStructuredText

.. _using_zephyr_as_uos:
Run Zephyr as the User VM
#########################
This tutorial describes how to run Zephyr as the User VM on the ACRN hypervisor. We are using
Kaby Lake-based NUC (model NUC7i5DNHE) in this tutorial.
Other :ref:`ACRN supported platforms <hardware>` should work as well.
.. note::
This tutorial uses the (default) SDC scenario. If you use a different
scenario, you will need a serial port connection to your platform to see
Zephyr console output.
Introduction to Zephyr
**********************
The Zephyr RTOS is a scalable real-time operating-system supporting multiple hardware architectures,
optimized for resource constrained devices, and built with safety and security in mind.
Steps for Using Zephyr as User VM
*********************************
#. Build Zephyr
Follow the `Zephyr Getting Started Guide <https://docs.zephyrproject.org/latest/getting_started/>`_ to
setup the Zephyr development environment.
The build process for ACRN User VM target is similar to other boards. We will build the `Hello World
<https://docs.zephyrproject.org/latest/samples/hello_world/README.html>`_ sample for ACRN:
.. code-block:: none
$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=acrn ..
$ make
This will build the application ELF binary in ``samples/hello_world/build/zephyr/zephyr.elf``.
#. Build grub2 boot loader image
We can build grub2 bootloader for Zephyr using ``boards/x86/common/scripts/build_grub.sh``
which locate in `Zephyr Sourcecode <https://github.com/zephyrproject-rtos/zephyr>`_.
.. code-block:: none
$ ./boards/x86/common/scripts/build_grub.sh x86_64
The EFI executable binary will be found at ``boards/x86/common/scripts/grub/bin/grub_x86_64.efi``.
#. Preparing the boot device
.. code-block:: none
$ dd if=/dev/zero of=zephyr.img bs=1M count=35
$ mkfs.vfat -F 32 zephyr.img
$ sudo mount `sudo losetup -f -P --show zephyr.img` /mnt
Create the following directories.
.. code-block:: none
$ sudo mkdir -p /mnt/efi/boot
$ sudo mkdir -p /mnt/kernel
Copy ``zephyr.elf`` and ``grub_x86_64.efi``
.. code-block:: none
$ sudo cp boards/x86/common/scripts/grub/bin/grub_x86_64.efi /mnt/efi/boot/bootx64.efi
$ sudo cp samples/hello_world/build/zephyr/zephyr.elf /mnt/kernel
Create ``/mnt/efi/boot/grub.cfg`` containing the following:
.. code-block:: console
set default=0
set timeout=10
menuentry "Zephyr Kernel" {
multiboot /kernel/zephyr.elf
}
Unmount the loopback device:
.. code-block:: none
$ sudo umount /mnt
You now have a virtual disk image with a bootable Zephyr in ``zephyr.img``. If the Zephyr build system is not
the ACRN Service VM, then you will need to transfer this image to the ACRN Service VM (via, e.g, a USB stick or network )
#. Follow XXX to boot "The ACRN Service OS" based on Clear Linux OS 28620
(ACRN tag: acrn-2019w14.3-140000p)
.. important:: need to remove reference to Clear Linux and reference
to deleted document (use SDC mode on the NUC)
#. Boot Zephyr as User VM
On the ACRN Service VM, prepare a directory and populate it with Zephyr files.
.. code-block:: none
$ mkdir zephyr && cd zephyr
$ cp /usr/share/acrn/samples/nuc/launch_zephyr.sh .
You will also need to copy the ``zephyr.img`` created in the above section into directory ``zephyr``.
Run the ``launch_zephyr.sh`` script to launch Zephyr as User VM.
.. code-block:: none
$ sudo ./launch_zephyr.sh
Then Zephyr will boot automatically. You will see a console message from the hello_world sample application:
.. code-block:: console
Hello World! acrn