aboutsummaryrefslogtreecommitdiffstats
path: root/meta-agl-bsp/meta-raspberrypi
diff options
context:
space:
mode:
authorLeonid Lazarev <leonid.lazarev@mera.com>2020-05-15 11:51:48 +0300
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2020-05-26 17:12:19 +0000
commit4028c726be78adc1f1df3708dbe99f9eb2303790 (patch)
treea612c618ec8689bd785e816582116c4cf81cc681 /meta-agl-bsp/meta-raspberrypi
parent30063de420b4f6c993dd3f2021ab84f622d69320 (diff)
Raspberry 4: XEN support
Added the support for DOM0 in raspberry pi4. The feature agl-virt-xen should be enabled to activate this code. 1512 MB of memory is used for DOM0 machine. There are limitations: - brcmfmac module disabled (bluethooth and Wifi) due to the crash - total_memory is set to the 3Gb, as it impacts the USB ports on rasbperry pi4 on Linux kernel 4.19 v2 (jsmoeller): make changes in virtualization-layer conditional to raspberrypi4 Bug-AGL: SPEC-3259 Change-Id: I873fbf1f5498e31ae5f468407502f16e1873f7fc Signed-off-by: Leonid Lazarev <leonid.lazarev@mera.com> Signed-off-by: Jan-Simon Möller <jsmoeller@linuxfoundation.org> Reviewed-on: https://gerrit.automotivelinux.org/gerrit/c/AGL/meta-agl/+/24522 Tested-by: Jenkins Job builder account <agl-jobbuilder@automotivelinux.org> ci-image-build: Jenkins Job builder account <agl-jobbuilder@automotivelinux.org> ci-image-boot-test: Jenkins Job builder account <agl-jobbuilder@automotivelinux.org>
Diffstat (limited to 'meta-agl-bsp/meta-raspberrypi')
-rw-r--r--meta-agl-bsp/meta-raspberrypi/recipes-bsp/bootfiles/rpi-config_git.bbappend5
-rw-r--r--meta-agl-bsp/meta-raspberrypi/recipes-bsp/rpi-u-boot-scr/files/boot_xen.cmd45
-rw-r--r--meta-agl-bsp/meta-raspberrypi/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bbappend18
-rw-r--r--meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/files/0002-Disable-DMA-in-sdhci-driver.patch25
-rw-r--r--meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/files/0003-Fix-PCIe-in-dom0-for-RPi4.patch31
-rw-r--r--meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/files/xen-be.cfg50
-rw-r--r--meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/linux-raspberrypi_%.bbappend10
-rw-r--r--meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/linux-raspberrypi_4.19.bbappend16
8 files changed, 200 insertions, 0 deletions
diff --git a/meta-agl-bsp/meta-raspberrypi/recipes-bsp/bootfiles/rpi-config_git.bbappend b/meta-agl-bsp/meta-raspberrypi/recipes-bsp/bootfiles/rpi-config_git.bbappend
index 5eecff6f1..9891fa200 100644
--- a/meta-agl-bsp/meta-raspberrypi/recipes-bsp/bootfiles/rpi-config_git.bbappend
+++ b/meta-agl-bsp/meta-raspberrypi/recipes-bsp/bootfiles/rpi-config_git.bbappend
@@ -1,4 +1,5 @@
DISABLE_OVERSCAN = "1"
+TOTAL_BOARD_MEM = "3072"
do_deploy_append_raspberrypi4() {
# ENABLE CAN
@@ -17,6 +18,10 @@ do_deploy_append_raspberrypi4() {
;;
esac
fi
+
+ if [ "${AGL_XEN_WANTED}" = "1" ]; then
+ echo "total_mem=${TOTAL_BOARD_MEM}" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt
+ fi
}
do_deploy_append() {
diff --git a/meta-agl-bsp/meta-raspberrypi/recipes-bsp/rpi-u-boot-scr/files/boot_xen.cmd b/meta-agl-bsp/meta-raspberrypi/recipes-bsp/rpi-u-boot-scr/files/boot_xen.cmd
new file mode 100644
index 000000000..24cfb1658
--- /dev/null
+++ b/meta-agl-bsp/meta-raspberrypi/recipes-bsp/rpi-u-boot-scr/files/boot_xen.cmd
@@ -0,0 +1,45 @@
+#
+# SPDX-License-Identifier: MIT
+#
+# Copyright (c) 2020, MERA
+#
+# Author: Leonid Lazarev
+#
+# Xen Boot Script
+#
+# https://www.raspberrypi.org/documentation/configuration/device-tree.md
+# We do not set fdt_addr, because device tree initially is loaded by raspberry pi firmware loader and the particular
+# modification are performed. The prepared DTS is propagated to u-boot and this prepared device tree has to be reused.
+
+setenv kernel_addr_r 0x00480000 # 16M
+setenv xen_addr_r 0x00200000 # 2M
+
+# Load xen to ${xen_addr_r}.
+fatload mmc 0:1 ${xen_addr_r} /xen-@@MACHINE@@
+
+#configure dom0
+fdt addr ${fdt_addr}
+
+#read prepared bootargs, rapsberry pi prepared initial list of the parameters for loading
+fdt get value bootargs /chosen bootargs
+fdt resize 8192
+
+# add device type for raspberry
+fdt set pcie0 device_type "pci"
+
+fdt chosen
+fdt set /chosen \#address-cells <1>
+fdt set /chosen \#size-cells <1>
+
+# Load Linux Image to ${kernel_addr_r}
+fatload mmc 0:1 ${kernel_addr_r} /@@KERNEL_IMAGETYPE@@
+
+# we load dom0 with 1512 MB of memory
+fdt mknod /chosen dom0
+fdt set /chosen xen,xen-bootargs "console=dtuart dtuart=/soc/serial@7e215040 sync_console dom0_mem=1512M bootscrub=0"
+fdt set /chosen xen,dom0-bootargs "${bootargs}"
+
+fdt set /chosen/dom0 compatible "xen,linux-zimage", "xen,multiboot-module"
+fdt set /chosen/dom0 reg <${kernel_addr_r} 0x${filesize} >
+
+@@KERNEL_BOOTCMD@@ ${xen_addr_r} - ${fdt_addr}
diff --git a/meta-agl-bsp/meta-raspberrypi/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bbappend b/meta-agl-bsp/meta-raspberrypi/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bbappend
new file mode 100644
index 000000000..2437d9a84
--- /dev/null
+++ b/meta-agl-bsp/meta-raspberrypi/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bbappend
@@ -0,0 +1,18 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
+
+SRC_URI_append =" \
+ ${@bb.utils.contains('AGL_XEN_WANTED','1',' file://boot_xen.cmd','',d)} \
+"
+
+do_compile_append() {
+
+ # if xen feature is activated we overwirte the boot script with xen specific one
+ if [ "${AGL_XEN_WANTED}" = "1" ]; then
+ sed -e 's/@@KERNEL_IMAGETYPE@@/${KERNEL_IMAGETYPE}/' \
+ -e 's/@@KERNEL_BOOTCMD@@/${KERNEL_BOOTCMD}/' \
+ -e 's/@@MACHINE@@/${MACHINE}/' \
+ "${WORKDIR}/boot_xen.cmd" > "${WORKDIR}/boot.cmd"
+
+ mkimage -A arm -T script -C none -n "Boot script" -d "${WORKDIR}/boot.cmd" boot.scr
+ fi
+} \ No newline at end of file
diff --git a/meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/files/0002-Disable-DMA-in-sdhci-driver.patch b/meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/files/0002-Disable-DMA-in-sdhci-driver.patch
new file mode 100644
index 000000000..04a8733f2
--- /dev/null
+++ b/meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/files/0002-Disable-DMA-in-sdhci-driver.patch
@@ -0,0 +1,25 @@
+From 758bc9b917469bc4e527dc3aae821c91cbc3d426 Mon Sep 17 00:00:00 2001
+From: Stewart Hildebrand <stewart.hildebrand@dornerworks.com>
+Date: Thu, 18 Jul 2019 00:01:27 -0400
+Subject: [PATCH 2/4] Disable DMA in sdhci driver
+
+---
+ drivers/mmc/host/sdhci-iproc.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/mmc/host/sdhci-iproc.c b/drivers/mmc/host/sdhci-iproc.c
+index 983cddce9..150f7bfc8 100644
+--- a/drivers/mmc/host/sdhci-iproc.c
++++ b/drivers/mmc/host/sdhci-iproc.c
+@@ -252,6 +252,8 @@ static const struct sdhci_iproc_data bcm2835_data = {
+
+ static const struct sdhci_pltfm_data sdhci_bcm2838_pltfm_data = {
+ .ops = &sdhci_iproc_32only_ops,
++ .quirks = SDHCI_QUIRK_BROKEN_DMA |
++ SDHCI_QUIRK_BROKEN_ADMA,
+ };
+
+ static const struct sdhci_iproc_data bcm2838_data = {
+--
+2.17.1
+
diff --git a/meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/files/0003-Fix-PCIe-in-dom0-for-RPi4.patch b/meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/files/0003-Fix-PCIe-in-dom0-for-RPi4.patch
new file mode 100644
index 000000000..835f36da3
--- /dev/null
+++ b/meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/files/0003-Fix-PCIe-in-dom0-for-RPi4.patch
@@ -0,0 +1,31 @@
+From 77765c2a47ce43911b8fe7b09f037c9bc13008ca Mon Sep 17 00:00:00 2001
+From: Jeff Kubascik <jeff.kubascik@dornerworks.com>
+Date: Tue, 30 Jul 2019 08:49:56 -0400
+Subject: [PATCH 3/4] Fix PCIe in dom0 for RPi4
+
+There is an issue where the Broadcom PCIe driver and Xen swiotlb layer
+invoke each other's dma alloc function recursively until the stack blows
+up. The cause appears to be due to arch_setup_dma_ops being called
+more than once for the device, possibly through of_dma_configure, and
+screwing up the dma_ops pointers. This patch adds a check to make sure
+that the xen_dma_ops are applied only once for a device.
+---
+ arch/arm64/mm/dma-mapping.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
+index d3a5bb16f..243a3b9be 100644
+--- a/arch/arm64/mm/dma-mapping.c
++++ b/arch/arm64/mm/dma-mapping.c
+@@ -895,7 +895,7 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
+ __iommu_setup_dma_ops(dev, dma_base, size, iommu);
+
+ #ifdef CONFIG_XEN
+- if (xen_initial_domain()) {
++ if (!dev->archdata.dev_dma_ops && xen_initial_domain()) {
+ dev->archdata.dev_dma_ops = dev->dma_ops;
+ dev->dma_ops = xen_dma_ops;
+ }
+--
+2.17.1
+
diff --git a/meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/files/xen-be.cfg b/meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/files/xen-be.cfg
new file mode 100644
index 000000000..36f390187
--- /dev/null
+++ b/meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/files/xen-be.cfg
@@ -0,0 +1,50 @@
+# global stuff - these enable us to allow some
+# of the not so generic stuff below for xen
+CONFIG_PARAVIRT=y
+CONFIG_NET=y
+CONFIG_NET_CORE=y
+CONFIG_NETDEVICES=y
+CONFIG_BLOCK=y
+CONFIG_WATCHDOG=y
+CONFIG_TARGET_CORE=y
+CONFIG_SCSI=y
+CONFIG_FB=y
+CONFIG_INPUT_MISC=y
+CONFIG_MEMORY_HOTPLUG=y
+CONFIG_TTY=y
+# Technically not required but otherwise produces
+# pretty useless systems starting from allnoconfig
+# You want TCP/IP and ELF binaries right?
+CONFIG_INET=y
+CONFIG_BINFMT_ELF=y
+# generic config
+CONFIG_XEN=y
+CONFIG_XEN_DOM0=y
+# backend drivers
+CONFIG_XEN_BACKEND=y
+CONFIG_XEN_BLKDEV_BACKEND=m
+CONFIG_XEN_NETDEV_BACKEND=m
+CONFIG_HVC_XEN=y
+CONFIG_XEN_WDT=m
+CONFIG_XEN_SCSI_BACKEND=m
+# frontend drivers
+CONFIG_XEN_FBDEV_FRONTEND=m
+CONFIG_HVC_XEN_FRONTEND=y
+CONFIG_INPUT_XEN_KBDDEV_FRONTEND=m
+CONFIG_XEN_SCSI_FRONTEND=m
+# others
+CONFIG_XEN_BALLOON=y
+CONFIG_XEN_SCRUB_PAGES=y
+CONFIG_XEN_DEV_EVTCHN=m
+CONFIG_XEN_BLKDEV_FRONTEND=m
+CONFIG_XEN_NETDEV_FRONTEND=m
+CONFIG_XENFS=m
+CONFIG_XEN_COMPAT_XENFS=y
+CONFIG_XEN_SYS_HYPERVISOR=y
+CONFIG_XEN_XENBUS_FRONTEND=y
+CONFIG_XEN_GNTDEV=m
+CONFIG_XEN_GRANT_DEV_ALLOC=m
+CONFIG_SWIOTLB_XEN=y
+CONFIG_XEN_PRIVCMD=m
+CONFIG_DEBUG_INFO=y
+CONFIG_FRAME_POINTER=y
diff --git a/meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/linux-raspberrypi_%.bbappend b/meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/linux-raspberrypi_%.bbappend
index ff17b2532..f78e0b5eb 100644
--- a/meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/linux-raspberrypi_%.bbappend
+++ b/meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/linux-raspberrypi_%.bbappend
@@ -5,8 +5,18 @@ require recipes-kernel/linux/linux-agl.inc
SRC_URI_append = "\
${@oe.utils.conditional('USE_FAYTECH_MONITOR', '1', 'file://0002-faytech-fix-rpi.patch', '', d)} \
"
+#take in account that linux under xen should use the hvc0 console
+SERIAL_OPTION = "${@bb.utils.contains('AGL_XEN_WANTED','1','hvc0','115200;ttyS0',d)}"
+SERIAL = "${@oe.utils.conditional("ENABLE_UART", "1", "console=${SERIAL_OPTION}", "", d)}"
CMDLINE_DEBUG = ""
+
+#XEN related option
+CMDLINE_append = ' ${@bb.utils.contains('AGL_XEN_WANTED','1','clk_ignore_unused','',d)}'
+
+#workaround for crash during brcmfmac loading. Disable it at this moment
+CMDLINE_append = ' ${@bb.utils.contains('AGL_XEN_WANTED','1','modprobe.blacklist=brcmfmac','',d)}'
+
CMDLINE_append = " usbhid.mousepoll=0"
# Add options to allow CMA to operate
diff --git a/meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/linux-raspberrypi_4.19.bbappend b/meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/linux-raspberrypi_4.19.bbappend
index 782d61597..7f17f0c3f 100644
--- a/meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/linux-raspberrypi_4.19.bbappend
+++ b/meta-agl-bsp/meta-raspberrypi/recipes-kernel/linux/linux-raspberrypi_4.19.bbappend
@@ -2,3 +2,19 @@ require recipes-kernel/linux/linux-agl-4.19.inc
ENABLE_UART_raspberrypi4 = "1"
+FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
+
+
+# For Xen
+
+SRC_URI_append =" \
+ ${@bb.utils.contains('AGL_XEN_WANTED','1','file://0002-Disable-DMA-in-sdhci-driver.patch','',d)} \
+"
+
+SRC_URI_append =" \
+ ${@bb.utils.contains('AGL_XEN_WANTED','1','file://0003-Fix-PCIe-in-dom0-for-RPi4.patch','',d)} \
+"
+
+SRC_URI_append = " \
+ ${@bb.utils.contains('AGL_XEN_WANTED','1','file://xen-be.cfg','',d)} \
+"