|
| 1 | +.. _acrn: |
| 2 | + |
| 3 | +ACRN UOS (User Operating System) |
| 4 | +################################# |
| 5 | + |
| 6 | +Overview |
| 7 | +******** |
| 8 | + |
| 9 | +This board configuration defines an ACRN User OS execution environment for |
| 10 | +running Zephyr RTOS applications. |
| 11 | + |
| 12 | +ACRN is a flexible, lightweight reference hypervisor, built with real-time |
| 13 | +and safety-criticality in mind, optimized to streamline embedded development |
| 14 | +through an open source platform. Check out the `Introduction to Project ACRN |
| 15 | +<https://projectacrn.github.io/latest/introduction/>`_ for more information. |
| 16 | + |
| 17 | +This baseline configuration can be used as a starting point for creating |
| 18 | +custom ACRN UOS configurations. It currently supports the following devices: |
| 19 | + |
| 20 | +* I/O APIC |
| 21 | +* local APIC timer |
| 22 | +* NS16550 UARTs |
| 23 | + |
| 24 | +Serial Ports |
| 25 | +------------ |
| 26 | + |
| 27 | +The serial ports are assumed present at traditional ``COM1:`` and ``COM2:`` |
| 28 | +I/O-space addresses (based at ``0x3f8`` and ``0x2f8``, respectively). Only |
| 29 | +polled operation is supported in this baseline configuration, as IRQ |
| 30 | +assignments under ACRN are configurable (and frequently non-standard). |
| 31 | +Interrupt-driven and MMIO operation are also possible. |
| 32 | + |
| 33 | +Building and Running |
| 34 | +******************** |
| 35 | + |
| 36 | +This details the process for building the :ref:`hello_world` sample and |
| 37 | +running it as an ACRN User OS. |
| 38 | + |
| 39 | +On the Zephyr Build System |
| 40 | +-------------------------- |
| 41 | + |
| 42 | +#. The build process for the ACRN UOS target is similar to other boards. We |
| 43 | +will build the :ref:`hello_world` sample for ACRN with: |
| 44 | + |
| 45 | + .. zephyr-app-commands:: |
| 46 | + :zephyr-app: samples/hello_world |
| 47 | + :board: acrn |
| 48 | + :goals: build |
| 49 | + :tool: all |
| 50 | + |
| 51 | + This will build the application ELF binary in |
| 52 | + ``samples/hello_world/build/zephyr/zephyr.elf``. |
| 53 | + |
| 54 | +#. Build GRUB2 boot loader image |
| 55 | + |
| 56 | + We can build the GRUB2 bootloader for Zephyr using |
| 57 | + ``boards/x86/common/scripts/build_grub.sh``: |
| 58 | + |
| 59 | + .. code-block:: none |
| 60 | +
|
| 61 | + $ ./boards/x86/common/scripts/build_grub.sh x86_64 |
| 62 | +
|
| 63 | + The EFI executable will be found at |
| 64 | + ``boards/x86/common/scripts/grub/bin/grub_x86_64.efi``. |
| 65 | + |
| 66 | +#. Preparing the boot device |
| 67 | + |
| 68 | + .. code-block:: none |
| 69 | +
|
| 70 | + $ dd if=/dev/zero of=zephyr.img bs=1M count=35 |
| 71 | + $ mkfs.vfat -F 32 zephyr.img |
| 72 | + $ LOOP_DEV=`sudo losetup -f -P --show zephyr.img` |
| 73 | + $ sudo mount $LOOP_DEV /mnt |
| 74 | + $ sudo mkdir -p /mnt/efi/boot |
| 75 | + $ sudo cp boards/x86/common/scripts/grub/bin/grub_x86_64.efi /mnt/efi/boot/bootx64.efi |
| 76 | + $ sudo mkdir -p /mnt/kernel |
| 77 | + $ sudo cp samples/hello_world/build/zephyr/zephyr.elf /mnt/kernel |
| 78 | +
|
| 79 | + Create ``/mnt/efi/boot/grub.cfg`` containing the following: |
| 80 | + |
| 81 | + .. code-block:: console |
| 82 | +
|
| 83 | + set default=0 |
| 84 | + set timeout=10 |
| 85 | +
|
| 86 | + menuentry "Zephyr Kernel" { |
| 87 | + multiboot /kernel/zephyr.elf |
| 88 | + } |
| 89 | +
|
| 90 | + And then unmount the image file: |
| 91 | + |
| 92 | + .. code-block:: console |
| 93 | +
|
| 94 | + $ sudo umount /mnt |
| 95 | +
|
| 96 | + You now have a virtual disk image with a bootable Zephyr in ``zephyr.img``. |
| 97 | + If the Zephyr build system is not the ACRN SOS, then you will need to |
| 98 | + transfer this image to the ACRN SOS (via, e.g., a USB stick or network). |
| 99 | + |
| 100 | +On the ACRN SOS |
| 101 | +--------------- |
| 102 | + |
| 103 | +#. If you are not already using the ACRN SOS, follow `Getting started guide |
| 104 | + for Intel NUC |
| 105 | + <https://projectacrn.github.io/latest/getting-started/apl-nuc.html>`_ to |
| 106 | + install and boot "The ACRN Service OS". |
| 107 | + |
| 108 | +#. Boot Zephyr as User OS |
| 109 | + |
| 110 | + On the ACRN SOS, prepare a directory and populate it with Zephyr files. |
| 111 | + |
| 112 | + .. code-block:: none |
| 113 | +
|
| 114 | + $ mkdir zephyr |
| 115 | + $ cd zephyr |
| 116 | + $ cp /usr/share/acrn/samples/nuc/launch_zephyr.sh . |
| 117 | + $ cp /usr/share/acrn/bios/OVMF.fd . |
| 118 | +
|
| 119 | + You will also need to copy the ``zephyr.img`` created in the first |
| 120 | + section into this directory. Then run ``launch_zephyr.sh`` script |
| 121 | + to launch the Zephyr as a UOS. |
| 122 | + |
| 123 | + .. code-block:: none |
| 124 | +
|
| 125 | + $ sudo ./launch_zephyr.sh |
| 126 | +
|
| 127 | + Then Zephyr will boot up automatically. You will see the banner: |
| 128 | + |
| 129 | + .. code-block:: console |
| 130 | +
|
| 131 | + Hello World! acrn |
| 132 | +
|
| 133 | + Which indicates that Zephyr is running successfully under ACRN! |
0 commit comments