当前位置: 首页 > news >正文

WSL2Linux 子系统(十三)

WSL 编译 yocto

Yocto 项目是一个开源项目,旨在帮助开发者创建定制的 Linux 发行版,尤其是用于嵌入式系统。它并不是一个完整的 Linux 发行版,而是一个工具集和框架,用于构建自定义的 Linux 系统。

Yocto 系统的特点:
灵活性:可以根据需要选择和定制软件包。
支持多种硬件平台:支持多种架构,如 ARM、x86、MIPS 等。
可重现性:通过使用配方(recipes)和元数据(metadata),可以确保构建过程的一致性。
社区和文档支持:有一个活跃的社区,提供丰富的文档和支持。

Yocto 优势:
高度定制化:用户可以根据需求选择所需的软件包。
优化:可以针对特定硬件进行优化,以提高性能和减少资源使用。
长期支持:提供长期支持(LTS),适合需要稳定版本的项目。
集成开发环境:提供完整的开发工具链,方便开发和调试。

Yocto 弊端:
学习曲线:对新手来说,Yocto 的学习曲线比较陡峭,需要掌握相对复杂的构建系统。
构建时间:从头构建整个系统可能需要较长时间,尤其是当软件包数量较多时。
配置复杂性:需要对配方和层(layers)有较深的理解,配置过程可能会比较繁琐。
依赖管理:处理依赖关系可能会变得复杂,特别是在大型项目中。

作者:炭烤毛蛋 ,点击博主了解更多。


提示: 编译 yocto 依赖包相对较多,某些情况需要科学上网。

文章目录

  • WSL 编译 yocto
  • 1 yocto 简介
  • 2. yocto 编译工具 BiBake
  • 3. yocto 编译错误
    • 3.1 缺少 zstd
    • 3.2 缺少 bzip2 chrpath diffstat pzstd 等依赖软件包
    • 3.3 编译参数错误
    • 3.4 系统语言非英文
    • 3.5 mke2fs 版本不匹配
  • 参考
  • 结语


1 yocto 简介

Yocto Project 是一个专注于嵌入式 Linux® 操作系统开发的开源协作项目,它提供灵活的工具集和开发环境,允许全球的嵌入式设备开发人员通过共享技术,软件堆栈,配置和用于创建这些定制的Linux映像的最佳实践进行协作。有关 Yocto 项目的更多信息,请参阅 Yocto Project 官网:www.yoctoproject.org。 Yocto Project 官网上有 Yocto Project Reference Manual 和 Yocto Project Overview 等相关文档详细描述了如何构建系统。

Yocto Project Release layer 介绍
layer	路径	优先级(数字越大优先级越高)	描述
meta-oe	meta-openembedded/meta-oe	6	contains a large amount of additional recipes
meta-python	meta-openembedded/meta-python	7	Provide Python recipes
meta-qt5	meta-qt5	7	Provides QT5 recipes
meta-clang	meta-clang	7	clang compiler
meta-rockchip	meta-rockchip	9	Rockchip board level support available
meta	meta	5	Contains the OpenEmbedded-Core metadata
meta-poky	meta-poky	5	Holds the configuration for the Poky reference distribution
meta-yocto-bsp	meta-yocto-bsp	5	Configuration for the Yocto Project reference hardware board support package.
meta-chromium	meta-chromium	7	Provide chromium browser recipe

2. yocto 编译工具 BiBake

BitBake 是一个通用任务执行引擎,它允许 shell 和 Python 任务高效并行运行,同时在复杂的任务间依赖约束下工作。 BitBake 的主要用户之一 OpenEmbedded,利用这个核心并使用面向任务的方法构建嵌入式 Linux 软件堆栈。BitBake 官方文档

bitbake <target> <paramater>
# e.g
bitbake u-boot-rockchip -c clean
bitbake u-boot-rockchipBitbake paramater	#描述
-c fetch	#拉取目标所需要的代码
-c clean	#清除目标的输出文件
-c cleanall	#删除目标所有输出文件、共享高速缓存(shared state cache)和源代码
-c compile -f	#使用此选项可在部署映像后强制重新编译,但不建议使用,除非 Yocto Project 不知道目标代码已经发生改变
-c listtasks	#列出目标定义的所有 target
  • 编译完整 core-image-minimal recipes
