【Yocto】devtool修改源代码「建议收藏」

【Yocto】devtool修改源代码「建议收藏」【Yocto】devtool修改源代码。

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

说明

本文接在【Yocto】BitBake入门之镜像中的HelloWorld之后完成。

修改源代码

如果想要修改Poky项目中的源代码,可以依赖于devtool工具,这里以修改busybox为例。

首先创建workspace:

jw@X1C:~/code/poky/build$ devtool create-workspace
NOTE: Starting bitbake server...
jw@X1C:~/code/poky/build$ tree workspace/

workspace/
├── conf
│   └── layer.conf
└── README

1 directory, 2 files

使用devtool create-workspace除了创建上述的workspace,还会修改conf/bblayers.conf,它的作用是将workspace作为一个Layer添加到项目中:

jw@X1C:~/code/poky/build$ cat conf/bblayers.conf 
# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"

BBPATH = "${TOPDIR}"
BBFILES ?= ""

BBLAYERS ?= " \ /home/jw/code/poky/meta \ /home/jw/code/poky/meta-poky \ /home/jw/code/poky/meta-yocto-bsp \ /home/jw/code/poky/meta-mylayer \ /home/jw/code/poky/build/workspace \ "

还可以通过bitbake-layers查看:

jw@X1C:~/code/poky/build$ bitbake-layers show-layers
NOTE: Starting bitbake server...
layer                 path                                      priority
==========================================================================
meta                  /home/jw/code/poky/meta                   5
meta-poky             /home/jw/code/poky/meta-poky              5
meta-yocto-bsp        /home/jw/code/poky/meta-yocto-bsp         5
meta-mylayer          /home/jw/code/poky/meta-mylayer           6
workspace             /home/jw/code/poky/build/workspace        99

其次就是添加配方到workspace目录:

