[meta-arm,2/2] arm-autonomy/wic: Deploy Xen related artefacts in the wic boot partition

Submitted by Diego Sueiro on Oct. 1, 2020, 4:07 p.m. | Patch ID: 176931

Details

Message ID 2722b0a055731bd2367ea9f8881ba986e88084db.1601568289.git.diego.sueiro@arm.com
State New
Headers show

Commit Message

Diego Sueiro Oct. 1, 2020, 4:07 p.m.
This patch brings the following changes:
* Documentation about how to customize the wic image for N1SDP
* Introduce a custom wks and grub.cfg file for N1SP when building with
  `DISTRO_FEATURES += "arm-autonomy-host"` to include Xen artefacts and boot
  option.
* Introduce a mechanism to include extra global settings for machines defined
  in meta-arm-bsp when building with `DISTRO_FEATURES += "arm-autonomy-host"`.

Change-Id: Ic9f36bae3bf04df1ee6a6c543e812f27c5c537a0
Issue-Id: SCM-1065
Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
---
 .../conf/distro/include/arm-autonomy-host.inc      | 11 +++++++
 meta-arm-autonomy/conf/layer.conf                  |  5 ++-
 .../documentation/n1sdp-image-customization.md     | 29 +++++++++++++++++
 .../arm-autonomy-machine-extra-settings.inc        |  5 +++
 .../conf/machine/n1sdp-extra-settings.inc          | 36 ++++++++++++++++++++++
 .../xen-devicetree/xen-devicetree.bbappend         |  4 +--
 .../wic/arm-autonomy-n1sdp-efidisk.wks.in          | 14 +++++++++
 .../meta-arm-bsp/wic/arm-autonomy-n1sdp-grub.cfg   | 28 +++++++++++++++++
 8 files changed, 129 insertions(+), 3 deletions(-)
 create mode 100644 meta-arm-autonomy/documentation/n1sdp-image-customization.md
 create mode 100644 meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/arm-autonomy-machine-extra-settings.inc
 create mode 100644 meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/n1sdp-extra-settings.inc
 create mode 100644 meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic/arm-autonomy-n1sdp-efidisk.wks.in
 create mode 100644 meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic/arm-autonomy-n1sdp-grub.cfg

Patch hide | download patch | download mbox

diff --git a/meta-arm-autonomy/conf/distro/include/arm-autonomy-host.inc b/meta-arm-autonomy/conf/distro/include/arm-autonomy-host.inc
index fcebd2d..822677d 100644
--- a/meta-arm-autonomy/conf/distro/include/arm-autonomy-host.inc
+++ b/meta-arm-autonomy/conf/distro/include/arm-autonomy-host.inc
@@ -12,3 +12,14 @@  RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= ""
 # Until we don't move to use the kea dhcp-server we build dhcp_4.4.2.bb recipe
 # which depends on bind_9.11.22.bb recipe.
 PREFERRED_VERSION_bind ?= "9.11%"
+
+# Require extra machine specific settings from meta-arm-bsp dynamic-layers only
+# if meta-arm-bsp is in the bblayers.conf
+# Directory for meta-arm-autonomy/dynamic-layers/meta-arm-bsp machine extra settings
+ARM_AUTONOMY_ARM_BSP_DYNAMIC_EXTRA_CFGDIR = "${ARM_AUTONOMY_ARM_BSP_DYNAMIC_DIR}/conf/machine"
+ARM_AUTONOMY_MACHINE_EXTRA_REQUIRE ?= \
+"${ARM_AUTONOMY_ARM_BSP_DYNAMIC_EXTRA_CFGDIR}/arm-autonomy-machine-extra-settings.inc"
+
+require ${@bb.utils.contains('BBFILE_COLLECTIONS', 'meta-arm-bsp', \
+                             '${ARM_AUTONOMY_MACHINE_EXTRA_REQUIRE}' , \
+                             '', d)}
diff --git a/meta-arm-autonomy/conf/layer.conf b/meta-arm-autonomy/conf/layer.conf
index 2b9e94d..5a439e2 100644
--- a/meta-arm-autonomy/conf/layer.conf
+++ b/meta-arm-autonomy/conf/layer.conf
@@ -23,8 +23,9 @@  LAYERSERIES_COMPAT_meta-arm-autonomy = "dunfell gatesgarth"
 # otherwise the user will see a warning on each build.
 SKIP_META_VIRT_SANITY_CHECK = "1"
 
+ARM_AUTONOMY_LAYERDIR := "${LAYERDIR}"
 # Directory of our distro config files
-ARM_AUTONOMY_DISTRO_CFGDIR = "${LAYERDIR}/conf/distro/include/"
+ARM_AUTONOMY_DISTRO_CFGDIR = "${ARM_AUTONOMY_LAYERDIR}/conf/distro/include/"
 
 # Add class to handle arm-autonomy distro extensions
 USER_CLASSES_append = " arm-autonomy-features"
