diff options
author | Mark Hatle <mark.hatle@amd.com> | 2024-05-23 09:49:48 -0600 |
---|---|---|
committer | Mark Hatle <mark.hatle@amd.com> | 2024-11-21 10:43:43 -0600 |
commit | 3fb0ec778d76d509c30dcf1e07dcdd659f823be7 (patch) | |
tree | cbc9c3a8458add6f673b3124ccbd8688767c934e /meta-xilinx-standalone-sdt/classes-recipe | |
parent | afad32c5d133a1f8a6e59e51d228161b9f47bb10 (diff) | |
download | meta-xilinx-3fb0ec778d76d509c30dcf1e07dcdd659f823be7.tar.gz |
meta-xilinx-standalone-sdt: Rename from ...-experimental
Add symlink to old name for temporarily compatibility.
Signed-off-by: Mark Hatle <mark.hatle@amd.com>
Diffstat (limited to 'meta-xilinx-standalone-sdt/classes-recipe')
3 files changed, 226 insertions, 0 deletions
diff --git a/meta-xilinx-standalone-sdt/classes-recipe/esw.bbclass b/meta-xilinx-standalone-sdt/classes-recipe/esw.bbclass new file mode 100644 index 00000000..7d0a2e5d --- /dev/null +++ b/meta-xilinx-standalone-sdt/classes-recipe/esw.bbclass | |||
@@ -0,0 +1,159 @@ | |||
1 | inherit python3native xlnx-embeddedsw pkgconfig cmake | ||
2 | |||
3 | # Poky always tries to enable EXPORT_COMPILE_COMMANDS, but ESW changes | ||
4 | # behavior when this is enabled and will generate: | ||
5 | # -isystem /usr/include | ||
6 | # which will cause a build failures. | ||
7 | OECMAKE_ARGS:remove = "-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON" | ||
8 | |||
9 | SRCREV_FORMAT = "src_decouple" | ||
10 | |||
11 | S = "${UNPACKDIR}/git" | ||
12 | B = "${UNPACKDIR}/build" | ||
13 | OECMAKE_SOURCEPATH = "${S}/${ESW_COMPONENT_SRC}" | ||
14 | LICFILENAME = "license.txt" | ||
15 | |||
16 | SPECFILE_PATH:arm = "${S}/scripts/specs/arm/Xilinx.spec" | ||
17 | SPECFILE_PATH:aarch64 = "${S}/scripts/specs/arm/Xilinx.spec" | ||
18 | SPECFILE_PATH:microblaze = "${S}/scripts/specs/microblaze/Xilinx.spec" | ||
19 | |||
20 | ESW_MACHINE ?= "${MACHINE}" | ||
21 | |||
22 | ESW_CFLAGS += "-specs=${SPECFILE_PATH}" | ||
23 | |||
24 | inherit ccmake | ||
25 | |||
26 | COMPATIBLE_HOST = ".*-elf" | ||
27 | COMPATIBLE_HOST:arm = "[^-]*-[^-]*-eabi" | ||
28 | |||
29 | CONFIG_DTFILE ??= "" | ||
30 | DTS_FILE = "${DEPLOY_DIR_IMAGE}/devicetree/${@os.path.basename(d.getVar('CONFIG_DTFILE').replace('.dts','.dtb'))}" | ||
31 | |||
32 | DEPENDS += "python3-pyyaml-native lopper-native device-tree python3-dtc-native" | ||
33 | |||
34 | # We need the deployed output | ||
35 | do_configure[depends] += "device-tree:do_deploy" | ||
36 | do_compile[depends] += "device-tree:do_deploy" | ||
37 | do_install[depends] += "device-tree:do_deploy" | ||
38 | |||
39 | def get_xlnx_cmake_machine(fam, variant, d): | ||
40 | cmake_machine = fam | ||
41 | if (fam == 'zynqmp'): | ||
42 | cmake_machine = 'ZynqMP' | ||
43 | elif (fam == 'versal'): | ||
44 | cmake_machine = 'Versal' | ||
45 | if (variant == 'net'): | ||
46 | cmake_machine = 'VersalNet' | ||
47 | elif (fam == 'zynq'): | ||
48 | cmake_machine = 'Zynq' | ||
49 | return cmake_machine | ||
50 | |||
51 | def get_xlnx_cmake_processor(tune, machine, variant, d): | ||
52 | cmake_processor = tune | ||
53 | if tune.startswith('microblaze'): | ||
54 | if (machine == 'psu_pmu_0'): | ||
55 | cmake_processor = 'pmu_microblaze' | ||
56 | elif (machine in [ 'psv_pmc_0', 'psx_pmc_0' ]): | ||
57 | cmake_processor = 'plm_microblaze' | ||
58 | else: | ||
59 | cmake_processor = 'microblaze' | ||
60 | elif (tune in [ 'cortexr5', 'cortexr5hf' ]): | ||
61 | cmake_processor = 'cortexr5' | ||
62 | elif (tune in [ 'cortexr52', 'cortexr52hf' ]): | ||
63 | cmake_processor = 'cortexr52' | ||
64 | elif tune.startswith('cortexa9'): | ||
65 | cmake_processor = 'cortexa9' | ||
66 | elif (tune in [ 'cortexa53', 'cortexa72-cortexa53' ]): | ||
67 | cmake_processor = 'cortexa53' | ||
68 | elif tune == 'cortexa72': | ||
69 | cmake_processor = 'cortexa72' | ||
70 | if (variant == 'net'): | ||
71 | cmake_processor = 'cortexa78' | ||
72 | return cmake_processor | ||
73 | |||
74 | XLNX_CMAKE_MACHINE = "${@get_xlnx_cmake_machine(d.getVar('SOC_FAMILY'), d.getVar('SOC_VARIANT'), d)}" | ||
75 | XLNX_CMAKE_PROCESSOR = "${@get_xlnx_cmake_processor(d.getVar('DEFAULTTUNE'), d.getVar('ESW_MACHINE'), d.getVar('SOC_VARIANT'), d)}" | ||
76 | XLNX_CMAKE_SYSTEM_NAME ?= "Generic" | ||
77 | XLNX_CMAKE_BSP_VARS ?= "" | ||
78 | |||
79 | cmake_do_generate_toolchain_file:append() { | ||
80 | cat >> ${UNPACKDIR}/toolchain.cmake <<EOF | ||
81 | include(CMakeForceCompiler) | ||
82 | CMAKE_FORCE_C_COMPILER("${OECMAKE_C_COMPILER}" GNU) | ||
83 | CMAKE_FORCE_CXX_COMPILER("${OECMAKE_CXX_COMPILER}" GNU) | ||
84 | set( CMAKE_SYSTEM_PROCESSOR "${XLNX_CMAKE_PROCESSOR}" ) | ||
85 | set( CMAKE_MACHINE "${XLNX_CMAKE_MACHINE}" ) | ||
86 | # Will need this in the future to make cmake understand esw variables | ||
87 | # set( CMAKE_SYSTEM_NAME `echo elf | sed -e 's/^./\u&/' -e 's/^\(Linux\).*/\1/'` ) | ||
88 | set( CMAKE_SYSTEM_NAME "${XLNX_CMAKE_SYSTEM_NAME}" ) | ||
89 | set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${S}/cmake) | ||
90 | set( CMAKE_LIBRARY_PATH ${B}) | ||
91 | if ("${XLNX_CMAKE_PROCESSOR}" STREQUAL "plm_microblaze") | ||
92 | set( CMAKE_BUILD_TYPE Release) | ||
93 | endif() | ||
94 | add_definitions( "${XLNX_CMAKE_BSP_VARS} -DSDT" ) | ||
95 | EOF | ||
96 | } | ||
97 | |||
98 | do_install() { | ||
99 | install -d ${D}${libdir} | ||
100 | install -d ${D}${includedir} | ||
101 | install -m 0755 ${B}/${ESW_COMPONENT_NAME} ${D}${libdir} | ||
102 | install -m 0644 ${B}/include/*.h ${D}${includedir} | ||
103 | } | ||
104 | |||
105 | CFLAGS:append = " ${ESW_CFLAGS}" | ||
106 | EXTRA_OECMAKE += "-DYOCTO=ON" | ||
107 | |||
108 | do_configure:prepend() { | ||
109 | ( | ||
110 | cd ${S} | ||
111 | lopper ${DTS_FILE} -- bmcmake_metadata_xlnx ${ESW_MACHINE} ${S}/lib/bsp/standalone/src/ hwcmake_metadata ${S} | ||
112 | install -m 0755 StandaloneExample.cmake ${S}/cmake/Findcommonmeta.cmake | ||
113 | ) | ||
114 | } | ||
115 | |||
116 | # We need to find the license file, which vaires depending on the component | ||
117 | # recurse a maximum of x times, could be fancier but it gets complicated since | ||
118 | # we dont know for certain we are running devtool or just externalsrc | ||
119 | python(){ | ||
120 | import os.path | ||
121 | if bb.data.inherits_class('externalsrc', d) and d.getVar('EXTERNALSRC'): | ||
122 | externalsrc = d.getVar('EXTERNALSRC') | ||
123 | lic_file = d.getVar('LIC_FILES_CHKSUM', False) | ||
124 | licpath=externalsrc | ||
125 | for i in range(5): | ||
126 | if os.path.isfile(licpath + '/' + d.getVar('LICFILENAME',True)): | ||
127 | lic_file = lic_file.replace('${S}',licpath) | ||
128 | d.setVar('LIC_FILES_CHKSUM', lic_file) | ||
129 | return | ||
130 | licpath=os.path.dirname(licpath) | ||
131 | bb.error("Couldn't find license file: %s, within directory %s or his parent directories" % (d.getVar('LICFILENAME',True), externalsrc)) | ||
132 | } | ||
133 | |||
134 | do_generate_driver_data[dirs] = "${B}" | ||
135 | do_generate_driver_data[depends] += "device-tree:do_deploy" | ||
136 | python do_generate_driver_data() { | ||
137 | import glob, subprocess, os | ||
138 | |||
139 | system_dt = glob.glob(d.getVar('DTS_FILE')) | ||
140 | src_dir = glob.glob(d.getVar('OECMAKE_SOURCEPATH')) | ||
141 | machine = d.getVar('ESW_MACHINE') | ||
142 | |||
143 | driver_name = d.getVar('REQUIRED_MACHINE_FEATURES') | ||
144 | |||
145 | if len(system_dt) == 0: | ||
146 | bb.error("Couldn't find device tree %s" % d.getVar('DTS_FILE')) | ||
147 | |||
148 | if len(src_dir) == 0: | ||
149 | bb.error("Couldn't find source dir %s" % d.getVar('OECMAKE_SOURCEPATH')) | ||
150 | |||
151 | os.chdir(d.getVar('B')) | ||
152 | command = ["lopper"] + ["-f"] + [system_dt[0]] + ["--"] + ["baremetalconfig_xlnx.py"] + [machine] + [src_dir[0]] | ||
153 | subprocess.run(command, check = True) | ||
154 | src_file = glob.glob('*_g.c') | ||
155 | if os.path.exists(src_file[0]): | ||
156 | bb.note("Generated config file for driver %s" % driver_name) | ||
157 | command = ["install"] + ["-m"] + ["0755"] + [src_file[0]] + [src_dir[0]] | ||
158 | subprocess.run(command, check = True) | ||
159 | } | ||
diff --git a/meta-xilinx-standalone-sdt/classes-recipe/esw_apps_common.bbclass b/meta-xilinx-standalone-sdt/classes-recipe/esw_apps_common.bbclass new file mode 100644 index 00000000..134d3cd2 --- /dev/null +++ b/meta-xilinx-standalone-sdt/classes-recipe/esw_apps_common.bbclass | |||
@@ -0,0 +1,31 @@ | |||
1 | # | ||
2 | # Copyright (C) 2024, Advanced Micro Devices, Inc. All rights reserved. | ||
3 | # | ||
4 | # SPDX-License-Identifier: MIT | ||
5 | # | ||
6 | # This bbclass is inherited by esw application recipes. This class provides | ||
7 | # common code for elf name, bitbake install and deploy task functionality for | ||
8 | # multiconfig target images. | ||
9 | |||
10 | inherit deploy image-artifact-names | ||
11 | |||
12 | APP_IMAGE_NAME ?= "${BPN}-${PKGE}-${PKGV}-${PKGR}-${MACHINE}-${BB_CURRENT_MC}${IMAGE_VERSION_SUFFIX}" | ||
13 | |||
14 | ESW_EXECUTABLE_NAME ?= "" | ||
15 | |||
16 | do_install() { | ||
17 | install -d ${D}/${base_libdir}/firmware | ||
18 | # Note that we have to make the ELF executable for it to be stripped | ||
19 | install -m 0755 ${B}/${ESW_EXECUTABLE_NAME}* ${D}/${base_libdir}/firmware | ||
20 | } | ||
21 | |||
22 | do_deploy() { | ||
23 | # We need to deploy the stripped elf, hence why not doing it from ${D} | ||
24 | install -Dm 0644 ${UNPACKDIR}/package/${base_libdir}/firmware/${ESW_EXECUTABLE_NAME}.elf ${DEPLOYDIR}/${APP_IMAGE_NAME}.elf | ||
25 | ln -sf ${APP_IMAGE_NAME}.elf ${DEPLOYDIR}/${BPN}-${MACHINE}-${BB_CURRENT_MC}.elf | ||
26 | ${OBJCOPY} -O binary ${UNPACKDIR}/package/${base_libdir}/firmware/${ESW_EXECUTABLE_NAME}.elf ${UNPACKDIR}/package/${base_libdir}/firmware/${ESW_EXECUTABLE_NAME}.bin | ||
27 | install -m 0644 ${UNPACKDIR}/package/${base_libdir}/firmware/${ESW_EXECUTABLE_NAME}.bin ${DEPLOYDIR}/${APP_IMAGE_NAME}.bin | ||
28 | ln -sf ${APP_IMAGE_NAME}.bin ${DEPLOYDIR}/${BPN}-${MACHINE}-${BB_CURRENT_MC}.bin | ||
29 | } | ||
30 | |||
31 | addtask deploy before do_build after do_package | ||
diff --git a/meta-xilinx-standalone-sdt/classes-recipe/esw_examples.bbclass b/meta-xilinx-standalone-sdt/classes-recipe/esw_examples.bbclass new file mode 100644 index 00000000..ae1a9bbb --- /dev/null +++ b/meta-xilinx-standalone-sdt/classes-recipe/esw_examples.bbclass | |||
@@ -0,0 +1,36 @@ | |||
1 | inherit esw deploy python3native | ||
2 | |||
3 | DEPENDS += "python3-dtc-native python3-pyyaml-native xilstandalone libxil xiltimer" | ||
4 | |||
5 | do_configure:prepend() { | ||
6 | ( | ||
7 | cd ${S} | ||
8 | lopper ${DTS_FILE} -- baremetallinker_xlnx.py ${ESW_MACHINE} ${S}/${ESW_COMPONENT_SRC} | ||
9 | install -m 0755 *.cmake ${S}/${ESW_COMPONENT_SRC}/ | ||
10 | cp -rf ${S}/scripts/linker_files/ ${S}/${ESW_COMPONENT_SRC}/linker_files | ||
11 | ) | ||
12 | } | ||
13 | |||
14 | ESW_CUSTOM_LINKER_FILE ?= "None" | ||
15 | EXTRA_OECMAKE = "-DCUSTOM_LINKER_FILE=${@d.getVar('ESW_CUSTOM_LINKER_FILE')}" | ||
16 | |||
17 | do_generate_eglist () { | ||
18 | cd ${S} | ||
19 | lopper ${DTS_FILE} -- bmcmake_metadata_xlnx.py ${ESW_MACHINE} ${S}/${ESW_COMPONENT_SRC} drvcmake_metadata | ||
20 | install -m 0755 *.cmake ${S}/${ESW_COMPONENT_SRC}/ | ||
21 | } | ||
22 | addtask generate_eglist before do_configure after do_prepare_recipe_sysroot | ||
23 | do_prepare_recipe_sysroot[rdeptask] = "do_unpack" | ||
24 | |||
25 | do_install() { | ||
26 | install -d ${D}/${base_libdir}/firmware | ||
27 | install -m 0755 ${B}/*.elf ${D}/${base_libdir}/firmware | ||
28 | } | ||
29 | |||
30 | do_deploy() { | ||
31 | install -d ${DEPLOYDIR}/${BPN}/ | ||
32 | install -Dm 0644 ${UNPACKDIR}/package/${base_libdir}/firmware/*.elf ${DEPLOYDIR}/${BPN}/ | ||
33 | } | ||
34 | addtask deploy before do_build after do_package | ||
35 | |||
36 | FILES:${PN} = "${base_libdir}/firmware/*.elf" | ||