jw@X1C:~/code/poky/build$ devtool modify busybox
NOTE: Starting bitbake server...
NOTE: Reconnecting to bitbake server...
NOTE: Retrying server connection (#1)...
Loading cache: 100% |########################################################################################################################################################################| Time: 0:00:00
Loaded 1424 entries from dependency cache.
INFO: SRC_URI contains some conditional appends/prepends - will create branches to represent these
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION           = "1.49.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "x86_64-poky-linux"
MACHINE              = "qemux86-64"
DISTRO               = "poky"
DISTRO_VERSION       = "3.2+snapshot-f13e17656248021debea6fe01564c40af27271d1"
TUNE_FEATURES        = "m64 core2"
TARGET_FPU           = ""
meta                 
meta-poky            
meta-yocto-bsp       
meta-mylayer         
workspace            = "master:f13e17656248021debea6fe01564c40af27271d1"

Initialising tasks: 100% |###################################################################################################################################################################| Time: 0:00:00
Sstate summary: Wanted 0 Found 0 Missed 0 Current 20 (0% match, 100% complete)
NOTE: Executing Tasks
NOTE: Tasks Summary: Attempted 93 tasks of which 90 didn't need to be rerun and all succeeded.
INFO: Adding local source files to srctree...
INFO: Source tree extracted to /home/jw/code/poky/build/workspace/sources/busybox
WARNING: SRC_URI is conditionally overridden in this recipe, thus several devtool-override-* branches have been created, one for each override that makes changes to SRC_URI. It is recommended that you make changes to the devtool branch first, then checkout and rebase each devtool-override-* branch and update any unique patches there (duplicates on those branches will be ignored by devtool finish/update-recipe)
INFO: Using source tree as build directory since that would be the default for this recipe
INFO: Recipe busybox now set up to build from /home/jw/code/poky/build/workspace/sources/busybox

这样busybox的代码就被下载到build/workspace/sources/busybox目录下了,这个时候在构建项目,则使用的是workspace目录下的源码,如下所示:

jw@X1C:~/code/poky/build$ bitbake core-image-minimal
Loading cache: 100% |########################################################################################################################################################################| Time: 0:00:00
Loaded 1424 entries from dependency cache.
Parsing recipes: 100% |######################################################################################################################################################################| Time: 0:00:00
Parsing of 810 .bb files complete (809 cached, 1 parsed). 1424 targets, 42 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION           = "1.49.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "x86_64-poky-linux"
MACHINE              = "qemux86-64"
DISTRO               = "poky"
DISTRO_VERSION       = "3.2+snapshot-f13e17656248021debea6fe01564c40af27271d1"
TUNE_FEATURES        = "m64 core2"
TARGET_FPU           = ""
meta                 
meta-poky            
meta-yocto-bsp       
meta-mylayer         
workspace            = "master:f13e17656248021debea6fe01564c40af27271d1"

Initialising tasks: 100% |###################################################################################################################################################################| Time: 0:00:01
Sstate summary: Wanted 5 Found 1 Missed 4 Current 1088 (20% match, 99% complete)
NOTE: Executing Tasks
NOTE: busybox: compiling from external source tree /home/jw/code/poky/build/workspace/sources/busybox
NOTE: Tasks Summary: Attempted 3113 tasks of which 3083 didn't need to be rerun and all succeeded.

下一个就是修改源码,比如修改coreutils/date.c,增加helloworld打印:

puts("helloworld\n");

然后再构建项目,发现会报错:

jw@X1C:~/code/poky/build$ bitbake core-image-minimal
Loading cache: 100% |########################################################################################################################################################################| Time: 0:00:00
Loaded 1424 entries from dependency cache.
Parsing recipes: 100% |######################################################################################################################################################################| Time: 0:00:01
Parsing of 810 .bb files complete (809 cached, 1 parsed). 1424 targets, 42 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION           = "1.49.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "x86_64-poky-linux"
MACHINE              = "qemux86-64"
DISTRO               = "poky"
DISTRO_VERSION       = "3.2+snapshot-f13e17656248021debea6fe01564c40af27271d1"
TUNE_FEATURES        = "m64 core2"
TARGET_FPU           = ""
meta                 
meta-poky            
meta-yocto-bsp       
meta-mylayer         
workspace            = "master:f13e17656248021debea6fe01564c40af27271d1"

Initialising tasks: 100% |###################################################################################################################################################################| Time: 0:00:01
Sstate summary: Wanted 5 Found 1 Missed 4 Current 1088 (20% match, 99% complete)
NOTE: Executing Tasks
NOTE: busybox: compiling from external source tree /home/jw/code/poky/build/workspace/sources/busybox
ERROR: busybox-1.32.0-r0 do_package: Error executing a python function in exec_python_func() autogenerated:

The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
     0001:
 *** 0002:ptest_update_alternatives(d)
     0003:
File: '/home/jw/code/poky/meta/classes/ptest.bbclass', lineno: 98, function: ptest_update_alternatives
     0094:        for alt_name, alt_link, alt_target, _ in alternatives:
     0095:            # Some alternatives are for man pages,
     0096:            # check if the alternative is in PATH
     0097:            if os.path.dirname(alt_link) in bin_paths:
 *** 0098:                os.symlink(alt_target, os.path.join(ptest_bindir, alt_name))
     0099:}
     0100:
     0101:do_configure_ptest_base[dirs] = "${B}"
     0102:do_compile_ptest_base[dirs] = "${B}"
Exception: FileExistsError: [Errno 17] File exists: '/bin/busybox.suid' -> '/home/jw/code/poky/build/tmp/work/core2-64-poky-linux/busybox/1.32.0-r0/package/usr/lib/busybox/ptest/bin/login'

ERROR: Logfile of failure stored in: /home/jw/code/poky/build/tmp/work/core2-64-poky-linux/busybox/1.32.0-r0/temp/log.do_package.12918
ERROR: Task (/home/jw/code/poky/meta/recipes-core/busybox/busybox_1.32.0.bb:do_package) failed with exit code '1'
NOTE: Tasks Summary: Attempted 3096 tasks of which 3090 didn't need to be rerun and 1 failed.

Summary: 1 task failed:
  /home/jw/code/poky/meta/recipes-core/busybox/busybox_1.32.0.bb:do_package
Summary: There was 1 ERROR message shown, returning a non-zero exit code.

但是如果再次编译,又能够编译成功了:

