9. Yocto 工程编译指南
本章节介绍如何使用 yocto 工程编译出可以在魔方派3上烧录和运行的镜像。
9.1 主机要求
-
配置
-
x86 计算机
-
至少四核 CPU,例如 Intel i7-2600 @ 3.4 GHz(同等或更高配置)
-
300 GB 可用磁盘空间(swap分区 > 32 GB)
-
16 GB RAM
-
Ubuntu 22.04
-
-
工具
-
Git 1.8.3.1 或更高版本
-
Tar 1.28 或更高版本
-
Python 3.10.2 或更高版本
-
GCC 7.5 或更高版本
-
GNU Make 4.0 或更高版本
-
-
权限
运行一些命令需要 sudo 权限
提示要在 Microsoft Windows 或 Apple(®) macOS(®) 上搭 建运行 Ubuntu 22.04 的虚拟机 (VM),请参阅 Qualcomm Linux 虚拟机搭建指南。VM 上的代码编译是一个较慢的过程,可能需要几个小时。 建议使用 Ubuntu 主机进行编译。
9.2 Ubuntu 主机配置
必须设置 Ubuntu 主机,以确保安装并配置所需的软件工具以供使用。
-
安装以下软件包,准备好运行 Yocto 版本所需的主机环境:
sudo apt update
sudo apt install repo git-lfs 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 pylint xterm python3-subunit mesa-common-dev zstd liblz4-tool locales tar python-is-python3 file libxml-opml-simplegen-perl vim whiptail g++ -
设置语言区域(如果尚未设置):
sudo locale-gen en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8 -
更新 git 配置:
# Check if your identity is configured in .gitconfig
git config --get user.email
git config --get user.name
# Run the following commands if you do not have your account identity set in .gitconfig
git config --global user.email <Your email ID>
git config --global user.name <"Your Name">
# Add the following UI color option for output of console (optional)
git config --global color.ui auto
# Add the following git configurations to fetch large size repositories and to avoid unreliable connections
git config --global http.postBuffer 1048576000
git config --global http.maxRequestBuffer 1048576000
git config --global http.lowSpeedLimit 0
git config --global http.lowSpeedTime 999999
9.3 代码同步
本部分使用安装在 Ubuntu 主机配置中的 Repo 工具,从 RUBIK Pi manifest 下载 git 存储库和其他属性。Repo 工具使用 repo init
命令下载 manifest。
下表显示了 Yocto 层到用于下载和编译 Qualcomm Linux 的 manifest release tag 的示例映射:
Yocto 层 | Manifest release tag | 参考发行版(DISTRO) |
---|---|---|
meta-qcom meta-qcom-hwe meta-qcom-distro meta-qcom-qim-product-sdk meta-rubikpi meta-rubikpi-extras meta-qt5 meta-ros | BSP build + QIMP SDK build: rubikpi-6.6.52-QLI.1.3-Ver.1.1_qim-product-sdk-1.1.2.xml | qcom-wayland |
-
manifest release tag 的语法:
rubikpi-<Linux LTS Kernel Version>-<distro>.<version>-Ver.<release>.xml
例如,manifest release tag
rubikpi-6.6.52-QLI.1.3-Ver.1.1.xml
表示以下内容:- 6.6.52:Qualcomm Linux 内核
- QLI.1.3: distro
- 1.1:里程碑发布版本
-
其他产品化 manifest 发布标记的语法:
rubikpi-<Linux LTS Kernel Version>-<distro>.<version>-Ver.<release>_<product/customization>-<release>.xml
例如,其他产品化 manifest 发布标记
rubikpi-6.6.52-QLI.1.3-Ver.1.1_qim-product-sdk-1.1.2.xml
表示以下内容:- 6.6.52:Qualcomm Linux 内核
- QLI.1.3: distro
- qim-product-sdk-1.1.2:基于 QLI.1.3 的 QIMP SDK 版本
- 其他产品/定制示例:
- 实时-linux-1.0
- 机器人-产品-sdk-1.1
- 1.0:里程碑发布版本
- 1.1:与里程碑发布版本相关的补丁发布版本
9.4 编译 QIMP SDK 镜像
Qualcomm® Intelligent Multimedia Product (QIMP)SDK 是四个独立功能 SDK 的集合,分别是 Qualcomm® Intelligent Multimedia SDK(IM SDK)、Qualcomm® Neural Processing SDK、Qualcomm® AI Engine Direct SDK 和 LiteRT。其中还包括可用于开发用例的示例程序。
有关详细信息,请参阅 QIMP SDK 快速入门指南。
-
下载 Qualcomm Yocto 和支持层:
信息<manifest release tag>
QIMP SDK build 与 BSP build 相同。在 BSP build 上克隆 QIMP SDK 层。# cd to directory where you have 300 GB of free storage space to create your workspaces
mkdir <WORKSPACE_DIR>
cd <WORKSPACE_DIR>
repo init -u https://github.com/rubikpi-ai/rubikpi-manifest -b qcom-linux-kirkstone -m <manifest release tag>
# Example, <manifest release tag> is rubikpi-6.6.52-QLI.1.3-Ver.1.1_qim-product-sdk-1.1.2.xml
# repo init -u https://github.com/rubikpi-ai/rubikpi-manifest -b qcom-linux-kirkstone -m rubikpi-6.6.52-QLI.1.3-Ver.1.1_qim-product-sdk-1.1.2.xml
repo sync -
编译软件镜像:
./rubikpi_build.sh
也可使用下面的 bitbake 命令对工程进行编译:
# 设置编译环境
export EXTRALAYERS="meta-qcom-qim-product-sdk"
export MACHINE=qcm6490-idp
export DISTRO=qcom-wayland
export FWZIP_PATH="`pwd`/src/vendor/thundercomm/prebuilt/BP-BINs"
source setup-environment_RUBIKPi
export BB_ENV_PASSTHROUGH_ADDITIONS="$BB_ENV_PASSTHROUGH_ADDITIONS FWZIP_PATH CUST_ID"
# 编译
bitbake qcom-multimedia-image
bitbake qcom-qim-product-sdk
9.5 打包和刷写
-
在代码根目录输入如下命令对编译好的镜像打包
./rubikpi_build.sh --zip_falt_build
-
打包完成后,在 <workspace_path>/rubikpi/output 目录下可找到已经打包好的镜像目录,和对应的压缩文件
-
参考 1.3.3 镜像烧录 小结进行镜像刷写
9.6 编译 eSDK
在 Github 中已经上传了预先编译好的 eSDK,下面说明 eSDK 具体的编译方法。
-
进入到 Yocto 工程根目录。
-
设置编译环境
export EXTRALAYERS="meta-qcom-qim-product-sdk"
export MACHINE=qcm6490-idp
export DISTRO=qcom-wayland
export FWZIP_PATH="`pwd`/src/vendor/thundercomm/prebuilt/BP-BINs"
source setup-environment_RUBIKPi
export BB_ENV_PASSTHROUGH_ADDITIONS="$BB_ENV_PASSTHROUGH_ADDITIONS FWZIP_PATH CUST_ID" -
编译 eSDK
bitbake -c do_populate_sdk_ext qcom-multimedia-image
-
编译完成后 eSDK 会在
<WORKSPACE_DIR>/build-qcom-wayland/tmp-glibc/deploy/sdk/
目录生成。它是一个独立的安装程序,可供对应用程序开 发感兴趣的用户使用,而无需进行完整的 BSP 编译。 -
安装 eSDK
qcom-wayland-x86_64-qcom-multimedia-image-armv8-2a-qcm6490-idp-toolchain-ext-1.3-ver.1.1.sh
出现提示时,输入要安装 eSDK 的文件系统路径。
例如,
/local/mnt/workspace/Platform_eSDK_plus_QIM
。