summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Enedino Hernandez Samaniego <alejandr@xilinx.com>2018-07-26 17:40:46 -0700
committerManjukumar Matha <manjukumar.harthikote-matha@xilinx.com>2019-01-01 20:03:46 -0800
commit291b324e677bc372e504609e418dae7b7cc94ee4 (patch)
treead4fd7f7ba83471aab6f0accfc2e879f882a0a20
parent8f77983ba82fd3ce5ce10251b9d8da1633c14334 (diff)
downloadmeta-xilinx-291b324e677bc372e504609e418dae7b7cc94ee4.tar.gz
qemu multiarch: Replace shell based wrapper with python one
The qemu-system-aarch64-multiarch wrapper parses the arguments passed to it, and launches two separate instances of qemu with the correct arguments for PMU and APU respectively. Using a python based wrapper gives us more control over how the calls to the qemu instances are made and how the arguments are passed. This patch replaces the old wrapper with a python based one providing the same functionality as the old one but also enables testimage to be run on qemu instances, switching the tcp serial ports passed to qemu to be able to read the output from qemurunner correctly Signed-off-by: Alejandro Enedino Hernandez Samaniego <alejandr@xilinx.com> Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com>
-rw-r--r--meta-xilinx-bsp/recipes-devtools/qemu/files/qemu-system-aarch64-multiarch84
1 files changed, 53 insertions, 31 deletions
diff --git a/meta-xilinx-bsp/recipes-devtools/qemu/files/qemu-system-aarch64-multiarch b/meta-xilinx-bsp/recipes-devtools/qemu/files/qemu-system-aarch64-multiarch
index 15124c1b..2c92c686 100644
--- a/meta-xilinx-bsp/recipes-devtools/qemu/files/qemu-system-aarch64-multiarch
+++ b/meta-xilinx-bsp/recipes-devtools/qemu/files/qemu-system-aarch64-multiarch
@@ -1,32 +1,54 @@
1#!/bin/bash 1#!/usr/bin/env python3
2
3BINPATH=$(dirname $0)
4MACHINE_PATH=$(mktemp -d)
5
6APU_ARGS=
7PMU_ARGS=
8
9while [ ! -z "$1" ]; do
10 if [ "$1" = "-pmu-args" ]; then
11 PMU_ARGS+=" $2"
12 shift
13 else
14 APU_ARGS+=" $1"
15 fi
16 shift
17done
18
19PMU_ROM=$(last=; for i in $PMU_ARGS; do if [ "$last" = "-kernel" ]; then echo "$i"; break; fi; last=$i; done)
20if [ ! -e $PMU_ROM ]; then
21 echo "------"
22 echo "Error: Missing PMU ROM - $PMU_ROM"
23 echo " See 'meta-xilinx/README.qemu.md' for more information on accquiring the PMU ROM."
24 echo "------"
25 exit 255
26fi
27
28# start the PMU instance
29$BINPATH/qemu-system-microblazeel $PMU_ARGS -machine-path $MACHINE_PATH &
30# start the APU instance
31$BINPATH/qemu-system-aarch64 $APU_ARGS -machine-path $MACHINE_PATH
32 2
3# Xilinx QEMU wrapper to launch both PMU and APU instances (multiarch)
4import os
5import subprocess
6import sys
7import tempfile
8import shutil
9
10binpath = os.path.dirname(os.path.abspath(__file__))
11mach_path = tempfile.mkdtemp()
12
13
14# Separate PMU and APU arguments
15APU_args = sys.argv[1:]
16PMU_args = APU_args[APU_args.index('-pmu-args')+1]
17APU_args.remove('-pmu-args')
18APU_args.remove(PMU_args)
19PMU_args = PMU_args.split()
20
21PMU_rom = PMU_args[PMU_args.index('-kernel')+1]
22error_msg = None
23
24if os.path.exists(PMU_rom):
25
26 # We need to switch tcp serial arguments (if they exist, e.g. qemurunner) to get the output correctly
27 tcp_serial_ports = [i for i, s in enumerate(APU_args) if 'tcp:127.0.0.1:' in s]
28
29 # We can only switch these if there are exactly two, otherwise we can't assume what is being executed so we leave it as is
30 if len(tcp_serial_ports) == 2:
31 APU_args[tcp_serial_ports[0]],APU_args[tcp_serial_ports[1]] = APU_args[tcp_serial_ports[1]],APU_args[tcp_serial_ports[0]]
32
33 pmu_cmd = binpath + '/qemu-system-microblazeel ' + ' '.join(PMU_args) + ' -machine-path ' + mach_path
34 apu_cmd = binpath + '/qemu-system-aarch64 ' + ' '.join(APU_args) + ' -machine-path ' + mach_path
35
36 # Debug prints
37 print('\nPMU instance cmd: %s\n' % pmu_cmd)
38 print('APU instance cmd: %s\n' % apu_cmd)
39
40
41 # Invoke QEMU pmu instance
42 process_pmu = subprocess.Popen(pmu_cmd, shell=True, stderr=subprocess.PIPE)
43
44 # Invoke QEMU APU instance
45 process_apu = subprocess.Popen(apu_cmd, shell=True, stderr=subprocess.PIPE)
46 if process_apu.wait():
47 error_msg = '\nQEMU APU instance failed:\n%s' % process_apu.stderr.read().decode()
48
49else:
50 error_msg = '\nError: Missing PMU ROM: %s' % PMU_rom
51 error_msg += '\nSee "meta-xilinx/README.qemu.md" for more information on accquiring the PMU ROM.\n'
52
53shutil.rmtree(mach_path)
54sys.exit(error_msg)