From 0ab5b8e55f2b13e43f1bcaeb4c88942741357e6a Mon Sep 17 00:00:00 2001 From: liujunxian Date: Fri, 20 Oct 2023 10:56:50 +0800 Subject: [PATCH 1/2] yocto: add uniproton support add uniproton support Signed-off-by: liujunxian --- rtos/meta-openeuler-rtos/conf/layer.conf | 2 + rtos/meta-uniproton/README.md | 23 +++ rtos/meta-uniproton/conf/layer.conf | 17 +++ .../recipes-kernel/uniproton.bb | 137 ++++++++++++++++++ 4 files changed, 179 insertions(+) create mode 100644 rtos/meta-uniproton/README.md create mode 100644 rtos/meta-uniproton/conf/layer.conf create mode 100644 rtos/meta-uniproton/recipes-kernel/uniproton.bb diff --git a/rtos/meta-openeuler-rtos/conf/layer.conf b/rtos/meta-openeuler-rtos/conf/layer.conf index ed082d86914..ea0341890b4 100644 --- a/rtos/meta-openeuler-rtos/conf/layer.conf +++ b/rtos/meta-openeuler-rtos/conf/layer.conf @@ -18,6 +18,8 @@ BBFILE_PATTERN_IGNORE_EMPTY_openeuler-rtos = "1" BBFILES_DYNAMIC += " \ rtthread:${LAYERDIR}/rtthread/*.bb \ rtthread:${LAYERDIR}/rtthread/*.bbappend \ +uniproton:${LAYERDIR}/uniproton/*.bb \ +uniproton:${LAYERDIR}/uniproton/*.bbappend \ " # Most rtos can't be built directly with xxx-linux-gcc toolchain, because of C library # A baremetal gcc toolchain is needed. The following variables are used to diff --git a/rtos/meta-uniproton/README.md b/rtos/meta-uniproton/README.md new file mode 100644 index 00000000000..9cec816f8a0 --- /dev/null +++ b/rtos/meta-uniproton/README.md @@ -0,0 +1,23 @@ +# UniProton 构建支持 + +本元构建层(meta-layer)包含了在openEuler Yocto构建环境下集成构建UniProton的相关配置和配方。 + +## 使用 + +1. 当前支持x86_64版本编译构建,构建时自动下载master分支最新代码,如需固定版本,需修改bb文件。 + +2. 在rtos/meta-openeuler-rtos/conf/layer.conf中添加相应的元构建层 + +``` + BBFILES_DYNAMIC += " \ + uniproton:${LAYERDIR}/uniproton/*.bb \ + uniproton:${LAYERDIR}/uniproton/*.bbappend \ + " +``` + +3. 构建UniProton. +``` + bitbake uniproton +``` + +UniProton构建的结果文件会安装在/lib/firmware目录,并打包成rpm文件。 diff --git a/rtos/meta-uniproton/conf/layer.conf b/rtos/meta-uniproton/conf/layer.conf new file mode 100644 index 00000000000..e244fd45306 --- /dev/null +++ b/rtos/meta-uniproton/conf/layer.conf @@ -0,0 +1,17 @@ +# We have a conf and classes directory, add to BBPATH +BBPATH .= ":${LAYERDIR}" + +# We have recipes-* directories, add to BBFILES +BBFILES += "${LAYERDIR}/recipes-*/*.bb \ + ${LAYERDIR}/recipes-*/*.bbappend" + +BBFILE_COLLECTIONS += "uniproton" +BBFILE_PATTERN_uniproton = "^${LAYERDIR}/" +BBFILE_PRIORITY_uniproton = "24" + +LAYERVERSION_uniproton = "1" + +LAYERDEPENDS_uniproton = "core" + +LAYERSERIES_COMPAT_uniproton = "kirkstone" + diff --git a/rtos/meta-uniproton/recipes-kernel/uniproton.bb b/rtos/meta-uniproton/recipes-kernel/uniproton.bb new file mode 100644 index 00000000000..e9523b645dc --- /dev/null +++ b/rtos/meta-uniproton/recipes-kernel/uniproton.bb @@ -0,0 +1,137 @@ +### Descriptive metadata: SUMMARY,DESCRITPION, HOMEPAGE, AUTHOR, BUGTRACKER +SUMMARY = "UniProton " +DESCRITPION = "A lightweight real-time operating system" +AUTHOR = "" +HOMEPAGE = "https://gitee.com/openeuler/UniProton" +BUGTRACKER = "https://gitee.com/openeuler/yocto-meta-openeuler" +### Package manager metadata: SECTION, PRIOIRTY(only for deb, opkg) +SECTION = "RTOS" +PN = "uniproton" +PV = "1" + +### License metadata +LICENSE = "MulanPSL-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=c7ea843127ff6afcb5f768497eb60f0a" + +### Build metadata: SRC_URI, SRCDATA, S, B, FILESEXTRAPATHS.... +SRC_URI = "git://gitee.com/openeuler/UniProton.git;branch=master;protocol=https \ + git://gitee.com/openeuler/libboundscheck.git;branch=master;protocol=https;name=libboundscheck;destsuffix=git/libboundscheck \ + git://gitee.com/src-openeuler/libmetal.git;branch=master;protocol=https;name=libmetal;destsuffix=git/libmetal \ + git://gitee.com/src-openeuler/OpenAMP.git;branch=master;protocol=https;name=openamp;destsuffix=git/openamp \ + git://gitlab.com/Tim-Tianyu/ethercat.git;branch=master;protocol=https;name=ethercat;destsuffix=git/ethercat " + +SRCREV="${AUTOREV}" +SRCREV_FORMAT="default_heads" +S = "${WORKDIR}/git" + + +def get_uniproton_cpu_type(d): + + supported_machine = { + "generic_x86_64": "x86_64", + } + + machine = d.getVar("MACHINE_ARCH",True) + + if not machine in supported_machine: + bb.error("unsupported target arch:%s" % machine) + return "" + + return supported_machine[machine] + +UNIPROTON_CPUTYPE = "${@get_uniproton_cpu_type(d)}" + +def get_uniproton_bsp(d): + + return "demos/" + get_uniproton_cpu_type(d) + "/build" + +UNIPROTON_BSPDIR = "${@get_uniproton_bsp(d)}" + +# alias package name +PROVIDES += "uniproton" + +### Runtime metadata +PACKAGES = "${PN}" +### Package metadata +FILES:${PN} = " \ + /lib/firmware \ +" + +# bypass package_qa as the deleted LDFLAGS will cause error +do_package_qa() { + echo "do package qa" +} + +# bypass configure as UniProton has no configure phase +do_configure() { + echo "do configure" +} + +# downloaded code preprocessing +prepare_compile() { + download_dir=$1 + + if [ -d "${download_dir}/ethercat" ] + then + mv ${download_dir}/ethercat ${download_dir}/src/net/ethercat + fi + if [ -d "${download_dir}/libboundscheck" ] + then + rm -rf ${download_dir}/platform/libboundscheck + mv ${download_dir}/libboundscheck ${download_dir}/platform + fi + if [ -d "${download_dir}/libmetal" ] + then + pushd ${download_dir}/libmetal + tar -zxvf libmetal-2022.10.0.tar.gz + mv ./libmetal-2022.10.0 ./libmetal + cp ${download_dir}/${UNIPROTON_BSPDIR}/../component/UniProton-patch-for-libmetal.patch ./libmetal/ + cd libmetal + patch -p1 -d . < UniProton-patch-for-libmetal.patch + cd ../ + mv ./libmetal ${download_dir}/${UNIPROTON_BSPDIR}/../component/ + cd ../ + rm -rf libmetal + popd + fi + if [ -d "${download_dir}/openamp" ] + then + pushd ${download_dir}/openamp + tar -zxvf openamp-2022.10.1.tar.gz + mv ./openamp-2022.10.1 ./open-amp + cp ${download_dir}/${UNIPROTON_BSPDIR}/../component/UniProton-patch-for-openamp.patch ./open-amp/ + cd open-amp + patch -p1 -d . < UniProton-patch-for-openamp.patch + cd ../ + mv ./open-amp ${download_dir}/${UNIPROTON_BSPDIR}/../component/ + cd ../ + rm -rf openamp + popd + fi +} + +build_ap_boot() { + if [ ${UNIPROTON_CPUTYPE} != "x86_64" ] + then + return + fi + cd ${download_dir}/${UNIPROTON_BSPDIR}/../ap_boot + make +} + +do_compile() { + prepare_compile ${S} + build_ap_boot + cd ${S}/${UNIPROTON_BSPDIR} + sh build_app.sh all yocto +} + +do_install() { + install -d ${D}/lib/firmware + install -m 644 -D ${S}/${UNIPROTON_BSPDIR}/*.bin ${D}/lib/firmware + install -m 644 -D ${S}/${UNIPROTON_BSPDIR}/*.elf ${D}/lib/firmware + if [ ${UNIPROTON_CPUTYPE} == "x86_64" ] + then + install -m 644 -D ${S}/${UNIPROTON_BSPDIR}/../ap_boot/ap_boot ${D}/lib/firmware + fi +} -- Gitee From 643ada001fec6d1a9d7f58ad11f425019b7bd0a3 Mon Sep 17 00:00:00 2001 From: liujunxian Date: Tue, 21 Nov 2023 10:48:09 +0800 Subject: [PATCH 2/2] yocto: UniProton use manifest to download download UniProton third-party libraries that rely on manifest method Signed-off-by: liujunxian --- .../recipes-kernel/uniproton.bb | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/rtos/meta-uniproton/recipes-kernel/uniproton.bb b/rtos/meta-uniproton/recipes-kernel/uniproton.bb index e9523b645dc..29d181d037a 100644 --- a/rtos/meta-uniproton/recipes-kernel/uniproton.bb +++ b/rtos/meta-uniproton/recipes-kernel/uniproton.bb @@ -14,16 +14,19 @@ LICENSE = "MulanPSL-2.0" LIC_FILES_CHKSUM = "file://LICENSE;md5=c7ea843127ff6afcb5f768497eb60f0a" ### Build metadata: SRC_URI, SRCDATA, S, B, FILESEXTRAPATHS.... -SRC_URI = "git://gitee.com/openeuler/UniProton.git;branch=master;protocol=https \ - git://gitee.com/openeuler/libboundscheck.git;branch=master;protocol=https;name=libboundscheck;destsuffix=git/libboundscheck \ - git://gitee.com/src-openeuler/libmetal.git;branch=master;protocol=https;name=libmetal;destsuffix=git/libmetal \ - git://gitee.com/src-openeuler/OpenAMP.git;branch=master;protocol=https;name=openamp;destsuffix=git/openamp \ - git://gitlab.com/Tim-Tianyu/ethercat.git;branch=master;protocol=https;name=ethercat;destsuffix=git/ethercat " - +SRC_URI:append:x86-64 = "git://gitee.com/openeuler/UniProton.git;branch=master;protocol=https \ + git://gitlab.com/Tim-Tianyu/ethercat.git;branch=master;protocol=https;name=ethercat;destsuffix=git/ethercat \ + git://gitee.com/zuyiwen/libcxx.git;branch=master;protocol=https;name=libcxx;destsuffix=git/libcxx \ + file://libboundscheck \ + file://libmetal \ + file://OpenAMP \ + " SRCREV="${AUTOREV}" SRCREV_FORMAT="default_heads" S = "${WORKDIR}/git" +OPENEULER_SRC_DIR = "/usr1/openeuler/src" +do_fetch[depends] += "libboundscheck:do_fetch libmetal:do_fetch openamp:do_fetch" def get_uniproton_cpu_type(d): @@ -75,16 +78,25 @@ prepare_compile() { then mv ${download_dir}/ethercat ${download_dir}/src/net/ethercat fi - if [ -d "${download_dir}/libboundscheck" ] + if [ -d "${download_dir}/libcxx" ] + then + mv ${download_dir}/libcxx ${download_dir}/${UNIPROTON_BSPDIR}/../component/ + fi + if [ -d "${OPENEULER_SRC_DIR}/libboundscheck" ] then rm -rf ${download_dir}/platform/libboundscheck - mv ${download_dir}/libboundscheck ${download_dir}/platform + pushd ${OPENEULER_SRC_DIR}/libboundscheck + tar -zxf libboundscheck*.tar.gz + find . -maxdepth 1 -name "libboundscheck*" -type d | xargs -I {} mv {} ${download_dir}/platform/libboundscheck + popd fi - if [ -d "${download_dir}/libmetal" ] + if [ -d "${OPENEULER_SRC_DIR}/libmetal" ] then + cp -r ${OPENEULER_SRC_DIR}/libmetal ${download_dir}/libmetal pushd ${download_dir}/libmetal - tar -zxvf libmetal-2022.10.0.tar.gz - mv ./libmetal-2022.10.0 ./libmetal + find . -maxdepth 1 -name "libmetal*" -type d | xargs -I {} rm -rf {} + tar -zxvf libmetal-*.tar.gz + find . -maxdepth 1 -name "libmetal*" -type d | xargs -I {} mv {} libmetal cp ${download_dir}/${UNIPROTON_BSPDIR}/../component/UniProton-patch-for-libmetal.patch ./libmetal/ cd libmetal patch -p1 -d . < UniProton-patch-for-libmetal.patch @@ -94,11 +106,12 @@ prepare_compile() { rm -rf libmetal popd fi - if [ -d "${download_dir}/openamp" ] + if [ -d "${OPENEULER_SRC_DIR}/OpenAMP" ] then + cp -r ${OPENEULER_SRC_DIR}/OpenAMP ${download_dir}/openamp pushd ${download_dir}/openamp tar -zxvf openamp-2022.10.1.tar.gz - mv ./openamp-2022.10.1 ./open-amp + find . -maxdepth 1 -name "openamp*" -type d | xargs -I {} mv {} open-amp cp ${download_dir}/${UNIPROTON_BSPDIR}/../component/UniProton-patch-for-openamp.patch ./open-amp/ cd open-amp patch -p1 -d . < UniProton-patch-for-openamp.patch -- Gitee