【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命令,结果如下:

在这里插入图片描述

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

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

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

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)
blank

相关推荐

  • 2、Tomcat集群实战,并用Nginx实现负载均衡(win环境)

    2、Tomcat集群实战,并用Nginx实现负载均衡(win环境)

  • 卡尔曼滤波算法详细推导[通俗易懂]

    卡尔曼滤波算法详细推导[通俗易懂]一、预备知识1、协方差矩阵是一个维列向量,是的期望,协方差矩阵为可以看出协方差矩阵都是对称矩阵且是半正定的协方差矩阵的迹是的均方误差2、用到的两个矩阵微分公式公式一:公式二:若是对称矩阵,则下式成立…

  • nginx 接口转发_nginx后端接口转发到内网

    nginx 接口转发_nginx后端接口转发到内网目前开发多数趋于前后端分离,后端开发人员有的时候懒得搭建前端环境,可是写后端又不便于联调,经常被这个困扰中,本文介绍如何用nginx转发。前提:有一套完整的环境,可以访问整个环境。环境地址,eghttp://wangzhi.com背景:开发人员不想搭建前端环境,可是又不便于联调。postman联调的话,参数拼接比较麻烦。步骤:1、本地项目启动,eg:localhost:80802、配置本地host127.0.0.1wangzhi.com说明:需要把环境地址,转到本地,

  • anaconda安装教程环境变量(如何配置环境变量)

    Linux安装anaconda的步骤:下载anaconda的安装包,后缀名为.sh,然后在root用户下执行bashXXX.shLinux配置anaconda环境变量:1、命令的路径在/usr/local/anaconda3/bin;2、通过vim/etc/profile,在文件的末尾添加PATH=$PATH:/usr/local//anaconda3/binex…

  • MySQL配置文件[通俗易懂]

    MySQL配置文件[通俗易懂]在Windows系统中,MySQL的配置文件为my.ini,在Linux系统中,配置文件为my.cnf,一般存放路径为/etc/my.cnf或/etc/mysql/my.cnf。参考链接:https://segmentfault.com/a/1190000021408999?utm_source=tag-newestMySQL的默认设置性能非常差,仅仅起一个功能测试的作用,不能用在生产环境中,需要对一些参数进行调整优化。每次更改文件后,需要重启MySQL服务,使修改生效。在该配置文件中,可.

  • 代价函数的意义

    代价函数的意义我们来复习上一节的知识:假设函数:hθ(x)=θ0+θ1xh_\theta(x)=\theta_0+\theta_1xhθ​(x)=θ0​+θ1​x参数:θ0,θ1\theta_0,\theta_1θ0​,θ1​代价函数:J(θ0,θ1)=12m∑i=1i=m(h(xi)−yi)2J(\theta_0,\theta_1)=\frac{1}{2m}\sum_{i=1}^{i=m}(h(x^i)…

发表回复

您的电子邮箱地址不会被公开。

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