文章描述:-2022年3月31日發(作者:申包胥)ZYQ:使?PetaLinux構建Linux項?參考?檔:環境安裝創建?錄:su rootmkdir optenvchown -R huangshuchao:embd optenv#chown -R huangshuchao:embd optenv# 2016.4以后的petalinux不能以超級權限去安裝,必須在$下安裝petalinux。tofrodo
-

ZYQ:使?PetaLinux構建Linux項?
參考?檔:
環境安裝
創建?錄:
su root
mkdir optenv
chown -R huangshuchao:embd optenv
#chown -R huangshuchao:embd optenv
# 2016.4以后的petalinux不能以超級權限去安裝,必須在$下安裝petalinux。
tofrodos iproute2 gawk gcc g++ git make net-tools libncurses5-dev tftpd zlib1g:i386 libssl-dev flex bison libselinux1 gnupg wget diffstat chrpath socat xterm autoconf libtool tar unzip texinfo zlib1g-dev gcc-multilib build-essential libsdl1.2-dev libgli
安裝
. optenvpetalinux2018.3
Ubuntu bash
dpkg-reconfigure dash
--> O
使?
每次都需要:
source optenvpetalinux2018.3
導?硬件
拷貝
design_1_wrapper_hw_platform_0
到Linux
創建項?
petalinux-create --type project --template zynq --name 項?名稱(?錄)
IFO: Create project: ax_peta
IFO: ew project successfully created in homehuangshuchaoax_peta
導?硬件信息
輸?以下命令:
硬件信息包:
design_1_wrapper_hw_platform_0_
(來?
13_vdma_to_qspi_sd
)
petalinux-config --get-hw-description ~hw-vivadodesign_1_wrapper_hw_platform_0_test
配置優化
我們這?再做?些優化?作,以?便我們的使?:
離線編譯
注意,修改鏡像時,填?的路徑是以
file:
開頭的。
-> Yocto Settings
## 設置緩存:SState cache
-> Local sstate feeds settings
-> local sstate feeds url ## 按 Enter
homexxsstage_package_for_petalinuxarm
-> Yocto Settings
## 設置鏡像:download mirror
-> Add pre-mirror url ## 按 Enter
file:homexxsstage_package_for_petalinuxdownloads
-> Yocto Settings
## 設置離線編譯
[ ] Enable etwork sstate feeds ## 按
[*] Enable BB O ETWORK ## 按 Y
啟動Linux時?動登錄
避免輸?賬號密碼。
-> Yocto Settings
[*] Enable Debug Tweaks ## 按 Y
不?動獲取IP地址
如果??存在時,可以考慮關閉?動獲取IP地址(會造成開機過慢)
-> Subsystem AUTO Hardware Settings (SUBSYSTEM_HARDWARE_AUTO [=y])
-> Ethernet Settings
Primary Ethernet ((ps7_ethernet_0) # 確認 存在此項
[ ] Obtain IP address automatically # 按下空格鍵取消,并設置?個IP
(192.168.168.168) Static IP address
(255.255.255.0) Static IP netmask (EW)
(192.168.168.1) Static IP gateway
u-boot Configuration --->
(192.168.168.1) TFTP Server IP addres # 設置TFTP服務器地址
修改?件系統類型(可選)
默認的?件系統類型會導致?件系統?法保存,?開始的時候可以保持默認,可以在后續修改為以下配置:
-> Image Packaging Configuration
-> Root filesystem type
-> Root filesystem type (SD card) --->
(devmmcblk0p2) Device node of SD device (EW)
保存退出,以下是提?信息:
IFO: Getting hardware description...
[IFO] generating Kconfig for project
[IFO] menuconfig project
*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.
[IFO] sourcing bitbake
[IFO] generating plnxtool conf
[IFO] generating meta-plnx-generated layer
[IFO] generating machine configuration
[IFO] generating bbappends for project . This may take time !
[IFO] generating u-boot configuration files
[IFO] generating kernel configuration files
[IFO] generating kconfig for Rootfs
[IFO] oldconfig rootfs
[IFO] generating
配置保護
保留Linux和UBoot源代碼
echo 'RM_WORK_EXCLUDE +=
echo 'RM_WORK_EXCLUDE +=
echo ''>> project-specmeta-userconf
原理:
_rm_work
中有對關鍵字進?解析,如果符合條件,那么不執?刪除操作。
配置uboot
petalinux-config -c u-boot
進?如下配置:
配置項值與說明
Boot mediaBoot介質,配置從SD卡啟動
delay in seconds before automatically bootingBoot?啟動時間,默認4s,可修改
Disable support for parallel OR flashOR flash?持,??持
add U-Boot environment variable versU-Boot環境變量添加,?
Display information about the CPU during start up啟動階段顯?CPU信息,可選
Display information about the board during start up啟動階段顯?板卡信息,可選
Command line interface命令?配置,?戶可進?步配置
Device Tree Control設備樹控制,保持默認配置(embeded)
配置內核
輸?:
petalinux-config -c kernel
以下是提?信息:
[IFO] generating Kconfig for project
[IFO] sourcing bitbake
[IFO] generating plnxtool conf
[IFO] generating meta-plnx-generated layer
[IFO] generating machine configuration
[IFO] configuring: kernel
[IFO] generating kernel configuration files
[IFO] bitbake virtualkernel -c menuconfig
Parsing recipes: 100% |##########################################| ETA: 0:00:56
Parsing of 2569 .bb files complete (0 cached, 2569 parsed). 3445 targets, 149 skipped, 0 masked, 0 errors.
OTE: Resolving any missing task queue dependencies
很快就會彈出Menuconfig菜單,選擇
COFIG_MICREL_PHY:
-> Device Drivers
-> etwork device support (ETDEVICES [=y])
-> PHY Device support and infrastructure (PHYLIB [=y])
[y] Micrel PHYs
保存,EXIT。
配置?件系統
petalinux-config -c rootfs
petalinux-config -c rootfs && petalinux-build
?更改,保存退出
編譯 uboot、內核、?件系統、設備樹
petalinux-build
此后,?成下?的?件
# ls imagelinux
.u-boot 4 2 zynq_ 2 3 st
?成
執?下?的代碼?成
petalinux-package --boot --fsbl .imageslinuxzynq_ --fpga .imageslinux --u-boot --force
下?的是提?信息:
IFO: Getting system flash information...
IFO: File in BOOT BI:
IFO: File in BOOT BI:
IFO: File in BOOT BI:
IFO: Generating Zynq binary package ...
****** Xilinx Bootgen v2018.3
**** Build date : ov 15 2018-19:22:29
** Copyright 1986-2018 Xilinx, Inc. All Rights Reserved.
IFO: Binary is ready.
?成
mkimage -f .imageslinux
測試
從
imagelinux
中拷貝:
、
,到SD卡即可。
創建項?的腳本
##
# Copyright By Schips, All Rights Reserved
# https:schips
#
# File ame: copy_petalinux_project_with_
# Created : 2020-07-25 11:28:24
#
##
#!binsh
# 項??程常見參數設置
## sstage包下載后設置
SSTATE_LOCAL_PATH=
## IP地址設置
ET=192.168.1
IPADDR=$ET.100
help () {
echo
echo
echo
exit 1
}
if [ -z
help
fi
if [ -z
help
fi
command -v petalinux-create >devnull 2>&1 || { echo >&2
command -v petalinux-config >devnull 2>&1 || { echo >&2
## 刪除源?錄
rm $1 -rf
## 創建項?
petalinux-create --type project --template zynq --name $1
PROJECT=$1
## 導?硬件信息
cd $PROJECT
petalinux-config --get-hw-description $2
## 使PetaLinux不刪除源碼
echo 'RM_WORK_EXCLUDE +=
echo 'RM_WORK_EXCLUDE +=
echo ''>> project-specmeta-userconf
# 刪除帶有指定關鍵字的?
delete_line_with_special_word ()
{
if [[ $# -lt 2 ]]; then
return
fi
FILE=$1
WORD=$2
sed -i
}
# ?件內容追加
append_line_into_file ()
{
if [[ $# -lt 2 ]]; then
return
fi
FILE=$1
LIE=$2
echo $LIE >> $FILE
}
COFIG=project-specconfigsconfig
cp $COFIG $
## ?絡設置
delete_line_with_special_word $COFIG COFIG_SUBSYSTEM_ETHERET_PS7_ETHERET_0_USE_DHCP
append_line_into_file $COFIG
append_line_into_file $COFIG
append_line_into_file $COFIG
append_line_into_file $COFIG
## 本地包
delete_line_with_special_word $COFIG COFIG_YOCTO_ETWORK_SSTATE_FEEDS
append_line_into_file $COFIG
delete_line_with_special_word $COFIG COFIG_YOCTO_BB_O_ETWORK
append_line_into_file $COFIG
delete_line_with_special_word $COFIG COFIG_PRE_MIRROR_URL
append_line_into_file $COFIG
delete_line_with_special_word $COFIG COFIG_YOCTO_LOCAL_SSTATE_FEEDS_URL
append_line_into_file $COFIG
## | ?錄 | 平臺 |
## | --------- | ----------- |
## | aarch64 | ZynqMP |
## | arm | Zynq |
## | mb-full | MB AXI |
## | mb-lite | MB AXI lite |
## | downloads | 全平臺 |
## 免輸?密碼登陸
delete_line_with_special_word $COFIG COFIG_YOCTO_EABLE_DEBUG_TWEAKS
append_line_into_file $COFIG
附錄:PetaLinux注意事項
導?項?創建項?以后,?程項?會確定當前路徑,所以需要注意,不要隨便改動?程路徑。
ERROR: OE-core's config sanity checker detected a potential misconfiguration.
Either fix the cause of this error or at your own risk disable the checker (see ).
Following is the list of potential problems advisories:
Error, TMPDIR has changed location. You need to either move it back to homehuangshuchaoax_1_design1hw0_retrybuildtmp or rebuild
不過可以通過拷貝petalinux?程的配置到另外的?錄,再build出那些臨時?件。
詳情見:
附錄: 構建各部分
petalinux-build -c kernel
petalinux-build -c device-tree
petalinux-build -c fsbl
petalinux-build -c u-boot
petalinux-package --boot --fsbl --fpga --u-boot --force
這樣在images?錄下就會?成我們需要的uImage、以及,為了確保設備樹修改完好,我們這?先反編譯?下設備樹,?成,查看??是否我們要修改的東西都已經修改好了(需要device-tree-compiler)。
在?件的?錄下運?
dtc -I dtb -O dts -o
打開,我們可以看到已經修改完畢
ZYQ:使?PetaLinux構建Linux項?
參考?檔:
環境安裝
創建?錄:
su root
mkdir optenv
chown -R huangshuchao:embd optenv
#chown -R huangshuchao:embd optenv
# 2016.4以后的petalinux不能以超級權限去安裝,必須在$下安裝petalinux。
tofrodos iproute2 gawk gcc g++ git make net-tools libncurses5-dev tftpd zlib1g:i386 libssl-dev flex bison libselinux1 gnupg wget diffstat chrpath socat xterm autoconf libtool tar unzip texinfo zlib1g-dev gcc-multilib build-essential libsdl1.2-dev libgli
安裝
. optenvpetalinux2018.3
Ubuntu bash
dpkg-reconfigure dash
--> O
使?
每次都需要:
source optenvpetalinux2018.3
導?硬件
拷貝
design_1_wrapper_hw_platform_0
到Linux
創建項?
petalinux-create --type project --template zynq --name 項?名稱(?錄)
IFO: Create project: ax_peta
IFO: ew project successfully created in homehuangshuchaoax_peta
導?硬件信息
輸?以下命令:
硬件信息包:
design_1_wrapper_hw_platform_0_
(來?
13_vdma_to_qspi_sd
)
petalinux-config --get-hw-description ~hw-vivadodesign_1_wrapper_hw_platform_0_test
配置優化
我們這?再做?些優化?作,以?便我們的使?:
離線編譯
注意,修改鏡像時,填?的路徑是以
file:
開頭的。
-> Yocto Settings
## 設置緩存:SState cache
-> Local sstate feeds settings
-> local sstate feeds url ## 按 Enter
homexxsstage_package_for_petalinuxarm
-> Yocto Settings
## 設置鏡像:download mirror
-> Add pre-mirror url ## 按 Enter
file:homexxsstage_package_for_petalinuxdownloads
-> Yocto Settings
## 設置離線編譯
[ ] Enable etwork sstate feeds ## 按
[*] Enable BB O ETWORK ## 按 Y
啟動Linux時?動登錄
避免輸?賬號密碼。
-> Yocto Settings
[*] Enable Debug Tweaks ## 按 Y
不?動獲取IP地址
如果??存在時,可以考慮關閉?動獲取IP地址(會造成開機過慢)
-> Subsystem AUTO Hardware Settings (SUBSYSTEM_HARDWARE_AUTO [=y])
-> Ethernet Settings
Primary Ethernet ((ps7_ethernet_0) # 確認 存在此項
[ ] Obtain IP address automatically # 按下空格鍵取消,并設置?個IP
(192.168.168.168) Static IP address
(255.255.255.0) Static IP netmask (EW)
(192.168.168.1) Static IP gateway
u-boot Configuration --->
(192.168.168.1) TFTP Server IP addres # 設置TFTP服務器地址
修改?件系統類型(可選)
默認的?件系統類型會導致?件系統?法保存,?開始的時候可以保持默認,可以在后續修改為以下配置:
-> Image Packaging Configuration
-> Root filesystem type
-> Root filesystem type (SD card) --->
(devmmcblk0p2) Device node of SD device (EW)
保存退出,以下是提?信息:
IFO: Getting hardware description...
[IFO] generating Kconfig for project
[IFO] menuconfig project
*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.
[IFO] sourcing bitbake
[IFO] generating plnxtool conf
[IFO] generating meta-plnx-generated layer
[IFO] generating machine configuration
[IFO] generating bbappends for project . This may take time !
[IFO] generating u-boot configuration files
[IFO] generating kernel configuration files
[IFO] generating kconfig for Rootfs
[IFO] oldconfig rootfs
[IFO] generating
配置保護
保留Linux和UBoot源代碼
echo 'RM_WORK_EXCLUDE +=
echo 'RM_WORK_EXCLUDE +=
echo ''>> project-specmeta-userconf
原理:
_rm_work
中有對關鍵字進?解析,如果符合條件,那么不執?刪除操作。
配置uboot
petalinux-config -c u-boot
進?如下配置:
配置項值與說明
Boot mediaBoot介質,配置從SD卡啟動
delay in seconds before automatically bootingBoot?啟動時間,默認4s,可修改
Disable support for parallel OR flashOR flash?持,??持
add U-Boot environment variable versU-Boot環境變量添加,?
Display information about the CPU during start up啟動階段顯?CPU信息,可選
Display information about the board during start up啟動階段顯?板卡信息,可選
Command line interface命令?配置,?戶可進?步配置
Device Tree Control設備樹控制,保持默認配置(embeded)
配置內核
輸?:
petalinux-config -c kernel
以下是提?信息:
[IFO] generating Kconfig for project
[IFO] sourcing bitbake
[IFO] generating plnxtool conf
[IFO] generating meta-plnx-generated layer
[IFO] generating machine configuration
[IFO] configuring: kernel
[IFO] generating kernel configuration files
[IFO] bitbake virtualkernel -c menuconfig
Parsing recipes: 100% |##########################################| ETA: 0:00:56
Parsing of 2569 .bb files complete (0 cached, 2569 parsed). 3445 targets, 149 skipped, 0 masked, 0 errors.
OTE: Resolving any missing task queue dependencies
很快就會彈出Menuconfig菜單,選擇
COFIG_MICREL_PHY:
-> Device Drivers
-> etwork device support (ETDEVICES [=y])
-> PHY Device support and infrastructure (PHYLIB [=y])
[y] Micrel PHYs
保存,EXIT。
配置?件系統
petalinux-config -c rootfs
petalinux-config -c rootfs && petalinux-build
?更改,保存退出
編譯 uboot、內核、?件系統、設備樹
petalinux-build
此后,?成下?的?件
# ls imagelinux
.u-boot 4 2 zynq_ 2 3 st
?成
執?下?的代碼?成
petalinux-package --boot --fsbl .imageslinuxzynq_ --fpga .imageslinux --u-boot --force
下?的是提?信息:
IFO: Getting system flash information...
IFO: File in BOOT BI:
IFO: File in BOOT BI:
IFO: File in BOOT BI:
IFO: Generating Zynq binary package ...
****** Xilinx Bootgen v2018.3
**** Build date : ov 15 2018-19:22:29
** Copyright 1986-2018 Xilinx, Inc. All Rights Reserved.
IFO: Binary is ready.
?成
mkimage -f .imageslinux
測試
從
imagelinux
中拷貝:
、
,到SD卡即可。
創建項?的腳本
##
# Copyright By Schips, All Rights Reserved
# https:schips
#
# File ame: copy_petalinux_project_with_
# Created : 2020-07-25 11:28:24
#
##
#!binsh
# 項??程常見參數設置
## sstage包下載后設置
SSTATE_LOCAL_PATH=
## IP地址設置
ET=192.168.1
IPADDR=$ET.100
help () {
echo
echo
echo
exit 1
}
if [ -z
help
fi
if [ -z
help
fi
command -v petalinux-create >devnull 2>&1 || { echo >&2
command -v petalinux-config >devnull 2>&1 || { echo >&2
## 刪除源?錄
rm $1 -rf
## 創建項?
petalinux-create --type project --template zynq --name $1
PROJECT=$1
## 導?硬件信息
cd $PROJECT
petalinux-config --get-hw-description $2
## 使PetaLinux不刪除源碼
echo 'RM_WORK_EXCLUDE +=
echo 'RM_WORK_EXCLUDE +=
echo ''>> project-specmeta-userconf
# 刪除帶有指定關鍵字的?
delete_line_with_special_word ()
{
if [[ $# -lt 2 ]]; then
return
fi
FILE=$1
WORD=$2
sed -i
}
# ?件內容追加
append_line_into_file ()
{
if [[ $# -lt 2 ]]; then
return
fi
FILE=$1
LIE=$2
echo $LIE >> $FILE
}
COFIG=project-specconfigsconfig
cp $COFIG $
## ?絡設置
delete_line_with_special_word $COFIG COFIG_SUBSYSTEM_ETHERET_PS7_ETHERET_0_USE_DHCP
append_line_into_file $COFIG
append_line_into_file $COFIG
append_line_into_file $COFIG
append_line_into_file $COFIG
## 本地包
delete_line_with_special_word $COFIG COFIG_YOCTO_ETWORK_SSTATE_FEEDS
append_line_into_file $COFIG
delete_line_with_special_word $COFIG COFIG_YOCTO_BB_O_ETWORK
append_line_into_file $COFIG
delete_line_with_special_word $COFIG COFIG_PRE_MIRROR_URL
append_line_into_file $COFIG
delete_line_with_special_word $COFIG COFIG_YOCTO_LOCAL_SSTATE_FEEDS_URL
append_line_into_file $COFIG
## | ?錄 | 平臺 |
## | --------- | ----------- |
## | aarch64 | ZynqMP |
## | arm | Zynq |
## | mb-full | MB AXI |
## | mb-lite | MB AXI lite |
## | downloads | 全平臺 |
## 免輸?密碼登陸
delete_line_with_special_word $COFIG COFIG_YOCTO_EABLE_DEBUG_TWEAKS
append_line_into_file $COFIG
附錄:PetaLinux注意事項
導?項?創建項?以后,?程項?會確定當前路徑,所以需要注意,不要隨便改動?程路徑。
ERROR: OE-core's config sanity checker detected a potential misconfiguration.
Either fix the cause of this error or at your own risk disable the checker (see ).
Following is the list of potential problems advisories:
Error, TMPDIR has changed location. You need to either move it back to homehuangshuchaoax_1_design1hw0_retrybuildtmp or rebuild
不過可以通過拷貝petalinux?程的配置到另外的?錄,再build出那些臨時?件。
詳情見:
附錄: 構建各部分
petalinux-build -c kernel
petalinux-build -c device-tree
petalinux-build -c fsbl
petalinux-build -c u-boot
petalinux-package --boot --fsbl --fpga --u-boot --force
這樣在images?錄下就會?成我們需要的uImage、以及,為了確保設備樹修改完好,我們這?先反編譯?下設備樹,?成,查看??是否我們要修改的東西都已經修改好了(需要device-tree-compiler)。
在?件的?錄下運?
dtc -I dtb -O dts -o
打開,我們可以看到已經修改完畢
-

發表評論