This change reworks how the meta-xilinx layer enables and provides the
custom version of QEMU based on Xilinx's fork of QEMU. The existing
implementation relied on the single sysroot which was changed in oe-core
such that now recipes have their own sysroots (RSS support).
Additionally oe-core now provides the QEMU binaries to the runqemu
script via the 'qemu-helper-native' recipes sysroot as opposed to the
image sysroot.

These rework changes allow for a single machine to select the targeted
QEMU version as well as to provide the qemuboot config specific to the
targeted QEMU version. The selection of QEMU version is now handled by
PREFERRED_PROVIDER mechanics with the meta-xilinx layer providing an
additional recipe that is equivalent to qemu-helper-native and which
also provides said target allowing for the machine to select via the use
of PREFERRED_PROVIDER_qemu-helper-native. This recipe
(qemu-xilinx-helper-native) however instead provides the sysroot
populated with qemu-xilinx instead of qemu.

Additionally the XILINX_QEMUBOOT variable is replaced with the
qemuboot-xilinx.bbclass, this provides the overrides for setting up
qemu-xilinx specific QB_* args. Additionally this bbclass points runqemu
at the qemu-xilinx-helper-native sysroot for QEMU binaries.

These changes also work towards making the meta-xilinx layer better
handle multiple qemuboot.conf variants as well as handling different
QEMU versions.

This change also removes the 'qemu-system-xilinx' MACHINE_FEATURES, this
is due to MACHINE_FEATURES no longer being available for native recipes.
Additionally there is no longer any logic that needs to know this any
way.

Signed-off-by: Nathan Rossi <nat...@nathanrossi.com>
---
 classes/qemuboot-xilinx.bbclass                    | 27 +++++++++++++++
 conf/machine/include/machine-xilinx-qemu.inc       | 39 ++++------------------
 conf/machine/ml605-qemu-microblazeel.conf          |  1 +
 conf/machine/qemu-zynq7.conf                       |  1 +
 conf/machine/s3adsp1800-qemu-microblazeeb.conf     |  1 +
 conf/machine/zcu102-zynqmp.conf                    |  8 +++--
 .../qemu/qemu-xilinx-helper-native_1.0.bb          | 20 +++++++++++
 7 files changed, 61 insertions(+), 36 deletions(-)
 create mode 100644 classes/qemuboot-xilinx.bbclass
 create mode 100644 recipes-devtools/qemu/qemu-xilinx-helper-native_1.0.bb

diff --git a/classes/qemuboot-xilinx.bbclass b/classes/qemuboot-xilinx.bbclass
new file mode 100644
index 0000000000..a2f5ef3eb6
--- /dev/null
+++ b/classes/qemuboot-xilinx.bbclass
@@ -0,0 +1,27 @@
+
+inherit qemuboot
+
+# enable the overrides for the context of the conf only
+OVERRIDES .= ":qemuboot-xilinx"
+
+# setup the target binary
+QB_SYSTEM_NAME_prepend = "qemu-xilinx/"
+
+# Default machine targets for Xilinx QEMU (FDT Generic)
+QB_MACHINE_aarch64 = "-machine arm-generic-fdt"
+QB_MACHINE_arm = "-machine arm-generic-fdt-plnx"
+QB_MACHINE_microblaze = "-machine microblaze-generic-fdt"
+
+# defaults
+QB_DEFAULT_KERNEL ?= "none"
+
+# rewrite the qemuboot with the custom sysroot bindir
+python do_write_qemuboot_conf_append() {
+    val = os.path.join(d.getVar('BASE_WORKDIR'), d.getVar('BUILD_SYS'), 
'qemu-xilinx-helper-native/1.0-r1/recipe-sysroot-native/usr/bin/')
+    cf.set('config_bsp', 'STAGING_BINDIR_NATIVE', '%s' % val)
+
+    # write out the updated version from this append
+    with open(qemuboot, 'w') as f:
+        cf.write(f)
+}
+
diff --git a/conf/machine/include/machine-xilinx-qemu.inc 
b/conf/machine/include/machine-xilinx-qemu.inc
index 3c6972fa58..e9f662bc62 100644
--- a/conf/machine/include/machine-xilinx-qemu.inc
+++ b/conf/machine/include/machine-xilinx-qemu.inc
@@ -1,4 +1,8 @@
-EXTRA_IMAGEDEPENDS += "qemu-native qemu-helper-native"
+# This include is used to setup default QEMU and qemuboot config for 
meta-xilinx
+# machines.
+
+# depend on qemu-helper-native, which will depend on QEMU
+EXTRA_IMAGEDEPENDS += "qemu-helper-native"
 
 def qemu_default_dtb(d):
     if d.getVar("IMAGE_BOOT_FILES", True):
