bitbake 使用指南

 stamps 目录。
2.3.1 staging 目录

软件包 B 在构建时可能依赖软件包 A 提供的头文件、库文件,也可能要使用软件包 C 生成的工具。staging 目录就是放这些输出文件的地方。
我们必须在配方文件中用“DEPENDS”变量声明构建时的依赖关系。bitbake 就会在构建软件包 B 前先构建软件包 A 和软件包 C,并将软件包 B 需要的头文件、库文件、和工具放在 staging 目录。这样,在构建软件包时,就可以从 staging 目录得到需要的头文件、库文件和工具。
2.3.2 work 目录

所有软件包的解包、打补丁、配置、编译、安装等工作都是在 work 目录进行的。所以 work 目录包含了整个嵌入式系统的完整源代码。
work 目录下按照硬件平台、发行人、目标平台的不同又分了几个目录。所有软件包都被放在对应的子目录中,每个软件包都有一个独立的目录。因为软件包总是根据一个配方文件构建的,所以软件包所在的目录就是对应配方文件的工作目录。在讨论 bitbake 和配方文件时我们还会回来,更仔细地观察配方文件的工作。
2.3.3 deploy 目录

这是保存输出成果的目录。其中 images 目录保存构建成功后产生的文件系统映像、内核映像,ipk 目录保存每个软件包的安装包。我们在修改、构建软件包后,可以在目标平台手工安装 ipk 目录下的对应安装包,确认没有问题后,再制作文件系统映像。
2.3.4 stamps 目录

和 work 目录类似,stamp 目录也按照硬件平台、发行人、目标平台的不同又分了几个子目录。软件包在完成每个 bitbake 任务后都会在对应子目录里 touch 一个对应任务的时间戳,有时我们会手工删除某个软件包的时间戳,强制 bitbake 重新构建这个软件包。
2.3.5 sources 目录

OE 环境的 sources 目录是一个储藏间,用来放从网上下载的源代码包。fetch 任务负责下载代码,放到 sources 目录。
3. BitBake 命令
3.1 查看 bitbake 命令

$ bitbake -h
Usage: bitbake [options] [recipename/target recipe:do_task ...]

    Executes the specified task (default is 'build') for a given set of target recipes (.bb files).
    It is assumed there is a conf/bblayers.conf available in cwd or in BBPATH which
    will provide the layer, BBFILES and other configuration information.

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -b BUILDFILE, --buildfile=BUILDFILE
                        Execute tasks from a specific .bb recipe directly.
                        WARNING: Does not handle any dependencies from other
                        recipes.
  -k, --continue        Continue as much as possible after an error. While the
                        target that failed and anything depending on it cannot
                        be built, as much as possible will be built before
                        stopping.
  -a, --tryaltconfigs   Continue with builds by trying to use alternative
                        providers where possible.
  -f, --force           Force the specified targets/task to run (invalidating
                        any existing stamp file).
  -c CMD, --cmd=CMD     Specify the task to execute. The exact options
                        available depend on the metadata. Some examples might
                        be 'compile' or 'populate_sysroot' or 'listtasks' may
                        give a list of the tasks available.
  -C INVALIDATE_STAMP, --clear-stamp=INVALIDATE_STAMP
                        Invalidate the stamp for the specified task such as
                        'compile' and then run the default task for the
                        specified target(s).
  -r PREFILE, --read=PREFILE
                        Read the specified file before bitbake.conf.
  -R POSTFILE, --postread=POSTFILE
                        Read the specified file after bitbake.conf.
  -v, --verbose         Output more log message data to the terminal.
  -D, --debug           Increase the debug level. You can specify this more
                        than once.
  -n, --dry-run         Don't execute, just go through the motions.
  -S SIGNATURE_HANDLER, --dump-signatures=SIGNATURE_HANDLER
                        Dump out the signature construction information, with
                        no task execution. The SIGNATURE_HANDLER parameter is
                        passed to the handler. Two common values are none and
                        printdiff but the handler may define more/less. none
                        means only dump the signature, printdiff means compare
                        the dumped signature with the cached one.
  -p, --parse-only      Quit after parsing the BB recipes.
  -s, --show-versions   Show current and preferred versions of all recipes.
  -e, --environment     Show the global or per-recipe environment complete
                        with information about where variables were
                        set/changed.
  -g, --graphviz        Save dependency tree information for the specified
                        targets in the dot syntax.
  -I EXTRA_ASSUME_PROVIDED, --ignore-deps=EXTRA_ASSUME_PROVIDED
                        Assume these dependencies don't exist and are already
                        provided (equivalent to ASSUME_PROVIDED). Useful to
                        make dependency graphs more appealing
  -l DEBUG_DOMAINS, --log-domains=DEBUG_DOMAINS
                        Show debug logging for the specified logging domains
  -P, --profile         Profile the command and save reports.
  -u UI, --ui=UI        The user interface to use (depexp, goggle, knotty or
                        ncurses - default knotty).
  -t SERVERTYPE, --servertype=SERVERTYPE
                        Choose which server type to use (process or xmlrpc -
                        default process).
  --token=XMLRPCTOKEN   Specify the connection token to be used when
                        connecting to a remote server.
  --revisions-changed   Set the exit code depending on whether upstream
                        floating revisions have changed or not.
  --server-only         Run bitbake without a UI, only starting a server
                        (cooker) process.
  -B BIND, --bind=BIND  The name/address for the bitbake server to bind to.
  --no-setscene         Do not run any setscene tasks. sstate will be ignored
                        and everything needed, built.
  --setscene-only       Only run setscene tasks, don't run any real tasks.
  --remote-server=REMOTE_SERVER
                        Connect to the specified server.
  -m, --kill-server     Terminate the remote server.
  --observe-only        Connect to a server as an observing-only client.
  --status-only         Check the status of the remote bitbake server.
  -w WRITEEVENTLOG, --write-log=WRITEEVENTLOG
                        Writes the event log of the build to a bitbake event
                        json file. Use '' (empty string) to assign the name
                        automatically.

 

