Skip to content

Commit

Permalink
boards: arm64: rpi_5: add rpi_5_xen_dom0 build target
Browse files Browse the repository at this point in the history
Add board rpi_5_xen_dom0 to build RPI5 with Xen Dom0 support:

  west build -b rpi_5_xen_dom0 -p always samples/hello_world/

Signed-off-by: Grygorii Strashko <[email protected]>
  • Loading branch information
Grygorii Strashko committed Apr 18, 2024
1 parent a821b6e commit 0fce7ee
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 1 deletion.
4 changes: 4 additions & 0 deletions boards/arm64/rpi_5/Kconfig.board
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
config BOARD_RPI_5
bool "Broadcom BCM2712"
depends on SOC_BCM2712

config BOARD_RPI_5_XEN_DOM0
bool "Broadcom BCM2712"
depends on SOC_BCM2712
15 changes: 14 additions & 1 deletion boards/arm64/rpi_5/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# Copyright 2023 honglin leng <[email protected]>
# SPDX-License-Identifier: Apache-2.0

if BOARD_RPI_5

config BOARD
default "Raspberry Pi 5"
depends on BOARD_RPI_5

endif # BOARD_RPI_5

if BOARD_RPI_5_XEN_DOM0

config BOARD
default "Raspberry Pi 5 Xen Dom0"

config XEN_DOM0
default y

endif # BOARD_RPI_5_XEN_DOM0
26 changes: 26 additions & 0 deletions boards/arm64/rpi_5/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,29 @@ When you power on the Raspberry Pi 5, you will see the following output in the s

.. _Raspberry Pi Debug Probe:
https://www.raspberrypi.com/products/debug-probe/

XEN Dom0
========

The Raspberry Pi 5 platform can be used to run as Xen Zephyr Dom0. For such purposes the additional
Raspberry Pi 5 platform is created named `rpi_5_xen_dom0`.

Run below command as an example of Zephyr build as Dom0:

.. code-block:: bash
west build -b rpi_5_xen_dom0 -p always samples/hello_world
It is expected to be used with special application performing Xen0 functions.

.. note::

The "hypervisor@x" and "memory@x" DT nodes may need to be updated depending on the Xen boot,
because normaly Xan will update DT for the target Kernel, but this is not possible in case
of Zephyr. See comments in `rpi_5_xen_dom0.dts`.

There is also option to use snippet `xen_dom0` for the same purposes:

.. code-block:: bash
west build -b rpi_5 -p always -S xen_dom0 samples/hello_worl
72 changes: 72 additions & 0 deletions boards/arm64/rpi_5/rpi_5_xen_dom0.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright 2024 Junho Lee <[email protected]>
*
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;

#include <broadcom/bcm2712.dtsi>
#include <mem.h>

/delete-node/ &sram0;

/ {
compatible = "raspberrypi,5-model-b-dom0", "raspberrypi,5-model-b", "brcm,bcm2712";
model = "Raspberry Pi 5 Xen Dom0";
#address-cells = <2>;
#size-cells = <2>;

chosen {
zephyr,sram = &sram0;
zephyr,console = &xen_consoleio_hvc;
zephyr,shell-uart = &xen_consoleio_hvc;
};

psci {
method = "hvc";
};

xen_consoleio_hvc: hvc {
compatible = "xen,hvc-consoleio";
status = "okay";
};

/*
* This node may differs on different setups, please check
* following line in Xen boot log to set it right:
* (XEN) Grant table range: 0x00000002800000-0x00000002840000
* Also, add extended region 0 or 1:
* (XEN) d0: extended region 0: 0x2a00000->0x7e00000
* (XEN) d0: extended region 1: 0x10000000->0x3fa00000
*
* Xen passes actual values for setup in domain device tree, but Zephyr
* is not capable to parse and handle it in runtime.
*
* Extended regions should not overlap kernel Virtual Memory region
* (CONFIG_KERNEL_VM_SIZE, CONFIG_KERNEL_VM_BASE)
*/
hypervisor: hypervisor@2800000 {
compatible = "xen,xen";
reg = <0x0 0x2800000 0x0 0x40000>, <0x0 0x2a00000 0x0 0x5400000>;
interrupts = <GIC_PPI 0x0 IRQ_TYPE_EDGE IRQ_DEFAULT_PRIORITY>;
interrupt-parent = <&gic>;
status = "okay";
};

/*
* This node may differs on different setups, because Xen picks
* region for Domain-0 for every specific configuration. You can
* start Xen for your platform and check following log:
* (XEN) Allocating 1:1 mappings totalling 128MB for dom0:
* (XEN) BANK[0] 0x00000008000000-0x00000010000000 (128MB)
* (XEN) Loading zImage from 0000000000080000 to 0000000008000000-000000000831f004
*
* Xen passes actual values for setup in domain device tree, but Zephyr
* is not capable to parse and handle it in runtime.
*/
sram0: memory@8000000 {
compatible = "mmio-sram";
reg = <0x00 0x8000000 0x0 DT_SIZE_M(128)>;
};
};
7 changes: 7 additions & 0 deletions boards/arm64/rpi_5/rpi_5_xen_dom0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
identifier: rpi_5_xen_dom0
name: Raspberry Pi 5 Xen Dom0
type: mcu
arch: arm64
toolchain:
- zephyr
- cross-compile
19 changes: 19 additions & 0 deletions boards/arm64/rpi_5/rpi_5_xen_dom0_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (C) 2024 EPAM Systems.
# SPDX-License-Identifier: Apache-2.0

CONFIG_SOC_BCM2712=y
CONFIG_BOARD_RPI_5_XEN_DOM0=y
CONFIG_ARM64_VA_BITS_40=y
CONFIG_ARM64_PA_BITS_40=y
CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y

# Enable serial console.
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_UART_INTERRUPT_DRIVEN=n

CONFIG_XEN_REGIONS=y
CONFIG_XEN_GRANT_TABLE=y
CONFIG_COMMON_LIBC_MALLOC=y
CONFIG_XEN_EVENTS=y

0 comments on commit 0fce7ee

Please sign in to comment.