@@ -28,42 +32,11 @@ def qemu_target_binary(d):
         ta = "microblaze"
     elif ta == "arm":
         ta = "aarch64"
-    if qemuboot_xilinx_enabled(d):
-        return "qemu-xilinx/qemu-system-%s" % ta
     return "qemu-system-%s" % ta
 
-def qemuboot_xilinx_enabled(d):
-    if bb.utils.contains("MACHINE_FEATURES", "qemu-system-xilinx", True, 
False, d):
-        if d.getVar("XILINX_QEMUBOOT", True) == "1":
-            return True
-    return False
-
-# For runqemu, default setup across all machines in meta-xilinx
-IMAGE_CLASSES += "qemuboot"
+# For qemuboot, default setup across all machines in meta-xilinx
 QB_SYSTEM_NAME ?= "${@qemu_target_binary(d)}"
 QB_DEFAULT_FSTYPE ?= "cpio"
-
-XILINX_QEMUBOOT[doc] = "Set this variable to '1' to enable the generation of 
qemuboot.conf which uses the Xilinx QEMU."
-XILINX_QEMUBOOT ??= ""
-
-# Dependencies for native Xilinx QEMU
-XILINX_QEMU_DEPENDS ?= "qemu-xilinx-native"
-# If the machine supports the Xilinx QEMU, add the dependencies
-EXTRA_IMAGEDEPENDS += "${@bb.utils.contains('MACHINE_FEATURES', 
'qemu-system-xilinx', '${XILINX_QEMU_DEPENDS}', '', d)}"
-
-# Add an override for when booting with the Xilinx QEMU
-MACHINEOVERRIDES .= "${@':qemuboot-xilinx' if qemuboot_xilinx_enabled(d) else 
''}"
-
-# This is ignored if using Xilinx's QEMU fork
 QB_DTB ?= "${@qemu_default_dtb(d)}"
-
-# ZynqMP machines need special "-hw-dtb" device trees for the Xilinx QEMU
-XILINX_QEMU_DEPENDS_append_zynqmp = " qemu-devicetrees"
-
-QB_DEFAULT_KERNEL_qemuboot-xilinx = "none"
 QB_KERNEL_CMDLINE_APPEND ?= "${@qemu_default_serial(d)}"
 
-# Default machine targets for Xilinx QEMU (FDT Generic)
-QB_MACHINE_qemuboot-xilinx_aarch64 = "-machine arm-generic-fdt"
-QB_MACHINE_qemuboot-xilinx_arm = "-machine arm-generic-fdt-plnx"
-QB_MACHINE_qemuboot-xilinx_microblaze = "-machine microblaze-generic-fdt"
diff --git a/conf/machine/ml605-qemu-microblazeel.conf 
b/conf/machine/ml605-qemu-microblazeel.conf
index a0ef7d3e16..731f26f3c4 100644
--- a/conf/machine/ml605-qemu-microblazeel.conf
+++ b/conf/machine/ml605-qemu-microblazeel.conf
@@ -17,6 +17,7 @@ SERIAL_CONSOLE = "115200 ttyS0"
 FILESOVERRIDES_append_pn-init-ifupdown = ":qemuarm"
 
 # This machine is a targeting a QEMU model, runqemu setup:
+IMAGE_CLASSES += "qemuboot"
 QB_MEM = "-m 256"
 QB_MACHINE = "-machine petalogix-ml605"
 QB_OPT_APPEND = "-nographic -serial mon:stdio"
diff --git a/conf/machine/qemu-zynq7.conf b/conf/machine/qemu-zynq7.conf
index 6073211cb6..0fe99e2742 100644
--- a/conf/machine/qemu-zynq7.conf
+++ b/conf/machine/qemu-zynq7.conf
@@ -17,6 +17,7 @@ IMAGE_BOOT_FILES += "${MACHINE}.dtb"
 FILESOVERRIDES_append_pn-init-ifupdown = ":qemuarm"
 
 # This machine is a targeting a QEMU model, runqemu setup:
