yocto-poky下目录结构分析

poky目录结构

  • poky目录下的核心组件
    • bitbake目录
    • build目录
    • meta目录
    • meta-poky目录
    • meta-yocto-bsp目录
    • meta-selftest目录
    • meta-skeleton目录
    • 已有硬件层的实例目录
      • metadara元数据
      • classes
      • recipes

yocto由许多的文件,目录或子目录组成,了解这些文件的意义和作用有助于我们快速的理解yocto项目

poky目录下的核心组件

bitbake目录

ubuntu:/media/C/Learn/poky/bitbake$  ls
AUTHORS    contrib  LICENSE               README
bin        doc      LICENSE.GPL-2.0-only  toaster-requirements.txt
ChangeLog  lib      LICENSE.MIT

bitbake是一个独立的项目,这里的poky/bitbake目录下就放了这个bitbake项目的副本,我们在使用的bitbake命令的其实就是这里的bitbake,而不是你的环境系统里面的。
bitbake是用来读取和解析meta目录中的数据,并创建相应的任务来处理,其他的目录基本上都是被bitbake使用的,用来按照相应的规则编译某个项目。
当我们source环境(source oe-init-build-env)的时候,会将scripts和bitbake/bin这两个目录的路径添加到PATH环境变量中:
yocto-poky下目录结构分析_第1张图片

build目录

一开始git clone下载的干净的poky目录下是没有这个build目录的,是我们source的过程中才开始创建的这个目录(可以参考oe-init-build-env和poky/scripts/oe-setup-builddir)
这个poky/build目录中包含有用户配置文件和OpenEmbedded构建系统在其标准配置中生成的输出,其中下载和解压后的源代码与编译输出的结果都在这个里面。
build目录也可以不固定放在poky目录下,或者名字也可以不固定,只要在source的时候带上参数即可:
. ./oe-init-build-env

meta目录

meta目录包含最小的,底层的OpenEmbedded核心元数据,保存着可以运行的虚拟目标,比如qemux86、qemuarm等的recipes,公共的class类和machine机器的配置。

ubuntu:/media/C/Learn/poky/meta$ ls
classes  files   recipes-connectivity  recipes-extended  recipes-kernel recipes-sato  site
conf  lib  recipes-core   recipes-gnome   recipes-multimedia  recipes-support
COPYING.MIT recipes-bsp recipes-devtools recipes-graphics recipes-rt          recipes.txt

meta-poky目录

该目录用来添加足够的元数据来定义poky reference distribution,是基于meta目录之上的扩展。build目录中的conf目录就是从meta-poky/conf中演变过来的,如local.conf和bblayer模板就是在这里

ubuntu:/media/C/Learn/poky/meta-poky$ tree
.
├── classes
│   └── poky-sanity.bbclass
├── conf
│   ├── bblayers.conf.sample
│   ├── conf-notes.txt
│   ├── distro
│   │   ├── include
│   │   │   ├── poky-distro-alt-test-config.inc
│   │   │   ├── poky-floating-revisions.inc
│   │   │   └── poky-world-exclude.inc
│   │   ├── poky-altcfg.conf
│   │   ├── poky-bleeding.conf
│   │   ├── poky.conf
│   │   └── poky-tiny.conf
│   ├── layer.conf
│   ├── local.conf.sample
│   ├── local.conf.sample.extended
│   └── site.conf.sample
├── README.poky
└── recipes-core
    ├── busybox
    │   ├── busybox
    │   │   └── poky-tiny
    │   │       └── defconfig
    │   └── busybox_%.bbappend
    ├── psplash
    │   ├── files
    │   │   └── psplash-poky-img.h
    │   └── psplash_git.bbappend
    └── tiny-init
        ├── files
        │   ├── init
        │   └── rc.local.sample
        └── tiny-init.bb

12 directories, 22 files

meta-yocto-bsp目录

这个目录下yocto官方为了方便bsp开发人员在开发和添加自己的bsp layer时,提供了3种目前主流体系架构的硬件平台bsp模板用于参考。比如这个目录下就有arm架构对应的beaglebone平台,mips对应的edgerouter平台,x86对应的genericx86平台等等。这里可以看到如何给这些平台增加相应的内核,bootLoader和其他的BSP配置。