3.2 bitbake 常用命令
BitBake 参数     描述     示例     备注
<target>     直接编译/执行一个 recipe     bitbake core-image-minimal     
-c <task> <target>     执行某个 recipe 的某个任务     bitbake -c build glibc     示例表示执行 glibc 的 do_build 任务

<task>表示要执行的任务:
fetch 表示从 recipe 中定义的地址拉取软件到本地
compile 表示重新编译镜像或软件包
deploy 表示部署镜像或软件包到目标 rootfs 内
cleanall 表示清空整个构建目录
-c listtasks <target>     显示某个 recipe 可执行的任务     bitbake -c listtasks glibc     如果你不确定 target 支持哪些任务,就可以用 listtasks 来查询
-b <xx.bb>     用BitBake直接执行这个.bb文件     bitbake -b rtl8188eu-driver_0.1.bb     单独编译 rtl8188eu-driver 任务
-k     有错误发生时也继续构建         
-e <target>     显示当前的执行环境     查找包的原路径:
bitbake -e hello | grep ^SRC_URI
查找包的安装路径:
bitbake -e hello | grep ^S=     
-s     显示所有可以 bitbake 的包     bitbake -s | grep hello     例如如果自己在一个Layer下面安装了一个hello.bb,可以查看 hello 这个 package 能否被 bitbake
-v     显示执行过程         
-vDDDD     打印一些调试信息(v 后面可以加多个 D)     bitbake -vDDDD -c build glibc     
-g <target>     显示一个包在 BitBake 时与其他包的依赖关系,生成依赖图     bitbake -g glibc     在当前目录生成一些文件:
task-depends.dot(任务之间的依赖关系)
package-depends.dot(运行时的目标依赖)
pn-depends.dot(构建时的依赖)
pn-buildlist(包含需要构建的任务列表)

*.dot 文件可以通过 xdot 工具打开
3.3 使用举例

单独编译 kernel、模块、设备树

MYS-6ULX-IOT 开发板对应的 kernel 是 linux-mys6ulx:

$ bitbake -c menuconfig -f -v linux-mys6ulx
$ bitbake -c compile -f -v linux-mys6ulx
$ bitbake -c compile_kernelmodules -f -v linux-mys6ulx
$ bitbake -c deploy -f -v linux-mys6ulx

 

也有一些资料用 virtual/kernel 来指定 kernel,命令变成这样了:

$ bitbake -c menuconfig virtual/kernel
$ bitbake -c compile -f -v virtual/kernel
$ bitbake -c compile_kernelmodules -f -v virtual/kernel
$ bitbake -c deploy -f -v virtual/kernel

 

通过 sources/meta-myir-imx6ulx/conf/machine/include/mys6ulx-base.inc 和
sources/meta-myir-imx6ulx/conf/distro/include/myir-imx-preferred-evn.inc 文件,我们可以看出一些端倪:

MACHINE_ARCH_FILTER = "virtual/kernel"

# Handle default kernel
IMX_DEFAULT_KERNEL = "linux-mys6ulx"
IMX_DEFAULT_KERNEL_mx6ul = "linux-mys6ulx"
IMX_DEFAULT_KERNEL_mx6ull = "linux-mys6ulx"
PREFERRED_PROVIDER_virtual/kernel ??= "${IMX_DEFAULT_KERNEL}"

 

单独编译u-boot

$ bitbake -c compile -f -v u-boot-mys6ulx
$ bitbake -c deploy -f -v u-boot-mys6ulx

 

编译文件系统

$ bitbake core-image-minimal
$ bitbake core-image-base
$ bitbake fsl-image-gui
$ bitbake fsl-image-qt5
$ bitbake fsl-image-multimedia

 

清除编译结果

$ bitbake -c clean -v linux-mys6ulx

 

清除还包括 clean、cleanall、cleanstate

参考
http://blog.sina.com.cn/s/blog_7880d3350102wvio.html
https://www.kancloud.cn/digest/yocto/138623

Yocto Project 上的 BitBake 用户手册:
https://www.yoctoproject.org/docs/1.6/bitbake-user-manual/bitbake-user-manual.html
---------------------

原文:https://blog.csdn.net/lu_embedded/article/details/80634368
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值