source oe-init-build-env
bitbake core-image-minimal
  • 编译 u-boot
bitbake u-boot-rockchip
  • 编译 kernel
bitbake linux-rockchip
  • 单模块编译
    单独编译部分 recipes 可以参考以下,以单独编译 rkmpp、librga为例。
# 单独编译 mpp (rockchip 平台 rockchip-mpp )
bitbake rockchip-mpp# 单独编译 rga (rockchip 平台 rockchip-librga)
bitbake rockchip-librga
  • 参看更多编译对象
bitbake -s rockchip-mpp rockchip-librga

编译生成的固件位于目录 <path/to/yocto>/build/tmp/deploy/images/<board>/core-image-minimal
默认登录账号密码为: root

3. yocto 编译错误

3.1 缺少 zstd

ERROR: The following required tools (as specified by HOSTTOOLS) appear to be unavailable in PATH, please install them in order to proceed:chrpath diffstat pzstd zstd

Install the required environment packages

sudo apt install zstd

3.2 缺少 bzip2 chrpath diffstat pzstd 等依赖软件包

ERROR: Running /home/zero/rv1126/device/rockchip/common/build-hooks/30-rootfs.sh - build_yocto failed!
ERROR: exit code 1 from line 29:"$SCRIPTS_DIR/check-yocto.sh"
ERROR: call stack:30-rootfs.sh: build_yocto(30)30-rootfs.sh: build_hook(244)build-helper: try_func(63)build-helper: try_hook(95)build-helper: source(173)30-rootfs.sh: main(267)ERROR: Logfile of failure stored in: /home/zero/rv1126/yocto/build/tmp/work/x86_64-linux/zstd-native/1.5.2-r0/temp/log.do_unpack.7919
NOTE: recipe zstd-native-1.5.2-r0: task do_unpack: Failed

相似日志日志如下。

ERROR: The following required tools (as specified by HOSTTOOLS) appear to be unavailable in PATH, please install them in order to proceed:bzip2 chrpath diffstat pzstd zstd

从错误日志分区,编译环境缺少相关依赖软件包。

sudo apt install bzip2 chrpath diffstat pzstd zstd -y

3.3 编译参数错误

ERROR: ExpansionError during parsing /home/zero/rv1126/yocto/build/../meta-rockchip/recipes-multimedia/rockchip-rkaiq/rockchip-rkaiq.bb
Traceback (most recent call last):File "Var <EXTRA_OECMAKE>", line 1, in <module>
bb.data_smart.ExpansionError: Failure expanding variable EXTRA_OECMAKE, expression was          -DARCH=${@bb.utils.contains('TUNE_FEATURES', 'aarch64', 'aarch64', 'arm', d)}     -DISP_HW_VERSION=-DISP_HW_V${@d.getVar('RK_ISP_VERSION').replace('.','')}     -DRKAIQ_TARGET_SOC=${@d.getVar('SOC_FAMILY').replace('rv1126','rv1109')}   which triggered exception AttributeError: 'NoneType' object has no attribute 'replace'
The variable dependency chain for the failure is: EXTRA_OECMAKE -> cmake_do_configureERROR: Parsing halted due to errors, see error messages aboveSummary: There were 2 WARNING messages.
Summary: There were 2 ERROR messages, returning a non-zero exit code.

与其相似日志如下:

WARNING: /home/zero/rv1126/yocto/build/../meta-rockchip/recipes-multimedia/rockchip-rkaiq/rockchip-rkaiq.bb: Exception during build_dependencies for cmake_do_configure
WARNING: /home/zero/rv1126/yocto/build/../meta-rockchip/recipes-multimedia/rockchip-rkaiq/rockchip-rkaiq.bb: Error during finalise of /home/zero/rv1126/yocto/build/../meta-rockchip/recipes-multimedia/rockchip-rkaiq/rockchip-rkaiq.bb
ERROR: ExpansionError during parsing /home/zero/rv1126/yocto/build/../meta-rockchip/recipes-multimedia/rockchip-rkaiq/rockchip-rkaiq.bb      | ETA:  0:00:04
Traceback (most recent call last):File "Var <EXTRA_OECMAKE>", line 1, in <module>
bb.data_smart.ExpansionError: Failure expanding variable EXTRA_OECMAKE, expression was          -DARCH=${@bb.utils.contains('TUNE_FEATURES', 'aarch64', 'aarch64', 'arm', d)}     -DISP_HW_VERSION=-DISP_HW_V${@d.getVar('RK_ISP_VERSION').replace('.','')}     -DRKAIQ_TARGET_SOC=${@d.getVar('SOC_FAMILY').replace('rv1126','rv1109')}   which triggered exception AttributeError: 'NoneType' object has no attribute 'replace'
The variable dependency chain for the failure is: EXTRA_OECMAKE -> cmake_do_configureERROR: Parsing halted due to errors, see error messages above
WARNING: /home/zero/rv1126/yocto/build/../poky/meta/recipes-graphics/xorg-xserver/xserver-xorg_21.1.7.bb: Error during finalise of /home/zero/rv1126/yocto/build/../poky/meta/recipes-graphics/xorg-xserver/xserver-xorg_21.1.7.bb