@@ -33,3 +34,5 @@  BBFILES_DYNAMIC += " \
     meta-arm-bsp:${LAYERDIR}/dynamic-layers/meta-arm-bsp/*/*/*.bbappend \
     meta-gem5:${LAYERDIR}/dynamic-layers/meta-gem5/*/*/*.bbappend \
 "
+# Root directory for the meta-arm-autonomy/dynamic-layers/meta-arm-bsp
+ARM_AUTONOMY_ARM_BSP_DYNAMIC_DIR = "${ARM_AUTONOMY_LAYERDIR}/dynamic-layers/meta-arm-bsp"
diff --git a/meta-arm-autonomy/documentation/n1sdp-image-customization.md b/meta-arm-autonomy/documentation/n1sdp-image-customization.md
new file mode 100644
index 0000000..9e4186c
--- /dev/null
+++ b/meta-arm-autonomy/documentation/n1sdp-image-customization.md
@@ -0,0 +1,29 @@ 
+Customizing Arm Autonomy Host image layout for N1SDP
+====================================================
+
+When buiding with `DISTRO_FEATURES += "arm-autonomy-host"` the user can
+perform a couple of customizations in the generated wic image:
+
+1. Set the guest partition size (default: 4iG) via `GUEST_PART_SIZE` and
+   `GUEST_PART_SIZE_UNIT` (M or G) variables to be set in any conf file. The
+   value of these variables should be aligned with the sum of all
+   XENGUEST_IMAGE_DISK_SIZE set for the guests. By default, LVM2 metadata is
+   1 MiB per physical volume, hence it needs to be taken into account when
+   setting GUEST_PART_SIZE.
+
+2. The wic image partition layout and contents with a custom wks file via
+   `ARM_AUTONOMY_WKS_FILE` variable (default:
+   arm-autonomy-n1sdp-efidisk.wks.in which is affected by GUEST_PART_SIZE,
+   GUEST_PART_SIZE_UNIT and GRUB_CFG_FILE variables).
+
+3. Custom grub.cfg file via `GRUB_CFG_FILE` (default:
+   arm-autonomy-n1sdp-grub.cfg) variable to be set in any conf file. The full
+   path or relative to `ARM_AUTONOMY_WKS_FILE` should be set.
+
+The `arm-autonomy-n1sdp-efidisk.wks.in` and `arm-autonomy-n1sdp-grub.cfg` files
+are located at `meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic`.
+
+Other variables can also be custmized to set what files need to be included
+in the wic image boot partition. Please refer to
+`meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/n1sdp-extra-settings.inc`
+for more details.
diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/arm-autonomy-machine-extra-settings.inc b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/arm-autonomy-machine-extra-settings.inc
new file mode 100644
index 0000000..fc24ee8
--- /dev/null
+++ b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/arm-autonomy-machine-extra-settings.inc
@@ -0,0 +1,5 @@ 
+# Require extra machine specific settings
+ARM_BSP_DYN_MACHINE_EXTRA_REQUIRE ?= ""
+ARM_BSP_DYN_MACHINE_EXTRA_REQUIRE_n1sdp = "n1sdp-extra-settings.inc"
+
+require ${ARM_BSP_DYN_MACHINE_EXTRA_REQUIRE}
diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/n1sdp-extra-settings.inc b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/n1sdp-extra-settings.inc
new file mode 100644
index 0000000..41c9433
--- /dev/null
+++ b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/n1sdp-extra-settings.inc
@@ -0,0 +1,36 @@ 
+# We need to extent the wks search path to be able to find the wks file set in
+# ARM_AUTONOMY_WKS_FILE.
+WKS_SEARCH_PATH_prepend := "${ARM_AUTONOMY_ARM_BSP_DYNAMIC_DIR}/wic:"
+
+ARM_AUTONOMY_WKS_FILE ?= "arm-autonomy-n1sdp-efidisk.wks.in"
+WKS_FILE = "${ARM_AUTONOMY_WKS_FILE}"
+
+# Set the wks guest partition size and unit. It must be aligned with the sum of
+# all XENGUEST_IMAGE_DISK_SIZE set for the guests. By default, LVM2 metadata is
+# 1 MiB per physical volume, hence it needs to be taken into account when
+# setting GUEST_PART_SIZE. The XENGUEST_IMAGE_DISK_SIZE default value is 4GiB.
+GUEST_PART_SIZE ?= "4097"
+GUEST_PART_SIZE_UNIT ?= "M"
+
+# The GRUB_CFG_FILE affects arm-autonomy-n1sdp-efidisk.wks.in file
+GRUB_CFG_FILE ?= "${ARM_AUTONOMY_ARM_BSP_DYNAMIC_DIR}/wic/arm-autonomy-n1sdp-grub.cfg"
+
+# From arm-autonomy-n1sdp-efidisk.wks.in, the /boot partition is /dev/sda1, and
+# the "/" partition is /dev/sda2.
+XENGUEST_MANAGER_VOLUME_DEVICE ?= "/dev/sda3"
+
+# The XEN_DEVICETREE_DEPEND and XEN_DEVICETREE_DTBS variables aftect the
+# xen-devicetree.bb recipe
+XEN_DEVICETREE_DEPEND = "virtual/trusted-firmware-a:do_deploy"
+XEN_DEVICETREE_DTBS ?= "n1sdp-single-chip.dtb"
+# XEN_MOD_DEVICETREE_DTBS are the generated devicetrees for Xen. By default the
+# xen-devicetree.bb recipe adds '-xen' suffix to it
+XEN_MOD_DEVICETREE_DTBS ?= "n1sdp-single-chip-xen.dtb"
+
+# When generating the wic image we need to have the xen deployed
+do_image_wic[depends] += "xen:do_deploy"
+
+# Select the extra files to be included in the boot partition
+IMAGE_EFI_BOOT_FILES += "xen-n1sdp.efi;xen.efi"
+IMAGE_EFI_BOOT_FILES += "${XEN_MOD_DEVICETREE_DTBS}"
+
diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-extended/xen-devicetree/xen-devicetree.bbappend b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-extended/xen-devicetree/xen-devicetree.bbappend
index 91af506..8284c63 100644
--- a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-extended/xen-devicetree/xen-devicetree.bbappend
+++ b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/recipes-extended/xen-devicetree/xen-devicetree.bbappend
@@ -9,8 +9,8 @@  XEN_DEVICETREE_DTSI_MERGE_append_juno = " xen-juno.dtsi"
 # Add a dtb snippet to remove pmu and iommu in dom0 on N1SDP
 SRC_URI_append_n1sdp = " file://xen-n1sdp.dtsi"
 XEN_DEVICETREE_DTSI_MERGE_append_n1sdp = " xen-n1sdp.dtsi"
