blob: 714eb96a77c94cbd69d76e0ad32b1bfbba98f4a1 [file] [log] [blame]
Brad Bishop286d45c2018-10-02 15:21:57 -04001#
2# This class handles configuring a recipe to build for the ZynqMP PMU
3# architecture. The reason for this class is due to limitations of multilib
4# with regards to multiple architectures (which do not work correctly).
5#
6# This class is specifically intended to extend the binutils-cross, gcc-cross,
7# newlib, libgloss and pmu-firmware recipes so that binaries can be emitted
8# which target the PMU architecture alongside building for the APU architecture
9# (ARM64). But the class can be applied globally via BBCLASSEXTEND in for
10# example a <machine>.conf.
11#
12# This class is almost the same as a multilib variant with custom TUNE_* setup
13# to allow for a switched TUNE_ARCH.
14#
15
16ORIG_TARGET_ARCH := "${TARGET_ARCH}"
17
18# zynqmp-pmu target arch (hardcoded based on pre-gen data from arch-microblaze.inc)
19DEFAULTTUNE = "microblaze"
20ABIEXTENSION = ""
21TUNE_ARCH = "microblazeel"
22#TUNE_FEATURES_tune-microblaze += "v9.2 barrel-shift pattern-compare"
23TUNE_CCARGS = "-mlittle-endian -mxl-barrel-shift -mxl-pattern-compare -mno-xl-reorder -mcpu=v9.2 -mxl-soft-mul -mxl-soft-div"
24TUNE_LDARGS = ""
25TUNE_ASARGS = ""
26TUNE_PKGARCH = "microblazeel-v9.2-bs-cmp"
27TARGET_OS = "elf"
28TARGET_FPU = "fpu-soft"
29
30# rebuild the MACHINE overrides
31MACHINEOVERRIDES = "${MACHINE}${@':${SOC_FAMILY}' if d.getVar('SOC_FAMILY') else ''}:microblaze"
32
33# override tune provided archs
34PACKAGE_EXTRA_ARCHS = "${TUNE_PKGARCH}"
35
36# baremetal equivalent config (note the tclibc is not included, this is purely
37# for recipes/etc that check for the value)
38TCLIBC = "baremetal"
39LIBCEXTENSION = ""
40LIBCOVERRIDE = ":libc-baremetal"
41USE_NLS = "no"
42IMAGE_LINGUAS = ""
43LIBC_DEPENDENCIES = ""
44
45# gcc-cross specific baremetal setup (due to the override order this is important)
46EXTRA_OECONF_pn-${MLPREFIX}gcc-cross-${TARGET_ARCH}_append = " --without-headers"
47
48EXTRA_OECONF_GCC_FLOAT = ""
49
50# Setup a multiarch like prefix.
51prefix = "/usr/${TARGET_SYS}"
52# Make sure GCC can search in the prefix dir (for libgcc)
53TOOLCHAIN_OPTIONS += "-B${RECIPE_SYSROOT}${includedir}/ -B${RECIPE_SYSROOT}${libdir}/"
54TOOLCHAIN_OPTIONS += "-I =${includedir} -L =${libdir}"
55
56python multitarget_zynqmp_pmu_virtclass_handler () {
57 variant = "zynqmp-pmu"
58 pn = d.getVar("PN")
59 if not (pn.startswith(variant + "-") or pn.endswith("-" + variant)):
60 return
61
62 if bb.data.inherits_class('native', e.data) or bb.data.inherits_class('nativesdk', e.data) or bb.data.inherits_class('crosssdk', e.data):
63 raise bb.parse.SkipPackage("Can't extend native/nativesdk/crosssdk recipes")
64
65 initialpn = e.data.getVar("PN").replace("-" + variant, "").replace(variant + "-", "")
66 e.data.setVar("MLPREFIX", variant + "-")
67 e.data.setVar("OVERRIDES", e.data.getVar("OVERRIDES", False) + ":virtclass-" + variant)
68
69 # hide multilib variants, this class is not one but this works around recipes thinking it is (due to MLPREFIX).
70 e.data.setVar("MULTILIB_VARIANTS", "")
71
72 # work around for -cross recipes that embed the TARGET_ARCH value
73 if bb.data.inherits_class('cross', e.data):
74 if initialpn.endswith("-" + d.getVar("ORIG_TARGET_ARCH")):
75 initialpn = initialpn.replace("-" + d.getVar("ORIG_TARGET_ARCH"), "-" + d.getVar("TARGET_ARCH"))
76
77 e.data.setVar("PN", variant + "-" + initialpn)
78}
79
80addhandler multitarget_zynqmp_pmu_virtclass_handler
81multitarget_zynqmp_pmu_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
82
83python () {
84 variant = "zynqmp-pmu"
85 pn = d.getVar("PN")
86 if not pn.startswith(variant + "-"):
87 return
88
89 if pn.endswith("gcc-cross-" + d.getVar("TARGET_ARCH")):
90 # work around, DEPENDS _remove being immediate in gcc-cross
91 d.setVar("DEPENDS_remove", "virtual/%slibc-for-gcc" % d.getVar("TARGET_PREFIX"))
92
93 if pn.endswith("libgcc"):
94 # work around, strip depends on libc via do_package* tasks (this class cannot set ASSUME_PROVIDED += libc)
95 for i in ["do_package", "do_package_write_ipk", "do_package_write_deb", "do_package_write_rpm"]:
96 sanitized = " ".join([dep for dep in d.getVarFlag(i, "depends").split() if not dep.startswith("virtual/%s-libc" % variant)])
97 d.setVarFlag(i, "depends", sanitized)
98
99 import oe.classextend
100
101 clsextend = oe.classextend.ClassExtender(variant, d)
102
103 clsextend.map_depends_variable("DEPENDS")
104 clsextend.map_variable("PROVIDES")
105
106 clsextend.rename_packages()
107 clsextend.rename_package_variables((d.getVar("PACKAGEVARS") or "").split())
108
109 clsextend.map_packagevars()
110 clsextend.map_regexp_variable("PACKAGES_DYNAMIC")
111 clsextend.map_variable("PACKAGE_INSTALL")
112}
113
114# microblaze elf insane definitions not currently in insane.bbclass
115PACKAGEQA_EXTRA_MACHDEFFUNCS += "package_qa_get_machine_dict_microblazeelf"
116def package_qa_get_machine_dict_microblazeelf(machdata, d):
117 machdata["elf"] = {
118 "microblaze": (189, 0, 0, False, 32),
119 "microblazeeb":(189, 0, 0, False, 32),
120 "microblazeel":(189, 0, 0, True, 32),
121 }
122 return machdata