ubuntu:/media/C/Learn/poky/meta-yocto-bsp$ tree
.
├── conf
│   ├── layer.conf
│   └── machine
│       ├── beaglebone-yocto.conf
│       ├── edgerouter.conf
│       ├── genericx86-64.conf
│       ├── genericx86.conf
│       └── include
│           └── genericx86-common.inc
├── lib
│   └── oeqa
│       ├── controllers
│       │   ├── beaglebonetarget.py
│       │   ├── edgeroutertarget.py
│       │   ├── grubtarget.py
│       │   └── __init__.py
│       └── selftest
│           └── cases
│               └── systemd_boot.py
├── README.hardware
├── recipes-bsp
│   ├── formfactor
│   │   ├── formfactor
│   │   │   ├── beaglebone-yocto
│   │   │   │   └── machconfig
│   │   │   ├── genericx86
│   │   │   │   └── machconfig
│   │   │   └── genericx86-64
│   │   │       └── machconfig
│   │   └── formfactor_0.0.bbappend
│   └── gma500-gfx-check
│       ├── gma500-gfx-check
│       │   ├── gma500-gfx-check.conf
│       │   └── gma500-gfx-check.sh
│       └── gma500-gfx-check_1.0.bb
├── recipes-graphics
│   └── xorg-xserver
│       ├── xserver-xf86-config
│       │   ├── beaglebone-yocto
│       │   │   └── xorg.conf
│       │   ├── genericx86
│       │   │   └── xorg.conf
│       │   └── genericx86-64
│       │       └── xorg.conf
│       └── xserver-xf86-config_0.1.bbappend
├── recipes-kernel
│   └── linux
│       ├── linux-yocto_5.4.bbappend
│       ├── linux-yocto_5.8.bbappend
│       └── linux-yocto-dev.bbappend
└── wic
    ├── beaglebone-yocto.wks
    ├── edgerouter.wks
    └── genericx86.wks.in

25 directories, 29 files

meta-selftest目录

这个目录存放自己的测试代码的配置,基本不用

meta-skeleton目录

skeleton英文意思是骨架,这个目录就是提供bsp和内核相关开发的模板,比如这里面就有一个hello-mod驱动模块的实例,系统层的服务程序,添加多个用户账户。

ubuntu:/media/C/Learn/poky$ tree meta-skeleton/
meta-skeleton/
├── conf
│   ├── layer.conf
│   ├── multilib-example2.conf
│   └── multilib-example.conf
├── recipes-baremetal
│   └── baremetal-examples
│       └── baremetal-helloworld_git.bb
├── recipes-core
│   └── busybox
│       ├── busybox
│       │   └── no_rfkill.cfg
│       └── busybox_%.bbappend
├── recipes-kernel
│   ├── hello-mod
│   │   ├── files
│   │   │   ├── COPYING
│   │   │   ├── hello.c
│   │   │   └── Makefile
│   │   └── hello-mod_0.1.bb
│   └── linux
│       ├── linux-yocto-custom
│       │   ├── 0001-linux-version-tweak.patch
│       │   ├── feature.scc
│       │   └── smp.cfg
│       └── linux-yocto-custom.bb
├── recipes-multilib
│   └── images
│       └── core-image-multilib-example.bb
└── recipes-skeleton
    ├── service
    │   ├── service
    │   │   ├── COPYRIGHT
    │   │   ├── skeleton
    │   │   └── skeleton_test.c
    │   └── service_0.1.bb
    └── useradd
        ├── useradd-example
        │   ├── file1
        │   ├── file2
        │   ├── file3
        │   └── file4
        └── useradd-example.bb

18 directories, 24 files

以下是meta-skeleton中的几个recipes,可以根据提示详细的分析

  • 1、recipes-baremetal
    这个目录里面是一个不跑系统的裸机程序演示,感兴趣的可以看下这个:
    https://github.com/aehs29/baremetal-helloqemu/blob/master/hello_baremetal_arm.c
  • 2、recipes-kernel
    教我们怎么给Linux内核添加patch补丁和config配置,怎么在源码树之外添加驱动模块实例
  • 3、recipes-skeleton
    教我们怎么添加一个应用层的service,而且还给了一个启动脚本
    同时还演示了如何在bb文件中安装启动脚本内容
  • 4、recipes-skeleton/useradd
    默认/home目录下通常只用一个root用户,这里就是我们可以往下面新增用户

已有硬件层的实例目录

这些目录了解需要我们根据yocto中的重要概念区分,找到对应的目录,后期我们将按照我们对这些目录的理解,去修改对应的文件或者增加对应的文件,解决自己目标需求。

metadara元数据