-XEN_DEVICETREE_DEPEND_n1sdp = "virtual/trusted-firmware-a:do_deploy"
-XEN_DEVICETREE_DTBS_n1sdp = "n1sdp-single-chip.dtb"
+# For N1SDP, the XEN_DEVICETREE_DEPEND and XEN_DEVICETREE_DTBS variables are
+# being set in meta-arm-autonomy/dynamic-layers/meta-arm-bsp/conf/machine/n1sdp-extra-settings.inc
 
 # Board specific configs
 XEN_DEVICETREE_DOM0_BOOTARGS_append_juno = " root=/dev/sda1 rootwait"
diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic/arm-autonomy-n1sdp-efidisk.wks.in b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic/arm-autonomy-n1sdp-efidisk.wks.in
new file mode 100644
index 0000000..d91d568
--- /dev/null
+++ b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic/arm-autonomy-n1sdp-efidisk.wks.in
@@ -0,0 +1,14 @@ 
+# short-description: Create an EFI disk image
+# long-description: Creates a partitioned EFI disk image that the user
+# can directly dd to boot media. Uses a custom grub.cfg file to configure the boot.
+
+# First boot partition normally populated as /dev/sda1
+part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024
+
+# Second rootfs partition normally populated as /dev/sda2
+part / --source rootfs --ondisk sda --fstype=ext4 --label root --align 1024
+
+# Third partition to accomodate guests images normally populated as /dev/sda3 (used by XENGUEST_MANAGER_VOLUME_DEVICE)
+part --label guests --source empty --ondisk sda --size="${GUEST_PART_SIZE}${GUEST_PART_SIZE_UNIT}" --system-id 8e --align 1024
+
+bootloader --ptable msdos --configfile="${GRUB_CFG_FILE}"
diff --git a/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic/arm-autonomy-n1sdp-grub.cfg b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic/arm-autonomy-n1sdp-grub.cfg
new file mode 100644
index 0000000..f4f8cd0
--- /dev/null
+++ b/meta-arm-autonomy/dynamic-layers/meta-arm-bsp/wic/arm-autonomy-n1sdp-grub.cfg
@@ -0,0 +1,28 @@ 
+set term="vt100"
+set default="3"
+set timeout="5"
+
+set kernel_cmdline="earlycon=pl011,0x2A400000 console=ttyAMA0,115200 root=/dev/sda2 rootwait"
+
+menuentry 'N1SDP ACPI Boot' {
+    linux /Image $kernel_cmdline acpi=force
+}
+
+menuentry 'N1SDP Single-Chip Boot (Device Tree)' {
+    devicetree /n1sdp-single-chip.dtb
+    linux /Image $kernel_cmdline
+}
+
+menuentry 'N1SDP Multi-Chip Boot (Device Tree)' {
+    devicetree /n1sdp-multi-chip.dtb
+    linux /Image $kernel_cmdline
+}
+
+menuentry 'N1SDP Arm Autonomy (Xen) Single-Chip Boot (Device Tree)' {
+    # no_argumants under here is a workaround for a bug
+    # also any kernel or dom0 cmdline arguments has to be passed via dtb
+    # because any arguments put here will be ignored by xen
+    xen_hypervisor /xen.efi no_arguments=use_dtb_for_xen_or_kernel_cmdline
+    xen_module /Image
+    devicetree /n1sdp-single-chip-xen.dtb
+}