Skip to content

Commit 27a56ad

Browse files
Charles E. Yousenashif
authored andcommitted
boards/x86: add ACRN UOS sample board configuration
Based on prior work by @dcpleung. It's suboptimal, but it provides a working starting point for ACRN work. The x86 board/SoC abstractions really need to be refactored to make this "board" (and other x86-based "boards", both extant and future) cleaner and easier to maintain. Punt. Signed-off-by: Charles E. Youse <[email protected]>
1 parent 91eb147 commit 27a56ad

File tree

6 files changed

+228
-0
lines changed

6 files changed

+228
-0
lines changed

boards/x86/acrn/Kconfig.board

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# Copyright (c) 2019 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
config BOARD_ACRN
8+
bool "ACRN User OS"
9+
depends on SOC_IA32
10+
select HAS_DTS
11+
select CPU_HAS_FPU if !X86_IAMCU
12+
select SET_GDT

boards/x86/acrn/Kconfig.defconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# Copyright (c) 2019 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
if BOARD_ACRN
8+
9+
config BOARD
10+
default "acrn"
11+
12+
endif # BOARD_ACRN

boards/x86/acrn/acrn.dts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) 2019 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/dts-v1/;
8+
9+
#include <mem.h>
10+
11+
#define DT_FLASH_SIZE DT_SIZE_K(8192)
12+
#define DT_SRAM_SIZE DT_SIZE_K(8192)
13+
14+
#include <ia32.dtsi>
15+
16+
/ {
17+
model = "ACRN";
18+
compatible = "intel,ia32";
19+
20+
aliases {
21+
uart-0 = &uart0;
22+
uart-1 = &uart1;
23+
};
24+
25+
chosen {
26+
zephyr,sram = &sram0;
27+
zephyr,flash = &flash0;
28+
zephyr,console = &uart0;
29+
zephyr,shell-uart = &uart0;
30+
};
31+
};
32+
33+
&uart0 {
34+
status = "ok";
35+
current-speed = <115200>;
36+
};
37+
38+
&uart1 {
39+
status = "ok";
40+
current-speed = <115200>;
41+
};
42+
43+
&flash0 {
44+
reg = <0x100000 DT_FLASH_SIZE>;
45+
};
46+
47+
&sram0 {
48+
reg = <0x400000 DT_SRAM_SIZE>;
49+
};

boards/x86/acrn/acrn.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
identifier: acrn
2+
name: ACRN
3+
type: mcu
4+
arch: x86
5+
toolchain:
6+
- zephyr
7+
ram: 8192
8+
flash: 8192

boards/x86/acrn/acrn_defconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CONFIG_SOC_IA32=y
2+
CONFIG_BOARD_ACRN=y
3+
CONFIG_IA32_LEGACY_IO_PORTS=y
4+
CONFIG_PIC_DISABLE=y
5+
CONFIG_LOAPIC=y
6+
CONFIG_LOAPIC_TIMER=y
7+
CONFIG_CONSOLE=y
8+
CONFIG_SERIAL=y
9+
CONFIG_UART_NS16550=y
10+
CONFIG_UART_CONSOLE=y
11+
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=25000000
12+
CONFIG_XIP=n
13+
CONFIG_BUILD_OUTPUT_BIN=y
14+
CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN=n

boards/x86/acrn/doc/index.rst

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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

Comments
 (0)