OBMC 添加一个新的recipe

编程入门 行业动态 更新时间:2024-10-18 16:46:18

OBMC 添加一个新的<a href=https://www.elefans.com/category/jswz/34/1531937.html style=recipe"/>

OBMC 添加一个新的recipe

OBMC 添加一个新的recipe

obmc用的是yocto进行编译。

代码结构如下:

[penghu4x@bmcdev-S2600WF0dsg-openbmc-openbmc$ ls
bitbake       meta-amd        meta-google         meta-lenovo        meta-qualcomm     meta-yadro          setup
build         meta-ampere     meta-hpe            meta-microsoft     meta-quanta       oe-init-build-env   vscode-bitbake-build
code          meta-arm        meta-hxt            meta-nuvoton       meta-raspberrypi  openbmc-env
Jenkinsfile   meta-aspeed     meta-ibm            meta-openembedded  meta-security     openbmc-meta-xxx
LICENSE       meta-bytedance  meta-ingrasys       meta-openpower     meta-skeleton     OWNERS
MAINTAINERS   meta-evb        meta-inspur         meta-phosphor      meta-supermicro   poky
meta          meta-facebook   meta-xxx-openbmc  meta-poky          meta-x86          README.md
meta-alibaba  meta-fii        meta-inventec       meta-portwell      meta-xilinx       scripts
[penghu4x@bmcdev-S2600WF0dsg-openbmc-openbmc$ ls ./openbmc-meta-xxx/
CODEOWNERS  COPYING.apache-2.0  files        meta-ast2500  meta-common        meta-egs       meta-wht       README
conf        COPYING.MIT         Jenkinsfile  meta-ast2600  meta-common-small  meta-internal  meta-wolfpass  README.md

如何在项目中添加一个新的功能库呢?

1. 本地代码开发

在dsg-openbmc-openbmc目录下新建一个code文件夹,用来存放代码。

[penghu4x@bmcdev-S2600WF0helloyocto$ pwd
/media/disk3/penghu4x/work/dsg-openbmc-openbmc/code/helloyocto
[penghu4x@bmcdev-S2600WF0helloyocto$ ls
cmake  CMakeLists.txt  main.c  oe-logs  oe-workdir

添加main.c

#include <stdio.h>int main (int argc, char **argv)
{printf ("Hello Yocto!\n");return 0;
} /* ----- End of main() ----- */

添加cmake,yocto支持cmake、meson、makefile

cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
project(helloyocto C)
AUX_SOURCE_DIRECTORY(. SRC_LIST)
add_executable (helloyocto ${SRC_LIST})install(TARGETS helloyocto DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)

在功能目录下用devtool命令添加新的repo,

devtool add hello ../code/hello 其中 hello是repo的名字, …/code/hello 是代码的路径。

命令执行完成后会有提示:‘Recipe /media/disk3/penghu4x/work/dsg-openbmc-openbmc/build/workspace/recipes/hello/hello.bb has been automatically created’

[penghu4x@bmcdev-S2600WF0dsg-openbmc-openbmc$ export TEMPLATECONF=openbmc-meta-xxx/meta-egs/conf
[penghu4x@bmcdev-S2600WF0dsg-openbmc-openbmc$ source ./oe-init-build-env
Common targets are:xxxx-platformsobmc-phosphor-imageqemu-helper-nativevirtual/kernelphosphor-ipmi-host
[penghu4x@bmcdev-S2600WF0build$ devtool add hello ../code/hello
NOTE: Starting bitbake server...
WARNING: Duplicate inclusion for /media/disk3/penghu4x/work/dsg-openbmc-openbmc/meta/conf/distro/include/security_flags.inc in /media/disk3/penghu4x/work/dsg-openbmc-openbmc/meta-phosphor/conf/distro/include/phosphor-defaults.inc
NOTE: Starting bitbake server...
WARNING: Duplicate inclusion for /media/disk3/penghu4x/work/dsg-openbmc-openbmc/meta/conf/distro/include/security_flags.inc in /media/disk3/penghu4x/work/dsg-openbmc-openbmc/meta-phosphor/conf/distro/include/phosphor-defaults.inc
NOTE: Reconnecting to bitbake server...
NOTE: Retrying server connection (#1)...
NOTE: Reconnecting to bitbake server...
NOTE: Reconnecting to bitbake server...
NOTE: Retrying server connection (#1)...
NOTE: Retrying server connection (#1)...
NOTE: Starting bitbake server...
WARNING: Duplicate inclusion for /media/disk3/penghu4x/work/dsg-openbmc-openbmc/meta/conf/distro/include/security_flags.inc in /media/disk3/penghu4x/work/dsg-openbmc-openbmc/meta-phosphor/conf/distro/include/phosphor-defaults.inc
INFO: Recipe /media/disk3/penghu4x/work/dsg-openbmc-openbmc/build/workspace/recipes/hello/hello.bb has been automatically created; further editing may be required to make it fully functional

之后用命令devtool编译代码: devtool build hello

-h 可以显示帮助信息,其中-c是clean。

[penghu4x@bmcdev-S2600WF0hello$ devtool build hello -h
NOTE: Starting bitbake server...
WARNING: Duplicate inclusion for /media/disk3/penghu4x/work/dsg-openbmc-openbmc/meta/conf/distro/include/security_flags.inc in /media/disk3/penghu4x/work/dsg-openbmc-openbmc/meta-phosphor/conf/distro/include/phosphor-defaults.inc
usage: devtool build [-h] [-s] [-c] recipenameBuilds the specified recipe using bitbake (up to and including do_populate_sysroot, do_packagedata)arguments:recipename            Recipe to buildoptions:-h, --help            show this help message and exit-s, --disable-parallel-makeDisable make parallelism-c, --clean           clean up recipe building results

至此,hello功能基本完成。

可以把bb文件加到meta中,把hello代码提交到gitlab中。

之后可以用devtool reset hello, 把该repo从当前工作环境中移除。

2. 添加bb文件到meta中

把之前生成的bb文件复制到一个meta目录中,具体路径需要根据你的功能去选择meta文件夹。

bb文件内容如下:

[penghu4x@bmcdev-S2600WF0hello$ cat /media/disk3/penghu4x/work/dsg-openbmc-openbmc/build/workspace/recipes/hello/hello.bb
# Recipe created by recipetool
# This is the basis of a recipe and may need further editing in order to be fully functional.
# (Feel free to remove these comments when editing.)# Unable to find any files that looked like license statements. Check the accompanying
# documentation and source headers and set LICENSE and LIC_FILES_CHKSUM accordingly.
#
# NOTE: LICENSE is being set to "CLOSED" to allow you to at least start building - if
# this is not accurate with respect to the licensing of the software being built (it
# will not be in most cases) you must specify the correct value before using this
# recipe for anything other than initial testing/development!
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""# No information for SRC_URI yet (only an external source tree was specified)
SRC_URI = ""inherit cmake# Specify any options you want to pass to cmake using EXTRA_OECMAKE:
EXTRA_OECMAKE = ""

其中license,在代码开发过程中,添加license文件,重新devtool add的时候会生成相应的cheksum

SRC_URI:在提交代码到gitlab后,从新devtool add 会生成相应的gitlab地址,并会添加SRCREV指定commit的id。

# Modify these as desired
PV = "1.0+git${SRCPV}"
SRCREV = "4a5c117d03d91a7a0a59c4eee4ad3f099f0099a8"S = "${WORKDIR}/git"

更多推荐

OBMC 添加一个新的recipe

本文发布于:2024-02-05 08:23:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1673767.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:OBMC   recipe

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!