Yocto Project 编译imx-第1节(下载和编译)

前言说明

参考网上其他人写的文章,然后整理的知识笔记。

参考文章

iMX6Ull采用Yocto构建嵌入式Linux系统系列:https://www.bilibili.com/read/cv16216317
bitbake 语言网站: https://docs.yoctoproject.org/bitbake/2.0/bitbake-user-manual/bitbake-user-manual-intro.html
Yocto网站 :https://git.yoctoproject.org/poky/refs/heads
imx-yocto 库网站1: https://source.codeaurora.org/external/imx/
imx-yocto 库网站2: https://git.codelinaro.org/explore/
openembedded 网站:https://layers.openembedded.org/layerindex/branch/zeus/layers/
将docker添加到发行版教程:https://m5p3nc3r.github.io/Adding_docker_to_yocto/

版本说明

名词说明
BB_VERSION“1.44.0”
BUILD_SYS“x86_64-linux”
NATIVELSBSTRING“ubuntu-20.04”
TARGET_SYS“arm-poky-linux-gnueabi”
MACHINE“imx6dlsabresd”
DISTRO“fsl-imx-fb”
DISTRO_VERSION“5.4-zeus”
TUNE_FEATURES“arm vfp cortexa9 neon thumb callconvention-hard”
TARGET_FPU“hard”

Ubuntu 系统说明和建议

使用的Ubuntu 系统可以是虚拟机,也可以是直接安装的系统。鉴于虚拟机的性能,建议使用自己安装的系统的方式进行编译,可以安装win10和ubuntu双系统方便开发使用,如果是安装了双系统,在Ubuntu 系统中也是可以挂载win10系统使用的硬盘的。
电脑的硬件最好是CPU核心越多越好。核心越多内存也要跟着一起扩大,因为编译时,核心越多,执行的任务越多,消耗的内存也越多。
双系统安装教程:http://t.zoukankan.com/leime-p-9446954.html

必备软件安装

安装指令:

sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib 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
sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \
 build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \
 xz-utils debianutils iputils-ping libsdl1.2-dev xterm
sudo apt install zstd curl

设置Git用户名和密码

git config --global user.name "Your Name" // 配置git用户名:“Your Name”
git config --global user.email "Your Email" // 配置git用户邮箱:“Your Email”
git config --list //  查看git配置信息

解决git报错

fatal: unable to access ‘https://github.com/…/.git‘: Could not resolve host: github.com

git config --global --unset http.proxy 
git config --global --unset https.proxy

使用FastGithub

地址:https://github.com/dotnetcore/FastGithub
详细使用方法参照FastGithub介绍,可以加速git访问
Linux-x64终端
sudo ./fastgithub

设置系统自动代理为,或手动代理 http/https 为 http://127.0.0.1:38457127.0.0.1:38457

git操作提示
需要关闭git的证书验证:SSL certificate problem git config --global http.sslverify false
火狐浏览器
Firefox提示
设置->隐私与安全->证书->查看证书->证书颁发机构,导入cacert/fastgithub.cer,勾选“信任由此证书颁发机构来标识网站”连接有潜在的安全问题

获取repo

切换至工程项目文件夹,如:/home/YourName/Yocto/,在该文件夹下使用如下命令:

curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
chmod a+x repo

获取Yocto项目

设置Yocto源

切换至Yocto工作路径/home/YourName/Yocto/,然后使用如下repo命令,获取Yocto项目(克隆NXP官方fsl-arm-yocto-bsp.git项目的imx-linux-zeus分支):

./repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b imx-linux-zeus -m imx-5.4.47-2.2.0.xml

注意:由于国内的原因,直接运行上面repo init命令时,会出现fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle的错误,这是因为repo运行时,会去google服务器请求最新版本,解决方式是在本地环境变量中指定repo服务器地址,可以使用清华的镜像源进行更新,即将如下内容复制到你的~/.bashrc里,并重启Ubuntu即可:

export REPO_URL="https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/"

输入上述命令./repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b imx-linux-zeus -m imx-5.4.47-2.2.0.xml后,会提示/usr/bin/env: ‘python’: No such file or directory,这是因为Ubuntu20.04中已经移除了python2的原因,直接使用的是Python3。因此,使用命令:

sudo rm -r /usr/bin/python
sudo ln -s /usr/bin/python3 /usr/bin/python

