PetaLinux環境下,也可以使用Yocto/openembedded的bitbake。Xilinx ug1144有詳細說明。
為了方便,我編寫了以下腳本,導入bitbake需要的環境。將下列腳本保存為sh文件,使用source導入,之后就能使用bitbake。腳本的第一個輸入參數是PetaLinux版本號,比如2019.2。如果source時沒有提供版本號,而系統有環境變量XILINX_VERSION,腳本就使用XILINX_VERSION作為PetaLinux版本號。如果source時沒有提供PetaLinux版本號,系統也沒有定義XILINX_VERSION,則缺省使用2019.2作為PetaLinux版本號。
#!/bin/bash
# hankf@xilinx.com echo -e "\nBegin to run script: $0" echo ""; # $1: the first argument could be Xilinx Petalinux version. if [ "$1" = "" ]; then if [ "$XILINX_VERSION" = "" ]; then XILINX_VERSION=2019.2 fi else XILINX_VERSION=$1 fi echo "Use Xilinx version: $XILINX_VERSION" export XILINX_VERSION # Xilinx UG1144 # Accessing BitBake in a Project # 1. Run petalinux-config or petalinux-config --oldconfig or petalinux-config --silentconfig at least once after creating the project, so that the required environment is setup. # 2. Source the PetaLinux tools script: # source /opt/Xilinx/peta/$XILINX_VERSION/settings.sh # 3. Source the Yocto e-SDK: source /opt/Xilinx/peta/$XILINX_VERSION/components/yocto/source/aarch64/environment-setup-aarch64-xilinx-linux source /opt/Xilinx/peta/$XILINX_VERSION/components/yocto/source/aarch64/layers/core/oe-init-build-env export PATH=/opt/Xilinx/peta/$XILINX_VERSION/tools/hsm/bin:$PATH export BB_ENV_EXTRAWHITE="$BB_ENV_EXTRAWHITE PETALINUX" # it will enter directory "build" # To test if the BitBake is available, run: # bitbake strace
在petalinux工程的目錄,使用source執行上述腳本后,會進入build目錄。這時可以執行各種bitbake命令,比如執行"bitbake strace"。
為了以后編譯PetaLinux編譯方便,或者為了創建離線編譯環境,可以通過bitbake命令提前下載編譯所需要的所有軟件包。Yocto 2.5使用命令“bitbake --runall=fetch”, 之前的版本使用命令“bitbake -c fetchall”。 根據 Yocto Project Mega-Manual 的31章,OpenEmbedded提供了一下target系統image的例子。下面是其中一些image的描述。
core-image-base: A console-only image that fully supports the target device hardware.
core-image-clutter: An image with support for the Open GL-based toolkit Clutter, which enables development of rich and animated graphical user interfaces.
core-image-minimal: A small image just capable of allowing a device to boot.
core-image-rt: A core-image-minimal image plus a real-time test suite and tools appropriate for real-time use.
core-image-sato: An image with Sato support, a mobile environment and visual style that works well with mobile devices. The image supports X11 with a Sato theme and applications such as a terminal, editor, file manager, media player, and so forth.
對於core-image-sato,使用命令“bitbake core-image-sato --runall=fetch”可以下載編譯core-image-sato所需要的所有軟件包。
hankf:~/zcu106_bsp_peta/build$
hankf:~/zcu106_bsp_peta/build$ bitbake core-image-sato --runall fetch
Loading cache: 100% |###########################################################################| Time: 0:00:01
Loaded 3980 entries from dependency cache.
Parsing recipes: 100% |#########################################################################| Time: 0:00:09
Parsing of 2894 .bb files complete (2893 cached, 1 parsed). 3981 targets, 164 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Initialising tasks: 100% |######################################################################| Time: 0:00:07
NOTE: Executing RunQueue Tasks
NOTE: Tasks Summary: Attempted 484 tasks of which 3 didn't need to be rerun and all succeeded.
Xilinx petalinux工程使用的配置名稱是petalinux-user-image,使用命令“bitbake petalinux-user-image --runall=fetch”可以下載編譯petalinux-user-image所需要的所有軟件包。
hankf:~/zcu106_bsp_peta/build$ bitbake petalinux-user-image --runall=fetch
Loading cache: 100% |############################################| Time: 0:00:00
Loaded 3980 entries from dependency cache.
Parsing recipes: 100% |##########################################| Time: 0:00:03
Parsing of 2894 .bb files complete (2893 cached, 1 parsed). 3981 targets, 164 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Initialising tasks: 100% |#######################################| Time: 0:00:01
NOTE: Executing RunQueue Tasks
NOTE: Tasks Summary: Attempted 252 tasks of which 252 didn't need to be rerun and all succeeded.
之后,可以在build/downloads目錄下可以看到大量的.tar.gz文件。把這些.tar.gz文件,拷貝到一個目錄,然后設置工程使用本地下載的文件。具體設置,可以參考 整合Xilinx PetaLinux工程編譯和Open Source U- Boot/Linux編譯.