Remove the obsolete xsct-tarball approach. Instead use a recipe to download and install the xsct-trim components. This contains a custom download and unpack routine so that the prior behave can be mostly preserved.
Note, on a local path, the checksum is now automatically computed and no longer verified. This matches standard YP behavior. A local file is copied to the download directory. This matches the current behavior and is slightly different then the normal YP behavior. Signed-off-by: Mark Hatle <[email protected]> --- .../sanity-meta-xilinx-tools.bbclass | 4 + classes-global/xsct-tarball.bbclass | 164 ------------------ classes-recipe/xsct-tc.bbclass | 2 - classes-recipe/xsct_baremetal_app.bbclass | 2 - classes-recipe/xsct_freertos_app.bbclass | 4 +- classes-recipe/xsctbase.bbclass | 2 +- .../meta-xilinx-tools-default-versions.inc | 2 + conf/layer.conf | 3 - conf/xsct-tarball.inc | 35 +--- recipes-bsp/embeddedsw/esw-bsp.bb | 19 -- recipes-utils/xsct/xsct-native.bb | 111 +++++++++++- 11 files changed, 112 insertions(+), 236 deletions(-) delete mode 100644 classes-global/xsct-tarball.bbclass delete mode 100644 recipes-bsp/embeddedsw/esw-bsp.bb diff --git a/classes-global/sanity-meta-xilinx-tools.bbclass b/classes-global/sanity-meta-xilinx-tools.bbclass index 85d9a38..c88fdd7 100644 --- a/classes-global/sanity-meta-xilinx-tools.bbclass +++ b/classes-global/sanity-meta-xilinx-tools.bbclass @@ -7,4 +7,8 @@ python security_bbappend_distrocheck() { it has not been enabled using XILINX_WITH_ESW in your configuration. Some \ bbappend files and preferred version setting may not take effect. See the \ meta-security README for details on enabling security support.") + elif e.data.getVar('XILINX_WITH_ESW') == 'xsct': + bb.warn("XSCT has been deprecated. It will still be available for \ +several releases. In the future, it's recommended to start new projects \ +with SDT workflow.") } diff --git a/classes-global/xsct-tarball.bbclass b/classes-global/xsct-tarball.bbclass deleted file mode 100644 index 8781379..0000000 --- a/classes-global/xsct-tarball.bbclass +++ /dev/null @@ -1,164 +0,0 @@ -# -# Copyright (C) 2016-2022, Xilinx, Inc. All rights reserved. -# Copyright (C) 2023, Advanced Micro Devices, Inc. All rights reserved. -# -# SPDX-License-Identifier: MIT -# - -require ${@'conf/xsct-tarball.inc' if d.getVar('XILINX_WITH_ESW') == 'xsct' else ''} - -addhandler xsct_event_extract -xsct_event_extract[eventmask] = "bb.event.DepTreeGenerated" - -python xsct_event_extract() { - if d.getVar('XILINX_WITH_ESW') != 'xsct': - return - - def check_xsct_version(): - xsct_path = d.getVar("XILINX_SDK_TOOLCHAIN") - if not os.path.exists(xsct_path): - bb.fatal("XSCT path was not found. This usually means the wrong version of XSCT is\nbeing used.\nUnable to find %s." % xsct_path) - loader = d.getVar("XSCT_LOADER") - if not os.path.exists(loader): - bb.fatal("XSCT binary is not found.\nUnable to find %s." % loader) - - # Only a handful of targets/tasks need XSCT - tasks_xsct = [t + '.do_configure' for t in d.getVar('XSCT_TARGETS').split()] - - xsct_buildtargets = False - for mct in e._depgraph['tdepends']: - t = mct.split(':')[-1] - for x in tasks_xsct: - if t == x: - xsct_buildtargets = True - break - if xsct_buildtargets: - break - - if not xsct_buildtargets and d.getVar('FORCE_XSCT_DOWNLOAD') != '1': - return - - bb.warn("XSCT has been deprecated. It will still be available for several releases. In the future, it's recommended to start new projects with SDT workflow.") - - ext_tarball = d.getVar("EXTERNAL_XSCT_TARBALL") - use_xscttar = d.getVar("USE_XSCT_TARBALL") - chksum_tar_recipe = d.getVar("XSCT_CHECKSUM") - validate = d.getVar("VALIDATE_XSCT_CHECKSUM") - xsct_url = d.getVar("XSCT_URL") - chksum_tar_actual = "" - - if use_xscttar == '0': - if d.getVar('WITHIN_EXT_SDK') != '1': - check_xsct_version() - return - elif d.getVar('WITHIN_EXT_SDK') != '1': - if not ext_tarball and not xsct_url: - bb.fatal('xsct-tarball class is enabled but no external tarball or url is provided.\n\ -\tEither set USE_XSCT_TARBALL to "0" or provide a path/url') - if ext_tarball and os.path.exists(ext_tarball): - bb.note("Checking local xsct tarball checksum") - import hashlib - sha256hash = hashlib.sha256() - readsize = 1024*sha256hash.block_size - with open(ext_tarball, 'rb') as f: - for chunk in iter(lambda: f.read(readsize), b''): - sha256hash.update(chunk) - chksum_tar_actual = sha256hash.hexdigest() - if validate == '1' and chksum_tar_recipe != chksum_tar_actual: - bb.fatal('Provided external tarball\'s sha256sum does not match checksum defined in xsct-tarball class') - elif ext_tarball: - bb.fatal("Unable to find %s" % ext_tarball) - elif xsct_url: - #if fetching the tarball, setting chksum_tar_actual as the one defined in the recipe as the fetcher will fail later otherwise - chksum_tar_actual = chksum_tar_recipe - xsctdldir = d.getVar("XSCT_DLDIR") - tarballname = d.getVar("XSCT_TARBALL") - xsctsysroots = d.getVar("XSCT_STAGING_DIR") - loader = d.getVar("XSCT_LOADER") - - tarballchksum = os.path.join(xsctsysroots, tarballname + ".chksum") - - if os.path.exists(loader) and os.path.exists(tarballchksum): - with open(tarballchksum, "r") as f: - readchksum = f.read().strip() - if readchksum == chksum_tar_actual: - return - - try: - import subprocess - import shutil - tarballpath = os.path.join(xsctdldir, tarballname) - if not os.path.exists(xsctdldir): - bb.utils.mkdirhier(xsctdldir) - - if os.path.exists(ext_tarball): - shutil.copy(ext_tarball, tarballpath) - elif xsct_url: - localdata = bb.data.createCopy(d) - localdata.setVar('FILESPATH', "") - localdata.setVar('DL_DIR', xsctdldir) - srcuri = d.expand("${XSCT_URL};sha256sum=%s;downloadfilename=%s" % (chksum_tar_actual, tarballname)) - bb.note("Fetching xsct binary tarball from %s" % srcuri) - fetcher = bb.fetch2.Fetch([srcuri], localdata) - fetcher.download() - localpath = fetcher.localpath(srcuri) - if localpath != tarballpath and os.path.exists(localpath) and not os.path.exists(tarballpath): - # Follow the symlink behavior from the bitbake fetch2. - # This will cover the case where an existing symlink is broken - # as well as if there are two processes trying to create it - # at the same time. - if os.path.islink(tarballpath): - # Broken symbolic link - os.unlink(tarballpath) - - # Deal with two processes trying to make symlink at once - try: - os.symlink(localpath, tarballpath) - except FileExistsError: - pass - - cmd = d.expand("\ - rm -rf ${XSCT_STAGING_DIR}; \ - mkdir -p ${XSCT_STAGING_DIR}; \ - cd ${XSCT_STAGING_DIR}; \ - tar -xvf ${XSCT_DLDIR}/${XSCT_TARBALL};") - bb.note('Extracting external xsct-tarball to sysroots') - subprocess.check_output(cmd, shell=True) - with open(tarballchksum, "w") as f: - f.write(chksum_tar_actual) - - check_xsct_version() - - except bb.fetch2.BBFetchException as e: - bb.fatal(str(e)) - except RuntimeError as e: - bb.fatal(str(e)) - except subprocess.CalledProcessError as exc: - bb.fatal("Unable to extract xsct tarball: %s" % str(exc)) -} - -# The following two items adjust some functions in populate_sdk_ext, so they are benign when set globally. -# Copy xsct tarball to esdk's download dir, where this class is expecting it to be -python copy_buildsystem:prepend() { - - if bb.data.inherits_class('xsct-tarball', d): - ext_tarball = d.getVar("COPY_XSCT_TO_ESDK") - #including xsct tarball in esdk - if ext_tarball == '1': - import shutil - baseoutpath = d.getVar('SDK_OUTPUT') + '/' + d.getVar('SDKPATH') - xsct_outdir = '%s/downloads/xsct/' % (baseoutpath) - bb.utils.mkdirhier(xsct_outdir) - shutil.copy(os.path.join(d.getVar("DL_DIR"), 'xsct', d.getVar("XSCT_TARBALL")), xsct_outdir) - #not including tarball in esdk - else: - d.setVar('sdk_extraconf','USE_XSCT_TARBALL = "0"') -} - -#Add dir with the tools to PATH -sdk_ext_postinst:append() { - if [ "${COPY_XSCT_TO_ESDK}" = "1" ]; then - echo "export PATH=$target_sdk_dir/tmp/sysroots-xsct/Vitis/${TOOL_VER_MAIN}/bin:\$PATH" >> $env_setup_script - fi -} - diff --git a/classes-recipe/xsct-tc.bbclass b/classes-recipe/xsct-tc.bbclass index ef32dff..de135d2 100644 --- a/classes-recipe/xsct-tc.bbclass +++ b/classes-recipe/xsct-tc.bbclass @@ -5,8 +5,6 @@ # SPDX-License-Identifier: MIT # -XILINX_SDK_TOOLCHAIN ??= "${XSCT_STAGING_DIR}/Vitis/${TOOL_VER_MAIN}" - XSCT_PATH_ADD = "${XILINX_SDK_TOOLCHAIN}/bin:" # When building in a Linux target config, we need to use the provided XSCT diff --git a/classes-recipe/xsct_baremetal_app.bbclass b/classes-recipe/xsct_baremetal_app.bbclass index 67023b7..b42e96c 100644 --- a/classes-recipe/xsct_baremetal_app.bbclass +++ b/classes-recipe/xsct_baremetal_app.bbclass @@ -8,8 +8,6 @@ inherit xsctapp xsctyaml deploy -DEPENDS = "esw-bsp" - # For ZynqMP DR device Baremetal app depends on libmetal. DEPENDS:append:zynqmp-dr = " libmetal" diff --git a/classes-recipe/xsct_freertos_app.bbclass b/classes-recipe/xsct_freertos_app.bbclass index 79b85a1..b03f277 100644 --- a/classes-recipe/xsct_freertos_app.bbclass +++ b/classes-recipe/xsct_freertos_app.bbclass @@ -8,8 +8,6 @@ inherit xsctapp xsctyaml deploy -DEPENDS = "esw-bsp" - # For ZynqMP DR device FreeRTOS app depends on libmetal. DEPENDS:append:zynqmp-dr = " libmetal" @@ -65,4 +63,4 @@ do_deploy() { ln -sf ${XSCTH_BASE_NAME}.elf ${DEPLOYDIR}/${FW_IMAGE_NAME}.elf } -FILES:${PN} += "${nonarch_base_libdir}/firmware/xilinx/${PN}" \ No newline at end of file +FILES:${PN} += "${nonarch_base_libdir}/firmware/xilinx/${PN}" diff --git a/classes-recipe/xsctbase.bbclass b/classes-recipe/xsctbase.bbclass index 9cd5dc6..973132b 100644 --- a/classes-recipe/xsctbase.bbclass +++ b/classes-recipe/xsctbase.bbclass @@ -32,7 +32,7 @@ XSCTH_ARCH ?= "${@bb.utils.contains_any('XSCTH_PROC_IP', ['psu_cortexa53', 'psv_ PROJ_ARG ??= "-ws ${XSCTH_WS} -pname ${XSCTH_PROJ} -rp ${XSCTH_REPO}" HW_ARG ??= "-processor_ip ${XSCTH_PROC_IP} -hdf ${XSCTH_HDF} -arch ${XSCTH_ARCH} ${@['', '-processor ${XSCTH_PROC}'][d.getVar('XSCTH_PROC', True) != '']}" -DEPENDS += 'ncurses-native' +DEPENDS += 'ncurses-native xsct-native' do_configure[vardeps] += "TOOL_VER_MAIN" do_configure[depends] += "virtual/hdf:do_deploy" diff --git a/conf/distro/include/meta-xilinx-tools-default-versions.inc b/conf/distro/include/meta-xilinx-tools-default-versions.inc index 039cd8f..0fbfb92 100644 --- a/conf/distro/include/meta-xilinx-tools-default-versions.inc +++ b/conf/distro/include/meta-xilinx-tools-default-versions.inc @@ -11,3 +11,5 @@ PREFERRED_VERSION_external-hdf ?= "${XILINX_XSCT_VERSION}%" PREFERRED_VERSION_openamp-fw-echo-testd ?= "${XILINX_XSCT_VERSION}%" PREFERRED_VERSION_openamp-fw-mat-muld ?= "${XILINX_XSCT_VERSION}%" PREFERRED_VERSION_openamp-fw-rpc-demo ?= "${XILINX_XSCT_VERSION}%" + +require conf/xsct-tarball.inc diff --git a/conf/layer.conf b/conf/layer.conf index 24b1824..28f7445 100644 --- a/conf/layer.conf +++ b/conf/layer.conf @@ -23,9 +23,6 @@ LAYERSERIES_COMPAT_xilinx-tools = "scarthgap" # Setting SKIP_META_XILINX_STANDALONE_SANITY_CHECK to "1" would skip the bbappend files check. INHERIT += "sanity-meta-xilinx-tools" -# Temporary. USER_CLASSES is evaluted too late. -INHERIT += "xsct-tarball" - # We need to load the ESW and related config components, only if XILINX_WITH_ESW # is in defined in some way. Since we don't know the configuration during # layer.conf load time, we delay using a special bbclass that simply includes diff --git a/conf/xsct-tarball.inc b/conf/xsct-tarball.inc index 4776226..b983e54 100644 --- a/conf/xsct-tarball.inc +++ b/conf/xsct-tarball.inc @@ -7,8 +7,7 @@ TOOL_VER_MAIN ?= "${XILINX_XSCT_VERSION}" TOOL_VER_MAIN[doc] = "XSCT version, usually the same as XILINX_XSCT_VERSION" -XILINX_SDK_TOOLCHAIN ??= "${XSCT_STAGING_DIR}/Vitis/${TOOL_VER_MAIN}" -XSCT_LOADER ?= "${XILINX_SDK_TOOLCHAIN}/bin/xsct" +XILINX_SDK_TOOLCHAIN ??= "${RECIPE_SYSROOT_NATIVE}/Vitis/${TOOL_VER_MAIN}" ESDK_LOCALCONF_ALLOW:append = " XILINX_SDK_TOOLCHAIN" @@ -20,9 +19,6 @@ XSCT_URL[2024.1] = "http://petalinux.xilinx.com/sswreleases/rel-v2024/xsct-trim/ XSCT_URL[2024.2] = "http://petalinux.xilinx.com/sswreleases/rel-v2024/xsct-trim/xsct-2024-2_XXXX.tar.xz" XSCT_URL ?= "${@d.getVarFlag('XSCT_URL', d.getVar('TOOL_VER_MAIN'))}" XSCT_TARBALL ?= "xsct_${TOOL_VER_MAIN}.tar.xz" -XSCT_DLDIR ?= "${DL_DIR}/xsct/" -XSCT_STAGING_DIR ?= "${TOPDIR}/xsct" -BB_HASHEXCLUDE_COMMON += "XSCT_STAGING_DIR" XSCT_CHECKSUM[2022.1] = "e343a8b386398e292f636f314a057076e551a8173723b8ea0bc1bbd879c05259" XSCT_CHECKSUM[2022.2] = "8a3272036ca61f017f357bf6ad9dfbdec6aebb39f43c3ca0cee7ec86ea4c066f" @@ -35,34 +31,5 @@ XSCT_CHECKSUM ?= "${@d.getVarFlag('XSCT_CHECKSUM', d.getVar('TOOL_VER_MAIN'))}" VALIDATE_XSCT_CHECKSUM ?= '1' VALIDATE_XSCT_CHECKSUM[doc] = "Ignore the checksum when set to 0" -USE_XSCT_TARBALL ?= '1' -USE_XSCT_TARBALL[doc] = "Flag to determine whether or not to use the xsct-tarball class. \ -If enabled, the tarball from path EXTERNAL_XSCT_TARBALL is copied to downloads/xsct, and extracted \ -to tmp/sysroots-xsct. XILINX_SDK_TOOLCHAIN is set accordingly to use xsct from this path." - -COPY_XSCT_TO_ESDK ?= "0" -COPY_XSCT_TO_ESDK[doc] = "Flag to determine whether or not to copy the xsct-tarball to the eSDK" - EXTERNAL_XSCT_TARBALL ?= "" EXTERNAL_XSCT_TARBALL[doc] = "Variable that defines where the xsct tarball is stored" - -# Specify which targets actually need to call xsct -XSCT_TARGETS ?= "\ - base-pdi \ - bitstream-extraction \ - device-tree \ - extract-cdo \ - fsbl-firmware \ - fs-boot \ - imgrcry \ - imgsel \ - openamp-fw-echo-testd \ - openamp-fw-mat-muld \ - openamp-fw-rpc-demo \ - plm-firmware \ - pmu-firmware \ - psm-firmware \ - uboot-device-tree \ - esw-bsp \ - xsct-native \ - " diff --git a/recipes-bsp/embeddedsw/esw-bsp.bb b/recipes-bsp/embeddedsw/esw-bsp.bb deleted file mode 100644 index 094c70d..0000000 --- a/recipes-bsp/embeddedsw/esw-bsp.bb +++ /dev/null @@ -1,19 +0,0 @@ -SUMMARY = "EmbeddedSW BSP to export xsct tool to build baremetal or freertos app" -LICENSE = "MIT" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" - -inherit xsctapp - -COMPATIBLE_MACHINE:zynq = ".*" -COMPATIBLE_MACHINE:zynqmp = ".*" -COMPATIBLE_MACHINE:versal = ".*" - -PACKAGE_ARCH = "${MACHINE_ARCH}" - -PARALLEL_MAKE = "-j1" - -do_patch[noexec] = "1" -do_configure[noexec] = "1" -do_compile[noexec] = "1" -do_install[noexec] = "1" -do_deploy[noexec] = "1" \ No newline at end of file diff --git a/recipes-utils/xsct/xsct-native.bb b/recipes-utils/xsct/xsct-native.bb index 10d41a6..71000ac 100644 --- a/recipes-utils/xsct/xsct-native.bb +++ b/recipes-utils/xsct/xsct-native.bb @@ -2,16 +2,111 @@ SUMMARY = "Trigger XSCT to download and install" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" +PV = "${TOOL_VER_MAIN}" + INHIBIT_DEFAULT_DEPS = "1" +BB_STRICT_CHECKSUM = "${VALIDATE_XSCT_CHECKSUM}" + +SRC_URI = "${XSCT_URL};downloadfilename=${XSCT_TARBALL}" +SRC_URI[sha256sum] = "${XSCT_CHECKSUM}" + inherit native -# If the user called us, lets attempt to do "nothing" to trigger the download/verification event -BB_DONT_CACHE = '1' +S = "${UNPACKDIR}/Vitis" +B = "${S}" + +SYSROOT_DIRS_NATIVE += "${STAGING_DIR_NATIVE}/Vitis/${PV}" + +# Based on poky/meta/classes-global/base.bbclass +python do_fetch() { + src_uri = (d.getVar('SRC_URI') or "").split() + if not src_uri: + return + + try: + for uri in src_uri: + if uri.startswith("file://"): + import shutil + fn = uri.split("://")[1].split(";")[0] + dfn = uri.split(";downloadfilename=")[1].split(";")[0] + shutil.copy(fn, os.path.join(d.getVar('DL_DIR'), dfn)) + else: + fetcher = bb.fetch2.Fetch([uri], d) + fetcher.download() + except bb.fetch2.BBFetchException as e: + bb.fatal("Bitbake Fetcher Error: " + repr(e)) +} + +# Based on poky/meta/classes-global/base.bbclass +python do_unpack() { + import shutil + + sourcedir = d.getVar('S') + # Intentionally keep SOURCE_BASEDIR internal to the task just for SDE + d.setVar("SOURCE_BASEDIR", sourcedir) + + src_uri = (d.getVar('SRC_URI') or "").split() + if not src_uri: + return + + basedir = None + unpackdir = d.getVar('UNPACKDIR') + workdir = d.getVar('WORKDIR') + if sourcedir.startswith(workdir) and not sourcedir.startswith(unpackdir): + basedir = sourcedir.replace(workdir, '').strip("/").split('/')[0] + if basedir: + bb.utils.remove(workdir + '/' + basedir, True) + d.setVar("SOURCE_BASEDIR", workdir + '/' + basedir) + + try: + for uri in src_uri: + if uri.startswith("file://"): + fn = uri.split("://")[1].split(";")[0] + dfn = uri.split(";downloadfilename=")[1].split(";")[0] + local_uri = "file://" + os.path.join(d.getVar('DL_DIR'), dfn) + else: + local_uri = uri + + fetcher = bb.fetch2.Fetch([local_uri], d) + fetcher.unpack(d.getVar('UNPACKDIR')) + except bb.fetch2.BBFetchException as e: + bb.fatal("Bitbake Fetcher Error: " + repr(e)) + + if basedir and os.path.exists(unpackdir + '/' + basedir): + # Compatibility magic to ensure ${WORKDIR}/git and ${WORKDIR}/${BP} + # as often used in S work as expected. + shutil.move(unpackdir + '/' + basedir, workdir + '/' + basedir) +} + +XSCT_LOADER ?= "${XILINX_SDK_TOOLCHAIN}/bin/xsct" + +# Remove files we don't want +do_compile() { + # Validation routines + if [ ! -d ${PV} ]; then + bbfatal "XSCT version mismatch.\nUnable to find `pwd`/${PV}.\nThis usually means the wrong version of XSCT is being used." + fi + + if [ ! -e ${PV}/bin/xsct ]; then + bbfatal "XSCT binary is not found.\nUnable to find `pwd`/${PV}/bin/xsct." + fi +} + +do_install() { + install -d ${D}${STAGING_DIR_NATIVE}/Vitis + cp --preserve=mode,timestamps -R ${S}/* ${D}${STAGING_DIR_NATIVE}/Vitis/. +} + +# If the user overrides with EXTERNAL_XSCT_TARBALL, use it instead +python() { + ext_tarball = d.getVar("EXTERNAL_XSCT_TARBALL") + + if ext_tarball: + d.setVar('XSCT_URL', 'file://${EXTERNAL_XSCT_TARBALL}') +} + +ERROR_QA:remove = "already-stripped" +INSANE_SKIP += "already-stripped" +INHIBIT_SYSROOT_STRIP = "1" -do_fetch[noexec] = "1" -do_patch[noexec] = "1" -do_configure[noexec] = "1" -do_compile[noexec] = "1" -do_install[noexec] = "1" -do_deploy[noexec] = "1" -- 2.34.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#5407): https://lists.yoctoproject.org/g/meta-xilinx/message/5407 Mute This Topic: https://lists.yoctoproject.org/mt/106609998/21656 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/meta-xilinx/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