将python连接为Python3即可。再次输入:

获取Yocto版本(https://source.codeaurora.org废弃)

Yocto 3.0版本(使用)

./repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b imx-linux-zeus -m imx-5.4.47-2.2.0.xml

Yocto 3.1版本

./repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b imx-linux-dunfell -m imx-5.4.47-2.2.0.xml

Yocto 4.0版本

./repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b imx-linux-kirkstone -m imx-5.15.32-2.0.0.xml
获取Yocto版本(https://github.com/nxp-imx/imx-manifest)
./repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-zeus -m imx-5.4.70-2.3.11.xml

Yocto 3.1版本

./repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-dunfell -m imx-5.4.47-2.0.0.xml

Yocto 4.0版本

./repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-kirkstone -m imx-5.15.32-2.0.0.xml

获取Yocto项目

./repo sync

解压文件(B站离线教程使用,在线下载文件不需要这步)

下载的文件为3个文件,把三个文件组合在一起指令入如下

cat *.tar.gz.* >> downloads.tar.gz

解压 downloads.tar.gz

tar -zxvf downloads.tar.gz

解压 uboot-2016.tar.bz2
1.先用 bzip2 -df 解压 bz2 文件,解压之后原 bz2 文件会消失,不放心的话可以自己备份一下。
2、褪下外层 bz2 之后该怎么解压怎么解压。

bzip2 -df ./uboot-2016.tar.bz2
tar -xvf uboot-2016.tar

初始化Yocto构建目录

通过repo取了Yocto项目源码(NXP官方的index: imx-manifest.git项目的imx-linux-zeus分支)之后,还需要初始化Yocto构建目录,用于Yocto构建嵌入式Linux系统的工作环境(实际上是创建一些文件夹、初始化一些变量值,得到的配置文件,用于构建特定的嵌入式Linux发行版本)。 在repo获取的Yocto项目源码路径(/home/jason/Linux/Yocto/fsl-release-yocto)下,Freescales提供了imx-setup-release.sh脚本。该脚本用于初始化Yocto构建目录,该脚本语法如下:

DISTRO=<distro name> MACHINE=<machine name> source imx-setup-release.sh -b <build dir>

imx-setup-release.sh脚本运行时,需要输入3个主要参数:

DISTRO=fsl-imx-fb
MACHINE=imx6ull14x14evk #芯片型号
-b build

fsl-imx-fb 说明
framebuffer是出现在内核中的驱动程序的接口。他把显示设备抽象的映射到帧缓冲区——可以认为是显存!可以把它看成是显示内存的一个映像,将其映射到进程地址空间以后,就可以直接进行读写操作,并且写操作可以直接反应在屏幕上。

例如:
1.imx6ull14x14evk芯片

 DISTRO=fsl-imx-fb MACHINE=imx6ull14x14evk source imx-setup-release.sh -b build_imx6ull_fb

2.imx6dlsabresd芯片(使用)

 DISTRO=fsl-imx-fb MACHINE=imx6dlsabresd source imx-setup-release.sh -b build_imx6dl_fb

3.imx8mp芯片

DISTRO=fsl-imx-fb MACHINE=imx8mpevk source imx-setup-release.sh -b build_imx8_fb

4.imx8mp芯片

DISTRO=fsl-imx-xwayland MACHINE=imx8mpevk source imx-setup-release.sh -b build_imx8_xwayland/

文件说明

获取Yocto项目源码成功后,会在Yocto工作路径/home/jason/Linux/Yocto/fsl-release-yocto路径下得到imx-setup-release.sh、setup-environment、sources等文件。其中:

文件或文件夹说明
imx-setup-release.sh该脚本用于初始化Yocto构建嵌入式Linux系统工作环境。
setup-environment该脚本根据运行imx-setup-release.sh脚本时输入的参数,设置Yocto工作环境。
sources文件夹在该文件夹下存放了很多文件、源码以及编译工具,用于构建嵌入式Linux系统。
sources文件夹下文件说明
base该文件夹下主要存放了bblayers.confsetup-environment,构建Yocto工作环境时用到。
meta-browser提供了几种浏览器,如gnome、mozilla。
meta-clangC语言家族前端和LLVM编译器后端。
meta-freescale提供了一些基于Freescale ARM官方参考板的基础支持软件。
meta-freescalse-3rdparty第三方板卡支持软件。
meta-freescalse-distro图形后端驱动层,包括fsl-framebuffer,fsl-wayland,fsl-xwayland,fslc-framebuffer,fslc-wayland,fslc-x11,fslc-xwayland,当前驱动选择与芯片型号有关,不一定全部支持
meta-nxp-demo-experienceNXP官方提供的一些demo。
meta-openembeddedOE内核的一些集合,定义了构建Yocto使用到的一些工具软件。
meta-qt5QT5相关的软件。
meta-timesys提供Vigiles工具来查看和通知BSP漏洞。
pokyYocto的基础发行版,在此版本基础上进行构建自己的嵌入式Linux发行版。
meta-python2python2相关的软件。
meta-rustrust相关的软件。
meta-imx文件夹
sources/meta-imx 文件夹下文件说明
meta-bspmeta-fsl-arm, poky, meta-openembedded层的一些更新软件。
meta-sdkmeta-freescale-distros以及发行版的一些更新软件。
meta-ml机器学习相关的软件。

需要注意的是,对于i.MX板卡的配置,主要是在meta-imx以及meta-freescale中定义的,包括Linux内核、U-Boot以及一些板级硬件配置信息

BitBake构建系统

Yocto项目中,采用的是BitBake工具来构建嵌入式Linux系统的。通过repo获取了Yocto项目的同时,也一起获取BitBake工具,直接使用即可。使用BitBake的最主要目的是生成一些安装包、内核、SDK以及一个完整的嵌入式Linux发行版(包括:U-Boot、Kernel、Rootfs、DeviceTree)。这些安装包或目标文件就构成了一个完成的嵌入式Linux发行版,可以通过Freescale提供的工具,将其生成一个SD卡镜像文件,用于烧写至开发板中。

运行imx-setup-release.sh脚本后,会自动生成一个build文件夹,进入该文件夹,运行bitbake命令:

bitbake imx-image-multimedia

此镜像包含除QT5,OpenCV,机器学习软件包之外的所有软件包。git

bitbake imx-image-full

这是包括imx image multimedia,OpenCV,QT5,机器学习的镜像

BitBake 使用的命令行参数

BitBake 参数描述示例备注
<target>直接编译/执行一个 recipe bitbake core-image-minimal
-c <task> <target>执行某个 recipe 的某个任务bitbake -c build glibc示例表示执行 glibc 的 do_build 任务<task>表示要执行的任务:fetch 表示从 recipe 中定义的地址拉取软件到本地 compile 表示重新编译镜像或软件包deploy 表示部署镜像或软件包到目标 rootfs 内 cleanall 表示清空整个构建目录
-c listtasks <target>显示某个 recipe 可执行的任务bitbake -c listtasks glibc如果你不确定 target 支持哪些任务,就可以用 listtasks 来查询
-b <xx.bb>用BitBake直接执行这个.bb文件bitbake -b rtl8188eu-driver_0.1.bb单独编译 rtl8188eu-driver 任务
-k有错误发生时也继续构建
-e <target>显示当前的执行环境查找包的原路径:bitbake -e hello | grep ^SRC_URI 查找包的安装路径:bitbake -e hello | grep ^S=
-s显示所有食谱(recipes)的当前和首选版本bitbake -s | grep hello例如如果自己在一个Layer下面安装了一个hello.bb,可以查看 hello 这个 package 能否被 bitbake
-v显示执行过程
-vDDDD打印一些调试信息(v 后面可以加多个 D)bitbake -vDDDD -c build glibc
-g <target>显示一个包在 BitBake 时与其他包的依赖关系,生成依赖图bitbake -g glibc在当前目录生成一些文件:task-depends.dot(任务之间的依赖关系)package-depends.dot(运行时的目标依赖)pn-depends.dot(构建时的依赖)pn-buildlist(包含需要构建的任务列表)*.dot 文件可以通过 xdot 工具打开
使用举例1
1.    显示全局或每个配方环境有关变量所在位置的信息:
	# 查看源码目录:
	bitbake –e linux-renesas | grep ^S=   # ^S 首字母为S 
	# S="/home/zsj/rzg2/build/tmp/work-shared/smarc-rzg2l/kernel-source"
	bitbake –e u-boot | grep ^S=   
	# 查看源码 git 下载链接:
	bitbake -e linux-renesas | grep ^SRC_URI=
	bitbake -e u-boot | grep ^SRC_URI=
	# 查看源码编译工作目录:
	bitbake -e linux-renesas | grep ^WORKDIR=
	bitbake -e u-boot | grep ^WORKDIR=
2.    配置内核 menuconfig
bitbake linux-renesas -c menuconfig
3.    编译修改后的内核目录 (-C 为大写)
bitbake linux-renesas -C compile –f
4.    编译内核所需要的执行的任务:
bitbake linux-renesas -c listtasks
5.    显示图层
bitbake-layers show-layers
6.    强制执行操作,即使不需要
bitbake -f <target>
7.    显示更多调试信息
bitbake -DDD <target>
8.    清除单个目标
bitbake -c clean <recipe_name/target_name>      # 执行 do_clean 任务
bitbake -c cleanall <recipe_name/target_name>  # 轻易不要用这个,这个会将 downloads 的源文件删除
使用举例2

单独编译 kernel、模块、设备树
MYS-6ULX-IOT 开发板对应的 kernel 是 linux-mys6ulx:

$ bitbake -c menuconfig -f -v linux-mys6ulx
$ bitbake -c compile -f -v linux-mys6ulx
$ bitbake -c compile_kernelmodules -f -v linux-mys6ulx
$ bitbake -c deploy -f -v linux-mys6ulx

也有一些资料用 virtual/kernel 来指定 kernel,命令变成这样了:

$ bitbake -c menuconfig virtual/kernel
$ bitbake -c compile -f -v virtual/kernel
$ bitbake -c compile_kernelmodules -f -v virtual/kernel
$ bitbake -c deploy -f -v virtual/kernel

单独编译u-boot

$ bitbake -c compile -f -v u-boot-mys6ulx
$ bitbake -c deploy -f -v u-boot-mys6ulx

编译文件系统

$ bitbake core-image-minimal
$ bitbake core-image-base
$ bitbake fsl-image-gui
$ bitbake fsl-image-qt5
$ bitbake fsl-image-multimedia

清除编译结果

$ bitbake -c clean -v linux-mys6ulx

bitbake-layers 使用的命令行参数

BitBake提供了Layer管理工具,用来查看Layers的一些基本信息。使用方式如下:

$ bitbake-layers command [arguments]

可以使用的命令如下:

command说明
help帮助命令。
show-layers显示当前配置的Layer。
show-recipes显示可用的recipes以及recipes提供的layers。
show-overlayed显示覆盖的recipes。高优先级Layer中的recipe将覆盖其他低优先级Layer中相同的recipes。
show-appends显示.bbappend文件,以及对应的recipe文件。
show-cross-depends显示不同Layer中recipes的依赖关系。
  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
To compile Wayland-EGL in Yocto, you can follow these steps: 1. Add the necessary layers to your Yocto build. This may include the meta-openembedded layer, which contains the recipes for Wayland and other related packages. 2. Configure your build to include the Wayland-EGL packages. You can do this by adding the following lines to your local.conf file: ``` IMAGE_INSTALL_append = " wayland-protocols" IMAGE_INSTALL_append = " wayland-egl" ``` This will ensure that the Wayland-Protocols and Wayland-EGL packages are included in your Yocto image. 3. Build your Yocto image. You can do this by running the `bitbake` command with the name of your image, such as: ``` bitbake core-image-minimal ``` This will compile the necessary packages and dependencies, and generate a Yocto image that includes Wayland-EGL. 4. Configure your system to use Wayland-EGL as the default display server. You can do this by modifying the `weston.ini` file in your image's root filesystem. Add the following lines to the file: ``` [core] modules=eglbackend.so,desktop-shell.so [shell] background-image=/usr/share/backgrounds/gnome/Aqua.jpg panel-location=none ``` This will configure the Weston compositor to use EGL as the backend for rendering graphics. 5. Boot your Yocto image and test Wayland-EGL. You can do this by running a Wayland client application, such as `weston-terminal` or `weston-flower`. If everything is configured correctly, you should see the application window rendered using EGL. These are the basic steps for compiling Wayland-EGL in Yocto. However, the exact steps may vary depending on your specific Yocto setup and hardware platform. It's recommended to consult the Yocto documentation and community resources for more detailed instructions and troubleshooting tips.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值