Yocto 创建 meta layer 和添加软件包

文章目录

  • [一、创建 meta layer](#一、创建 meta layer)
  • 二、添加软件包
    • [1. 添加第一个软件包](#1. 添加第一个软件包)
    • [2. 添加基于 Makefile 的软件包](#2. 添加基于 Makefile 的软件包)
    • [3. 添加基于 CMake 的软件包](#3. 添加基于 CMake 的软件包)
    • [4. 添加基于 configure 的软件包](#4. 添加基于 configure 的软件包)

一、创建 meta layer

在 build 目录下执行:

shell 复制代码
bitbake-layers create-layer ../meta-mylayer

add:

shell 复制代码
bitbake-layers add-layer ../meta-mylayer

默认文件夹和文件:

执行或者清除:

shell 复制代码
bitbake example
bitbake -c cleanall example

二、添加软件包

1. 添加第一个软件包

在新创建的 meta layer 里面添加第一个软件包:

shell 复制代码
mkdir ../meta-mylayer/recipes-helloworld

参考自带的 meta-skeleton 这个 layer ,复制过来:

shell 复制代码
cp ../meta-skeleton/recipes-skeleton/hello-single/ ../../meta-mylayer/recipes-helloworld/ -r 

编译:hello 是一个程序,编译的话跟 CPU 架构有关系,所以在架构目录下找

shell 复制代码
bitbake hello

编译成功后在临时工作区可以找到该程序,不过还没打包到系统,我们添加 bbappend 追加到系统自带的镜像:

shell 复制代码
mkdir -p ../meta-mylayer/recipes-sato/images/
vi ../meta-mylayer/recipes-sato/images/core-image-sato.bbappend

# 添加
IMAGE_INSTALL += "hello"

查看系统自带的镜像:

shell 复制代码
ls ../meta/recipes-sato/images/core-image-stao.bb

修改成功后回到初始目录重新配置环境:

shell 复制代码
source oe-init-build-env build-arm/
bitbake core-image-sato

镜像构建成功后就可以找到该程序:

打开虚拟系统验证:

shell 复制代码
runqemu qemuarm64


2. 添加基于 Makefile 的软件包

在这里 hello-a 代表基于 configure 编译,hello-c 代表基于 CMake 编译,hello-m 代表基于 Makefile 编译。

默认编译 .bb 如下:

基于 Makefile 编译模板目录:

Makefile 文件:

.c 文件:

默认 .bb 文件:



编译:

shell 复制代码
bitbake hello-m

添加 append 后打包:

shell 复制代码
source oe-init-build-env build-arm/
bitbake core-image-sato

3. 添加基于 CMake 的软件包

默认目录:

CMakeLists.txt:

默认 .bb 文件:

编译:

shell 复制代码
bitbake hello-c

添加 bbappend 后打包,跟上面步骤一样:

shell 复制代码
source oe-init-build-env build-arm/
bitbake core-image-sato

4. 添加基于 configure 的软件包

目录:

configure.ac 和 helloworld-a/src/Makefile.am:

README 和 helloworld-a/Makefile.am:

不用 bitbake,手工命令编译:

shell 复制代码
autoreconf --install
shell 复制代码
./configure
make

# 清除
make distclean


用 bitbake 编译:

shell 复制代码
bitbake hello-a


构建镜像:

shell 复制代码
bitbake core-image-sato
相关推荐
-水火-2 个月前
【yocto】Yocto Project 核心:深入了解.bbclass文件
linux·yocto·.bbclass
TNT_TT10 个月前
一、STM32MP257开发板初体验
linux·stm32·单片机·嵌入式硬件·yocto
TNT_TT10 个月前
二、STM32MP257安全启动流程简介
stm32·嵌入式硬件·安全·yocto
划碎、时光1 年前
Yocto 项目下通过网络更新内核、设备树及模块
bsp·yocto
bai-xin1 年前
yocto编辑软件包-devtool的使用方法
yocto·devtool·yocto编辑软件包·yocto开发
「QT(C++)开发工程师」1 年前
【Yocto 是一个开源项目】
linux·qt·yocto
TNT_TT1 年前
十二、Yocto集成ROS2 app程序(package)
嵌入式·ros·yocto·raspberrypi
TNT_TT2 年前
十一、Yocto集成tcpdump等网络工具
网络·嵌入式·yocto·tcpdump·raspberrypi
TNT_TT2 年前
四、Yocto创建静态IP和VLAN(基于raspiberrypi 4B)
yocto·vlan