summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-xilinx-core/recipes-devtools/qemu/files/qemu-system-aarch64-multiarch113
1 files changed, 66 insertions, 47 deletions
diff --git a/meta-xilinx-core/recipes-devtools/qemu/files/qemu-system-aarch64-multiarch b/meta-xilinx-core/recipes-devtools/qemu/files/qemu-system-aarch64-multiarch
index 370e694b..1dcac990 100644
--- a/meta-xilinx-core/recipes-devtools/qemu/files/qemu-system-aarch64-multiarch
+++ b/meta-xilinx-core/recipes-devtools/qemu/files/qemu-system-aarch64-multiarch
@@ -13,58 +13,77 @@ mach_path = tempfile.mkdtemp()
13 13
14# Separate PMU and APU arguments 14# Separate PMU and APU arguments
15APU_args = sys.argv[1:] 15APU_args = sys.argv[1:]
16mbtype='' 16PMU_args = []
17PLM_args = []
17 18
18if '-pmu-args' in APU_args: 19if '-pmu-args' in APU_args:
19 MB_args = APU_args[APU_args.index('-pmu-args')+1] 20 pmu_args_idx = APU_args.index('-pmu-args')
20 APU_args.remove('-pmu-args') 21 PMU_args = APU_args[pmu_args_idx+1].split()
21 APU_args.remove(MB_args) 22 del APU_args[pmu_args_idx:pmu_args_idx+2]
22 MB_args = MB_args.split() 23
23 PMU_rom = MB_args[MB_args.index('-kernel')+1] 24if '-plm-args' in APU_args:
24 mbtype='PMU' 25 plm_args_idx = APU_args.index('-plm-args')
25elif '-plm-args' in APU_args: 26 PLM_args = APU_args[plm_args_idx+1].split()
26 MB_args = APU_args[APU_args.index('-plm-args')+1] 27 del APU_args[plm_args_idx:plm_args_idx+2]
27 APU_args.remove('-plm-args') 28
28 APU_args.remove(MB_args) 29if PMU_args and PLM_args:
29 MB_args = MB_args.split() 30 sys.exit("\nError: -pmu-args can not be used with -plm-args\n")
30 mbtype='PLM' 31
31elif '--help' in APU_args: 32if ('--help' in APU_args) or (not PMU_args and not PLM_args):
32 mbtype='help' 33 print("AMD FPGA QEMU multiarch wrapper\n")
33else: 34 print("Version 2024.1")
34 error_msg = '\nMultiarch not setup properly.' 35 print("")
35 sys.exit(error_msg) 36 print("Usage:")
36 37 print(" %s <APU options> [-pmu-args <pmu options>]" % (sys.argv[0]))
37error_msg = None 38 print(" %s <APU options> [-plm-args <plm options>]" % (sys.argv[0]))
38if (mbtype == 'PMU' and os.path.exists(PMU_rom)) or mbtype == 'PLM': 39 print("")
39 40 sys.exit(1)
40 # We need to switch tcp serial arguments (if they exist, e.g. qemurunner) to get the output correctly 41
41 tcp_serial_ports = [i for i, s in enumerate(APU_args) if 'tcp:127.0.0.1:' in s] 42if PMU_args:
42 43 PMU_rom = PMU_args[PMU_args.index('-kernel')+1]
43 #NEED TO FIX for next yocto release (dont need to switch ports anymore, they will be provided correctly upstream
44 # 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
45 if len(tcp_serial_ports) == 2:
46 APU_args[tcp_serial_ports[0]],APU_args[tcp_serial_ports[1]] = APU_args[tcp_serial_ports[1]],APU_args[tcp_serial_ports[0]]
47
48 mb_cmd = binpath + '/qemu-system-microblazeel ' + ' '.join(MB_args) + ' -machine-path ' + mach_path
49 apu_cmd = binpath + '/qemu-system-aarch64 ' + ' '.join(APU_args) + ' -machine-path ' + mach_path
50
51 # Debug prints
52 print('\n%s instance cmd: %s\n' % (mbtype, mb_cmd))
53 print('APU instance cmd: %s\n' % apu_cmd)
54
55
56 # Invoke QEMU pmu instance
57 process_pmu = subprocess.Popen(mb_cmd, shell=True, stderr=subprocess.PIPE)
58
59 # Invoke QEMU APU instance
60 process_apu = subprocess.Popen(apu_cmd, shell=True, stderr=subprocess.PIPE)
61 if process_apu.wait():
62 error_msg = '\nQEMU APU instance failed:\n%s' % process_apu.stderr.read().decode()
63 44
64else: 45 if not os.path.exists(PMU_rom):
65 if mbtype == 'PMU':
66 error_msg = '\nError: Missing PMU ROM: %s' % PMU_rom 46 error_msg = '\nError: Missing PMU ROM: %s' % PMU_rom
67 error_msg += '\nSee "meta-xilinx/README.qemu.md" for more information on accquiring the PMU ROM.\n' 47 error_msg += '\nSee "meta-xilinx/README.qemu.md" for more information on accquiring the PMU ROM.\n'
48 sys.exit(error_msg)
49
50# We need to switch tcp serial arguments (if they exist, e.g. qemurunner) to get the output correctly
51tcp_serial_ports = [i for i, s in enumerate(APU_args) if 'tcp:127.0.0.1:' in s]
52
53#NEED TO FIX for next yocto release (dont need to switch ports anymore, they will be provided correctly upstream
54# 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
55if len(tcp_serial_ports) == 2:
56 APU_args[tcp_serial_ports[0]],APU_args[tcp_serial_ports[1]] = APU_args[tcp_serial_ports[1]],APU_args[tcp_serial_ports[0]]
57
58mb_cmd = ""
59if PMU_args:
60 mb_cmd = binpath + '/qemu-system-microblazeel ' + ' '.join(PMU_args) + ' -machine-path ' + mach_path
61
62 print("PMU instance cmd: %s\n" % mb_cmd)
63
64if PLM_args:
65 mb_cmd = binpath + '/qemu-system-microblazeel ' + ' '.join(PLM_args) + ' -machine-path ' + mach_path
66
67 print("PLM instance cmd: %s\n" % mb_cmd)
68
69apu_cmd = binpath + '/qemu-system-aarch64 ' + ' '.join(APU_args) + ' -machine-path ' + mach_path
70
71print("APU instance cmd: %s\n" % apu_cmd)
72
73
74if mb_cmd:
75 process_mb = subprocess.Popen(mb_cmd, shell=True, stderr=subprocess.PIPE)
76
77if apu_cmd:
78 process_apu = subprocess.Popen(apu_cmd, shell=True, stderr=subprocess.PIPE)
79
80error_msg = ""
81if apu_cmd and process_apu.wait():
82 # We only check for failures on the MB instance if APU fails
83 error_msg += '\nQEMU APU instance failed:\n%s' % process_apu.stderr.read().decode()
84
85 if mb_cmd and process_mb.wait():
86 error_msg += '\nQEMU MB instance failed:\n%s' % process_mb.stderr.read().decode()
68 87
69shutil.rmtree(mach_path) 88shutil.rmtree(mach_path)
70sys.exit(error_msg) 89sys.exit(error_msg)