metadata中包括共享的配置(比如qemux86-64.conf机器配置),全局变量定义(如使用的kernel是什么版本,机器镜像有哪些功能等,比如x11,screen、alsa等等),共享的class类(如meta/classes),包装(meta/lib)和recipes配方。metadata和layers通常可以理解为一个东西,就是下面这些

poky]$ ls | grep "^meta"
meta #yocto基础的layer
meta-freescale #飞思卡尔的layer
meta-poky #yocto的poky发行版本layer
meta-qcom #这个是高通的layer
meta-qt5 #Qt5的layer
meta-selftest #自我测试的layer
meta-skeleton #骨架,很多例子
meta-yocto-bsp #yocto官方提供的参考bsp layer

classes

classes类定义了构建具有逻辑的封装和继承,有些Linux的bb文件就继承了Linux相关的一些class类,继承这些类的kernelrecipe bb文件,就不需要我们为内核的下载,config配置编译和安装等任务做太多事情,Linux的类有

ubuntu:/media/C/Learn/poky$ ls meta/classes/kernel*
meta/classes/kernel-arch.bbclass
meta/classes/kernel-artifact-names.bbclass
meta/classes/kernel.bbclass
meta/classes/kernel-devicetree.bbclass
meta/classes/kernel-fitimage.bbclass
meta/classes/kernel-grub.bbclass
meta/classes/kernel-module-split.bbclass
meta/classes/kernelsrc.bbclass
meta/classes/kernel-uboot.bbclass
meta/classes/kernel-uimage.bbclass
meta/classes/kernel-yocto.bbclass

第三方应用项目也有许多的class类,比如有些项目是cmake构建的,可以继承/meta/classes/cmake.bbclass,你就可以省去cmake项目应该怎么构建的烦恼。
Linux类和cmake类怎么继承,看例子:

#poky/meta/recipes-kernel/linux/linux-yocto.inc
inherit kernel 
inherit kernel-yocto
...
#poky/meta/recipes-support/libical/libical_3.0.8.bb
inherit cmake pkgconfig
...

使用到了inherit关键字

recipes

recipes配方是构建的软件和镜像的逻辑单元,它是构建一个项目的基本,通常应该包含若干个bb文件,包括bbappend文件。recipes通常是放在metadata layers目录中,会继承上面提及的一些class类,大致如下:

meta-xxx/recipes-abc/abc.bb

如果想知道自己yocto有哪些recipes,可以通过下面的命令查看:

build]$ bitbake-layers show-recipes

我们简单的看下/poky/meta/recipes.txt中内容

1 recipes-bsp          - Anything with links to specific hardware or hardware configuration information
2 recipes-connectivity - Libraries and applications related to communication with other devices
3 recipes-core         - What's needed to build a basic working Linux image including commonly used dependencies
4 recipes-devtools     - Tools primarily used by the build system (but can also be used on targets)
5 recipes-extended     - Applications which whilst not essential add features compared to the alternatives in
6                        core. May be needed for full tool functionality.
7 recipes-gnome        - All things related to the GTK+ application framework
8 recipes-graphics     - X and other graphically related system libraries
9 recipes-kernel       - The kernel and generic applications/libraries with strong kernel dependencies
10 recipes-multimedia   - Codecs and support utilties for audio, images and video
11 recipes-rt           - Provides package and image recipes for using and testing the PREEMPT_RT kernel
12 recipes-sato         - The Sato demo/reference UI/UX, its associated apps and configuration
13 recipes-support      - Recipes used by other recipes but that are not directly included in images

翻译:

recipes-bsp—任何带有特定硬件或硬件配置信息链接的内容
recip- connectivity -与其他设备通信相关的库和应用程序
recipes-core—构建包括常用依赖项在内的基本工作Linux映像所需要的内容
recipes-devtools——主要用于构建系统的工具(但也可以用于目标)
recipes-extended -与内核中的替代方案相比,这些应用程序虽然不是必不可少的,但却可以添加一些特性。可能需要完整的工具功能。
所有与GTK+应用程序框架相关的内容
recipes-graphics ---X和其他图形相关的系统库
recipes-kernel—具与内核有强依赖性的通用应用程序或者库
recipes-multimedia --音频、图像和视频的编解码器和支持应用程序
recipes-rt——提供用于使用和测试PREEMPT_RT内核的包和映像食谱
recipes-sato  参考UI/UX,相关的应用程序和配置
recipes-support——其他食谱使用的食谱,但没有直接包含在图片中

你可能感兴趣的:(YOCTO学习,yocto,软件集成,linux)