jw@X1C:~/code/poky/build$ bitbake core-image-minimal
Loading cache: 100% |########################################################################################################################################################################| Time: 0:00:00
Loaded 1424 entries from dependency cache.
Parsing recipes: 100% |######################################################################################################################################################################| Time: 0:00:00
Parsing of 810 .bb files complete (809 cached, 1 parsed). 1424 targets, 42 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION           = "1.49.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "x86_64-poky-linux"
MACHINE              = "qemux86-64"
DISTRO               = "poky"
DISTRO_VERSION       = "3.2+snapshot-f13e17656248021debea6fe01564c40af27271d1"
TUNE_FEATURES        = "m64 core2"
TARGET_FPU           = ""
meta                 
meta-poky            
meta-yocto-bsp       
meta-mylayer         
workspace            = "master:f13e17656248021debea6fe01564c40af27271d1"

Initialising tasks: 100% |###################################################################################################################################################################| Time: 0:00:01
Sstate summary: Wanted 5 Found 1 Missed 4 Current 1088 (20% match, 99% complete)
NOTE: Executing Tasks
NOTE: busybox: compiling from external source tree /home/jw/code/poky/build/workspace/sources/busybox
NOTE: Tasks Summary: Attempted 3113 tasks of which 3090 didn't need to be rerun and all succeeded.

运行镜像之后执行date命令,结果如下:

在这里插入图片描述

可以看到代码修改成功了。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/185673.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 表白生成器PHP源码,表白网页在线生成源码[通俗易懂]

    表白生成器PHP源码,表白网页在线生成源码[通俗易懂]在520这个节日里面,很多人都开始了表白计划,对于那些不敢说出口的问题,就直接来此下载520表白网页一键生成软件,帮助你们直接生成最棒的表白页面,让你们增加成功的机会。520表白网页一键生成软件简介如果你喜欢她不能亲自向她说不如做个网页,把自己想说的话写进去,然后发个地址给她,里面添加她喜欢的音乐或者mv。不会做网页怎么办,没事。表白网页生成器帮助你!无需任何编程。一键生成,然后把生成在桌面的i…

    2022年5月21日
    35
  • 记一次Linux系统内存占用较高得排查

    记一次Linux系统内存占用较高得排查

    2022年3月5日
    96
  • Linux load average负载量分析与解决思路

    Linux load average负载量分析与解决思路top命令中loadaverage显示的是最近1分钟、5分钟和15分钟的系统平均负载。系统平均负载表示  系统平均负载被定义为在特定时间间隔内运行队列中(在CPU上运行或者等待运行多少进程)的平均进程树。如果一个进程满足以下条件则其就会位于运行队列中:  -它没有在等待I/O操作的结果  -它没有主动进入等待状态(也就是没有调用’wait’)  -没有被停止

    2022年7月17日
    13
  • lte频谱带宽_lte信道带宽可以配置为

    lte频谱带宽_lte信道带宽可以配置为1.频带(Band)所谓频带,指代的是一个频率的范围或者频谱的宽度,即无线解码器的最低工作频率至最高工作频率之间的范围,单位是Hz。为了方便起见,在LTE中,使用数字1-43来表示不同的频带(36101-V10.21.0版本协议),从而指代不同的频率范围。协议36101规定了目前LTE所有的频带、该频带的频率范围和LTE制式,如下图所示。需要注意的是,频带1-32的上下行频率范围是不重叠的,即上行

    2022年10月11日
    0
  • 你想要的Http和Https知识这里都有[通俗易懂]

    你想要的Http和Https知识这里都有[通俗易懂]你真的了解HTTP和HTTPS吗?HTTPS=SSL+HTTP,面试必问。

    2022年10月16日
    0
  • 反向传播算法(过程及公式推导)「建议收藏」

    反向传播算法(过程及公式推导)「建议收藏」一、反向传播的由来在我们开始DL的研究之前,需要把ANN—人工神经元网络以及bp算法做一个简单解释。关于ANN的结构,我不再多说,网上有大量的学习资料,主要就是搞清一些名词:输入层/输入神经元,输出

    2022年8月4日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号