【风火轮YY3568开发板免费体验】第三章:在 buildroot 框架中添加本地的 hello_world 软件包以及给包打patch

第三章:在 buildroot 框架中添加本地的 hello_world 软件包以及给包打patch在第二章介绍了在buildroot框架下快乐编译 ffmpeg之后,本章就记录下如何在buildroot 的编译框架中添加一个新的软件包实现开发的一致性,这样做的好处是保持整个构建过程的统一,要不然可能还需要自己构建自己工程的编译环境,兼容buildroot编译框架的好处会随着开发软件包的复杂度提高逐渐显示出来这种做法的优越性。所以,本章就演示下如何根据 the buildroot user manual.pdf 的指导一步步完成 hello_world 工程到 builderoot package 的集成工作。
将本地的 hello_world 工程集成到 buildroot package 的编译框架如何集成 patch 的合并工作,在构建 hello_world 的自动打上这个 patch主要参考资料:[the buildroot user manual.pdf](the buildroot user manual.pdf)
1. hello_world 到 buildroot 的集成首先看一下 hello_world 工程本身的结构和内容:
下面就是准备将 hello_world 集成到 buildroot 中作为一个 package 进行构建,这部分首先看下一 buildroot 的 manual 是怎么描述的(the buildroot user manual.pdf中有详细的描述):
这里有关键的三类共计四个文件:
config 文件(配置的文件) config.in 文件,交叉编译的工程,本次使用交叉编译 hello_wolrd 工程,最后的可执行程序运行在 yy3568 上,所以使用这个文件config.in.host 文件,编译 host 的工程mk 文件(构建的文件 xxx.mk 文件,这个因为我对传统的 makefile 比较熟悉,所以本次使用的是就是 makefiles for generic packages )hash 文件(下载的软件包的 hash 校验文件,xxx.hash文件,因为本次构建是直接使用的 local 的源码文件,所以不存在文件包的校验,所以这个文件暂时没有)根据上面的介绍,所以首先在 buildroot 的 package 目录中创建 hello_world 目录,然后创建 config.in 和 hello_world.mk 文件,这两个文件的内容分别如下:
config.in 文件,本次为了演示,仅仅使用了开启关闭编译 hello_world 的选项:
config br2_package_hello_world bool hello_world help this is a comment that explains how to add new package to buildroothello_world.mk 文件:
################################################################################## hello_world#################################################################################hello_world_version = 0.9hello_world_source = hello_worldhello_world_site = /home/red/public/buildroot_sample/hello_worldhello_world_license = gpl-3.0+hello_world_license_files = copyinghello_world_install_staging = yeshello_world_site_method = localdefine hello_world_build_cmds$(make) $(target_configure_opts) -c $(@d) allendefdefine hello_world_install_staging_cmds$(install) -d -m 0755 $(@d)/hello_world $(staging_dir)/usr/binendefdefine hello_world_install_target_cmds$(install) -d -m 0755 $(@d)/hello_world $(staging_dir)/usr/binendef$(eval $(generic-package))在 hello_world.mk 文件,关键的地方有 hello_world_site_method 需要设置为 local,这样才会使用本地目录的原始文件;hello_world_site 需要设置为本地 hello_world 工程源码的目录,而非 hello_world 工程(文件夹)所在的目录。
最后要修改的就是让 buildroot 的 config.in 引用的 hello_world 的 config.in,即相关的 diff 文件:
diff --git a/buildroot/package/config.in b/buildroot/package/config.inindex d18c688..d06ec07 100644--- a/buildroot/package/config.in+++ b/buildroot/package/config.in@@ -10,6 +10,7 @@ menu target packages source package/skeleton-init-sysv/config.in menu audio and video applications+ source package/hello_world/config.in source package/alsa-utils/config.in source package/alsa-plugins/config.in source package/atest/config.in因为我会开发一个视频处理有关的应用,所以引用 hello_world 工程我就放在了 audio and video applications。
这样启动 buildroot menuconfig 配置找到 hello_world 的配置选项,选中进行构建。
将编译出来的 hello_world 通过 scp 发送到 yy3568,打印如下:
2. 给hello_world创建一个 patch,并依靠 buildroot 在构建的时候合并 patch 并编译有了第一部分的基础后,我们进阶一下,给 hello_world 打一个补丁,让 buildroot 在构建这个工程的时候先打上补丁在进行编译。
这里我们需要参看这部分内容:
首先我们创建这个补丁,补丁文件命名为0001-say-sth-else.patch:
diff --git a/main.c b/main.cindex dd0e127..fcbbe7e 100644--- a/main.c+++ b/main.c@@ -2,6 +2,6 @@ int main(int argc, char *argv[]) {- printf(red say hello world to yy3568n);+ printf(red say sth else to yy3568 just for demonstate how to patch package in buildrootn); return 0; }放在 buildroot/package/hello_world 目录:
接着需要将原始的 hello_world 工程打包为一个压缩包,比如 hello_world.tar。然后修改 hello_world.mk 文件如下:
--- /tmp/tar_o.txt 2023-08-12 12:41:28.772370902 +0800+++ /tmp/tar.txt 2023-08-12 12:41:53.564330270 +0800@@ -4,12 +4,12 @@ # ################################################################################ hello_world_version = 0.9-hello_world_source = hello_world-hello_world_site = /home/red/public/buildroot_sample/hello_world+hello_world_source = hello_world.tar+hello_world_site = /home/red/public/buildroot_sample hello_world_license = gpl-3.0+ hello_world_license_files = copying hello_world_install_staging = yes-hello_world_site_method = local+hello_world_site_method = file define hello_world_build_cmds $(make) $(target_configure_opts) -c $(@d) all endef然后删除 buildroot/output/rockchip_rk3568/build/hello_world-0.9 目录,重新构建:
运行新编译出来的hello_world 到 yy3568,可以看到打印提示就变了:
切记不能用之前的 hello_world_site_method = local 这种方法实际我测试发现不会有打 patch 这个动作。
至此,就记录了如何为 buildroot 添加一个本地的软件包以及打 patch 的操作,将远端的软件包纳入 buildroot package 进行构建的方法是类似的,这里暂时就不记录了。这里提示下,如果 patch 是在远端的,该怎么办呢?需要就对应的 patch 文件添加到变量 _patch,这部分 the buildroot user manual.pdf 也有介绍。

希捷首款16TB磁盘规格简介
威刚推出三款PCIe 4.0 SSD,读取速度超7000MB/s
首配前后双摄像头 乐视新机或在MWC亮相
PC行业再度打击 一季度全球出货为2013年来最差
高通和爱立信联手,打通全球首个5G电话
【风火轮YY3568开发板免费体验】第三章:在 buildroot 框架中添加本地的 hello_world 软件包以及给包打patch
你在生活中发现了物联网的元素吗
海信“净风”空净一体空调发布 聚焦用户对于健康和舒适的双重需求
监视器进入休眠状态怎么办 监视器的屏幕刷新频率怎么设置
AAFD-DU多回路型故障电弧探测器产品的功能及应用
中国5nm芯片最新消息
如何安全拆解CRT电视
霍尔芯片在智能围棋 电子棋盘中的应用及原理
5G将如何改变印度的沟通方式
怎样了解人工智能未来
软磁环磁滞回线测量中的定标
苹果APPstore疑似故障,用户无法访问
XunPu详解SIM卡座电路原理
美国五巨头股价较高点均下跌逾20%
新能源汽车高速发展背后:召回率达13% 三年车龄贬值过半