0. Environment set up
- PetaLinux relies on Python 2.7. It would ease the process by creating a Conda environment with Python 2.7 enabled and doing PetaLinux work in it.
- Sometime you should source the following file to run PetaLinux smoothly
$PetaLinux/components/yocto/source/arm/environment-setup-cortexa9t2hf-neon-xilinx-linux-gnueabi
1. Create a new project
petalinux-create -t project --template zynq -n $(project_name)
or
petalinux-create -t project -s $(bsp_file)
2. Import hardware information and configure
Refer to the directory where the .hdf
file is instead of the path to the .hdf
file.
petalinux-config --get-hw-description=$(path_to_hdf)
The following is a list of requirements for a Zynq hardware project to boot Linux (UG980):
- One Triple Timer Counter (TTC) (Required)
IMPORTANT:
If multiple TTCs are enabled, the Zynq Linux kernel uses the first TTC block from the device tree.
Please make sure the TTC is not used by others.- External memory controller with at least 32MB of memory (Required)
- UART for serial console (Required)
IMPORTANT: If soft IP is used, ensure the interrupt signal is connected- Non-volatile memory (Optional) e.g. QSPI Flash, SD/MMC
- Ethernet (Optional, essential for network access)
IMPORTANT: If soft IP is used, ensure the interrupt signal is connected
HDF文件是一个zip文件,可以直接使用7zip解压;也可以把后缀改为zip,使用其它工具解压。解压后可以得到文件design_1.hwh, design_1_bd.tcl, design_1_wrapper.bit, psu_init.c, psu_init.h, psu_init.html, psu_init.tcl, psu_init_gpl.c, psu_init_gpl.h, sysdef.xml。
- psu_init.c, psu_init.h是Vivado根据工程师配置的硬件信息,产生的C代码,会被编译进FSBL,用于初始化MPSoC的MIO,DDR等。
- design_1_bd.tcl是一个TCL脚本,Vivado可以执行这个脚本恢复整个Vivado工程。
- sysdef.xml,design_1_bd.tcl都含有工具版本信息,可以查看Vivado的版本。
2.1 Ethernet configuration
Subsystem AUTO Hardware Settings
Ethernet Settings
2.2 tftp server configuration
u-boot Configuration
TFTP server IP address
Image Packaging Configuration
tftpboot directory
2.3 Firmware information
Firmware Version Configuration
2.4 Change to boot from SD card
Image Packaging Configuration
Root filesystem type
SD card
3. Create a new application/module
petalinux-create -t apps -n $(app_name)
petalinux-create -t modules -n $(module_name)
The PL device tree is located at:
./components/plnx_workspace/device-tree/device-tree/pl.dtsi
4. Configure kernel
petalinux-config -c kernel
For DMA, may need to disable DMAS engine:
Device Drivers
DMA Engine support
Xilinx AXI DMAS Engine
. Uncheck the option. (per https://lauri.vosandi.com/hdl/zynq/xilinx-dma.html)
5. Configure rootfs
petalinux-config -c rootfs
Select modules/apps to be enabled:
apps
6. Build
petalinux-build
7. Create BOOT.bin
petalinux-package --boot --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/system.bit --u-boot --force
or
create a file, e.g., boot.bif
(UG1283)
image : {
[bootloader] images/linux/zynq_fsbl.elf
images/linux/system.bit
images/linux/u-boot.elf
}
And then, run command:
bootgen -image boot.bif -o i BOOT.BIN -w on
8. Boot file system from SD card
a) Change configuration if using standalone rootfs
When reading hardware configuration (petalinux-config --get-hw-description=xxx
)
Select Image Packaging Configuration
Root filesystem type
SD card
Or when configuring:
petalinux-config
Select Image Packaging Configuration
Root filesystem type
SD card
If using default rootfs, keep this option unchanged:
Image Packaging Configuration
Root filesystem type
INITRAMFS
b) Generate images
petalinux-build
petalinux-package --boot --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/system.bit --u-boot --force
c) Prepare SD card
cp /tftpboot/BOOT.BIN /media/$(username)/BOOT/.
cp /tftpboot/image.ub /media/$(username)/BOOT/.
cp /tftpboot/boot.scr /media/$(username)/BOOT/.
PetaLinux 2020.1 changed uboot so that it requires boot.scr also in the BOOT partition of the SD card.
If use rootfs images created by PetaLinux:
cp images/linux/rootfs.cpio /media/$(username)/rootfs
If use standalone rootfs:
sudo cp -a /path-to-compiled-rootfs/* /media/$(username)/rootfs/.
Then
petalinux-util --update-sdcard -d /media/$(username)/BOOT
Unmount and eject the SD card.
Reference
- UG980
- UG1144
- UG1157
- UG1283