既然是新增一个helloworld,那就和linux中的helloworld一样,需要源码以及编译这个源码的Makefile.
hello.c
#include "stdio.h"
#include "stdlib.h"
int main()
{
while(1)
{
fprintf(stderr, "HelloWorld");
sleep(1);
}
return 0;
}
以及标准的HelloWorld Makefile
hello:hello.o
$(CC) -o hello hello.o
hello.o: hello.c
$(CC) -c hello.c
.PHONY : clean
clearn:
-rm -rf *.o
Yocto编译时是bitbake去读取配方中的配置来进行获取源文件,编译,以及将编译生成的目标文件install到rootfs中去的。
因此如果我需要让bitbake能编译到我的源码,我就需要让新增一个recipes用于描述这个新增的hello模块该怎么编译,并让bitbake在编译时读取到我新增的recipes.
要让bitbake能够读取到hello的recipes,我们有多种办法,最简单的就是在已有的layer文件夹下.
首先看一下那些layer会被读取到
zrh@zrh-PC:~/hdd2/poky$ cat ./build/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/zrh/hdd2/poky/meta \
/home/zrh/hdd2/poky/meta-poky \
/home/zrh/hdd2/poky/meta-yocto-bsp \
"
所以我选择meta-poky这个layer,在这个layer里面已经存在一个recipes-core的文件夹,新增一个recipes-test用来存放hello的源码和recipes,在recipes-test里面新建hello文件夹,并新增hello.bb
hello.bb
DESCRIPTION = "Hello World Test"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://hello.c;md5=c887acb828cf8aa8512e94eed3e729f0"
PV = "1"
PR = "r0"
SRC_URI = "file://hello.c \
file://Makefile \
"
S = "${WORKDIR}"
do_compile () {
make
}
do_install() {
install -d ${
D}${
bindir}/
install -m 0755 ${
S}/hello ${
D}${
bindir}/
}
FILES_${
PN} = "${bindir}/hello"
以下是参数说明
再把c文件和Makefile文件添加进去就可以完成这个recipces了,添加完成之后的目录结构是这样的
zrh@zrh-PC:~/hdd2/poky/meta-poky/recipes-test$ tree hello/
hello/
|-- hello
| |-- Makefile
| `-- hello.c
`-- hello.bb
1 directory, 3 files
在完成上面这些步骤之后,我们就可以单独的编译这个包了。
先查看一下bitbake能不能读取到我们新增的recipes
zrh@zrh-PC:~/hdd2/poky/meta-poky/recipes-test$ bitbake -s | grep hello
go-helloworld :0.1-r0
hello :1-r0
看起来是能读到
那就可以执行bitbake hello单编一下这个recipes试试了
zrh@zrh-PC:~/hdd2/poky/meta-poky/recipes-test$ bitbake hello
WARNING: Host distribution "deepin-20-Beta" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
Loading cache: 100% |#####################################################################################################################################################| Time: 0:00:00
Loaded 1309 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "1.46.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "x86_64-poky-linux"
MACHINE = "qemux86-64"
DISTRO = "poky"
DISTRO_VERSION = "3.1.1"
TUNE_FEATURES = "m64 core2"
TARGET_FPU = ""
meta
meta-poky
meta-yocto-bsp = "my-yocto-3.1.1:febbe2944c0c4a04b85fa98fdc261186115954d8"
Initialising tasks: 100% |################################################################################################################################################| Time: 0:00:00
Sstate summary: Wanted 0 Found 0 Missed 0 Current 135 (0% match, 100% complete)
NOTE: Executing Tasks
NOTE: Tasks Summary: Attempted 542 tasks of which 542 didn't need to be rerun and all succeeded.
Summary: There was 1 WARNING message shown.
此时虽然能单编通过,但是我们在rootfs中并没有找到hello,这是因为我们没有将hello这个package添加到编译目标的recipes中,也就是说编译整个Linux发行版的时候是不会编到hello的。
以官方Yocto Project Quick Build.为例,
执行 bitbake core-image-sato 进行编译时,首先是读取的 core-image-sato.bb,所以我们只需要在这个recipes中添加我们的包就可以了,如下所示
diff --git a/meta/recipes-sato/images/core-image-sato.bb b/meta/recipes-sato/images/core-image-sato.bb
index 673106eb6d..c5d01c1ce0 100644
--- a/meta/recipes-sato/images/core-image-sato.bb
+++ b/meta/recipes-sato/images/core-image-sato.bb
@@ -13,3 +13,7 @@ TOOLCHAIN_HOST_TASK_remove_task-populate-sdk-ext = " nativesdk-intltool nativesd
QB_MEM = '${@bb.utils.contains("DISTRO_FEATURES", "opengl", "-m 512", "-m 256", d)}'
QB_MEM_qemumips = "-m 256"
+
+IMAGE_INSTALL_append += "hello"
+
+
执行runqemu qemux86-64启动虚拟机
启动之后点开终端,然后输入hello,回车,会发现hello能被执行,并且不断地在当前终端打印helloworld,表示hello成功的添加到了yocto中
文章浏览阅读891次,点赞18次,收藏29次。c语言学习01:认识c语言
文章浏览阅读525次。当我们的目标是在波涛汹涌的海况中探测较小的船只时,这种增强特别有价值。这项工作使用了一种名为几何摄动-极化陷波(GP-PNF)的舰船探测器,其目的是改善其性能,特别是在可获得的极化图像较少的情况下(例如,双极化数据)。这个想法是设计一个新的极化特征向量,包含更多的特征,这些特征被认为是允许船只和海杂波分离的。然后利用主成分分析(PCA)对新特征空间进行降维。_gp-pnf
文章浏览阅读580次,点赞25次,收藏24次。【FPS 1000+】ubuntu下libfacedetection人脸检测 tensorrt加速部署_人脸检测 tensorrt
文章浏览阅读1.2k次。一、LwIP移植记录lwip-1.4.1\src\core\ipv4\icmp.c 注释掉:#if CHECKSUM_GEN_ICMP新增加:#ifdef CHECKSUM_BY_HARDWARE代码如下://#if CHECKSUM_GEN_ICMP// /* adjust the checksum */// if (iecho->chksum..._stm32f107 lwip 直连
文章浏览阅读7k次,点赞2次,收藏7次。到目前为止,我们已经学习了Java语言的好几种运算符,包括算术运算符、赋值运算符、逻辑运算符、关系运算符等基础运算符,并且在书写赋值语句时都没添加圆括号,显然是默认了先完成算术、逻辑、关系等运算,最后才进行赋值操作。也就是说,在这四类运算符当中,赋值运算符的优先级最低,那么其他三种运算符的优先级顺序又是如何排列的呢?首先来看算术运算符,Java中的算术运算符主要包括正号负号、加减乘除,以及取余数..._大于小于和等于的优先级
文章浏览阅读407次。一:特殊三位数请输出满足条件n=a!+b!+c!的所有三位数n,其中,a、b、c分别是n的百、十、个位数。要求用自定义函数实现求阶乘。#includeusing namespace std;int f(int n){ int s=1,i; for(i=1;i<=n;i++) s=s*i; return s;} int main() {_定义一个有10个的数组a,将数组a中的所有素数放在数组b,再对数组b排序。
文章浏览阅读808次。每个请求按访问ip的hash结果分配,这样每个访客固定访问一个后端服务器,可以解决session的问题,但是ip_hash会造成负载不均,有的服务请求接受多,有的服务请求接受少,所以不建议采用ip_hash模式,session 共享问题可用后端服务的 session 共享代替 nginx 的 ip_hash。基于用户请求的uri做hash。[在这里插入图片描述](https://img-blog.csdnimg.cn/cb5b2fd0e902423897c1b729c66349d1.png)_nginx tomcat 反向代理负载均衡
文章浏览阅读845次,点赞27次,收藏8次。***构造包含指定collection元素的列表,这些元素利用该集合的迭代器按顺序返回*如果指定的集合为null,throws NullPointerException。*/= 0) {} else {下面在我们分析 ArrayList 扩容时会降到这一点内容!二 一步一步分析 ArrayList 扩容机制这里以无参构造函数创建的 ArrayList 为例分析。
文章浏览阅读392次,点赞6次,收藏6次。1、话说mysql innodb在5.6.4以后就有了fulltext全文索引。_mysql fulltext索引
文章浏览阅读1.5k次。JAVA中四舍五入方法_string.format 四舍五入
文章浏览阅读609次。注:参考文章:https://blog.csdn.net/qq_36754544/article/details/55062391struts2是一种重量级的框架,位于MVC架构中的controller,可以分析出来,它是用于接受页面信息然后通过内部处理,将结果返回。同时struts2也是一个web层的MVC框架,那么什么是struts2中的MVC呢?我们可以联想一下struts2的使用流程,我们需要先通过过滤器,调用URL判断使用哪个Action,再由Action决定返回结果,继而 提交..._1、什么是struts2框架,它的作用是什么?
文章浏览阅读1w次,点赞16次,收藏14次。import matplotlib.pyplot as pltplt.rc('font',family='Times New Roman') 注意一定要在导入包之后就设置这个代码,否则可能不显示。参考文献[1]matplotlib 全局字体改为 Times New Roman_python画图调整字体为times