diff options
Diffstat (limited to 'meta-xilinx-core/classes/qemuboot-xilinx.bbclass')
-rw-r--r-- | meta-xilinx-core/classes/qemuboot-xilinx.bbclass | 119 |
1 files changed, 118 insertions, 1 deletions
diff --git a/meta-xilinx-core/classes/qemuboot-xilinx.bbclass b/meta-xilinx-core/classes/qemuboot-xilinx.bbclass index 59d3f0ab..0f7c75ed 100644 --- a/meta-xilinx-core/classes/qemuboot-xilinx.bbclass +++ b/meta-xilinx-core/classes/qemuboot-xilinx.bbclass | |||
@@ -10,6 +10,12 @@ QB_MACHINE_XILINX:aarch64 = "-machine arm-generic-fdt" | |||
10 | QB_MACHINE_XILINX:arm = "-M arm-generic-fdt-7series" | 10 | QB_MACHINE_XILINX:arm = "-M arm-generic-fdt-7series" |
11 | QB_MACHINE_XILINX:microblaze = "-M microblaze-fdt-plnx" | 11 | QB_MACHINE_XILINX:microblaze = "-M microblaze-fdt-plnx" |
12 | 12 | ||
13 | QB_SYSTEM_NAME = "${@qemu_target_binary(d)}" | ||
14 | QB_DEFAULT_FSTYPE = "${@qemu_rootfs_params(d,'fstype')}" | ||
15 | QB_ROOTFS = "${@qemu_rootfs_params(d,'rootfs')}" | ||
16 | QB_ROOTFS_OPT = "${@qemu_rootfs_params(d,'rootfs-opt')}" | ||
17 | QB_DTB = "${@qemu_default_dtb(d)}" | ||
18 | |||
13 | # defaults | 19 | # defaults |
14 | QB_DEFAULT_KERNEL ?= "none" | 20 | QB_DEFAULT_KERNEL ?= "none" |
15 | QB_DEFAULT_KERNEL:zynq ?= "${@'zImage' if \ | 21 | QB_DEFAULT_KERNEL:zynq ?= "${@'zImage' if \ |
@@ -19,6 +25,118 @@ QB_DEFAULT_KERNEL:microblaze ?= "${@'simpleImage.mb' if \ | |||
19 | 25 | ||
20 | inherit qemuboot | 26 | inherit qemuboot |
21 | 27 | ||
28 | def qemu_target_binary(data): | ||
29 | package_arch = data.getVar("PACKAGE_ARCH") | ||
30 | qemu_target_binary = (data.getVar("QEMU_TARGET_BINARY_%s" % package_arch) or "") | ||
31 | if qemu_target_binary: | ||
32 | return qemu_target_binary | ||
33 | |||
34 | target_arch = data.getVar("TARGET_ARCH") | ||
35 | if target_arch == "microblazeeb": | ||
36 | target_arch = "microblaze" | ||
37 | elif target_arch == "aarch64": | ||
38 | target_arch += "-multiarch" | ||
39 | elif target_arch == "arm": | ||
40 | target_arch = "aarch64" | ||
41 | return "qemu-system-%s" % target_arch | ||
42 | |||
43 | def qemu_add_extra_args(data): | ||
44 | initramfs_image = data.getVar('INITRAMFS_IMAGE') or "" | ||
45 | bundle_image = data.getVar('INITRAMFS_IMAGE_BUNDLE') or "" | ||
46 | deploy_dir = data.getVar('DEPLOY_DIR_IMAGE') or "" | ||
47 | machine_name = data.getVar('MACHINE') or "" | ||
48 | soc_family = data.getVar('SOC_FAMILY') or "" | ||
49 | qb_extra_args = '' | ||
50 | # Add kernel image and boot.scr to qemu boot command when initramfs_image supplied | ||
51 | kernel_name = '' | ||
52 | bootscr_image = '%s/boot.scr' % deploy_dir | ||
53 | if soc_family in ('zynqmp', 'versal'): | ||
54 | kernel_name = 'Image' | ||
55 | bootscr_loadaddr = '0x20000000' | ||
56 | if initramfs_image: | ||
57 | kernel_image = '%s/%s' % (deploy_dir, kernel_name) | ||
58 | if bundle_image == "1": | ||
59 | kernel_image = '%s/%s-initramfs-%s.bin' % (deploy_dir, kernel_name, machine_name) | ||
60 | kernel_loadaddr = '0x200000' | ||
61 | if kernel_name: | ||
62 | qb_extra_args = ' -device loader,file=%s,addr=%s,force-raw=on' % (kernel_image, kernel_loadaddr) | ||
63 | qb_extra_args += ' -device loader,file=%s,addr=%s,force-raw=on' % (bootscr_image, bootscr_loadaddr) | ||
64 | if soc_family == 'versal': | ||
65 | qb_extra_args += ' -boot mode=5' | ||
66 | else: | ||
67 | if soc_family in ('zynqmp', 'versal'): | ||
68 | qb_extra_args = ' -boot mode=5' | ||
69 | return qb_extra_args | ||
70 | |||
71 | def qemu_rootfs_params(data, param): | ||
72 | initramfs_image = data.getVar('INITRAMFS_IMAGE') or "" | ||
73 | bundle_image = data.getVar('INITRAMFS_IMAGE_BUNDLE') or "" | ||
74 | soc_family = data.getVar('SOC_FAMILY') or "" | ||
75 | tune_features = (data.getVar('TUNE_FEATURES') or []).split() | ||
76 | if 'microblaze' in tune_features: | ||
77 | soc_family = 'microblaze' | ||
78 | soc_variant = data.getVar('SOC_VARIANT') or "" | ||
79 | |||
80 | if param == 'rootfs': | ||
81 | return 'none' if bundle_image == "1" else '' | ||
82 | |||
83 | elif param == 'fstype': | ||
84 | fstype_dict = { | ||
85 | "microblaze": "cpio.gz", | ||
86 | "zynq": "cpio.gz", | ||
87 | "zynqmp": "cpio.gz.u-boot", | ||
88 | "versal": "cpio.gz.u-boot.qemu-sd-fatimg" | ||
89 | } | ||
90 | if not initramfs_image: | ||
91 | image_fs = data.getVar('IMAGE_FSTYPES') | ||
92 | if 'wic.qemu-sd' in image_fs: | ||
93 | return 'wic.qemu-sd' | ||
94 | return fstype_dict[soc_family] | ||
95 | |||
96 | elif param == 'rootfs-opt': | ||
97 | sd_index = "1" | ||
98 | if soc_family == 'zynq': | ||
99 | sd_index = "0" | ||
100 | if soc_family == 'versal' and soc_variant == 'net': | ||
101 | sd_index = "0" | ||
102 | |||
103 | # Device is using a disk | ||
104 | if not initramfs_image: | ||
105 | return ' -drive if=sd,index=%s,file=@ROOTFS@,format=raw' % (sd_index) | ||
106 | |||
107 | # Device is using a ramdisk | ||
108 | if soc_family not in ('zynq', 'microblaze'): | ||
109 | return ' -device loader,file=@ROOTFS@,addr=0x04000000,force-raw=on' | ||
110 | |||
111 | # Ramdisk must be compiled into the kernel | ||
112 | return '' | ||
113 | |||
114 | def qemu_default_dtb(data): | ||
115 | if data.getVar("IMAGE_BOOT_FILES", True): | ||
116 | dtbs = data.getVar("IMAGE_BOOT_FILES", True).split(" ") | ||
117 | # IMAGE_BOOT_FILES has extra renaming info in the format '<source>;<target>' | ||
118 | # Note: Wildcard sources work here only because runqemu expands them at run time | ||
119 | dtbs = [f.split(";")[0] for f in dtbs] | ||
120 | dtbs = [f for f in dtbs if f.endswith(".dtb")] | ||
121 | if len(dtbs) != 0: | ||
122 | return dtbs[0] | ||
123 | return "" | ||
124 | |||
125 | def qemu_default_serial(data): | ||
126 | if data.getVar("SERIAL_CONSOLES", True): | ||
127 | first_console = data.getVar("SERIAL_CONSOLES", True).split(" ")[0] | ||
128 | speed, console = first_console.split(";", 1) | ||
129 | # zynqmp uses earlycon and stdout (in dtb) | ||
130 | if "zynqmp" in data.getVar("MACHINEOVERRIDES", True).split(":"): | ||
131 | return "" | ||
132 | return "console=%s,%s earlyprintk" % (console, speed) | ||
133 | return "" | ||
134 | |||
135 | def qemu_zynqmp_unhalt(data, multiarch): | ||
136 | if multiarch: | ||
137 | return "-global xlnx,zynqmp-boot.cpu-num=0 -global xlnx,zynqmp-boot.use-pmufw=true" | ||
138 | return "-device loader,addr=0xfd1a0104,data=0x8000000e,data-len=4 -device loader,addr=0xfd1a0104,data=0x8000000e,data-len=4" | ||
139 | |||
22 | # rewrite the qemuboot with the custom sysroot bindir | 140 | # rewrite the qemuboot with the custom sysroot bindir |
23 | python do_write_qemuboot_conf:append() { | 141 | python do_write_qemuboot_conf:append() { |
24 | val = os.path.join(d.getVar('BASE_WORKDIR'), d.getVar('BUILD_SYS'), 'qemu-xilinx-helper-native/1.0-r1/recipe-sysroot-native/usr/bin/') | 142 | val = os.path.join(d.getVar('BASE_WORKDIR'), d.getVar('BUILD_SYS'), 'qemu-xilinx-helper-native/1.0-r1/recipe-sysroot-native/usr/bin/') |
@@ -28,4 +146,3 @@ python do_write_qemuboot_conf:append() { | |||
28 | with open(qemuboot, 'w') as f: | 146 | with open(qemuboot, 'w') as f: |
29 | cf.write(f) | 147 | cf.write(f) |
30 | } | 148 | } |
31 | |||