• yocto(六)——搭建yocto环境


    yocto环境没了,重新构建一下。说来惭愧,先写了后面的文章,才来补环境搭建~~~

    文章参考官方手册:https://docs.yoctoproject.org/brief-yoctoprojectqs/index.html

    准备环境

    我的系统是ubuntu20.04,执行以下命令安装依赖包。

    sudo apt install gawk wget git diffstat unzip texinfo gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool
    
    • 1

    其他发行版环境依赖可查看这个网址

    提醒:后续所有操作均不需要root权限!!!后续所有操作均不需要root权限!!!后续所有操作均不需要root权限!!!

    选择yocto版本

    1.下载需要使用Git,配置方法网上有太多教程了,自行百度一下。

    2.找个空闲的目录下载yocto。

    mkdir yocto
    cd yocto
    git clone git://git.yoctoproject.org/poky
    
    • 1
    • 2
    • 3

    3.选择一个长期支持的版本,点击这个网站查看。

    在这里插入图片描述

    上图可以看到后续稳定支持的版本所有三个,我们选择一个新的,即kirkstone版本。
    注意:新版本的yocto语法有些改动,比如操作符分割不再使用下划线_了,而是使用:符号,在编写yocto配方时候需要特别注意!!!

    cd poky
    git branch -a #查看所有分支
    git checkout -t origin/kirkstone -b my-kirkstone #选择kirstone分支
    
    • 1
    • 2
    • 3

    后续如果需要更新yocto的话执行:

    git pull
    
    • 1

    构建yocto

    $ cd poky
    $ source oe-init-build-env
    
    You had no conf/local.conf file. This configuration file has therefore been
    created for you with some default values. You may wish to edit it to, for
    example, select a different MACHINE (target hardware). See conf/local.conf
    for more information as common configuration options are commented.
    
    You had no conf/bblayers.conf file. This configuration file has therefore been
    created for you with some default values. To add additional metadata layers
    into your configuration please add entries to conf/bblayers.conf.
    
    The Yocto Project has extensive documentation about OE including a reference
    manual which can be found at:
        https://docs.yoctoproject.org
    
    For more information about OpenEmbedded see the website:
        https://www.openembedded.org/
    
    
    ### Shell environment set up for builds. ###
    
    You can now run 'bitbake '
    
    Common targets are:
        core-image-minimal
        core-image-full-cmdline
        core-image-sato
        core-image-weston
        meta-toolchain
        meta-ide-support
    
    You can also run generated qemu images with a command like 'runqemu qemux86'
    
    Other commonly useful commands are:
     - 'devtool' and 'recipetool' handle common recipe tasks
     - 'bitbake-layers' handles common layer tasks
     - 'oe-pkgdata-util' handles common target package tasks
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39

    source oe-init-build-env命令将设置环境变量,这意味着每次打开新的终端都需要执行它。由于没有设置MACHINE,默认为qemux86

    开始构建吧。

    bitbake core-image-sato
    
    • 1

    第一次编译时间取决于编译设备和网络,一般需要2小时左右,后续再次编译就会很快了。

    依赖出错

    编译刚开始可能会提示依赖包未安装,安装相应依赖即可。还有可能提示依赖版本不对,这样就需要移除之前的依赖包,再安装新版本依赖。

    下载出错

    第一次构建需要非常长的时间,因为我们前面下载的yocto工程只是一些配置文件(配方文件),没有源码包的,所以第一次构建时要去下载源码包,这也意味着可能下载失败。

    下载失败可能存在一下情况:

    1)你当前的网络无法访问对应的URL。

    2)代理有问题。

    3)对应的URL就是失效了。

    4)当前ubuntu软件源有问题,尽量使用学校的源,比如清华源。

    解决方法可以参考我的这篇文章,代理的问题还可查看这篇文章

    注意

    安装过程中如果想要强制停止,尽量只按一下 Ctrl + c ,之后yocto会结束后续的任务,但会把当前编译的任务完成。如果多次按Ctrl + c将会强制停止yocto,这样容易导致下次无法编译,但一般只需去build目录下删除*.sock和*.lcok文件即可,如下:

    $ ls build/
    bitbake-cookerdaemon.log  bitbake.lock  bitbake.sock  cache  conf  downloads  hashserve.sock  sstate-cache  tmp
    
    • 1
    • 2

    运行

    编译完成后如下所示:

    runqemu qemux86-64
    
    • 1

    然后会看到一个弹窗,如下图所示:
    在这里插入图片描述

    启动完成之后,就进入了yocto编译出来的系统了,不过。。。有点卡~~~

    常见问题

    有个中文网址(参考使用,非yocto官方),里面汇总了各类常见问题,详情查阅网址
    当然,官方也有一个网站,但是这个网站是英文的,点击网站

  • 相关阅读:
    前端部分知识点总结
    ARMv8 cache的包含策略inclusive 和 exclusive之间的区别以及Cortex-A55示例详解
    【Lilishop商城】No2-3.确定软件架构搭建二(本篇包括接口规范、日志处理)
    1465. 切割后面积最大的蛋糕
    [笔记] Windows内核课程:保护模式《二》段寄存器介绍
    VEX —— Attribute type metadata
    计算机微信小程序毕业设计题目SSM项目班级打卡系统+后台管理系统|前后分离VUE[包运行成功]
    记一次乐观锁并发场景下遇到的问题
    Blazor前后端框架Known-V1.2.15
    使用 SSL 实现 2 路身份验证的最简单方法 - 提供源代码的示例
  • 原文地址:https://blog.csdn.net/zz2633105/article/details/126076286