错误的根本原因是 RK_ISP_VERSION 或 SOC_FAMILY (或两者)没有设置或为 None。

EXTRA_OECMAKE += "\-DARCH=${@bb.utils.contains('TUNE_FEATURES', 'aarch64', 'aarch64', 'arm', d)} \-DISP_HW_VERSION=-DISP_HW_V${@d.getVar('RK_ISP_VERSION', True).replace('.', '') if d.getVar('RK_ISP_VERSION', True) else ''} \-DRKAIQ_TARGET_SOC=${@d.getVar('SOC_FAMILY', True).replace('rv1126', 'rv1109') if d.getVar('SOC_FAMILY', True) else ''} \"

3.4 系统语言非英文

locale-gen 未设置为英文 UTF-8格式

ERROR: exit code 1 from line 89:LANG=en_US.UTF-8 LANGUAGE=en_US.en LC_ALL=en_US.UTF-8 bitbake core-image-minimal -f -c rootfs -c image_complete -R conf/rksdk_override.conf
ERROR: call stack

解决方案

$ 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 python3-subunit mesa-common-dev zstd liblz4-tool file locales libacl1$ sudo locale-gen en_US.UTF-8

3.5 mke2fs 版本不匹配

Your mke2fs is too new: mke2fs 1.47.1 (20-May-2024)
Please downgrade it:
git clone https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git --depth 1 -b v1.46.6
cd e2fsprogs
./configure
sudo make install -j8 -k -i

解决方案,参照编译日志提示处理即可。

参考

docs.yoctoproject.org

结语

不枉博主详细讲解,欢迎订阅博主–炭烤毛蛋 。


http://www.mrgr.cn/news/55792.html

相关文章:

  • 原生小程序开发拓展能力组件|拓展组件库汇总(六)
  • [笔记] 关于CreateProcessWithLogonW函数创建进程
  • 智能安全配电装置在老旧建筑防火中的应用
  • 035_基于php助农生鲜销售系统的设计与实现
  • SpringBoot+MyBatis+MySQL项目基础搭建
  • SpringBoot篇(二、制作SpringBoot程序)
  • Mybatis 中<where>的用法注意事项(附Demo)
  • 商场楼宇室内导航系统
  • 不再手动处理繁琐任务!Python自动化方案梳理
  • 【力扣刷题实战】用队列实现栈
  • SpringBoot整合mybatisPlus实现批量插入并获取ID
  • 用docker Desktop 下载使用thingsboard/tb-gateway
  • 【Java面试——并发编程——相关类和关键字——Day4】
  • 华为OD机试 - 生成哈夫曼树(Python/JS/C/C++ 2024 D卷 100分)
  • 快快收藏!学习 Python 最常访问的10个网站
  • MyBatis-Plus中FieldFill理解与应用
  • 编程题 7-22 龟兔赛跑【PAT】
  • C++游戏开发:从基础到进阶
  • JavaWeb——Maven(6/8):依赖管理-依赖传递 (介绍、直接依赖与间接依赖、演示、排除依赖)
  • Java 分页实战详解
  • 保研推荐信模板
  • Unity地面检测、跳跃
  • 低功耗4G模组的小秘密:RSA算法示例驾到,通通闪开...
  • 一分钟运行DBT入门示例项目(Jaffle Shop)
  • 新的类Rufus应用可带来简单的Windows 11 24H2安装旁路
  • 【07】z检验