+IMAGE_CLASSES += "qemuboot"
 QB_MEM = "-m 1024"
 QB_MACHINE = "-machine xilinx-zynq-a9"
 QB_OPT_APPEND = "-nographic -serial null -serial mon:stdio"
diff --git a/conf/machine/s3adsp1800-qemu-microblazeeb.conf 
b/conf/machine/s3adsp1800-qemu-microblazeeb.conf
index 2577faabc0..16bf4d46ea 100644
--- a/conf/machine/s3adsp1800-qemu-microblazeeb.conf
+++ b/conf/machine/s3adsp1800-qemu-microblazeeb.conf
@@ -16,6 +16,7 @@ SERIAL_CONSOLE = "115200 ttyUL0"
 MACHINE_ESSENTIAL_EXTRA_RDEPENDS_remove = "device-tree"
 
 # This machine is a targeting a QEMU model, runqemu setup:
+IMAGE_CLASSES += "qemuboot"
 QB_MEM = "-m 256"
 QB_MACHINE = "-machine petalogix-s3adsp1800"
 QB_OPT_APPEND = "-nographic -serial mon:stdio"
diff --git a/conf/machine/zcu102-zynqmp.conf b/conf/machine/zcu102-zynqmp.conf
index c55b536c54..2e3c136744 100644
--- a/conf/machine/zcu102-zynqmp.conf
+++ b/conf/machine/zcu102-zynqmp.conf
@@ -7,7 +7,7 @@ require conf/machine/include/machine-xilinx-default.inc
 require conf/machine/include/machine-xilinx-board.inc
 require conf/machine/include/machine-xilinx-qemu.inc
 
-MACHINE_FEATURES = "rtc ext2 ext3 vfat usbhost mali qemu-system-xilinx"
+MACHINE_FEATURES = "rtc ext2 ext3 vfat usbhost mali"
 
 UBOOT_MACHINE = "xilinx_zynqmp_zcu102_revB_defconfig"
 
@@ -20,16 +20,18 @@ PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot-xlnx"
 
 EXTRA_IMAGEDEPENDS += "\
                arm-trusted-firmware \
+               qemu-devicetrees \
                "
 
 # This machine has a QEMU model, runqemu setup:
+IMAGE_CLASSES += "qemuboot-xilinx"
 QB_MACHINE = "-machine xlnx-zcu102"
 QB_MEM = "-m 2048"
 QB_OPT_APPEND = "-nographic -serial mon:stdio -serial null"
 QB_NETWORK_DEVICE = "-net nic -net nic -net nic -net 
nic,netdev=net0,macaddr=@MAC@"
 
-# Xilinx QEMU options, default to using Xilinx QEMU
-XILINX_QEMUBOOT ?= "1"
+# Use qemu-xilinx instead of mainline
+PREFERRED_PROVIDER_qemu-helper-native = "qemu-xilinx-helper-native"
 
 # Reset and unhalt CPU0, load the boot media.
 QB_OPT_APPEND_append_qemuboot-xilinx = " \
diff --git a/recipes-devtools/qemu/qemu-xilinx-helper-native_1.0.bb 
b/recipes-devtools/qemu/qemu-xilinx-helper-native_1.0.bb
new file mode 100644
index 0000000000..f04be9602e
--- /dev/null
+++ b/recipes-devtools/qemu/qemu-xilinx-helper-native_1.0.bb
@@ -0,0 +1,20 @@
+
+def get_filespath_extra(d, subpath):
+       metaroot = next((p for p in d.getVar('BBPATH').split(':') if 
os.path.basename(p) == 'meta'), None)
+       if metaroot:
+               return os.path.join(metaroot, subpath) + ":"
+       return ""
+
+# TODO: improve this, since it is very hacky that this recipe need to build 
tunctl.
+# include the existing qemu-helper-native
+require recipes-devtools/qemu/qemu-helper-native_1.0.bb
+# get the path to tunctl.c
+FILESEXTRAPATHS_prepend := "${@get_filespath_extra(d, 
'recipes-devtools/qemu/qemu-helper')}"
+
+# provide it, to replace the existing
+PROVIDES += "qemu-helper-native"
+
+# replace qemu with qemu-xilinx
+DEPENDS_remove = "qemu-native"
+DEPENDS_append = " qemu-xilinx-native"
+
-- 
2.11.0

-- 
_______________________________________________
meta-xilinx mailing list
meta-xilinx@yoctoproject.org
https://lists.yoctoproject.org/listinfo/meta-xilinx

Reply via email to