diff options
author | Christopher Clark <christopher.w.clark@gmail.com> | 2020-06-29 18:54:49 -0700 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2020-07-06 16:25:56 -0400 |
commit | 90a01fcbd93d2efc94ca5d296e6a5d45fa9778ec (patch) | |
tree | ad8428f4f0ad629255fbe5d615a19e049e5275a5 | |
parent | 4c0e161157be1111c03367da82f690ec7cf6c9e2 (diff) | |
download | meta-virtualization-90a01fcbd93d2efc94ca5d296e6a5d45fa9778ec.tar.gz |
xen, raspberry pi: add dynamic-layer for Xen configuration for Rpi4
A Xen-specific u-boot script is needed for launching Xen, and the GIC
(interrupt controller) needs to be enabled.
Since this is both Xen-specific and Raspberry Pi-specific, use a
dynamic layer to conditionally enable the recipes when both
meta-virtualization and meta-raspberrypi are in use together.
Signed-off-by: Christopher Clark <christopher.w.clark@gmail.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
4 files changed, 87 insertions, 0 deletions
diff --git a/conf/layer.conf b/conf/layer.conf index 142621c3..1ec7a157 100644 --- a/conf/layer.conf +++ b/conf/layer.conf | |||
@@ -11,6 +11,21 @@ BBFILE_PRIORITY_virtualization-layer = "8" | |||
11 | # Custom licenses used by some packages in this layer | 11 | # Custom licenses used by some packages in this layer |
12 | LICENSE_PATH += "${LAYERDIR}/files/custom-licenses" | 12 | LICENSE_PATH += "${LAYERDIR}/files/custom-licenses" |
13 | 13 | ||
14 | # The dynamic-layers directory hosts extensions and layer-specific | ||
15 | # modifications. | ||
16 | # | ||
17 | # The .bbappend and .bb files are included if the respective layer | ||
18 | # collection is available. | ||
19 | BBFILES += "${@' '.join('${LAYERDIR}/dynamic-layers/%s/recipes*/*/*.bbappend' % layer \ | ||
20 | for layer in BBFILE_COLLECTIONS.split())}" | ||
21 | BBFILES += "${@' '.join('${LAYERDIR}/dynamic-layers/%s/recipes*/*/*.bb' % layer \ | ||
22 | for layer in BBFILE_COLLECTIONS.split())}" | ||
23 | |||
24 | BBFILES_DYNAMIC += " \ | ||
25 | raspberrypi:${LAYERDIR}/dynamic-layers/raspberrypi/*/*/*.bb \ | ||
26 | raspberrypi:${LAYERDIR}/dynamic-layers/rasbperrypi/*/*/*.bbappend \ | ||
27 | " | ||
28 | |||
14 | # This should only be incremented on significant changes that will | 29 | # This should only be incremented on significant changes that will |
15 | # cause compatibility issues with other layers | 30 | # cause compatibility issues with other layers |
16 | LAYERVERSION_virtualization-layer = "1" | 31 | LAYERVERSION_virtualization-layer = "1" |
diff --git a/dynamic-layers/raspberrypi/recipes-bsp/bootfiles/rpi-config_git.bbappend b/dynamic-layers/raspberrypi/recipes-bsp/bootfiles/rpi-config_git.bbappend new file mode 100644 index 00000000..2b9c4fbc --- /dev/null +++ b/dynamic-layers/raspberrypi/recipes-bsp/bootfiles/rpi-config_git.bbappend | |||
@@ -0,0 +1,6 @@ | |||
1 | do_deploy_append() { | ||
2 | # We need the GIC enabled for Xen to work. | ||
3 | if [ "${@bb.utils.contains('DISTRO_FEATURES', 'xen', 'yes', 'no', d)}" = "yes" ]; then | ||
4 | echo "enable_gic=1" >> ${DEPLOYDIR}/bcm2835-bootfiles/config.txt | ||
5 | fi | ||
6 | } | ||
diff --git a/dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/files/boot.cmd.xen.in b/dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/files/boot.cmd.xen.in new file mode 100644 index 00000000..6c38d7d7 --- /dev/null +++ b/dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/files/boot.cmd.xen.in | |||
@@ -0,0 +1,49 @@ | |||
1 | # Set the fdt address to what came from the GPU, so we can edit it | ||
2 | fdt addr ${fdt_addr} | ||
3 | |||
4 | # Pull the bootargs that the GPU has edited | ||
5 | fdt get value bootargs /chosen bootargs | ||
6 | |||
7 | # Set module load addresses | ||
8 | setenv xen_loadaddr "0x00200000" | ||
9 | setenv kernel_loadaddr "0x00400000" | ||
10 | |||
11 | # Add some space to the fdt so we can edit it | ||
12 | fdt resize 0x1000 | ||
13 | echo Add boot arguments for Xen | ||
14 | fdt set /chosen xen,xen-bootargs "console=dtuart dtuart=/soc/serial@7e215040 dom0_mem='@@RPI_DOM0_MEM@@' @@RPI_DEBUG_XEN_ARGS@@" | ||
15 | |||
16 | echo Add boot arguments for dom0 | ||
17 | setenv dom0_bootargs "console=hvc0 earlyprintk=xen debug root=/dev/mmcblk0p2 rootwait" | ||
18 | fdt set /chosen xen,dom0-bootargs \"${dom0_bootargs}\" | ||
19 | |||
20 | echo Add a dom0 node to chosen to put Linux boot information in | ||
21 | fdt mknode /chosen dom0 | ||
22 | |||
23 | echo Set this for the Linux boot command | ||
24 | fdt set /chosen/dom0 compatible "xen,linux-zimage", "xen,multiboot-module" | ||
25 | |||
26 | # Tell Xen where PCI is | ||
27 | fdt set /scb/pcie@7d500000 device_type "pci" | ||
28 | |||
29 | echo Delay to allow the MMC card to be ready | ||
30 | sleep 1 | ||
31 | |||
32 | echo Load Xen into memory | ||
33 | fatload mmc 0:1 ${xen_loadaddr} xen | ||
34 | echo Load Linux kernel into memory | ||
35 | fatload mmc 0:1 ${kernel_loadaddr} Image | ||
36 | setenv kernel_size 0x$filesize | ||
37 | |||
38 | echo Set the address and size for the Linux kernel so Xen can pick it up | ||
39 | fdt set /chosen/dom0 reg <${kernel_loadaddr} ${kernel_size}> | ||
40 | |||
41 | # Define the size and address cells | ||
42 | fdt set /chosen '#size-cells' <1> | ||
43 | fdt set /chosen '#address-cells' <1> | ||
44 | |||
45 | # Display the chosen fdt section - can be important for debugging | ||
46 | fdt print /chosen | ||
47 | |||
48 | echo Boot Xen | ||
49 | booti ${xen_loadaddr} - ${fdt_addr} | ||
diff --git a/dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bbappend b/dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bbappend new file mode 100644 index 00000000..2a511160 --- /dev/null +++ b/dynamic-layers/raspberrypi/recipes-bsp/rpi-u-boot-scr/rpi-u-boot-scr.bbappend | |||
@@ -0,0 +1,17 @@ | |||
1 | FILESEXTRAPATHS_prepend := "${THISDIR}/files:" | ||
2 | |||
3 | RPI_DOM0_MEM ??= "256M" | ||
4 | RPI_DEBUG_XEN_ARGS ??= "sync_console bootscrub=0" | ||
5 | |||
6 | SRC_URI += "file://boot.cmd.xen.in" | ||
7 | |||
8 | # If the distro is Xen enabled, override the default boot.cmd.in with the | ||
9 | # alternative boot.cmd.xen.in from this layer, with variables subsitution here | ||
10 | do_compile_append() { | ||
11 | if [ "${@bb.utils.contains('DISTRO_FEATURES', 'xen', 'yes', 'no', d)}" = "yes" ]; then | ||
12 | sed -e 's/@@RPI_DOM0_MEM@@/${RPI_DOM0_MEM}/' \ | ||
13 | -e 's/@@RPI_DEBUG_XEN_ARGS@@/${RPI_DEBUG_XEN_ARGS}/' \ | ||
14 | "${WORKDIR}/boot.cmd.xen.in" > "${WORKDIR}/boot.cmd" | ||
15 | mkimage -A arm -T script -C none -n "Boot script" -d "${WORKDIR}/boot.cmd" boot.scr | ||
16 | fi | ||
17 | } | ||